in.c File Reference

Converts stream to string. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "in.h"

Include dependency graph for in.c:

Include dependency graph

Go to the source code of this file.

Defines

#define EVAL(expr)   if (expr) { errno = ENOMEM; perror(pcerr); iret = EXIT_FAILURE; goto cleanup; }
 Evaluand gives unto status errandi.

Functions

int in (FILE *pf, char **ppc)
 Read stream into providant vector.


Detailed Description

Converts stream to string.

Definition in file in.c.


Define Documentation

#define EVAL expr   )     if (expr) { errno = ENOMEM; perror(pcerr); iret = EXIT_FAILURE; goto cleanup; }
 

Evaluand gives unto status errandi.

Parameters:
expr evaluand

Definition at line 12 of file in.c.

Referenced by digest(), in(), lex(), lexbuf(), main(), math(), migrate(), out(), parse(), parsetag(), template(), and translatetoken().


Function Documentation

int in FILE *  pf,
char **  ppc
 

Read stream into providant vector.

Parameters:
pf lectand's whence
ppc lectate's thither

Definition at line 17 of file in.c.

References EVAL, and READ.

Referenced by main(), and template().

00018 {
00019   int iret = EXIT_SUCCESS;
00020   size_t s = 0, scur = 0;
00021   char pcbuf[READ];
00022   const char *pcerr = "in.c in()";
00023   *ppc = (char *) malloc(0);
00024   while ((s = fread(pcbuf, sizeof(char), READ, pf))) {
00025     EVAL((*ppc = (char *) realloc(*ppc, scur + s + sizeof('\0'))) == NULL);
00026     strncpy(*ppc + scur, pcbuf, s);
00027     scur += s;
00028   }
00029   *(*ppc + scur) = '\0';
00030 
00031  cleanup:
00032   return iret;
00033 }


Generated on Tue Dec 7 06:38:25 2004 for CSCI101:ProjectLatex by  doxygen 1.3.9.1