Woolz Image Processing  Version 1.7.5
bibFileIO.c File Reference

File I/O functions to parse the bibtex based file syntax used for serial section data, .... More...

Macros

#define BIBFILE_REGEXPR_CACHE   /* Cache regular expressions */
 
#define BIBFILE_REGEXPR_REGEXEC   /* Use regexec(3) and regcomp(3) */
 
#define BIBFILE_EOL   '\n'
 
#define BIBFILE_RESTRICTED_NUM   4
 
#define BIBFILE_STRBUF_START   256
 
#define BIBFILE_STRBUF_INC   1024
 

Enumerations

enum  BibFileTok {
  BIBFILE_TOK_MIN = 0,
  BIBFILE_TOK_NEW = 0,
  BIBFILE_TOK_SEP,
  BIBFILE_TOK_OPEN,
  BIBFILE_TOK_CLOSE,
  BIBFILE_TOK_EQUAL,
  BIBFILE_TOK_ESC,
  BIBFILE_TOK_COMMENT,
  BIBFILE_TOK_RECNAME,
  BIBFILE_TOK_RECID,
  BIBFILE_TOK_FLDNAME,
  BIBFILE_TOK_FLDVAL,
  BIBFILE_TOK_MAX
}
 

Functions

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...
 
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...
 
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...
 
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 BibFileFieldError (char **eMsg, BibFileField *field)
 Build an error string showing with some field info. More...
 
static BibFileError BibFileRecordError (char **eMsg, BibFileRecord *record)
 Build an error string showing with some record info. More...
 
static BibFileError BibFileSkipSpaces (FILE *fP)
 Read and skip white space characters. 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...
 

Detailed Description

File I/O functions to parse the bibtex based file syntax used for serial section data, ....

Author
Bill Hill
Date
March 1999
Version
Id
9a19b4ec07e1542025c0eff0b4611423c5e23224
Address: MRC Human Genetics Unit, MRC Institute of Genetics and Molecular Medicine, University of Edinburgh, Western General Hospital, Edinburgh, EH4 2XU, UK.
Copyright (C), [2012], The University Court of the University of Edinburgh, Old College, Edinburgh, UK.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. The syntax is:

                  file :=       (comment | record)
                  comment :=    COMMENT text EOL
                  record :=     NEW name OPEN id field (SEP field)*
                                CLOSE
                  field :=      name EQUAL OPEN value CLOSE

Example:

                  % this is a comment which is ignored
                  @Comment
                  { 0,
                    Text = {This is a comment too, but it is parsed}
                  }
                  @Fred{1, FFred={First bit},
                    SFred={Second line of text} % comment here too
                  }
                  % another comment
                  @Bert{2,FBert={bert's 1st value has a newline
                  and an escaped newline \
                  too},
                  SBert =
                  {bert's 2nd includes a \} character}}

All the tokens (eg OPEN, CLOSE, ...) are parsed using regular expressions and character lists held in tables. The parsing could be changed/extended by modifying the tables, eg changing the definition of OPEN/CLOSE to allow the double quote character. Using regular expressions has made coding easier and the parsing more flexible at the cost of speed. On a Sparc 10/40 with -O4 optimisation about 20% of the execution time is spent matching regular expressions.

Macro Definition Documentation

#define BIBFILE_REGEXPR_CACHE   /* Cache regular expressions */
#define BIBFILE_REGEXPR_REGEXEC   /* Use regexec(3) and regcomp(3) */
#define BIBFILE_EOL   '\n'
#define BIBFILE_RESTRICTED_NUM   4
#define BIBFILE_STRBUF_START   256
#define BIBFILE_STRBUF_INC   1024

Enumeration Type Documentation

enum BibFileTok
Enumerator
BIBFILE_TOK_MIN 
BIBFILE_TOK_NEW 
BIBFILE_TOK_SEP 
BIBFILE_TOK_OPEN 
BIBFILE_TOK_CLOSE 
BIBFILE_TOK_EQUAL 
BIBFILE_TOK_ESC 
BIBFILE_TOK_COMMENT 
BIBFILE_TOK_RECNAME 
BIBFILE_TOK_RECID 
BIBFILE_TOK_FLDNAME 
BIBFILE_TOK_FLDVAL 
BIBFILE_TOK_MAX