diff options
Diffstat (limited to 'src/util/gnunet-uri.c')
-rw-r--r-- | src/util/gnunet-uri.c | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/src/util/gnunet-uri.c b/src/util/gnunet-uri.c index 75667b30f..a80ac0997 100644 --- a/src/util/gnunet-uri.c +++ b/src/util/gnunet-uri.c | |||
@@ -49,15 +49,15 @@ static struct GNUNET_DISK_PipeHandle *sigpipe; | |||
49 | * @param cls closure, NULL | 49 | * @param cls closure, NULL |
50 | */ | 50 | */ |
51 | static void | 51 | static void |
52 | maint_child_death(void *cls) | 52 | maint_child_death (void *cls) |
53 | { | 53 | { |
54 | enum GNUNET_OS_ProcessStatusType type; | 54 | enum GNUNET_OS_ProcessStatusType type; |
55 | 55 | ||
56 | (void)cls; | 56 | (void) cls; |
57 | if ((GNUNET_OK != GNUNET_OS_process_status(p, &type, &exit_code)) || | 57 | if ((GNUNET_OK != GNUNET_OS_process_status (p, &type, &exit_code)) || |
58 | (type != GNUNET_OS_PROCESS_EXITED)) | 58 | (type != GNUNET_OS_PROCESS_EXITED)) |
59 | GNUNET_break(0 == GNUNET_OS_process_kill(p, GNUNET_TERM_SIG)); | 59 | GNUNET_break (0 == GNUNET_OS_process_kill (p, GNUNET_TERM_SIG)); |
60 | GNUNET_OS_process_destroy(p); | 60 | GNUNET_OS_process_destroy (p); |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
@@ -70,10 +70,10 @@ maint_child_death(void *cls) | |||
70 | * @param cfg configuration | 70 | * @param cfg configuration |
71 | */ | 71 | */ |
72 | static void | 72 | static void |
73 | run(void *cls, | 73 | run (void *cls, |
74 | char *const *args, | 74 | char *const *args, |
75 | const char *cfgfile, | 75 | const char *cfgfile, |
76 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 76 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
77 | { | 77 | { |
78 | const char *uri; | 78 | const char *uri; |
79 | const char *slash; | 79 | const char *slash; |
@@ -81,52 +81,52 @@ run(void *cls, | |||
81 | char *program; | 81 | char *program; |
82 | struct GNUNET_SCHEDULER_Task *rt; | 82 | struct GNUNET_SCHEDULER_Task *rt; |
83 | 83 | ||
84 | (void)cls; | 84 | (void) cls; |
85 | (void)cfgfile; | 85 | (void) cfgfile; |
86 | if (NULL == (uri = args[0])) | 86 | if (NULL == (uri = args[0])) |
87 | { | 87 | { |
88 | fprintf(stderr, _("No URI specified on command line\n")); | 88 | fprintf (stderr, _ ("No URI specified on command line\n")); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | if (0 != strncasecmp("gnunet://", uri, strlen("gnunet://"))) | 91 | if (0 != strncasecmp ("gnunet://", uri, strlen ("gnunet://"))) |
92 | { | 92 | { |
93 | fprintf(stderr, | 93 | fprintf (stderr, |
94 | _("Invalid URI: does not start with `%s'\n"), | 94 | _ ("Invalid URI: does not start with `%s'\n"), |
95 | "gnunet://"); | 95 | "gnunet://"); |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | uri += strlen("gnunet://"); | 98 | uri += strlen ("gnunet://"); |
99 | if (NULL == (slash = strchr(uri, '/'))) | 99 | if (NULL == (slash = strchr (uri, '/'))) |
100 | { | 100 | { |
101 | fprintf(stderr, _("Invalid URI: fails to specify subsystem\n")); | 101 | fprintf (stderr, _ ("Invalid URI: fails to specify subsystem\n")); |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | subsystem = GNUNET_strndup(uri, slash - uri); | 104 | subsystem = GNUNET_strndup (uri, slash - uri); |
105 | if (GNUNET_OK != | 105 | if (GNUNET_OK != |
106 | GNUNET_CONFIGURATION_get_value_string(cfg, "uri", subsystem, &program)) | 106 | GNUNET_CONFIGURATION_get_value_string (cfg, "uri", subsystem, &program)) |
107 | { | 107 | { |
108 | fprintf(stderr, _("No handler known for subsystem `%s'\n"), subsystem); | 108 | fprintf (stderr, _ ("No handler known for subsystem `%s'\n"), subsystem); |
109 | GNUNET_free(subsystem); | 109 | GNUNET_free (subsystem); |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | GNUNET_free(subsystem); | 112 | GNUNET_free (subsystem); |
113 | rt = GNUNET_SCHEDULER_add_read_file( | 113 | rt = GNUNET_SCHEDULER_add_read_file ( |
114 | GNUNET_TIME_UNIT_FOREVER_REL, | 114 | GNUNET_TIME_UNIT_FOREVER_REL, |
115 | GNUNET_DISK_pipe_handle(sigpipe, GNUNET_DISK_PIPE_END_READ), | 115 | GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ), |
116 | &maint_child_death, | 116 | &maint_child_death, |
117 | NULL); | 117 | NULL); |
118 | p = GNUNET_OS_start_process(GNUNET_NO, | 118 | p = GNUNET_OS_start_process (GNUNET_NO, |
119 | 0, | 119 | 0, |
120 | NULL, | 120 | NULL, |
121 | NULL, | 121 | NULL, |
122 | NULL, | 122 | NULL, |
123 | program, | 123 | program, |
124 | program, | 124 | program, |
125 | args[0], | 125 | args[0], |
126 | NULL); | 126 | NULL); |
127 | GNUNET_free(program); | 127 | GNUNET_free (program); |
128 | if (NULL == p) | 128 | if (NULL == p) |
129 | GNUNET_SCHEDULER_cancel(rt); | 129 | GNUNET_SCHEDULER_cancel (rt); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
@@ -135,17 +135,17 @@ run(void *cls, | |||
135 | * respective handler by writing to the trigger pipe. | 135 | * respective handler by writing to the trigger pipe. |
136 | */ | 136 | */ |
137 | static void | 137 | static void |
138 | sighandler_child_death() | 138 | sighandler_child_death () |
139 | { | 139 | { |
140 | static char c; | 140 | static char c; |
141 | int old_errno = errno; /* back-up errno */ | 141 | int old_errno = errno; /* back-up errno */ |
142 | 142 | ||
143 | GNUNET_break( | 143 | GNUNET_break ( |
144 | 1 == | 144 | 1 == |
145 | GNUNET_DISK_file_write(GNUNET_DISK_pipe_handle(sigpipe, | 145 | GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle (sigpipe, |
146 | GNUNET_DISK_PIPE_END_WRITE), | 146 | GNUNET_DISK_PIPE_END_WRITE), |
147 | &c, | 147 | &c, |
148 | sizeof(c))); | 148 | sizeof(c))); |
149 | errno = old_errno; /* restore errno */ | 149 | errno = old_errno; /* restore errno */ |
150 | } | 150 | } |
151 | 151 | ||
@@ -158,7 +158,7 @@ sighandler_child_death() | |||
158 | * @return 0 ok, 1 on error | 158 | * @return 0 ok, 1 on error |
159 | */ | 159 | */ |
160 | int | 160 | int |
161 | main(int argc, char *const *argv) | 161 | main (int argc, char *const *argv) |
162 | { | 162 | { |
163 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 163 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
164 | GNUNET_GETOPT_OPTION_END | 164 | GNUNET_GETOPT_OPTION_END |
@@ -166,25 +166,25 @@ main(int argc, char *const *argv) | |||
166 | struct GNUNET_SIGNAL_Context *shc_chld; | 166 | struct GNUNET_SIGNAL_Context *shc_chld; |
167 | int ret; | 167 | int ret; |
168 | 168 | ||
169 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) | 169 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
170 | return 2; | 170 | return 2; |
171 | sigpipe = GNUNET_DISK_pipe(GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO); | 171 | sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO); |
172 | GNUNET_assert(sigpipe != NULL); | 172 | GNUNET_assert (sigpipe != NULL); |
173 | shc_chld = | 173 | shc_chld = |
174 | GNUNET_SIGNAL_handler_install(GNUNET_SIGCHLD, &sighandler_child_death); | 174 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); |
175 | ret = GNUNET_PROGRAM_run(argc, | 175 | ret = GNUNET_PROGRAM_run (argc, |
176 | argv, | 176 | argv, |
177 | "gnunet-uri URI", | 177 | "gnunet-uri URI", |
178 | gettext_noop( | 178 | gettext_noop ( |
179 | "Perform default-actions for GNUnet URIs"), | 179 | "Perform default-actions for GNUnet URIs"), |
180 | options, | 180 | options, |
181 | &run, | 181 | &run, |
182 | NULL); | 182 | NULL); |
183 | GNUNET_SIGNAL_handler_uninstall(shc_chld); | 183 | GNUNET_SIGNAL_handler_uninstall (shc_chld); |
184 | shc_chld = NULL; | 184 | shc_chld = NULL; |
185 | GNUNET_DISK_pipe_close(sigpipe); | 185 | GNUNET_DISK_pipe_close (sigpipe); |
186 | sigpipe = NULL; | 186 | sigpipe = NULL; |
187 | GNUNET_free((void *)argv); | 187 | GNUNET_free ((void *) argv); |
188 | return ((GNUNET_OK == ret) && (0 == exit_code)) ? 0 : 1; | 188 | return ((GNUNET_OK == ret) && (0 == exit_code)) ? 0 : 1; |
189 | } | 189 | } |
190 | 190 | ||