diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-13 08:58:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-13 08:58:42 +0000 |
commit | f7de70d68cfad378a9b4f3b1f572196e8fa23e2a (patch) | |
tree | 458f632a19f37ee071be657e099b3f0e9f99980c /src/util | |
parent | 10cb56ae4e463e404d4d3ba2147340809d608ed8 (diff) | |
download | gnunet-f7de70d68cfad378a9b4f3b1f572196e8fa23e2a.tar.gz gnunet-f7de70d68cfad378a9b4f3b1f572196e8fa23e2a.zip |
-fixes and cleanup
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/os_installation.c | 110 | ||||
-rw-r--r-- | src/util/os_priority.c | 6 | ||||
-rw-r--r-- | src/util/test_resolver_api.c | 60 |
3 files changed, 80 insertions, 96 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 2e1acac64..962d016e7 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c | |||
@@ -56,8 +56,7 @@ get_path_from_proc_maps () | |||
56 | char *lgu; | 56 | char *lgu; |
57 | 57 | ||
58 | GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/maps", getpid ()); | 58 | GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/maps", getpid ()); |
59 | f = FOPEN (fn, "r"); | 59 | if (NULL == (f = FOPEN (fn, "r"))) |
60 | if (f == NULL) | ||
61 | return NULL; | 60 | return NULL; |
62 | while (NULL != fgets (line, sizeof (line), f)) | 61 | while (NULL != fgets (line, sizeof (line), f)) |
63 | { | 62 | { |
@@ -74,6 +73,7 @@ get_path_from_proc_maps () | |||
74 | return NULL; | 73 | return NULL; |
75 | } | 74 | } |
76 | 75 | ||
76 | |||
77 | /** | 77 | /** |
78 | * Try to determine path by reading /proc/PID/exe | 78 | * Try to determine path by reading /proc/PID/exe |
79 | */ | 79 | */ |
@@ -131,6 +131,7 @@ get_path_from_module_filename () | |||
131 | #if DARWIN | 131 | #if DARWIN |
132 | typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t * bufsize); | 132 | typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t * bufsize); |
133 | 133 | ||
134 | |||
134 | static char * | 135 | static char * |
135 | get_path_from_NSGetExecutablePath () | 136 | get_path_from_NSGetExecutablePath () |
136 | { | 137 | { |
@@ -138,22 +139,19 @@ get_path_from_NSGetExecutablePath () | |||
138 | char *path; | 139 | char *path; |
139 | size_t len; | 140 | size_t len; |
140 | MyNSGetExecutablePathProto func; | 141 | MyNSGetExecutablePathProto func; |
141 | int ret; | ||
142 | 142 | ||
143 | path = NULL; | 143 | path = NULL; |
144 | func = | 144 | if (NULL == (func = |
145 | (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT, "_NSGetExecutablePath"); | 145 | (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT, "_NSGetExecutablePath"))) |
146 | if (!func) | ||
147 | return NULL; | 146 | return NULL; |
148 | path = &zero; | 147 | path = &zero; |
149 | len = 0; | 148 | len = 0; |
150 | /* get the path len, including the trailing \0 */ | 149 | /* get the path len, including the trailing \0 */ |
151 | func (path, &len); | 150 | func (path, &len); |
152 | if (len == 0) | 151 | if (0 == len) |
153 | return NULL; | 152 | return NULL; |
154 | path = GNUNET_malloc (len); | 153 | path = GNUNET_malloc (len); |
155 | ret = func (path, &len); | 154 | if (0 != func (path, &len)) |
156 | if (ret != 0) | ||
157 | { | 155 | { |
158 | GNUNET_free (path); | 156 | GNUNET_free (path); |
159 | return NULL; | 157 | return NULL; |
@@ -165,11 +163,13 @@ get_path_from_NSGetExecutablePath () | |||
165 | return path; | 163 | return path; |
166 | } | 164 | } |
167 | 165 | ||
166 | |||
168 | static char * | 167 | static char * |
169 | get_path_from_dyld_image () | 168 | get_path_from_dyld_image () |
170 | { | 169 | { |
171 | const char *path; | 170 | const char *path; |
172 | char *p, *s; | 171 | char *p; |
172 | char *s; | ||
173 | int i; | 173 | int i; |
174 | int c; | 174 | int c; |
175 | 175 | ||
@@ -180,11 +180,11 @@ get_path_from_dyld_image () | |||
180 | if (_dyld_get_image_header (i) == &_mh_dylib_header) | 180 | if (_dyld_get_image_header (i) == &_mh_dylib_header) |
181 | { | 181 | { |
182 | path = _dyld_get_image_name (i); | 182 | path = _dyld_get_image_name (i); |
183 | if (path != NULL && strlen (path) > 0) | 183 | if ( (NULL != path) && (strlen (path) > 0) ) |
184 | { | 184 | { |
185 | p = GNUNET_strdup (path); | 185 | p = GNUNET_strdup (path); |
186 | s = p + strlen (p); | 186 | s = p + strlen (p); |
187 | while ((s > p) && (*s != '/')) | 187 | while ((s > p) && ('/' != *s)) |
188 | s--; | 188 | s--; |
189 | s++; | 189 | s++; |
190 | *s = '\0'; | 190 | *s = '\0'; |
@@ -196,6 +196,7 @@ get_path_from_dyld_image () | |||
196 | } | 196 | } |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | |||
199 | /** | 200 | /** |
200 | * Return the actual path to a file found in the current | 201 | * Return the actual path to a file found in the current |
201 | * PATH environment variable. | 202 | * PATH environment variable. |
@@ -213,7 +214,7 @@ get_path_from_PATH (const char *binary) | |||
213 | const char *p; | 214 | const char *p; |
214 | 215 | ||
215 | p = getenv ("PATH"); | 216 | p = getenv ("PATH"); |
216 | if (p == NULL) | 217 | if (NULL == p) |
217 | return NULL; | 218 | return NULL; |
218 | path = GNUNET_strdup (p); /* because we write on it */ | 219 | path = GNUNET_strdup (p); /* because we write on it */ |
219 | buf = GNUNET_malloc (strlen (path) + 20); | 220 | buf = GNUNET_malloc (strlen (path) + 20); |
@@ -232,7 +233,7 @@ get_path_from_PATH (const char *binary) | |||
232 | pos = end + 1; | 233 | pos = end + 1; |
233 | } | 234 | } |
234 | sprintf (buf, "%s/%s", pos, binary); | 235 | sprintf (buf, "%s/%s", pos, binary); |
235 | if (GNUNET_DISK_file_test (buf) == GNUNET_YES) | 236 | if (GNUNET_YES == GNUNET_DISK_file_test (buf)) |
236 | { | 237 | { |
237 | pos = GNUNET_strdup (pos); | 238 | pos = GNUNET_strdup (pos); |
238 | GNUNET_free (buf); | 239 | GNUNET_free (buf); |
@@ -244,17 +245,18 @@ get_path_from_PATH (const char *binary) | |||
244 | return NULL; | 245 | return NULL; |
245 | } | 246 | } |
246 | 247 | ||
248 | |||
247 | static char * | 249 | static char * |
248 | get_path_from_GNUNET_PREFIX () | 250 | get_path_from_GNUNET_PREFIX () |
249 | { | 251 | { |
250 | const char *p; | 252 | const char *p; |
251 | 253 | ||
252 | p = getenv ("GNUNET_PREFIX"); | 254 | if (NULL != (p = getenv ("GNUNET_PREFIX"))) |
253 | if (p != NULL) | ||
254 | return GNUNET_strdup (p); | 255 | return GNUNET_strdup (p); |
255 | return NULL; | 256 | return NULL; |
256 | } | 257 | } |
257 | 258 | ||
259 | |||
258 | /** | 260 | /** |
259 | * @brief get the path to GNUnet bin/ or lib/, prefering the lib/ path | 261 | * @brief get the path to GNUnet bin/ or lib/, prefering the lib/ path |
260 | * @author Milan | 262 | * @author Milan |
@@ -266,32 +268,25 @@ os_get_gnunet_path () | |||
266 | { | 268 | { |
267 | char *ret; | 269 | char *ret; |
268 | 270 | ||
269 | ret = get_path_from_GNUNET_PREFIX (); | 271 | if (NULL != (ret = get_path_from_GNUNET_PREFIX ())) |
270 | if (ret != NULL) | ||
271 | return ret; | 272 | return ret; |
272 | #if LINUX | 273 | #if LINUX |
273 | ret = get_path_from_proc_maps (); | 274 | if (NULL != (ret = get_path_from_proc_maps ())) |
274 | if (ret != NULL) | ||
275 | return ret; | 275 | return ret; |
276 | ret = get_path_from_proc_exe (); | 276 | if (NULL != (ret = get_path_from_proc_exe ())) |
277 | if (ret != NULL) | ||
278 | return ret; | 277 | return ret; |
279 | #endif | 278 | #endif |
280 | #if WINDOWS | 279 | #if WINDOWS |
281 | ret = get_path_from_module_filename (); | 280 | if (NULL != (ret = get_path_from_module_filename ())) |
282 | if (ret != NULL) | ||
283 | return ret; | 281 | return ret; |
284 | #endif | 282 | #endif |
285 | #if DARWIN | 283 | #if DARWIN |
286 | ret = get_path_from_dyld_image (); | 284 | if (NULL != (ret = get_path_from_dyld_image ())) |
287 | if (ret != NULL) | ||
288 | return ret; | 285 | return ret; |
289 | ret = get_path_from_NSGetExecutablePath (); | 286 | if (NULL != (ret = get_path_from_NSGetExecutablePath ())) |
290 | if (ret != NULL) | ||
291 | return ret; | 287 | return ret; |
292 | #endif | 288 | #endif |
293 | ret = get_path_from_PATH ("gnunet-arm"); | 289 | if (NULL != (ret = get_path_from_PATH ("gnunet-arm"))) |
294 | if (ret != NULL) | ||
295 | return ret; | 290 | return ret; |
296 | /* other attempts here */ | 291 | /* other attempts here */ |
297 | LOG (GNUNET_ERROR_TYPE_ERROR, | 292 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -312,24 +307,20 @@ os_get_exec_path () | |||
312 | { | 307 | { |
313 | char *ret; | 308 | char *ret; |
314 | 309 | ||
315 | ret = NULL; | ||
316 | #if LINUX | 310 | #if LINUX |
317 | ret = get_path_from_proc_exe (); | 311 | if (NULL != (ret = get_path_from_proc_exe ())) |
318 | if (ret != NULL) | ||
319 | return ret; | 312 | return ret; |
320 | #endif | 313 | #endif |
321 | #if WINDOWS | 314 | #if WINDOWS |
322 | ret = get_path_from_module_filename (); | 315 | if (NULL != (ret = get_path_from_module_filename ())) |
323 | if (ret != NULL) | ||
324 | return ret; | 316 | return ret; |
325 | #endif | 317 | #endif |
326 | #if DARWIN | 318 | #if DARWIN |
327 | ret = get_path_from_NSGetExecutablePath (); | 319 | if (NULL != (ret = get_path_from_NSGetExecutablePath ())) |
328 | if (ret != NULL) | ||
329 | return ret; | 320 | return ret; |
330 | #endif | 321 | #endif |
331 | /* other attempts here */ | 322 | /* other attempts here */ |
332 | return ret; | 323 | return NULL; |
333 | } | 324 | } |
334 | 325 | ||
335 | 326 | ||
@@ -355,21 +346,21 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) | |||
355 | 346 | ||
356 | /* try to get GNUnet's bin/ or lib/, or if previous was unsuccessful some | 347 | /* try to get GNUnet's bin/ or lib/, or if previous was unsuccessful some |
357 | * guess for the current app */ | 348 | * guess for the current app */ |
358 | if (execpath == NULL) | 349 | if (NULL == execpath) |
359 | execpath = os_get_gnunet_path (); | 350 | execpath = os_get_gnunet_path (); |
360 | 351 | ||
361 | if (execpath == NULL) | 352 | if (NULL == execpath) |
362 | return NULL; | 353 | return NULL; |
363 | 354 | ||
364 | n = strlen (execpath); | 355 | n = strlen (execpath); |
365 | if (n == 0) | 356 | if (0 == n) |
366 | { | 357 | { |
367 | /* should never happen, but better safe than sorry */ | 358 | /* should never happen, but better safe than sorry */ |
368 | GNUNET_free (execpath); | 359 | GNUNET_free (execpath); |
369 | return NULL; | 360 | return NULL; |
370 | } | 361 | } |
371 | /* remove filename itself */ | 362 | /* remove filename itself */ |
372 | while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR)) | 363 | while ((n > 1) && (DIR_SEPARATOR == execpath[n - 1])) |
373 | execpath[--n] = '\0'; | 364 | execpath[--n] = '\0'; |
374 | 365 | ||
375 | isbasedir = 1; | 366 | isbasedir = 1; |
@@ -377,7 +368,7 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) | |||
377 | ((0 == strcasecmp (&execpath[n - 5], "lib32")) || | 368 | ((0 == strcasecmp (&execpath[n - 5], "lib32")) || |
378 | (0 == strcasecmp (&execpath[n - 5], "lib64")))) | 369 | (0 == strcasecmp (&execpath[n - 5], "lib64")))) |
379 | { | 370 | { |
380 | if (dirkind != GNUNET_OS_IPK_LIBDIR) | 371 | if (GNUNET_OS_IPK_LIBDIR != dirkind) |
381 | { | 372 | { |
382 | /* strip '/lib32' or '/lib64' */ | 373 | /* strip '/lib32' or '/lib64' */ |
383 | execpath[n - 5] = '\0'; | 374 | execpath[n - 5] = '\0'; |
@@ -458,30 +449,39 @@ GNUNET_OS_check_helper_binary (const char *binary) | |||
458 | struct stat statbuf; | 449 | struct stat statbuf; |
459 | char *p; | 450 | char *p; |
460 | char *pf; | 451 | char *pf; |
461 | |||
462 | #ifdef MINGW | 452 | #ifdef MINGW |
463 | SOCKET rawsock; | 453 | SOCKET rawsock; |
464 | char *binaryexe; | 454 | char *binaryexe; |
465 | 455 | ||
466 | GNUNET_asprintf (&binaryexe, "%s.exe", binary); | 456 | GNUNET_asprintf (&binaryexe, "%s.exe", binary); |
467 | p = get_path_from_PATH (binaryexe); | 457 | if (DIR_SEPARATOR == binary[0]) |
468 | if (p != NULL) | 458 | p = GNUNET_strdup (binary); |
459 | else | ||
469 | { | 460 | { |
470 | GNUNET_asprintf (&pf, "%s/%s", p, binaryexe); | 461 | p = get_path_from_PATH (binaryexe); |
471 | GNUNET_free (p); | 462 | if (NULL != p) |
472 | p = pf; | 463 | { |
464 | GNUNET_asprintf (&pf, "%s/%s", p, binaryexe); | ||
465 | GNUNET_free (p); | ||
466 | p = pf; | ||
467 | } | ||
473 | } | 468 | } |
474 | GNUNET_free (binaryexe); | 469 | GNUNET_free (binaryexe); |
475 | #else | 470 | #else |
476 | p = get_path_from_PATH (binary); | 471 | if (DIR_SEPARATOR == binary[0]) |
477 | if (p != NULL) | 472 | p = GNUNET_strdup (binary); |
473 | else | ||
478 | { | 474 | { |
479 | GNUNET_asprintf (&pf, "%s/%s", p, binary); | 475 | p = get_path_from_PATH (binary); |
480 | GNUNET_free (p); | 476 | if (NULL != p) |
481 | p = pf; | 477 | { |
478 | GNUNET_asprintf (&pf, "%s/%s", p, binary); | ||
479 | GNUNET_free (p); | ||
480 | p = pf; | ||
481 | } | ||
482 | } | 482 | } |
483 | #endif | 483 | #endif |
484 | if (p == NULL) | 484 | if (NULL == p) |
485 | { | 485 | { |
486 | LOG (GNUNET_ERROR_TYPE_INFO, _("Could not find binary `%s' in PATH!\n"), | 486 | LOG (GNUNET_ERROR_TYPE_INFO, _("Could not find binary `%s' in PATH!\n"), |
487 | binary); | 487 | binary); |
diff --git a/src/util/os_priority.c b/src/util/os_priority.c index e53dbfa2d..3f49290a7 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c | |||
@@ -781,7 +781,7 @@ start_process (int pipe_control, | |||
781 | pid_t ret; | 781 | pid_t ret; |
782 | char lpid[16]; | 782 | char lpid[16]; |
783 | char fds[16]; | 783 | char fds[16]; |
784 | struct GNUNET_OS_Process *gnunet_proc = NULL; | 784 | struct GNUNET_OS_Process *gnunet_proc; |
785 | char *childpipename = NULL; | 785 | char *childpipename = NULL; |
786 | int i; | 786 | int i; |
787 | int j; | 787 | int j; |
@@ -918,7 +918,7 @@ start_process (int pipe_control, | |||
918 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename); | 918 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename); |
919 | _exit (1); | 919 | _exit (1); |
920 | #else | 920 | #else |
921 | struct GNUNET_DISK_FileHandle *control_pipe = NULL; | 921 | struct GNUNET_DISK_FileHandle *control_pipe; |
922 | char *childpipename = NULL; | 922 | char *childpipename = NULL; |
923 | char **arg; | 923 | char **arg; |
924 | char **non_const_argv; | 924 | char **non_const_argv; |
@@ -928,7 +928,7 @@ start_process (int pipe_control, | |||
928 | STARTUPINFOW start; | 928 | STARTUPINFOW start; |
929 | PROCESS_INFORMATION proc; | 929 | PROCESS_INFORMATION proc; |
930 | int argcount = 0; | 930 | int argcount = 0; |
931 | struct GNUNET_OS_Process *gnunet_proc = NULL; | 931 | struct GNUNET_OS_Process *gnunet_proc; |
932 | char path[MAX_PATH + 1]; | 932 | char path[MAX_PATH + 1]; |
933 | char *our_env[5] = { NULL, NULL, NULL, NULL, NULL }; | 933 | char *our_env[5] = { NULL, NULL, NULL, NULL, NULL }; |
934 | char *env_block = NULL; | 934 | char *env_block = NULL; |
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index 4a3a20375..f924661dd 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include "gnunet_resolver_service.h" | 30 | #include "gnunet_resolver_service.h" |
31 | #include "resolver.h" | 31 | #include "resolver.h" |
32 | 32 | ||
33 | #define VERBOSE GNUNET_NO | ||
34 | 33 | ||
35 | /** | 34 | /** |
36 | * Using DNS root servers to check gnunet's resolver service | 35 | * Using DNS root servers to check gnunet's resolver service |
@@ -40,12 +39,13 @@ | |||
40 | #define ROOTSERVER_NAME "a.root-servers.net" | 39 | #define ROOTSERVER_NAME "a.root-servers.net" |
41 | #define ROOTSERVER_IP "198.41.0.4" | 40 | #define ROOTSERVER_IP "198.41.0.4" |
42 | 41 | ||
42 | |||
43 | static void | 43 | static void |
44 | check_hostname (void *cls, const struct sockaddr *sa, socklen_t salen) | 44 | check_hostname (void *cls, const struct sockaddr *sa, socklen_t salen) |
45 | { | 45 | { |
46 | int *ok = cls; | 46 | int *ok = cls; |
47 | 47 | ||
48 | if (salen == 0) | 48 | if (0 == salen) |
49 | { | 49 | { |
50 | (*ok) &= ~8; | 50 | (*ok) &= ~8; |
51 | return; | 51 | return; |
@@ -82,7 +82,7 @@ check_localhost (void *cls, const char *hostname) | |||
82 | { | 82 | { |
83 | int *ok = cls; | 83 | int *ok = cls; |
84 | 84 | ||
85 | if (hostname == NULL) | 85 | if (NULL == hostname) |
86 | return; | 86 | return; |
87 | if (0 == strcmp (hostname, "localhost")) | 87 | if (0 == strcmp (hostname, "localhost")) |
88 | { | 88 | { |
@@ -98,13 +98,14 @@ check_localhost (void *cls, const char *hostname) | |||
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | |||
101 | static void | 102 | static void |
102 | check_127 (void *cls, const struct sockaddr *sa, socklen_t salen) | 103 | check_127 (void *cls, const struct sockaddr *sa, socklen_t salen) |
103 | { | 104 | { |
104 | int *ok = cls; | 105 | int *ok = cls; |
105 | const struct sockaddr_in *sai = (const struct sockaddr_in *) sa; | 106 | const struct sockaddr_in *sai = (const struct sockaddr_in *) sa; |
106 | 107 | ||
107 | if (sa == NULL) | 108 | if (NULL == sa) |
108 | return; | 109 | return; |
109 | GNUNET_assert (sizeof (struct sockaddr_in) == salen); | 110 | GNUNET_assert (sizeof (struct sockaddr_in) == salen); |
110 | if (sai->sin_addr.s_addr == htonl (INADDR_LOOPBACK)) | 111 | if (sai->sin_addr.s_addr == htonl (INADDR_LOOPBACK)) |
@@ -122,6 +123,7 @@ check_127 (void *cls, const struct sockaddr *sa, socklen_t salen) | |||
122 | } | 123 | } |
123 | } | 124 | } |
124 | 125 | ||
126 | |||
125 | static void | 127 | static void |
126 | check_local_fqdn (void *cls, const char *gnunet_fqdn) | 128 | check_local_fqdn (void *cls, const char *gnunet_fqdn) |
127 | { | 129 | { |
@@ -159,14 +161,13 @@ check_local_fqdn (void *cls, const char *gnunet_fqdn) | |||
159 | } | 161 | } |
160 | 162 | ||
161 | 163 | ||
162 | |||
163 | static void | 164 | static void |
164 | check_rootserver_ip (void *cls, const struct sockaddr *sa, socklen_t salen) | 165 | check_rootserver_ip (void *cls, const struct sockaddr *sa, socklen_t salen) |
165 | { | 166 | { |
166 | int *ok = cls; | 167 | int *ok = cls; |
167 | const struct sockaddr_in *sai = (const struct sockaddr_in *) sa; | 168 | const struct sockaddr_in *sai = (const struct sockaddr_in *) sa; |
168 | 169 | ||
169 | if (sa == NULL) | 170 | if (NULL == sa) |
170 | return; | 171 | return; |
171 | GNUNET_assert (sizeof (struct sockaddr_in) == salen); | 172 | GNUNET_assert (sizeof (struct sockaddr_in) == salen); |
172 | 173 | ||
@@ -184,12 +185,13 @@ check_rootserver_ip (void *cls, const struct sockaddr *sa, socklen_t salen) | |||
184 | } | 185 | } |
185 | } | 186 | } |
186 | 187 | ||
188 | |||
187 | static void | 189 | static void |
188 | check_rootserver_name (void *cls, const char *hostname) | 190 | check_rootserver_name (void *cls, const char *hostname) |
189 | { | 191 | { |
190 | int *ok = cls; | 192 | int *ok = cls; |
191 | 193 | ||
192 | if (hostname == NULL) | 194 | if (NULL == hostname) |
193 | return; | 195 | return; |
194 | 196 | ||
195 | if (0 == strcmp (hostname, ROOTSERVER_NAME)) | 197 | if (0 == strcmp (hostname, ROOTSERVER_NAME)) |
@@ -206,6 +208,7 @@ check_rootserver_name (void *cls, const char *hostname) | |||
206 | } | 208 | } |
207 | } | 209 | } |
208 | 210 | ||
211 | |||
209 | static void | 212 | static void |
210 | run (void *cls, char *const *args, const char *cfgfile, | 213 | run (void *cls, char *const *args, const char *cfgfile, |
211 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 214 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -347,36 +350,33 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
347 | 350 | ||
348 | } | 351 | } |
349 | 352 | ||
350 | static int | 353 | |
351 | check () | 354 | int |
355 | main (int argc, char *argv[]) | ||
352 | { | 356 | { |
353 | int ok = 1 + 2 + 4 + 8; | 357 | int ok = 1 + 2 + 4 + 8; |
354 | char *fn; | 358 | char *fn; |
355 | char *pfx; | 359 | char *pfx; |
356 | struct GNUNET_OS_Process *proc; | 360 | struct GNUNET_OS_Process *proc; |
357 | 361 | char *const argvx[] = { | |
358 | char *const argv[] = | 362 | "test-resolver-api", "-c", "test_resolver_api_data.conf", NULL |
359 | { "test-resolver-api", "-c", "test_resolver_api_data.conf", | ||
360 | #if VERBOSE | ||
361 | "-L", "DEBUG", | ||
362 | #endif | ||
363 | NULL | ||
364 | }; | 363 | }; |
365 | struct GNUNET_GETOPT_CommandLineOption options[] = | 364 | struct GNUNET_GETOPT_CommandLineOption options[] = |
366 | { GNUNET_GETOPT_OPTION_END }; | 365 | { GNUNET_GETOPT_OPTION_END }; |
366 | |||
367 | GNUNET_log_setup ("test-resolver-api", | ||
368 | "WARNING", | ||
369 | NULL); | ||
367 | pfx = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); | 370 | pfx = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); |
368 | GNUNET_asprintf (&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR); | 371 | GNUNET_asprintf (&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR); |
369 | GNUNET_free (pfx); | 372 | GNUNET_free (pfx); |
370 | proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, fn, "gnunet-service-resolver", | 373 | proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, fn, "gnunet-service-resolver", |
371 | #if VERBOSE | ||
372 | "-L", "DEBUG", | ||
373 | #endif | ||
374 | "-c", "test_resolver_api_data.conf", NULL); | 374 | "-c", "test_resolver_api_data.conf", NULL); |
375 | GNUNET_assert (NULL != proc); | 375 | GNUNET_assert (NULL != proc); |
376 | GNUNET_free (fn); | 376 | GNUNET_free (fn); |
377 | GNUNET_assert (GNUNET_OK == | 377 | GNUNET_assert (GNUNET_OK == |
378 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 378 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, |
379 | argv, "test-resolver-api", "nohelp", | 379 | argvx, "test-resolver-api", "nohelp", |
380 | options, &run, &ok)); | 380 | options, &run, &ok)); |
381 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 381 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
382 | { | 382 | { |
@@ -386,26 +386,10 @@ check () | |||
386 | GNUNET_OS_process_wait (proc); | 386 | GNUNET_OS_process_wait (proc); |
387 | GNUNET_OS_process_destroy (proc); | 387 | GNUNET_OS_process_destroy (proc); |
388 | proc = NULL; | 388 | proc = NULL; |
389 | if (ok != 0) | 389 | if (0 != ok) |
390 | FPRINTF (stderr, "Missed some resolutions: %u\n", ok); | 390 | FPRINTF (stderr, "Missed some resolutions: %u\n", ok); |
391 | return ok; | 391 | return ok; |
392 | } | 392 | } |
393 | 393 | ||
394 | int | ||
395 | main (int argc, char *argv[]) | ||
396 | { | ||
397 | int ret; | ||
398 | |||
399 | GNUNET_log_setup ("test-resolver-api", | ||
400 | #if VERBOSE | ||
401 | "DEBUG", | ||
402 | #else | ||
403 | "WARNING", | ||
404 | #endif | ||
405 | NULL); | ||
406 | ret = check (); | ||
407 | |||
408 | return ret; | ||
409 | } | ||
410 | 394 | ||
411 | /* end of test_resolver_api.c */ | 395 | /* end of test_resolver_api.c */ |