Woolz Image Processing  Version 1.8.3
libbibfile

Convenience procedures for reading and writing "bibtex" style text files for record-formatted data. libbibfile for more detail. More...

Files

file  bibFile.h
 Types and constants for the bibtex based file syntax used for serial section data, ....
 
file  bibFileAlloc.c
 Functions for allocation and freeing of the bibtex based record and field data structures.
 
file  bibFileIO.c
 File I/O functions to parse the bibtex based file syntax used for serial section data, ....
 
file  bibFileParse.c
 Functions to parse the bibtex based file syntax.
 

Functions

void BibFileRecordFree (BibFileRecord **record)
 Free's the given record and sets it to NULL. More...
 
void BibFileFieldFree (BibFileField **field)
 Recursively free's the given field and sets it to NULL. More...
 
BibFileRecordBibFileRecordMake (char *name, char *id, BibFileField *field)
 Given record name and id strings and a field pointer a new record is created.
More...
 
BibFileFieldBibFileFieldMake (char *name, char *value, BibFileField *next)
 Given field name and value strings and a field pointer for the next field, a new field is created.
More...
 
BibFileFieldBibFileFieldMakeVa (char *name, char *value,...)
 Given a list of field name and value string pairs which is terminated by a NULL. A hierarchy of new fields is created. More...
 
BibFileFieldBibFileFieldJoin (BibFileField *field0, BibFileField *field1,...)
 Given a NULL terminated varargs list of fields, these are joined by filling in the appropriate next fields. More...
 
BibFileError BibFileRecordRead (BibFileRecord **record, char **eMsg, FILE *fP)
 Read a bibtex style record from the given stream and allocate storage as required.
More...
 
BibFileError BibFileRecordWrite (FILE *fP, char **eMsg, BibFileRecord *record)
 Write a bibtex style record to the given stream. More...
 
static BibFileError BibFileRecordError (char **eMsg, BibFileRecord *record)
 Build an error string showing with some record info. More...
 
BibFileError BibFileFieldRead (BibFileField **field, char **eMsg, int *endFlag, FILE *fP)
 Read a bibtex style field from the given stream and allocate storage as required.
More...
 
BibFileError BibFileFieldWrite (FILE *fP, char **eMsg, BibFileField *field)
 Write a bibtex style field to the given stream. More...
 
static BibFileError BibFileFieldError (char **eMsg, BibFileField *field)
 Build an error string showing with some field info. More...
 
static BibFileError BibFileStrRead (char **str, BibFileTok tok, int skipSp, FILE *fP)
 Read a character string from the given stream until a character not matched by the given charcter list is read, this character is then put back so that it can be read again. If the skip spaces flag is non zero then leading white space characters will be skipped. Characters in the string may be escaped by the escape character. String length is only limited by the memory available to AlcMalloc.
More...
 
static BibFileError BibFileCharMatch (BibFileTok tok, int skipFlag, int skipSp, FILE *fP)
 Check for a character that matches the given charcter list. If the skip flag is zero this character is put back so that it can be read again. If the skip spaces flag is non zero then leading white space characters will be skipped.
More...
 
static BibFileError BibFileCharUnread (char newC, FILE *fP)
 Put a character back into the stream from which it was read.
More...
 
static BibFileError BibFileCharRegEx (char given, BibFileTok tok)
 Match the given character to the given regular expression. The regular expression may either be compilled or a charcater string.
More...
 
static BibFileError BibFileSkipSpaces (FILE *fP)
 Read and skip white space characters. More...
 
BibFileError BibFileEscapeRestrictedChar (char *inString, char **outString)
 Replace any special character with ESC+spacial char. More...
 
BibFileError BibFileUnEscapeRestrictedChar (char *inString, char **outString)
 Replace any special caracter with ESC+spacial char. More...
 
int BibFileFieldParseFmt (BibFileField *topField, void *value, char *fmt, char *name,...)
 Given the top most field from which to parse fields and a NULL terminated varargs list of field value pointers, format strings (for sscanf) and field name strings. All fields are parsed for all name strings. Parsed values are allowed to overwrite those previously parsed. Note that string values are parsed using a char ** and are AlcStrDup()'d.
More...
 

Detailed Description

Convenience procedures for reading and writing "bibtex" style text files for record-formatted data. libbibfile for more detail.

Function Documentation

◆ BibFileRecordFree()

◆ BibFileFieldFree()

void BibFileFieldFree ( BibFileField **  field)

Recursively free's the given field and sets it to NULL.

Returns
void
Parameters
fieldField ptr to free.

References AlcFree(), _BibFileField::name, _BibFileField::next, and _BibFileField::value.

Referenced by BibFileFieldMakeVa(), and BibFileRecordFree().

◆ BibFileRecordMake()

BibFileRecord* BibFileRecordMake ( char *  name,
char *  id,
BibFileField field 
)

Given record name and id strings and a field pointer a new record is created.

Returns
New record, NULL on error.
Parameters
nameRecord name string.
idRecord id string.
fieldTop field of record.

References AlcCalloc(), AlcFree(), AlcStrDup(), BibFileRecord::field, BibFileRecord::id, _BibFileField::name, and BibFileRecord::name.

Referenced by WlzEffBibWrite3DSectionViewParamsRecord(), WlzEffBibWriteFileRecord(), WlzEffBibWriteTiePointVtxsRecord(), WlzEffBibWriteWarpInputSegmentationParamsRecord(), WlzEffBibWriteWarpInputThresholdParamsRecord(), and WlzEffBibWriteWarpTransformParamsRecord().

◆ BibFileFieldMake()

BibFileField* BibFileFieldMake ( char *  name,
char *  value,
BibFileField next 
)

Given field name and value strings and a field pointer for the next field, a new field is created.

Returns
New field, NULL on error.
Parameters
nameField name string.
valueField value string.
nextNext field below this one.

References AlcCalloc(), AlcFree(), AlcStrDup(), _BibFileField::name, _BibFileField::next, and _BibFileField::value.

Referenced by BibFileFieldMakeVa().

◆ BibFileFieldMakeVa()

BibFileField* BibFileFieldMakeVa ( char *  name,
char *  value,
  ... 
)

Given a list of field name and value string pairs which is terminated by a NULL. A hierarchy of new fields is created.

Returns
Top of new fields, maybe NULL on error.
Parameters
nameFirst field name string.
valueFirst field value string.
...NULL terminated varargs list of name value pairs.

References BibFileFieldFree(), BibFileFieldMake(), _BibFileField::name, _BibFileField::next, and _BibFileField::value.

Referenced by WlzEffBibWrite3DSectionViewParamsRecord(), WlzEffBibWriteFileRecord(), WlzEffBibWriteTiePointVtxsRecord(), WlzEffBibWriteWarpInputSegmentationParamsRecord(), WlzEffBibWriteWarpInputThresholdParamsRecord(), and WlzEffBibWriteWarpTransformParamsRecord().

◆ BibFileFieldJoin()

BibFileField* BibFileFieldJoin ( BibFileField field0,
BibFileField field1,
  ... 
)

Given a NULL terminated varargs list of fields, these are joined by filling in the appropriate next fields.

Returns
Top field of the join, NULL on error.
Parameters
field0Top most field of join.
field1Field to be added to top field.
...NULL terminated varargs list of fields to be joined.

References _BibFileField::next.

◆ BibFileRecordRead()

BibFileError BibFileRecordRead ( BibFileRecord **  record,
char **  eMsg,
FILE *  fP 
)

Read a bibtex style record from the given stream and allocate storage as required.

Returns
Non zero if read fails.
Parameters
recordDestination ptr for the record.
eMsgPtr for error message strings.
fPInput file stream.

References AlcCalloc(), BIBFILE_ER_EOF, BIBFILE_ER_MALLOC, BIBFILE_ER_NONE, BIBFILE_TOK_CLOSE, BIBFILE_TOK_NEW, BIBFILE_TOK_OPEN, BIBFILE_TOK_RECID, BIBFILE_TOK_RECNAME, BIBFILE_TOK_SEP, BibFileCharMatch(), BibFileFieldRead(), BibFileRecordError(), BibFileRecordFree(), and BibFileStrRead().

Referenced by WlzEffBibRead3DView().

◆ BibFileRecordWrite()

BibFileError BibFileRecordWrite ( FILE *  fP,
char **  eMsg,
BibFileRecord record 
)

Write a bibtex style record to the given stream.

Returns
Non zero if write fails.
Parameters
fPOutput file stream.
eMsgPtr for error message strings.
recordRecord ptr.

References BIBFILE_ER_NONE, BIBFILE_ER_SYNTAX, BibFileRecord::field, BibFileRecord::id, and BibFileRecord::name.

Referenced by WlzEffBibWrite3DSectionViewParamsRecord(), WlzEffBibWriteFileRecord(), WlzEffBibWriteTiePointVtxsRecord(), WlzEffBibWriteWarpInputSegmentationParamsRecord(), WlzEffBibWriteWarpInputThresholdParamsRecord(), and WlzEffBibWriteWarpTransformParamsRecord().

◆ BibFileRecordError()

static BibFileError BibFileRecordError ( char **  eMsg,
BibFileRecord record 
)

Build an error string showing with some record info.

Returns
Non zero if fails to build an error string!
Parameters
eMsgPtr for error message strings.
recordRecord ptr.

References BIBFILE_ER_NONE.

Referenced by BibFileRecordRead().

◆ BibFileFieldRead()

BibFileError BibFileFieldRead ( BibFileField **  field,
char **  eMsg,
int *  endFlag,
FILE *  fP 
)

Read a bibtex style field from the given stream and allocate storage as required.

Returns
Non zero if read fails.
Parameters
fieldDestination ptr for the field.
eMsgPtr for error message strings.
endFlagSet to non zero if last field.
fPInput file stream.

References AlcCalloc(), AlcFree(), BIBFILE_ER_EOF, BIBFILE_ER_MALLOC, BIBFILE_ER_NONE, BIBFILE_ER_SYNTAX, BIBFILE_TOK_CLOSE, BIBFILE_TOK_EQUAL, BIBFILE_TOK_FLDNAME, BIBFILE_TOK_FLDVAL, BIBFILE_TOK_OPEN, BIBFILE_TOK_SEP, BibFileCharMatch(), BibFileFieldError(), BibFileStrRead(), _BibFileField::name, and _BibFileField::value.

Referenced by BibFileRecordRead().

◆ BibFileFieldWrite()

BibFileError BibFileFieldWrite ( FILE *  fP,
char **  eMsg,
BibFileField field 
)

Write a bibtex style field to the given stream.

Returns
Non zero if write fails.
Parameters
fPOutput file stream.
eMsgPtr for error message strings.
fieldField ptr.

References BIBFILE_ER_NONE, BIBFILE_ER_SYNTAX, _BibFileField::name, and _BibFileField::value.

◆ BibFileFieldError()

static BibFileError BibFileFieldError ( char **  eMsg,
BibFileField field 
)

Build an error string showing with some field info.

Returns
Non zero if fails to build an error string!
Parameters
eMsgPtr for error message strings.
fieldField ptr.

References BIBFILE_ER_NONE, and _BibFileField::name.

Referenced by BibFileFieldRead().

◆ BibFileStrRead()

static BibFileError BibFileStrRead ( char **  str,
BibFileTok  tok,
int  skipSp,
FILE *  fP 
)

Read a character string from the given stream until a character not matched by the given charcter list is read, this character is then put back so that it can be read again. If the skip spaces flag is non zero then leading white space characters will be skipped. Characters in the string may be escaped by the escape character. String length is only limited by the memory available to AlcMalloc.

Returns
Non zero if read fails.
Parameters
strPtr for the string to be read.
tokRegular expression for valid characters within the string.
skipSpSkip leading white space characters if non zero.
fPGiven input stream.

