Ignore:
Timestamp:
04/23/06 14:11:01 (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:
698a217
Parents:
e337363
Message:

Fixup stdio to be more standard compliant
Fix format wag to be more sensitive to errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtraceio-stdio.c

    r39e141f r4315572b  
    44#include <sys/types.h> /* for ssize_t/off_t */
    55#include <stdio.h>
     6#include <stdlib.h>
     7
     8#include <errno.h> /* for debugging */
    69
    710struct libtrace_io_t {
     
    1114ssize_t libtrace_io_read(libtrace_io_t *io, void *buf, size_t len)
    1215{
    13         return fread(buf,len,1,io->file);
     16        int ret=fread(buf,1,len,io->file);
     17
     18        if (ret==(int)len) {
     19                printf("read %i bytes\n",ret);
     20                return len;
     21        }
     22
     23        /* EOF or an Error occurred */
     24        if (ferror(io->file)) {
     25                int err=errno;
     26                perror("fread");
     27                errno=err;
     28                /* errno will be set */
     29                return -1;
     30        }
     31
     32        printf("eof\n");
     33
     34        return 0; /* EOF */
    1435}
    1536
Note: See TracChangeset for help on using the changeset viewer.