Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
Data Structures | Macros | Functions
parse.h File Reference

Include file for the command parser. More...

#include "MathType.h"
#include "deprecated.h"

Go to the source code of this file.

Data Structures

struct  KeyWd
 
struct  MKeyWd
 

Macros

#define STRING   1 /* Defines used for the MAKEKEY macro */
 
#define NUMBER   0
 
#define PARSE_ERRC   -1 /* Error return values from parse() */
 
#define PARSE_ERRP   -2
 
#define PARSE_COMMENT   -3
 
#define MAKEKEY(x, w, v, z)
 
#define MAKEMKEY(x, w, v, mn, mx)
 
#define _PARSE_H_DEPRECATED
 

Functions

int blParse (char *comline, int nkeys, KeyWd *keywords, REAL *REALparam, char **strparam)
 
int blMparse (char *comline, int nkeys, MKeyWd *keywords, REAL *REALparam, char **strparam, int *nparams)
 
int blMatch (char *comstring, char *string2, int *nletters)
 
int blGetString (char *command, char *strparam)
 
int blGetParam (char *command, REAL *value, int *nletters)
 

Detailed Description

Include file for the command parser.

Version
V1.11
Date
14.08.14
Author
Andrew C. R. Martin
Institute of Structural & Molecular Biology, University College London, Gower Street, London. WC1E 6BT.
andre.nosp@m.w@bi.nosp@m.oinf..nosp@m.org..nosp@m.uk andre.nosp@m.w.ma.nosp@m.rtin@.nosp@m.ucl..nosp@m.ac.uk

This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.

The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.

The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.

Description:

Here are defined the MAKEKEY macro, STRING and NUMBER defines, the KeyWd structure and return values for the parser.

Usage:

Revision History:

Definition in file parse.h.

Macro Definition Documentation

#define _PARSE_H_DEPRECATED

Definition at line 130 of file parse.h.

#define MAKEKEY (   x,
  w,
  v,
 
)
Value:
(x).name = (char *)malloc((strlen(w)+2) * sizeof(char)); \
if((x).name != NULL) strcpy((x).name,w); \
(x).string = v; \
(x).nparam = z
#define NULL
Definition: array2.c:99

Definition at line 102 of file parse.h.

#define MAKEMKEY (   x,
  w,
  v,
  mn,
  mx 
)
Value:
(x).name = (char *)malloc((strlen(w)+2) * sizeof(char)); \
if((x).name != NULL) strcpy((x).name,w); \
(x).string = v; \
(x).minparam = mn; \
(x).maxparam = mx
#define NULL
Definition: array2.c:99

Definition at line 109 of file parse.h.

#define NUMBER   0

Definition at line 77 of file parse.h.

#define PARSE_COMMENT   -3

Definition at line 81 of file parse.h.

#define PARSE_ERRC   -1 /* Error return values from parse() */

Definition at line 79 of file parse.h.

#define PARSE_ERRP   -2

Definition at line 80 of file parse.h.

#define STRING   1 /* Defines used for the MAKEKEY macro */

Definition at line 76 of file parse.h.

Function Documentation

int blGetParam ( char *  command,
REAL value,
int *  nletters 
)
Parameters
[in]*commandA character string
[out]*valueReturned float value
[out]*nlettersNumber of charcters pulled out of the command string
Returns
0 If error 1 If OK

Extracts the first space-delimited number from the `command' character string.

  • 11.07.90 Original By: ACRM
  • 22.04.93 Tidied comments, etc. Corrected NULL to 0
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 412 of file parse.c.

int blGetString ( char *  command,
char *  strparam 
)
Parameters
[in]*commandA character string
[out]*strparamReturned character string
Returns
Number of characters pulled out of the command string

Returns the first space-delimited group of characters from character string `command'

  • 11.07.90 Original By: ACRM
  • 22.04.93 Tidied comments, etc. Changed toggle method
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 358 of file parse.c.

int blMatch ( char *  comstring,
char *  string2,
int *  nletters 
)
Parameters
[in]*comstringA character string
[in]*string2A second string
[out]*nlettersNumber of letters matched
Returns
0 String mismatch 1 First string finished first 2 Second string finished first

Matches two strings, but stops the comparison as soon as a space or NULL is found in either string. The returned value indicates which string finished first or 0 if the letters before the space or NULL have a mismatch. The routine calls StringToUpper() on `comstring' before the comparison.

  • 11.07.90 Original By: ACRM
  • 22.04.93 Tidied comments, etc. Added check on malloc and corrected calls to free()
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 304 of file parse.c.

int blMparse ( char *  comline,
int  nkeys,
MKeyWd keywords,
REAL floatparam,
char **  strparam,
int *  nparam 
)
Parameters
[in]*comlineA command line string to parse
[in]nkeysNumber of keywords
[in]*keywordsArray of keyword structures
[out]*floatparamArray of returned strings
[out]**strparamArray of pointers to returned strings
[out]*nparamNumber of parameters found
Returns
Index of found command or error flag

As blParse(), but allows variable number of parameters to each keyword.

  • 23.02.94 Original based on parse() By: ACRM
  • 11.03.94 Added $ line handling
  • 08.10.99 Initialise nlett to 0
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 447 of file parse.c.

int blParse ( char *  comline,
int  nkeys,
KeyWd keywords,
REAL floatparam,
char **  strparam 
)
Parameters
[in]*comlineA command line string to parse
[in]nkeysNumber of keywords
[in]*keywordsArray of keyword structures
[out]*floatparamArray of returned strings
[out]**strparamArray of pointers to returned strings
Returns
Index of found command or error flag

Keyword-based command parser using a fixed number of parameters per command

  • 11.07.90 Original By: ACRM
  • 22.04.93 Tidied comments, etc. Corrected NULL to 0.
  • 11.03.94 Added $ line handling
  • 08.10.99 Initialise nlett
  • 28.02.11 Added # for comments
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 202 of file parse.c.