gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3187 - in GNUnet: . src/applications/getoption src/include


From: grothoff
Subject: [GNUnet-SVN] r3187 - in GNUnet: . src/applications/getoption src/include
Date: Sun, 30 Jul 2006 15:27:52 -0700 (PDT)

Author: grothoff
Date: 2006-07-30 15:27:51 -0700 (Sun, 30 Jul 2006)
New Revision: 3187

Modified:
   GNUnet/src/applications/getoption/clientapi.c
   GNUnet/src/applications/getoption/getoption.c
   GNUnet/src/applications/getoption/getoption.h
   GNUnet/src/include/gnunet_getoption_lib.h
   GNUnet/todo
Log:
getoption compiles

Modified: GNUnet/src/applications/getoption/clientapi.c
===================================================================
--- GNUnet/src/applications/getoption/clientapi.c       2006-07-30 22:19:34 UTC 
(rev 3186)
+++ GNUnet/src/applications/getoption/clientapi.c       2006-07-30 22:27:51 UTC 
(rev 3187)
@@ -34,9 +34,10 @@
 
 /**
  * Obtain option from a peer.
- * @return NULL on error
+ *
+ * @return NULL on error (for both option not set and internal errors)
  */
-char * getConfigurationOptionValue(GNUNET_TCP_SOCKET * sock,
+char * getConfigurationOptionValue(struct ClientServerConnection * sock,
                                   const char * section,
                                   const char * option) {
   CS_getoption_request_MESSAGE req;
@@ -56,20 +57,20 @@
         section);
   strcpy(&req.option[0],
         option);
-  res = writeToSocket(sock,
-                     &req.header);
+  res = connection_write(sock,
+                        &req.header);
   if (res != OK)
     return NULL;
   reply = NULL;
-  res = readFromSocket(sock,
-                      (CS_MESSAGE_HEADER**)&reply);
+  res = connection_read(sock,
+                       (MESSAGE_HEADER**)&reply);
   if (res != OK)
     return NULL;
-  ret = MALLOC(ntohs(reply->header.size) - sizeof(CS_MESSAGE_HEADER) + 1);
+  ret = MALLOC(ntohs(reply->header.size) - sizeof(MESSAGE_HEADER) + 1);
   memcpy(ret,
         &reply->value[0],
-        ntohs(reply->header.size) - sizeof(CS_MESSAGE_HEADER));
-  ret[ntohs(reply->header.size) - sizeof(CS_MESSAGE_HEADER)] = '\0';
+        ntohs(reply->header.size) - sizeof(MESSAGE_HEADER));
+  ret[ntohs(reply->header.size) - sizeof(MESSAGE_HEADER)] = '\0';
   FREE(reply);
   return ret;
 }

Modified: GNUnet/src/applications/getoption/getoption.c
===================================================================
--- GNUnet/src/applications/getoption/getoption.c       2006-07-30 22:19:34 UTC 
(rev 3186)
+++ GNUnet/src/applications/getoption/getoption.c       2006-07-30 22:27:51 UTC 
(rev 3187)
@@ -1,6 +1,6 @@
  /*
       This file is part of GNUnet
-      (C) 2005 Christian Grothoff (and other contributing authors)
+      (C) 2005, 2006 Christian Grothoff (and other contributing authors)
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
@@ -33,8 +33,8 @@
 
 static CoreAPIForApplication * coreAPI;
 
-static int handleGetOption(ClientHandle sock,
-                          const CS_MESSAGE_HEADER * message) {
+static int handleGetOption(struct ClientHandle * sock,
+                          const MESSAGE_HEADER * message) {
   CS_getoption_request_MESSAGE * req;
   CS_getoption_reply_MESSAGE * rep;
   char * val;
@@ -45,19 +45,17 @@
   req = (CS_getoption_request_MESSAGE*)message;
   req->section[CS_getoption_request_MESSAGE_OPT_LEN-1] = '\0';
   req->option[CS_getoption_request_MESSAGE_OPT_LEN-1] = '\0';
-  val = getConfigurationString(req->section,
-                              req->option);
-  if (val == NULL) {
-    int ival = getConfigurationInt(req->section,
-                                  req->option);
-    val = MALLOC(12);
-    SNPRINTF(val,
-            12,
-            "%d",
-            ival);
-  }
-  rep = MALLOC(sizeof(CS_MESSAGE_HEADER) + strlen(val) + 1);
-  rep->header.size = htons(sizeof(CS_MESSAGE_HEADER) + strlen(val) + 1);
+  val = NULL;
+  if ( (0 != GC_get_configuration_value_string(coreAPI->cfg,
+                                              req->section,
+                                              req->option,
+                                              NULL,
+                                              &val)) ||
+       (val == NULL) ) 
+    return SYSERR; /* signal error: option not set */
+
+  rep = MALLOC(sizeof(MESSAGE_HEADER) + strlen(val) + 1);
+  rep->header.size = htons(sizeof(MESSAGE_HEADER) + strlen(val) + 1);
   memcpy(rep->value,
         val,
         strlen(val)+1);
