diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-09-28 00:56:33 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-09-28 00:56:33 +0200 |
commit | 31aee41701fa2cd92ec566bd459e3425ee1f0b7d (patch) | |
tree | 7a8e25a7eee5a0de025d6595041f96cf76a06278 /src/include | |
parent | 9388822eb43827ee4f343a881d86a6225beca939 (diff) | |
download | gnunet-31aee41701fa2cd92ec566bd459e3425ee1f0b7d.tar.gz gnunet-31aee41701fa2cd92ec566bd459e3425ee1f0b7d.zip |
handle arm -s completion nicely via signaling pipe
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_disk_lib.h | 189 | ||||
-rw-r--r-- | src/include/gnunet_os_lib.h | 134 | ||||
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 195 | ||||
-rw-r--r-- | src/include/gnunet_service_lib.h | 92 |
4 files changed, 325 insertions, 285 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index d1e1e0333..9376a1059 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -38,7 +38,8 @@ struct GNUNET_DISK_PipeHandle; | |||
38 | /** | 38 | /** |
39 | * Type of a handle. | 39 | * Type of a handle. |
40 | */ | 40 | */ |
41 | enum GNUNET_FILE_Type { | 41 | enum GNUNET_FILE_Type |
42 | { | ||
42 | /** | 43 | /** |
43 | * Handle represents an event. | 44 | * Handle represents an event. |
44 | */ | 45 | */ |
@@ -58,7 +59,8 @@ enum GNUNET_FILE_Type { | |||
58 | /** | 59 | /** |
59 | * Handle used to access files (and pipes). | 60 | * Handle used to access files (and pipes). |
60 | */ | 61 | */ |
61 | struct GNUNET_DISK_FileHandle { | 62 | struct GNUNET_DISK_FileHandle |
63 | { | ||
62 | /** | 64 | /** |
63 | * File handle on Unix-like systems. | 65 | * File handle on Unix-like systems. |
64 | */ | 66 | */ |
@@ -86,7 +88,8 @@ extern "C" | |||
86 | /** | 88 | /** |
87 | * Specifies how a file should be opened. | 89 | * Specifies how a file should be opened. |
88 | */ | 90 | */ |
89 | enum GNUNET_DISK_OpenFlags { | 91 | enum GNUNET_DISK_OpenFlags |
92 | { | ||
90 | /** | 93 | /** |
91 | * Open the file for reading | 94 | * Open the file for reading |
92 | */ | 95 | */ |
@@ -126,7 +129,8 @@ enum GNUNET_DISK_OpenFlags { | |||
126 | /** | 129 | /** |
127 | * Specifies what type of memory map is desired. | 130 | * Specifies what type of memory map is desired. |
128 | */ | 131 | */ |
129 | enum GNUNET_DISK_MapType { | 132 | enum GNUNET_DISK_MapType |
133 | { | ||
130 | /** | 134 | /** |
131 | * Read-only memory map. | 135 | * Read-only memory map. |
132 | */ | 136 | */ |
@@ -147,7 +151,8 @@ enum GNUNET_DISK_MapType { | |||
147 | /** | 151 | /** |
148 | * File access permissions, UNIX-style. | 152 | * File access permissions, UNIX-style. |
149 | */ | 153 | */ |
150 | enum GNUNET_DISK_AccessPermissions { | 154 | enum GNUNET_DISK_AccessPermissions |
155 | { | ||
151 | /** | 156 | /** |
152 | * Nobody is allowed to do anything to the file. | 157 | * Nobody is allowed to do anything to the file. |
153 | */ | 158 | */ |
@@ -204,7 +209,8 @@ enum GNUNET_DISK_AccessPermissions { | |||
204 | * Constants for specifying how to seek. Do not change values or order, | 209 | * Constants for specifying how to seek. Do not change values or order, |
205 | * some of the code depends on the specific numeric values! | 210 | * some of the code depends on the specific numeric values! |
206 | */ | 211 | */ |
207 | enum GNUNET_DISK_Seek { | 212 | enum GNUNET_DISK_Seek |
213 | { | ||
208 | /** | 214 | /** |
209 | * Seek an absolute position (from the start of the file). | 215 | * Seek an absolute position (from the start of the file). |
210 | */ | 216 | */ |
@@ -225,7 +231,8 @@ enum GNUNET_DISK_Seek { | |||
225 | /** | 231 | /** |
226 | * Enumeration identifying the two ends of a pipe. | 232 | * Enumeration identifying the two ends of a pipe. |
227 | */ | 233 | */ |
228 | enum GNUNET_DISK_PipeEnd { | 234 | enum GNUNET_DISK_PipeEnd |
235 | { | ||
229 | /** | 236 | /** |
230 | * The reading-end of a pipe. | 237 | * The reading-end of a pipe. |
231 | */ | 238 | */ |
@@ -245,7 +252,7 @@ enum GNUNET_DISK_PipeEnd { | |||
245 | * @return #GNUNET_YES if invalid, #GNUNET_NO if valid | 252 | * @return #GNUNET_YES if invalid, #GNUNET_NO if valid |
246 | */ | 253 | */ |
247 | int | 254 | int |
248 | GNUNET_DISK_handle_invalid(const struct GNUNET_DISK_FileHandle *h); | 255 | GNUNET_DISK_handle_invalid (const struct GNUNET_DISK_FileHandle *h); |
249 | 256 | ||
250 | 257 | ||
251 | /** | 258 | /** |
@@ -257,7 +264,7 @@ GNUNET_DISK_handle_invalid(const struct GNUNET_DISK_FileHandle *h); | |||
257 | * else (will print an error message in that case, too). | 264 | * else (will print an error message in that case, too). |
258 | */ | 265 | */ |
259 | int | 266 | int |
260 | GNUNET_DISK_file_test(const char *fil); | 267 | GNUNET_DISK_file_test (const char *fil); |
261 | 268 | ||
262 | 269 | ||
263 | /** | 270 | /** |
@@ -268,7 +275,7 @@ GNUNET_DISK_file_test(const char *fil); | |||
268 | * @param fil name of the file to back up | 275 | * @param fil name of the file to back up |
269 | */ | 276 | */ |
270 | void | 277 | void |
271 | GNUNET_DISK_file_backup(const char *fil); | 278 | GNUNET_DISK_file_backup (const char *fil); |
272 | 279 | ||
273 | 280 | ||
274 | /** | 281 | /** |
@@ -279,8 +286,8 @@ GNUNET_DISK_file_backup(const char *fil); | |||
279 | * @return the new position on success, GNUNET_SYSERR otherwise | 286 | * @return the new position on success, GNUNET_SYSERR otherwise |
280 | */ | 287 | */ |
281 | off_t | 288 | off_t |
282 | GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, | 289 | GNUNET_DISK_file_seek (const struct GNUNET_DISK_FileHandle *h, off_t offset, |
283 | enum GNUNET_DISK_Seek whence); | 290 | enum GNUNET_DISK_Seek whence); |
284 | 291 | ||
285 | 292 | ||
286 | /** | 293 | /** |
@@ -298,10 +305,10 @@ GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, | |||
298 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 305 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
299 | */ | 306 | */ |
300 | int | 307 | int |
301 | GNUNET_DISK_file_size(const char *filename, | 308 | GNUNET_DISK_file_size (const char *filename, |
302 | uint64_t *size, | 309 | uint64_t *size, |
303 | int include_symbolic_links, | 310 | int include_symbolic_links, |
304 | int single_file_mode); | 311 | int single_file_mode); |
305 | 312 | ||
306 | 313 | ||
307 | /** | 314 | /** |
@@ -320,9 +327,9 @@ GNUNET_DISK_file_size(const char *filename, | |||
320 | * @return #GNUNET_OK on success | 327 | * @return #GNUNET_OK on success |
321 | */ | 328 | */ |
322 | int | 329 | int |
323 | GNUNET_DISK_file_get_identifiers(const char *filename, | 330 | GNUNET_DISK_file_get_identifiers (const char *filename, |
324 | uint64_t *dev, | 331 | uint64_t *dev, |
325 | uint64_t *ino); | 332 | uint64_t *ino); |
326 | 333 | ||
327 | 334 | ||
328 | /** | 335 | /** |
@@ -337,7 +344,7 @@ GNUNET_DISK_file_get_identifiers(const char *filename, | |||
337 | * file on disk in directory for temporary files | 344 | * file on disk in directory for temporary files |
338 | */ | 345 | */ |
339 | char * | 346 | char * |
340 | GNUNET_DISK_mktemp(const char *t); | 347 | GNUNET_DISK_mktemp (const char *t); |
341 | 348 | ||
342 | 349 | ||
343 | /** | 350 | /** |
@@ -350,7 +357,7 @@ GNUNET_DISK_mktemp(const char *t); | |||
350 | * @return NULL on error, otherwise name of freshly created directory | 357 | * @return NULL on error, otherwise name of freshly created directory |
351 | */ | 358 | */ |
352 | char * | 359 | char * |
353 | GNUNET_DISK_mkdtemp(const char *t); | 360 | GNUNET_DISK_mkdtemp (const char *t); |
354 | 361 | ||
355 | 362 | ||
356 | /** | 363 | /** |
@@ -366,9 +373,9 @@ GNUNET_DISK_mkdtemp(const char *t); | |||
366 | * @return IO handle on success, NULL on error | 373 | * @return IO handle on success, NULL on error |
367 | */ | 374 | */ |
368 | struct GNUNET_DISK_FileHandle * | 375 | struct GNUNET_DISK_FileHandle * |
369 | GNUNET_DISK_file_open(const char *fn, | 376 | GNUNET_DISK_file_open (const char *fn, |
370 | enum GNUNET_DISK_OpenFlags flags, | 377 | enum GNUNET_DISK_OpenFlags flags, |
371 | enum GNUNET_DISK_AccessPermissions perm); | 378 | enum GNUNET_DISK_AccessPermissions perm); |
372 | 379 | ||
373 | 380 | ||
374 | /** | 381 | /** |
@@ -379,8 +386,8 @@ GNUNET_DISK_file_open(const char *fn, | |||
379 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 386 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
380 | */ | 387 | */ |
381 | int | 388 | int |
382 | GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, | 389 | GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh, |
383 | off_t *size); | 390 | off_t *size); |
384 | 391 | ||
385 | 392 | ||
386 | /** | 393 | /** |
@@ -393,10 +400,10 @@ GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, | |||
393 | * @return handle to the new pipe, NULL on error | 400 | * @return handle to the new pipe, NULL on error |
394 | */ | 401 | */ |
395 | struct GNUNET_DISK_PipeHandle * | 402 | struct GNUNET_DISK_PipeHandle * |
396 | GNUNET_DISK_pipe(int blocking_read, | 403 | GNUNET_DISK_pipe (int blocking_read, |
397 | int blocking_write, | 404 | int blocking_write, |
398 | int inherit_read, | 405 | int inherit_read, |
399 | int inherit_write); | 406 | int inherit_write); |
400 | 407 | ||
401 | 408 | ||
402 | /** | 409 | /** |
@@ -410,9 +417,9 @@ GNUNET_DISK_pipe(int blocking_read, | |||
410 | * @return handle to the new pipe, NULL on error | 417 | * @return handle to the new pipe, NULL on error |
411 | */ | 418 | */ |
412 | struct GNUNET_DISK_PipeHandle * | 419 | struct GNUNET_DISK_PipeHandle * |
413 | GNUNET_DISK_pipe_from_fd(int blocking_read, | 420 | GNUNET_DISK_pipe_from_fd (int blocking_read, |
414 | int blocking_write, | 421 | int blocking_write, |
415 | int fd[2]); | 422 | int fd[2]); |
416 | 423 | ||
417 | 424 | ||
418 | /** | 425 | /** |
@@ -421,7 +428,7 @@ GNUNET_DISK_pipe_from_fd(int blocking_read, | |||
421 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 428 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
422 | */ | 429 | */ |
423 | int | 430 | int |
424 | GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p); | 431 | GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p); |
425 | 432 | ||
426 | 433 | ||
427 | /** | 434 | /** |
@@ -432,8 +439,8 @@ GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p); | |||
432 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 439 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
433 | */ | 440 | */ |
434 | int | 441 | int |
435 | GNUNET_DISK_pipe_close_end(struct GNUNET_DISK_PipeHandle *p, | 442 | GNUNET_DISK_pipe_close_end (struct GNUNET_DISK_PipeHandle *p, |
436 | enum GNUNET_DISK_PipeEnd end); | 443 | enum GNUNET_DISK_PipeEnd end); |
437 | 444 | ||
438 | 445 | ||
439 | /** | 446 | /** |
@@ -449,8 +456,8 @@ GNUNET_DISK_pipe_close_end(struct GNUNET_DISK_PipeHandle *p, | |||
449 | * (or if that end is not present or is closed). | 456 | * (or if that end is not present or is closed). |
450 | */ | 457 | */ |
451 | struct GNUNET_DISK_FileHandle * | 458 | struct GNUNET_DISK_FileHandle * |
452 | GNUNET_DISK_pipe_detach_end(struct GNUNET_DISK_PipeHandle *p, | 459 | GNUNET_DISK_pipe_detach_end (struct GNUNET_DISK_PipeHandle *p, |
453 | enum GNUNET_DISK_PipeEnd end); | 460 | enum GNUNET_DISK_PipeEnd end); |
454 | 461 | ||
455 | /** | 462 | /** |
456 | * Close an open file. | 463 | * Close an open file. |
@@ -459,7 +466,7 @@ GNUNET_DISK_pipe_detach_end(struct GNUNET_DISK_PipeHandle *p, | |||
459 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 466 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
460 | */ | 467 | */ |
461 | int | 468 | int |
462 | GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h); | 469 | GNUNET_DISK_file_close (struct GNUNET_DISK_FileHandle *h); |
463 | 470 | ||
464 | 471 | ||
465 | /** | 472 | /** |
@@ -470,8 +477,8 @@ GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h); | |||
470 | * @return handle for the respective end | 477 | * @return handle for the respective end |
471 | */ | 478 | */ |
472 | const struct GNUNET_DISK_FileHandle * | 479 | const struct GNUNET_DISK_FileHandle * |
473 | GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, | 480 | GNUNET_DISK_pipe_handle (const struct GNUNET_DISK_PipeHandle *p, |
474 | enum GNUNET_DISK_PipeEnd n); | 481 | enum GNUNET_DISK_PipeEnd n); |
475 | 482 | ||
476 | /** | 483 | /** |
477 | * Update POSIX permissions mask of a file on disk. If both argumets | 484 | * Update POSIX permissions mask of a file on disk. If both argumets |
@@ -483,9 +490,9 @@ GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, | |||
483 | * @param require_gid_match #GNUNET_YES means 770 unless @a require_uid_match is set | 490 | * @param require_gid_match #GNUNET_YES means 770 unless @a require_uid_match is set |
484 | */ | 491 | */ |
485 | void | 492 | void |
486 | GNUNET_DISK_fix_permissions(const char *fn, | 493 | GNUNET_DISK_fix_permissions (const char *fn, |
487 | int require_uid_match, | 494 | int require_uid_match, |
488 | int require_gid_match); | 495 | int require_gid_match); |
489 | 496 | ||
490 | 497 | ||
491 | /** | 498 | /** |
@@ -495,7 +502,7 @@ GNUNET_DISK_fix_permissions(const char *fn, | |||
495 | * @return file handle corresponding to the descriptor | 502 | * @return file handle corresponding to the descriptor |
496 | */ | 503 | */ |
497 | struct GNUNET_DISK_FileHandle * | 504 | struct GNUNET_DISK_FileHandle * |
498 | GNUNET_DISK_get_handle_from_int_fd(int fno); | 505 | GNUNET_DISK_get_handle_from_int_fd (int fno); |
499 | 506 | ||
500 | 507 | ||
501 | /** | 508 | /** |
@@ -505,7 +512,7 @@ GNUNET_DISK_get_handle_from_int_fd(int fno); | |||
505 | * @return file handle corresponding to the descriptor | 512 | * @return file handle corresponding to the descriptor |
506 | */ | 513 | */ |
507 | struct GNUNET_DISK_FileHandle * | 514 | struct GNUNET_DISK_FileHandle * |
508 | GNUNET_DISK_get_handle_from_native(FILE *fd); | 515 | GNUNET_DISK_get_handle_from_native (FILE *fd); |
509 | 516 | ||
510 | 517 | ||
511 | /** | 518 | /** |
@@ -517,9 +524,9 @@ GNUNET_DISK_get_handle_from_native(FILE *fd); | |||
517 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure | 524 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure |
518 | */ | 525 | */ |
519 | ssize_t | 526 | ssize_t |
520 | GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, | 527 | GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle *h, |
521 | void *result, | 528 | void *result, |
522 | size_t len); | 529 | size_t len); |
523 | 530 | ||
524 | 531 | ||
525 | /** | 532 | /** |
@@ -533,9 +540,9 @@ GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, | |||
533 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure | 540 | * @return the number of bytes read on success, #GNUNET_SYSERR on failure |
534 | */ | 541 | */ |
535 | ssize_t | 542 | ssize_t |
536 | GNUNET_DISK_file_read_non_blocking(const struct GNUNET_DISK_FileHandle * h, | 543 | GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h, |
537 | void *result, | 544 | void *result, |
538 | size_t len); | 545 | size_t len); |
539 | 546 | ||
540 | 547 | ||
541 | /** | 548 | /** |
@@ -547,9 +554,9 @@ GNUNET_DISK_file_read_non_blocking(const struct GNUNET_DISK_FileHandle * h, | |||
547 | * @return number of bytes read, #GNUNET_SYSERR on failure | 554 | * @return number of bytes read, #GNUNET_SYSERR on failure |
548 | */ | 555 | */ |
549 | ssize_t | 556 | ssize_t |
550 | GNUNET_DISK_fn_read(const char *fn, | 557 | GNUNET_DISK_fn_read (const char *fn, |
551 | void *result, | 558 | void *result, |
552 | size_t len); | 559 | size_t len); |
553 | 560 | ||
554 | 561 | ||
555 | /** | 562 | /** |
@@ -561,9 +568,9 @@ GNUNET_DISK_fn_read(const char *fn, | |||
561 | * @return number of bytes written on success, #GNUNET_SYSERR on error | 568 | * @return number of bytes written on success, #GNUNET_SYSERR on error |
562 | */ | 569 | */ |
563 | ssize_t | 570 | ssize_t |
564 | GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, | 571 | GNUNET_DISK_file_write (const struct GNUNET_DISK_FileHandle *h, |
565 | const void *buffer, | 572 | const void *buffer, |
566 | size_t n); | 573 | size_t n); |
567 | 574 | ||
568 | 575 | ||
569 | /** | 576 | /** |
@@ -575,9 +582,9 @@ GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, | |||
575 | * @return number of bytes written on success, #GNUNET_SYSERR on error | 582 | * @return number of bytes written on success, #GNUNET_SYSERR on error |
576 | */ | 583 | */ |
577 | ssize_t | 584 | ssize_t |
578 | GNUNET_DISK_file_write_blocking(const struct GNUNET_DISK_FileHandle *h, | 585 | GNUNET_DISK_file_write_blocking (const struct GNUNET_DISK_FileHandle *h, |
579 | const void *buffer, | 586 | const void *buffer, |
580 | size_t n); | 587 | size_t n); |
581 | 588 | ||
582 | 589 | ||
583 | /** | 590 | /** |
@@ -591,10 +598,10 @@ GNUNET_DISK_file_write_blocking(const struct GNUNET_DISK_FileHandle *h, | |||
591 | * @return number of bytes written on success, #GNUNET_SYSERR on error | 598 | * @return number of bytes written on success, #GNUNET_SYSERR on error |
592 | */ | 599 | */ |
593 | ssize_t | 600 | ssize_t |
594 | GNUNET_DISK_fn_write(const char *fn, | 601 | GNUNET_DISK_fn_write (const char *fn, |
595 | const void *buffer, | 602 | const void *buffer, |
596 | size_t n, | 603 | size_t n, |
597 | enum GNUNET_DISK_AccessPermissions mode); | 604 | enum GNUNET_DISK_AccessPermissions mode); |
598 | 605 | ||
599 | 606 | ||
600 | /** | 607 | /** |
@@ -605,8 +612,8 @@ GNUNET_DISK_fn_write(const char *fn, | |||
605 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 612 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
606 | */ | 613 | */ |
607 | int | 614 | int |
608 | GNUNET_DISK_file_copy(const char *src, | 615 | GNUNET_DISK_file_copy (const char *src, |
609 | const char *dst); | 616 | const char *dst); |
610 | 617 | ||
611 | 618 | ||
612 | /** | 619 | /** |
@@ -618,9 +625,9 @@ GNUNET_DISK_file_copy(const char *src, | |||
618 | * @return the number of files found, -1 on error | 625 | * @return the number of files found, -1 on error |
619 | */ | 626 | */ |
620 | int | 627 | int |
621 | GNUNET_DISK_directory_scan(const char *dir_name, | 628 | GNUNET_DISK_directory_scan (const char *dir_name, |
622 | GNUNET_FileNameCallback callback, | 629 | GNUNET_FileNameCallback callback, |
623 | void *callback_cls); | 630 | void *callback_cls); |
624 | 631 | ||
625 | 632 | ||
626 | /** | 633 | /** |
@@ -632,7 +639,7 @@ GNUNET_DISK_directory_scan(const char *dir_name, | |||
632 | * #GNUNET_NO if directory exists but is not writeable | 639 | * #GNUNET_NO if directory exists but is not writeable |
633 | */ | 640 | */ |
634 | int | 641 | int |
635 | GNUNET_DISK_directory_create_for_file(const char *filename); | 642 | GNUNET_DISK_directory_create_for_file (const char *filename); |
636 | 643 | ||
637 | 644 | ||
638 | /** | 645 | /** |
@@ -648,7 +655,7 @@ GNUNET_DISK_directory_create_for_file(const char *filename); | |||
648 | * does not exist or `stat`ed | 655 | * does not exist or `stat`ed |
649 | */ | 656 | */ |
650 | int | 657 | int |
651 | GNUNET_DISK_directory_test(const char *fil, int is_readable); | 658 | GNUNET_DISK_directory_test (const char *fil, int is_readable); |
652 | 659 | ||
653 | 660 | ||
654 | /** | 661 | /** |
@@ -659,7 +666,7 @@ GNUNET_DISK_directory_test(const char *fil, int is_readable); | |||
659 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 666 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
660 | */ | 667 | */ |
661 | int | 668 | int |
662 | GNUNET_DISK_directory_remove(const char *filename); | 669 | GNUNET_DISK_directory_remove (const char *filename); |
663 | 670 | ||
664 | 671 | ||
665 | /** | 672 | /** |
@@ -670,8 +677,8 @@ GNUNET_DISK_directory_remove(const char *filename); | |||
670 | * @param option option with the dir name to purge | 677 | * @param option option with the dir name to purge |
671 | */ | 678 | */ |
672 | void | 679 | void |
673 | GNUNET_DISK_purge_cfg_dir(const char *cfg_filename, | 680 | GNUNET_DISK_purge_cfg_dir (const char *cfg_filename, |
674 | const char *option); | 681 | const char *option); |
675 | 682 | ||
676 | 683 | ||
677 | /** | 684 | /** |
@@ -681,7 +688,7 @@ GNUNET_DISK_purge_cfg_dir(const char *cfg_filename, | |||
681 | * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise | 688 | * @returns #GNUNET_SYSERR on failure, #GNUNET_OK otherwise |
682 | */ | 689 | */ |
683 | int | 690 | int |
684 | GNUNET_DISK_directory_create(const char *dir); | 691 | GNUNET_DISK_directory_create (const char *dir); |
685 | 692 | ||
686 | 693 | ||
687 | /** | 694 | /** |
@@ -694,9 +701,9 @@ GNUNET_DISK_directory_create(const char *dir); | |||
694 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 701 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
695 | */ | 702 | */ |
696 | int | 703 | int |
697 | GNUNET_DISK_file_lock(struct GNUNET_DISK_FileHandle *fh, | 704 | GNUNET_DISK_file_lock (struct GNUNET_DISK_FileHandle *fh, |
698 | off_t lock_start, | 705 | off_t lock_start, |
699 | off_t lock_end, int excl); | 706 | off_t lock_end, int excl); |
700 | 707 | ||
701 | 708 | ||
702 | /** | 709 | /** |
@@ -708,9 +715,9 @@ GNUNET_DISK_file_lock(struct GNUNET_DISK_FileHandle *fh, | |||
708 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 715 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
709 | */ | 716 | */ |
710 | int | 717 | int |
711 | GNUNET_DISK_file_unlock(struct GNUNET_DISK_FileHandle *fh, | 718 | GNUNET_DISK_file_unlock (struct GNUNET_DISK_FileHandle *fh, |
712 | off_t unlock_start, | 719 | off_t unlock_start, |
713 | off_t unlock_end); | 720 | off_t unlock_end); |
714 | 721 | ||
715 | 722 | ||
716 | /** | 723 | /** |
@@ -718,7 +725,7 @@ GNUNET_DISK_file_unlock(struct GNUNET_DISK_FileHandle *fh, | |||
718 | * @param fn the filename to canonicalize | 725 | * @param fn the filename to canonicalize |
719 | */ | 726 | */ |
720 | void | 727 | void |
721 | GNUNET_DISK_filename_canonicalize(char *fn); | 728 | GNUNET_DISK_filename_canonicalize (char *fn); |
722 | 729 | ||
723 | 730 | ||
724 | /** | 731 | /** |
@@ -728,8 +735,8 @@ GNUNET_DISK_filename_canonicalize(char *fn); | |||
728 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 735 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
729 | */ | 736 | */ |
730 | int | 737 | int |
731 | GNUNET_DISK_file_change_owner(const char *filename, | 738 | GNUNET_DISK_file_change_owner (const char *filename, |
732 | const char *user); | 739 | const char *user); |
733 | 740 | ||
734 | 741 | ||
735 | /** | 742 | /** |
@@ -747,10 +754,10 @@ struct GNUNET_DISK_MapHandle; | |||
747 | * @return pointer to the mapped memory region, NULL on failure | 754 | * @return pointer to the mapped memory region, NULL on failure |
748 | */ | 755 | */ |
749 | void * | 756 | void * |
750 | GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, | 757 | GNUNET_DISK_file_map (const struct GNUNET_DISK_FileHandle *h, |
751 | struct GNUNET_DISK_MapHandle **m, | 758 | struct GNUNET_DISK_MapHandle **m, |
752 | enum GNUNET_DISK_MapType access, | 759 | enum GNUNET_DISK_MapType access, |
753 | size_t len); | 760 | size_t len); |
754 | 761 | ||
755 | 762 | ||
756 | /** | 763 | /** |
@@ -760,7 +767,7 @@ GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, | |||
760 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 767 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
761 | */ | 768 | */ |
762 | int | 769 | int |
763 | GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h); | 770 | GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h); |
764 | 771 | ||
765 | 772 | ||
766 | /** | 773 | /** |
@@ -770,7 +777,7 @@ GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h); | |||
770 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 777 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
771 | */ | 778 | */ |
772 | int | 779 | int |
773 | GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h); | 780 | GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h); |
774 | 781 | ||
775 | 782 | ||
776 | #if 0 /* keep Emacsens' auto-indent happy */ | 783 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index e5bc7146b..e4c0d6cdb 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h | |||
@@ -65,7 +65,8 @@ extern "C" | |||
65 | * Flags that determine which of the standard streams | 65 | * Flags that determine which of the standard streams |
66 | * should be inherited by the child process. | 66 | * should be inherited by the child process. |
67 | */ | 67 | */ |
68 | enum GNUNET_OS_InheritStdioFlags { | 68 | enum GNUNET_OS_InheritStdioFlags |
69 | { | ||
69 | /** | 70 | /** |
70 | * No standard streams should be inherited. | 71 | * No standard streams should be inherited. |
71 | */ | 72 | */ |
@@ -112,7 +113,8 @@ struct GNUNET_OS_Process; | |||
112 | /** | 113 | /** |
113 | * Possible installation paths to request | 114 | * Possible installation paths to request |
114 | */ | 115 | */ |
115 | enum GNUNET_OS_InstallationPathKind { | 116 | enum GNUNET_OS_InstallationPathKind |
117 | { | ||
116 | /** | 118 | /** |
117 | * Return the "PREFIX" directory given to configure. | 119 | * Return the "PREFIX" directory given to configure. |
118 | */ | 120 | */ |
@@ -166,7 +168,8 @@ enum GNUNET_OS_InstallationPathKind { | |||
166 | /** | 168 | /** |
167 | * Process status types | 169 | * Process status types |
168 | */ | 170 | */ |
169 | enum GNUNET_OS_ProcessStatusType { | 171 | enum GNUNET_OS_ProcessStatusType |
172 | { | ||
170 | /** | 173 | /** |
171 | * The process is not known to the OS (or at | 174 | * The process is not known to the OS (or at |
172 | * least not one of our children). | 175 | * least not one of our children). |
@@ -199,7 +202,8 @@ enum GNUNET_OS_ProcessStatusType { | |||
199 | * Project-specific data used to help the OS subsystem | 202 | * Project-specific data used to help the OS subsystem |
200 | * find installation paths. | 203 | * find installation paths. |
201 | */ | 204 | */ |
202 | struct GNUNET_OS_ProjectData { | 205 | struct GNUNET_OS_ProjectData |
206 | { | ||
203 | /** | 207 | /** |
204 | * Name of a library that is installed in the "lib/" directory of | 208 | * Name of a library that is installed in the "lib/" directory of |
205 | * the project, such as "libgnunetutil". Used to locate the | 209 | * the project, such as "libgnunetutil". Used to locate the |
@@ -290,14 +294,14 @@ struct GNUNET_OS_ProjectData { | |||
290 | * Return default project data used by 'libgnunetutil' for GNUnet. | 294 | * Return default project data used by 'libgnunetutil' for GNUnet. |
291 | */ | 295 | */ |
292 | const struct GNUNET_OS_ProjectData * | 296 | const struct GNUNET_OS_ProjectData * |
293 | GNUNET_OS_project_data_default(void); | 297 | GNUNET_OS_project_data_default (void); |
294 | 298 | ||
295 | 299 | ||
296 | /** | 300 | /** |
297 | * @return current (actual) project data. | 301 | * @return current (actual) project data. |
298 | */ | 302 | */ |
299 | const struct GNUNET_OS_ProjectData * | 303 | const struct GNUNET_OS_ProjectData * |
300 | GNUNET_OS_project_data_get(void); | 304 | GNUNET_OS_project_data_get (void); |
301 | 305 | ||
302 | 306 | ||
303 | /** | 307 | /** |
@@ -306,7 +310,7 @@ GNUNET_OS_project_data_get(void); | |||
306 | * @param pd project data used to determine paths. | 310 | * @param pd project data used to determine paths. |
307 | */ | 311 | */ |
308 | void | 312 | void |
309 | GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd); | 313 | GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd); |
310 | 314 | ||
311 | 315 | ||
312 | /** | 316 | /** |
@@ -318,7 +322,7 @@ GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd); | |||
318 | * @return a pointer to the dir path (to be freed by the caller) | 322 | * @return a pointer to the dir path (to be freed by the caller) |
319 | */ | 323 | */ |
320 | char * | 324 | char * |
321 | GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind); | 325 | GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); |
322 | 326 | ||
323 | 327 | ||
324 | /** | 328 | /** |
@@ -330,7 +334,7 @@ GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind); | |||
330 | * @return full path to the binary, if possible, otherwise copy of 'progname' | 334 | * @return full path to the binary, if possible, otherwise copy of 'progname' |
331 | */ | 335 | */ |
332 | char * | 336 | char * |
333 | GNUNET_OS_get_libexec_binary_path(const char *progname); | 337 | GNUNET_OS_get_libexec_binary_path (const char *progname); |
334 | 338 | ||
335 | 339 | ||
336 | /** | 340 | /** |
@@ -346,8 +350,8 @@ GNUNET_OS_get_libexec_binary_path(const char *progname); | |||
346 | * otherwise | 350 | * otherwise |
347 | */ | 351 | */ |
348 | char * | 352 | char * |
349 | GNUNET_OS_get_suid_binary_path(const struct GNUNET_CONFIGURATION_Handle *cfg, | 353 | GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg, |
350 | const char *progname); | 354 | const char *progname); |
351 | 355 | ||
352 | 356 | ||
353 | /** | 357 | /** |
@@ -379,14 +383,16 @@ typedef int | |||
379 | * @param proc_cls closure for @a proc | 383 | * @param proc_cls closure for @a proc |
380 | */ | 384 | */ |
381 | void | 385 | void |
382 | GNUNET_OS_network_interfaces_list(GNUNET_OS_NetworkInterfaceProcessor proc, | 386 | GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor proc, |
383 | void *proc_cls); | 387 | void *proc_cls); |
384 | 388 | ||
385 | /** | 389 | /** |
386 | * @brief Get maximum string length returned by gethostname() | 390 | * @brief Get maximum string length returned by gethostname() |
387 | */ | 391 | */ |
388 | #if HAVE_SYSCONF && defined(_SC_HOST_NAME_MAX) | 392 | #if HAVE_SYSCONF && defined(_SC_HOST_NAME_MAX) |
389 | #define GNUNET_OS_get_hostname_max_length() ({ int __sc_tmp = sysconf(_SC_HOST_NAME_MAX); __sc_tmp <= 0 ? 255 : __sc_tmp; }) | 393 | #define GNUNET_OS_get_hostname_max_length() ({ int __sc_tmp = sysconf ( \ |
394 | _SC_HOST_NAME_MAX); __sc_tmp <= \ | ||
395 | 0 ? 255 : __sc_tmp; }) | ||
390 | #elif defined(HOST_NAME_MAX) | 396 | #elif defined(HOST_NAME_MAX) |
391 | #define GNUNET_OS_get_hostname_max_length() HOST_NAME_MAX | 397 | #define GNUNET_OS_get_hostname_max_length() HOST_NAME_MAX |
392 | #else | 398 | #else |
@@ -403,7 +409,7 @@ GNUNET_OS_network_interfaces_list(GNUNET_OS_NetworkInterfaceProcessor proc, | |||
403 | * @return pointer to the process sturcutre for this process | 409 | * @return pointer to the process sturcutre for this process |
404 | */ | 410 | */ |
405 | struct GNUNET_OS_Process * | 411 | struct GNUNET_OS_Process * |
406 | GNUNET_OS_process_current(void); | 412 | GNUNET_OS_process_current (void); |
407 | 413 | ||
408 | 414 | ||
409 | /** | 415 | /** |
@@ -414,8 +420,8 @@ GNUNET_OS_process_current(void); | |||
414 | * @return 0 on success, -1 on error | 420 | * @return 0 on success, -1 on error |
415 | */ | 421 | */ |
416 | int | 422 | int |
417 | GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, | 423 | GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, |
418 | int sig); | 424 | int sig); |
419 | 425 | ||
420 | 426 | ||
421 | /** | 427 | /** |
@@ -424,7 +430,7 @@ GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, | |||
424 | * @param proc pointer to process structure | 430 | * @param proc pointer to process structure |
425 | */ | 431 | */ |
426 | void | 432 | void |
427 | GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc); | 433 | GNUNET_OS_process_destroy (struct GNUNET_OS_Process *proc); |
428 | 434 | ||
429 | 435 | ||
430 | /** | 436 | /** |
@@ -435,7 +441,7 @@ GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc); | |||
435 | * @return the current process id | 441 | * @return the current process id |
436 | */ | 442 | */ |
437 | pid_t | 443 | pid_t |
438 | GNUNET_OS_process_get_pid(struct GNUNET_OS_Process *proc); | 444 | GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc); |
439 | 445 | ||
440 | 446 | ||
441 | /** | 447 | /** |
@@ -451,13 +457,13 @@ GNUNET_OS_process_get_pid(struct GNUNET_OS_Process *proc); | |||
451 | * @return pointer to process structure of the new process, NULL on error | 457 | * @return pointer to process structure of the new process, NULL on error |
452 | */ | 458 | */ |
453 | struct GNUNET_OS_Process * | 459 | struct GNUNET_OS_Process * |
454 | GNUNET_OS_start_process_vap(int pipe_control, | 460 | GNUNET_OS_start_process_vap (int pipe_control, |
455 | enum GNUNET_OS_InheritStdioFlags std_inheritance, | 461 | enum GNUNET_OS_InheritStdioFlags std_inheritance, |
456 | struct GNUNET_DISK_PipeHandle *pipe_stdin, | 462 | struct GNUNET_DISK_PipeHandle *pipe_stdin, |
457 | struct GNUNET_DISK_PipeHandle *pipe_stdout, | 463 | struct GNUNET_DISK_PipeHandle *pipe_stdout, |
458 | struct GNUNET_DISK_PipeHandle *pipe_stderr, | 464 | struct GNUNET_DISK_PipeHandle *pipe_stderr, |
459 | const char *filename, | 465 | const char *filename, |
460 | char *const argv[]); | 466 | char *const argv[]); |
461 | 467 | ||
462 | 468 | ||
463 | /** | 469 | /** |
@@ -473,12 +479,12 @@ GNUNET_OS_start_process_vap(int pipe_control, | |||
473 | * @return pointer to process structure of the new process, NULL on error | 479 | * @return pointer to process structure of the new process, NULL on error |
474 | */ | 480 | */ |
475 | struct GNUNET_OS_Process * | 481 | struct GNUNET_OS_Process * |
476 | GNUNET_OS_start_process(int pipe_control, | 482 | GNUNET_OS_start_process (int pipe_control, |
477 | enum GNUNET_OS_InheritStdioFlags std_inheritance, | 483 | enum GNUNET_OS_InheritStdioFlags std_inheritance, |
478 | struct GNUNET_DISK_PipeHandle *pipe_stdin, | 484 | struct GNUNET_DISK_PipeHandle *pipe_stdin, |
479 | struct GNUNET_DISK_PipeHandle *pipe_stdout, | 485 | struct GNUNET_DISK_PipeHandle *pipe_stdout, |
480 | struct GNUNET_DISK_PipeHandle *pipe_stderr, | 486 | struct GNUNET_DISK_PipeHandle *pipe_stderr, |
481 | const char *filename, ...); | 487 | const char *filename, ...); |
482 | 488 | ||
483 | 489 | ||
484 | /** | 490 | /** |
@@ -494,12 +500,12 @@ GNUNET_OS_start_process(int pipe_control, | |||
494 | * @return pointer to process structure of the new process, NULL on error | 500 | * @return pointer to process structure of the new process, NULL on error |
495 | */ | 501 | */ |
496 | struct GNUNET_OS_Process * | 502 | struct GNUNET_OS_Process * |
497 | GNUNET_OS_start_process_va(int pipe_control, | 503 | GNUNET_OS_start_process_va (int pipe_control, |
498 | enum GNUNET_OS_InheritStdioFlags std_inheritance, | 504 | enum GNUNET_OS_InheritStdioFlags std_inheritance, |
499 | struct GNUNET_DISK_PipeHandle *pipe_stdin, | 505 | struct GNUNET_DISK_PipeHandle *pipe_stdin, |
500 | struct GNUNET_DISK_PipeHandle *pipe_stdout, | 506 | struct GNUNET_DISK_PipeHandle *pipe_stdout, |
501 | struct GNUNET_DISK_PipeHandle *pipe_stderr, | 507 | struct GNUNET_DISK_PipeHandle *pipe_stderr, |
502 | const char *filename, va_list va); | 508 | const char *filename, va_list va); |
503 | 509 | ||
504 | /** | 510 | /** |
505 | * Start a process. | 511 | * Start a process. |
@@ -514,11 +520,11 @@ GNUNET_OS_start_process_va(int pipe_control, | |||
514 | * @return pointer to process structure of the new process, NULL on error | 520 | * @return pointer to process structure of the new process, NULL on error |
515 | */ | 521 | */ |
516 | struct GNUNET_OS_Process * | 522 | struct GNUNET_OS_Process * |
517 | GNUNET_OS_start_process_v(int pipe_control, | 523 | GNUNET_OS_start_process_v (int pipe_control, |
518 | enum GNUNET_OS_InheritStdioFlags std_inheritance, | 524 | enum GNUNET_OS_InheritStdioFlags std_inheritance, |
519 | const SOCKTYPE *lsocks, | 525 | const SOCKTYPE *lsocks, |
520 | const char *filename, | 526 | const char *filename, |
521 | char *const argv[]); | 527 | char *const argv[]); |
522 | 528 | ||
523 | 529 | ||
524 | /** | 530 | /** |
@@ -540,10 +546,10 @@ GNUNET_OS_start_process_v(int pipe_control, | |||
540 | * @return pointer to process structure of the new process, NULL on error | 546 | * @return pointer to process structure of the new process, NULL on error |
541 | */ | 547 | */ |
542 | struct GNUNET_OS_Process * | 548 | struct GNUNET_OS_Process * |
543 | GNUNET_OS_start_process_s(int pipe_control, | 549 | GNUNET_OS_start_process_s (int pipe_control, |
544 | unsigned int std_inheritance, | 550 | unsigned int std_inheritance, |
545 | const SOCKTYPE * lsocks, | 551 | const SOCKTYPE *lsocks, |
546 | const char *filename, ...); | 552 | const char *filename, ...); |
547 | 553 | ||
548 | 554 | ||
549 | /** | 555 | /** |
@@ -568,7 +574,7 @@ typedef void | |||
568 | * @param cmd handle to the process | 574 | * @param cmd handle to the process |
569 | */ | 575 | */ |
570 | void | 576 | void |
571 | GNUNET_OS_command_stop(struct GNUNET_OS_CommandHandle *cmd); | 577 | GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd); |
572 | 578 | ||
573 | 579 | ||
574 | /** | 580 | /** |
@@ -583,11 +589,11 @@ GNUNET_OS_command_stop(struct GNUNET_OS_CommandHandle *cmd); | |||
583 | * @return NULL on error | 589 | * @return NULL on error |
584 | */ | 590 | */ |
585 | struct GNUNET_OS_CommandHandle * | 591 | struct GNUNET_OS_CommandHandle * |
586 | GNUNET_OS_command_run(GNUNET_OS_LineProcessor proc, | 592 | GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, |
587 | void *proc_cls, | 593 | void *proc_cls, |
588 | struct GNUNET_TIME_Relative timeout, | 594 | struct GNUNET_TIME_Relative timeout, |
589 | const char *binary, | 595 | const char *binary, |
590 | ...); | 596 | ...); |
591 | 597 | ||
592 | 598 | ||
593 | /** | 599 | /** |
@@ -600,9 +606,9 @@ GNUNET_OS_command_run(GNUNET_OS_LineProcessor proc, | |||
600 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise | 606 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise |
601 | */ | 607 | */ |
602 | int | 608 | int |
603 | GNUNET_OS_process_status(struct GNUNET_OS_Process *proc, | 609 | GNUNET_OS_process_status (struct GNUNET_OS_Process *proc, |
604 | enum GNUNET_OS_ProcessStatusType *type, | 610 | enum GNUNET_OS_ProcessStatusType *type, |
605 | unsigned long *code); | 611 | unsigned long *code); |
606 | 612 | ||
607 | 613 | ||
608 | /** | 614 | /** |
@@ -616,7 +622,7 @@ GNUNET_OS_process_status(struct GNUNET_OS_Process *proc, | |||
616 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | 622 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise |
617 | */ | 623 | */ |
618 | int | 624 | int |
619 | GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc); | 625 | GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc); |
620 | 626 | ||
621 | 627 | ||
622 | 628 | ||
@@ -630,9 +636,9 @@ GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc); | |||
630 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise | 636 | * @return #GNUNET_OK on success, #GNUNET_NO if the process is still running, #GNUNET_SYSERR otherwise |
631 | */ | 637 | */ |
632 | int | 638 | int |
633 | GNUNET_OS_process_wait_status(struct GNUNET_OS_Process *proc, | 639 | GNUNET_OS_process_wait_status (struct GNUNET_OS_Process *proc, |
634 | enum GNUNET_OS_ProcessStatusType *type, | 640 | enum GNUNET_OS_ProcessStatusType *type, |
635 | unsigned long *code); | 641 | unsigned long *code); |
636 | 642 | ||
637 | 643 | ||
638 | /** | 644 | /** |
@@ -644,7 +650,7 @@ GNUNET_OS_process_wait_status(struct GNUNET_OS_Process *proc, | |||
644 | * @param cls closure (unused) | 650 | * @param cls closure (unused) |
645 | */ | 651 | */ |
646 | void | 652 | void |
647 | GNUNET_OS_install_parent_control_handler(void *cls); | 653 | GNUNET_OS_install_parent_control_handler (void *cls); |
648 | 654 | ||
649 | 655 | ||
650 | /** | 656 | /** |
@@ -665,9 +671,9 @@ GNUNET_OS_install_parent_control_handler(void *cls); | |||
665 | * #GNUNET_SYSERR on error (no such binary or not executable) | 671 | * #GNUNET_SYSERR on error (no such binary or not executable) |
666 | */ | 672 | */ |
667 | int | 673 | int |
668 | GNUNET_OS_check_helper_binary(const char *binary, | 674 | GNUNET_OS_check_helper_binary (const char *binary, |
669 | int check_suid, | 675 | int check_suid, |
670 | const char *params); | 676 | const char *params); |
671 | 677 | ||
672 | 678 | ||
673 | #if 0 /* keep Emacsens' auto-indent happy */ | 679 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index 39b16a1b4..da968737e 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -52,7 +52,8 @@ struct GNUNET_SCHEDULER_Task; | |||
52 | * Reasons why the schedule may have triggered | 52 | * Reasons why the schedule may have triggered |
53 | * the task now. | 53 | * the task now. |
54 | */ | 54 | */ |
55 | enum GNUNET_SCHEDULER_Reason { | 55 | enum GNUNET_SCHEDULER_Reason |
56 | { | ||
56 | /** | 57 | /** |
57 | * This task is not ready. | 58 | * This task is not ready. |
58 | */ | 59 | */ |
@@ -99,7 +100,8 @@ enum GNUNET_SCHEDULER_Reason { | |||
99 | * Possible events on FDs, used as a bitmask. | 100 | * Possible events on FDs, used as a bitmask. |
100 | * Modelled after GPollFD. | 101 | * Modelled after GPollFD. |
101 | */ | 102 | */ |
102 | enum GNUNET_SCHEDULER_EventType { | 103 | enum GNUNET_SCHEDULER_EventType |
104 | { | ||
103 | /** | 105 | /** |
104 | * No event (useful for timeout). | 106 | * No event (useful for timeout). |
105 | */ | 107 | */ |
@@ -140,7 +142,8 @@ enum GNUNET_SCHEDULER_EventType { | |||
140 | /** | 142 | /** |
141 | * Information about an event relating to a file descriptor/socket. | 143 | * Information about an event relating to a file descriptor/socket. |
142 | */ | 144 | */ |
143 | struct GNUNET_SCHEDULER_FdInfo { | 145 | struct GNUNET_SCHEDULER_FdInfo |
146 | { | ||
144 | /** | 147 | /** |
145 | * GNUnet network socket the event is about, matches @a sock, | 148 | * GNUnet network socket the event is about, matches @a sock, |
146 | * NULL if this is about a file handle or if no network | 149 | * NULL if this is about a file handle or if no network |
@@ -170,7 +173,8 @@ struct GNUNET_SCHEDULER_FdInfo { | |||
170 | /** | 173 | /** |
171 | * Context information passed to each scheduler task. | 174 | * Context information passed to each scheduler task. |
172 | */ | 175 | */ |
173 | struct GNUNET_SCHEDULER_TaskContext { | 176 | struct GNUNET_SCHEDULER_TaskContext |
177 | { | ||
174 | /** | 178 | /** |
175 | * Reason why the task is run now | 179 | * Reason why the task is run now |
176 | */ | 180 | */ |
@@ -219,8 +223,8 @@ struct GNUNET_SCHEDULER_TaskContext { | |||
219 | * @param fdi information about the related FD | 223 | * @param fdi information about the related FD |
220 | */ | 224 | */ |
221 | void | 225 | void |
222 | GNUNET_SCHEDULER_task_ready(struct GNUNET_SCHEDULER_Task *task, | 226 | GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task, |
223 | struct GNUNET_SCHEDULER_FdInfo *fdi); | 227 | struct GNUNET_SCHEDULER_FdInfo *fdi); |
224 | 228 | ||
225 | 229 | ||
226 | /** | 230 | /** |
@@ -250,14 +254,15 @@ struct GNUNET_SCHEDULER_Handle; | |||
250 | * if we are done running tasks (yield to block) | 254 | * if we are done running tasks (yield to block) |
251 | */ | 255 | */ |
252 | int | 256 | int |
253 | GNUNET_SCHEDULER_do_work(struct GNUNET_SCHEDULER_Handle *sh); | 257 | GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh); |
254 | 258 | ||
255 | 259 | ||
256 | /** | 260 | /** |
257 | * API an external event loop has to implement for | 261 | * API an external event loop has to implement for |
258 | * #GNUNET_SCHEDULER_driver_init. | 262 | * #GNUNET_SCHEDULER_driver_init. |
259 | */ | 263 | */ |
260 | struct GNUNET_SCHEDULER_Driver { | 264 | struct GNUNET_SCHEDULER_Driver |
265 | { | ||
261 | /** | 266 | /** |
262 | * Closure to pass to the functions in this struct. | 267 | * Closure to pass to the functions in this struct. |
263 | */ | 268 | */ |
@@ -348,7 +353,7 @@ typedef void | |||
348 | * #GNUNET_SCHEDULER_driver_done | 353 | * #GNUNET_SCHEDULER_driver_done |
349 | */ | 354 | */ |
350 | struct GNUNET_SCHEDULER_Handle * | 355 | struct GNUNET_SCHEDULER_Handle * |
351 | GNUNET_SCHEDULER_driver_init(const struct GNUNET_SCHEDULER_Driver *driver); | 356 | GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver); |
352 | 357 | ||
353 | 358 | ||
354 | /** | 359 | /** |
@@ -366,7 +371,7 @@ GNUNET_SCHEDULER_driver_init(const struct GNUNET_SCHEDULER_Driver *driver); | |||
366 | * @param sh the handle returned by #GNUNET_SCHEDULER_driver_init | 371 | * @param sh the handle returned by #GNUNET_SCHEDULER_driver_init |
367 | */ | 372 | */ |
368 | void | 373 | void |
369 | GNUNET_SCHEDULER_driver_done(struct GNUNET_SCHEDULER_Handle *sh); | 374 | GNUNET_SCHEDULER_driver_done (struct GNUNET_SCHEDULER_Handle *sh); |
370 | 375 | ||
371 | 376 | ||
372 | /** | 377 | /** |
@@ -375,7 +380,7 @@ GNUNET_SCHEDULER_driver_done(struct GNUNET_SCHEDULER_Handle *sh); | |||
375 | * @return NULL on error | 380 | * @return NULL on error |
376 | */ | 381 | */ |
377 | struct GNUNET_SCHEDULER_Driver * | 382 | struct GNUNET_SCHEDULER_Driver * |
378 | GNUNET_SCHEDULER_driver_select(void); | 383 | GNUNET_SCHEDULER_driver_select (void); |
379 | 384 | ||
380 | 385 | ||
381 | /** | 386 | /** |
@@ -412,8 +417,8 @@ typedef int | |||
412 | * @param task_cls closure of @a task | 417 | * @param task_cls closure of @a task |
413 | */ | 418 | */ |
414 | void | 419 | void |
415 | GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, | 420 | GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, |
416 | void *task_cls); | 421 | void *task_cls); |
417 | 422 | ||
418 | /** | 423 | /** |
419 | * Initialize and run scheduler. This function will return when all | 424 | * Initialize and run scheduler. This function will return when all |
@@ -427,9 +432,9 @@ GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, | |||
427 | * @param task_cls closure of @a task | 432 | * @param task_cls closure of @a task |
428 | */ | 433 | */ |
429 | void | 434 | void |
430 | GNUNET_SCHEDULER_run_with_optional_signals(int install_signals, | 435 | GNUNET_SCHEDULER_run_with_optional_signals (int install_signals, |
431 | GNUNET_SCHEDULER_TaskCallback task, | 436 | GNUNET_SCHEDULER_TaskCallback task, |
432 | void *task_cls); | 437 | void *task_cls); |
433 | 438 | ||
434 | 439 | ||
435 | /** | 440 | /** |
@@ -439,7 +444,7 @@ GNUNET_SCHEDULER_run_with_optional_signals(int install_signals, | |||
439 | * will be delayed until the next shutdown signal. | 444 | * will be delayed until the next shutdown signal. |
440 | */ | 445 | */ |
441 | void | 446 | void |
442 | GNUNET_SCHEDULER_shutdown(void); | 447 | GNUNET_SCHEDULER_shutdown (void); |
443 | 448 | ||
444 | 449 | ||
445 | /** | 450 | /** |
@@ -454,7 +459,7 @@ GNUNET_SCHEDULER_shutdown(void); | |||
454 | * @return number of tasks pending right now | 459 | * @return number of tasks pending right now |
455 | */ | 460 | */ |
456 | unsigned int | 461 | unsigned int |
457 | GNUNET_SCHEDULER_get_load(enum GNUNET_SCHEDULER_Priority p); | 462 | GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p); |
458 | 463 | ||
459 | 464 | ||
460 | /** | 465 | /** |
@@ -464,7 +469,7 @@ GNUNET_SCHEDULER_get_load(enum GNUNET_SCHEDULER_Priority p); | |||
464 | * @return task context with information why the current task is run | 469 | * @return task context with information why the current task is run |
465 | */ | 470 | */ |
466 | const struct GNUNET_SCHEDULER_TaskContext * | 471 | const struct GNUNET_SCHEDULER_TaskContext * |
467 | GNUNET_SCHEDULER_get_task_context(void); | 472 | GNUNET_SCHEDULER_get_task_context (void); |
468 | 473 | ||
469 | 474 | ||
470 | /** | 475 | /** |
@@ -480,7 +485,7 @@ GNUNET_SCHEDULER_get_task_context(void); | |||
480 | * @return original closure of the task | 485 | * @return original closure of the task |
481 | */ | 486 | */ |
482 | void * | 487 | void * |
483 | GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task); | 488 | GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task); |
484 | 489 | ||
485 | 490 | ||
486 | /** | 491 | /** |
@@ -494,10 +499,13 @@ GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task); | |||
494 | * @param priority priority to use for the task | 499 | * @param priority priority to use for the task |
495 | */ | 500 | */ |
496 | void | 501 | void |
497 | GNUNET_SCHEDULER_add_with_reason_and_priority(GNUNET_SCHEDULER_TaskCallback task, | 502 | GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback |
498 | void *task_cls, | 503 | task, |
499 | enum GNUNET_SCHEDULER_Reason reason, | 504 | void *task_cls, |
500 | enum GNUNET_SCHEDULER_Priority priority); | 505 | enum GNUNET_SCHEDULER_Reason |
506 | reason, | ||
507 | enum GNUNET_SCHEDULER_Priority | ||
508 | priority); | ||
501 | 509 | ||
502 | 510 | ||
503 | /** | 511 | /** |
@@ -510,9 +518,9 @@ GNUNET_SCHEDULER_add_with_reason_and_priority(GNUNET_SCHEDULER_TaskCallback task | |||
510 | * only valid until @a task is started! | 518 | * only valid until @a task is started! |
511 | */ | 519 | */ |
512 | struct GNUNET_SCHEDULER_Task * | 520 | struct GNUNET_SCHEDULER_Task * |
513 | GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, | 521 | GNUNET_SCHEDULER_add_with_priority (enum GNUNET_SCHEDULER_Priority prio, |
514 | GNUNET_SCHEDULER_TaskCallback task, | 522 | GNUNET_SCHEDULER_TaskCallback task, |
515 | void *task_cls); | 523 | void *task_cls); |
516 | 524 | ||
517 | 525 | ||
518 | /** | 526 | /** |
@@ -531,8 +539,8 @@ GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, | |||
531 | * only valid until @a task is started! | 539 | * only valid until @a task is started! |
532 | */ | 540 | */ |
533 | struct GNUNET_SCHEDULER_Task * | 541 | struct GNUNET_SCHEDULER_Task * |
534 | GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, | 542 | GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, |
535 | void *task_cls); | 543 | void *task_cls); |
536 | 544 | ||
537 | 545 | ||
538 | /** | 546 | /** |
@@ -546,8 +554,8 @@ GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, | |||
546 | * only valid until @a task is started! | 554 | * only valid until @a task is started! |
547 | */ | 555 | */ |
548 | struct GNUNET_SCHEDULER_Task * | 556 | struct GNUNET_SCHEDULER_Task * |
549 | GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, | 557 | GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, |
550 | void *task_cls); | 558 | void *task_cls); |
551 | 559 | ||
552 | 560 | ||
553 | /** | 561 | /** |
@@ -565,9 +573,9 @@ GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, | |||
565 | * only valid until @a task is started! | 573 | * only valid until @a task is started! |
566 | */ | 574 | */ |
567 | struct GNUNET_SCHEDULER_Task * | 575 | struct GNUNET_SCHEDULER_Task * |
568 | GNUNET_SCHEDULER_add_now_with_lifeness(int lifeness, | 576 | GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, |
569 | GNUNET_SCHEDULER_TaskCallback task, | 577 | GNUNET_SCHEDULER_TaskCallback task, |
570 | void *task_cls); | 578 | void *task_cls); |
571 | 579 | ||
572 | 580 | ||
573 | /** | 581 | /** |
@@ -582,9 +590,9 @@ GNUNET_SCHEDULER_add_now_with_lifeness(int lifeness, | |||
582 | * only valid until @a task is started! | 590 | * only valid until @a task is started! |
583 | */ | 591 | */ |
584 | struct GNUNET_SCHEDULER_Task * | 592 | struct GNUNET_SCHEDULER_Task * |
585 | GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, | 593 | GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, |
586 | GNUNET_SCHEDULER_TaskCallback task, | 594 | GNUNET_SCHEDULER_TaskCallback task, |
587 | void *task_cls); | 595 | void *task_cls); |
588 | 596 | ||
589 | 597 | ||
590 | /** | 598 | /** |
@@ -599,9 +607,9 @@ GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, | |||
599 | * only valid until @a task is started! | 607 | * only valid until @a task is started! |
600 | */ | 608 | */ |
601 | struct GNUNET_SCHEDULER_Task * | 609 | struct GNUNET_SCHEDULER_Task * |
602 | GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, | 610 | GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at, |
603 | GNUNET_SCHEDULER_TaskCallback task, | 611 | GNUNET_SCHEDULER_TaskCallback task, |
604 | void *task_cls); | 612 | void *task_cls); |
605 | 613 | ||
606 | 614 | ||
607 | /** | 615 | /** |
@@ -616,10 +624,11 @@ GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, | |||
616 | * only valid until @a task is started! | 624 | * only valid until @a task is started! |
617 | */ | 625 | */ |
618 | struct GNUNET_SCHEDULER_Task * | 626 | struct GNUNET_SCHEDULER_Task * |
619 | GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, | 627 | GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, |
620 | enum GNUNET_SCHEDULER_Priority priority, | 628 | enum GNUNET_SCHEDULER_Priority |
621 | GNUNET_SCHEDULER_TaskCallback task, | 629 | priority, |
622 | void *task_cls); | 630 | GNUNET_SCHEDULER_TaskCallback task, |
631 | void *task_cls); | ||
623 | 632 | ||
624 | 633 | ||
625 | /** | 634 | /** |
@@ -634,10 +643,10 @@ GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, | |||
634 | * only valid until @a task is started! | 643 | * only valid until @a task is started! |
635 | */ | 644 | */ |
636 | struct GNUNET_SCHEDULER_Task * | 645 | struct GNUNET_SCHEDULER_Task * |
637 | GNUNET_SCHEDULER_add_at_with_priority(struct GNUNET_TIME_Absolute at, | 646 | GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at, |
638 | enum GNUNET_SCHEDULER_Priority priority, | 647 | enum GNUNET_SCHEDULER_Priority priority, |
639 | GNUNET_SCHEDULER_TaskCallback task, | 648 | GNUNET_SCHEDULER_TaskCallback task, |
640 | void *task_cls); | 649 | void *task_cls); |
641 | 650 | ||
642 | 651 | ||
643 | /** | 652 | /** |
@@ -661,10 +670,10 @@ GNUNET_SCHEDULER_add_at_with_priority(struct GNUNET_TIME_Absolute at, | |||
661 | * only valid until @a task is started! | 670 | * only valid until @a task is started! |
662 | */ | 671 | */ |
663 | struct GNUNET_SCHEDULER_Task * | 672 | struct GNUNET_SCHEDULER_Task * |
664 | GNUNET_SCHEDULER_add_read_net(struct GNUNET_TIME_Relative delay, | 673 | GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, |
665 | struct GNUNET_NETWORK_Handle *rfd, | 674 | struct GNUNET_NETWORK_Handle *rfd, |
666 | GNUNET_SCHEDULER_TaskCallback task, | 675 | GNUNET_SCHEDULER_TaskCallback task, |
667 | void *task_cls); | 676 | void *task_cls); |
668 | 677 | ||
669 | 678 | ||
670 | /** | 679 | /** |
@@ -690,11 +699,12 @@ GNUNET_SCHEDULER_add_read_net(struct GNUNET_TIME_Relative delay, | |||
690 | * only valid until @a task is started! | 699 | * only valid until @a task is started! |
691 | */ | 700 | */ |
692 | struct GNUNET_SCHEDULER_Task * | 701 | struct GNUNET_SCHEDULER_Task * |
693 | GNUNET_SCHEDULER_add_read_net_with_priority(struct GNUNET_TIME_Relative delay, | 702 | GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, |
694 | enum GNUNET_SCHEDULER_Priority priority, | 703 | enum GNUNET_SCHEDULER_Priority |
695 | struct GNUNET_NETWORK_Handle *rfd, | 704 | priority, |
696 | GNUNET_SCHEDULER_TaskCallback task, | 705 | struct GNUNET_NETWORK_Handle *rfd, |
697 | void *task_cls); | 706 | GNUNET_SCHEDULER_TaskCallback task, |
707 | void *task_cls); | ||
698 | 708 | ||
699 | 709 | ||
700 | /** | 710 | /** |
@@ -719,10 +729,10 @@ GNUNET_SCHEDULER_add_read_net_with_priority(struct GNUNET_TIME_Relative delay, | |||
719 | * only valid until @a task is started! | 729 | * only valid until @a task is started! |
720 | */ | 730 | */ |
721 | struct GNUNET_SCHEDULER_Task * | 731 | struct GNUNET_SCHEDULER_Task * |
722 | GNUNET_SCHEDULER_add_write_net(struct GNUNET_TIME_Relative delay, | 732 | GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, |
723 | struct GNUNET_NETWORK_Handle *wfd, | 733 | struct GNUNET_NETWORK_Handle *wfd, |
724 | GNUNET_SCHEDULER_TaskCallback task, | 734 | GNUNET_SCHEDULER_TaskCallback task, |
725 | void *task_cls); | 735 | void *task_cls); |
726 | 736 | ||
727 | 737 | ||
728 | /** | 738 | /** |
@@ -749,13 +759,13 @@ GNUNET_SCHEDULER_add_write_net(struct GNUNET_TIME_Relative delay, | |||
749 | * only valid until "task" is started! | 759 | * only valid until "task" is started! |
750 | */ | 760 | */ |
751 | struct GNUNET_SCHEDULER_Task * | 761 | struct GNUNET_SCHEDULER_Task * |
752 | GNUNET_SCHEDULER_add_net_with_priority(struct GNUNET_TIME_Relative delay, | 762 | GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, |
753 | enum GNUNET_SCHEDULER_Priority priority, | 763 | enum GNUNET_SCHEDULER_Priority priority, |
754 | struct GNUNET_NETWORK_Handle *fd, | 764 | struct GNUNET_NETWORK_Handle *fd, |
755 | int on_read, | 765 | int on_read, |
756 | int on_write, | 766 | int on_write, |
757 | GNUNET_SCHEDULER_TaskCallback task, | 767 | GNUNET_SCHEDULER_TaskCallback task, |
758 | void *task_cls); | 768 | void *task_cls); |
759 | 769 | ||
760 | 770 | ||
761 | /** | 771 | /** |
@@ -779,10 +789,10 @@ GNUNET_SCHEDULER_add_net_with_priority(struct GNUNET_TIME_Relative delay, | |||
779 | * only valid until @a task is started! | 789 | * only valid until @a task is started! |
780 | */ | 790 | */ |
781 | struct GNUNET_SCHEDULER_Task * | 791 | struct GNUNET_SCHEDULER_Task * |
782 | GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, | 792 | GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, |
783 | const struct GNUNET_DISK_FileHandle *rfd, | 793 | const struct GNUNET_DISK_FileHandle *rfd, |
784 | GNUNET_SCHEDULER_TaskCallback task, | 794 | GNUNET_SCHEDULER_TaskCallback task, |
785 | void *task_cls); | 795 | void *task_cls); |
786 | 796 | ||
787 | 797 | ||
788 | /** | 798 | /** |
@@ -806,10 +816,10 @@ GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, | |||
806 | * only valid until @a task is started! | 816 | * only valid until @a task is started! |
807 | */ | 817 | */ |
808 | struct GNUNET_SCHEDULER_Task * | 818 | struct GNUNET_SCHEDULER_Task * |
809 | GNUNET_SCHEDULER_add_write_file(struct GNUNET_TIME_Relative delay, | 819 | GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, |
810 | const struct GNUNET_DISK_FileHandle *wfd, | 820 | const struct GNUNET_DISK_FileHandle *wfd, |
811 | GNUNET_SCHEDULER_TaskCallback task, | 821 | GNUNET_SCHEDULER_TaskCallback task, |
812 | void *task_cls); | 822 | void *task_cls); |
813 | 823 | ||
814 | 824 | ||
815 | /** | 825 | /** |
@@ -836,12 +846,15 @@ GNUNET_SCHEDULER_add_write_file(struct GNUNET_TIME_Relative delay, | |||
836 | * only valid until @a task is started! | 846 | * only valid until @a task is started! |
837 | */ | 847 | */ |
838 | struct GNUNET_SCHEDULER_Task * | 848 | struct GNUNET_SCHEDULER_Task * |
839 | GNUNET_SCHEDULER_add_file_with_priority(struct GNUNET_TIME_Relative delay, | 849 | GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, |
840 | enum GNUNET_SCHEDULER_Priority priority, | 850 | enum GNUNET_SCHEDULER_Priority |
841 | const struct GNUNET_DISK_FileHandle *fd, | 851 | priority, |
842 | int on_read, int on_write, | 852 | const struct |
843 | GNUNET_SCHEDULER_TaskCallback task, | 853 | GNUNET_DISK_FileHandle *fd, |
844 | void *task_cls); | 854 | int on_read, |
855 | int on_write, | ||
856 | GNUNET_SCHEDULER_TaskCallback task, | ||
857 | void *task_cls); | ||
845 | 858 | ||
846 | 859 | ||
847 | /** | 860 | /** |
@@ -876,12 +889,12 @@ GNUNET_SCHEDULER_add_file_with_priority(struct GNUNET_TIME_Relative delay, | |||
876 | * only valid until @a task is started! | 889 | * only valid until @a task is started! |
877 | */ | 890 | */ |
878 | struct GNUNET_SCHEDULER_Task * | 891 | struct GNUNET_SCHEDULER_Task * |
879 | GNUNET_SCHEDULER_add_select(enum GNUNET_SCHEDULER_Priority prio, | 892 | GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, |
880 | struct GNUNET_TIME_Relative delay, | 893 | struct GNUNET_TIME_Relative delay, |
881 | const struct GNUNET_NETWORK_FDSet *rs, | 894 | const struct GNUNET_NETWORK_FDSet *rs, |
882 | const struct GNUNET_NETWORK_FDSet *ws, | 895 | const struct GNUNET_NETWORK_FDSet *ws, |
883 | GNUNET_SCHEDULER_TaskCallback task, | 896 | GNUNET_SCHEDULER_TaskCallback task, |
884 | void *task_cls); | 897 | void *task_cls); |
885 | 898 | ||
886 | /** | 899 | /** |
887 | * Sets the select function to use in the scheduler (scheduler_select). | 900 | * Sets the select function to use in the scheduler (scheduler_select). |
@@ -890,8 +903,8 @@ GNUNET_SCHEDULER_add_select(enum GNUNET_SCHEDULER_Priority prio, | |||
890 | * @param new_select_cls closure for @a new_select | 903 | * @param new_select_cls closure for @a new_select |
891 | */ | 904 | */ |
892 | void | 905 | void |
893 | GNUNET_SCHEDULER_set_select(GNUNET_SCHEDULER_select new_select, | 906 | GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select, |
894 | void *new_select_cls); | 907 | void *new_select_cls); |
895 | 908 | ||
896 | 909 | ||
897 | 910 | ||
@@ -908,7 +921,7 @@ GNUNET_SCHEDULER_set_select(GNUNET_SCHEDULER_select new_select, | |||
908 | * @param aid the asynchronous scope id to enter | 921 | * @param aid the asynchronous scope id to enter |
909 | */ | 922 | */ |
910 | void | 923 | void |
911 | GNUNET_SCHEDULER_begin_async_scope(struct GNUNET_AsyncScopeId *aid); | 924 | GNUNET_SCHEDULER_begin_async_scope (struct GNUNET_AsyncScopeId *aid); |
912 | 925 | ||
913 | 926 | ||
914 | 927 | ||
diff --git a/src/include/gnunet_service_lib.h b/src/include/gnunet_service_lib.h index 9cdf4d459..19a5fb89b 100644 --- a/src/include/gnunet_service_lib.h +++ b/src/include/gnunet_service_lib.h | |||
@@ -50,7 +50,8 @@ extern "C" | |||
50 | /** | 50 | /** |
51 | * Options for the service (bitmask). | 51 | * Options for the service (bitmask). |
52 | */ | 52 | */ |
53 | enum GNUNET_SERVICE_Options { | 53 | enum GNUNET_SERVICE_Options |
54 | { | ||
54 | /** | 55 | /** |
55 | * Use defaults. Terminates all client connections and the listen | 56 | * Use defaults. Terminates all client connections and the listen |
56 | * sockets immediately upon receiving the shutdown signal. | 57 | * sockets immediately upon receiving the shutdown signal. |
@@ -68,7 +69,18 @@ enum GNUNET_SERVICE_Options { | |||
68 | * Trigger a SOFT server shutdown on signals, allowing active | 69 | * Trigger a SOFT server shutdown on signals, allowing active |
69 | * non-monitor clients to complete their transactions. | 70 | * non-monitor clients to complete their transactions. |
70 | */ | 71 | */ |
71 | GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2 | 72 | GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN = 2, |
73 | |||
74 | /** | ||
75 | * Bitmask over the shutdown options. | ||
76 | */ | ||
77 | GNUNET_SERVICE_OPTION_SHUTDOWN_BITMASK = 3, | ||
78 | |||
79 | /** | ||
80 | * Instead of listening on lsocks passed by the parent, | ||
81 | * close them *after* opening our own listen socket(s). | ||
82 | */ | ||
83 | GNUNET_SERVICE_OPTION_CLOSE_LSOCKS = 4 | ||
72 | }; | 84 | }; |
73 | 85 | ||
74 | 86 | ||
@@ -164,12 +176,12 @@ typedef void | |||
164 | * @return NULL on error | 176 | * @return NULL on error |
165 | */ | 177 | */ |
166 | struct GNUNET_SERVICE_Handle * | 178 | struct GNUNET_SERVICE_Handle * |
167 | GNUNET_SERVICE_start(const char *service_name, | 179 | GNUNET_SERVICE_start (const char *service_name, |
168 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 180 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
169 | GNUNET_SERVICE_ConnectHandler connect_cb, | 181 | GNUNET_SERVICE_ConnectHandler connect_cb, |
170 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, | 182 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, |
171 | void *cls, | 183 | void *cls, |
172 | const struct GNUNET_MQ_MessageHandler *handlers); | 184 | const struct GNUNET_MQ_MessageHandler *handlers); |
173 | 185 | ||
174 | 186 | ||
175 | /** | 187 | /** |
@@ -178,7 +190,7 @@ GNUNET_SERVICE_start(const char *service_name, | |||
178 | * @param srv service to stop | 190 | * @param srv service to stop |
179 | */ | 191 | */ |
180 | void | 192 | void |
181 | GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv); | 193 | GNUNET_SERVICE_stop (struct GNUNET_SERVICE_Handle *srv); |
182 | 194 | ||
183 | 195 | ||
184 | /** | 196 | /** |
@@ -223,15 +235,15 @@ GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv); | |||
223 | * @return 0 on success, non-zero on error | 235 | * @return 0 on success, non-zero on error |
224 | */ | 236 | */ |
225 | int | 237 | int |
226 | GNUNET_SERVICE_run_(int argc, | 238 | GNUNET_SERVICE_run_ (int argc, |
227 | char *const *argv, | 239 | char *const *argv, |
228 | const char *service_name, | 240 | const char *service_name, |
229 | enum GNUNET_SERVICE_Options options, | 241 | enum GNUNET_SERVICE_Options options, |
230 | GNUNET_SERVICE_InitCallback service_init_cb, | 242 | GNUNET_SERVICE_InitCallback service_init_cb, |
231 | GNUNET_SERVICE_ConnectHandler connect_cb, | 243 | GNUNET_SERVICE_ConnectHandler connect_cb, |
232 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, | 244 | GNUNET_SERVICE_DisconnectHandler disconnect_cb, |
233 | void *cls, | 245 | void *cls, |
234 | const struct GNUNET_MQ_MessageHandler *handlers); | 246 | const struct GNUNET_MQ_MessageHandler *handlers); |
235 | 247 | ||
236 | 248 | ||
237 | /** | 249 | /** |
@@ -291,23 +303,24 @@ GNUNET_SERVICE_run_(int argc, | |||
291 | * GNUNET_MQ_handler_end ()); | 303 | * GNUNET_MQ_handler_end ()); |
292 | * </code> | 304 | * </code> |
293 | */ | 305 | */ |
294 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, disconnect_cb, cls, ...) \ | 306 | #define GNUNET_SERVICE_MAIN(service_name, service_options, init_cb, connect_cb, \ |
307 | disconnect_cb, cls, ...) \ | ||
295 | int \ | 308 | int \ |
296 | main(int argc, \ | 309 | main (int argc, \ |
297 | char *const *argv) \ | 310 | char *const *argv) \ |
298 | { \ | 311 | { \ |
299 | struct GNUNET_MQ_MessageHandler mh[] = { \ | 312 | struct GNUNET_MQ_MessageHandler mh[] = { \ |
300 | __VA_ARGS__ \ | 313 | __VA_ARGS__ \ |
301 | }; \ | 314 | }; \ |
302 | return GNUNET_SERVICE_run_(argc, \ | 315 | return GNUNET_SERVICE_run_ (argc, \ |
303 | argv, \ | 316 | argv, \ |
304 | service_name, \ | 317 | service_name, \ |
305 | service_options, \ | 318 | service_options, \ |
306 | init_cb, \ | 319 | init_cb, \ |
307 | connect_cb, \ | 320 | connect_cb, \ |
308 | disconnect_cb, \ | 321 | disconnect_cb, \ |
309 | cls, \ | 322 | cls, \ |
310 | mh); \ | 323 | mh); \ |
311 | } | 324 | } |
312 | 325 | ||
313 | 326 | ||
@@ -318,7 +331,7 @@ GNUNET_SERVICE_run_(int argc, | |||
318 | * @param sh service to stop accepting connections. | 331 | * @param sh service to stop accepting connections. |
319 | */ | 332 | */ |
320 | void | 333 | void |
321 | GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh); | 334 | GNUNET_SERVICE_suspend (struct GNUNET_SERVICE_Handle *sh); |
322 | 335 | ||
323 | 336 | ||
324 | /** | 337 | /** |
@@ -327,7 +340,7 @@ GNUNET_SERVICE_suspend(struct GNUNET_SERVICE_Handle *sh); | |||
327 | * @param sh service to resume accepting connections. | 340 | * @param sh service to resume accepting connections. |
328 | */ | 341 | */ |
329 | void | 342 | void |
330 | GNUNET_SERVICE_resume(struct GNUNET_SERVICE_Handle *sh); | 343 | GNUNET_SERVICE_resume (struct GNUNET_SERVICE_Handle *sh); |
331 | 344 | ||
332 | 345 | ||
333 | /** | 346 | /** |
@@ -337,7 +350,7 @@ GNUNET_SERVICE_resume(struct GNUNET_SERVICE_Handle *sh); | |||
337 | * @param c the client to continue receiving from | 350 | * @param c the client to continue receiving from |
338 | */ | 351 | */ |
339 | void | 352 | void |
340 | GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c); | 353 | GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c); |
341 | 354 | ||
342 | 355 | ||
343 | /** | 356 | /** |
@@ -347,7 +360,7 @@ GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c); | |||
347 | * @return the message queue of @a c | 360 | * @return the message queue of @a c |
348 | */ | 361 | */ |
349 | struct GNUNET_MQ_Handle * | 362 | struct GNUNET_MQ_Handle * |
350 | GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c); | 363 | GNUNET_SERVICE_client_get_mq (struct GNUNET_SERVICE_Client *c); |
351 | 364 | ||
352 | 365 | ||
353 | /** | 366 | /** |
@@ -359,7 +372,8 @@ GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c); | |||
359 | * @param c client for which to disable the warning | 372 | * @param c client for which to disable the warning |
360 | */ | 373 | */ |
361 | void | 374 | void |
362 | GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c); | 375 | GNUNET_SERVICE_client_disable_continue_warning (struct |
376 | GNUNET_SERVICE_Client *c); | ||
363 | 377 | ||
364 | 378 | ||
365 | /** | 379 | /** |
@@ -378,7 +392,7 @@ GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c); | |||
378 | * @param c client to disconnect now | 392 | * @param c client to disconnect now |
379 | */ | 393 | */ |
380 | void | 394 | void |
381 | GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c); | 395 | GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c); |
382 | 396 | ||
383 | 397 | ||
384 | /** | 398 | /** |
@@ -387,7 +401,7 @@ GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c); | |||
387 | * @param sh server to shutdown | 401 | * @param sh server to shutdown |
388 | */ | 402 | */ |
389 | void | 403 | void |
390 | GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh); | 404 | GNUNET_SERVICE_shutdown (struct GNUNET_SERVICE_Handle *sh); |
391 | 405 | ||
392 | 406 | ||
393 | /** | 407 | /** |
@@ -403,7 +417,7 @@ GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh); | |||
403 | * @param c client to mark as a monitor | 417 | * @param c client to mark as a monitor |
404 | */ | 418 | */ |
405 | void | 419 | void |
406 | GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c); | 420 | GNUNET_SERVICE_client_mark_monitor (struct GNUNET_SERVICE_Client *c); |
407 | 421 | ||
408 | 422 | ||
409 | /** | 423 | /** |
@@ -414,7 +428,7 @@ GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c); | |||
414 | * @param c client to persist the socket (never to be closed) | 428 | * @param c client to persist the socket (never to be closed) |
415 | */ | 429 | */ |
416 | void | 430 | void |
417 | GNUNET_SERVICE_client_persist(struct GNUNET_SERVICE_Client *c); | 431 | GNUNET_SERVICE_client_persist (struct GNUNET_SERVICE_Client *c); |
418 | 432 | ||
419 | 433 | ||
420 | #if 0 /* keep Emacsens' auto-indent happy */ | 434 | #if 0 /* keep Emacsens' auto-indent happy */ |