示例#1
0
APIRET xprfCloseProfile(PXINI pXIni)       // in: profile opened with xprfOpenProfile
{
    APIRET  arc = NO_ERROR;

    if (    (!pXIni)
         || (memcmp(pXIni->acMagic, XINI_MAGIC_BYTES, sizeof(XINI_MAGIC_BYTES)))
       )
        arc = ERROR_INVALID_PARAMETER;
    else
    {
        if (pXIni->fDirty)
            arc = WriteINI(pXIni);

        if (!arc)
        {
            if (!(arc = DosClose(pXIni->hFile)))
            {
                pXIni->hFile = 0;

                FreeINI(pXIni);
            }
        }
    }

    return arc;
}
示例#2
0
文件: set.c 项目: justid/Zoolu
int SaveProj(void)
{
	
	int confile_ptr = -1 ;
	char temp_buffer[MAXLINE] ;

	confile_ptr = Bfile_OpenFile(configfile, _OPENMODE_READWRITE) ;
	if (confile_ptr < 0) return -1 ;

	sprintf(temp_buffer,"StakeD = %9.3f",allset.stake_d) ;
	confile_ptr = WriteINI(confile_ptr, allset.fpos.sk, temp_buffer,LATER,TRUE) ;
	sprintf(temp_buffer,"WitchMAX = %9.3f",allset.width_max) ;
	confile_ptr = WriteINI(confile_ptr, allset.fpos.wd, temp_buffer,LATER,FALSE) ;
	sprintf(temp_buffer,"XLTYPE = %9.3f",floor(allset.xl_type)) ;
	confile_ptr = WriteINI(confile_ptr, allset.fpos.xl, temp_buffer,LATER,FALSE) ;
	sprintf(temp_buffer,"PJMODE = %9.3f",floor(allset.pj_mode)) ;
	confile_ptr = WriteINI(confile_ptr, allset.fpos.pj, temp_buffer,NOW,FALSE) ;


	Bfile_CloseFile(confile_ptr) ;
	return 0;
}
示例#3
0
bool FDBFile::WriteToFile(const char* filename, FDBPackage::e_export_format e)
{
    if (e==FDBPackage::EX_NONE) e = DefaultFormat();

    assert(ExportFormatIsValid(e));

    bool res=false;
    switch (e)
    {
        case FDBPackage::EX_RAW:
            res = WriteRAW(filename);
            break;

        case FDBPackage::EX_INI:
            res = WriteINI(filename);
            break;

        case FDBPackage::EX_LUA:
            res = WriteLUA(filename);
            break;

        case FDBPackage::EX_CSV:
            res = WriteCSV( GetTargetName( filename, e).c_str());
            break;

        case FDBPackage::EX_SQLITE:
            res = WriteSQLITE(GetTargetName( filename, e).c_str());
            break;

        case FDBPackage::EX_MYSQL:
            res = WriteMySQL(GetTargetName( filename, e).c_str());
            break;
    }

    return res;
}
示例#4
0
文件: set.c 项目: justid/Zoolu
int upgradeINI(double version, int file_ptr, int pos)
{
void* rebuff_ptr = NULL;
void* buff_prev = NULL;
void* buff_next = NULL;

int size ;
int bytesfree ;
char* Addto ;
BYTE insert_flag = FALSE ;
char Addto113[] = "Current_PLD = \\;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n" ;
char Addto117[] = "Current_YS = EMP ;\r\nYS1 =  XYF ;\r\nYS2 = BBBB ;\r\nYS3 = CCCC ;\r\nYS4 = DDDD ;\r\nYS5 = EEEE ;\r\nYS6 = FFFF ;\r\nYS7 = GGGG ;\r\nYS8 = HHHH ;\r\n\r\n" ;
char Addto1171[] = "XLTYPE =     1.000 ;\r\nPJMODE =     1.000 ;\r\n" ;
char Addto1172[] = "Current_HP =  EMP ;" ;
char Addto119[] = "\r\n\r\nCurrent_SD = EMP ;\r\nSD1 = AAAA ;\r\nSD2 = BBBB ;\r\nSD3 = CCCC ;\r\nSD4 = DDDD ;\r\nSD5 = EEEE ;\r\nSD6 = FFFF ;\r\nSD7 = GGGG ;\r\nSD8 = HHHH ;" ;

Warning("升级中..",2) ;
file_ptr = Reopen(file_ptr) ;

if (version == 1.11){
	Addto = Addto113 ;
	WriteINI(file_ptr, pos, "Version =     1.130 ;",NOW,TRUE) ;
} else if (version == 1.13){
	Addto = Addto117 ;
	WriteINI(file_ptr, pos, "Version =     1.170 ;",NOW,TRUE) ;	
} else if (version == 1.17){
	Addto = Addto1171 ;
	WriteINI(file_ptr, pos, "Version =     1.171 ;",NOW,TRUE) ;
	insert_flag = TRUE ;	
} else if (version == 1.171){
	Addto = Addto1172 ;
	WriteINI(file_ptr, pos, "Version =     1.172 ;",NOW,TRUE) ;
} else if (version == 1.172){
	Addto = Addto119 ;
	WriteINI(file_ptr, pos, "Version =     1.190 ;",NOW,TRUE) ;
} else {
	Warning("错误的版本号!",2) ;
	return FALSE ;
}

//增加ini文件大小
size = Bfile_GetFileSize(file_ptr) ;
rebuff_ptr = calloc( size+ strlen(Addto),sizeof(char)) ;
if (insert_flag == TRUE){
		buff_prev = calloc( allset.fpos.sk,sizeof(char)) ;	
		buff_next = calloc( size-allset.fpos.sk,sizeof(char)) ;
		if (buff_prev == NULL || buff_next == NULL){
			if (rebuff_ptr != NULL) free(rebuff_ptr) ;
			DebugS("申请内存失败!") ;
			return FALSE ;
		}
}
else if (rebuff_ptr == NULL){
	DebugS("申请内存失败!") ;
	return FALSE ;
}
if (insert_flag == TRUE){
	Bfile_ReadFile(file_ptr,buff_prev,allset.fpos.sk ,-1) ;	//读取前半部分
	Bfile_ReadFile(file_ptr,buff_next,size-allset.fpos.sk ,-1) ;	//读取后半部分	
}
else Bfile_ReadFile(file_ptr,rebuff_ptr,size ,-1) ;

Bfile_CloseFile(file_ptr) ;
Bfile_DeleteFile(configfile) ;


if (Bfile_CreateFile(configfile, size+strlen(Addto)) < 0) {
	if (rebuff_ptr != NULL)	free(rebuff_ptr) ;
	if (buff_prev != NULL)	free(buff_prev) ;
	if (buff_next != NULL)	free(buff_next) ;
	DebugS("创建文件失败\n请重新上传 ") ;
	return FALSE ;
}
file_ptr = Reopen(file_ptr) ;
if (insert_flag == TRUE) {
	strncat(rebuff_ptr,buff_prev,strlen(buff_prev)) ;		//拼接
	strncat(rebuff_ptr,Addto,strlen(Addto)) ;	
	strncat(rebuff_ptr,buff_next,strlen(buff_next)) ;		
}
else strncat(rebuff_ptr,Addto,strlen(Addto)) ;
Bfile_WriteFile(file_ptr,rebuff_ptr,size+strlen(Addto)) ;
		
if (rebuff_ptr != NULL)	free(rebuff_ptr) ;
if (buff_prev != NULL)	free(buff_prev) ;
if (buff_next != NULL)	free(buff_next) ;

Bfile_CloseFile(file_ptr) ;

return TRUE ;	
}
示例#5
0
文件: set.c 项目: justid/Zoolu
int InitConfig()
{
# ifdef RELEASE
FONTCHARACTER indexfile[] = { '\\','\\','f','l','s','0','\\','I','N','D','E','X','.','d','a','t' ,'\0'} ;
# else
FONTCHARACTER indexfile[] = { '\\','\\','c','r','d','0','\\','I','N','D','E','X','.','d','a','t' ,'\0'} ;
# endif
	int indexf_ptr = -1 ;
	int confile_ptr = -1 ;
	unsigned int prog = 0 ;
	int error_code = 0 ;
	double ini_version ;
	unsigned int ini_fpos ;
	
	
	//Get_MID() ;CheckReg("ABCDEF");
	confile_ptr = Bfile_OpenFile(configfile, _OPENMODE_READWRITE) ;
	if (confile_ptr < 0) {
		Warning("无配置文件 ", 3) ;
		return -1 ;
	} else {
		// DO NOTHING NOW
	}

	

	fpos = 0 ;
	stateT = 0 ;
	stateK = 0 ;
	stateV = 0 ;
	
	
	while (error_code == 0  && getline(confile_ptr) ) {
		prog = parse((char*)Linebuffer) ;
		switch (prog){
		case PROG_VER:
			ini_version = statebox.value ;
			ini_fpos = fpos ;
			break ;
		case PROG_SN:
			Get_MID() ;
			strcpy(regstr,statebox.str) ;
			if (CheckReg(regstr) == TRUE)  {
				if (strcmp(regstr,statebox.str) != 0 ){
					//定位到数值位置并写入 
					sprintf(Linebuffer,"SN = %s\r\n",regstr) ;
					confile_ptr = WriteINI(confile_ptr,fpos,Linebuffer,NOW,TRUE) ;	
					if (confile_ptr < 0 )  error_code = -1 ;
				}
			}
			break ;
		case PROG_X1:
			total_set.stat_point.x = statebox.value ;
			total_set.fpos.x1 = fpos ;
			break ;
		case PROG_Y1:
			total_set.stat_point.y = statebox.value ; 
			total_set.fpos.y1 = fpos ;
			break ;
		case PROG_H1:
			total_set.stat_point.z = statebox.value ; 
			total_set.fpos.h1 = fpos ;
			break ;
		case PROG_X2:
			total_set.bak_point.x = statebox.value ; 
			total_set.fpos.x2 = fpos ;
			break ;
		case PROG_Y2:
			total_set.bak_point.y = statebox.value ; 
			total_set.fpos.y2 = fpos ;
			break ;
		case PROG_H2:
			total_set.bak_point.z = statebox.value ; 
			total_set.fpos.h2 = fpos ;
			break ;
		case PROG_STH:
			total_set.station_ht = statebox.value ; 
		        total_set.fpos.sth = fpos ;
			break ;
		case PROG_PRH:
			total_set.prism_ht = statebox.value ; 
			total_set.fpos.prh = fpos ;
			break ;
		case PROG_STAKED:
			allset.stake_d = statebox.value ; 
			allset.fpos.sk = fpos ;
			break ;
		case PROG_WDMAX:
			allset.width_max = statebox.value ; 
			allset.fpos.wd = fpos ;
			break ;
		case PROG_XLTYPE:
			allset.xl_type = statebox.value ; 
			allset.fpos.xl = fpos ;
			break; 
		case PROG_PJMODE:
			allset.pj_mode = statebox.value ; 
			allset.fpos.pj = fpos ;
			break ;
		case PROG_CUPQ:	//平曲
			if (strcmp(statebox.str,"PQ1") == 0)  dbset.current_pq = dbset.pq1 ;
			else if (strcmp(statebox.str,"PQ2") == 0) dbset.current_pq = dbset.pq2 ;
			else if (strcmp(statebox.str,"PQ3") == 0) dbset.current_pq = dbset.pq3 ;
			else if (strcmp(statebox.str,"PQ4") == 0) dbset.current_pq = dbset.pq4 ;
			else if (strcmp(statebox.str,"PQ5") == 0) dbset.current_pq = dbset.pq5 ;
			else if (strcmp(statebox.str,"EMP") == 0) dbset.current_pq = NULL ;
			else error_code = -1 ;
			
			dbset.fpos.cupq = fpos ;
			break ;
		case PROG_PQ1:
			strcpy(dbset.pq1,statebox.str) ;
			dbset.fpos.pq1 = fpos ;
			break ;
		case PROG_PQ2:
			strcpy(dbset.pq2,statebox.str) ;
			dbset.fpos.pq2 = fpos ;
			break ;
		case PROG_PQ3:
			strcpy(dbset.pq3,statebox.str) ;
			dbset.fpos.pq3 = fpos ;
			break ;
		case PROG_PQ4:
			strcpy(dbset.pq4,statebox.str) ;
			dbset.fpos.pq4 = fpos ;
			break ;
		case PROG_PQ5:
			strcpy(dbset.pq5,statebox.str) ;
			dbset.fpos.pq5 = fpos ;
			break ;
		case PROG_CUSQ:	//竖曲
			if (strcmp(statebox.str,"SQ1") == 0)  dbset.current_sq = dbset.sq1 ;
			else if (strcmp(statebox.str,"SQ2") == 0) dbset.current_sq = dbset.sq2 ;
			else if (strcmp(statebox.str,"SQ3") == 0) dbset.current_sq = dbset.sq3 ;
			else if (strcmp(statebox.str,"SQ4") == 0) dbset.current_sq = dbset.sq4 ;
			else if (strcmp(statebox.str,"SQ5") == 0) dbset.current_sq = dbset.sq5 ;
			else if (strcmp(statebox.str,"EMP") == 0) dbset.current_sq = NULL ;
			else error_code = -1 ;
			
			dbset.s_fpos.cusq = fpos ;
			break ;
		case PROG_SQ1:
			strcpy(dbset.sq1,statebox.str) ;
			dbset.s_fpos.sq1 = fpos ;
			break ;
		case PROG_SQ2:
			strcpy(dbset.sq2,statebox.str) ;
			dbset.s_fpos.sq2 = fpos ;
			break ;
		case PROG_SQ3:
			strcpy(dbset.sq3,statebox.str) ;
			dbset.s_fpos.sq3 = fpos ;
			break ;
		case PROG_SQ4:
			strcpy(dbset.sq4,statebox.str) ;
			dbset.s_fpos.sq4 = fpos ;
			break ;
		case PROG_SQ5:
			strcpy(dbset.sq5,statebox.str) ;
			dbset.s_fpos.sq5 = fpos ;
			break ;
		case PROG_CUPLD:
			if (strncmp(statebox.str,"\\\\",2) == 0) {
				CharToFont(statebox.str,pld_FileName) ;
				pld_flag = TRUE ;
				//从索引文件中获取数据行数 
				indexf_ptr = Bfile_OpenFile(indexfile, _OPENMODE_READ_SHARE) ;
				ptlist_count = Bfile_GetFileSize(indexf_ptr) /  sizeof(DWORD) ;
				Bfile_CloseFile(indexf_ptr) ;
				
				//从路径中提取文件名 
				GetNamefromStr(name,statebox.str) ;
				
				//DebugS("%s",statebox.str) ;
			} else pld_flag = FALSE ;
			dbset.pld_pos = fpos ;
			break ;			
		case PROG_CUYS:	//线元法
			if (strcmp(statebox.str,"YS1") == 0)  dbset.current_ys = dbset.ys1 ;
			else if (strcmp(statebox.str,"YS2") == 0)  dbset.current_ys = dbset.ys2 ;
			else if (strcmp(statebox.str,"YS3") == 0)  dbset.current_ys = dbset.ys3 ;
			else if (strcmp(statebox.str,"YS4") == 0)  dbset.current_ys = dbset.ys4 ;
			else if (strcmp(statebox.str,"YS5") == 0)  dbset.current_ys = dbset.ys5 ;
			else if (strcmp(statebox.str,"YS6") == 0)  dbset.current_ys = dbset.ys6 ;
			else if (strcmp(statebox.str,"YS7") == 0)  dbset.current_ys = dbset.ys7 ;
			else if (strcmp(statebox.str,"YS8") == 0)  dbset.current_ys = dbset.ys8 ;
			else if (strcmp(statebox.str,"EMP") == 0) dbset.current_ys = NULL ;
			else error_code = -1 ;
			
			dbset.ys_fpos.cuys = fpos ;
			break ;
		case PROG_YS1:
			strcpy(dbset.ys1,statebox.str) ;
			dbset.ys_fpos.ys1 = fpos ;
			break ;
		case PROG_YS2:
			strcpy(dbset.ys2,statebox.str) ;
			dbset.ys_fpos.ys2 = fpos ;
			break ;
		case PROG_YS3:
			strcpy(dbset.ys3,statebox.str) ;
			dbset.ys_fpos.ys3 = fpos ;
			break ;
		case PROG_YS4:
			strcpy(dbset.ys4,statebox.str) ;
			dbset.ys_fpos.ys4 = fpos ;
			break ;
		case PROG_YS5:
			strcpy(dbset.ys5,statebox.str) ;
			dbset.ys_fpos.ys5 = fpos ;
			break ;
		case PROG_YS6:
			strcpy(dbset.ys6,statebox.str) ;
			dbset.ys_fpos.ys6 = fpos ;
			break ;
		case PROG_YS7:
			strcpy(dbset.ys7,statebox.str) ;
			dbset.ys_fpos.ys7 = fpos ;
			break ;
		case PROG_YS8:
			strcpy(dbset.ys8,statebox.str) ;
			dbset.ys_fpos.ys8 = fpos ;
			break ;
		case PROG_CUHP:
			if (strcmp(statebox.str,"EMP") == 0)  ;
			else strcpy(dbset.current_hp,statebox.str) ;
			dbset.hp_pos = fpos ;
			break ;
		case PROG_CUSD:
			if (strcmp(statebox.str,"SD1") == 0)  dbset.current_sd = dbset.sd1 ;
			else if (strcmp(statebox.str,"SD2") == 0)  dbset.current_sd = dbset.sd2 ;
			else if (strcmp(statebox.str,"SD3") == 0)  dbset.current_sd = dbset.sd3 ;
			else if (strcmp(statebox.str,"SD4") == 0)  dbset.current_sd = dbset.sd4 ;
			else if (strcmp(statebox.str,"SD5") == 0)  dbset.current_sd = dbset.sd5 ;
			else if (strcmp(statebox.str,"SD6") == 0)  dbset.current_sd = dbset.sd6 ;
			else if (strcmp(statebox.str,"SD7") == 0)  dbset.current_sd = dbset.sd7 ;
			else if (strcmp(statebox.str,"SD8") == 0)  dbset.current_sd = dbset.sd8 ;
			else if (strcmp(statebox.str,"EMP") == 0) dbset.current_sd = NULL ;
			else error_code = -1 ;
			dbset.sd_fpos.cusd = fpos ;
			break ;
		case PROG_SD1:
			strcpy(dbset.sd1,statebox.str) ;
			dbset.sd_fpos.sd1 = fpos ;
			break ;
		case PROG_SD2:
			strcpy(dbset.sd2,statebox.str) ;
			dbset.sd_fpos.sd2 = fpos ;
			break ;
		case PROG_SD3:
			strcpy(dbset.sd3,statebox.str) ;
			dbset.sd_fpos.sd3 = fpos ;
			break ;
		case PROG_SD4:
			strcpy(dbset.sd4,statebox.str) ;
			dbset.sd_fpos.sd4 = fpos ;
			break ;
		case PROG_SD5:
			strcpy(dbset.sd5,statebox.str) ;
			dbset.sd_fpos.sd5 = fpos ;
			break ;
		case PROG_SD6:
			strcpy(dbset.sd6,statebox.str) ;
			dbset.sd_fpos.sd6 = fpos ;
			break ;
		case PROG_SD7:
			strcpy(dbset.sd7,statebox.str) ;
			dbset.sd_fpos.sd7 = fpos ;
			break ;
		case PROG_SD8:
			strcpy(dbset.sd8,statebox.str) ;
			dbset.sd_fpos.sd8 = fpos ;
			break ;
		case PROG_ERR:
			break ;
		default:
			break ;
		}		
		fpos += strlen(Linebuffer);
	}
	if (ini_version == 1.11) {
		Warning("当前ver1.11",2) ;
		DebugS("按EXE确认升级\nini配置文件 ") ;
		if ( upgradeINI(1.11,confile_ptr,ini_fpos) == TRUE ) Warning("升级成功!",2) ;
		else Warning("升级失败!",2) ;
		error_code = -1 ;		//不管升级成功还是失败 均返回程序开始
	}
	else if (ini_version == 1.13) {
		Warning("当前ver1.13",2) ;
		DebugS("按EXE确认升级\nini配置文件 ") ;
		if ( upgradeINI(1.13,confile_ptr,ini_fpos) == TRUE ) Warning("升级成功!",2) ;
		else Warning("升级失败!",2) ;
		error_code = -1 ;		//不管升级成功还是失败 均返回程序开始
	}
	else if (ini_version == 1.17){
		Warning("当前ver1.17",2) ;
		DebugS("按EXE确认升级\nini配置文件 ") ;
		if ( upgradeINI(1.17,confile_ptr,ini_fpos) == TRUE ) Warning("升级成功!",2) ;
		else Warning("升级失败!",2) ;
		error_code = -1 ;		//不管升级成功还是失败 均返回程序开始
	}
	else if (ini_version == 1.171) {
		Warning("当前ver1.171",2) ; 
		DebugS("按EXE确认升级\nini配置文件 ") ;
		if ( upgradeINI(1.171,confile_ptr,ini_fpos) == TRUE ) Warning("升级成功!",2) ;
		else Warning("升级失败!",2) ;
		error_code = -1 ;		//不管升级成功还是失败 均返回程序开始
	}
	else if (ini_version == 1.172) {
		Warning("当前ver1.172",2) ; 
		DebugS("按EXE确认升级\nini配置文件 ") ;
		if ( upgradeINI(1.172,confile_ptr,ini_fpos) == TRUE ) Warning("升级成功!",2) ;
		else Warning("升级失败!",2) ;
		error_code = -1 ;		//不管升级成功还是失败 均返回程序开始
	}
	else if (ini_version == 1.19) ;//Warning("当前ver1.19",2) ; 
	else Warning("ini版本错误 ",2) ;
	
	Bfile_CloseFile(confile_ptr) ;
	
	return  error_code;
}
示例#6
0
void Setting::WriteSetting(){
	WriteINI(_T("abtlinst"),_T("setpath"),m_setpath ? _T("1") : _T("0"));
	WriteINI(_T("abtlinst"),_T("InstallDir"),m_installdir);
}