Show
Ignore:
Timestamp:
04/10/04 22:39:57 (9 years ago)
Author:
alexcv
Message:

Embryonic user classes support

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/src/conf.c

    r39 r43  
    6060        oFWScriptsPath, 
    6161        oFWType, 
     62        oUserClass, 
    6263} OpCodes; 
    6364 
     
    8384        { "fwscriptspath",      oFWScriptsPath }, 
    8485        { "fwtype",             oFWType }, 
     86        { "userclass",          oUserClass }, 
    8587        { NULL,                 oBadOption }, 
    8688}; 
     
    108110        config.fwscripts_path = DEFAULT_FWSCRIPTS_PATH; 
    109111        config.fwtype = DEFAULT_FWTYPE; 
     112        config.userclasses = (char **)malloc(sizeof(char *) * 256); 
     113        memset(config.userclasses, 0, sizeof(char *) * 256); 
    110114} 
    111115 
     
    173177 
    174178                                switch(opcode) { 
     179                                case oUserClass: 
     180                                        add_userclass((int)strtol(p1, NULL, 10), 
     181                                                        ++p2); 
     182                                        break; 
    175183                                case oDaemon: 
    176184                                        if (((value = parse_value(p1)) != -1)) { 
     
    243251} 
    244252 
    245         char * 
     253char * 
    246254get_string(char *ptr) 
    247255{ 
    248256        char *buf; 
    249257 
    250         buf = (char *)malloc(MAX_BUF); 
    251  
    252         strncpy(buf, ptr, MAX_BUF); 
     258        buf = strdup(ptr); 
    253259        return buf; 
     260} 
     261 
     262char * 
     263add_userclass(int profile, char *ptr) 
     264{ 
     265        char *tmp_str; 
     266 
     267        if (profile > 255 || profile < 0) 
     268                return NULL; 
     269 
     270        if (*(config.userclasses + profile) != NULL) 
     271                free(*(config.userclasses + profile)); 
     272 
     273        tmp_str = strdup(ptr); 
     274 
     275        *(config.userclasses + profile) = tmp_str; 
     276 
     277        return tmp_str; 
    254278} 
    255279