Пример #1
0
bool cfg_FindPattern(char *pattern, char *buffer)
{
    bool found = false;

    fseek(cfgfile, section_offset, SEEK_SET);

    do fgets(buffer, _STR_BUFLEN, cfgfile);
    while(!feof(cfgfile) && !checkPattern("[", buffer) && !(found = checkPattern(pattern, buffer)));

    return found;
}
Пример #2
0
bool cfg_SeekSection(char *sectionName)
{

    char buffer[_STR_BUFLEN];
    char pattern[_STR_BUFLEN];
    bool found = false;

    sprintf(pattern, "[%s]", sectionName);

    rewind(cfgfile);

    do fgets(buffer, _STR_BUFLEN, cfgfile);
    while(!feof(cfgfile) && !(found = checkPattern(pattern, buffer)));

    if(found)
    {
        section_offset = ftell(cfgfile);
        return true;
    }

    message_WarningEx("config: Could not find section '%s'.\n", pattern);

    return false;

}
Пример #3
0
int checkRule( int rule ) 
{
  int fire = 0;
  char arg[MEMORY_ELEMENT_SIZE]={0};

  extern int fireRule( int, char * );

  fire = checkPattern(rule, arg);

  if (fire == 1) {

    fire = fireRule( rule, arg );

  }

  return fire;
}
Пример #4
0
bool cfg_NextSection(char *sectionName)
{
    char buffer[_STR_BUFLEN];
    char pattern[_STR_BUFLEN];
    int found = false;

    sprintf(pattern, "[");

    do fgets(buffer, _STR_BUFLEN, cfgfile);
    while(!feof(cfgfile) && !(found = checkPattern(pattern, buffer)));

    if(found)
    {
        char *start = buffer + 1;
        char *end = strrchr(start, ']') - 1;
        memcpy(sectionName, start, end - start + 1);
        sectionName[end - start + 1] = '\0';
        section_offset = ftell(cfgfile);
        return true;
    }

    return false;
}