inc/keys.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 2000 Jim Kent.  This source code may be freely used         *
00003  * for personal, academic, and non-profit purposes.  Commercial use          *
00004  * permitted only by explicit agreement with Jim Kent (jim_kent@pacbell.net) *
00005  *****************************************************************************/
00006 /* keys.h - Stuff to manage a little key/value table and
00007  * evaluate expressions on it. */
00008 #ifndef KEYS_H
00009 #define KEYS_H
00010 
00011 struct keyVal
00012 /* A key/value pair of strings. */
00013     {
00014     char *key;
00015     char *val;
00016     };
00017 
00018 struct kvt *newKvt(int size);
00019 /* Get a new key value table. */
00020 
00021 void freeKvt(struct kvt **pKvt);
00022 /* Free up key value table. */
00023 
00024 void kvtClear(struct kvt *kvt);
00025 /* Clear the keys table. */
00026 
00027 struct keyVal *kvtAdd(struct kvt *kvt, char *key, char *val);
00028 /* Add in new key. */
00029 
00030 struct keyVal* kvtGet(struct kvt *kvt, char *key);
00031 /* get the keyVal for the specified key, of NULL if not found. */
00032 
00033 char *kvtLookup(struct kvt *kvt, char *key);
00034 /* Search table for key.  Return key value, or NULL if
00035  * key not found. */
00036 
00037 void kvtWriteAll(struct kvt *kvt, FILE *f, struct slName *hideList);
00038 /* Write all keys to file except the ones in hideList */
00039 
00040 void kvtParseAdd(struct kvt *kvt, char *text);
00041 /* Add in keys from text.  Text is in format:
00042  *     key val
00043  * for each line of text. Text gets many of it's
00044  * space characters and newlines replaced by 0's
00045  * and should persist until call to keysClear(). */
00046 
00047 struct keyExp
00048 /* A handle on a parsed expression which can be
00049  * quickly evaluated.  */
00050     {
00051     void *rootExp;       /* Internally struct exp. */
00052     void *tokenList;     /* Internally struct tok. */
00053     };
00054 
00055 boolean keyExpEval(struct keyExp *exp, struct kvt *kvt);
00056 /* Recursively evaluate expression. */
00057 
00058 struct keyExp *keyExpParse(char *text);
00059 /* Parse text into key expression.  Squawk and die if it
00060  * fails. */
00061 
00062 boolean keyTextScan(char *text, char *key, char *valBuf, int valBufSize);
00063 /* Get value of key in text. Return FALSE if key doesn't exist. */
00064 
00065 #endif /* KEYS_H */
00066 

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2