Changeset f99a183


Ignore:
Timestamp:
08/05/05 14:41:47 (15 years ago)
Author:
Shane Alcock <salcock@…>
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:
a114d8b5
Parents:
df2dff9
Message:

Minor fixes - removed init_output and added some doc to libtrace.h

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h

    rfe43699 rf99a183  
    237237struct libtrace_out_t *trace_output_create(char *uri);
    238238
     239/** Configures a trace output file as specified by an option string in getopt() format
     240 *
     241 * @param libtrace      the output trace file to be configured
     242 * @param options       the string containing the configuration options
     243 * @returns -1 if configuration fails, 0 if successful
     244 */
    239245int trace_output_config(struct libtrace_out_t *libtrace, char *options);
    240246
  • lib/trace.c

    rdf2dff9 rf99a183  
    194194#define URI_PROTO_LINE 16
    195195
    196 /** Initialises the data contained within the libtrace_out_t structure, based on the provided uri.
    197  *
    198  * @param libtrace      the libtrace_out_t structure to initialise
    199  * @param uri           the uri defining the output type and destination
    200  * @returns             1 if initialised successfully, 0 otherwise
    201  *
    202  * @author Shane Alcock
    203  * */
    204 static int init_output(struct libtrace_out_t **libtrace, char *uri) {
    205         char *scan = calloc(sizeof(char),URI_PROTO_LINE);
    206         char *uridata = 0;
    207         int i;
    208        
    209         // parse the URI to determine what sort of event we are dealing with
    210 
    211         // want snippet before the : to get the uri base type.
    212        
    213         if((uridata = strchr(uri,':')) == NULL) {
    214                 // badly formed URI - needs a :
    215                 return 0;
    216         }
    217 
    218         if ((*uridata - *uri) > URI_PROTO_LINE) {
    219                 // badly formed URI - uri type is too long
    220                 return 0;
    221         }
    222        
    223         strncpy(scan,uri, (uridata - uri));
    224        
    225         (*libtrace)->format = 0;
    226         for (i = 0; i < nformats; i++) {
    227                 if (strlen(scan) == strlen(format_list[i]->name) &&
    228                                 !strncasecmp(scan,
    229                                         format_list[i]->name,
    230                                         strlen(scan))) {
    231                                 (*libtrace)->format=format_list[i];
    232                                 break;
    233                                 }
    234         }
    235         if ((*libtrace)->format == 0) {
    236                 fprintf(stderr,
    237                         "libtrace has no support for this format (%s)\n",scan);
    238                 return 0;
    239         }
    240        
    241         // push uridata past the delimiter
    242         uridata++;
    243         (*libtrace)->uridata = strdup(uridata);
    244        
    245        
    246         // libtrace->format now contains the type of uri
    247         // libtrace->uridata contains the appropriate data for this
    248 
    249         if ((*libtrace)->format->init_output) {
    250                 (*libtrace)->format->init_output( (*libtrace));
    251         } else {
    252                 fprintf(stderr,
    253                         "No init_output function for format %s\n",scan);
    254                 return 0;
    255         }
    256 
    257        
    258         (*libtrace)->fifo = create_fifo(1048576);
    259         assert( (*libtrace)->fifo);
    260         return 1;
    261 }
    262196
    263197/** Create a trace file from a URI
Note: See TracChangeset for help on using the changeset viewer.