📄 config.c
字号:
/****************************************************************************** * * Copyright (c) 2003 Gerhard W. Gruber * * PROJECT: pICE * $Source: /cvsroot/pice/pice/module/config.c,v $ * $Revision: 1.1 $ * $Date: 2004/02/17 23:12:26 $ * $Author: lightweave $ * $Name: $ * * $Log: config.c,v $ * Revision 1.1 2004/02/17 23:12:26 lightweave * New configuration handler for reading config files. See CHANGES.txt for * details. * * *****************************************************************************//* * This file contains all code which is related to configuration. Specifically * it loads the config file from /etc/pice.conf and, in later versions might * also write it back. * The configuration is loaded once into memory and appropriate data structures * are created. After that the configuration is freed. * * Configuration in /etc/pice.conf will contain the general config for keybindings * and video mode in use. The format of the config file is similar to INI files * in Windows. Refer to profile.c for more details. * */static char *ident = "$Header: /cvsroot/pice/pice/module/config.c,v 1.1 2004/02/17 23:12:26 lightweave Exp $";/*++Copyright (c) 2003 Gerhard W. GruberModule ModuleName: config.cAbstract:Environment: Kernel mode onlyAuthor: Gerhard W. GruberCopyright notice: This file may be distributed under the terms of the GNU Public License.--*/////////////////////////////////////////////////////// INCLUDES////#include "remods.h"#include <linux/fs.h> /* struct file, filp_open, etc. */#include "precomp.h"#include "profile.h"#include "parse.h"#define CONFIG#include "config.h"typedef struct { ETERMINALMODE eTerminalMode; char *ConsoleDriver;}SConsoleMapping;static SConsoleMapping ConsoleMapping[] = { { TERMINAL_MODE_VGA_TEXT, "vga" }, { TERMINAL_MODE_HERCULES_GRAPHICS, "hercules" }, { TERMINAL_MODE_SERIAL, "serial" }, { TERMINAL_MODE_NONE, NULL }};//************************************************************************* // LoadConfig() //// Load configuration file and construct appropriate objects.////************************************************************************* BOOLEAN LoadConfig(VOID){ BOOLEAN rc = FALSE; PROFILE_HANDLE *h; PROFILE_SECTION *s; PROFILE_MAP *m; int i; ENTER_FUNC(); if((h = OpenProfile("/etc/pice.conf", TRUE, FALSE)) == NULL) { DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "OpenProfile() failed\n"); goto Quit; } if(FindSection(h, "Display", &s) == -1) { DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "Unable to find Display section in INI file!\n"); goto Quit; } if(FindMap(s, "VideoDriver", TRUE, &m) == -1) { DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "Unable to find VideoDriver entry in INI file!\n"); goto Quit; } i = 0; while(ConsoleMapping[i].ConsoleDriver != NULL) { DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "Entry for Consoledriver [%s:%s] %d\n", m->Value, ConsoleMapping[i].ConsoleDriver, stricmp(m->Value, ConsoleMapping[i].ConsoleDriver)); if(stricmp(m->Value, ConsoleMapping[i].ConsoleDriver) == 0) { eTerminalMode = ConsoleMapping[i].eTerminalMode; break; } i++; } if(eTerminalMode == TERMINAL_MODE_NONE) DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "Invalid entry for VideoDriver [%s]\n", m->Value); // The next values are optional rc = TRUE; if(FindSection(h, "Init", &s) == -1) { DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "Unable to find Init section in INI file!\n"); goto Quit; } if(FindMap(s, "SystemMap", TRUE, &m) == -1) { DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "Unable to find SystemMap entry in INI file!\n"); goto Quit; } if((pCurrentSymbols = LoadSymbols(m->Value)) == NULL) { DPRINT(PICE_DEBUG, DBT_CONFIG, DBL_INFO, "Unable to load Symbol!\n"); goto Quit; } strcpy(szCurrentFile, m->Value); rc = TRUE;Quit: if(h) CloseProfile(h); LEAVE_FUNC(); return(rc);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -