Changeset 393 for libmpc/trunk/mpcchap/iniparser.c
- Timestamp:
- 04/05/08 23:41:11 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/mpcchap/iniparser.c
r387 r393 83 83 static char l[ASCIILINESZ+1]; 84 84 char * last ; 85 85 86 86 if (s==NULL) return NULL ; 87 87 88 88 while (isspace((int)*s) && *s) s++; 89 89 memset(l, 0, ASCIILINESZ+1); … … 170 170 } 171 171 172 int iniparser_getnkey(dictionary * d, int nsec) 172 /*-------------------------------------------------------------------------*/ 173 /** 174 @brief Get number of keys for section n in a dictionary. 175 @param d Dictionary to examine 176 @param n Section number (from 0 to nsec-1). 177 @return Number of keys in section 178 179 This function locates the n-th section in a dictionary and returns 180 the number of keys in this section. 181 182 This function returns -1 in case of error. 183 */ 184 /*--------------------------------------------------------------------------*/ 185 int iniparser_getnkey(dictionary * d, int n) 173 186 { 174 187 int i, i_sec, cnt = 0 ; … … 179 192 continue ; 180 193 if (strchr(d->key[i], ':')==NULL) { 181 if (n sec== -1)194 if (n == -1) 182 195 break; 183 n sec-- ;196 n -- ; 184 197 } 185 if (n sec== -1)198 if (n == -1) 186 199 cnt ++; 187 200 } … … 189 202 } 190 203 204 /*-------------------------------------------------------------------------*/ 205 /** 206 @brief Get key and string for key nkey in section nsec in a dictionary. 207 @param d Dictionary to examine 208 @param nsec Section number. 209 @param nkey Key number. 210 @param string Pointer where the string will be returned. 211 @return Pointer to char string 212 213 This function locates the nkey-th key in the nsec-th section in a dictionary 214 and returns the key name and the key string as a pointer to strings 215 statically allocated inside the dictionary. 216 Do not free or modify the returned strings! 217 218 This function returns NULL in case of error. 219 */ 220 /*--------------------------------------------------------------------------*/ 191 221 char * iniparser_getkeyname(dictionary * d, int nsec, int nkey, char ** string) 192 222 { … … 212 242 nkey--; 213 243 } 214 244 215 245 *string = d->val[i]; 216 246 return d->key[i] + keylen; … … 505 535 char * key, 506 536 char * value) 507 { 537 { 508 538 line_status sta ; 509 539 char line[ASCIILINESZ+1]; … … 519 549 } else if (line[0]=='#' || line[0]==';') { 520 550 /* Comment line */ 521 sta = LINE_COMMENT ; 551 sta = LINE_COMMENT ; 522 552 } else if (line[0]=='[' && line[len-1]==']') { 523 553 /* Section name */
Note: See TracChangeset
for help on using the changeset viewer.