Changeset 16:013ce9851131 in freeDiameter for freeDiameter/main.c
- Timestamp:
- Oct 2, 2009, 6:57:06 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/main.c
r14 r16 38 38 #include <signal.h> 39 39 #include <getopt.h> 40 #include <locale.h> 41 42 #ifdef GCRY_THREAD_OPTION_PTHREAD_IMPL 43 GCRY_THREAD_OPTION_PTHREAD_IMPL; 44 #endif /* GCRY_THREAD_OPTION_PTHREAD_IMPL */ 45 40 46 41 47 /* forward declarations */ … … 62 68 /* Initialize the library */ 63 69 CHECK_FCT( fd_lib_init() ); 70 TRACE_DEBUG(INFO, "libfreeDiameter initialized."); 64 71 65 72 /* Name this thread */ … … 71 78 /* Parse the command-line */ 72 79 CHECK_FCT( main_cmdline(argc, argv) ); 80 81 /* Initialize gnutls */ 82 CHECK_GNUTLS_DO( gnutls_global_init(), return EINVAL ); 83 if ( ! gnutls_check_version(GNUTLS_VERSION) ) { 84 fprintf(stderr, "The GNUTLS library is too old; found '%s', need '" GNUTLS_VERSION "'\n", gnutls_check_version(NULL)); 85 return EINVAL; 86 } else { 87 TRACE_DEBUG(INFO, "GNUTLS library '%s' initialized.", gnutls_check_version(NULL)); 88 } 73 89 74 90 /* Allow SIGINT and SIGTERM from this point */ … … 141 157 142 158 CHECK_FCT_DO( fd_thr_term(&sig_th), /* continue */ ); 159 160 gnutls_global_deinit(); 143 161 144 162 return ret; … … 168 186 int c; 169 187 int option_index = 0; 188 char * locale; 170 189 171 190 struct option long_options[] = { 172 { "help", 0, NULL, 'h' }, 173 { "version", 0, NULL, 'V' }, 174 { "config", 1, NULL, 'c' }, 175 { "debug", 0, NULL, 'd' }, 176 { "quiet", 0, NULL, 'q' }, 177 { NULL, 0, NULL, 0 } 191 { "help", no_argument, NULL, 'h' }, 192 { "version", no_argument, NULL, 'V' }, 193 { "config", required_argument, NULL, 'c' }, 194 { "debug", no_argument, NULL, 'd' }, 195 { "quiet", no_argument, NULL, 'q' }, 196 { "dbglocale", optional_argument, NULL, 'l' }, 197 { NULL, 0, NULL, 0 } 178 198 }; 179 199 … … 182 202 /* Loop on arguments */ 183 203 while (1) { 184 c = getopt_long (argc, argv, "hVc:dq ", long_options, &option_index);204 c = getopt_long (argc, argv, "hVc:dql:", long_options, &option_index); 185 205 if (c == -1) 186 206 break; /* Exit from the loop. */ … … 200 220 break; 201 221 222 case 'l': /* Change the locale. */ 223 locale = setlocale(LC_ALL, optarg?:""); 224 if (locale) { 225 TRACE_DEBUG(INFO, "Locale set to: %s", optarg ?: locale); 226 } else { 227 TRACE_DEBUG(INFO, "Unable to set locale (%s)", optarg); 228 return EINVAL; 229 } 230 break; 231 202 232 case 'd': /* Increase verbosity of debug messages. */ 203 233 fd_g_debug_lvl++; … … 210 240 case '?': /* Invalid option. */ 211 241 /* `getopt_long' already printed an error message. */ 212 TRACE_DEBUG(INFO, "getopt_long found an invalid character \n");242 TRACE_DEBUG(INFO, "getopt_long found an invalid character"); 213 243 return EINVAL; 214 244 215 245 default: /* bug: option not considered. */ 216 TRACE_DEBUG(INFO, "A command-line option is missing in parser: %c \n", c);246 TRACE_DEBUG(INFO, "A command-line option is missing in parser: %c", c); 217 247 ASSERT(0); 218 248 return EINVAL; … … 267 297 printf( "\nDebug:\n" 268 298 " These options are mostly useful for developers\n" 299 " -l, --dbglocale Set the locale for error messages\n" 269 300 " -d, --debug Increase verbosity of debug messages\n" 270 301 " -q, --quiet Decrease verbosity then remove debug messages\n");
Note: See TracChangeset
for help on using the changeset viewer.