fix uninit variable causing crash on 0 value
[oweals/gnunet.git] / src / gns / test_gns_proxy.c
index 7411c9bc94c570655c7afbfe8bf68984bd6f6146..b381f5b4f9b6a23dfbdfc643845da0f4d014d3d6 100644 (file)
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 /**
  * @author Martin Schanzenbach
  */
 #include "platform.h"
+#if HAVE_CURL_CURL_H
 #include <curl/curl.h>
+#elif HAVE_GNURL_CURL_H
+#include <gnurl/curl.h>
+#endif
 #include <microhttpd.h>
 #include "gnunet_namestore_service.h"
 #include "gnunet_gns_service.h"
@@ -75,7 +79,7 @@ copy_buffer (void *ptr, size_t size, size_t nmemb, void *ctx)
 
   if (cbc->pos + size * nmemb > sizeof(cbc->buf))
     return 0;                   /* overflow */
-  memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
+  GNUNET_memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
   cbc->pos += size * nmemb;
   return size * nmemb;
 }
@@ -161,8 +165,7 @@ curl_main (void);
 
 
 static void
-curl_task (void *cls,
-         const struct GNUNET_SCHEDULER_TaskContext *tc)
+curl_task (void *cls)
 {
   curl_task_id = NULL;
   curl_main ();
@@ -242,11 +245,12 @@ curl_main ()
                                              NULL);
 }
 
+
 static void
-start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+start_curl (void *cls)
 {
   GNUNET_asprintf (&url,
-                  "http://%s:%d/hello_world",  
+                  "http://%s:%d/hello_world",
                   TEST_DOMAIN, PORT);
   curl = curl_easy_init ();
   curl_easy_setopt (curl, CURLOPT_URL, url);
@@ -265,12 +269,14 @@ start_curl (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   curl_main ();
 }
 
+
 static void
-disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+disco_ns (void* cls)
 {
   GNUNET_NAMESTORE_disconnect (namestore);
 }
 
+
 /**
  * Callback invoked from the namestore service once record is
  * created.
@@ -284,25 +290,27 @@ disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  *                specified target peer; NULL on error
  */
 static void
-commence_testing (void *cls, int32_t success, const char *emsg)
+commence_testing (void *cls,
+                 int32_t success,
+                 const char *emsg)
 {
   GNUNET_SCHEDULER_add_now (&disco_ns, NULL);
 
-  if ((emsg != NULL) && (GNUNET_YES != success))
+  if ( (emsg != NULL) && (GNUNET_YES != success) )
   {
     fprintf (stderr,
-            "NS failed to create record %s\n", emsg);
+            "NS failed to create record %s\n",
+            emsg);
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
 
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), start_curl, NULL);
-
+  curl_task_id =
+    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 
+                                 &start_curl, NULL);
 }
 
 
-
-
 /**
  * Function to keep the HTTP server running.
  */
@@ -311,8 +319,7 @@ mhd_main (void);
 
 
 static void
-mhd_task (void *cls,
-         const struct GNUNET_SCHEDULER_TaskContext *tc)
+mhd_task (void *cls)
 {
   mhd_task_id = NULL;
   MHD_run (mhd);
@@ -475,4 +482,3 @@ main (int argc, char *const *argv)
 }
 
 /* end of test_gns_vpn.c */
-