References AlcMalloc(), BIBFILE_ER_MALLOC, BIBFILE_ER_NONE, and BIBFILE_STRBUF_START.

Referenced by BibFileFieldRead(), and BibFileRecordRead().

◆ BibFileCharMatch()

static BibFileError BibFileCharMatch ( BibFileTok  tok,
int  skipFlag,
int  skipSp,
FILE *  fP 
)

Check for a character that matches the given charcter list. If the skip flag is zero this character is put back so that it can be read again. If the skip spaces flag is non zero then leading white space characters will be skipped.

Returns
Non zero if match fails.
Parameters
tokRegular expression token.
skipFlagPut the character back into the input stream if non zero.
skipSpSkip leading white space characters if non zero.
fPGiven input stream.

References BIBFILE_ER_NONE.

Referenced by BibFileFieldRead(), and BibFileRecordRead().

◆ BibFileCharUnread()

static BibFileError BibFileCharUnread ( char  newC,
FILE *  fP 
)

Put a character back into the stream from which it was read.

Returns
Non zero if cant put it back.
Parameters
newCThe character to put back.
fPGiven input stream.

References BIBFILE_ER_NONE, and BIBFILE_ER_READ.

◆ BibFileCharRegEx()

static BibFileError BibFileCharRegEx ( char  given,
BibFileTok  tok 
)

Match the given character to the given regular expression. The regular expression may either be compilled or a charcater string.

Returns
Non zero if match read fails.
Parameters
givenCharacter to match.
tokRegular expression for valid characters to match.

References BIBFILE_ER_MALLOC, BIBFILE_ER_NONE, BIBFILE_TOK_MAX, and BIBFILE_TOK_MIN.

◆ BibFileSkipSpaces()

static BibFileError BibFileSkipSpaces ( FILE *  fP)

Read and skip white space characters.

Returns
Non zero if read fails.
Parameters
fPGiven input stream.

References BIBFILE_ER_EOF, and BIBFILE_ER_NONE.

◆ BibFileEscapeRestrictedChar()

BibFileError BibFileEscapeRestrictedChar ( char *  inString,
char **  outString 
)

Replace any special character with ESC+spacial char.

Returns
Non zero if read fails.
Parameters
inStringGiven string.
outStringDestination pointer for the escaped string.

References AlcMalloc(), BIBFILE_ER_NONE, BIBFILE_RESTRICTED_NUM, and BIBFILE_STRBUF_START.

◆ BibFileUnEscapeRestrictedChar()

BibFileError BibFileUnEscapeRestrictedChar ( char *  inString,
char **  outString 
)

Replace any special caracter with ESC+spacial char.

Returns
Non zero if read fails.
Parameters
inStringOriginal string.
outStringThe escaped string.

References AlcFree(), AlcMalloc(), AlcStrDup(), BIBFILE_ER_MALLOC, and BIBFILE_ER_NONE.

◆ BibFileFieldParseFmt()

int BibFileFieldParseFmt ( BibFileField topField,
void *  value,
char *  fmt,
char *  name,
  ... 
)

Given the top most field from which to parse fields and a NULL terminated varargs list of field value pointers, format strings (for sscanf) and field name strings. All fields are parsed for all name strings. Parsed values are allowed to overwrite those previously parsed. Note that string values are parsed using a char ** and are AlcStrDup()'d.

Returns
Count of fields parsed, zero on error.
Parameters
topFieldTop most field in hierarchy of fields to be parsed.
valueFirst value pointer for result, passed directly to sscanf.
fmtFirst format string for sscanf.
nameFirst field name to be matched.
...NULL terminated varargs list of value, format and name triples.

References AlcStrDup(), _BibFileField::name, _BibFileField::next, and _BibFileField::value.

Referenced by WlzEffBibParse3DSectionViewParamsRecord(), WlzEffBibParseFileRecord(), WlzEffBibParseTiePointVtxsRecord(), WlzEffBibParseWarpInputSegmentationParamsRecord(), WlzEffBibParseWarpInputThresholdParamsRecord(), and WlzEffBibParseWarpTransformParamsRecord().