Changeset a114d8b5
- Timestamp:
- 08/08/05 15:18:27 (16 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 8184acc
- Parents:
- f99a183
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace.h
rf99a183 ra114d8b5 75 75 #define COLLECTOR_PORT 3435 76 76 77 77 78 /** Opaque structure holding information about an output trace */ 78 79 struct libtrace_out_t; … … 194 195 void trace_help(); 195 196 197 void trace_perror(); 196 198 197 199 /** Create a trace file from a URI -
lib/trace.c
rf99a183 ra114d8b5 157 157 #endif 158 158 159 // Error codes 160 enum {E_NOERROR, E_BAD_FORMAT, E_NO_INIT, E_NO_INIT_OUT, E_URI_LONG, E_URI_NOCOLON }; 161 162 static struct { 163 int err_num; // error code 164 char *problem; // the format, uri etc that caused the error for reporting purposes 165 } trace_err; 166 159 167 struct libtrace_format_t **format_list = 0; 160 168 int format_size = 0; … … 190 198 } 191 199 200 void trace_perror(char *caller) { 201 switch (trace_err.err_num) { 202 case E_BAD_FORMAT: 203 fprintf(stderr, "%s: No support for format (%s)\n", caller, trace_err.problem); 204 break; 205 case E_NO_INIT: 206 fprintf(stderr, "%s: Format (%s) does not have an init_trace function defined\n", caller, trace_err.problem); 207 break; 208 case E_NO_INIT_OUT: 209 fprintf(stderr, "%s: Format (%s) does not have an init_output function defined\n", caller, trace_err.problem); 210 break; 211 case E_URI_LONG: 212 fprintf(stderr, "%s: uri is too long\n", caller); 213 break; 214 case E_URI_NOCOLON: 215 fprintf(stderr, "%s: A uri must contain at least one colon e.g. format:destination\n", caller); 216 break; 217 default: 218 219 } 220 trace_err.err_num = E_NOERROR; 221 } 192 222 193 223 #define RP_BUFSIZE 65536 194 224 #define URI_PROTO_LINE 16 225 195 226 196 227 … … 228 259 int i = 0; 229 260 struct stat buf; 261 262 trace_err.err_num = E_NOERROR; 230 263 264 231 265 // parse the URI to determine what sort of event we are dealing with 232 266 … … 235 269 if((uridata = strchr(uri,':')) == NULL) { 236 270 // badly formed URI - needs a : 271 trace_err.err_num = E_URI_NOCOLON; 237 272 return 0; 238 273 } … … 240 275 if ((*uridata - *uri) > URI_PROTO_LINE) { 241 276 // badly formed URI - uri type is too long 277 trace_err.err_num = E_URI_LONG; 242 278 return 0; 243 279 } … … 258 294 } 259 295 if (libtrace->format == 0) { 260 fprintf(stderr,261 "libtrace has no support for this format (%s)\n",scan);296 trace_err.err_num = E_BAD_FORMAT; 297 trace_err.problem = scan; 262 298 return 0; 263 299 } … … 273 309 libtrace->format->init_input( libtrace); 274 310 } else { 275 fprintf(stderr,276 "No init function for format %s\n",scan);311 trace_err.err_num = E_NO_INIT; 312 trace_err.problem = scan; 277 313 return 0; 278 314 } … … 299 335 int i; 300 336 337 trace_err.err_num = E_NOERROR; 301 338 // parse the URI to determine what sort of event we are dealing with 302 339 … … 305 342 if((uridata = strchr(uri,':')) == NULL) { 306 343 // badly formed URI - needs a : 344 trace_err.err_num = E_URI_NOCOLON; 307 345 return 0; 308 346 } … … 310 348 if ((*uridata - *uri) > URI_PROTO_LINE) { 311 349 // badly formed URI - uri type is too long 350 trace_err.err_num = E_URI_LONG; 312 351 return 0; 313 352 } … … 326 365 } 327 366 if (libtrace->format == 0) { 328 fprintf(stderr, 329 "libtrace has no support for this format (%s)\n",scan); 367 trace_err.err_num = E_BAD_FORMAT; 368 trace_err.problem = scan; 330 369 return 0; 331 370 } … … 342 381 libtrace->format->init_output( libtrace); 343 382 } else { 344 fprintf(stderr, 345 "No init_output function for format %s\n",scan);383 trace_err.err_num = E_NO_INIT_OUT; 384 trace_err.problem = scan; 346 385 return 0; 347 386 } … … 389 428 libtrace->format->fin_input(libtrace); 390 429 // need to free things! 391 destroy_fifo(libtrace->fifo); 430 free(libtrace->uridata); 431 destroy_fifo(libtrace->fifo); 392 432 free(libtrace); 393 433 } … … 402 442 assert(libtrace); 403 443 libtrace->format->fin_output(libtrace); 444 free(libtrace->uridata); 404 445 destroy_fifo(libtrace->fifo); 405 446 free(libtrace);
Note: See TracChangeset
for help on using the changeset viewer.