⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ospf_nvram.c

📁 vxworks下ospf协议栈
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif            }        if (router_management_parameters (string_from_ini_file,cptr_value_string) == FAIL)            {#if !defined (__RAM_FILE__)           fclose (filptr_ini_file);#endif            return (FAIL);            }        }#if !defined (__RAM_FILE__)   fclose (filptr_ini_file);    PARAMETER_NOT_USED (location_of_ini_file);#else    PARAMETER_NOT_USED (vptr_location_of_configuration_table);#endif    return (PASS);}#if !defined (__RAM_FILE__)/****************************************************************************/static enum TEST parse_section_ini_parameters (char *string_from_ini_file,ULONG location_of_ini_file,    void *vptr_location_of_configuration_table){    char *cptr_value_string;    ospf_nvram.sptr_current_configuration_table = vptr_location_of_configuration_table;    ospf_nvram.current_configuration_section_index = 0x0000;    if (ospf_nvram.sptr_current_configuration_table == NULL)        {        nvram_printf (("NVRAM: No configuration table defined %s\r\n",string_from_ini_file));        return (FAIL);        }#if !defined (__RAM_FILE__)    while (fgets (string_from_ini_file,256,(FILE *) location_of_ini_file) != NULL)#else    cptr_current_string = NULL;    while (get_string_from_memory_file_image (string_from_ini_file,sizeof (string_from_ini_file),location_of_ini_file) == PASS)#endif        {        if (*string_from_ini_file == '/' && *(string_from_ini_file + 1) == '/')            {            continue;            }        else if ((cptr_value_string = strchr (string_from_ini_file,'=')) == NULL)            {            continue;            }        cptr_value_string++;        /* skip equals */        while(*cptr_value_string && *cptr_value_string <= ' ')            {            cptr_value_string++; /* skip any white space after equals */            }        if (ospf_nvram.display_configuration_file == TRUE)            {#if !defined (__RAM_FILE__)            nvram_printf (("%s",string_from_ini_file));#else            nvram_printf (("%s\r\n",string_from_ini_file));#endif            }        if (*string_from_ini_file == '[' && *(string_from_ini_file + 1) == '[')            {            break;            }        if (router_management_parameters (string_from_ini_file,cptr_value_string) == FAIL)            {#if !defined (__RAM_FILE__)        fclose ((FILE *) location_of_ini_file);#endif            return (FAIL);            }        }    return (PASS);}#endif/****************************************************************************/#if defined (__RAM_FILE__)/****************************************************************************/static enum TEST get_string_from_memory_file_image (char *cptr_return_string,USHORT size_of_return_string,    ULONG location_of_ini_file){    char *cptr_next_string;    if (cptr_current_string == NULL)        {        cptr_current_string = (char *) location_of_ini_file;        }    if (cptr_current_string != NULL && *cptr_current_string == 0x00)        {        return (FAIL);        }    cptr_next_string = find_cr_newline (cptr_current_string);    if (*cptr_current_string == 0x00 && cptr_next_string != NULL)        {        cptr_current_string = find_cr_newline (cptr_next_string);        }    if (cptr_current_string == NULL)        {        return (FAIL);        }    else        {        strncpy (cptr_return_string,cptr_current_string,size_of_return_string);        cptr_current_string = cptr_next_string;        return (PASS);        }}/****************************************************************************/static char *find_cr_newline (char *cptr_string_from_config_file){    char *cptr_first_occurrence_of_byte;    cptr_first_occurrence_of_byte = NULL;    while (*cptr_string_from_config_file != 0x00)        {        if (*cptr_string_from_config_file == '\r' || *cptr_string_from_config_file == '\n')            {            if (cptr_first_occurrence_of_byte == NULL)                {                cptr_first_occurrence_of_byte = cptr_string_from_config_file;                }            while (*cptr_string_from_config_file != 0x00)                {                if (*cptr_string_from_config_file == '\r' || *cptr_string_from_config_file == '\n')                    {                    ++cptr_string_from_config_file;                    continue;                    }                break;                }            break;            }        ++cptr_string_from_config_file;        }    if (*cptr_string_from_config_file != 0x00)        {        if (cptr_first_occurrence_of_byte != NULL)            {            *cptr_first_occurrence_of_byte = 0x00;            }        }    return (cptr_string_from_config_file);}#endif/****************************************************************************/static enum TEST router_management_parameters (char *cptr_string_from_config_file,char *cptr_value_string){    USHORT number_of_configuration_functions;    BOOLEAN processed_parameter;    char configuration_parameter_string[256];    if (cptr_value_string != NULL)        *(cptr_value_string - 1) = (char) 0x00;    if (*cptr_string_from_config_file == '[' && *(cptr_string_from_config_file + 1) == '[')        {        ospf_nvram.current_configuration_section_index = get_section_name (cptr_string_from_config_file + 2);        if (ospf_nvram.current_configuration_section_index == ILLEGAL_SECTION_INDEX)            {            nvram_printf (("NVRAM: illegal configuration section defined\r\n"));            return (PASS); /* ignore unrecognized section and continue to parse file */            }        ospf_nvram.sptr_current_configuration_table = sptr_configuration_table[ospf_nvram.current_configuration_section_index];        if (ospf_nvram.sptr_current_configuration_table == NULL)            {            nvram_printf (("NVRAM: No configuration table defined %s\r\n",cptr_string_from_config_file));            return (FAIL);            }        else            {            return (PASS);            }    }    else if (ospf_nvram.current_configuration_section_index == ILLEGAL_SECTION_INDEX)        {        return (PASS); /* ignore unrecognized section and continue to parse file */        }    processed_parameter = FALSE;    for (number_of_configuration_functions = 0x0000;        (ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].cptr_parameter_string != NULL) ||        (ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].eptr_enable_string != NULL);        ++number_of_configuration_functions)        {        strcpy (configuration_parameter_string,            ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].cptr_parameter_string);        if (strcmp ((const char *)ospf_strlwr (configuration_parameter_string),            (const char *)ospf_strlwr(cptr_string_from_config_file)) == STRINGS_MATCH)            {            if (ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].eptr_enable_string != NULL)                {                *(BOOLEAN *)(                    (ULONG) ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].ulptr_parameter_2 +                    (ULONG) ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].parameter_1) = (BOOLEAN)                    nvram_is_parameter_enabled (cptr_value_string);                processed_parameter = TRUE;                }            else                {                (*ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].fptr_parameter_function)                (cptr_value_string,ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].parameter_1,                    ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].ulptr_parameter_2,                    ospf_nvram.sptr_current_configuration_table->function[number_of_configuration_functions].parameter_3);                processed_parameter = TRUE;                }            break;            }        }    if (processed_parameter == FALSE)        {        nvram_printf (("NVRAM: Unknown configuration parameter  %s in section %s\r\n",cptr_string_from_config_file,            section_name_array[ospf_nvram.current_configuration_section_index]));        return (FAIL);        }    return (PASS);}/****************************************************************************/static BYTE get_section_name (char *cptr_section_name){    BYTE section_name_index;    char section_name[256];    if (cptr_section_name == NULL)        {        return (ILLEGAL_SECTION_INDEX);        }    for (section_name_index = 0x00;        section_name_index < sizeof(section_name_array)/sizeof(section_name_array[0]); section_name_index++)        {        if (section_name_array[section_name_index] == NULL            || *section_name_array[section_name_index] == 0)            {            return (ILLEGAL_SECTION_INDEX);            }        strcpy (section_name, section_name_array[section_name_index]);        if (strstr ((const char *)ospf_strlwr (cptr_section_name), (const char *)ospf_strlwr (section_name)) != NULL)            {            return (section_name_index);            }        }    return (ILLEGAL_SECTION_INDEX);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -