Ignore:
Timestamp:
02/17/06 14:49:14 (15 years ago)
Author:
Perry Lorier <perry@…>
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:
65a5900
Parents:
f03fc17
Message:

Abstract away opening up traces into a single trace_open_trace that's more
simple and reliable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_helper.c

    r880aa58 r3d4d52d  
    3636#include <stdio.h>
    3737#include <string.h>
     38#include <errno.h>
     39#include <fcntl.h> /* for O_LARGEFILE */
    3840#ifdef HAVE_INTTYPES_H
    3941#  include <inttypes.h>
     
    135137       
    136138}
     139
     140/* Catch undefined O_LARGEFILE on *BSD etc */
     141#ifndef O_LARGEFILE
     142#  define O_LARGEFILE 0
     143#endif
     144
     145LIBTRACE_FILE trace_open_file(libtrace_t *trace)
     146{
     147        int fd;
     148        LIBTRACE_FILE ret;
     149
     150
     151        if (strcmp(trace->uridata,"-")==0) {
     152                ret=LIBTRACE_FDOPEN(fileno(stdin),"r");
     153                return ret;
     154        }
     155
     156        /* We open the file with open(2), so we can provide O_LARGEFILE
     157         * as zlib doesn't always do it itself
     158         */
     159        fd=open(trace->uridata,O_LARGEFILE);
     160        if (fd==-1) {
     161                trace_set_err(errno,"Unable to open %s",trace->uridata);
     162                return 0;
     163        }
     164        ret=LIBTRACE_FDOPEN(fd,"r");
     165        return ret;
     166}
Note: See TracChangeset for help on using the changeset viewer.