config.cpp
上传用户:looem2003
上传日期:2014-07-20
资源大小:13733k
文件大小:5k
- #include "config.h"
- LPCTSTR cfgName = _T("OPTIONS");
- BOOL WINAPI load_config( LPAPPCONFIG ac, LPVOID param )
- {
- BOOL ret = FALSE;
- LPADDITIONALCONFIG aac = NULL;
- TCHAR tmp[MAX_PATH] = _T("");
- if( (NULL != ac) && (NULL != (aac = (LPADDITIONALCONFIG)(ac->addParam = param))) )
- {
- ZeroMemory( aac, sizeof(*aac) );
- aac->showAdvanced = ( 0 != GetPrivateProfileInt( cfgName, _T("SHOW_ADVANCED"), 0, ac->iniFile ));
- aac->savePass = ( 0 != GetPrivateProfileInt( cfgName, _T("SAVE_PASS"), 0, ac->iniFile ));
- aac->closeWnd = ( 0 != GetPrivateProfileInt( cfgName, _T("CLOSE_WND"), 0, ac->iniFile ));
- aac->transmReport = ( 0 != GetPrivateProfileInt( cfgName, _T("TRANSITION_REPORT"), 1, ac->iniFile ));
- aac->transmReportAttach = ( 0 != GetPrivateProfileInt( cfgName, _T("TRANSITION_REPORT_ATTACH"), 1, ac->iniFile ));
- //aac->showPass = ( 0 != GetPrivateProfileInt( cfgName, _T("SHOW_PASS"), 0, ac->iniFile ));
- aac->showPass = FALSE;
- aac->threshold = ( 0 != GetPrivateProfileInt( cfgName, _T("THRESHOLD"), 1, ac->iniFile ));
- aac->dithering = !aac->threshold;
- aac->timeOut = GetPrivateProfileInt( cfgName, _T("TIMEOUT"), 1000, ac->iniFile );
- if( aac->timeOut < 1000 )
- aac->timeOut = 1000;
- GetPrivateProfileString( cfgName, _T("USER_NAME"), NULL, aac->userName, ARRAYSIZE(aac->userName), ac->iniFile );
- GetPrivateProfileString( cfgName, _T("USER_PASS"), NULL, aac->userPass, ARRAYSIZE(aac->userPass), ac->iniFile );
- GetPrivateProfileString( cfgName, _T("SERV_NAME"), _T("www.popfax.com"), aac->servName, ARRAYSIZE(aac->servName), ac->iniFile );
- GetPrivateProfileString( cfgName, _T("OBJ_NAME"), _T("api/api-server.php"), aac->objName, ARRAYSIZE(aac->objName), ac->iniFile );
- GetPrivateProfileString( cfgName, _T("LOGO"), _T("en_logo.gif"), aac->logo, ARRAYSIZE(aac->logo), ac->iniFile );
- GetPrivateProfileString( cfgName, _T("SUBSCRIBE"), _T("http://www.popfax.com/"), aac->subscribe, ARRAYSIZE(aac->subscribe), ac->iniFile );
- GetPrivateProfileString( cfgName, _T("DELIMITER"), _T(","), aac->delim, ARRAYSIZE(aac->delim), ac->iniFile );
- if( 0 == _tcsicmp( _T("TAB"), aac->delim ) )
- {
- aac->delim[0] = _T(' ');
- aac->delim[1] = _T(' ');
- }
- SHGetFolderPath( NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, tmp );
- GetPrivateProfileString( cfgName, _T("LAST_DIR_ADD_MASS_FILE"), tmp, aac->dirAddFile, ARRAYSIZE(aac->dirAddFile), ac->iniFile );
- if( 0 == _tcslen( aac->dirAddFile ) )
- _tcscpy_s( aac->dirAddFile, ARRAYSIZE(aac->dirAddFile), tmp );
-
- if( NULL == _tcsrchr( aac->logo, _T(':') ) )
- {
- _tcscpy_s( aac->logo, ARRAYSIZE(aac->logo), ac->workPath );
- GetPrivateProfileString( cfgName, _T("LOGO"), _T("en_logo.gif"), aac->logo+_tcslen(aac->logo), ARRAYSIZE(aac->logo)-_tcslen(aac->logo), ac->iniFile );
- }
- }
- return ret;
- }
- BOOL WINAPI save_config( LPAPPCONFIG ac )
- {
- BOOL ret = FALSE;
- LPADDITIONALCONFIG aac = NULL;
- TCHAR num[30] = _T("");
- if( (NULL != ac) && (NULL != (aac = (LPADDITIONALCONFIG)ac->addParam)) )
- {
- WritePrivateProfileString( cfgName, _T("SHOW_ADVANCED"), aac->showAdvanced?_T("1"):_T("0"), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("SAVE_PASS"), aac->savePass?_T("1"):_T("0"), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("CLOSE_WND"), aac->closeWnd?_T("1"):_T("0"), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("TRANSITION_REPORT"), aac->transmReport?_T("1"):_T("0"), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("TRANSITION_REPORT_ATTACH"), aac->transmReportAttach?_T("1"):_T("0"), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("SHOW_PASS"), aac->showPass?_T("1"):_T("0"), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("DITHERING"), aac->dithering?_T("1"):_T("0"), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("THRESHOLD"), aac->threshold?_T("1"):_T("0"), ac->iniFile );
- _itot_s( aac->timeOut, num, ARRAYSIZE(num), 10);
- WritePrivateProfileString( cfgName, _T("TIMEOUT"), num, ac->iniFile );
- WritePrivateProfileString( cfgName, _T("USER_NAME"), aac->userName, ac->iniFile );
- WritePrivateProfileString( cfgName, _T("USER_PASS"), ( aac->savePass )?aac->userPass:_T(""), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("SERV_NAME"), aac->servName, ac->iniFile );
- WritePrivateProfileString( cfgName, _T("OBJ_NAME"), aac->objName, ac->iniFile );
- WritePrivateProfileString( cfgName, _T("SUBSCRIBE"), aac->subscribe, ac->iniFile );
- WritePrivateProfileString( cfgName, _T("LOGO"), aac->logo, ac->iniFile );
- WritePrivateProfileString( cfgName, _T("DELIMITER"), (( _T(' ') == aac->delim[0])?_T("TAB"):aac->delim), ac->iniFile );
- WritePrivateProfileString( cfgName, _T("LAST_DIR_ADD_MASS_FILE"), aac->dirAddFile, ac->iniFile );
- }
- return ret;
- }