aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_os_lib.h
blob: dfab4a74775fff33126aab2da610aa4d53086b82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
     This file is part of GNUnet.
     (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing authors)

     GNUnet is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published
     by the Free Software Foundation; either version 2, or (at your
     option) any later version.

     GNUnet is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with GNUnet; see the file COPYING.  If not, write to the
     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
*/

/**
 * @file include/gnunet_os_lib.h
 * @brief low level process routines
 * @author Christian Grothoff
 * @author Krista Bennett
 * @author Gerd Knorr <kraxel@bytesex.org>
 * @author Ioana Patrascu
 * @author Tzvetan Horozov
 * @author Milan
 */

#ifndef GNUNET_OS_LIB_H
#define GNUNET_OS_LIB_H

#ifdef __cplusplus
extern "C"
{
#if 0                           /* keep Emacsens' auto-indent happy */
}
#endif
#endif

#include "gnunet_common.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_scheduler_lib.h"


/**
 * Possible installation paths to request
 */
enum GNUNET_OS_InstallationPathKind
{
  GNUNET_OS_IPK_PREFIX,
  GNUNET_OS_IPK_BINDIR,
  GNUNET_OS_IPK_LIBDIR,
  GNUNET_OS_IPK_DATADIR,
  GNUNET_OS_IPK_LOCALEDIR,
  GNUNET_OS_IPK_SELF_PREFIX
};


/**
 * Get the path to a specific GNUnet installation directory or, with
 * GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation
 * directory.
 *
 * @param dirkind what kind of directory is desired?
 * @return a pointer to the dir path (to be freed by the caller)
 */
char *GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind
                                       dirkind);


/**
 * Callback function invoked for each interface found.
 *
 * @param cls closure
 * @param name name of the interface (can be NULL for unknown)
 * @param isDefault is this presumably the default interface
 * @param addr address of this interface (can be NULL for unknown or unassigned)
 * @param addrlen length of the address
 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
 */
typedef int (*GNUNET_OS_NetworkInterfaceProcessor) (void *cls,
                                                    const char *name,
                                                    int isDefault,
                                                    const struct sockaddr *
                                                    addr, socklen_t addrlen);


/**
 * @brief Enumerate all network interfaces
 * @param callback the callback function
 */
void GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor
                                        proc, void *cls);

/**
 * Get the current CPU load.
 *
 * @param cfg to determine acceptable load level (LOAD::MAXCPULOAD)
 * @return -1 on error, otherwise load value (between 0 and 100,
 *        (100 is equivalent to full load for one CPU)
 */
int GNUNET_OS_load_cpu_get (struct GNUNET_CONFIGURATION_Handle *cfg);

/**
 * Get the current IO load.
 *
 * @param cfg to determine acceptable load level (LOAD::MAXIOLOAD)
 * @return -1 on error, otherwise load value (between 0 and 100,
 *       100 means that we spend all of our cycles waiting for
 *       the disk)
 */
int GNUNET_OS_load_disk_get (struct GNUNET_CONFIGURATION_Handle *cfg);


/**
 * Set process priority
 *
 * @param proc id of the process
 * @param prio priority value
 * @return GNUNET_OK on success, GNUNET_SYSERR on error
 */
int GNUNET_OS_set_process_priority (pid_t proc,
                                    enum GNUNET_SCHEDULER_Priority prio);


/**
 * Start a process.
 *
 * @param filename name of the binary
 * @param ... NULL-terminated list of arguments to the process
 * @return process ID of the new process, -1 on error
 */
pid_t GNUNET_OS_start_process (const char *filename, ...);

/**
 * Start a process.
 *
 * @param filename name of the binary
 * @param argv NULL-terminated list of arguments to the process,
 *             including the process name as the first argument
 * @return process ID of the new process, -1 on error
 */
pid_t GNUNET_OS_start_process_v (const char *filename, char *const argv[]);

#if 0                           /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus
}
#endif


/* ifndef GNUNET_OS_LIB_H */
#endif
/* end of gnunet_os_lib.h */