Ignore:
Timestamp:
04/05/08 23:41:11 (17 years ago)
Author:
r2d
Message:

added commentary to added iniparser functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/mpcchap/iniparser.c

    r387 r393  
    8383    static char l[ASCIILINESZ+1];
    8484        char * last ;
    85        
     85
    8686    if (s==NULL) return NULL ;
    87    
     87
    8888        while (isspace((int)*s) && *s) s++;
    8989        memset(l, 0, ASCIILINESZ+1);
     
    170170}
    171171
    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/*--------------------------------------------------------------------------*/
     185int iniparser_getnkey(dictionary * d, int n)
    173186{
    174187        int i, i_sec, cnt = 0 ;
     
    179192                        continue ;
    180193                if (strchr(d->key[i], ':')==NULL) {
    181                         if (nsec == -1)
     194                        if (n == -1)
    182195                                break;
    183                         nsec -- ;
     196                        n -- ;
    184197                }
    185                 if (nsec == -1)
     198                if (n == -1)
    186199                        cnt ++;
    187200        }
     
    189202}
    190203
     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/*--------------------------------------------------------------------------*/
    191221char * iniparser_getkeyname(dictionary * d, int nsec, int nkey, char ** string)
    192222{
     
    212242                nkey--;
    213243        }
    214        
     244
    215245        *string = d->val[i];
    216246        return d->key[i] + keylen;
     
    505535    char * key,
    506536    char * value)
    507 {   
     537{
    508538    line_status sta ;
    509539    char        line[ASCIILINESZ+1];
     
    519549    } else if (line[0]=='#' || line[0]==';') {
    520550        /* Comment line */
    521         sta = LINE_COMMENT ; 
     551        sta = LINE_COMMENT ;
    522552    } else if (line[0]=='[' && line[len-1]==']') {
    523553        /* Section name */
Note: See TracChangeset for help on using the changeset viewer.