comparison freeDiameter/main.c @ 501:e5f06199cee7

New command-line option to enable GNUTLS debugging
author Sebastien Decugis <sdecugis@nict.go.jp>
date Wed, 18 Aug 2010 18:13:09 +0900
parents 9a8b3178a7a7
children a9a938287b49
comparison
equal deleted inserted replaced
500:d4fc98a3b79c 501:e5f06199cee7
177 fd_lib_fini(); 177 fd_lib_fini();
178 178
179 return ret; 179 return ret;
180 } 180 }
181 181
182 /* gnutls debug */
183 static void fd_gnutls_debug(int level, const char * str) {
184 fd_log_debug(" [gnutls:%d] %s", level, str);
185 }
186
182 /* Parse the command-line */ 187 /* Parse the command-line */
183 static int main_cmdline(int argc, char *argv[]) 188 static int main_cmdline(int argc, char *argv[])
184 { 189 {
185 int c; 190 int c;
186 int option_index = 0; 191 int option_index = 0;
193 { "debug", no_argument, NULL, 'd' }, 198 { "debug", no_argument, NULL, 'd' },
194 { "quiet", no_argument, NULL, 'q' }, 199 { "quiet", no_argument, NULL, 'q' },
195 { "dbglocale", optional_argument, NULL, 'l' }, 200 { "dbglocale", optional_argument, NULL, 'l' },
196 { "dbg_func", required_argument, NULL, 'f' }, 201 { "dbg_func", required_argument, NULL, 'f' },
197 { "dbg_file", required_argument, NULL, 'F' }, 202 { "dbg_file", required_argument, NULL, 'F' },
203 { "dbg_gnutls", required_argument, NULL, 'g' },
198 { NULL, 0, NULL, 0 } 204 { NULL, 0, NULL, 0 }
199 }; 205 };
200 206
201 TRACE_ENTRY("%d %p", argc, argv); 207 TRACE_ENTRY("%d %p", argc, argv);
202 208
244 break; 250 break;
245 251
246 case 'F': /* Full debug for the file with this name. */ 252 case 'F': /* Full debug for the file with this name. */
247 #ifdef DEBUG 253 #ifdef DEBUG
248 fd_debug_one_file = basename(optarg); 254 fd_debug_one_file = basename(optarg);
255 #else /* DEBUG */
256 TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature");
257 return EINVAL;
258 #endif /* DEBUG */
259 break;
260
261 case 'g': /* Full debug for the function with this name. */
262 #ifdef DEBUG
263 {
264 int l = (int)atoi(optarg);
265 if (l) {
266 gnutls_global_set_log_function((gnutls_log_func)fd_gnutls_debug);
267 gnutls_global_set_log_level (l);
268 TRACE_DEBUG(INFO, "Enabled GNUTLS debug at level %d", l);
269 }
270 }
249 #else /* DEBUG */ 271 #else /* DEBUG */
250 TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature"); 272 TRACE_DEBUG(INFO, "Error: must compile with DEBUG support to use this feature");
251 return EINVAL; 273 return EINVAL;
252 #endif /* DEBUG */ 274 #endif /* DEBUG */
253 break; 275 break;
"Welcome to our mercurial repository"