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

📄 guest_code.cpp

📁 m68k手持机的通讯相关源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		{
			AfxMessageBox("读取表名称失败!");
			return FALSE;
		}
		strRead.TrimRight(" ");
		strRead.TrimLeft(" ");
		if(strRead.GetLength() == 0) continue; //空行跳过
		if(strRead.Left(2)	== "//") continue; //注释行跳过
		if(strRead.Find("表名称:")!=-1) strRead.Replace("表名称:","表名称:");
		if(strRead.Find("表名称:")!=-1) 
		{
			strRead.Replace("表名称:","");
			i = 0;
			while(1)
			{
					strRead.TrimRight(" ");
					strRead.TrimLeft(" ");
					if(sscanf(strRead,"%s",g_array_table_struct[i].str_table_name)!=1) 
					{
						if(i==0) 
						{
							AfxMessageBox("表名称名称格式有误!");
							return FALSE;
						}else break;
					}
					len = strlen(g_array_table_struct[i].str_table_name);
					for(m=0;m<len;m++) strRead.SetAt(m,' ');
					i++;
					if(i>=MAX_NUM_OF_TABLE) break;
			}
			g_num_tables = i;
			break;
		}
	}

	//读取数据传输计划设置信息
	file.SeekToBegin();
	i = 0;
	while(1) {
			if(file.ReadString(strRead)==FALSE)      //read txt file path
			{
				AfxMessageBox("读取数据库配置信息出错!");
				return FALSE;
			}
			strRead.TrimRight(" ");
			strRead.TrimLeft(" ");
			if(strRead.GetLength() == 0) continue; //空行跳过
			if(strRead.Left(2)	== "//") continue; //注释行跳过
			if(sscanf(strRead,"%2d %2d %2d %2d %s %s", &tmp1,
											 &tmp2,    //null
											 &tmp3,    //null
											 &tmp4,    //null
											 filepath1,
											 filepath2)!=6) break;
			if(tmp1&&tmp2&&!PathFileExists((char*)filepath2))
			{
				strRead.Format("下载文件:%s 没有找到!\r\n请检查配置文件!",filepath2);
				AfxMessageBox(strRead);
			}
	
			g_SelectTab[i] = tmp1;
			g_dirTab[i] = tmp2;
			g_UpLDDelTab[i] = tmp3;
			g_DnLDDelTab[i] = tmp4;
			strcpy(g_strUPLDFileName[i],(LPSTR)(LPCTSTR)filepath1);
			strcpy(g_strDNLDFileName[i],(LPSTR)(LPCTSTR)filepath2);
			i++;
			if(i>=g_num_tables) break;
	}

	//读取数据库在手持机上的空间的大小,64k为单位
	file.SeekToBegin();
	while(1) {
			if(file.ReadString(strRead)==FALSE)      //read txt file path
			{
				AfxMessageBox("读取数据库表空间大小出错!");
				return FALSE;
			}
			strRead.TrimRight(" ");
			strRead.TrimLeft(" ");
			if(strRead.GetLength() == 0) continue; //空行跳过
			if(strRead.Left(2)	== "//") continue; //注释行跳过
			if(strRead.Find("表空间的大小:")!=-1) 
			{
				strRead.Replace("表空间的大小:","表空间的大小:");
			}
			if(strRead.Find("表空间的大小:")!=-1) 
			{
				strRead.Replace("表空间的大小:","");
				i = 0;
				while(1)
				{
						strRead.TrimRight(" ");
						strRead.TrimLeft(" ");
						if(sscanf(strRead,"%d",&iTmp[i])!=1) 
						{
							if(i<g_num_tables) 
							{
								AfxMessageBox("数据库表空间大小设置有误!");
								return FALSE;
							}
						}
						sscanf(strRead,"%s",strTmp);
						len = strlen(strTmp);
						for(m=0;m<len;m++) strRead.SetAt(m,' ');
						i++;
						if(i>=g_num_tables) break;
				}
				for(i=0;i<g_num_tables;i++)
				{
					g_block_num[i] = iTmp[i];
				}
				break;
			}	
	}
	//读取每个数据表的记录大小
	file.SeekToBegin();
	while(1) 
	{
			if(file.ReadString(strRead)==FALSE)      //read txt file path
			{
				AfxMessageBox("读取数据库表记录的大小出错!");
				return FALSE;
			}
			strRead.TrimRight(" ");
			strRead.TrimLeft(" ");
			if(strRead.GetLength() == 0) continue; //空行跳过
			if(strRead.Left(2)	== "//") continue; //注释行跳过
			if(strRead.Find("表记录的大小:")!=-1) 
			{
				strRead.Replace("表记录的大小:","表记录的大小:");
			}
			if(strRead.Find("表记录的大小:")!=-1) 
			{
				strRead.Replace("表记录的大小:","");
				i = 0;
				while(1)
				{
						strRead.TrimRight(" ");
						strRead.TrimLeft(" ");
						if(sscanf(strRead,"%d",&iTmp[i])!=1) 
						{
							if(i<g_num_tables) 
							{
								AfxMessageBox("读取数据库表记录的大小出错!");
								return FALSE;
							}
						}
						sscanf(strRead,"%s",strTmp);
						len = strlen(strTmp);
						for(m=0;m<len;m++) strRead.SetAt(m,' ');
						i++;
						if(i>=g_num_tables) break;
				}
				for(i=0;i<g_num_tables;i++)  
				{
					g_rec_size[i] = iTmp[i];
				}
				break;
			}	
	}
	//读取间隔符
	file.SeekToBegin();
	while(1) 
	{
			if(file.ReadString(strRead)==FALSE) break;//read txt file path
			strRead.TrimRight(" ");
			strRead.TrimLeft(" ");
			if(strRead.GetLength() == 0) continue; //空行跳过
			if(strRead.Left(2)	== "//") continue; //注释行跳过
			if(strRead.Find("字段间隔符:")!=-1) 
			{
				strRead.Replace("字段间隔符:","字段间隔符:");
			}
			if(strRead.Find("字段间隔符:")!=-1) 
			{
				char chTmp;
				strRead.Replace("字段间隔符:","");
				strRead.TrimRight(" ");
				strRead.TrimLeft(" ");
				if(sscanf(strRead,"%c",&chTmp)!=1) 
				{
					AfxMessageBox("读取字段间隔符出错!");
					return FALSE;
				}else {
					g_char_flag = chTmp;
				}
				break;
			}	
	}
	//读取数据表的每一个字段的名称,类型,长度设置
	for(i=0;i<g_num_tables;i++)
	{
		num_type=num_len=0;
		for(step=0;step<3;step++)
		{
			switch(step)
			{
				case 0:
					strTmp.Format("表%d字段名称:",i+1);
					strTmp1.Format("表%d字段名称:",i+1);
					break;
				case 1:
					strTmp.Format("表%d字段类型:",i+1);
					strTmp1.Format("表%d字段类型:",i+1);
					break;
				case 2:
					strTmp.Format("表%d字段长度:",i+1);
					strTmp1.Format("表%d字段长度:",i+1);
					break;
				default:
					break;
			}
			file.SeekToBegin();
			while(1)
			{
				if(file.ReadString(strRead)==FALSE)  break;
				strRead.TrimRight(" ");
				strRead.TrimLeft(" ");
				if(strRead.GetLength() == 0) continue; //空行跳过
				if(strRead.Left(2)	== "//") continue; //注释行跳过
				strRead.Replace('	',' ');
				if(strRead.Find(strTmp1)!=-1) strRead.Replace(strTmp1,strTmp);
				if(strRead.Find(strTmp)!=-1) 
				{
					strRead.Replace(strTmp,"");
					for(j=0;;j++)
					{
							strRead.TrimLeft(' ');
							if(sscanf(strRead,"%s",strTmp2)!=1)  break;
							switch(step)
							{
								case 0:
									strcpy(g_array_table_struct[i].str_fields_names[j],strTmp2);
									g_array_table_struct[i].fields_num++;
									break;
								case 1:
									if(sscanf(strTmp2,"%d",&g_array_table_struct[i].fields_types[j])!=1)
									{
										strTmp2.Format("读取表%d类型设置失败!",i+1);
										AfxMessageBox(strTmp2);
										return FALSE;
									}
									num_type++;
									break;
								case 2:
									if(sscanf(strTmp2,"%d",&g_array_table_struct[i].fields_lens[j])!=1)
									{
										strTmp2.Format("读取表%d长度设置失败!",i+1);
										AfxMessageBox(strTmp2);
										return FALSE;
									}
									num_len++;
									break;
								default:
									break;
							}
							for(m=0;m<strlen(strTmp2);m++) strRead.SetAt(m,' ');
					}
				}
			}
		}
		if(g_array_table_struct[i].fields_num<=0) 
		{
			strTmp2.Format("读取表%d名称失败!",i+1);
			AfxMessageBox(strTmp2);
			return FALSE;
		}
		if(num_type<=0||num_type!=g_array_table_struct[i].fields_num) 
		{
			strTmp2.Format("读取表%d类型设置失败!-2 ",i+1);
			AfxMessageBox(strTmp2);
			return FALSE;
		} 
		if(num_len<=0||num_len!=g_array_table_struct[i].fields_num) 
		{
			strTmp2.Format("读取表%d长度设置失败!-2 ",i+1);
			AfxMessageBox(strTmp2);
			return FALSE;
		}
	}
	for(i=0;i<g_num_tables;i++)
	{
		for(j=0,tmp1=0;j<g_array_table_struct[i].fields_num;j++)
		{
			tmp1 +=  g_array_table_struct[i].fields_lens[j];
		}
		if(g_rec_size[i]!=tmp1)
		{
			strTmp.Format("表%d记录的大小不等于同各字段长度和!",i+1);
			AfxMessageBox(strTmp);
			return FALSE;
		}
	}

	for(i=0;i<MAX_NUM_OF_TABLE;i++) strcpy(g_TableName[i],g_array_table_struct[i].str_table_name);

	file.Close();
	return TRUE;
}

⌨️ 快捷键说明

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