aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util/client.c95
-rw-r--r--src/util/disk.c24
2 files changed, 69 insertions, 50 deletions
diff --git a/src/util/client.c b/src/util/client.c
index f656cc20f..0e6cf0a4f 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -56,7 +56,7 @@ struct GNUNET_CLIENT_TransmitHandle
56 GNUNET_CONNECTION_TransmitReadyNotify notify; 56 GNUNET_CONNECTION_TransmitReadyNotify notify;
57 57
58 /** 58 /**
59 * Closure for notify. 59 * Closure for @e notify.
60 */ 60 */
61 void *notify_cls; 61 void *notify_cls;
62 62
@@ -127,7 +127,7 @@ struct TransmitGetResponseContext
127 GNUNET_CLIENT_MessageHandler rn; 127 GNUNET_CLIENT_MessageHandler rn;
128 128
129 /** 129 /**
130 * Closure for "rn". 130 * Closure for @e rn.
131 */ 131 */
132 void *rn_cls; 132 void *rn_cls;
133}; 133};
@@ -287,7 +287,7 @@ try_unixpath (const char *service_name,
287 * 287 *
288 * @param service_name name of service to connect to 288 * @param service_name name of service to connect to
289 * @param cfg configuration to use 289 * @param cfg configuration to use
290 * @return GNUNET_OK if the configuration is valid, GNUNET_SYSERR if not 290 * @return #GNUNET_OK if the configuration is valid, #GNUNET_SYSERR if not
291 */ 291 */
292static int 292static int
293test_service_configuration (const char *service_name, 293test_service_configuration (const char *service_name,
@@ -330,7 +330,8 @@ test_service_configuration (const char *service_name,
330 */ 330 */
331static struct GNUNET_CONNECTION_Handle * 331static struct GNUNET_CONNECTION_Handle *
332do_connect (const char *service_name, 332do_connect (const char *service_name,
333 const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int attempt) 333 const struct GNUNET_CONFIGURATION_Handle *cfg,
334 unsigned int attempt)
334{ 335{
335 struct GNUNET_CONNECTION_Handle *connection; 336 struct GNUNET_CONNECTION_Handle *connection;
336 char *hostname; 337 char *hostname;
@@ -492,14 +493,14 @@ check_complete (struct GNUNET_CLIENT_Connection *client)
492 493
493/** 494/**
494 * Callback function for data received from the network. Note that 495 * Callback function for data received from the network. Note that
495 * both "available" and "errCode" would be 0 if the read simply timed out. 496 * both @a available and @a errCode would be 0 if the read simply timed out.
496 * 497 *
497 * @param cls closure 498 * @param cls closure
498 * @param buf pointer to received data 499 * @param buf pointer to received data
499 * @param available number of bytes availabe in "buf", 500 * @param available number of bytes availabe in @a buf,
500 * possibly 0 (on errors) 501 * possibly 0 (on errors)
501 * @param addr address of the sender 502 * @param addr address of the sender
502 * @param addrlen size of addr 503 * @param addrlen size of @a addr
503 * @param errCode value of errno (on errors receiving) 504 * @param errCode value of errno (on errors receiving)
504 */ 505 */
505static void 506static void
@@ -594,12 +595,13 @@ receive_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
594 * 595 *
595 * @param client the service 596 * @param client the service
596 * @param handler function to call with the message 597 * @param handler function to call with the message
597 * @param handler_cls closure for handler 598 * @param handler_cls closure for @a handler
598 * @param timeout how long to wait until timing out 599 * @param timeout how long to wait until timing out
599 */ 600 */
600void 601void
601GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *client, 602GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *client,
602 GNUNET_CLIENT_MessageHandler handler, void *handler_cls, 603 GNUNET_CLIENT_MessageHandler handler,
604 void *handler_cls,
603 struct GNUNET_TIME_Relative timeout) 605 struct GNUNET_TIME_Relative timeout)
604{ 606{
605 if (NULL == client->connection) 607 if (NULL == client->connection)
@@ -640,7 +642,7 @@ struct GNUNET_CLIENT_TestHandle
640 GNUNET_CLIENT_TestResultCallback cb; 642 GNUNET_CLIENT_TestResultCallback cb;
641 643
642 /** 644 /**
643 * Closure for 'cb'. 645 * Closure for @e cb.
644 */ 646 */
645 void *cb_cls; 647 void *cb_cls;
646 648
@@ -655,7 +657,7 @@ struct GNUNET_CLIENT_TestHandle
655 struct GNUNET_CLIENT_TransmitHandle *th; 657 struct GNUNET_CLIENT_TransmitHandle *th;
656 658
657 /** 659 /**
658 * Deadline for calling 'cb'. 660 * Deadline for calling @e cb.
659 */ 661 */
660 struct GNUNET_TIME_Absolute test_deadline; 662 struct GNUNET_TIME_Absolute test_deadline;
661 663
@@ -702,7 +704,7 @@ GNUNET_CLIENT_service_test_cancel (struct GNUNET_CLIENT_TestHandle *th)
702 * Task that reports back the result by calling the callback 704 * Task that reports back the result by calling the callback
703 * and then cleans up. 705 * and then cleans up.
704 * 706 *
705 * @param cls the 'struct GNUNET_CLIENT_TestHandle' 707 * @param cls the `struct GNUNET_CLIENT_TestHandle`
706 * @param tc scheduler context 708 * @param tc scheduler context
707 */ 709 */
708static void 710static void
@@ -736,7 +738,7 @@ service_test_report (struct GNUNET_CLIENT_TestHandle *th,
736/** 738/**
737 * Receive confirmation from test, service is up. 739 * Receive confirmation from test, service is up.
738 * 740 *
739 * @param cls closure with the 'struct GNUNET_CLIENT_TestHandle' 741 * @param cls closure with the `struct GNUNET_CLIENT_TestHandle`
740 * @param msg message received, NULL on timeout or fatal error 742 * @param msg message received, NULL on timeout or fatal error
741 */ 743 */
742static void 744static void
@@ -764,10 +766,10 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg)
764 * Send the 'TEST' message to the service. If successful, prepare to 766 * Send the 'TEST' message to the service. If successful, prepare to
765 * receive the reply. 767 * receive the reply.
766 * 768 *
767 * @param cls the 'struct GNUNET_CLIENT_TestHandle' of the test 769 * @param cls the `struct GNUNET_CLIENT_TestHandle` of the test
768 * @param size number of bytes available in buf 770 * @param size number of bytes available in @a buf
769 * @param buf where to write the message 771 * @param buf where to write the message
770 * @return number of bytes written to buf 772 * @return number of bytes written to @a buf
771 */ 773 */
772static size_t 774static size_t
773write_test (void *cls, size_t size, void *buf) 775write_test (void *cls, size_t size, void *buf)
@@ -807,14 +809,15 @@ write_test (void *cls, size_t size, void *buf)
807 * @param cfg configuration to use 809 * @param cfg configuration to use
808 * @param timeout how long to wait at most 810 * @param timeout how long to wait at most
809 * @param cb function to call with the result 811 * @param cb function to call with the result
810 * @param cb_cls closure for 'cb' 812 * @param cb_cls closure for @a cb
811 * @return handle to cancel the test 813 * @return handle to cancel the test
812 */ 814 */
813struct GNUNET_CLIENT_TestHandle * 815struct GNUNET_CLIENT_TestHandle *
814GNUNET_CLIENT_service_test (const char *service, 816GNUNET_CLIENT_service_test (const char *service,
815 const struct GNUNET_CONFIGURATION_Handle *cfg, 817 const struct GNUNET_CONFIGURATION_Handle *cfg,
816 struct GNUNET_TIME_Relative timeout, 818 struct GNUNET_TIME_Relative timeout,
817 GNUNET_CLIENT_TestResultCallback cb, void *cb_cls) 819 GNUNET_CLIENT_TestResultCallback cb,
820 void *cb_cls)
818{ 821{
819 struct GNUNET_CLIENT_TestHandle *th; 822 struct GNUNET_CLIENT_TestHandle *th;
820 char *hostname; 823 char *hostname;
@@ -836,13 +839,17 @@ GNUNET_CLIENT_service_test (const char *service,
836 839
837 unixpath = NULL; 840 unixpath = NULL;
838 if ((GNUNET_OK == 841 if ((GNUNET_OK ==
839 GNUNET_CONFIGURATION_get_value_filename (cfg, service, "UNIXPATH", &unixpath)) && 842 GNUNET_CONFIGURATION_get_value_filename (cfg,
843 service,
844 "UNIXPATH",
845 &unixpath)) &&
840 (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */ 846 (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */
841 { 847 {
842 if (strlen (unixpath) >= sizeof (s_un.sun_path)) 848 if (strlen (unixpath) >= sizeof (s_un.sun_path))
843 { 849 {
844 LOG (GNUNET_ERROR_TYPE_WARNING, 850 LOG (GNUNET_ERROR_TYPE_WARNING,
845 _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath, 851 _("UNIXPATH `%s' too long, maximum length is %llu\n"),
852 unixpath,
846 (unsigned long long) sizeof (s_un.sun_path)); 853 (unsigned long long) sizeof (s_un.sun_path));
847 unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath); 854 unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
848 LOG (GNUNET_ERROR_TYPE_INFO, 855 LOG (GNUNET_ERROR_TYPE_INFO,
@@ -851,6 +858,11 @@ GNUNET_CLIENT_service_test (const char *service,
851 } 858 }
852 if (NULL != unixpath) 859 if (NULL != unixpath)
853 { 860 {
861 if (GNUNET_OK !=
862 GNUNET_DISK_directory_create_for_file (unixpath))
863 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
864 "mkdir",
865 unixpath);
854 sock = GNUNET_NETWORK_socket_create (PF_UNIX, SOCK_STREAM, 0); 866 sock = GNUNET_NETWORK_socket_create (PF_UNIX, SOCK_STREAM, 0);
855 if (NULL != sock) 867 if (NULL != sock)
856 { 868 {
@@ -1001,7 +1013,7 @@ GNUNET_CLIENT_service_test (const char *service,
1001 * a transmission request. Either pass it on to our 1013 * a transmission request. Either pass it on to our
1002 * user or, if possible, retry. 1014 * user or, if possible, retry.
1003 * 1015 *
1004 * @param cls our "struct GNUNET_CLIENT_TransmissionHandle" 1016 * @param cls our `struct GNUNET_CLIENT_TransmissionHandle`
1005 * @param size number of bytes available for transmission 1017 * @param size number of bytes available for transmission
1006 * @param buf where to write them 1018 * @param buf where to write them
1007 * @return number of bytes written to buf 1019 * @return number of bytes written to buf
@@ -1014,11 +1026,12 @@ client_notify (void *cls, size_t size, void *buf);
1014 * This task is run if we should re-try connection to the 1026 * This task is run if we should re-try connection to the
1015 * service after a while. 1027 * service after a while.
1016 * 1028 *
1017 * @param cls our "struct GNUNET_CLIENT_TransmitHandle" of the request 1029 * @param cls our `struct GNUNET_CLIENT_TransmitHandle` of the request
1018 * @param tc unused 1030 * @param tc unused
1019 */ 1031 */
1020static void 1032static void
1021client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1033client_delayed_retry (void *cls,
1034 const struct GNUNET_SCHEDULER_TaskContext *tc)
1022{ 1035{
1023 struct GNUNET_CLIENT_TransmitHandle *th = cls; 1036 struct GNUNET_CLIENT_TransmitHandle *th = cls;
1024 struct GNUNET_TIME_Relative delay; 1037 struct GNUNET_TIME_Relative delay;
@@ -1033,7 +1046,9 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1033 return; 1046 return;
1034 } 1047 }
1035 th->client->connection = 1048 th->client->connection =
1036 do_connect (th->client->service_name, th->client->cfg, th->client->attempts++); 1049 do_connect (th->client->service_name,
1050 th->client->cfg,
1051 th->client->attempts++);
1037 th->client->first_message = GNUNET_YES; 1052 th->client->first_message = GNUNET_YES;
1038 if (NULL == th->client->connection) 1053 if (NULL == th->client->connection)
1039 { 1054 {
@@ -1073,10 +1088,10 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1073 * Connection notifies us about failure or success of a transmission 1088 * Connection notifies us about failure or success of a transmission
1074 * request. Either pass it on to our user or, if possible, retry. 1089 * request. Either pass it on to our user or, if possible, retry.
1075 * 1090 *
1076 * @param cls our "struct GNUNET_CLIENT_TransmissionHandle" 1091 * @param cls our `struct GNUNET_CLIENT_TransmissionHandle`
1077 * @param size number of bytes available for transmission 1092 * @param size number of bytes available for transmission
1078 * @param buf where to write them 1093 * @param buf where to write them
1079 * @return number of bytes written to buf 1094 * @return number of bytes written to @a buf
1080 */ 1095 */
1081static size_t 1096static size_t
1082client_notify (void *cls, size_t size, void *buf) 1097client_notify (void *cls, size_t size, void *buf)
@@ -1086,7 +1101,8 @@ client_notify (void *cls, size_t size, void *buf)
1086 size_t ret; 1101 size_t ret;
1087 struct GNUNET_TIME_Relative delay; 1102 struct GNUNET_TIME_Relative delay;
1088 1103
1089 LOG (GNUNET_ERROR_TYPE_DEBUG, "client_notify is running\n"); 1104 LOG (GNUNET_ERROR_TYPE_DEBUG,
1105 "client_notify is running\n");
1090 th->th = NULL; 1106 th->th = NULL;
1091 client->th = NULL; 1107 client->th = NULL;
1092 if (NULL == buf) 1108 if (NULL == buf)
@@ -1151,7 +1167,7 @@ client_notify (void *cls, size_t size, void *buf)
1151 * if the caller does not care about temporary connection errors, 1167 * if the caller does not care about temporary connection errors,
1152 * for example because the protocol is stateless 1168 * for example because the protocol is stateless
1153 * @param notify function to call 1169 * @param notify function to call
1154 * @param notify_cls closure for notify 1170 * @param notify_cls closure for @a notify
1155 * @return NULL if our buffer will never hold size bytes, 1171 * @return NULL if our buffer will never hold size bytes,
1156 * a handle if the notify callback was queued (can be used to cancel) 1172 * a handle if the notify callback was queued (can be used to cancel)
1157 */ 1173 */
@@ -1160,8 +1176,8 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *client,
1160 size_t size, 1176 size_t size,
1161 struct GNUNET_TIME_Relative timeout, 1177 struct GNUNET_TIME_Relative timeout,
1162 int auto_retry, 1178 int auto_retry,
1163 GNUNET_CONNECTION_TransmitReadyNotify 1179 GNUNET_CONNECTION_TransmitReadyNotify notify,
1164 notify, void *notify_cls) 1180 void *notify_cls)
1165{ 1181{
1166 struct GNUNET_CLIENT_TransmitHandle *th; 1182 struct GNUNET_CLIENT_TransmitHandle *th;
1167 1183
@@ -1213,8 +1229,7 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *client,
1213 * @param th handle from the original request. 1229 * @param th handle from the original request.
1214 */ 1230 */
1215void 1231void
1216GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHandle 1232GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHandle *th)
1217 *th)
1218{ 1233{
1219 if (GNUNET_SCHEDULER_NO_TASK != th->reconnect_task) 1234 if (GNUNET_SCHEDULER_NO_TASK != th->reconnect_task)
1220 { 1235 {
@@ -1234,17 +1249,19 @@ GNUNET_CLIENT_notify_transmit_ready_cancel (struct GNUNET_CLIENT_TransmitHandle
1234 1249
1235/** 1250/**
1236 * Function called to notify a client about the socket 1251 * Function called to notify a client about the socket
1237 * begin ready to queue the message. "buf" will be 1252 * begin ready to queue the message. @a buf will be
1238 * NULL and "size" zero if the socket was closed for 1253 * NULL and @a size zero if the socket was closed for
1239 * writing in the meantime. 1254 * writing in the meantime.
1240 * 1255 *
1241 * @param cls closure of type "struct TransmitGetResponseContext*" 1256 * @param cls closure of type "struct TransmitGetResponseContext*"
1242 * @param size number of bytes available in buf 1257 * @param size number of bytes available in @a buf
1243 * @param buf where the callee should write the message 1258 * @param buf where the callee should write the message
1244 * @return number of bytes written to buf 1259 * @return number of bytes written to @a buf
1245 */ 1260 */
1246static size_t 1261static size_t
1247transmit_for_response (void *cls, size_t size, void *buf) 1262transmit_for_response (void *cls,
1263 size_t size,
1264 void *buf)
1248{ 1265{
1249 struct TransmitGetResponseContext *tc = cls; 1266 struct TransmitGetResponseContext *tc = cls;
1250 uint16_t msize; 1267 uint16_t msize;
@@ -1286,8 +1303,8 @@ transmit_for_response (void *cls, size_t size, void *buf)
1286 * if the caller does not care about temporary connection errors, 1303 * if the caller does not care about temporary connection errors,
1287 * for example because the protocol is stateless 1304 * for example because the protocol is stateless
1288 * @param rn function to call with the response 1305 * @param rn function to call with the response
1289 * @param rn_cls closure for rn 1306 * @param rn_cls closure for @a rn
1290 * @return GNUNET_OK on success, GNUNET_SYSERR if a request 1307 * @return #GNUNET_OK on success, #GNUNET_SYSERR if a request
1291 * is already pending 1308 * is already pending
1292 */ 1309 */
1293int 1310int
diff --git a/src/util/disk.c b/src/util/disk.c
index 92c32e093..d0065734d 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -140,9 +140,9 @@ translate_unix_perms (enum GNUNET_DISK_AccessPermissions perm)
140 * Iterate over all files in the given directory and 140 * Iterate over all files in the given directory and
141 * accumulate their size. 141 * accumulate their size.
142 * 142 *
143 * @param cls closure of type "struct GetFileSizeData" 143 * @param cls closure of type `struct GetFileSizeData`
144 * @param fn current filename we are looking at 144 * @param fn current filename we are looking at
145 * @return GNUNET_SYSERR on serious errors, otherwise GNUNET_OK 145 * @return #GNUNET_SYSERR on serious errors, otherwise #GNUNET_OK
146 */ 146 */
147static int 147static int
148getSizeRec (void *cls, const char *fn) 148getSizeRec (void *cls, const char *fn)
@@ -187,7 +187,7 @@ getSizeRec (void *cls, const char *fn)
187 * Checks whether a handle is invalid 187 * Checks whether a handle is invalid
188 * 188 *
189 * @param h handle to check 189 * @param h handle to check
190 * @return GNUNET_YES if invalid, GNUNET_NO if valid 190 * @return #GNUNET_YES if invalid, #GNUNET_NO if valid
191 */ 191 */
192int 192int
193GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h) 193GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
@@ -204,7 +204,7 @@ GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h)
204 * 204 *
205 * @param fh open file handle 205 * @param fh open file handle
206 * @param size where to write size of the file 206 * @param size where to write size of the file
207 * @return GNUNET_OK on success, GNUNET_SYSERR on error 207 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
208 */ 208 */
209int 209int
210GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, 210GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
@@ -237,7 +237,7 @@ GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
237 * @param h handle of an open file 237 * @param h handle of an open file
238 * @param offset position to move to 238 * @param offset position to move to
239 * @param whence specification to which position the offset parameter relates to 239 * @param whence specification to which position the offset parameter relates to
240 * @return the new position on success, GNUNET_SYSERR otherwise 240 * @return the new position on success, #GNUNET_SYSERR otherwise
241 */ 241 */
242off_t 242off_t
243GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset, 243GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset,
@@ -282,13 +282,15 @@ GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle * h, off_t offset,
282 * of all sizes of files in the directory) 282 * of all sizes of files in the directory)
283 * @param include_symbolic_links should symbolic links be 283 * @param include_symbolic_links should symbolic links be
284 * included? 284 * included?
285 * @param single_file_mode GNUNET_YES to only get size of one file 285 * @param single_file_mode #GNUNET_YES to only get size of one file
286 * and return GNUNET_SYSERR for directories. 286 * and return #GNUNET_SYSERR for directories.
287 * @return GNUNET_SYSERR on error, GNUNET_OK on success 287 * @return #GNUNET_SYSERR on error, #GNUNET_OK on success
288 */ 288 */
289int 289int
290GNUNET_DISK_file_size (const char *filename, uint64_t * size, 290GNUNET_DISK_file_size (const char *filename,
291 int include_symbolic_links, int single_file_mode) 291 uint64_t * size,
292 int include_symbolic_links,
293 int single_file_mode)
292{ 294{
293 struct GetFileSizeData gfsd; 295 struct GetFileSizeData gfsd;
294 int ret; 296 int ret;
@@ -632,7 +634,7 @@ GNUNET_DISK_directory_test (const char *fil, int is_readable)
632 * (of a file that exists and that is not a directory). 634 * (of a file that exists and that is not a directory).
633 * 635 *
634 * @param fil filename to check 636 * @param fil filename to check
635 * @return #GNUNET_YES if yes, GNUNET_NO if not a file, #GNUNET_SYSERR if something 637 * @return #GNUNET_YES if yes, #GNUNET_NO if not a file, #GNUNET_SYSERR if something
636 * else (will print an error message in that case, too). 638 * else (will print an error message in that case, too).
637 */ 639 */
638int 640int