Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > ParamHelper
comparison ReadParamsFromFile.c @ 7:1bf28dddc45f
Created MC_shared branch
| author | Me@portablequad |
|---|---|
| date | Sat, 11 Feb 2012 20:08:58 -0800 |
| parents | d46150af45ad |
| children | b80587574901 |
comparison
equal
deleted
inserted
replaced
| 4:4716765ac299 | 5:c2d795c0bec9 |
|---|---|
| 20 getline( char **lineptr, size_t *n, FILE *stream ) | 20 getline( char **lineptr, size_t *n, FILE *stream ) |
| 21 { | 21 { |
| 22 if ( lineptr == NULL || n == NULL) return -1; | 22 if ( lineptr == NULL || n == NULL) return -1; |
| 23 if (*lineptr == NULL || *n == 0) | 23 if (*lineptr == NULL || *n == 0) |
| 24 { *n = 500; //max length of line in a config file | 24 { *n = 500; //max length of line in a config file |
| 25 *lineptr = (char *) malloc( *n ); | 25 *lineptr = (char *) VMS__malloc( *n ); |
| 26 if (*lineptr == NULL) return -1; | 26 if (*lineptr == NULL) return -1; |
| 27 } | 27 } |
| 28 if( fgets( *lineptr, *n, stream ) ) | 28 if( fgets( *lineptr, *n, stream ) ) |
| 29 return *n; | 29 return *n; |
| 30 else | 30 else |
| 41 char* paramType;// = malloc( 12 ); //"double" is the longest type | 41 char* paramType;// = malloc( 12 ); //"double" is the longest type |
| 42 char* paramName;// = malloc( 500 ); //max of 500 chars in name | 42 char* paramName;// = malloc( 500 ); //max of 500 chars in name |
| 43 char* paramValue;// = malloc( 500 ); //max of 500 chars in value | 43 char* paramValue;// = malloc( 500 ); //max of 500 chars in value |
| 44 | 44 |
| 45 lineSz = 500; //max length of line in a config file | 45 lineSz = 500; //max length of line in a config file |
| 46 line = (char *) malloc( lineSz ); | 46 line = (char *) VMS__malloc( lineSz ); |
| 47 if( line == NULL ) | 47 if( line == NULL ) |
| 48 { printf( "\nIn readParamFileIntoBag: no mem for line\n" ); | 48 { printf( "\nIn readParamFileIntoBag: no mem for line\n" ); |
| 49 return; | 49 return; |
| 50 } | 50 } |
| 51 | 51 |
| 104 paramStruc = makeParamFromStrs( paramType, paramValue ); | 104 paramStruc = makeParamFromStrs( paramType, paramValue ); |
| 105 addParamToBag( paramName, paramStruc, bag ); | 105 addParamToBag( paramName, paramStruc, bag ); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 free( line ); | 109 VMS__free( line ); |
| 110 } | 110 } |
| 111 | 111 |
