diff options
Diffstat (limited to 'src/gns/gnocksy/gnocksy.c')
-rw-r--r-- | src/gns/gnocksy/gnocksy.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/gns/gnocksy/gnocksy.c b/src/gns/gnocksy/gnocksy.c index faccfa6d2..49b7d72bd 100644 --- a/src/gns/gnocksy/gnocksy.c +++ b/src/gns/gnocksy/gnocksy.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <regex.h> | 26 | #include <regex.h> |
27 | 27 | ||
28 | #include "protocol.h" | 28 | #include "protocol.h" |
29 | #include "gns_glue.h" | ||
29 | 30 | ||
30 | #define MAXEVENTS 64 | 31 | #define MAXEVENTS 64 |
31 | 32 | ||
@@ -40,12 +41,6 @@ | |||
40 | static struct MHD_Daemon *mhd_daemon; | 41 | static struct MHD_Daemon *mhd_daemon; |
41 | static regex_t re_dotplus; | 42 | static regex_t re_dotplus; |
42 | 43 | ||
43 | void | ||
44 | gns_glue_expand_and_shorten ( char* sorig, char* new ) | ||
45 | { | ||
46 | memcpy (new, "foo.bar.gnunet", strlen("foo.bar.gnunet")); | ||
47 | } | ||
48 | |||
49 | static size_t | 44 | static size_t |
50 | curl_write_data (void *buffer, size_t size, size_t nmemb, void* cls) | 45 | curl_write_data (void *buffer, size_t size, size_t nmemb, void* cls) |
51 | { | 46 | { |
@@ -60,6 +55,7 @@ curl_write_data (void *buffer, size_t size, size_t nmemb, void* cls) | |||
60 | char* plusptr; | 55 | char* plusptr; |
61 | char* p; | 56 | char* p; |
62 | char new_host[256]; | 57 | char new_host[256]; |
58 | char to_exp[256]; | ||
63 | uint64_t bytes_copied = 0; | 59 | uint64_t bytes_copied = 0; |
64 | 60 | ||
65 | char new_buf[CURL_MAX_WRITE_SIZE+1]; | 61 | char new_buf[CURL_MAX_WRITE_SIZE+1]; |
@@ -103,13 +99,17 @@ curl_write_data (void *buffer, size_t size, size_t nmemb, void* cls) | |||
103 | 99 | ||
104 | if (m[1].rm_so != -1) | 100 | if (m[1].rm_so != -1) |
105 | { | 101 | { |
106 | hostptr = p+m[1].rm_eo; | 102 | hostptr = p+m[1].rm_so; |
107 | if (DEBUG) | 103 | if (DEBUG) |
108 | printf ("Copying %d bytes.\n", (hostptr-p)); | 104 | printf ("Copying %d bytes.\n", (hostptr-p)); |
109 | memcpy (br->MHD_CURL_BUF+bytes_copied, p, (hostptr-p)); | 105 | memcpy (br->MHD_CURL_BUF+bytes_copied, p, (hostptr-p)); |
110 | bytes_copied += (hostptr-p); | 106 | bytes_copied += (hostptr-p); |
111 | memset (new_host, 0, sizeof(new_host)); | 107 | memset (new_host, 0, sizeof(new_host)); |
112 | gns_glue_expand_and_shorten ( br->full_url, | 108 | memset (to_exp, 0, sizeof (to_exp)); |
109 | memcpy (to_exp, hostptr, (m[1].rm_eo-m[1].rm_so)); | ||
110 | |||
111 | gns_glue_expand_and_shorten ( to_exp, | ||
112 | br->host, | ||
113 | new_host ); | 113 | new_host ); |
114 | if (DEBUG) | 114 | if (DEBUG) |
115 | { | 115 | { |
@@ -366,7 +366,7 @@ mhd_content_cb (void* cls, | |||
366 | return MHD_CONTENT_READER_END_OF_STREAM; | 366 | return MHD_CONTENT_READER_END_OF_STREAM; |
367 | } | 367 | } |
368 | pthread_mutex_unlock ( &br->m_done ); | 368 | pthread_mutex_unlock ( &br->m_done ); |
369 | 369 | ||
370 | pthread_mutex_lock ( &br->m_buf ); | 370 | pthread_mutex_lock ( &br->m_buf ); |
371 | if ( br->MHD_CURL_BUF_STATUS == BUF_WAIT_FOR_CURL ) | 371 | if ( br->MHD_CURL_BUF_STATUS == BUF_WAIT_FOR_CURL ) |
372 | { | 372 | { |
@@ -375,6 +375,8 @@ mhd_content_cb (void* cls, | |||
375 | return 0; | 375 | return 0; |
376 | } | 376 | } |
377 | 377 | ||
378 | |||
379 | |||
378 | if ( br->MHD_CURL_BUF_SIZE > max ) | 380 | if ( br->MHD_CURL_BUF_SIZE > max ) |
379 | { | 381 | { |
380 | printf("buffer in mhd response too small!\n"); | 382 | printf("buffer in mhd response too small!\n"); |
@@ -389,6 +391,7 @@ mhd_content_cb (void* cls, | |||
389 | memcpy ( buf, br->MHD_CURL_BUF, br->MHD_CURL_BUF_SIZE ); | 391 | memcpy ( buf, br->MHD_CURL_BUF, br->MHD_CURL_BUF_SIZE ); |
390 | } | 392 | } |
391 | br->MHD_CURL_BUF_STATUS = BUF_WAIT_FOR_CURL; | 393 | br->MHD_CURL_BUF_STATUS = BUF_WAIT_FOR_CURL; |
394 | curl_easy_pause (br->curl, CURLPAUSE_CONT); | ||
392 | pthread_mutex_unlock ( &br->m_buf ); | 395 | pthread_mutex_unlock ( &br->m_buf ); |
393 | 396 | ||
394 | return br->MHD_CURL_BUF_SIZE; | 397 | return br->MHD_CURL_BUF_SIZE; |