Back to index

courier  0.68.2
Functions
rfc2045_fromfd.c File Reference
#include <sys/types.h>
#include "rfc2045.h"

Go to the source code of this file.

Functions

struct rfc2045rfc2045_fromfd (int fd)
struct rfc2045rfc2045header_fromfd (int fd)

Function Documentation

struct rfc2045* rfc2045_fromfd ( int  fd) [read]

Definition at line 21 of file rfc2045_fromfd.c.

{
struct rfc2045       *rfc;
char   buf[BUFSIZ];
int    n;
off_t  orig_pos;

       if ((orig_pos=lseek(fd, 0L, SEEK_CUR)) == (off_t)-1) return (NULL);
       if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1)  return (NULL);
       if ((rfc=rfc2045_alloc()) == 0)    return (NULL);

       while ((n=read(fd, buf, sizeof(buf))) > 0)
              rfc2045_parse(rfc, buf, n);
       rfc2045_parse_partial(rfc);

       if (lseek(fd, orig_pos, SEEK_SET) == (off_t)-1)
       {
              rfc2045_free(rfc);
              rfc=0;
       }
       return (rfc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct rfc2045* rfc2045header_fromfd ( int  fd) [read]

Definition at line 46 of file rfc2045_fromfd.c.

{
struct        rfc2045        *rfc;
char        buf[BUFSIZ];
int        n;
off_t        orig_pos;

        if ((orig_pos=lseek(fd, 0L, SEEK_CUR)) == (off_t)-1) return (NULL);
        if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1)        return (NULL);
        if ((rfc=rfc2045_alloc()) == 0)        return (NULL);

        while (rfc->workinheader && (n=read(fd, buf, sizeof(buf))) > 0)
                rfc2045_parse(rfc, buf, n);
        if (lseek(fd, orig_pos, SEEK_SET) == (off_t)-1)
        {
                rfc2045_free(rfc);
                rfc=0;
        }
        return (rfc);
}

Here is the call graph for this function: