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

📄 2003-01-02_settings.cpp

📁 JK Proxy Project - Version 0.1 ------------------------------ This was going to be a proxy serve
💻 CPP
字号:
/*
+-----------------------------------------------------------------------------+
|                                                                             |
|   settings.cpp                                                              |
|   Last change: yyyy-mm-dd                                                   |
|                                                                             |
|   Author: Jan Krumsiek                                                      |
|   eMail:  proxy@krumsiek.com                                                |
|   Web:    http://www.krumsiek.com/proxy                                     |
|                                                                             |
|   Copyright 2003 - Jan Krumsiek                                             |
|   This source code can freely be modified and redistributed. No liability   |
|   whatsoever is taken by the author for any use of this software.           |
|                                                                             |
|   Description:                                                              |
|   This module is resonsible for loading all settings from the config files  |
|                                                                             |
+-----------------------------------------------------------------------------+
*/

#include "proxymain.h"
#include "rulefile.h"
#include "cfgfiles.h"
#include "settings.h"

MAINSETTINGS mainset;

MAINSETTYPE MStrToCommand(CHARPTR command);

int LoadSettings()
// This is the main procedure that loads and stores main settings
{
	// notification msg
	printf("Loading settings... \0");
	
	// Open main config file and walk through all commands
	COMMAND cur;
	char mainfile[] = "c:\\mainconf.txt\0";
	OpenConfigFile(mainfile);

	cur = GetNextFullCommand();
	while (cur.command != 0)
	{

		switch (MStrToCommand(cur.command))
		{

		case MS_EMAILRULES:
			// At this point, just save string because only on file can be open at a time
			mainset.emailsettings.rulefile = cur.paras[0];
			break;

		case MS_EMAILPORT:
			// email listen port, simply save it in settings struct
			mainset.emailsettings.port =  atoi(cur.paras[0]);
			break;

		case MS_EMAILTRASH:
			// email trash dir, blocked msgs are stored here
			mainset.emailsettings.trashdir = 
				(CHARPTR)CopyAndPtr(cur.paras[0],strlen(cur.paras[0]));
			break;

		default:
			cout << "Error in " << mainfile << "(" << cur.line << ")"
				 << ": Unknown command '" << cur.command << "'";
		}
		cur = GetNextFullCommand();
	}

	ReleaseConfigFile();

	// Email rules, now load rules and save in settings struct
	mainset.emailsettings.rules = LoadRules(mainset.emailsettings.rulefile);
	if (mainset.emailsettings.rules == 0) // An error occured
	{
		ErrorAbort();
		return false;
	}

	// [DBG] !!
	mainset.emailsettings.archivedir = 
		(CHARPTR)CopyAndPtr("D:/MyProjects/Proxy/archive/\0",29);

	// notification msg
	printf("Done\n\0");

	return true;

}

MAINSETTYPE MStrToCommand(CHARPTR command)
// converts a string-command from the main config file
// to its ID (type MAINSETTYPE)
{
	// email rules file
	if (stricmp(command,"emailrules") == 0)
		return MS_EMAILRULES;

	// email listen port
	if (stricmp(command,"emailport") == 0)
		return MS_EMAILPORT;

	// email trash
	if (stricmp(command,"emailtrash") == 0)
		return MS_EMAILTRASH;
	
	return MS_UNKNOWN;
}

⌨️ 快捷键说明

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