Пример #1
0
/*------------------------------------------------------------
 *   �ѵ�ɬ��ë���继�������ƻ�֧�£�  �꼰�ֳ��ƥ���£�
 *------------------------------------------------------------*/
static int TITLE_getConfigOneLine( FILE *fp, char *line, int linelen)
{
	char    buf[1024];
	int     startflg = FALSE;
	int     linenum=0;
	line[0] = '\0';
	
	while( fgets( buf, sizeof( buf ), fp )){
		linenum ++;
		if( buf[0] == '#' )continue;        /* comment */
		if( buf[0] == '\n' )continue;       /* none    */
		/*  ���������    */
		/*  ���� tab ë " " ��  �徧����    */
		replaceString( buf, '\t' , ' ' );
		/* ��ʸ�������� */
		deleteCharFromString( buf, " ");

		if( buf[0] == '{' ) {
			if( startflg == TRUE ) {
				print( "titleconfig:����û�йرա�{��ȴ������: %d \n",linenum);
				/* } */
				return -1;
			}
			startflg = TRUE;
		}
		else if( buf[0] == '}' ) {
			if( startflg == FALSE) {
				print( "titleconfig:����û�йرա�{��ȴ������: %d \n",linenum);
				/* } */
				return -1;
			}
			return 1;
		}
		else {
			/* "{"ƥ�ȱ�����Ȼ������� }*/
			if( startflg == TRUE ) {
				if( strlen( line) != 0 ) {
					if( line[strlen(line) -1] != ',' ) {
						strcatsafe( line, linelen, ",");
					}
				}
				/* �������继������*/
				chompex( buf );
				strcatsafe( line,linelen,  buf);
			}
			/*   ���ֻ�"{"ƥ��Ԫ���Ȼ�ئ�������������������ƥ߯�� }*/
			else {
				chompex( buf );
				strcatsafe( line,linelen,  buf);
				return 1;
			}
		}
	}
	/* �����������ɵ��Ƿ�EOF   ѱ��Ԫ��ئ��������   */
	return 0;
}
Пример #2
0
static char *NPC_Util_MargeStrFromArgFile( char *filename, char *buf, int len)
{
	FILE	*fp;
	char	*cret = NULL;
	char	line[NPC_UTIL_GETARGSTR_LINEMAX];
	char	opfile[256];

	sprintf( opfile, "%s/", getNpcdir( ) );
	strcat( opfile, filename);
	*buf = '\0';
	fp = fopen( opfile, "r");
	if( fp != NULL ) {
		while( fgets( line, sizeof( line), fp)) {
			if( strlen(buf) != 0 ) {
				if( buf[strlen(buf) -1] != '|' ) {
					strcatsafe( buf, len, "|");
				}
			}
			chompex( line);
			strcatsafe( buf,len,  line);
		}
		fclose( fp);
		cret=buf;
	}
	return cret;
}
Пример #3
0
char *Pet_TalkGetFunStr( char *temp , char *buf, int len)
{
	char filename[56];
	char pathfile[128];
	char talkfun[ 10240];
	char buf1[256],buf2[256],buf3[256];
	FILE *petarg;
	char	*cStr=NULL; 
	int talkNo=1,mark=1;
	char	line[4096];
	BOOL find=FALSE;
	talkfun[0] ='\0';

	while( getStringFromIndexWithDelim( pettalktext,"&",talkNo, buf1, sizeof( buf1) ) != FALSE){
		talkNo++;
		if( NPC_Util_GetStrFromStrWithDelim( buf1, "PETTEMPNO", buf2, sizeof( buf2)) == NULL  )
			continue;
		mark=2;
		strcpy( filename,"\0");
		while( getStringFromIndexWithDelim( buf2,",", mark,buf3,sizeof( buf3)) != FALSE )	{
			mark ++;
			if( !strcmp( buf3, temp))	{
				print("\n buf2=%s",buf2);
				if( getStringFromIndexWithDelim( buf2,",", 1,filename,sizeof( filename)) == FALSE )
					return NULL;
				find = TRUE;
				break;
			}
		}
		if( find == TRUE )
			break;
	}
	if( !strcmp( filename, "\0") )
		return NULL;

	sprintf( pathfile, "%s/pettalk/%s", getNpcdir(), filename);
	petarg = fopen( pathfile , "r" );
	if( petarg != NULL ) {
		while( fgets( line, sizeof( line), petarg ) ) {
			if( strlen( talkfun) != 0 ) {
				if( talkfun[strlen( talkfun) -1] != '|' ) {
					strcatsafe( talkfun, sizeof( talkfun), "|");
				}
			}
			chompex( line);
			strcatsafe( talkfun, sizeof( talkfun ),  line);
		}
		fclose( petarg);
	}else	{
		return NULL;
	}
	talkNo = 1;
	while( getStringFromIndexWithDelim( talkfun,"}",talkNo, buf, len) != FALSE)	{
		talkNo++;
		if( NPC_Util_GetStrFromStrWithDelim( buf, "PETTEMPNO", buf2, sizeof( buf2)) == NULL  )
			continue;
		if( !strcmp( temp, buf2) )		{
			cStr = buf;
			break;
		}
	}
	return( cStr);
}