inc/keys.h File Reference

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

Go to the source code of this file.

Data Structures

struct  keyVal
struct  keyExp

Functions

kvtnewKvt (int size)
void freeKvt (struct kvt **pKvt)
void kvtClear (struct kvt *kvt)
keyValkvtAdd (struct kvt *kvt, char *key, char *val)
keyValkvtGet (struct kvt *kvt, char *key)
char * kvtLookup (struct kvt *kvt, char *key)
void kvtWriteAll (struct kvt *kvt, FILE *f, struct slName *hideList)
void kvtParseAdd (struct kvt *kvt, char *text)
boolean keyExpEval (struct keyExp *exp, struct kvt *kvt)
keyExpkeyExpParse (char *text)
boolean keyTextScan (char *text, char *key, char *valBuf, int valBufSize)


Function Documentation

void freeKvt ( struct kvt **  pKvt  ) 

Definition at line 32 of file keys.c.

References freeMem(), freez(), and kvt::table.

00034 {
00035 struct kvt *kvt;
00036 if ((kvt = *pKvt) != NULL)
00037     {
00038     freeMem(kvt->table);
00039     freez(pKvt);
00040     }
00041 }

Here is the call graph for this function:

boolean keyExpEval ( struct keyExp exp,
struct kvt kvt 
)

Definition at line 321 of file keys.c.

References rkeyEval(), and keyExp::rootExp.

00323 {
00324 return rkeyEval(kvt, keyExp->rootExp);
00325 }

Here is the call graph for this function:

struct keyExp* keyExpParse ( char *  text  )  [read]

Definition at line 519 of file keys.c.

References AllocVar, kxTokenize(), parseExp(), keyExp::rootExp, tok, keyExp::tokenList, and TRUE.

00522 {
00523 struct keyExp *ke;
00524 struct kxTok *tok;
00525 AllocVar(ke);
00526 ke->tokenList = tok = kxTokenize(text, TRUE);
00527 ke->rootExp = parseExp(tok);
00528 
00529 return ke;
00530 }

Here is the call graph for this function:

boolean keyTextScan ( char *  text,
char *  key,
char *  valBuf,
int  valBufSize 
)

Definition at line 534 of file keys.c.

References FALSE, and TRUE.

00536 {
00537 int keySize = strlen(key);
00538 char *s, *nl;
00539 boolean ok = FALSE;
00540 
00541 for (s = text; !isspace(s[0]); s = nl+1)
00542     {
00543     nl = strchr(s, '\n');
00544     assert(nl != NULL);
00545     if (s[keySize] == ' ' && memcmp(s, key, keySize) == 0)
00546         {
00547         char *val = s + keySize + 1;
00548         int valSize = nl - val;
00549         if (valSize >= valBufSize)
00550             valSize = valBufSize-1;
00551         memcpy(valBuf, val, valSize);
00552         valBuf[valSize] = 0;
00553         ok = TRUE;
00554         break;
00555         }
00556     }
00557 return ok;
00558 }

struct keyVal* kvtAdd ( struct kvt kvt,
char *  key,
char *  val 
) [read]

Definition at line 49 of file keys.c.

References kvt::alloced, errAbort(), keyVal::key, kvt::table, kvt::used, and keyVal::val.

Referenced by kvtParseAdd().

00051 {
00052 struct keyVal *kv;
00053 if (kvt->used == kvt->alloced)
00054     errAbort("Too many keys in keyVal(%s %s)", key, val);
00055 kv = &kvt->table[kvt->used++];
00056 kv->key = key;
00057 kv->val = val;
00058 return kv;
00059 }

Here is the call graph for this function:

Here is the caller graph for this function:

void kvtClear ( struct kvt kvt  ) 

Definition at line 43 of file keys.c.

References kvt::used.

00045 {
00046 kvt->used = 0;
00047 }

struct keyVal* kvtGet ( struct kvt kvt,
char *  key 
) [read]

Definition at line 85 of file keys.c.

References sameString, kvt::table, and kvt::used.

Referenced by kvtLookup().

00087 {
00088 int i;
00089 struct keyVal *keyTable = kvt->table;
00090 int keysUsed = kvt->used;
00091 
00092 for (i=0; i<keysUsed; ++i)
00093     {
00094     if (sameString(key, keyTable[i].key))
00095         return &keyTable[i];
00096     }
00097 return NULL;
00098 }

Here is the caller graph for this function:

char* kvtLookup ( struct kvt kvt,
char *  key 
)

Definition at line 100 of file keys.c.

References kvtGet(), and keyVal::val.

Referenced by getIntVals(), and rkeyEval().

00103 {
00104 struct keyVal *keyVal = kvtGet(kvt, key);
00105 if (keyVal == NULL)
00106     return NULL;
00107 else
00108     return keyVal->val;
00109 }

Here is the call graph for this function:

Here is the caller graph for this function:

void kvtParseAdd ( struct kvt kvt,
char *  text 
)

Definition at line 61 of file keys.c.

References ArraySize, chopString(), and kvtAdd().

00062                                             :
00063  *     key val
00064  * for each line of text. Text gets many of it's
00065  * space characters and newlines replaced by 0's
00066  * and should persist until call to keysClear(). */
00067 {
00068 char *lines[256];
00069 int lineCount;
00070 int i;
00071 char *k, *v;
00072 
00073 lineCount = chopString(text, "\n\r", lines, ArraySize(lines));
00074 for (i=0; i<lineCount; ++i)
00075     {
00076     k = lines[i];
00077     if ((v = strchr(k, ' ')) != NULL)
00078         {
00079         *v++ = 0;
00080         kvtAdd(kvt, k, v);
00081         }
00082     }
00083 }

Here is the call graph for this function:

void kvtWriteAll ( struct kvt kvt,
FILE *  f,
struct slName hideList 
)

Definition at line 111 of file keys.c.

References keyVal::key, mustWrite(), slNameInList(), kvt::table, kvt::used, and keyVal::val.

00113 {
00114 int i;
00115 static char lf = '\n';
00116 struct keyVal *kv = kvt->table;
00117 int keyCount = kvt->used;
00118 
00119 for (i=0; i<keyCount; ++i)
00120     {
00121     char *key = kv->key;
00122     if (kv->val != NULL && !slNameInList(hideList, key))
00123         fprintf(f, "%s %s\n", key, kv->val);
00124     ++kv;
00125     }
00126 mustWrite(f, &lf, 1);   /* Instead of fputc for error checking. */
00127 }

Here is the call graph for this function:

struct kvt* newKvt ( int  size  )  [read]

Definition at line 21 of file keys.c.

References kvt::alloced, AllocVar, needMem(), and kvt::table.

00023 {
00024 struct kvt *kvt;
00025 AllocVar(kvt);
00026 kvt->alloced = size;
00027 kvt->table = needMem(size * sizeof(kvt->table[0]));
00028 return kvt;
00029 }

Here is the call graph for this function:


Generated on Tue Dec 25 19:02:50 2007 for blat by  doxygen 1.5.2