eg_io.h File Reference

#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include "eg_macros.h"

Include dependency graph for eg_io.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define EGnullDisplay   ((EGdisplay_f)0)
#define EGsfopen(__file, __mode)
 safe open function, it test that we can open the given file with the given mode, if an error occurs, display it on screen and exit, otherwise, return the open file stream.

Typedefs

typedef void(* EGdisplay_f )(void *, FILE *)
 type of functions for display, receives a void* to the structure to print, and a *FILE where to output
typedef void(* EGdisplayOS_f )(void *, FILE *, size_t *)
 type of functions for display, receives a void* to the structure to print, a *FILE where to output, and a set of offsets for datas, the length of that array must be know by the user.

Functions

void EGdisplayString (void *str, FILE *file)
 display function for strings
void EGioDisCom (char **next, char **current, const char *delim, const char *coment, char *store, unsigned int storeSize, FILE *in)
 this discard all lines starting with comments and stores the next leading line in current and the next token in next, we assume that next does not contain data, and that current store the remainings of the current line
void EGioNParse (char *input, int max_argc, const char *delim, const char *comment, int *argc, char **argv)
 Given a string 'input' this function uses EGioParse to separate up to N words in it, we assume that argc is an array of pointers to strings of size N, and note that the input array will be changed.
void EGioParse (char **next, char **current, const char *delim, const char *coment)
 given two *pointers 'next' and 'current' and a constant set of strings (parse delimiters), it store in 'next the next meaningfull string, and in current the rest of the secuence, the idea is to iterate over 'next' while it is not true; you have to store the original pointer to the string stream elsewere; also, we assume that the original stream is terminated with ''; also, it will discaard any sub-string that start with #, that is inteded for discard comments
int EGioReadLine (char *const str, size_t const max_len, FILE *file)
 read a line from an input stream.
void EGmvar (char *str, int nind, const char *header,...)
 create names with indices


Define Documentation

#define EGnullDisplay   ((EGdisplay_f)0)
 

Definition at line 72 of file eg_io.h.

#define EGsfopen __file,
__mode   ) 
 

Value:

({\
  const char*__EGsfile = (__file);\
  const char*__EGsmode = (__mode);\
  FILE*__EGsFILE = fopen(__EGsfile,__EGsmode);\
  if(!__EGsFILE)\
  {\
    const int __EGserrno = errno;\
    fprintf(stderr,"fopen() failed with error code %d, error\n%s",__EGserrno,strerror(__EGserrno));\
    MESSAGE(0,"Could not open %s with mode %s", __EGsfile, __EGsmode);\
    exit(__EGserrno);\
  }\
  __EGsFILE;})
safe open function, it test that we can open the given file with the given mode, if an error occurs, display it on screen and exit, otherwise, return the open file stream.

Parameters:
__file file name to open (is a const char*)
__mode mode to use to open the file (is a const char*)
Returns:
FILE* stream

Definition at line 54 of file eg_io.h.


Typedef Documentation

typedef void(* EGdisplay_f)(void *, FILE *)
 

type of functions for display, receives a void* to the structure to print, and a *FILE where to output

Definition at line 70 of file eg_io.h.

typedef void(* EGdisplayOS_f)(void *, FILE *, size_t *)
 

type of functions for display, receives a void* to the structure to print, a *FILE where to output, and a set of offsets for datas, the length of that array must be know by the user.

Definition at line 78 of file eg_io.h.


Function Documentation

void EGdisplayString void *  str,
FILE *  file
 

display function for strings

Parameters:
str pointer to a null terminated string of chars.
file pointer to a stream where we write the string.
Description:
This function just print the string on the file, it won't add a '
' at the end.

Definition at line 205 of file eg_io.c.

void EGioDisCom char **  next,
char **  current,
const char *  delim,
const char *  coment,
char *  store,
unsigned int  storeSize,
FILE *  in
 

this discard all lines starting with comments and stores the next leading line in current and the next token in next, we assume that next does not contain data, and that current store the remainings of the current line

Definition at line 173 of file eg_io.c.

Here is the call graph for this function:

void EGioNParse char *  input,
int  max_argc,
const char *  delim,
const char *  comment,
int *  argc,
char **  argv
 

Given a string 'input' this function uses EGioParse to separate up to N words in it, we assume that argc is an array of pointers to strings of size N, and note that the input array will be changed.

Definition at line 57 of file eg_io.c.

Here is the call graph for this function:

void EGioParse char **  next,
char **  current,
const char *  delim,
const char *  coment
 

given two *pointers 'next' and 'current' and a constant set of strings (parse delimiters), it store in 'next the next meaningfull string, and in current the rest of the secuence, the idea is to iterate over 'next' while it is not true; you have to store the original pointer to the string stream elsewere; also, we assume that the original stream is terminated with ''; also, it will discaard any sub-string that start with #, that is inteded for discard comments

Definition at line 88 of file eg_io.c.

int EGioReadLine char *const   str,
size_t const   max_len,
FILE *  file
 

read a line from an input stream.

Parameters:
str where to store the line.
max_len maximum allowed length.
file stream from where we read the input
Returns:
zero on success, non-zero otherwise, errors are cast when we can not read from the given file.

Definition at line 212 of file eg_io.c.

void EGmvar char *  str,
int  nind,
const char *  header,
  ...
 

create names with indices

Definition at line 21 of file eg_io.c.


Generated on Wed Nov 21 09:38:17 2007 for MTgomory by  doxygen 1.4.6