@@ -71,16 +69,20 @@
 
 int initialize_module_getoption(CoreAPIForApplication * capi) {
   coreAPI = capi;
-  LOG(LOG_DEBUG,
-      _("`%s' registering client handler %d\n"),
-      "getoption",
-      CS_PROTO_GET_OPTION_REQUEST);
+  GE_LOG(capi->ectx,
+        GE_INFO | GE_USER | GE_REQUEST,
+        _("`%s' registering client handler %d\n"),
+        "getoption",
+        CS_PROTO_GET_OPTION_REQUEST);
   capi->registerClientHandler(CS_PROTO_GET_OPTION_REQUEST,
                              &handleGetOption);
-  setConfigurationString("ABOUT",
-                        "getoption",
-                        _("allows clients to determine gnunetd's"
-                          " configuration"));
+  GE_ASSERT(capi->ectx,
+           0 == GC_set_configuration_value_string(capi->cfg,
+                                                  capi->ectx,
+                                                  "ABOUT",
+                                                  "getoption",
+                                                  _("allows clients to 
determine gnunetd's"
+                                                    " configuration")));
   return OK;
 }
 

Modified: GNUnet/src/applications/getoption/getoption.h
===================================================================
--- GNUnet/src/applications/getoption/getoption.h       2006-07-30 22:19:34 UTC 
(rev 3186)
+++ GNUnet/src/applications/getoption/getoption.h       2006-07-30 22:27:51 UTC 
(rev 3187)
@@ -1,5 +1,6 @@
  /*
       This file is part of GNUnet
+      (C) 2005, 2006 Christian Grothoff (and other contributing authors)
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
@@ -26,7 +27,7 @@
  * Request for option value.
  */
 typedef struct {
-  CS_MESSAGE_HEADER header;
+  MESSAGE_HEADER header;
   char section[CS_getoption_request_MESSAGE_OPT_LEN];
   char option[CS_getoption_request_MESSAGE_OPT_LEN];
 } CS_getoption_request_MESSAGE;
@@ -36,7 +37,7 @@
  * value is 0-terminated).
  */
 typedef struct {
-  CS_MESSAGE_HEADER header;
+  MESSAGE_HEADER header;
   char value[1];
 } CS_getoption_reply_MESSAGE;
 

Modified: GNUnet/src/include/gnunet_getoption_lib.h
===================================================================
--- GNUnet/src/include/gnunet_getoption_lib.h   2006-07-30 22:19:34 UTC (rev 
3186)
+++ GNUnet/src/include/gnunet_getoption_lib.h   2006-07-30 22:27:51 UTC (rev 
3187)
@@ -27,7 +27,7 @@
 #ifndef GNUNET_GETOPTION_LIB_H
 #define GNUNET_GETOPTION_LIB_H
 
-#include "gnunet_util.h"
+#include "gnunet_util_network_client.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -36,12 +36,11 @@
 #endif
 #endif
 
-
 /**
  * Obtain option value from a peer.
  * @return NULL on error
  */
-char * getConfigurationOptionValue(GNUNET_TCP_SOCKET * sock,
+char * getConfigurationOptionValue(struct ClientServerConnection * sock,
                                   const char * section,
                                   const char * option);
 

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-07-30 22:19:34 UTC (rev 3186)
+++ GNUnet/todo 2006-07-30 22:27:51 UTC (rev 3187)
@@ -26,8 +26,8 @@
     + needs testing, also likely to be missing features
   * applications:
     + fragmentation, identity,  pingpong, session, transport,
-      stats, topology_default, state compile
-    + for basics: advertising, bootstrap_http, getoption, traffic
+      stats, topology_default, state, getoption compile
+    + for basics: advertising, bootstrap_http, traffic
     + for fs: datastore, fs, gap, sqstore_sqlite
     + rest: sqstore_mysql, dht, chat, kvstore_sqlite, 
             sqstore_mysql, rpc, tbench, template, testbed, 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]