GNUnet  0.11.x
gnunet_os_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2011 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
48 #ifndef GNUNET_OS_LIB_H
49 #define GNUNET_OS_LIB_H
50 
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #if 0 /* keep Emacsens' auto-indent happy */
55 }
56 #endif
57 #endif
58 
59 #include "gnunet_common.h"
61 #include "gnunet_scheduler_lib.h"
62 
63 
69 {
74 
80 
86 
92 
98 
104 };
105 
106 
110 struct GNUNET_OS_Process;
111 
112 
117 {
122 
127 
132 
137 
142 
149 
154 
160 
165 };
166 
167 
172 {
178 
183 
188 
193 
198 };
199 
200 
206 {
212  const char *libname;
213 
220  const char *project_dirname;
221 
227  const char *binary_name;
228 
233  const char *env_varname;
234 
240  const char *env_varname_alt;
241 
247  const char *base_config_varname;
248 
252  const char *bug_email;
253 
257  const char *homepage;
258 
262  const char *config_file;
263 
267  const char *user_config_file;
268 
272  const char *version;
273 
277  int is_gnu;
278 
284 
290 };
291 
292 
296 const struct GNUNET_OS_ProjectData *
298 
299 
303 const struct GNUNET_OS_ProjectData *
305 
306 
312 void
313 GNUNET_OS_init (const struct GNUNET_OS_ProjectData *pd);
314 
315 
324 char *
326 
327 
336 char *
337 GNUNET_OS_get_libexec_binary_path (const char *progname);
338 
339 
352 char *
354  const char *progname);
355 
356 
369 typedef int
371  const char *name,
372  int isDefault,
373  const struct sockaddr *addr,
374  const struct sockaddr *broadcast_addr,
375  const struct sockaddr *netmask,
376  socklen_t addrlen);
377 
378 
385 void
387  void *proc_cls);
388 
392 #if HAVE_SYSCONF && defined(_SC_HOST_NAME_MAX)
393 #define GNUNET_OS_get_hostname_max_length() ({ int __sc_tmp = sysconf ( \
394  _SC_HOST_NAME_MAX); __sc_tmp <= \
395  0 ? 255 : __sc_tmp; })
396 #elif defined(HOST_NAME_MAX)
397 #define GNUNET_OS_get_hostname_max_length() HOST_NAME_MAX
398 #else
399 #define GNUNET_OS_get_hostname_max_length() 255
400 #endif
401 
402 
411 struct GNUNET_OS_Process *
413 
414 
422 int
424  int sig);
425 
426 
432 void
434 
435 
443 pid_t
445 
446 
459 struct GNUNET_OS_Process *
460 GNUNET_OS_start_process_vap (int pipe_control,
461  enum GNUNET_OS_InheritStdioFlags std_inheritance,
462  struct GNUNET_DISK_PipeHandle *pipe_stdin,
463  struct GNUNET_DISK_PipeHandle *pipe_stdout,
464  struct GNUNET_DISK_PipeHandle *pipe_stderr,
465  const char *filename,
466  char *const argv[]);
467 
468 
481 struct GNUNET_OS_Process *
482 GNUNET_OS_start_process (int pipe_control,
483  enum GNUNET_OS_InheritStdioFlags std_inheritance,
484  struct GNUNET_DISK_PipeHandle *pipe_stdin,
485  struct GNUNET_DISK_PipeHandle *pipe_stdout,
486  struct GNUNET_DISK_PipeHandle *pipe_stderr,
487  const char *filename, ...);
488 
489 
502 struct GNUNET_OS_Process *
503 GNUNET_OS_start_process_va (int pipe_control,
504  enum GNUNET_OS_InheritStdioFlags std_inheritance,
505  struct GNUNET_DISK_PipeHandle *pipe_stdin,
506  struct GNUNET_DISK_PipeHandle *pipe_stdout,
507  struct GNUNET_DISK_PipeHandle *pipe_stderr,
508  const char *filename, va_list va);
509 
522 struct GNUNET_OS_Process *
523 GNUNET_OS_start_process_v (int pipe_control,
524  enum GNUNET_OS_InheritStdioFlags std_inheritance,
525  const int *lsocks,
526  const char *filename,
527  char *const argv[]);
528 
529 
548 struct GNUNET_OS_Process *
549 GNUNET_OS_start_process_s (int pipe_control,
550  unsigned int std_inheritance,
551  const int *lsocks,
552  const char *filename, ...);
553 
554 
559 
560 
567 typedef void
568 (*GNUNET_OS_LineProcessor) (void *cls, const char *line);
569 
570 
576 void
578 
579 
593  void *proc_cls,
595  const char *binary,
596  ...);
597 
598 
608 int
611  unsigned long *code);
612 
613 
624 int
626 
627 
637 int
640  unsigned long *code);
641 
642 
651 void
653 
654 
672 int
673 GNUNET_OS_check_helper_binary (const char *binary,
674  int check_suid,
675  const char *params);
676 
677 
678 #if 0 /* keep Emacsens' auto-indent happy */
679 {
680 #endif
681 #ifdef __cplusplus
682 }
683 #endif
684 
685 /* ifndef GNUNET_OS_LIB_H */
686 #endif
687  /* end of group */
689 
690 /* end of gnunet_os_lib.h */
Return the directory where translations are installed (share/locale/)
GNUNET_OS_InheritStdioFlags
Flags that determine which of the standard streams should be inherited by the child process...
Definition: gnunet_os_lib.h:68
const char * config_file
Configuration file name (in $XDG_CONFIG_HOME) to use.
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:91
pid_t GNUNET_OS_process_get_pid(struct GNUNET_OS_Process *proc)
Get the pid of the process in question.
Definition: os_priority.c:274
char * gettext_domain
Gettext domain for localisation, e.g.
Project-specific data used to help the OS subsystem find installation paths.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
char * gettext_path
Gettext directory, e.g.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
Definition: os_priority.c:287
int GNUNET_OS_process_status(struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code)
Retrieve the status of a process, waiting on it if dead.
Definition: os_priority.c:963
Return the directory where libraries are installed.
const char * project_dirname
Name of the project that is used in the "libexec" prefix, For example, "gnunet".
struct GNUNET_OS_Process * GNUNET_OS_start_process(int pipe_control, enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename,...)
Start a process.
Definition: os_priority.c:687
When this flag is set, the child process will inherit stdin of the parent.
Definition: gnunet_os_lib.h:79
const char * env_varname_alt
Alternative name of an environment variable that can be used to override installation path detection...
const char * user_config_file
Configuration file name to use (if $XDG_CONFIG_HOME is not set).
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by &#39;libgnunetutil&#39; for GNUnet.
int GNUNET_OS_check_helper_binary(const char *binary, int check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
void GNUNET_OS_network_interfaces_list(GNUNET_OS_NetworkInterfaceProcessor proc, void *proc_cls)
Enumerate all network interfaces.
Definition: os_network.c:396
struct GNUNET_OS_Process * GNUNET_OS_start_process_va(int pipe_control, enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, va_list va)
Start a process.
Definition: os_priority.c:639
void * proc_cls
Closure for proc.
Definition: os_priority.c:1044
int is_gnu
Non-zero means this project is part of GNU.
const char * version
String identifying the current project version.
const char * bug_email
E-mail address for reporting bugs.
Return the "PREFIX" directory given to configure.
Use this option to have all of the standard streams (stdin, stdout and stderror) be inherited...
const char * env_varname
Name of an environment variable that can be used to override installation path detection, for example "GNUNET_PREFIX".
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static char * line
Desired phone line (string to be converted to a hash).
Return the prefix of the path with documentation files, including the license (share/doc/gnunet/).
const char * libname
Name of a library that is installed in the "lib/" directory of the project, such as "libgnunetutil"...
No standard streams should be inherited.
Definition: gnunet_os_lib.h:73
When this flag is set, the child process will inherit stdout of the parent.
Definition: gnunet_os_lib.h:85
GNUNET_OS_ProcessStatusType
Process status types.
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation directory.
struct GNUNET_OS_Process * GNUNET_OS_process_current(void)
Get process structure for current process.
Definition: os_priority.c:210
struct GNUNET_OS_Process * GNUNET_OS_start_process_vap(int pipe_control, enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, char *const argv[])
Start a process.
Definition: os_priority.c:607
int GNUNET_OS_process_wait_status(struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code)
Retrieve the status of a process, waiting on it if dead.
Definition: os_priority.c:981
const char * binary_name
Name of a project-specific binary that should be in "$PREFIX/bin/".
static char * filename
char * GNUNET_OS_get_suid_binary_path(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *progname)
Given the name of a helper, service or daemon binary construct the full path to the binary using the ...
The process exited with a return code.
Return the directory where helper binaries are installed (lib/gnunet/libexec/)
void GNUNET_OS_install_parent_control_handler(void *cls)
Connects this process to its parent via pipe; essentially, the parent control handler will read signa...
Definition: os_priority.c:141
GNUNET_OS_InstallationPathKind
Possible installation paths to request.
When these flags are set, the child process will inherit stdout and stderr of the parent...
Definition: gnunet_os_lib.h:97
struct GNUNET_OS_Process * GNUNET_OS_start_process_v(int pipe_control, enum GNUNET_OS_InheritStdioFlags std_inheritance, const int *lsocks, const char *filename, char *const argv[])
Start a process.
Definition: os_priority.c:726
int(* GNUNET_OS_NetworkInterfaceProcessor)(void *cls, const char *name, int isDefault, const struct sockaddr *addr, const struct sockaddr *broadcast_addr, const struct sockaddr *netmask, socklen_t addrlen)
Callback function invoked for each interface found.
struct GNUNET_OS_CommandHandle * GNUNET_OS_command_run(GNUNET_OS_LineProcessor proc, void *proc_cls, struct GNUNET_TIME_Relative timeout, const char *binary,...)
Run the given command line and call the given function for each line of the output.
Definition: os_priority.c:1161
The process was killed by a signal.
Return the installation directory of this application, not the one of the overall GNUnet installation...
Return the directory where the program binaries are installed.
const char * homepage
Project homepage.
int GNUNET_OS_process_wait(struct GNUNET_OS_Process *proc)
Wait for a process to terminate.
Definition: os_priority.c:1000
configuration data
Definition: configuration.c:85
const char * name
Handle to a command.
Definition: os_priority.c:1019
struct GNUNET_OS_Process * GNUNET_OS_start_process_s(int pipe_control, unsigned int std_inheritance, const int *lsocks, const char *filename,...)
Start a process.
Definition: os_priority.c:762
const char * base_config_varname
Name of an environment variable that can be used to override the location from which default configur...
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get(void)
The process is still running.
GNUNET_OS_LineProcessor proc
Function to call on each line of output.
Definition: os_priority.c:1039
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
void GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd)
Setup OS subsystem with project data.
The process is not known to the OS (or at least not one of our children).
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void GNUNET_OS_command_stop(struct GNUNET_OS_CommandHandle *cmd)
Stop/kill a command.
Definition: os_priority.c:1076
Return the prefix of the path with application icons (share/icons/).
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
void(* GNUNET_OS_LineProcessor)(void *cls, const char *line)
Type of a function to process a line of output.
Handle used to manage a pipe.
Definition: disk.c:68
The process is paused (but could be resumed).
Return the directory where data is installed (share/gnunet/)
Time for relative time used by GNUnet, in microseconds.
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:225