Ejemplo n.º 1
0
void OAC_ReadFileInsertAcList( char *filename)
{
	FILE *fp=NULL;
	int cnt=0;
	char buf[512], buf1[256];

	if( (fp=fopen( filename, "r")) == NULL ) return;

	while( fgets( buf, sizeof(buf)-1, fp) ){
		if( buf[0] == '#' || buf[0] == '\n' ||
			buf[0] == 0 ) continue;
		remove_r( buf );
		easyGetTokenFromBuf( buf, ':', 1, buf1, sizeof( buf1));
		sprintf( OAC_List[cnt].name, "%s", buf1);

		easyGetTokenFromBuf( buf, ':', 2, buf1, sizeof( buf1));
		sprintf( OAC_List[cnt].addr, "%s", buf1);
		OAC_List[cnt].use = 1;
		cnt++;
		if( cnt >= MAXTCPCONNECTION ) break;
	}
	fclose( fp);
	{//andy_log
		int i;
		for( i=0; i<MAXTCPCONNECTION; i++){
			if( OAC_List[i].use == 0 ) continue;
			log( "OAC_List[%d] %s %s .\n", i, OAC_List[i].name, OAC_List[i].addr)
		}
	}
}
Ejemplo n.º 2
0
void DEFEND_ReadScoreForList( char *filename)
{
	FILE *fp=NULL;
	char buf1[256], buf2[256];
	char cdkey[256], name[256], fromname[256];
	int score;
	fp = fopen( filename, "r");
	if( fp == NULL ){
		log( "Can't Read %s..!\n", filename);
		return;
	}

	while( fgets( buf1 , sizeof( buf1 ) , fp )){
		int i;
		if( strlen(buf1) < 1 || strlen(buf1) > 512 ) continue;
		for( i=0; i<strlen(buf1); i++){
			if( buf1[i] == '\n' ) buf1[1] = '\0';
		}
		easyGetTokenFromBuf( buf1, ',', 1, buf2, sizeof(buf2));
		memcpy( cdkey, buf2, sizeof( cdkey));
		easyGetTokenFromBuf( buf1, ',', 2, buf2, sizeof(buf2));
		memcpy( name, buf2, sizeof( name));
		easyGetTokenFromBuf( buf1, ',', 3, buf2, sizeof(buf2));
		memcpy( fromname, buf2, sizeof( fromname));
		easyGetTokenFromBuf( buf1, ',', 4, buf2, sizeof(buf2));
		score = atoi( buf2);
		DEFEND_addScoreForList( cdkey, name, score, fromname);
	}
	fclose( fp);
}
Ejemplo n.º 3
0
void DEFEND_ReadUserForList( char *filename)
{
	FILE *fp=NULL;
	char buf1[256], buf2[256];
	char cdkey[256], name[256];
	int type, nums, score;
	fp = fopen( filename, "r");
	if( fp == NULL ){
		log( "Can't Read %s..!\n", filename);
		return;
	}

	while( fgets( buf1 , sizeof( buf1 ) , fp )){
		easyGetTokenFromBuf( buf1, ',', 1, buf2, sizeof(buf2));
		memcpy( cdkey, buf2, sizeof( cdkey));
		easyGetTokenFromBuf( buf1, ',', 2, buf2, sizeof(buf2));
		memcpy( name, buf2, sizeof( name));
		easyGetTokenFromBuf( buf1, ',', 3, buf2, sizeof(buf2));
		nums = atoi( buf2);
		easyGetTokenFromBuf( buf1, ',', 4, buf2, sizeof(buf2));
		score = atoi( buf2);
		easyGetTokenFromBuf( buf1, ',', 5, buf2, sizeof(buf2));
		type = atoi( buf2);

		DEFEND_addUserForList( cdkey, name, score, nums, type);
	}
	fclose( fp);
	DEFEND_ShowUserLists();
}
Ejemplo n.º 4
0
void DEFEND_LoadScoreForList( char *listarg)
{
	char buf2[256];
	char cdkey[256], name[256], fromname[256];
	int score;

	easyGetTokenFromBuf( listarg, ',', 1, buf2, sizeof(buf2));
	memcpy( cdkey, buf2, sizeof( cdkey));
	easyGetTokenFromBuf( listarg, ',', 2, buf2, sizeof(buf2));
	memcpy( name, buf2, sizeof( name));
	easyGetTokenFromBuf( listarg, ',', 3, buf2, sizeof(buf2));
	memcpy( fromname, buf2, sizeof( fromname));
	easyGetTokenFromBuf( listarg, ',', 4, buf2, sizeof(buf2));
	score = atoi( buf2);

	if( DEFEND_addScoreForList( cdkey, name, score, fromname) < 1 ){
	}
	DEFEND_backupScoreLists( SCORE_FILENAME);
	DEFEND_ShowScoreLists();

}
Ejemplo n.º 5
0
void DEFEND_LoadUserForList( char *listarg)
{
	char buf2[256];
	char cdkey[256], name[256];
	int type, nums, score;

	easyGetTokenFromBuf( listarg, ',', 1, buf2, sizeof(buf2));
	memcpy( cdkey, buf2, sizeof( cdkey));
	easyGetTokenFromBuf( listarg, ',', 2, buf2, sizeof(buf2));
	memcpy( name, buf2, sizeof( name));
	easyGetTokenFromBuf( listarg, ',', 3, buf2, sizeof(buf2));
	nums = atoi( buf2);
	easyGetTokenFromBuf( listarg, ',', 4, buf2, sizeof(buf2));
	score = atoi( buf2);
	easyGetTokenFromBuf( listarg, ',', 5, buf2, sizeof(buf2));
	type = atoi( buf2);

	if( DEFEND_addUserForList( cdkey, name, score, nums, type) != -1 ){
		DEFEND_ShowUserLists();
		DEFEND_SendToUserLists();
	}
}
Ejemplo n.º 6
0
static int initMissionTable( void )
{
	FILE *fp;
	char onedata[1024];
	char buf[1024];
	int index =0;

	memset( missiontable, 0, sizeof(missiontable));
	fp = fopen( MISSIONFILE, "r");
	if( !fp ) {
		log("\n¼ÓÔؾ«ÁéÕÙ»½´íÎó!!!! \n");
		//return false;
	}
	log("\n¼ÓÔؾ«ÁéÕÙ»½...");
	while(1) {
		//
		if( fgets( onedata, sizeof(onedata), fp) == NULL)
			break;
		if( onedata[0] == '\0' || onedata[0] == '#' )
			continue;
		//easyGetTokenFromBuf( onedata, ",", 1, buf, sizeof( buf));
		//index = atoi( buf);
		easyGetTokenFromBuf( onedata, ",", 1, buf, sizeof( buf));
		if( buf[0] == '\0' ) continue;
		strcpy( missiontable[index].angelinfo, buf);
		easyGetTokenFromBuf( onedata, ",", 2, buf, sizeof( buf));
		if( buf[0] == '\0' ) continue;
		strcpy( missiontable[index].heroinfo, buf);
		easyGetTokenFromBuf( onedata, ",", 3, buf, sizeof( buf));
		if( buf[0] == '\0' ) continue;
		missiontable[index].mission = atoi( buf);
		easyGetTokenFromBuf( onedata, ",", 4, buf, sizeof( buf));
		if( buf[0] == '\0' ) continue;
		missiontable[index].flag = atoi( buf);
		easyGetTokenFromBuf( onedata, ",", 5, buf, sizeof( buf));
		if( buf[0] == '\0' ) continue;
		missiontable[index].time = atoi( buf);
		easyGetTokenFromBuf( onedata, ",", 6, buf, sizeof( buf));
		if( buf[0] == '\0' ) continue;
		missiontable[index].limittime = atoi( buf);

		log("%d=%s,%s,%d,%d,%d,%d \n", index,
			missiontable[index].angelinfo,
			missiontable[index].heroinfo,
			missiontable[index].mission,
			missiontable[index].flag,
			missiontable[index].time,
			missiontable[index].limittime );

		index++;
		if( index >= MAXMISSIONTABLE) break;
	}
	fclose( fp);
	log("..³É¹¦! \n");
	//return true;
}