diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
commit | 83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch) | |
tree | d0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/util/program.c | |
parent | 28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff) | |
download | gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip |
curly wars / auto-indentation
Diffstat (limited to 'src/util/program.c')
-rw-r--r-- | src/util/program.c | 108 |
1 files changed, 53 insertions, 55 deletions
diff --git a/src/util/program.c b/src/util/program.c index 5582f30c6..6a0e5a555 100644 --- a/src/util/program.c +++ b/src/util/program.c | |||
@@ -129,9 +129,9 @@ cmd_sorter (__const void *a1, __const void *a2) | |||
129 | */ | 129 | */ |
130 | int | 130 | int |
131 | GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, | 131 | GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, |
132 | const char *binaryHelp, | 132 | const char *binaryHelp, |
133 | const struct GNUNET_GETOPT_CommandLineOption *options, | 133 | const struct GNUNET_GETOPT_CommandLineOption *options, |
134 | GNUNET_PROGRAM_Main task, void *task_cls) | 134 | GNUNET_PROGRAM_Main task, void *task_cls) |
135 | { | 135 | { |
136 | struct CommandContext cc; | 136 | struct CommandContext cc; |
137 | char *path; | 137 | char *path; |
@@ -159,29 +159,29 @@ GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, | |||
159 | logfile = NULL; | 159 | logfile = NULL; |
160 | gargs = getenv ("GNUNET_ARGS"); | 160 | gargs = getenv ("GNUNET_ARGS"); |
161 | if (gargs != NULL) | 161 | if (gargs != NULL) |
162 | { | 162 | { |
163 | char **gargv; | 163 | char **gargv; |
164 | unsigned int gargc; | 164 | unsigned int gargc; |
165 | int i; | 165 | int i; |
166 | char *tok; | 166 | char *tok; |
167 | char *cargs; | 167 | char *cargs; |
168 | 168 | ||
169 | gargv = NULL; | 169 | gargv = NULL; |
170 | gargc = 0; | 170 | gargc = 0; |
171 | for (i = 0; i < argc; i++) | 171 | for (i = 0; i < argc; i++) |
172 | GNUNET_array_append (gargv, gargc, GNUNET_strdup (argv[i])); | 172 | GNUNET_array_append (gargv, gargc, GNUNET_strdup (argv[i])); |
173 | cargs = GNUNET_strdup (gargs); | 173 | cargs = GNUNET_strdup (gargs); |
174 | tok = strtok (cargs, " "); | 174 | tok = strtok (cargs, " "); |
175 | while (NULL != tok) | 175 | while (NULL != tok) |
176 | { | 176 | { |
177 | GNUNET_array_append (gargv, gargc, GNUNET_strdup (tok)); | 177 | GNUNET_array_append (gargv, gargc, GNUNET_strdup (tok)); |
178 | tok = strtok (NULL, " "); | 178 | tok = strtok (NULL, " "); |
179 | } | ||
180 | GNUNET_free (cargs); | ||
181 | GNUNET_array_append (gargv, gargc, NULL); | ||
182 | argv = (char *const *) gargv; | ||
183 | argc = gargc - 1; | ||
184 | } | 179 | } |
180 | GNUNET_free (cargs); | ||
181 | GNUNET_array_append (gargv, gargc, NULL); | ||
182 | argv = (char *const *) gargv; | ||
183 | argc = gargc - 1; | ||
184 | } | ||
185 | memset (&cc, 0, sizeof (cc)); | 185 | memset (&cc, 0, sizeof (cc)); |
186 | loglev = NULL; | 186 | loglev = NULL; |
187 | cc.task = task; | 187 | cc.task = task; |
@@ -193,28 +193,27 @@ GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, | |||
193 | setlocale (LC_ALL, ""); | 193 | setlocale (LC_ALL, ""); |
194 | path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR); | 194 | path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LOCALEDIR); |
195 | if (path != NULL) | 195 | if (path != NULL) |
196 | { | 196 | { |
197 | BINDTEXTDOMAIN ("GNUnet", path); | 197 | BINDTEXTDOMAIN ("GNUnet", path); |
198 | GNUNET_free (path); | 198 | GNUNET_free (path); |
199 | } | 199 | } |
200 | textdomain ("GNUnet"); | 200 | textdomain ("GNUnet"); |
201 | #endif | 201 | #endif |
202 | cnt = 0; | 202 | cnt = 0; |
203 | while (options[cnt].name != NULL) | 203 | while (options[cnt].name != NULL) |
204 | cnt++; | 204 | cnt++; |
205 | allopts = | 205 | allopts = |
206 | GNUNET_malloc ((cnt + | 206 | GNUNET_malloc ((cnt + |
207 | 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption) + | 207 | 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption) + |
208 | sizeof (defoptions)); | 208 | sizeof (defoptions)); |
209 | memcpy (allopts, defoptions, sizeof (defoptions)); | 209 | memcpy (allopts, defoptions, sizeof (defoptions)); |
210 | memcpy (&allopts | 210 | memcpy (&allopts |
211 | [sizeof (defoptions) / | 211 | [sizeof (defoptions) / |
212 | sizeof (struct GNUNET_GETOPT_CommandLineOption)], options, | 212 | sizeof (struct GNUNET_GETOPT_CommandLineOption)], options, |
213 | (cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption)); | 213 | (cnt + 1) * sizeof (struct GNUNET_GETOPT_CommandLineOption)); |
214 | cnt += | 214 | cnt += sizeof (defoptions) / sizeof (struct GNUNET_GETOPT_CommandLineOption); |
215 | sizeof (defoptions) / sizeof (struct GNUNET_GETOPT_CommandLineOption); | ||
216 | qsort (allopts, cnt, sizeof (struct GNUNET_GETOPT_CommandLineOption), | 215 | qsort (allopts, cnt, sizeof (struct GNUNET_GETOPT_CommandLineOption), |
217 | &cmd_sorter); | 216 | &cmd_sorter); |
218 | loglev = NULL; | 217 | loglev = NULL; |
219 | cc.cfgfile = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE); | 218 | cc.cfgfile = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE); |
220 | lpfx = GNUNET_strdup (binaryName); | 219 | lpfx = GNUNET_strdup (binaryName); |
@@ -222,31 +221,30 @@ GNUNET_PROGRAM_run (int argc, char *const *argv, const char *binaryName, | |||
222 | *spc = '\0'; | 221 | *spc = '\0'; |
223 | if ((-1 == | 222 | if ((-1 == |
224 | (ret = | 223 | (ret = |
225 | GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv))) | 224 | GNUNET_GETOPT_run (binaryName, allopts, (unsigned int) argc, argv))) || |
226 | || (GNUNET_OK != GNUNET_log_setup (lpfx, loglev, logfile))) | 225 | (GNUNET_OK != GNUNET_log_setup (lpfx, loglev, logfile))) |
227 | { | 226 | { |
228 | GNUNET_CONFIGURATION_destroy (cfg); | 227 | GNUNET_CONFIGURATION_destroy (cfg); |
229 | GNUNET_free_non_null (cc.cfgfile); | 228 | GNUNET_free_non_null (cc.cfgfile); |
230 | GNUNET_free_non_null (loglev); | 229 | GNUNET_free_non_null (loglev); |
231 | GNUNET_free_non_null (logfile); | 230 | GNUNET_free_non_null (logfile); |
232 | GNUNET_free (allopts); | 231 | GNUNET_free (allopts); |
233 | GNUNET_free (lpfx); | 232 | GNUNET_free (lpfx); |
234 | return GNUNET_SYSERR; | 233 | return GNUNET_SYSERR; |
235 | } | 234 | } |
236 | (void) GNUNET_CONFIGURATION_load (cfg, cc.cfgfile); | 235 | (void) GNUNET_CONFIGURATION_load (cfg, cc.cfgfile); |
237 | GNUNET_free (allopts); | 236 | GNUNET_free (allopts); |
238 | GNUNET_free (lpfx); | 237 | GNUNET_free (lpfx); |
239 | if (GNUNET_OK == | 238 | if (GNUNET_OK == |
240 | GNUNET_CONFIGURATION_get_value_number (cc.cfg, "testing", "skew_offset", | 239 | GNUNET_CONFIGURATION_get_value_number (cc.cfg, "testing", "skew_offset", |
241 | &skew_offset) && | 240 | &skew_offset) && |
242 | (GNUNET_OK == | 241 | (GNUNET_OK == |
243 | GNUNET_CONFIGURATION_get_value_number (cc.cfg, "testing", | 242 | GNUNET_CONFIGURATION_get_value_number (cc.cfg, "testing", |
244 | "skew_variance", | 243 | "skew_variance", &skew_variance))) |
245 | &skew_variance))) | 244 | { |
246 | { | 245 | clock_offset = skew_offset - skew_variance; |
247 | clock_offset = skew_offset - skew_variance; | 246 | GNUNET_TIME_set_offset (clock_offset); |
248 | GNUNET_TIME_set_offset (clock_offset); | 247 | } |
249 | } | ||
250 | /* run */ | 248 | /* run */ |
251 | cc.args = &argv[ret]; | 249 | cc.args = &argv[ret]; |
252 | GNUNET_SCHEDULER_run (&program_main, &cc); | 250 | GNUNET_SCHEDULER_run (&program_main, &cc); |