Changeset 14:14cf6daf716d in freeDiameter for freeDiameter/main.c
- Timestamp:
- Oct 1, 2009, 6:24:07 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/main.c
r13 r14 42 42 static void * sig_hdl(void * arg); 43 43 static int main_cmdline(int argc, char *argv[]); 44 static void main_version(void); 45 static void main_help( void ); 44 46 45 47 /* The static configuration structure */ … … 77 79 78 80 /* Initialize other modules */ 79 CHECK_FCT( fd_ext_init() );80 81 CHECK_FCT( fd_queues_init() ); 81 82 CHECK_FCT( fd_msg_init() ); 82 CHECK_FCT( fd_p eer_init() );83 CHECK_FCT( fd_p_expi_init() ); 83 84 84 85 /* Parse the configuration file */ … … 133 134 134 135 /* cleanups */ 135 CHECK_FCT_DO( fd_ext_fini(), /* continue */ ); 136 TODO("Stop dispatch thread(s) properly (no cancel yet)"); 137 CHECK_FCT_DO( fd_peer_fini(), /* Stop all connections */ ); 138 TODO("Stop dispatch & routing threads"); 139 CHECK_FCT_DO( fd_ext_fini(), /* Cleaup all extensions */ ); 140 TODO("Cleanup queues (dump all remaining messages ?)"); 141 136 142 CHECK_FCT_DO( fd_thr_term(&sig_th), /* continue */ ); 137 143 138 144 return ret; 145 } 146 147 const char * fd_ev_str(int event) 148 { 149 switch (event) { 150 #define case_str( _val )\ 151 case _val : return #_val 152 case_str(FDEV_TERMINATE); 153 case_str(FDEV_DUMP_DICT); 154 case_str(FDEV_DUMP_EXT); 155 case_str(FDEV_DUMP_QUEUES); 156 case_str(FDEV_DUMP_CONFIG); 157 case_str(FDEV_DUMP_PEERS); 158 159 default: 160 TRACE_DEBUG(FULL, "Unknown event : %d", event); 161 return "Unknown event"; 162 } 163 } 164 165 /* Parse the command-line */ 166 static int main_cmdline(int argc, char *argv[]) 167 { 168 int c; 169 int option_index = 0; 170 171 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 } 178 }; 179 180 TRACE_ENTRY("%d %p", argc, argv); 181 182 /* Loop on arguments */ 183 while (1) { 184 c = getopt_long (argc, argv, "hVc:dq", long_options, &option_index); 185 if (c == -1) 186 break; /* Exit from the loop. */ 187 188 switch (c) { 189 case 'h': /* Print help and exit. */ 190 main_help(); 191 exit(0); 192 193 case 'V': /* Print version and exit. */ 194 main_version(); 195 exit(0); 196 197 case 'c': /* Read configuration from this file instead of the default location.. */ 198 CHECK_PARAMS( optarg ); 199 fd_g_config->cnf_file = optarg; 200 break; 201 202 case 'd': /* Increase verbosity of debug messages. */ 203 fd_g_debug_lvl++; 204 break; 205 206 case 'q': /* Decrease verbosity then remove debug messages. */ 207 fd_g_debug_lvl--; 208 break; 209 210 case '?': /* Invalid option. */ 211 /* `getopt_long' already printed an error message. */ 212 TRACE_DEBUG(INFO, "getopt_long found an invalid character\n"); 213 return EINVAL; 214 215 default: /* bug: option not considered. */ 216 TRACE_DEBUG(INFO, "A command-line option is missing in parser: %c\n", c); 217 ASSERT(0); 218 return EINVAL; 219 } 220 } 221 222 return 0; 139 223 } 140 224 … … 187 271 } 188 272 189 /* Parse the command-line */190 static int main_cmdline(int argc, char *argv[])191 {192 int c;193 int option_index = 0;194 195 struct option long_options[] = {196 { "help", 0, NULL, 'h' },197 { "version", 0, NULL, 'V' },198 { "config", 1, NULL, 'c' },199 { "debug", 0, NULL, 'd' },200 { "quiet", 0, NULL, 'q' },201 { NULL, 0, NULL, 0 }202 };203 204 TRACE_ENTRY("%d %p", argc, argv);205 206 /* Loop on arguments */207 while (1) {208 c = getopt_long (argc, argv, "hVc:dq", long_options, &option_index);209 if (c == -1)210 break; /* Exit from the loop. */211 212 switch (c) {213 case 'h': /* Print help and exit. */214 main_help();215 exit(0);216 217 case 'V': /* Print version and exit. */218 main_version();219 exit(0);220 221 case 'c': /* Read configuration from this file instead of the default location.. */222 CHECK_PARAMS( optarg );223 fd_g_config->cnf_file = optarg;224 break;225 226 case 'd': /* Increase verbosity of debug messages. */227 fd_g_debug_lvl++;228 break;229 230 case 'q': /* Decrease verbosity then remove debug messages. */231 fd_g_debug_lvl--;232 break;233 234 case '?': /* Invalid option. */235 /* `getopt_long' already printed an error message. */236 TRACE_DEBUG(INFO, "getopt_long found an invalid character\n");237 return EINVAL;238 239 default: /* bug: option not considered. */240 TRACE_DEBUG(INFO, "A command-line option is missing in parser: %c\n", c);241 ASSERT(0);242 return EINVAL;243 }244 }245 246 return 0;247 248 }249 250 273 #ifdef HAVE_SIGNALENT_H 251 274 const char *const signalstr[] = {
Note: See TracChangeset
for help on using the changeset viewer.