Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > ParamHelper
changeset 6:d46150af45ad
Newly created project repository -- commit sub-states
author | Me@portablequad |
---|---|
date | Tue, 07 Feb 2012 12:51:29 -0800 |
parents | a8744027c1a9 |
children | 1bf28dddc45f 11553bc2f69e |
files | ParamBag.c ReadParamsFromFile.c |
diffstat | 2 files changed, 314 insertions(+), 314 deletions(-) [+] |
line diff
1.1 --- a/ParamBag.c Fri Jan 27 15:51:11 2012 +0100 1.2 +++ b/ParamBag.c Tue Feb 07 12:51:29 2012 -0800 1.3 @@ -1,203 +1,203 @@ 1.4 -/* 1.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 - * Licensed under GNU General Public License version 2 1.7 - * 1.8 - * Based on code posted to a discussion group on the web. (Forgot to mark 1.9 - * down where got it from) 1.10 - * 1.11 - * Author: seanhalle@yahoo.com 1.12 - * 1.13 - * Created on November 14, 2009, 9:00 PM 1.14 - */ 1.15 -#include <string.h> 1.16 -#include <stdio.h> 1.17 -#include <stdlib.h> 1.18 - 1.19 -#include "Param.h" 1.20 - 1.21 -void freeParamStruc( ParamStruc * param ); 1.22 -void freeParamBagHashEntry( ParamBagHashEntry *entry ); 1.23 -ParamBagHashEntry * lookupKeyInHash( char *key, ParamBag * bag ); 1.24 -unsigned int hashThisKey( char *s, int hashSz ); 1.25 -void nullOutParamBagHashEntries( ParamBag *bag ); 1.26 - 1.27 - ParamBag * 1.28 -makeParamBag() 1.29 - { ParamBag * retBag; 1.30 - retBag = malloc( sizeof( ParamBag ) ); 1.31 - retBag->entries = malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) ); 1.32 - retBag->bagSz = PARAM_BAG_HASHSIZE; 1.33 - nullOutParamBagHashEntries( retBag ); 1.34 - 1.35 - return retBag; 1.36 - } 1.37 - 1.38 - void 1.39 -nullOutParamBagHashEntries( ParamBag *bag ) 1.40 - { int i, bagSz; 1.41 - bagSz = bag->bagSz; 1.42 - ParamBagHashEntry ** entries = bag->entries; 1.43 - for( i = 0; i < bagSz; i++ ) 1.44 - entries[ i ] = NULL; 1.45 - } 1.46 - 1.47 - unsigned int 1.48 -hashKey( char *s, int hashSz ) 1.49 - { unsigned int h = 0; 1.50 - 1.51 - for( ; *s != 0; s++ ) 1.52 - h = *s + h*31; 1.53 - return h % hashSz; 1.54 - } 1.55 - 1.56 -/*Need this to be separated out, for use in both getParam and putParam 1.57 - */ 1.58 - ParamBagHashEntry * 1.59 -lookupKeyInHash( char *key, ParamBag * bag ) 1.60 - { unsigned int 1.61 - hashIndex = hashKey( key, bag->bagSz ); 1.62 - ParamBagHashEntry* 1.63 - hashEntry = bag->entries[ hashIndex ]; 1.64 - for( ; hashEntry != NULL; hashEntry = hashEntry->next ) 1.65 - { if( strcmp( hashEntry->key, key ) == 0 ) return hashEntry; 1.66 - } 1.67 - return NULL; 1.68 - } 1.69 - 1.70 - ParamStruc * 1.71 -getParamFromBag( char *key, ParamBag * bag ) 1.72 - { ParamBagHashEntry *entry; 1.73 - entry = lookupKeyInHash( key, bag ); 1.74 - if( entry == NULL ) return NULL; 1.75 - 1.76 - return entry->param; 1.77 - } 1.78 - 1.79 - int 1.80 -addParamToBag( char* key, ParamStruc *param, ParamBag *bag ) 1.81 - { unsigned int hashIdx; 1.82 - ParamBagHashEntry* hashEntry; 1.83 - hashEntry = lookupKeyInHash( key, bag ); 1.84 - if( hashEntry == NULL ) 1.85 - { hashIdx = hashKey( key, bag->bagSz ); 1.86 - hashEntry = (ParamBagHashEntry*) malloc( sizeof( ParamBagHashEntry ) ); 1.87 - if( hashEntry == NULL ) return 0; 1.88 - hashEntry->key = strdup( key ); 1.89 - if( hashEntry->key == NULL ) return 0; 1.90 - hashEntry->next = (bag->entries)[hashIdx]; 1.91 - (bag->entries)[hashIdx] = hashEntry; 1.92 - } 1.93 - else 1.94 - { freeParamStruc( hashEntry->param ); 1.95 - } 1.96 - hashEntry->param = param; 1.97 - return 1; 1.98 - } 1.99 - 1.100 - 1.101 - void 1.102 -freeParamBag( ParamBag *bag ) 1.103 - { int i; 1.104 - ParamBagHashEntry *hashEntry, *temp, **entries; 1.105 - 1.106 - entries = bag->entries; 1.107 - for( i=0; i < bag->bagSz; i++ ) 1.108 - { if( entries[i] != NULL ) 1.109 - { hashEntry = entries[i]; 1.110 - while( hashEntry != NULL ) 1.111 - { 1.112 - temp = hashEntry->next; 1.113 - freeParamBagHashEntry( hashEntry ); 1.114 - hashEntry = temp; 1.115 - } 1.116 - } 1.117 - } 1.118 - } 1.119 - 1.120 - void 1.121 -freeParamBagHashEntry( ParamBagHashEntry *entry ) 1.122 - { 1.123 - freeParamStruc( entry->param ); 1.124 - free( entry->key ); //was malloc'd above, so free it 1.125 - free( entry ); 1.126 - } 1.127 - 1.128 - void 1.129 -freeParamStruc( ParamStruc * param ) 1.130 - { if( param->type == STRING_PARAM_TYPE ) free( param->strValue ); 1.131 - free( param ); 1.132 - } 1.133 - 1.134 - ParamStruc * 1.135 -makeParamStruc() 1.136 - { ParamStruc *retStruc; 1.137 - retStruc = malloc( sizeof( ParamStruc ) ); 1.138 - retStruc->floatValue = 0.0; 1.139 - retStruc->intValue = 0; 1.140 - retStruc->strValue = NULL; 1.141 - 1.142 - return retStruc; 1.143 - } 1.144 - 1.145 -void 1.146 -removeEndWhtSpaceFromStr( char *str ) 1.147 - { int n; 1.148 - 1.149 - n = strlen ( str ); 1.150 - while( --n >= 0 ) 1.151 - { 1.152 - if(str[n] != ' ' && str[n] != '\t' && str[n] != '\n' && str[n] != '\r') 1.153 - break; 1.154 - } 1.155 - str[n + 1] = '\0'; 1.156 - } 1.157 - 1.158 - 1.159 -ParamStruc * 1.160 -makeParamFromStrs( char * type, char *value ) 1.161 - { ParamStruc *retParam; 1.162 - retParam = makeParamStruc(); 1.163 - switch(*type) 1.164 - { case 'i': 1.165 - { retParam->type = INT_PARAM_TYPE; 1.166 - retParam->intValue = atoi( value ); 1.167 - } break; 1.168 - case 's': 1.169 - { retParam->type = STRING_PARAM_TYPE; 1.170 - retParam->strValue = malloc( strlen(value) + 1); 1.171 - strcpy( retParam->strValue, value ); 1.172 - removeEndWhtSpaceFromStr( retParam->strValue ); 1.173 - } break; 1.174 - case 'f': 1.175 - { retParam->type = FLOAT_PARAM_TYPE; 1.176 - retParam->floatValue = atof( value ); 1.177 - } break; 1.178 - } 1.179 - return retParam; 1.180 - } 1.181 - 1.182 - 1.183 -/* A pretty useless but good debugging function, 1.184 - which simply displays the hashtable in (key.value) pairs 1.185 -*/ 1.186 -/*void paramBagToString( ParamBag * bag ) 1.187 - { int i; 1.188 - ParamBagHashEntry *t; 1.189 - for( i = 0; i < bag->bagSz; i++ ) 1.190 - { t = entries[i]; 1.191 - if( t == NULL ) 1.192 - strcat_m( retStr, &"()" ); 1.193 - else 1.194 - { strcat_m( retStr, &"(" ); 1.195 - for( ; t != NULL; t = t->next ) 1.196 - { strcat_m( retStr, &" " ); 1.197 - strcat_m( retStr, t->key ); 1.198 - strcat_m( retStr, &"." ); 1.199 - strcat_m( retStr, paramToString( t->param ) ); 1.200 - strcat_m( retStr, &" " ); 1.201 - } 1.202 - strcat_m( retStr, &")" ); 1.203 - } 1.204 - } 1.205 - } 1.206 -*/ 1.207 +/* 1.208 + * Copyright 2009 OpenSourceStewardshipFoundation.org 1.209 + * Licensed under GNU General Public License version 2 1.210 + * 1.211 + * Based on code posted to a discussion group on the web. (Forgot to mark 1.212 + * down where got it from) 1.213 + * 1.214 + * Author: seanhalle@yahoo.com 1.215 + * 1.216 + * Created on November 14, 2009, 9:00 PM 1.217 + */ 1.218 +#include <string.h> 1.219 +#include <stdio.h> 1.220 +#include <stdlib.h> 1.221 + 1.222 +#include "Param.h" 1.223 + 1.224 +void freeParamStruc( ParamStruc * param ); 1.225 +void freeParamBagHashEntry( ParamBagHashEntry *entry ); 1.226 +ParamBagHashEntry * lookupKeyInHash( char *key, ParamBag * bag ); 1.227 +unsigned int hashThisKey( char *s, int hashSz ); 1.228 +void nullOutParamBagHashEntries( ParamBag *bag ); 1.229 + 1.230 + ParamBag * 1.231 +makeParamBag() 1.232 + { ParamBag * retBag; 1.233 + retBag = malloc( sizeof( ParamBag ) ); 1.234 + retBag->entries = malloc( PARAM_BAG_HASHSIZE * sizeof( ParamBagHashEntry *) ); 1.235 + retBag->bagSz = PARAM_BAG_HASHSIZE; 1.236 + nullOutParamBagHashEntries( retBag ); 1.237 + 1.238 + return retBag; 1.239 + } 1.240 + 1.241 + void 1.242 +nullOutParamBagHashEntries( ParamBag *bag ) 1.243 + { int i, bagSz; 1.244 + bagSz = bag->bagSz; 1.245 + ParamBagHashEntry ** entries = bag->entries; 1.246 + for( i = 0; i < bagSz; i++ ) 1.247 + entries[ i ] = NULL; 1.248 + } 1.249 + 1.250 + unsigned int 1.251 +hashKey( char *s, int hashSz ) 1.252 + { unsigned int h = 0; 1.253 + 1.254 + for( ; *s != 0; s++ ) 1.255 + h = *s + h*31; 1.256 + return h % hashSz; 1.257 + } 1.258 + 1.259 +/*Need this to be separated out, for use in both getParam and putParam 1.260 + */ 1.261 + ParamBagHashEntry * 1.262 +lookupKeyInHash( char *key, ParamBag * bag ) 1.263 + { unsigned int 1.264 + hashIndex = hashKey( key, bag->bagSz ); 1.265 + ParamBagHashEntry* 1.266 + hashEntry = bag->entries[ hashIndex ]; 1.267 + for( ; hashEntry != NULL; hashEntry = hashEntry->next ) 1.268 + { if( strcmp( hashEntry->key, key ) == 0 ) return hashEntry; 1.269 + } 1.270 + return NULL; 1.271 + } 1.272 + 1.273 + ParamStruc * 1.274 +getParamFromBag( char *key, ParamBag * bag ) 1.275 + { ParamBagHashEntry *entry; 1.276 + entry = lookupKeyInHash( key, bag ); 1.277 + if( entry == NULL ) return NULL; 1.278 + 1.279 + return entry->param; 1.280 + } 1.281 + 1.282 + int 1.283 +addParamToBag( char* key, ParamStruc *param, ParamBag *bag ) 1.284 + { unsigned int hashIdx; 1.285 + ParamBagHashEntry* hashEntry; 1.286 + hashEntry = lookupKeyInHash( key, bag ); 1.287 + if( hashEntry == NULL ) 1.288 + { hashIdx = hashKey( key, bag->bagSz ); 1.289 + hashEntry = (ParamBagHashEntry*) malloc( sizeof( ParamBagHashEntry ) ); 1.290 + if( hashEntry == NULL ) return 0; 1.291 + hashEntry->key = strdup( key ); 1.292 + if( hashEntry->key == NULL ) return 0; 1.293 + hashEntry->next = (bag->entries)[hashIdx]; 1.294 + (bag->entries)[hashIdx] = hashEntry; 1.295 + } 1.296 + else 1.297 + { freeParamStruc( hashEntry->param ); 1.298 + } 1.299 + hashEntry->param = param; 1.300 + return 1; 1.301 + } 1.302 + 1.303 + 1.304 + void 1.305 +freeParamBag( ParamBag *bag ) 1.306 + { int i; 1.307 + ParamBagHashEntry *hashEntry, *temp, **entries; 1.308 + 1.309 + entries = bag->entries; 1.310 + for( i=0; i < bag->bagSz; i++ ) 1.311 + { if( entries[i] != NULL ) 1.312 + { hashEntry = entries[i]; 1.313 + while( hashEntry != NULL ) 1.314 + { 1.315 + temp = hashEntry->next; 1.316 + freeParamBagHashEntry( hashEntry ); 1.317 + hashEntry = temp; 1.318 + } 1.319 + } 1.320 + } 1.321 + } 1.322 + 1.323 + void 1.324 +freeParamBagHashEntry( ParamBagHashEntry *entry ) 1.325 + { 1.326 + freeParamStruc( entry->param ); 1.327 + free( entry->key ); //was malloc'd above, so free it 1.328 + free( entry ); 1.329 + } 1.330 + 1.331 + void 1.332 +freeParamStruc( ParamStruc * param ) 1.333 + { if( param->type == STRING_PARAM_TYPE ) free( param->strValue ); 1.334 + free( param ); 1.335 + } 1.336 + 1.337 + ParamStruc * 1.338 +makeParamStruc() 1.339 + { ParamStruc *retStruc; 1.340 + retStruc = malloc( sizeof( ParamStruc ) ); 1.341 + retStruc->floatValue = 0.0; 1.342 + retStruc->intValue = 0; 1.343 + retStruc->strValue = NULL; 1.344 + 1.345 + return retStruc; 1.346 + } 1.347 + 1.348 +void 1.349 +removeEndWhtSpaceFromStr( char *str ) 1.350 + { int n; 1.351 + 1.352 + n = strlen ( str ); 1.353 + while( --n >= 0 ) 1.354 + { 1.355 + if(str[n] != ' ' && str[n] != '\t' && str[n] != '\n' && str[n] != '\r') 1.356 + break; 1.357 + } 1.358 + str[n + 1] = '\0'; 1.359 + } 1.360 + 1.361 + 1.362 +ParamStruc * 1.363 +makeParamFromStrs( char * type, char *value ) 1.364 + { ParamStruc *retParam; 1.365 + retParam = makeParamStruc(); 1.366 + switch(*type) 1.367 + { case 'i': 1.368 + { retParam->type = INT_PARAM_TYPE; 1.369 + retParam->intValue = atoi( value ); 1.370 + } break; 1.371 + case 's': 1.372 + { retParam->type = STRING_PARAM_TYPE; 1.373 + retParam->strValue = malloc( strlen(value) + 1); 1.374 + strcpy( retParam->strValue, value ); 1.375 + removeEndWhtSpaceFromStr( retParam->strValue ); 1.376 + } break; 1.377 + case 'f': 1.378 + { retParam->type = FLOAT_PARAM_TYPE; 1.379 + retParam->floatValue = atof( value ); 1.380 + } break; 1.381 + } 1.382 + return retParam; 1.383 + } 1.384 + 1.385 + 1.386 +/* A pretty useless but good debugging function, 1.387 + which simply displays the hashtable in (key.value) pairs 1.388 +*/ 1.389 +/*void paramBagToString( ParamBag * bag ) 1.390 + { int i; 1.391 + ParamBagHashEntry *t; 1.392 + for( i = 0; i < bag->bagSz; i++ ) 1.393 + { t = entries[i]; 1.394 + if( t == NULL ) 1.395 + strcat_m( retStr, &"()" ); 1.396 + else 1.397 + { strcat_m( retStr, &"(" ); 1.398 + for( ; t != NULL; t = t->next ) 1.399 + { strcat_m( retStr, &" " ); 1.400 + strcat_m( retStr, t->key ); 1.401 + strcat_m( retStr, &"." ); 1.402 + strcat_m( retStr, paramToString( t->param ) ); 1.403 + strcat_m( retStr, &" " ); 1.404 + } 1.405 + strcat_m( retStr, &")" ); 1.406 + } 1.407 + } 1.408 + } 1.409 +*/
2.1 --- a/ReadParamsFromFile.c Fri Jan 27 15:51:11 2012 +0100 2.2 +++ b/ReadParamsFromFile.c Tue Feb 07 12:51:29 2012 -0800 2.3 @@ -1,111 +1,111 @@ 2.4 -/* 2.5 - * Author: SeanHalle@yahoo.com 2.6 - * 2.7 - * Created on June 15, 2009, 10:12 AM 2.8 - */ 2.9 - 2.10 -#include <stdio.h> 2.11 -#include <stdlib.h> 2.12 -#include <string.h> 2.13 - 2.14 -#include "Param.h" 2.15 - 2.16 -ParamStruc * makeParamFromStrs( char * type, char *value ); 2.17 - 2.18 -#define _GNU_SOURCE 2.19 - 2.20 -/*Copied from gnu's win32 lib 2.21 - */ 2.22 - ssize_t 2.23 -getline( char **lineptr, size_t *n, FILE *stream ) 2.24 - { 2.25 - if ( lineptr == NULL || n == NULL) return -1; 2.26 - if (*lineptr == NULL || *n == 0) 2.27 - { *n = 500; //max length of line in a config file 2.28 - *lineptr = (char *) malloc( *n ); 2.29 - if (*lineptr == NULL) return -1; 2.30 - } 2.31 - if( fgets( *lineptr, *n, stream ) ) 2.32 - return *n; 2.33 - else 2.34 - return -1; 2.35 - } 2.36 - 2.37 - void 2.38 -readParamFileIntoBag( char *paramFileName, ParamBag * bag ) 2.39 - { 2.40 - size_t lineSz = 0; 2.41 - FILE* paramFile; 2.42 - char* line = NULL; 2.43 - 2.44 - char* paramType;// = malloc( 12 ); //"double" is the longest type 2.45 - char* paramName;// = malloc( 500 ); //max of 500 chars in name 2.46 - char* paramValue;// = malloc( 500 ); //max of 500 chars in value 2.47 - 2.48 - lineSz = 500; //max length of line in a config file 2.49 - line = (char *) malloc( lineSz ); 2.50 - if( line == NULL ) 2.51 - { printf( "\nIn readParamFileIntoBag: no mem for line\n" ); 2.52 - return; 2.53 - } 2.54 - 2.55 - 2.56 - paramFile = fopen( paramFileName, "r" ); 2.57 - if( paramFile == NULL ) 2.58 - { printf("\ncouldn't open param file: %s\n", paramFileName); exit(0); } 2.59 - fseek( paramFile, 0, SEEK_SET ); 2.60 - while( !feof( paramFile ) ) 2.61 - { while( getline( &line, &lineSz, paramFile ) != -1 ) 2.62 - { 2.63 - char *lineEnd = line + strlen(line) +1; 2.64 - char *searchPos = line; 2.65 - 2.66 - if( *line == '\n') continue; //blank line 2.67 - if( *line == '/' ) continue; //comment line 2.68 - 2.69 - //read the param type 2.70 - paramType = line; //start of string 2.71 - int foundIt = 0; 2.72 - for( ; searchPos < lineEnd && !foundIt; searchPos++) 2.73 - { if( *searchPos == ',' ) 2.74 - { foundIt = 1; 2.75 - *searchPos = 0; //mark end of string 2.76 - } 2.77 - } 2.78 - //get rid of leading spaces 2.79 - for( ; searchPos < lineEnd; searchPos++) 2.80 - { if( *searchPos != ' ' ) break; 2.81 - } 2.82 - //read the param name 2.83 - paramName = searchPos; 2.84 - foundIt = 0; 2.85 - for( ; searchPos < lineEnd && !foundIt; searchPos++) 2.86 - { if( *searchPos == ',' ) 2.87 - { foundIt = 1; 2.88 - *searchPos = 0; //mark end 2.89 - } 2.90 - } 2.91 - //get rid of leading spaces 2.92 - for( ; searchPos < lineEnd; searchPos++) 2.93 - { if( *searchPos != ' ' ) break; 2.94 - } 2.95 - //read the param value 2.96 - paramValue = searchPos; 2.97 - foundIt = 0; 2.98 - for( ; searchPos < lineEnd && !foundIt; searchPos++) 2.99 - { if( *searchPos == '\n' ) 2.100 - { foundIt = 1; 2.101 - *searchPos = 0; //mark end 2.102 - } 2.103 - } 2.104 - if( foundIt ) 2.105 - { printf("Found: %s, %s, %s\n", paramType, paramName, paramValue ); 2.106 - ParamStruc * 2.107 - paramStruc = makeParamFromStrs( paramType, paramValue ); 2.108 - addParamToBag( paramName, paramStruc, bag ); 2.109 - } 2.110 - } 2.111 - } 2.112 - free( line ); 2.113 - } 2.114 - 2.115 +/* 2.116 + * Author: SeanHalle@yahoo.com 2.117 + * 2.118 + * Created on June 15, 2009, 10:12 AM 2.119 + */ 2.120 + 2.121 +#include <stdio.h> 2.122 +#include <stdlib.h> 2.123 +#include <string.h> 2.124 + 2.125 +#include "Param.h" 2.126 + 2.127 +ParamStruc * makeParamFromStrs( char * type, char *value ); 2.128 + 2.129 +#define _GNU_SOURCE 2.130 + 2.131 +/*Copied from gnu's win32 lib 2.132 + */ 2.133 + ssize_t 2.134 +getline( char **lineptr, size_t *n, FILE *stream ) 2.135 + { 2.136 + if ( lineptr == NULL || n == NULL) return -1; 2.137 + if (*lineptr == NULL || *n == 0) 2.138 + { *n = 500; //max length of line in a config file 2.139 + *lineptr = (char *) malloc( *n ); 2.140 + if (*lineptr == NULL) return -1; 2.141 + } 2.142 + if( fgets( *lineptr, *n, stream ) ) 2.143 + return *n; 2.144 + else 2.145 + return -1; 2.146 + } 2.147 + 2.148 + void 2.149 +readParamFileIntoBag( char *paramFileName, ParamBag * bag ) 2.150 + { 2.151 + size_t lineSz = 0; 2.152 + FILE* paramFile; 2.153 + char* line = NULL; 2.154 + 2.155 + char* paramType;// = malloc( 12 ); //"double" is the longest type 2.156 + char* paramName;// = malloc( 500 ); //max of 500 chars in name 2.157 + char* paramValue;// = malloc( 500 ); //max of 500 chars in value 2.158 + 2.159 + lineSz = 500; //max length of line in a config file 2.160 + line = (char *) malloc( lineSz ); 2.161 + if( line == NULL ) 2.162 + { printf( "\nIn readParamFileIntoBag: no mem for line\n" ); 2.163 + return; 2.164 + } 2.165 + 2.166 + 2.167 + paramFile = fopen( paramFileName, "r" ); 2.168 + if( paramFile == NULL ) 2.169 + { printf("\ncouldn't open param file: %s\n", paramFileName); exit(0); } 2.170 + fseek( paramFile, 0, SEEK_SET ); 2.171 + while( !feof( paramFile ) ) 2.172 + { while( getline( &line, &lineSz, paramFile ) != -1 ) 2.173 + { 2.174 + char *lineEnd = line + strlen(line) +1; 2.175 + char *searchPos = line; 2.176 + 2.177 + if( *line == '\n') continue; //blank line 2.178 + if( *line == '/' ) continue; //comment line 2.179 + 2.180 + //read the param type 2.181 + paramType = line; //start of string 2.182 + int foundIt = 0; 2.183 + for( ; searchPos < lineEnd && !foundIt; searchPos++) 2.184 + { if( *searchPos == ',' ) 2.185 + { foundIt = 1; 2.186 + *searchPos = 0; //mark end of string 2.187 + } 2.188 + } 2.189 + //get rid of leading spaces 2.190 + for( ; searchPos < lineEnd; searchPos++) 2.191 + { if( *searchPos != ' ' ) break; 2.192 + } 2.193 + //read the param name 2.194 + paramName = searchPos; 2.195 + foundIt = 0; 2.196 + for( ; searchPos < lineEnd && !foundIt; searchPos++) 2.197 + { if( *searchPos == ',' ) 2.198 + { foundIt = 1; 2.199 + *searchPos = 0; //mark end 2.200 + } 2.201 + } 2.202 + //get rid of leading spaces 2.203 + for( ; searchPos < lineEnd; searchPos++) 2.204 + { if( *searchPos != ' ' ) break; 2.205 + } 2.206 + //read the param value 2.207 + paramValue = searchPos; 2.208 + foundIt = 0; 2.209 + for( ; searchPos < lineEnd && !foundIt; searchPos++) 2.210 + { if( *searchPos == '\n' ) 2.211 + { foundIt = 1; 2.212 + *searchPos = 0; //mark end 2.213 + } 2.214 + } 2.215 + if( foundIt ) 2.216 + { printf("Found: %s, %s, %s\n", paramType, paramName, paramValue ); 2.217 + ParamStruc * 2.218 + paramStruc = makeParamFromStrs( paramType, paramValue ); 2.219 + addParamToBag( paramName, paramStruc, bag ); 2.220 + } 2.221 + } 2.222 + } 2.223 + free( line ); 2.224 + } 2.225 +