Changeset ffc8c8d for lib/trace.c


Ignore:
Timestamp:
08/11/05 11:30:41 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
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:
4d5a9a7
Parents:
a8ba977
Message:

better return codes in format_*.c, trace_perror stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    r3dcc2e2 rffc8c8d  
    113113#endif
    114114
    115 //#if HAVE_PCAP_H
    116 //#  include <pcap.h>
    117 //#  ifdef HAVE_PCAP_INT_H
    118 //#    include <pcap-int.h>
    119 //#  endif
    120 //#endif
    121 
    122 //#ifdef HAVE_ZLIB_H
    123 //#  include <zlib.h>
    124 //#endif
    125 
    126 
    127 //#include "wag.h"
    128 
    129 //#ifdef HAVE_DAG_API
    130 //#  include "dagnew.h"
    131 //#  include "dagapi.h"
    132 //#else
    133 //#  include "dagformat.h"
    134 //#endif
    135 
    136115#include "libtrace_int.h"
    137116#include "format_helper.h"
    138 //#include "format/format_list.h"
    139117#include <err.h>
    140118
    141119#define MAXOPTS 1024
    142120
    143 //typedef enum {SOCKET, TRACE, STDIN, DEVICE, INTERFACE, RT } source_t;
    144 
    145 //typedef enum {ERF, PCAP, PCAPINT, DAG, RTCLIENT, WAG, WAGINT } format_e_t;
    146 
    147 //typedef enum {RTSERVER, GZERF } output_t;
    148121#if HAVE_BPF
    149122/** A type encapsulating a bpf filter
     
    158131#endif
    159132
    160 // Error codes
    161 enum {E_NOERROR, E_BAD_FORMAT, E_NO_INIT, E_NO_INIT_OUT, E_URI_LONG, E_URI_NOCOLON };
    162 
    163 static struct {
    164         int err_num;    // error code
    165         char *problem;  // the format, uri etc that caused the error for reporting purposes
    166 } trace_err;
     133
    167134
    168135struct libtrace_format_t **format_list = 0;
     
    216183                        fprintf(stderr, "%s: A uri must contain at least one colon e.g. format:destination\n", caller);
    217184                        break;
     185                case E_INIT_FAILED:
     186                        fprintf(stderr, "%s: libtrace failed to initialise (%s)\n",caller,trace_err.problem);
     187                       
    218188                default:
    219189                        fprintf(stderr, "Unkown errcode %d\n",trace_err.err_num);
     
    310280       
    311281        if (libtrace->format->init_input) {
    312                 libtrace->format->init_input( libtrace);
     282                if (!libtrace->format->init_input( libtrace)) {
     283                        trace_err.err_num = E_INIT_FAILED;
     284                        trace_err.problem = scan;
     285                        return 0;
     286                }
    313287        } else {
    314288                trace_err.err_num = E_NO_INIT;
     
    382356
    383357        if (libtrace->format->init_output) {
    384                 libtrace->format->init_output( libtrace);
     358                if(!libtrace->format->init_output( libtrace)) {
     359                        return 0;
     360                }
    385361        } else {
    386362                trace_err.err_num = E_NO_INIT_OUT;
     
    460436
    461437        if (!libtrace) {
    462                 fprintf(stderr,"Oi! You called trace_read_packet() with a NULL libtrace parameter!\n");
     438                fprintf(stderr,"You called trace_read_packet() with a NULL libtrace parameter!\n");
    463439        }
    464440        assert(libtrace);
Note: See TracChangeset for help on using the changeset viewer.