Changeset f66a4933


Ignore:
Timestamp:
11/24/05 11:30:11 (15 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:
9cecdb2
Parents:
187a6d6
Message:

moved LIBTRACE_READ etc defines into common.h

if we don't have zlib, use read,open etc. We were using fread,fopen, but these take different parameters, and i couldn't make them work nicely.

stdin doesn't seem to work for non-zlib paths however

Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/common.h

    r6ad8afc rf66a4933  
    1010#endif /* __cplusplus */
    1111
     12#if HAVE_ZLIB
     13#  include <zlib.h>
     14#  define LIBTRACE_READ(file,buf,len) gzread(file,buf,len)
     15#  define LIBTRACE_FDOPEN(fd,mode) gzdopen(fd,mode)
     16#  define LIBTRACE_OPEN(path,mode) gzopen(path,mode)
     17#  define LIBTRACE_CLOSE(file) gzclose(file)
     18#  define LIBTRACE_WRITE(file,buf,len) gzwrite(file,buf,len)
     19#else
     20#  define LIBTRACE_READ(file,buf,len) read(file,buf,len)
     21#  define LIBTRACE_FDOPEN(fd,mode) dup(fd)
     22#  define LIBTRACE_OPEN(path,mode) open(path,mode)
     23#  define LIBTRACE_CLOSE(file) close(file)
     24#  define LIBTRACE_WRITE(file,buf,len) write(file,buf,len)
     25#endif
     26
    1227#endif // COMMON_H
  • lib/format_erf.c

    rf3ed52a rf66a4933  
    6565/*
    6666 gzread (gzFile, buf, len)
     67 gzdopen(path, mode)
     68 gzopen(path, mode)
     69 gzclose(gzFile)
    6770 gzwrite(gzFile, buf, len)
    68  gzdopen(path, mode)
    69  gzclose(gzFile)
    7071
    7172 fread(ptr, size, num, FILE)
     73 fdopen(filedes,mode)
     74 fopen(path, mode)
     75 fclose(FILE)
    7276 fwrite(ptr, size, num, FILE)
    73  fopen(path, mode)
    74  fdopen(fildes, mode)
    75 */
     77*/
     78/*
    7679#if HAVE_ZLIB
    7780#  include <zlib.h>
    78 #  define LIBTRACE_READ gzread
    79 #  define LIBTRACE_OPEN gzopen
    80 #  define LIBTRACE_FDOPEN gzdopen
    81 #  define LIBTRACE_CLOSE gzclose
    82 #  define LIBTRACE_WRITE gzwrite
     81#  define LIBTRACE_READ(file,buf,len) gzread(file,buf,len)
     82#  define LIBTRACE_FDOPEN(fd,mode) gzdopen(fd,mode)
     83#  define LIBTRACE_OPEN(path,mode) gzopen(path,mode)
     84#  define LIBTRACE_CLOSE(file) gzclose(file)
     85#  define LIBTRACE_WRITE(file,buf,len) gzwrite(file,buf,len)
    8386#else
    84 #  define LIBTRACE_READ fread
    85 #  define LIBTRACE_OPEN fopen
    86 #  define LIBTRACE_FDOPEN fdopen
    87 #  define LIBTRACE_CLOSE fclose
    88 #  define LIBTRACE_WRITE fwrite
    89 #endif
    90 
     87#  define LIBTRACE_READ(file,buf,len) fread(buf,len,1,file)
     88#  define LIBTRACE_FDOPEN(fd,mode) fdopen(fd,mode)
     89#  define LIBTRACE_OPEN(path,mode) fopen(path,mode)
     90#  define LIBTRACE_CLOSE(file) fclose(file)
     91#  define LIBTRACE_WRITE(file,buf,len) fwrite(buf,len,1,file)
     92#endif
     93*/
    9194#define COLLECTOR_PORT 3435
    9295
     
    126129                gzFile *file;
    127130#else   
    128                 FILE  *file;
     131                //FILE  *file;
     132                int file;
    129133#endif
    130134        } input;
     
    164168                gzFile *file;
    165169#else
    166                 FILE *file;
     170                //FILE *file;
     171                int file;
    167172#endif
    168173        } output;
     
    264269                // STDIN
    265270                libtrace->sourcetype = STDIN;
    266                 INPUT.file = LIBTRACE_FDOPEN(STDIN, "r");
     271                if ((INPUT.file = LIBTRACE_FDOPEN(stdin, "r")) < 0) {
     272                        perror("libtrace_fdopen:");
     273                        return 0;
     274                }
     275               
    267276
    268277        } else {
     
    373382        if (!strncmp(libtrace->uridata,"-",1)) {
    374383                // STDOUT
    375                 OUTPUT.file = LIBTRACE_FDOPEN(dup(1),filemode);
     384                OUTPUT.file = LIBTRACE_FDOPEN(stdout,filemode);
    376385        }
    377386        else {
  • lib/format_wag.c

    rf3ed52a rf66a4933  
    6363#include <stdlib.h>
    6464
     65/*
    6566#if HAVE_ZLIB
    6667#  include <zlib.h>
     
    7576#  define LIBTRACE_WRITE write
    7677#endif
    77 
     78*/
    7879#ifdef HAVE_LIMITS_H
    7980#  include <limits.h>
     
    110111                gzFile *file;
    111112#else   
    112                 FILE *file;
     113                //FILE *file;
     114                int file;
    113115#endif
    114116        } input;       
     
    129131                gzFile *file;
    130132#else
    131                 FILE *file;
     133                //FILE *file;
     134                int file;
    132135#endif
    133136        } output;
Note: See TracChangeset for help on using the changeset viewer.