diff options
Diffstat (limited to 'src/include/gnunet_os_lib.h')
-rw-r--r-- | src/include/gnunet_os_lib.h | 134 |
1 files changed, 70 insertions, 64 deletions
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 */ |