コード例 #1
0
ファイル: hash.c プロジェクト: marceloprates/compiladores
linkedList_t* addSymbol(char* text, type_t type)
{
	symbol_t symbol;
	symbol.text = (char*) calloc(strlen(text) + 1, sizeof(char));
	strcpy(symbol.text, text);
	symbol.type = type;

	switch(type)
	{
		case SYMBOL_LIT_INTEGER:
			symbol.value.intLit = atoi(text);
			break;
		case SYMBOL_LIT_TRUE:
			symbol.value.boolLit = 1;
			break;
		case SYMBOL_LIT_FALSE:
			symbol.value.boolLit = 0;
			break;
		case SYMBOL_LIT_CHAR:
			symbol.value.charLit = removeQuotes(text)[0];
			break;
		case SYMBOL_LIT_STRING:
			symbol.value.stringLit = removeQuotes(text);
			break;
		case SYMBOL_IDENTIFIER:
			symbol.value.identifier = text;
			break;
	}

	return addToTable(symbol, symbolTable, SYMBOL_TABLE_SIZE);
}
コード例 #2
0
ファイル: shell.c プロジェクト: RyanKadri/OpSys
/* Given the input, break it into tokens and pipes and keep track of how 
 * many there are*/
int parseInput(char* input, char** tokens, char** pipes, int* numTokens, int* numPipes){

	int i;
	int currentToken = 0;
	int currentPipe = 0;

	for(i = 0; input[i] != '\0'; ++i){
	
		/*Skip ahead to any non-space character*/
		i = skipToToken(input, i);
		if(i == -1){
			break;
		}else{
			/* Keep track of pipes */
			if(input[i] == '|'){
				pipes[currentPipe] = input + ((char) i);
				++currentPipe;
				input[i] = '\0';
				continue;
			}
			/* Pointer Arithmetic */
			tokens[currentToken] = input + ((char) i);
			++currentToken;
		}
		
		/*Skip ahead to a space, tab, or newline*/
		i = skipToSeperator(input, i);
		if(i < 0){
			return i;
		}else{
			/* A pipe is a token and a seperator by this logic*/
			if(input[i] == '|'){
				pipes[currentPipe] = input + ((char) i);
				++currentPipe;
			}
			input[i] = '\0';
		}
		
		if(currentToken==MAX_TOKENS){
			return MAX_ARGS_ERROR;
		}
	}
	
	removeQuotes(tokens,currentToken);
	
	(*numTokens) = currentToken;
	(*numPipes) = currentPipe;
	
	return 0;
	
}
コード例 #3
0
ファイル: AppendToFile.c プロジェクト: jgrossmann/security3
/*
	Parses the data string to make sure it is valid
*/
char *parseData(char *data) {
	int isQuoted = quotedString(data);
	if(isQuoted == -1) {
		printf("Error: Data string not closed\n");
		return NULL;
	}
	
	char *newData = NULL;
	char *temp = NULL;
	if(isQuoted) {
		temp = removeQuotes(data);
		newData = parseQuotedString(temp);
		return newData;
	}else {
		newData = parseString(data);
		if(newData == NULL) {
			return NULL;
		}
		temp = (char *) malloc((strlen(newData) + 1) * sizeof(char));
		strncpy(temp, newData, strlen(newData) + 1);
		return temp;
	}
}
コード例 #4
0
ファイル: hash.c プロジェクト: marceloprates/compiladores
linkedList_t* addSymbol(char* text, type_t type)
{
	symbol_t symbol;
	symbol.text = (char*) calloc(strlen(text) + 1, sizeof(char));
	strcpy(symbol.text, text);
	symbol.type = type;
	symbol.marked = FALSE;

	switch(type)
	{
		case SYMBOL_LIT_INTEGER:
		{
			char* hexString = (char*)calloc(strlen(text),sizeof(char));
			sprintf(hexString,"%s",text);

			int i;

			for(i = 0; i < strlen(hexString); i++)
				hexString[i] = tolower(hexString[i]);

			char* junk;
			symbol.value.intLit = strtol(hexString,&junk,16);

			symbol.dataType = INTEGER;

			break;
		}
		case SYMBOL_LIT_TRUE:
		{
			symbol.value.boolLit = 1;

			symbol.dataType = BOOL;

			break;
		}
		case SYMBOL_LIT_FALSE:
		{
			symbol.value.boolLit = 0;

			symbol.dataType = BOOL;

			break;
		}
		case SYMBOL_LIT_CHAR:
		{
			symbol.value.charLit = removeQuotes(text)[0];

			symbol.dataType = INTEGER;

			break;
		}
		case SYMBOL_LIT_STRING:
		{
			symbol.value.stringLit = removeQuotes(text);

			break;
		}
		case SYMBOL_IDENTIFIER:
		{
			symbol.value.identifier = (char*) calloc(strlen(text) + 1, sizeof(char));
			strcpy(symbol.value.identifier, text);

			break;
		}
	}

	return addToTable(symbol, symbolTable, SYMBOL_TABLE_SIZE);
}
コード例 #5
0
ファイル: tabpriv.c プロジェクト: trafodion/tests
/*
---------------------------------------------------------
   TestSQLTablePrivileges
---------------------------------------------------------
*/
PassFail TestMXSQLTablePrivileges( TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	char			Heading[MAX_HEADING_SIZE];
	/*  */char	ColumnWC4_TabOwner[NAME_LEN];
 	RETCODE			returncode;
 	SQLHANDLE 		henv = (SQLHANDLE)NULL;
 	SQLHANDLE 		hdbc = (SQLHANDLE)NULL;
 	SQLHANDLE		hstmt = (SQLHANDLE)NULL, hstmt1 = (SQLHANDLE)NULL;
	CHAR			TableQualifier[NAME_LEN],TableOwner[NAME_LEN],*TableStr;

	CHAR			*TableName;
	
	// CHAR			*Grantor; //Assume that we log on as role.user
	CHAR            Grantor[SQL_MAX_ROLENAME_LEN+2];

	CHAR			oTableQualifier[NAME_LEN];  
	CHAR			oTableOwner[NAME_LEN];
	CHAR			oTableName[NAME_LEN];
	CHAR			oGrantor[NAME_LEN];
	CHAR			oGrantee[NAME_LEN];
	CHAR			oPrivilege[NAME_LEN];
	CHAR			oIs_Grantable[3];

	SQLLEN		oTableQualifierlen;
	SQLLEN		oTableOwnerlen;
	SQLLEN		oTableNamelen;
	SQLLEN		oGrantorlen = SQL_NTS;
	SQLLEN		oGranteelen;
	SQLLEN		oPrivilegelen;
	SQLLEN		oIs_Grantablelen;

/*  */
	struct
	{
		CHAR		*Col;
		CHAR		*Grantee;
		CHAR		*Is_Grantable;
		CHAR		*Privilege;
	} TableCol[] = {
		{"--",SQ_GRANTEE,"YES","DELETE"},
		{"--",SQ_GRANTEE,"NO","DELETE,SELECT"},
		{"--",SQ_GRANTEE,"YES","SELECT"},
		{"--",SQ_GRANTEE,"NO","DELETE"},
		{"--",SQ_GRANTEE,"YES","INSERT"},
		{"--",SQ_GRANTEE,"NO","UPDATE"},
		{"--",SQ_GRANTEE,"YES","REFERENCES"},
		{"--",SQ_GRANTEE,"NO","SELECT"},
		{"--",SQ_GRANTEE,"YES","INSERT"},
		{"--",SQ_GRANTEE,"NO","REFERENCES"},
		{"--",SQ_GRANTEE,"YES","UPDATE"},
		{"--",SQ_GRANTEE,"NO","REFERENCES"},
		{"--",SQ_GRANTEE,"YES","UPDATE"},
		{"--",SQ_GRANTEE,"NO","INSERT",},
		{"--",SQ_GRANTEE,"YES","SELECT"},
		{"--",SQ_GRANTEE,"NO","REFERENCES,SELECT"},
		{"--",SQ_GRANTEE,"YES","DELETE,INSERT,SELECT"},
		{"--",SQ_GRANTEE,"NO","INSERT,REFERENCES,UPDATE"},
		{"--",SQ_GRANTEE,"YES","SELECT,DELETE,INSERT,UPDATE"},
		{"--",SQ_GRANTEE,"NO","DELETE,INSERT,REFERENCES,UPDATE",},
		{"--",SQ_GRANTEE,"YES","DELETE,INSERT,REFERENCES,SELECT,UPDATE"},
		{"--",SQ_GRANTEE,"NO","DELETE"},						//Bignum
		{"--",SQ_GRANTEE,"YES","SELECT"},					//Bignum
		{"--",SQ_GRANTEE,"NO","INSERT"},						//Bignum
		{"--",SQ_GRANTEE,"YES","UPDATE"},					//Bignum
		{"--",SQ_GRANTEE,"NO","REFERENCES"},					//Bignum
		{"--",SQ_GRANTEE,"YES","SELECT,DELETE,INSERT,UPDATE"},//Bignum
		{"--",SQ_GRANTEE,"NO","INSERT,REFERENCES,UPDATE"},	//Bignum
		{"endloop",}
	};

	struct
	{
		CHAR		*TabQua;
		CHAR		*TabOwner;
		CHAR		*TabName;
		RETCODE		CheckCode;
		int			isEscape;
	} ColumnWC[] = {								// wild cards from here 
							{"--","--","--", SQL_SUCCESS,0},// Have a row with all valid values here so that 
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							//	Testing escape sequences
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"endloop",}
						};

	struct
	{
		CHAR		*TabQua;
		SWORD		TabQuaLen;
		CHAR		*TabOwner;
		SWORD		TabOwnerLen;
		CHAR		*TabName;
		SWORD		TabNameLen;
		CHAR		*ColName;
		SWORD		ColNameLen;
	} ColumnWC2[] = {								//	wild cards from here
							{"--", (SWORD)-1, "--",(SWORD)-1, "--",(SWORD)-1, "", (SWORD)-1},
							{"--", (SWORD)4,  "--",(SWORD)2,  "--",(SWORD)2,  "", (SWORD)2},
//							{"TEST_CATALOG", (SWORD)0, "TEST_SCHEMA",(SWORD)0, "TEST_TABLE",(SWORD)0, "", (SWORD)0},
							{"endloop",}
						};

	int cols;
	int	iatt;
	SWORD numOfCols = 0;
	SWORD pcbDesc;
	SQLLEN pfDesc;
	CHAR cn[COLNAME_LEN];
	SWORD cl;
	SWORD st;
	SQLULEN cp;
	SWORD cs, cnull;
	CHAR rgbDesc[RGB_MAX_LEN];
	CHAR *CharOutput[12];
	SQLLEN stringlength;	//	Attributes for columns added for negative testing
	UWORD DescrType[] = 
				{
					SQL_COLUMN_AUTO_INCREMENT,SQL_COLUMN_CASE_SENSITIVE,SQL_COLUMN_COUNT,
					SQL_COLUMN_DISPLAY_SIZE,SQL_COLUMN_LENGTH,SQL_COLUMN_MONEY,
					SQL_COLUMN_NULLABLE,SQL_COLUMN_PRECISION,SQL_COLUMN_SCALE,
					SQL_COLUMN_SEARCHABLE,SQL_COLUMN_TYPE,SQL_COLUMN_UNSIGNED,
					SQL_COLUMN_UPDATABLE,SQL_COLUMN_NAME,SQL_COLUMN_TYPE_NAME,
					SQL_COLUMN_OWNER_NAME,SQL_COLUMN_QUALIFIER_NAME,SQL_COLUMN_TABLE_NAME,
					SQL_COLUMN_LABEL
				};

	CHAR	*TestColumn;
	int		i = 0, k = 0;

    struct {
        char cat[STR_LEN];
        char sch[STR_LEN];
        char tab[STR_LEN];
    } displayBuf;

//	DWORD	nSize;


//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLTablePrivileges", charset_file);
	if (var_list == NULL) return FAILED;

	TableName = var_mapping("SQLTablePrivileges_TableName", var_list);

	TestColumn = var_mapping("SQLTablePrivileges_TestColumn", var_list);

	TableCol[0].Col = var_mapping("SQLTablePrivileges_TableCol_Col_0", var_list);
	TableCol[1].Col = var_mapping("SQLTablePrivileges_TableCol_Col_1", var_list);
	TableCol[2].Col = var_mapping("SQLTablePrivileges_TableCol_Col_2", var_list);
	TableCol[3].Col = var_mapping("SQLTablePrivileges_TableCol_Col_3", var_list);
	TableCol[4].Col = var_mapping("SQLTablePrivileges_TableCol_Col_4", var_list);
	TableCol[5].Col = var_mapping("SQLTablePrivileges_TableCol_Col_5", var_list);
	TableCol[6].Col = var_mapping("SQLTablePrivileges_TableCol_Col_6", var_list);
	TableCol[7].Col = var_mapping("SQLTablePrivileges_TableCol_Col_7", var_list);
	TableCol[8].Col = var_mapping("SQLTablePrivileges_TableCol_Col_8", var_list);
	TableCol[9].Col = var_mapping("SQLTablePrivileges_TableCol_Col_9", var_list);
	TableCol[10].Col = var_mapping("SQLTablePrivileges_TableCol_Col_10", var_list);
	TableCol[11].Col = var_mapping("SQLTablePrivileges_TableCol_Col_11", var_list);
	TableCol[12].Col = var_mapping("SQLTablePrivileges_TableCol_Col_12", var_list);
	TableCol[13].Col = var_mapping("SQLTablePrivileges_TableCol_Col_13", var_list);
	TableCol[14].Col = var_mapping("SQLTablePrivileges_TableCol_Col_14", var_list);
	TableCol[15].Col = var_mapping("SQLTablePrivileges_TableCol_Col_15", var_list);
	TableCol[16].Col = var_mapping("SQLTablePrivileges_TableCol_Col_16", var_list);
	TableCol[17].Col = var_mapping("SQLTablePrivileges_TableCol_Col_17", var_list);
	TableCol[18].Col = var_mapping("SQLTablePrivileges_TableCol_Col_18", var_list);
	TableCol[19].Col = var_mapping("SQLTablePrivileges_TableCol_Col_19", var_list);
	TableCol[20].Col = var_mapping("SQLTablePrivileges_TableCol_Col_20", var_list);
	TableCol[21].Col = var_mapping("SQLTablePrivileges_TableCol_Col_21", var_list);
	TableCol[22].Col = var_mapping("SQLTablePrivileges_TableCol_Col_22", var_list);
	TableCol[23].Col = var_mapping("SQLTablePrivileges_TableCol_Col_23", var_list);
	TableCol[24].Col = var_mapping("SQLTablePrivileges_TableCol_Col_24", var_list);
	TableCol[25].Col = var_mapping("SQLTablePrivileges_TableCol_Col_25", var_list);
	TableCol[26].Col = var_mapping("SQLTablePrivileges_TableCol_Col_26", var_list);
	TableCol[27].Col = var_mapping("SQLTablePrivileges_TableCol_Col_27", var_list);

	ColumnWC[0].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_0", var_list);
	ColumnWC[0].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_0", var_list);
	ColumnWC[0].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_0", var_list);

	ColumnWC[1].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_1", var_list);
	ColumnWC[1].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_1", var_list);
	ColumnWC[1].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_1", var_list);

	ColumnWC[2].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_2", var_list);
	ColumnWC[2].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_2", var_list);
	ColumnWC[2].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_2", var_list);

	ColumnWC[3].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_3", var_list);
	ColumnWC[3].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_3", var_list);
	ColumnWC[3].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_3", var_list);

	ColumnWC[4].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_4", var_list);
        ColumnWC[4].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_4", var_list); 
	ColumnWC[4].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_4", var_list);

	ColumnWC[5].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_5", var_list);
	ColumnWC[5].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_5", var_list);
	ColumnWC[5].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_5", var_list);

	ColumnWC[6].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_6", var_list);
	ColumnWC[6].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_6", var_list);
	ColumnWC[6].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_6", var_list);

	ColumnWC[7].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_7", var_list);
	ColumnWC[7].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_7", var_list);
	ColumnWC[7].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_7", var_list);

	ColumnWC[8].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_8", var_list);
	ColumnWC[8].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_8", var_list);
	ColumnWC[8].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_8", var_list);

	ColumnWC[9].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_9", var_list);
	ColumnWC[9].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_9", var_list);
	ColumnWC[9].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_9", var_list);

	ColumnWC[10].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_10", var_list);
	ColumnWC[10].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_10", var_list);
	ColumnWC[10].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_10", var_list);

	ColumnWC[11].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_11", var_list);
	ColumnWC[11].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_11", var_list);
	ColumnWC[11].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_11", var_list);

	ColumnWC[12].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_12", var_list);
	ColumnWC[12].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_12", var_list);
	ColumnWC[12].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_12", var_list);

	ColumnWC[13].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_13", var_list);
	ColumnWC[13].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_13", var_list);
	ColumnWC[13].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_13", var_list);

	ColumnWC[14].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_14", var_list);
	ColumnWC[14].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_14", var_list);
	ColumnWC[14].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_14", var_list);

	ColumnWC[15].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_15", var_list);
	ColumnWC[15].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_15", var_list);
	ColumnWC[15].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_15", var_list);

	ColumnWC[16].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_16", var_list);
	ColumnWC[16].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_16", var_list);
	ColumnWC[16].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_16", var_list);

	ColumnWC[17].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_17", var_list);
	ColumnWC[17].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_17", var_list);
	ColumnWC[17].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_17", var_list);

	ColumnWC[18].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_18", var_list);
	ColumnWC[18].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_18", var_list);
	ColumnWC[18].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_18", var_list);

	ColumnWC[19].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_19", var_list);
	ColumnWC[19].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_19", var_list);
	ColumnWC[19].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_19", var_list);

	ColumnWC[20].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_20", var_list);
	ColumnWC[20].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_20", var_list);
	ColumnWC[20].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_20", var_list);

	ColumnWC[21].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_21", var_list);
	ColumnWC[21].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_21", var_list);
	ColumnWC[21].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_21", var_list);

	ColumnWC[22].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_22", var_list);
	ColumnWC[22].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_22", var_list);
	ColumnWC[22].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_22", var_list);

	ColumnWC[23].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_23", var_list);
	ColumnWC[23].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_23", var_list);
	ColumnWC[23].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_23", var_list);

	ColumnWC[24].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_24", var_list);
	ColumnWC[24].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_24", var_list);
	ColumnWC[24].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_24", var_list);

	ColumnWC[25].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_25", var_list);
	ColumnWC[25].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_25", var_list);
	ColumnWC[25].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_25", var_list);

	ColumnWC[26].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_26", var_list);
	ColumnWC[26].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_26", var_list);
	ColumnWC[26].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_26", var_list);

	ColumnWC[27].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_27", var_list);
	ColumnWC[27].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_27", var_list);
	ColumnWC[27].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_27", var_list);

	ColumnWC[28].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_28", var_list);
	ColumnWC[28].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_28", var_list);
	ColumnWC[28].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_28", var_list);

	ColumnWC[29].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_29", var_list);
	ColumnWC[29].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_29", var_list);
	ColumnWC[29].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_29", var_list);

	ColumnWC[30].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_30", var_list);
	ColumnWC[30].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_30", var_list);
	ColumnWC[30].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_30", var_list);

	ColumnWC[31].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_31", var_list);
	ColumnWC[31].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_31", var_list);
	ColumnWC[31].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_31", var_list);

	ColumnWC[32].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_32", var_list);
	ColumnWC[32].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_32", var_list);
	ColumnWC[32].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_32", var_list);

	ColumnWC[33].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_33", var_list);
	ColumnWC[33].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_33", var_list);
	ColumnWC[33].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_33", var_list);

	ColumnWC[34].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_34", var_list);
	ColumnWC[34].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_34", var_list);
	ColumnWC[34].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_34", var_list);

	ColumnWC2[0].TabQua = var_mapping("SQLTablePrivileges_ColumnWC2_TabQua_0", var_list);
	ColumnWC2[0].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC2_TabOwner_0", var_list);
	ColumnWC2[0].TabName = var_mapping("SQLTablePrivileges_ColumnWC2_TabName_0", var_list);

	ColumnWC2[1].TabQua = var_mapping("SQLTablePrivileges_ColumnWC2_TabQua_1", var_list);
	ColumnWC2[1].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC2_TabOwner_1", var_list);
	ColumnWC2[1].TabName = var_mapping("SQLTablePrivileges_ColumnWC2_TabName_1", var_list);

//=================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => SQLTablePrivileges | SQLTablePriv | tabpriv.c\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLTablePrivileges tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

#ifdef LDAP
	// Grantor = var_mapping("SQLTablePrivileges_Grantor", var_list);
/*
	returncode = SQLGetConnectAttr(hdbc, (SQLINTEGER)SQL_ATTR_ROLENAME, (SQLCHAR*)Grantor, SQL_MAX_ROLENAME_LEN+2, (SQLINTEGER *) &oGrantorlen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
*/
/* hardcode it for now */ strcpy (Grantor, "DB__ROOT");
#else
        sprintf(Grantor, "%s", var_mapping("SQLTablePrivileges_Grantor", var_list)); 
#endif

	LogMsg(NONE,"Grantor is: %s\n", Grantor);

	TESTCASE_END;  // end of setup
 
	strcpy(TableQualifier,pTestInfo->Catalog);
	strcpy(TableOwner,pTestInfo->Schema);

	TableStr = (char *)malloc(MAX_NOS_SIZE);
	i = 0;
	while (_stricmp(TableCol[i].Col,"endloop") != 0)
	{
		sprintf(Heading,"Test #%d\n",i);
		TESTCASE_BEGIN(Heading);

		if (_stricmp(TableCol[i].Privilege,"ALL PRIVILEGES") == 0)
			strcpy(TableCol[i].Privilege,"DELETE");

		// clean up left over table, if any.  We don't care about returncode from SQLExecDirect
		sprintf(TableStr,"drop table %s",TableName);
		SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		
		// create table to test against
		sprintf(TableStr,"create table %s (%s) no partition;",TableName,TableCol[i].Col);
		returncode = SQLExecDirect(hstmt,(SQLCHAR*)TableStr,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		else
		{
			// execute GRANT statement to set up some table privileges
			sprintf(TableStr,"GRANT %s ON %s TO \"%s\"",TableCol[i].Privilege,TableName,TableCol[i].Grantee);
			if (_stricmp(TableCol[i].Is_Grantable,"YES") == 0)
				strcat(TableStr, " WITH GRANT OPTION");
			LogMsg(NONE,"%s\n",TableStr);
			returncode = SQLExecDirect(hstmt,(SQLCHAR*)TableStr,SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				// Execute SQLTablePrivileges for test table
				if (strlen(TableQualifier) == 0)
					returncode = SQLTablePrivileges(hstmt,NULL,0,(SQLCHAR*)TableOwner,(SWORD)strlen(TableOwner),(SQLCHAR*)TableName,(SWORD)strlen(TableName));
				else
					returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)TableQualifier,(SWORD)strlen(TableQualifier),(SQLCHAR*)TableOwner,(SWORD)strlen(TableOwner),(SQLCHAR*)TableName,(SWORD)strlen(TableName));
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					LogMsg(NONE,"SQLTablePrivileges function call executed correctly.\n");

					// clear all buffers
					strcpy(oTableQualifier,"");
					strcpy(oTableOwner,"");
					strcpy(oTableName,"");
					strcpy(oGrantor,"");
					strcpy(oGrantee,"");
					strcpy(oPrivilege,"");
					strcpy(oIs_Grantable,"");

					// Bind all columns to recieve data returned from SQLTablePrivileges
					returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					} 
					returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					
					
					// Loop, reading and checking all data retuned from SQLTablePrivileges call
					k = 0;
					while (returncode == SQL_SUCCESS)
					{
						returncode = SQLFetch(hstmt);
						if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
						{
							LogAllErrors(henv,hdbc,hstmt);
							TEST_FAILED;
						}
						else 
						{
							// check for SQL_SUCCESS in case SQL_NO_DATA_FOUND was what was returned
							// compare results for rows where oGrantor is not the same as Grantor (super.super)
							if ((returncode == SQL_SUCCESS) && (_stricmp(Grantor,oGrantor) == 0) && (_stricmp(TableCol[i].Grantee,oGrantee) == 0))
							{
								k++;	// found a match, increment counter
								if ((_stricmp(TableQualifier,oTableQualifier) == 0) 
									&& (cstrcmp(TableOwner,oTableOwner,TRUE,isCharSet) == 0) 
									&& (cstrcmp(TableName,oTableName,TRUE,isCharSet) == 0) 
									//&& (_stricmp(oGrantor,Grantor) == 0) 
									//&& (_stricmp(TableCol[i].Grantee,oGrantee) == 0) // NOT NEEDED
									&& (strstr(TableCol[i].Privilege,oPrivilege) != NULL) 
									&& (_stricmp(TableCol[i].Is_Grantable,oIs_Grantable) == 0) )
								{
									LogMsg(NONE,"SQLTablePrivileges: compare results of rows fetched for following column.\n");
									LogMsg(NONE,"TableQualifier expect: %s and actual: %s are matched\n",TableQualifier,oTableQualifier);
									LogMsg(NONE,"TableOwner expect: %s and actual: %s are matched\n",TableOwner,oTableOwner);
									LogMsg(NONE,"TableName expect: %s and actual: %s are matched\n",TableName,oTableName);
									LogMsg(NONE,"Grantor expect: %s and actual: %s are matched\n",Grantor,oGrantor);
									LogMsg(NONE,"Grantee expect: %s and actual: %s are matched\n",TableCol[i].Grantee,oGrantee);
									LogMsg(NONE,"Privilege expect: %s and actual: %s are matched\n",TableCol[i].Privilege,oPrivilege);
									LogMsg(NONE,"Is_Grantable expect: %s and actual: %s are matched\n",TableCol[i].Is_Grantable,oIs_Grantable);
								}
								else
								{
									TEST_FAILED;	
									LogMsg(NONE,"SQLTablePrivileges: compare results of rows fetched for following column failed line %d.\n", __LINE__);
									if (_stricmp(TableQualifier,oTableQualifier) != 0)
										LogMsg(ERRMSG,"TableQualifier expect: %s and actual: %s are not matched\n",TableQualifier,oTableQualifier);
									if (cstrcmp(TableOwner,oTableOwner,TRUE,isCharSet) != 0) 
										LogMsg(ERRMSG,"TableOwner expect: %s and actual: %s are not matched\n",TableOwner,oTableOwner);
									if (cstrcmp(TableName,oTableName,TRUE,isCharSet) != 0) 
										LogMsg(ERRMSG,"TableName expect: %s and actual: %s are not matched\n",TableName,oTableName);
									//if (_stricmp(oGrantor,Grantor) != 0)
									//	LogMsg(ERRMSG,"Grantor expect: %s and actual: %s are not matched\n",Grantor,oGrantor);
									//if (_stricmp(TableCol[i].Grantee,oGrantee) != 0)
									//	LogMsg(ERRMSG,"Grantee expect: %s and actual: %s are not matched\n",TableCol[i].Grantee,oGrantee);
									if (strstr(TableCol[i].Privilege,oPrivilege) == NULL)
										LogMsg(ERRMSG,"Privilege expect: %s and actual: %s are not matched\n",TableCol[i].Privilege,oPrivilege);
									if (_stricmp(TableCol[i].Is_Grantable,oIs_Grantable) != 0)
										LogMsg(ERRMSG,"Is_Grantable expect: %s and actual: %s are not matched\n",TableCol[i].Is_Grantable,oIs_Grantable);
								}
							}
						}
					}
					if(k == 0){
						TEST_FAILED;
						LogMsg(ERRMSG,"No matching grantee record for '%s' found\n"
										  "   At least one row fetched should have matched\n",
										  TableCol[i].Grantee);
						}
					SQLFreeStmt(hstmt,SQL_UNBIND);
					SQLFreeStmt(hstmt,SQL_CLOSE);
				}
			}
		}
		TESTCASE_END;
		
		// clean up SQL table
		sprintf(TableStr,"drop table %s",TableName);
		SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		i++;
	} 

//=======================================================================================

	i = 0;
	sprintf(TableStr,"drop table %s.%s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	LogMsg(NONE,"%s\n",TableStr);
	sprintf(TableStr,"drop schema %s.%s cascade",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	LogMsg(NONE,"%s\n",TableStr);

	sprintf(TableStr,"create schema %s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	LogMsg(NONE,"%s\n",TableStr);
	returncode = SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	else
	{
		sprintf(TableStr,"create table %s.%s.%s(%s char(10)) no partition;",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName, TestColumn);
		returncode = SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
	}
	LogMsg(NONE,"%s\n",TableStr);
	returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}// end of setup
	if (returncode == SQL_SUCCESS) 
	{
		while ((_stricmp(ColumnWC[i].TabQua,"endloop") != 0) && (ColumnWC[i].isEscape == 0))
		{
			sprintf(Heading,"SQLTablePrivileges: wildcard options => \n"
				"Table Qualifier: %s \nTable Owner: %s \nTable Name: %s\n", 
				printSymbol(ColumnWC[i].TabQua,displayBuf.cat), 
				printSymbol(ColumnWC[i].TabOwner,displayBuf.sch), 
				printSymbol(ColumnWC[i].TabName,displayBuf.tab));
			TESTCASE_BEGIN(Heading);
			if (_stricmp(ColumnWC[i].TabQua,"NULL") == 0)
				ColumnWC[i].TabQua = NULL;
			if (_stricmp(ColumnWC[i].TabOwner,"NULL") == 0)
				ColumnWC[i].TabOwner = NULL;
			if (_stricmp(ColumnWC[i].TabName,"NULL") == 0)
				ColumnWC[i].TabName = NULL;

			if (ColumnWC[i].TabQua == NULL || ColumnWC[i].TabOwner == NULL || ColumnWC[i].TabName == NULL)
				returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,SQL_NTS,
                                                      (SQLCHAR*)ColumnWC[i].TabOwner,SQL_NTS,
                                                      (SQLCHAR*)removeQuotes(ColumnWC[i].TabName,displayBuf.tab),SQL_NTS);
			else
				returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),
                                                      (SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),
                                                      (SQLCHAR*)removeQuotes(ColumnWC[i].TabName,displayBuf.tab),(SWORD)strlen(displayBuf.tab));
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				LogMsg(NONE,"SQLTablePrivileges: SQLTablePrivileges function call executed correctly.\n");
				strcpy(oTableQualifier,"");
				strcpy(oTableOwner,"");
				strcpy(oTableName,"");
				strcpy(oGrantor,"");
				strcpy(oGrantee,"");
				strcpy(oPrivilege,"");
				strcpy(oIs_Grantable,"");
				returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				} 
				returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}

				returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				
				returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				k = 0;
				while (returncode == SQL_SUCCESS) 
				{
					returncode = SQLFetch(hstmt);
					if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}
					if (returncode == SQL_SUCCESS)
						k++;
				}
				if(k == 0 && ColumnWC[i].CheckCode == SQL_SUCCESS)
				{
					if(ColumnWC[i].isEscape == 1)
						LogMsg(ERRMSG, "Search string pattern in Catalog's Name is not supported\n");
					else {
						TEST_FAILED;
						LogMsg(ERRMSG,"No Data Found => Atleast one row should be fetched\n");
					}
				}
			}
			SQLFreeStmt(hstmt,SQL_CLOSE);
			TESTCASE_END;
			i++;
		}
	}

//======================================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Negative test with invalid handle.\n");

	i = 0;
	returncode = SQLTablePrivileges(hstmt1,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),(SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),(SQLCHAR*)ColumnWC[i].TabName,(SWORD)strlen(ColumnWC[i].TabName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTables: Negative test with NULL handle.\n");

	hstmt1 = (SQLHANDLE)NULL;
	i = 0;
	returncode = SQLTablePrivileges(hstmt1,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),(SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),(SQLCHAR*)ColumnWC[i].TabName,(SWORD)strlen(ColumnWC[i].TabName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Negative test with invalid arg lengths.\n");

	returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC2[0].TabQua,ColumnWC2[0].TabQuaLen,(SQLCHAR*)ColumnWC2[0].TabOwner,ColumnWC2[0].TabOwnerLen,(SQLCHAR*)ColumnWC2[0].TabName,ColumnWC2[0].TabNameLen);
	LogMsg(NONE, "Input parameters: CatalogLen %d SchemaLen %d TableLen %d\n", ColumnWC2[0].TabQuaLen, ColumnWC2[0].TabOwnerLen, ColumnWC2[0].TabNameLen);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLTablePrivileges"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}

	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Positive test with invalid arg lengths.\n");

	returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC2[1].TabQua,ColumnWC2[1].TabQuaLen,(SQLCHAR*)ColumnWC2[1].TabOwner,ColumnWC2[1].TabOwnerLen,(SQLCHAR*)ColumnWC2[1].TabName,ColumnWC2[1].TabNameLen);
	LogMsg(NONE, "Input parameters: CatalogLen %d SchemaLen %d TableLen %d\n", ColumnWC2[1].TabQuaLen, ColumnWC2[1].TabOwnerLen, ColumnWC2[1].TabNameLen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else {
		LogMsg(NONE,"SQLTablePrivileges: SQLTablePrivileges function call executed correctly.\n");
		strcpy(oTableQualifier,"");
		strcpy(oTableOwner,"");
		strcpy(oTableName,"");
		strcpy(oGrantor,"");
		strcpy(oGrantee,"");
		strcpy(oPrivilege,"");
		strcpy(oIs_Grantable,"");
		returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		} 
		returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		
		returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		k = 0;
		while (returncode == SQL_SUCCESS) 
		{
			returncode = SQLFetch(hstmt);
			if (returncode == SQL_SUCCESS) k++;
		}
		if(k > 0)
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Should be no data found - check for similar objects unintentionally appear\n");
		}
	}

	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("Testing SQLColAttribute, SQLDescribeCol, SQLBindCol and SQLFetch functions for catalog names.\n");

	returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}// end of setup

	for(i = 0; i < 5; i++)
	{
		sprintf(Heading,"======================================\n"
						"SQLTablePrivileges: wildcard options => \n"
						"Table Qualifier: %s \nTable Owner: %s \nTable Name: %s\n", 
						printSymbol(ColumnWC[i].TabQua,displayBuf.cat), 
						printSymbol(ColumnWC[i].TabOwner,displayBuf.sch), 
						printSymbol(ColumnWC[i].TabName,displayBuf.tab));
		LogMsg(NONE,Heading);

		returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),
											  (SQLCHAR*)removeQuotes(ColumnWC[i].TabOwner, displayBuf.sch),(SWORD)strlen(displayBuf.sch),
											  (SQLCHAR*)removeQuotes(ColumnWC[i].TabName, displayBuf.tab),(SWORD)strlen(displayBuf.tab));
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColumns"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		LogMsg(NONE,"after the call\n");

		returncode = SQLNumResultCols(hstmt, &numOfCols);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultsCol"))
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Test failed while executing call for SQLNUMRESULTSCOL");
			LogAllErrors(henv,hdbc,hstmt);
		}
		for(cols = 0; cols < numOfCols; cols++)
		{
			returncode = SQLDescribeCol(hstmt,(SWORD)(cols+1),(SQLCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,"Test failed while executing call for SQLDESCRIBECOL of column");
				LogAllErrors(henv,hdbc,hstmt);
			}
			CharOutput[cols] = (char *)malloc(STR_LEN);
			for (iatt = 0; iatt <= TOTALATTRIBS; iatt++)
			{
				strcpy(rgbDesc,"");
				pcbDesc = 0;
				pfDesc = 0;
				returncode = SQLColAttributes(hstmt,(SWORD)(cols+1),DescrType[iatt],rgbDesc,STR_LEN,&pcbDesc,&pfDesc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColAttribute"))
				{
					TEST_FAILED;
					LogMsg(ERRMSG,"Test failed while executing call for SQLCOLATTRIBUTES of column : %d.\n",i+1);
					LogAllErrors(henv,hdbc,hstmt);
				}
			}
			returncode = SQLBindCol(hstmt,(SWORD)(cols+1),SQL_C_CHAR,CharOutput[cols],STR_LEN,&stringlength);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,"Test failed while executing call for SQLBindCols of column : %d.\n",cols);
				LogAllErrors(henv,hdbc,hstmt);
			}
		}

		k = 0;
		while (returncode == SQL_SUCCESS)
		{
			returncode = SQLFetch(hstmt);
			if(returncode == SQL_ERROR)
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			} else if (returncode == SQL_NO_DATA_FOUND) {
				break;
			}
			else {
				if (returncode == SQL_SUCCESS_WITH_INFO)
					LogAllErrors(henv,hdbc,hstmt);
				k++;
			}
		}
		if(k == 0)
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"No Data Found => Atleast one row should be fetched\n");
		}
		
		for(cols = 0; cols < numOfCols; cols++)
		{
			free(CharOutput[cols]);
		}
		TESTCASE_END;
	}

//=========================================================================================
	// Cleanup
	i=0;
	sprintf(TableStr,"drop table %s.%s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	sprintf(TableStr,"drop schema %s.%s cascade",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);

	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLTablePrivileges.\n");
	free(TableStr); 
	free_list(var_list);
	TEST_RETURN;
}
コード例 #6
0
ファイル: MeshManager.cpp プロジェクト: condorkm/ThinRender
Mesh* MeshManager::parseMD5(string filename, char* buffer, int lenght){
    Mesh* resultMesh = new Mesh(filename, getNewId());
	int numJoints = 0;
	int numMeshes = 0;
	int numVerts = 0;
	int numTris = 0;
	int numWeights = 0;
	unsigned int idSubMesh = 0;
	int n = 0;
	copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//autoincrease i
	while (buffer[n] != '\0'){
		if(strncmp(tempBuffer, "MD5Version", 10) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			//resultMesh->versionMD5 = (int) atoi(tempBuffer);
			//logInf("md5 version %s", tempBuffer);
		}
		else if(strncmp(tempBuffer, "commandline", 11) == 0){
			skipLine(buffer, &n);
		}
		else if(strncmp(tempBuffer, "numJoints", 9) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			numJoints = (int) atoi(tempBuffer);
			resultMesh->joints.reserve(numJoints);
		}
		else if(strncmp(tempBuffer, "numMeshes", 9) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			numMeshes = (int) atoi(tempBuffer);
			resultMesh->subMeshes.reserve(numMeshes);
		}
		else if(strncmp(tempBuffer, "joints", 6) == 0){
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n); //read the '{' character
			Mesh::Joint auxJoint;
			for(int i = 0; i < numJoints; i++){
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointName = tempBuffer;
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointParentID = (int) atoi(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// '(' char
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointPos.x = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointPos.y = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointPos.z = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// ')' char
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// '(' char
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointOrient.x = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointOrient.y = (float) fast_atof(tempBuffer);
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
				auxJoint.jointOrient.z = (float) fast_atof(tempBuffer);
				skipLine(buffer, &n);

				removeQuotes(&(auxJoint.jointName));
				computeQuaternionW(&(auxJoint.jointOrient));

				resultMesh->joints.push_back(auxJoint);
			}
		}
		else if(strncmp(tempBuffer, "mesh", 4) == 0){
			SubMesh* auxSubMesh = new SubMesh(idSubMesh);
			idSubMesh++;
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);// char {
			copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
			while(strncmp(tempBuffer, "}", 1) != 0){
				if(strncmp(tempBuffer, "shader", 6) == 0){
					///////////////TODO
					//shader factory
					//used to set the texture!! be careful
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					auxSubMesh->setSubMeshTextureName(tempBuffer);
					skipLine(buffer, &n);
				}
				else if(strncmp(tempBuffer, "numverts", 8) == 0){
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					numVerts = (int) atoi(tempBuffer);
					glm::vec2 textCoord;
					glm::i32vec2 weightStartAndCount;
					for(int i = 0; i < numVerts; ++i){
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//"vert"
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//id (sorted)
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//'('

						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						textCoord.x = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						textCoord.y = (float) fast_atof(tempBuffer);

						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//')'

						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						weightStartAndCount.x = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						weightStartAndCount.y = (int) atoi(tempBuffer);

						auxSubMesh->textureCoord.push_back(textCoord);
						auxSubMesh->weightsIndex.push_back(weightStartAndCount);
					}
				}
				else if(strncmp(tempBuffer, "numtris", 7) == 0){
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					numTris = (int) atoi(tempBuffer);
					glm::i32vec3 tri;
					auxSubMesh->elements.reserve(numTris);
					for (int i = 0; i < numTris; ++i){
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						tri.x = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						tri.z = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						tri.y = (int) atoi(tempBuffer);
						auxSubMesh->elements.push_back(tri);
					}
				}
				else if(strncmp(tempBuffer, "numweights", 10) == 0){
					copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
					numWeights = (int) atoi(tempBuffer);
					SubMesh::Weight auxWeight;
					auxSubMesh->weights.reserve(numWeights);
					for (int i = 0; i < numWeights; ++i){
						//logInf("Weight[%i]",i);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//weight
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//id (sorted)
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//id joint
						auxWeight.weightJointID = (int) atoi(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//bias
						auxWeight.weightBias = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//'('
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						auxWeight.weightPos.x = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						auxWeight.weightPos.y = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);
						auxWeight.weightPos.z = (float) fast_atof(tempBuffer);
						copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//')'

						auxSubMesh->weights.push_back(auxWeight);
						//logInf("Weight[%i]",i);
					}
				}
				else if(strncmp(tempBuffer, "//", 2) == 0){
					skipLine(buffer, &n);
				}
				copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);

			}
			prepareSubMeshVertex(resultMesh, auxSubMesh);
			prepareSubMeshNormals(resultMesh, auxSubMesh);
			resultMesh->subMeshes.push_back(auxSubMesh);
		}

		copyNextWord(tempBuffer, BUFFERSIZE, buffer, &n);//autoincrease i
        if(n>=lenght)break;

	}
	return resultMesh;
}
コード例 #7
0
NPCConfigFile FileFormats::ReadNpcTXTFile(PGEFILE &inf, bool IgnoreBad)
{
    errorString.clear();
    int str_count=0;        //Line Counter
    //int i;                  //counters
    QString line;           //Current Line data
    QStringList Params;
    QTextStream in(&inf);   //Read File

    in.setAutoDetectUnicode(true); //Test Fix for MacOS
    in.setLocale(QLocale::system()); //Test Fix for MacOS
    in.setCodec(QTextCodec::codecForLocale()); //Test Fix for MacOS

    QString unknownLines;

    NPCConfigFile FileData = CreateEmpytNpcTXTArray();

    //Read NPC.TXT File config

    str_count++;line = in.readLine(); // Read file line
    while(!line.isNull())
    {
       QString ln = line;
       if(line.remove(' ')=="")
       {
           str_count++;line = in.readLine();
           continue;
       } //Skip empty strings

       line=ln;

       Params=line.split("=", QString::SkipEmptyParts); // split the Parameter and value (example: chicken=2)
       if(Params.count() != 2) // If string does not contain strings with "=" as separator
       {
           if(!IgnoreBad)
           {
               unknownLines += QString::number(str_count)+": "+line+" <wrong syntax!>\n";
               str_count++;line = in.readLine();
               continue;
           }
       }

       Params[0] = Params[0].simplified();
       Params[0].remove(' '); //Delete spaces

       if(Params[0]=="gfxoffsetx")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::sInt(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be signed intger!>\n";
           }
           else
           {
               FileData.gfxoffsetx=Params[1].toInt();
               FileData.en_gfxoffsetx=true;
           }
        }
       else
       if(Params[0]=="gfxoffsety")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::sInt(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be signed intger!>\n";
           }
           else
           {
               Params[1] = Params[1].replace(QString(" "), QString("")); //Delete spaces
               FileData.gfxoffsety=Params[1].toInt();
               FileData.en_gfxoffsety=true;
           }
        }
       else
       if(Params[0]=="width")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be unsigned intger!>\n";
           }
           else
           {
               FileData.width=Params[1].toInt();
               FileData.en_width=true;
           }
        }
       else
       if(Params[0]=="height")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
              unknownLines += QString::number(str_count)+": "+line+" <Should be unsigned intger!>\n";
           }
           else
           {
               Params[1] = Params[1].replace(QString(" "), QString("")); //Delete spaces
               FileData.height=Params[1].toInt();
               FileData.en_height=true;
           }
        }
       else
       if(Params[0]=="gfxwidth")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
              unknownLines += QString::number(str_count)+": "+line+" <Should be unsigned intger!>\n";
           }
           else
           {
               FileData.gfxwidth=Params[1].toInt();
               FileData.en_gfxwidth=true;
           }
        }
       else
       if(Params[0]=="gfxheight")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
              unknownLines += QString::number(str_count)+": "+line+" <Should be unsigned intger!>\n";
           }
           else
           {
              FileData.gfxheight=Params[1].toInt();
              FileData.en_gfxheight=true;
           }
        }
       else
       if(Params[0]=="score")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
              unknownLines += QString::number(str_count)+": "+line+" <Should be unsigned intger!>\n";
           }
           else
           {
              FileData.score=Params[1].toInt();
              FileData.en_score=true;
           }
        }
       else
       if(Params[0]=="playerblock")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.playerblock=(bool)Params[1].toInt();
               FileData.en_playerblock=true;
           }
        }
       else
       if(Params[0]=="playerblocktop")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.playerblocktop=(bool)Params[1].toInt();
               FileData.en_playerblocktop=true;
           }
        }
       else
       if(Params[0]=="npcblock")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.npcblock=(bool)Params[1].toInt();
               FileData.en_npcblock=true;
           }
        }
       else
       if(Params[0]=="npcblocktop")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.npcblocktop=(bool)Params[1].toInt();
               FileData.en_npcblocktop=true;
           }
        }
       else
       if(Params[0]=="grabside")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.grabside=(bool)Params[1].toInt();
               FileData.en_grabside=true;
           }
        }
       else
       if(Params[0]=="grabtop")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.grabtop=(bool)Params[1].toInt();
               FileData.en_grabtop=true;
           }
        }
       else
       if(Params[0]=="jumphurt")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.jumphurt=(bool)Params[1].toInt();
               FileData.en_jumphurt=true;
           }
        }
       else
       if(Params[0]=="nohurt")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.nohurt=(bool)Params[1].toInt();
               FileData.en_nohurt=true;
           }
        }
       else
       if(Params[0]=="noblockcollision")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.noblockcollision=(bool)Params[1].toInt();
               FileData.en_noblockcollision=true;
           }
        }
       else
       if(Params[0]=="cliffturn")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.cliffturn=(bool)Params[1].toInt();
               FileData.en_cliffturn=true;
           }
        }
       else
       if(Params[0]=="noyoshi")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.noyoshi=(bool)Params[1].toInt();
               FileData.en_noyoshi=true;
           }
        }
       else
       if(Params[0]=="foreground")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.foreground=(bool)Params[1].toInt();
               FileData.en_foreground=true;
           }
        }
       else
       if(Params[0]=="speed")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::sFloat(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be signed floating point number!>\n";
           }
           else
           {
               FileData.speed=Params[1].replace(QChar(','), QChar('.')).toFloat();
               FileData.en_speed=true;
           }
        }
       else
       if(Params[0]=="nofireball")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.nofireball=(bool)Params[1].toInt();
               FileData.en_nofireball=true;
           }
        }
       else
       if(Params[0]=="nogravity")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.nogravity=(bool)Params[1].toInt();
               FileData.en_nogravity=true;
           }
        }
       else
       if(Params[0]=="frames")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be unsigned intger!>\n";
           }
           else
           {
               FileData.frames=Params[1].toInt();
               FileData.en_frames=true;
           }
        }
       else
       if(Params[0]=="framespeed")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be unsigned intger!>\n";
           }
           else
           {
               FileData.framespeed=Params[1].toInt();
               FileData.en_framespeed=true;
           }
        }
       else
       if(Params[0]=="framestyle")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::uInt(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be from 0 to 3!>\n";
           }
           else
           {
               FileData.framestyle=Params[1].toInt();
               FileData.en_framestyle=true;
           }
        }
       else
       if(Params[0]=="noiceball")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
              unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.noiceball=(bool)Params[1].toInt();
               FileData.en_noiceball=true;
           }
        }
       else // Non-SMBX64 parameters (not working in SMBX <=1.3)
       if(Params[0]=="nohammer")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.nohammer=(bool)Params[1].toInt();
               FileData.en_nohammer=true;
           }
        }
       else
       if(Params[0]=="noshell")
        {
           Params[1] = Params[1].simplified();
           Params[1].remove(' '); //Delete spaces
           if(SMBX64::dBool(Params[1]))
           {
               unknownLines += QString::number(str_count)+": "+line+" <Should be 1 or 0!>\n";
           }
           else
           {
               FileData.noshell=(bool)Params[1].toInt();
               FileData.en_noshell=true;
           }
        }
       else
       if(Params[0]=="name")
        {
           if(!SMBX64::qStr(Params[1]))
               FileData.name = removeQuotes(Params[1]);
           else
               FileData.name = Params[1];
               FileData.en_name=true;
        }
       else
       if(Params[0]=="image")
        {
           if(!SMBX64::qStr(Params[1]))
               FileData.image = removeQuotes(Params[1]);
           else
               FileData.image= Params[1];
               FileData.en_image=true;
        }
       else
       if(Params[0]=="script")
        {
           if(!SMBX64::qStr(Params[1]))
               FileData.script = removeQuotes(Params[1]);
           else
               FileData.script= Params[1];
               FileData.en_script=true;
        }
       else
       {
              //errStr = "Unknown value";
              //if(!IgnoreBad) goto badfile;
           //Store unknown value into warning
           unknownLines += QString::number(str_count)+": "+line+"\n";
       }

    str_count++;line = in.readLine();
    }

    #ifdef PGE_EDITOR
    if(!IgnoreBad)
    {
        if(!unknownLines.isEmpty())
        QMessageBox::warning(MainWinConnect::pMainWin, QTranslator::tr("Unknown values are presented"),
                             QTranslator::tr("Your file have an unknown values which will be removed\n"
                                             " when you will save file")+QString("\n====================================\n%1").arg(unknownLines),
                             QMessageBox::Ok);
    }
    #endif


    FileData.ReadFileValid=true;
    return FileData;

//No more need
    //badfile:    //If file format not corrects
    //BadFileMsg(inf.fileName(), str_count, line+"\n"+Params[0]+"\nReason: "+errStr);
    //FileData.ReadFileValid=false;
    //return FileData;
}
コード例 #8
0
INT IIS_ScanCmdl(INT argc, TEXTCHAR* argv[], const TEXTCHAR* str, ...)
{
    INT i              = 0;
    INT found_and_set  = 0;
    INT nArgs          = 0;
    INT* switches_used = 0;
    INT*   b_str_opt   = 0;
    TEXTCHAR*  s_str       = 0;
    TEXTCHAR*  c_str_type  = 0;
    TEXTCHAR*  str_clean   = 0;

    va_list ap;

    if (argc == 0 || argc == 1)
    {
        FDKprintf("No command line arguments\n");
        goto bail;
    }

    str_clean  = (TEXTCHAR*)  FDKcalloc((unsigned int)_tcslen(str), sizeof(TEXTCHAR));
    if (str_clean == NULL) {
        FDKprintf("Error allocating memory line %d, file %s\n",  __LINE__, __FILE__);
        return 0;
    }

    RemoveWhiteSpace(str, str_clean );
    GetNumberOfArgs(str_clean, &nArgs);

    b_str_opt  = (INT*)   FDKcalloc(nArgs,    sizeof(INT));
    s_str      = (TEXTCHAR*)  FDKcalloc(nArgs*CMDL_MAX_ARGC, sizeof(TEXTCHAR) );
    c_str_type = (TEXTCHAR*)  FDKcalloc(nArgs,    sizeof(TEXTCHAR));
    switches_used = (INT*) FDKcalloc(argc, sizeof(INT));

    if (b_str_opt == NULL || s_str == NULL || c_str_type == NULL || switches_used == NULL) {
        FDKprintf("Error allocating memory line %d, file %s\n",  __LINE__, __FILE__);
        goto bail;
    }

    if ( ParseString( str_clean, b_str_opt, s_str, c_str_type )) {
        goto bail;
    }

    va_start(ap, str);

    for ( i = 0; i < nArgs; i++ )
    {
        TEXTCHAR arg[CMDL_MAX_STRLEN] = {L'\0'};
        TEXTCHAR* p_arg = arg;
        TEXTCHAR* current_str = &(s_str[i*CMDL_MAX_ARGC]);

        if (GetArgFromString(argc, argv, current_str, c_str_type[i], arg, switches_used )
                && !b_str_opt[i] )
        {
#ifdef _UNICODE
            _ftprintf(stderr, _TEXT("\n\nError: Parsing argument for required switch '%ls'.\n" ), current_str);
#else
            _ftprintf(stderr, _TEXT("\n\nError: Parsing argument for required switch '%s'.\n" ), current_str);
#endif
            found_and_set = 0;
            goto bail;
        }
        if (CheckArg(p_arg, s_str, nArgs, c_str_type[i], current_str))
        {
            goto bail;
        }

        switch (c_str_type[i] )
        {
        case 's':
        {
            TEXTCHAR* tmp;
            tmp = va_arg(ap, TEXTCHAR*);

            if ( arg[0] == '\0' )
                break;

            _tcsncpy( tmp, arg, CMDL_MAX_STRLEN );
            /* Remove quotes. Windows Mobile Workaround. */
            removeQuotes(tmp);
            found_and_set++;
            break;
        }
        case 'd':
        {
            INT* tmp = va_arg(ap, INT*);

            if ( arg[0] == '\0' )
                break;

            *tmp = _tcstol(arg, NULL, 0);
            found_and_set++;
            break;
        }
        case 'c':
        {
            char* tmp = va_arg(ap, char*);

            if ( arg[0] == '\0' )
                break;

            *tmp = *arg;
            found_and_set++;
            break;
        }
        case 'u':
        {
            UCHAR* tmp = va_arg(ap, UCHAR*);

            if ( arg[0] == '\0' )
                break;

            *tmp = _tstoi(arg);
            found_and_set++;
            break;
        }
        case 'f':
        {
            float* tmp = (float*) va_arg( ap,double*);

            if ( arg[0] == '\0' )
                break;

            *tmp = (float) _tstof(arg);
            found_and_set++;
            break;
        }
        case 'y': // support 'data type double'
        {
            double* tmp = (double*) va_arg( ap,double*);
            // use sscanf instead _tstof because of gcc
            //_tstof(arg,"%lf",tmp); // '%lf' reads as double
            *tmp = _tstof(arg); // '%lf' reads as double
            found_and_set++;
            break;
        }
        case '1':
        {

            INT* tmp = va_arg( ap, INT*);

            if ( arg[0] == '\0' )
                break;

            *tmp = 1;
            found_and_set++;
            break;
        }

        default:
            FDKprintfErr("Bug: unsupported data identifier \"%c\"\n", c_str_type[i]);
            break;

        }

    }

    va_end(ap);

    CheckForUnusedSwitches(argc, /*argv,*/ switches_used);

bail:
    if (b_str_opt)     FDKfree(b_str_opt);
    if (s_str)         FDKfree(s_str);
    if (c_str_type)    FDKfree(c_str_type);
    if (str_clean)     FDKfree(str_clean);
    if (switches_used) FDKfree(switches_used);

    return found_and_set;
}
コード例 #9
0
ファイル: file_wld.cpp プロジェクト: hacheipe399/PlatGEnWohl
WorldData FileFormats::ReadSMBX64WldFile(QString RawData, QString filePath)
{
    FileStringList in;
    in.addData( RawData );

    int str_count=0;        //Line Counter
    int file_format=0;        //File format number
    QString line;           //Current Line data

    WorldData FileData = dummyWldDataArray();

    //Add path data
    if(!filePath.isEmpty())
    {
        QFileInfo in_1(filePath);
        FileData.filename = in_1.baseName();
        FileData.path = in_1.absoluteDir().absolutePath();
    }

    FileData.untitled = false;
    FileData.modified = false;

    //Enable strict mode for SMBX WLD file format
    FileData.smbx64strict = true;

    WorldTiles tile;
    WorldScenery scen;
    WorldPaths pathitem;
    WorldLevels lvlitem;
    WorldMusic musicbox;

    str_count++;line = in.readLine();   //Read first Line
    if( SMBX64::Int(line) ) //File format number
        goto badfile;
    else file_format=line.toInt();

    str_count++;line = in.readLine();
    if( SMBX64::qStr(line) ) //Episode name
        goto badfile;
    else FileData.EpisodeTitle = removeQuotes(line);

    if(file_format >= 55)
    {
        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Mario
            goto badfile;
        else FileData.nocharacter1 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Luigi
            goto badfile;
        else FileData.nocharacter2 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Peach
            goto badfile;
        else FileData.nocharacter3 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Toad
            goto badfile;
        else FileData.nocharacter4 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Link
            goto badfile;
        else FileData.nocharacter5 = SMBX64::wBoolR(line);

        //Convert into the bool array
        FileData.nocharacter<<
             FileData.nocharacter1<<
             FileData.nocharacter2<<
             FileData.nocharacter3<<
             FileData.nocharacter4<<
             FileData.nocharacter5;


    }

    if(file_format >= 10)
    {
        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Autostart level
            goto badfile;
        else FileData.IntroLevel_file = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Don't use world map on this episode
            goto badfile;
        else FileData.HubStyledWorld = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Restart level on playable character's death
            goto badfile;
        else FileData.restartlevel = SMBX64::wBoolR(line);
    }

    if(file_format >= 20)
    {
        str_count++;line = in.readLine();
        if( SMBX64::Int(line) ) //Stars quantity
            goto badfile;
        else FileData.stars = line.toInt();
    }

    if(file_format >= 10)
    {
        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 1
            goto badfile;
        else FileData.author1 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 2
            goto badfile;
        else FileData.author2 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 3
            goto badfile;
        else FileData.author3 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 4
            goto badfile;
        else FileData.author4 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 5
            goto badfile;
        else FileData.author5 = removeQuotes(line);

        FileData.authors.clear();
        FileData.authors += (FileData.author1.isEmpty())? "" : FileData.author1+"\n";
        FileData.authors += (FileData.author2.isEmpty())? "" : FileData.author2+"\n";
        FileData.authors += (FileData.author3.isEmpty())? "" : FileData.author3+"\n";
        FileData.authors += (FileData.author4.isEmpty())? "" : FileData.author4+"\n";
        FileData.authors += (FileData.author5.isEmpty())? "" : FileData.author5;
    }


    ////////////Tiles Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        tile = dummyWldTile();
        if(SMBX64::sInt(line)) //Tile x
            goto badfile;
        else tile.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Tile y
            goto badfile;
        else tile.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Tile ID
            goto badfile;
        else tile.id = line.toInt();

        tile.array_id = FileData.tile_array_id;
        FileData.tile_array_id++;
        tile.index = FileData.tiles.size(); //Apply element index

        FileData.tiles.push_back(tile);

        str_count++;line = in.readLine();
    }

    ////////////Scenery Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        scen = dummyWldScen();
        if(SMBX64::sInt(line)) //Scenery x
            goto badfile;
        else scen.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Scenery y
            goto badfile;
        else scen.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Scenery ID
            goto badfile;
        else scen.id = line.toInt();

        scen.array_id = FileData.scene_array_id;
        FileData.scene_array_id++;
        scen.index = FileData.scenery.size(); //Apply element index

        FileData.scenery.push_back(scen);

        str_count++;line = in.readLine();
    }

    ////////////Paths Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        pathitem = dummyWldPath();
        if(SMBX64::sInt(line)) //Path x
            goto badfile;
        else pathitem.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Path y
            goto badfile;
        else pathitem.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Path ID
            goto badfile;
        else pathitem.id = line.toInt();

        pathitem.array_id = FileData.path_array_id;
        FileData.path_array_id++;
        pathitem.index = FileData.paths.size(); //Apply element index

        FileData.paths.push_back(pathitem);

        str_count++;line = in.readLine();
    }

    ////////////LevelBox Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        lvlitem = dummyWldLevel();

        if(SMBX64::sInt(line)) //Level x
            goto badfile;
        else lvlitem.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Level y
            goto badfile;
        else lvlitem.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Level ID
            goto badfile;
        else lvlitem.id = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::qStr(line)) //Level file
            goto badfile;
        else lvlitem.lvlfile = removeQuotes(line);

        str_count++;line = in.readLine();
        if(SMBX64::qStr(line)) //Level title
            goto badfile;
        else lvlitem.title = removeQuotes(line);

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Top exit
            goto badfile;
        else lvlitem.top_exit = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Left exit
            goto badfile;
        else lvlitem.left_exit = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //bottom exit
            goto badfile;
        else lvlitem.bottom_exit = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //right exit
            goto badfile;
        else lvlitem.right_exit = line.toInt();

        if(file_format >= 10)
        {
            str_count++;line = in.readLine();
            if(SMBX64::Int(line)) //Enter via Level's warp
                goto badfile;
            else lvlitem.entertowarp = line.toInt();
        }

        if(file_format >= 28)
        {
            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Always Visible
                goto badfile;
            else lvlitem.alwaysVisible = SMBX64::wBoolR(line);

            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Path background
                goto badfile;
            else lvlitem.pathbg = SMBX64::wBoolR(line);

            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Game start point
                goto badfile;
            else lvlitem.gamestart = SMBX64::wBoolR(line);

            str_count++;line = in.readLine();
            if(SMBX64::sInt(line)) //Goto x on World map
                goto badfile;
            else lvlitem.gotox = line.toInt();

            str_count++;line = in.readLine();
            if(SMBX64::sInt(line)) //Goto y on World map
                goto badfile;
            else lvlitem.gotoy = line.toInt();

            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Big Path background
                goto badfile;
            else lvlitem.bigpathbg = SMBX64::wBoolR(line);
        }

        lvlitem.array_id = FileData.level_array_id;
        FileData.level_array_id++;
        lvlitem.index = FileData.levels.size(); //Apply element index

        FileData.levels.push_back(lvlitem);

        str_count++;line = in.readLine();
    }

    ////////////MusicBox Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        musicbox = dummyWldMusic();
        if(SMBX64::sInt(line)) //MusicBox x
            goto badfile;
        else musicbox.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //MusicBox y
            goto badfile;
        else musicbox.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //MusicBox ID
            goto badfile;
        else musicbox.id = line.toInt();

        musicbox.array_id = FileData.musicbox_array_id;
        FileData.musicbox_array_id++;
        musicbox.index = FileData.music.size(); //Apply element index

        FileData.music.push_back(musicbox);

        str_count++;line = in.readLine();
    }


    str_count++;line = in.readLine(); // Read last line

    if((line!="")&&(!line.isNull()))
        goto badfile;


FileData.ReadFileValid=true;

return FileData;

badfile:    //If file format not corrects
    BadFileMsg(FileData.path, str_count, line);
    FileData.ReadFileValid=false;
return FileData;
}
コード例 #10
0
ファイル: turtle.c プロジェクト: kevinqmcdonald/shellproject
char * cleanInput( char * in ) {
	return expandTilde( expandEnv( removeQuotes( in ) ) );
}
コード例 #11
0
ファイル: AppendToFile.c プロジェクト: jgrossmann/security3
/*
	Takes a string path and collapses it to find the
	absolute path without "." or ".."
*/
node *collapseFilePath(char *path) {
	
	int isQuoted = quotedString(path);
	if(isQuoted == -1) {
		printf("Error: File Path string not closed\n");
		return NULL;
	}
	
	node *currentNode = NULL;
	
	char *checkedStr = NULL;
	if(!isQuoted) {
		currentNode = getCurrentPath();
		checkedStr = parseString(path);
		if(checkedStr == NULL) {
			freePathReverse(currentNode);
			return NULL;
		}
		
		char *temp = (char *) malloc(strlen(checkedStr) + 8);
		if(temp == NULL) {
			printf("ERROR: No memory left to append uni to file path\n");
			freePathReverse(currentNode);
			return NULL;
		}
		strncpy(temp, checkedStr, strlen(checkedStr) + 1);
		strncat(temp, ".jg3538", 8);
		currentNode = insertNode(currentNode, temp);
		free(temp);
	}else {
	
		if(path[1] != '/') {
			currentNode = getCurrentPath();
		}
	
		path = removeQuotes(path);
		char temp[strlen(path)+1];
		strncpy(temp, path, strlen(path)+1);
		char *base = basename(temp);
		if(strncmp(base, "..", 3) == 0 && strlen(base) == 2) {
			path = (char *) realloc(path, strlen(path) + 9);
			if(path == NULL) {
				printf("ERROR: No memory left to append uni to file path\n");
				freePathReverse(currentNode);
				return NULL;
			}
			strncat(path, "/.jg3538", 8);
		}else {
			path = (char *) realloc(path, strlen(path) + 8);
			if(path == NULL) {
				printf("ERROR: No memory left to append uni to file path\n");
				freePathReverse(currentNode);
				return NULL;
			}
			strncat(path, ".jg3538", 8);
		}
		
		char *token = strtok(path, "/");
	
		while(token != NULL) {
			checkedStr = parseQuotedString(token);
		
			if(checkedStr == NULL) {
				freePathReverse(currentNode);
				free(path);
				return NULL;
			}
		
			currentNode = insertNode(currentNode, checkedStr);
			free(checkedStr);
			token = strtok(NULL, "/");
		}
		
		free(path);
	}

	while(currentNode->prev != NULL) {
		currentNode = currentNode->prev;
	}
	
	return currentNode;
}
コード例 #12
0
ファイル: tables.c プロジェクト: trafodion/tests
PassFail TestMXSQLTables (TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	TCHAR			Heading[MAX_HEADING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt, hstmt1;
	TCHAR			TableQualifier[NAME_LEN],TableOwner[NAME_LEN],Remark[REM_LEN],*TableStr;
	TCHAR			oTableQualifier[NAME_LEN];
	TCHAR			oTableOwner[NAME_LEN];
	TCHAR			oTableName[NAME_LEN];
	TCHAR			oTableType[NAME_LEN];
	TCHAR			oRemark[REM_LEN];
	SQLLEN			oTableQualifierlen,oTableOwnerlen,oTableNamelen,oTableTypelen,oRemarklen;

	int				cols, iatt;
	SWORD numOfCols = 0;
	SWORD pcbDesc;
	SQLLEN pfDesc;
	TCHAR cn[TabType_LEN];
	SWORD cl;
	SWORD st;
	SQLULEN cp;
	SWORD cs, cnull;
	TCHAR rgbDesc[RGB_MAX_LEN];
	TCHAR *CharOutput[12];
	SQLLEN stringlength;
	struct
	{
		TCHAR		*TableName;
		TCHAR		*TableType;
		TCHAR		*TableTypeIn;
	} Table[] = {
							{_T("--")	,_T("TABLE")	,_T("")},
							{_T("--")	,_T("TABLE")	,_T("TABLE")},
							{_T("--")	,_T("TABLE")	,_T("TABLE,VIEW,SYSTEM TABLE")}, 
							{_T("--")	,_T("TABLE")	,_T("TABLE,SYSTEM TABLE,VIEW")},
							{_T("--")	,_T("TABLE")	,_T("TABLE,VIEW,SYSTEM TABLE,SYNONYM,MV,MVG")},
							{_T("--")	,_T("VIEW"),_T("VIEW")},
							{_T("--")	,_T("VIEW"),_T("TABLE,VIEW,SYSTEM TABLE")},
							{_T("--")	,_T("MATERIALIZED VIEW"),_T("")}, 
							{_T("--")	,_T("MATERIALIZED VIEW"),_T("MV")},
							{_T("--")	,_T("SYNONYM"),_T("")}, 
							{_T("--")	,_T("SYNONYM"),_T("SYNONYM")},
							{_T("endloop"),}
					};

	struct
	{
		TCHAR		*TabQua;
		TCHAR		*TabOwner;
		TCHAR		*TabName;
		TCHAR		*TabType;
		int			changedSchema;
	} TableWC[] = 
						{		
							{_T(SQL_ALL_CATALOGS),_T("")			,_T("--")	,_T("")						,-1},		//0
							{_T("")				,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("")						,-1},		//1
							{_T("")				,_T("")				,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//2
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//3
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//4
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//5
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//6
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//7
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//8
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//9
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//10
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//11
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//12
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//13
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//14
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//15
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//16
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//17
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//18
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//19
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//20
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//21
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//22
							{pTestInfo->Catalog	,_T(SQL_ALL_SCHEMAS),_T("--")	,_T("TABLE")				,-1},		//23
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//24
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//25
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T("TABLE")				,1},		//26
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("VIEW")					,-1},		//27
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//28
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,-1},		//29
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//30
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("VIEW")					,-1},		//31
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//32
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//33
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//34
							{_T("NULL")			,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//35
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//36
							{pTestInfo->Catalog	,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//37
							{_T("NULL")			,_T("--")			,_T("--")	,_T("TABLE")				,0},		//38
							{_T("NULL")			,pTestInfo->Schema	,_T("--")	,_T("TABLE")				,-1},		//39
							{_T("NULL")			,_T("NULL")			,_T("--")	,_T("TABLE")				,-1},		//40
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,0},		//41
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,0},		//42
							{pTestInfo->Catalog	,_T("--")			,_T("--")	,_T(SQL_ALL_TABLE_TYPES)	,2},		//43
							{_T("endloop"),}
						};	

	struct
	{
		TCHAR		*TabQua;
		SWORD		TabQuaLen;
		TCHAR		*TabOwner;
		SWORD		TabOwnerLen;
		TCHAR		*TabName;
		SWORD		TabNameLen;
		TCHAR		*TabType;
		SWORD		TabTypeLen;
	} TableWC2[] = {		// wild cards from here
							{pTestInfo->Catalog, (SWORD)-1, pTestInfo->Schema,(SWORD)-1, _T("--"),(SWORD)-1, _T(""), (SWORD)-1},
							//{pTestInfo->Catalog, (SWORD)4, pTestInfo->Schema,(SWORD)2, "OBJECTS",(SWORD)2, _T(""), (SWORD)2},
							//{pTestInfo->Catalog, (SWORD)3, pTestInfo->Schema,(SWORD)7, "OBJECTS",(SWORD)3, _T(""), (SWORD)0},
							{_T("endloop"),}
						};
	//attributes for columns added for negative testing
	UWORD DescrType[] = 
				{
					SQL_COLUMN_AUTO_INCREMENT,SQL_COLUMN_CASE_SENSITIVE,SQL_COLUMN_COUNT,
					SQL_COLUMN_DISPLAY_SIZE,SQL_COLUMN_LENGTH,SQL_COLUMN_MONEY,
					SQL_COLUMN_NULLABLE,SQL_COLUMN_PRECISION,SQL_COLUMN_SCALE,
					SQL_COLUMN_SEARCHABLE,SQL_COLUMN_TYPE,SQL_COLUMN_UNSIGNED,
					SQL_COLUMN_UPDATABLE,SQL_COLUMN_NAME,SQL_COLUMN_TYPE_NAME,
					SQL_COLUMN_OWNER_NAME,SQL_COLUMN_QUALIFIER_NAME,SQL_COLUMN_TABLE_NAME,
					SQL_COLUMN_LABEL
				};

    struct {
        TCHAR cat[STR_LEN];
        TCHAR sch[STR_LEN];
        TCHAR tab[STR_LEN];
        TCHAR typ[STR_LEN];
    } displayBuf;
	
	int	i = 0, k = 0, NullValue = 0;
	TCHAR tmpSchema[129];
	TCHAR schemaList[3][256];
	int myInd=1;
	int len = _tcslen(pTestInfo->Schema);

	TCHAR *CrtCol[] = { _T("--"), _T("--") };
	TCHAR *DrpTab[] = { _T("--"), _T("--"), _T("--")};
	TCHAR *CrtTab[] = { _T("--"), _T("--"), _T("--")};

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLTables"), charset_file);
	if (var_list == NULL) return FAILED;

	Table[0].TableName = var_mapping(_T("SQLTables_Table_TableName_0"), var_list);
	Table[1].TableName = var_mapping(_T("SQLTables_Table_TableName_1"), var_list);
	Table[2].TableName = var_mapping(_T("SQLTables_Table_TableName_2"), var_list);
	Table[3].TableName = var_mapping(_T("SQLTables_Table_TableName_3"), var_list);
	Table[4].TableName = var_mapping(_T("SQLTables_Table_TableName_4"), var_list);
	Table[5].TableName = var_mapping(_T("SQLTables_Table_TableName_5"), var_list);
	Table[6].TableName = var_mapping(_T("SQLTables_Table_TableName_6"), var_list);
	Table[7].TableName = var_mapping(_T("SQLTables_Table_TableName_7"), var_list);
	Table[8].TableName = var_mapping(_T("SQLTables_Table_TableName_8"), var_list);
	Table[9].TableName = var_mapping(_T("SQLTables_Table_TableName_9"), var_list);
	Table[10].TableName = var_mapping(_T("SQLTables_Table_TableName_10"), var_list);
	
	TableWC[10].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_10"), var_list);
	TableWC[11].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_11"), var_list);
	TableWC[22].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_22"), var_list);
	TableWC[24].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_24"), var_list);
	TableWC[26].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_26"), var_list);
	TableWC[38].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_38"), var_list);
	TableWC[41].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_10"), var_list);
	TableWC[42].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_41"), var_list);
	TableWC[43].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_43"), var_list);

	TableWC[0].TabName = var_mapping(_T("SQLTables_TableWC_TabName_0"), var_list);
	TableWC[1].TabName = var_mapping(_T("SQLTables_TableWC_TabName_1"), var_list);
	TableWC[2].TabName = var_mapping(_T("SQLTables_TableWC_TabName_2"), var_list);
	TableWC[3].TabName = var_mapping(_T("SQLTables_TableWC_TabName_3"), var_list);
	TableWC[4].TabName = var_mapping(_T("SQLTables_TableWC_TabName_4"), var_list);
	TableWC[5].TabName = var_mapping(_T("SQLTables_TableWC_TabName_5"), var_list);
	TableWC[6].TabName = var_mapping(_T("SQLTables_TableWC_TabName_6"), var_list);
	TableWC[7].TabName = var_mapping(_T("SQLTables_TableWC_TabName_7"), var_list);
	TableWC[8].TabName = var_mapping(_T("SQLTables_TableWC_TabName_8"), var_list);
	TableWC[9].TabName = var_mapping(_T("SQLTables_TableWC_TabName_9"), var_list);
	TableWC[10].TabName = var_mapping(_T("SQLTables_TableWC_TabName_10"), var_list);
	TableWC[11].TabName = var_mapping(_T("SQLTables_TableWC_TabName_11"), var_list);
	TableWC[12].TabName = var_mapping(_T("SQLTables_TableWC_TabName_12"), var_list);
	TableWC[13].TabName = var_mapping(_T("SQLTables_TableWC_TabName_13"), var_list);
	TableWC[14].TabName = var_mapping(_T("SQLTables_TableWC_TabName_14"), var_list);
	TableWC[15].TabName = var_mapping(_T("SQLTables_TableWC_TabName_15"), var_list);
	TableWC[16].TabName = var_mapping(_T("SQLTables_TableWC_TabName_16"), var_list);
	TableWC[17].TabName = var_mapping(_T("SQLTables_TableWC_TabName_17"), var_list);
	TableWC[18].TabName = var_mapping(_T("SQLTables_TableWC_TabName_18"), var_list);
	TableWC[19].TabName = var_mapping(_T("SQLTables_TableWC_TabName_19"), var_list);
	TableWC[20].TabName = var_mapping(_T("SQLTables_TableWC_TabName_20"), var_list);
	TableWC[21].TabName = var_mapping(_T("SQLTables_TableWC_TabName_21"), var_list);
	TableWC[22].TabName = var_mapping(_T("SQLTables_TableWC_TabName_22"), var_list);
	TableWC[23].TabName = var_mapping(_T("SQLTables_TableWC_TabName_23"), var_list);
	TableWC[24].TabName = var_mapping(_T("SQLTables_TableWC_TabName_24"), var_list);
	TableWC[25].TabName = var_mapping(_T("SQLTables_TableWC_TabName_25"), var_list);
	TableWC[26].TabName = var_mapping(_T("SQLTables_TableWC_TabName_26"), var_list);
	TableWC[27].TabName = var_mapping(_T("SQLTables_TableWC_TabName_27"), var_list);
	TableWC[28].TabName = var_mapping(_T("SQLTables_TableWC_TabName_28"), var_list);
	TableWC[29].TabName = var_mapping(_T("SQLTables_TableWC_TabName_29"), var_list);
	TableWC[30].TabName = var_mapping(_T("SQLTables_TableWC_TabName_30"), var_list);
	TableWC[31].TabName = var_mapping(_T("SQLTables_TableWC_TabName_31"), var_list);
	TableWC[32].TabName = var_mapping(_T("SQLTables_TableWC_TabName_32"), var_list);
	TableWC[33].TabName = var_mapping(_T("SQLTables_TableWC_TabName_33"), var_list);
	TableWC[34].TabName = var_mapping(_T("SQLTables_TableWC_TabName_34"), var_list);
	TableWC[35].TabName = var_mapping(_T("SQLTables_TableWC_TabName_35"), var_list);
	TableWC[36].TabName = var_mapping(_T("SQLTables_TableWC_TabName_36"), var_list);
	TableWC[37].TabName = var_mapping(_T("SQLTables_TableWC_TabName_37"), var_list);
	TableWC[38].TabName = var_mapping(_T("SQLTables_TableWC_TabName_38"), var_list);
	TableWC[39].TabName = var_mapping(_T("SQLTables_TableWC_TabName_39"), var_list);
	TableWC[40].TabName = var_mapping(_T("SQLTables_TableWC_TabName_40"), var_list);
	TableWC[41].TabName = var_mapping(_T("SQLTables_TableWC_TabName_41"), var_list);
	TableWC[42].TabName = var_mapping(_T("SQLTables_TableWC_TabName_42"), var_list);
	TableWC[43].TabName = var_mapping(_T("SQLTables_TableWC_TabName_43"), var_list);

	TableWC2[0].TabName = var_mapping(_T("SQLTables_TableWC2_TabName_0"), var_list);

	CrtCol[0] = var_mapping(_T("SQLTables_CrtCol_0"), var_list);
	CrtCol[1] = var_mapping(_T("SQLTables_CrtCol_1"), var_list);

	DrpTab[0] = var_mapping(_T("SQLTables_DrpTab_0"), var_list);
	DrpTab[1] = var_mapping(_T("SQLTables_DrpTab_1"), var_list);
	DrpTab[2] = var_mapping(_T("SQLTables_DrpTab_2"), var_list);

	CrtTab[0] = var_mapping(_T("SQLTables_CrtTab_0"), var_list);
	CrtTab[1] = var_mapping(_T("SQLTables_CrtTab_1"), var_list);
	CrtTab[2] = var_mapping(_T("SQLTables_CrtTab_2"), var_list);
//===========================================================================================================

	memset(schemaList[0],'\0', 256*sizeof(TCHAR));
	memset(schemaList[1],'\0', 256*sizeof(TCHAR));
	memset(schemaList[2],'\0', 256*sizeof(TCHAR));

	myInd = len - 2;
	if (len>5) myInd=4;

/*
#ifndef UNICODE
	if (_tcscmp("English", _tsetlocale(LC_ALL, _T(""))) != 0) {
		_mbsncpy(schemaList[0],pTestInfo->Schema,myInd);
		_mbscat(schemaList[0], "%");

		_mbsncpy(schemaList[1],pTestInfo->Schema,myInd+1);
		_mbscat(schemaList[1], "%");
	}
	else {
#endif
*/
		_tcsncpy(schemaList[0],pTestInfo->Schema,myInd);
		_tcscat(schemaList[0], _T("%"));

		_tcsncpy(schemaList[1],pTestInfo->Schema,myInd+1);
		_tcscat(schemaList[1], _T("%"));
/*
#ifndef UNICODE
	}
#endif
*/

	len = 0; myInd = 0;
	do {
		if (pTestInfo->Schema[myInd] == '_')
			schemaList[2][len++] = '\\';
		schemaList[2][len++] = pTestInfo->Schema[myInd];
	} while (pTestInfo->Schema[myInd++] != '\0');

    LogMsg(NONE,_T("%s %s %s\n"), schemaList[0], schemaList[1], schemaList[2]);

	if (isCharSet) {
		_stprintf(tmpSchema, _T("\"SQLTABLES_%s\""), pTestInfo->Schema);
	}
	else {
		_stprintf(tmpSchema, _T("SQLTABLES_%s"), pTestInfo->Schema);
	}
	_tcsupr(tmpSchema);
//======================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX SPECIFIC SQLTables.\n"));

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLTables tests\n");
	// for ODBC 3.0
	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,_T("Unable to connect as ODBC3.0 application.\n"));
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		LogMsg(NONE,_T("Allocate a stmt handle successfully.\n"));
	}

   TESTCASE_END;

   _tcscpy(pTestInfo->Catalog, _T("TRAFODION"));
	if (returncode == SQL_SUCCESS)
	{
        _stprintf(Heading,_T("drop schema %s.%s cascade"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
        _stprintf(Heading,_T("create schema %s.%s"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

        _stprintf(Heading,_T("set schema %s.%s"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

		_tcscpy(TableQualifier,pTestInfo->Catalog);
		_tcscpy(TableOwner, tmpSchema);
		_tcscpy(Remark,_T(""));
		TableStr = (TCHAR *)malloc(MAX_NOS_SIZE);

		i = 0;
		while (_tcsicmp(Table[i].TableName,_T("endloop")) != 0) // cleanup 
		{
			_tcscpy(TableStr,_T(""));
			_tcscat(TableStr,_T("drop "));
			_tcscat(TableStr,Table[i].TableType);
			_tcscat(TableStr,_T(" "));
			_tcscat(TableStr,Table[i].TableName);
			_tcscat(TableStr,_T(" cascade"));
			LogMsg(NONE,_T("Cleanup: %s\n"),TableStr);
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*) TableStr,SQL_NTS);
			i++;
		}
		
		i = 0;
		while (_tcsicmp(Table[i].TableName,_T("endloop")) != 0)
		{
			_tcscpy(TableStr,_T(""));
			_tcscat(TableStr,_T("create "));
			_tcscat(TableStr,Table[i].TableType);
			_tcscat(TableStr,_T(" "));
			_tcscat(TableStr,Table[i].TableName);
			if (_tcsicmp(Table[i].TableType,_T("VIEW")) == 0) {
				_tcscat(TableStr,CrtCol[1]);
				_tcscat(TableStr, Table[0].TableName);
			}
			else if (_tcsicmp(Table[i].TableType,_T("MATERIALIZED VIEW")) == 0) {
				_tcscat(TableStr, _T(" REFRESH ON REQUEST INITIALIZE ON REFRESH "));
				_tcscat(TableStr,CrtCol[1]);
				_tcscat(TableStr, Table[0].TableName); 
			}
			else if (_tcsicmp(Table[i].TableType,_T("SYNONYM")) == 0) {
				_tcscat(TableStr, _T(" FOR "));
				_tcscat(TableStr, Table[0].TableName);
			}
			else
			{
				_tcscat(TableStr,CrtCol[0]);
			}
		
			_stprintf(Heading,_T("SQLTables: Test %d: using the following table create command=> \n"),i);
			_tcscat(Heading,TableStr);
			_tcscat(Heading,_T("\n"));
			TESTCASE_BEGINW(Heading);
			
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)TableStr,SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				LogMsg(NONE,_T("Created table successfully.\n"));
			}

			if(isCharSet) {
				returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_TRUE,0);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
			}
			
			if (returncode == SQL_SUCCESS)
			{
				if (_tcslen(TableQualifier) > 0)
					returncode = SQLTables(hstmt,(SQLTCHAR*)TableQualifier,(SWORD)_tcslen(TableQualifier),(SQLTCHAR*)TableOwner,(SWORD)_tcslen(TableOwner),(SQLTCHAR*)Table[i].TableName,(SWORD)_tcslen(Table[i].TableName),(SQLTCHAR*)Table[i].TableTypeIn,(SWORD)_tcslen(Table[i].TableTypeIn));
				else
					returncode = SQLTables(hstmt,NULL,(SWORD)_tcslen(TableQualifier),(SQLTCHAR*)TableOwner,(SWORD)_tcslen(TableOwner),(SQLTCHAR*)Table[i].TableName,(SWORD)_tcslen(Table[i].TableName),(SQLTCHAR*)Table[i].TableTypeIn,(SWORD)_tcslen(Table[i].TableTypeIn));
				
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTables"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				else
				{
					LogMsg(NONE,_T("Call to SQLTables() executed successfully.\n"));
					
					_tcscpy(oTableQualifier,_T(""));
					_tcscpy(oTableOwner,_T(""));
					_tcscpy(oTableName,_T(""));
					_tcscpy(oTableType,_T(""));
					_tcscpy(oRemark,_T(""));
					returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
				   returncode=SQLBindCol(hstmt,2,SQL_C_TCHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					returncode=SQLBindCol(hstmt,3,SQL_C_TCHAR,oTableName,NAME_LEN,&oTableNamelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
				   returncode=SQLBindCol(hstmt,4,SQL_C_TCHAR,oTableType,NAME_LEN,&oTableTypelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					returncode=SQLBindCol(hstmt,5,SQL_C_TCHAR,oRemark,NAME_LEN,&oRemarklen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}

					k = 0;
					while (returncode == SQL_SUCCESS)
					{
						returncode = SQLFetch(hstmt);
						if((returncode != SQL_NO_DATA_FOUND)&&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
						{
							LogAllErrors(henv,hdbc,hstmt);
							TEST_FAILED;
						}
						else if (returncode == SQL_SUCCESS)
						{
							if (_tcslen(TableQualifier) == 0)
							{
								//_tcscpy(TableQualifier, _T("TRAFODION"));
								_tcscpy(TableQualifier, _T("TRAFODION"));
							}
							if ((_tcsicmp(TableQualifier,oTableQualifier) == 0) 
								&& (cwcscmp(TableOwner,oTableOwner,TRUE) == 0) 
								&& (cwcscmp(Table[i].TableName,oTableName,TRUE) == 0) 
								&& (_tcsnicmp(Table[i].TableType,oTableType,_tcslen(Table[i].TableType)) == 0) 
								&& (_tcsicmp(Remark,oRemark) == 0))
							{
								LogMsg(NONE,_T("TableQualifier expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)TableQualifier,oTableQualifier);
								LogMsg(NONE,_T("TableOwner expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)TableOwner,oTableOwner);
								LogMsg(NONE,_T("TableName expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)Table[i].TableName,oTableName);
								LogMsg(NONE,_T("TableType expect: '%s' and actual: '%s' are matched\n"),Table[i].TableType,oTableType);
								LogMsg(NONE,_T("Remark expect: '%s' and actual: '%s' are matched\n"),Remark,oRemark);
							}	
							else
							{
								TEST_FAILED;	
								if (_tcsicmp(TableQualifier,oTableQualifier) != 0)
									LogMsg(ERRMSG,_T("TableQualifier expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)TableQualifier,oTableQualifier);
								if (cwcscmp(TableOwner,oTableOwner,TRUE) != 0) 
									LogMsg(ERRMSG,_T("TableOwner expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)TableOwner,oTableOwner);
								if (cwcscmp(Table[i].TableName,oTableName,TRUE) != 0) 
									LogMsg(ERRMSG,_T("TableName expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)Table[i].TableName,oTableName);
								if (_tcsnicmp(Table[i].TableType,oTableType,10) != 0) 
									LogMsg(ERRMSG,_T("TableType expect: '%s' and actual: '%s' are not matched\n"),Table[i].TableType,oTableType);
								if (_tcsicmp(Remark,oRemark) != 0) 
									LogMsg(ERRMSG,_T("Remark expect: '%s' and actual: '%s' are not matched\n"),Remark,oRemark);
							}

							k++;
						}
					}//End while loop

					if(k != 1)
					{
						TEST_FAILED;
						LogMsg(ERRMSG,_T("Only one row should be fetched, the actual number of rows fetched: %d\n"), k);
					} else {
						LogMsg(NONE, _T("Number of rows fetched: %d\n"), k);
					}
				}
				SQLFreeStmt(hstmt,SQL_UNBIND);
				SQLFreeStmt(hstmt,SQL_CLOSE);
			}
			TESTCASE_END;
			i++;
		}
//		i = 0;
//		while (_tcsicmp(Table[i].TableName,"endloop") != 0) // cleanup
//		{
//			_tcscpy(TableStr,_T(""));
//			_tcscat(TableStr,"drop ");
//			_tcscat(TableStr,Table[i].TableType);
//			_tcscat(TableStr," ");
//			_tcscat(TableStr,Table[i].TableName);
//			SQLExecDirect(hstmt,(SQLTCHAR*) TableStr,SQL_NTS);
//			i++;
//		}

        _stprintf(Heading,_T("drop schema %s.%s cascade"),pTestInfo->Catalog,tmpSchema);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

		if (isCharSet) {
			_stprintf(Heading,_T("set schema %s.\"%s\""),pTestInfo->Catalog,pTestInfo->Schema);
		}
		else {
			_stprintf(Heading,_T("set schema %s.%s"),pTestInfo->Catalog,pTestInfo->Schema);
		}
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

//======================================================================================================
		_stprintf(Heading,_T("Setting up Table & view to test SQLTables for wildcard options => \n"));
		_tcscat(Heading,_T("\n"));
		TESTCASE_BEGINW(Heading);
		SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[0],SQL_NTS);
		SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[1],SQL_NTS);
		SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[2],SQL_NTS);
		LogMsg(NONE,_T("%s\n"), CrtTab[0]);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[0],SQL_NTS);

		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		else
		{
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[1],SQL_NTS);
			LogMsg(NONE,_T("%s\n"), CrtTab[1]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				LogMsg(NONE,_T("setting up tables & views executed successfully.\n"));
				TESTCASE_END;
			}
		}
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[2],SQL_NTS);
		LogMsg(NONE,_T("%s\n"), CrtTab[2]);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		i = 0;
		while (_tcsicmp(TableWC[i].TabQua,_T("endloop")) != 0)
		{
			if(TableWC[i].changedSchema == -1) {
				printSymbol(TableWC[i].TabQua,displayBuf.cat);
                printSymbol(TableWC[i].TabOwner,displayBuf.sch);
				printSymbol(TableWC[i].TabName,displayBuf.tab);
                printSymbol(TableWC[i].TabType,displayBuf.typ);

				_stprintf(Heading,_T("Test Positive Functionality of SQLTables for following wildcard options => \n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"),
				displayBuf.cat, displayBuf.sch,	displayBuf.tab, displayBuf.typ);
			}
			else {
				printSymbol(TableWC[i].TabQua,displayBuf.cat);
                printSymbol(schemaList[TableWC[i].changedSchema],displayBuf.sch);
				printSymbol(TableWC[i].TabName,displayBuf.tab);
                printSymbol(TableWC[i].TabType,displayBuf.typ);

				_stprintf(Heading,_T("Test Positive Functionality of SQLTables for following wildcard options => \n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"),
				displayBuf.cat, displayBuf.sch, displayBuf.tab, displayBuf.typ);
			}

			TESTCASE_BEGINW(Heading);
			NullValue = 0;

			returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}

			if (_tcsicmp(TableWC[i].TabType,_T("NULL")) == 0)
			{
				TableWC[i].TabType = NULL;
				NullValue = 1;
				returncode = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,NULL,0);
			}
			else if (_tcsicmp(TableWC[i].TabName,_T("NULL")) == 0)
			{
				TableWC[i].TabName = NULL;
				NullValue = 1;
				returncode = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}
			else if (_tcsicmp(TableWC[i].TabOwner,_T("NULL")) == 0)
			{
				TableWC[i].TabOwner = NULL;
				NullValue = 1;
				returncode = SQLTables(hstmt,NULL,0,NULL,0,(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}
			else if (_tcsicmp(TableWC[i].TabQua,_T("NULL")) == 0)
			{
				TableWC[i].TabQua = NULL;
				NullValue = 1;
				if (TableWC[i].changedSchema == -1)
					returncode = SQLTables(hstmt,NULL,0,(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
				else
					returncode = SQLTables(hstmt,NULL,0,(SQLTCHAR*)schemaList[TableWC[i].changedSchema],(SWORD)_tcslen(schemaList[TableWC[i].changedSchema]),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}
			else
			{
				if (TableWC[i].changedSchema == -1)
					returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
				else
					returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)schemaList[TableWC[i].changedSchema],(SWORD)_tcslen(schemaList[TableWC[i].changedSchema]),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
			}

			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTables"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				LogMsg(NONE,_T("Call to SQLTables() executed successfully.\n"));
				_tcscpy(oTableQualifier,_T(""));
				_tcscpy(oTableOwner,_T(""));
				_tcscpy(oTableName,_T(""));
				_tcscpy(oTableType,_T(""));
				_tcscpy(oRemark,_T(""));
				returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,2,SQL_C_TCHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,3,SQL_C_TCHAR,oTableName,NAME_LEN,&oTableNamelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,4,SQL_C_TCHAR,oTableType,NAME_LEN,&oTableTypelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				returncode=SQLBindCol(hstmt,5,SQL_C_TCHAR,oRemark,NAME_LEN,&oRemarklen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				k = 0;
				while (returncode == SQL_SUCCESS)
				{
					returncode = SQLFetch(hstmt);
					if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					if (returncode == SQL_SUCCESS)
						k++;
				}
				if(k == 0)
				{
					TEST_FAILED;
					LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n"));
                } else {
                    LogMsg(NONE, _T("Number of rows fetched: %d\n"), k);
                }
			}
			SQLFreeStmt(hstmt,SQL_CLOSE);
			i++;
			TESTCASE_END;
		}
		free(TableStr);
	}

//=========================================================================================

	TESTCASE_BEGIN("SQLTables: Negative test with NULL handle.\n");

	hstmt1 = (SQLHANDLE)NULL;
	i = 0;
	returncode = SQLTables(hstmt1,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)TableWC[i].TabName,(SWORD)_tcslen(TableWC[i].TabName),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTables: Negative test with invalid arg lengths.\n");
	i = 0;
	while (_tcsicmp(TableWC2[i].TabQua,_T("endloop")) != 0)
	{
		returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC2[i].TabQua,TableWC2[i].TabQuaLen,(SQLTCHAR*)TableWC2[i].TabOwner,TableWC2[i].TabOwnerLen,(SQLTCHAR*)TableWC2[i].TabName,TableWC2[i].TabNameLen,(SQLTCHAR*)TableWC2[i].TabType,TableWC2[i].TabTypeLen);
		if(!CHECKRC(SQL_ERROR,returncode,"SQLTables"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		i++;
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("Testing SQLColAttribute, SQLDescribeCol, SQLBindCol and SQLFetch functions for catalog names.\n");

    if(isCharSet) {
		returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}

	for(i = 0; i < 5; i++)
	{
		returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)TableWC[i].TabName,(SWORD)_tcslen(TableWC[i].TabName),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType));
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColumns"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		returncode = SQLNumResultCols(hstmt, &numOfCols);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultsCol"))
		{
			TEST_FAILED;
			LogMsg(ERRMSG,_T("Test failed while executing call for SQLNUMRESULTSCOL"));
			LogAllErrors(henv,hdbc,hstmt);
		}
		for(cols = 0; cols < numOfCols; cols++)
		{
			returncode = SQLDescribeCol(hstmt,(SWORD)(cols+1),(SQLTCHAR*)cn,TabType_LEN,&cl,&st,&cp,&cs,&cnull);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("Test failed while executing call for SQLDESCRIBECOL of column"));
				LogAllErrors(henv,hdbc,hstmt);
			}
			CharOutput[cols] = (TCHAR *)malloc(STR_LEN);
			for (iatt = 0; iatt <= TOTALATTRIBS; iatt++)
			{
				_tcscpy(rgbDesc,_T(""));
				pcbDesc = 0;
				pfDesc = 0;
				returncode = SQLColAttributes(hstmt,(SWORD)(cols+1),DescrType[iatt],(SQLTCHAR*)rgbDesc,STR_LEN,&pcbDesc,&pfDesc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColAttribute"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
			}
			returncode = SQLBindCol(hstmt,(SWORD)(cols+1),SQL_C_TCHAR,(SQLTCHAR*)CharOutput[cols],STR_LEN,&stringlength);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("Test failed while executing call for SQLBindCols of column : %d.\n"),cols);
				LogAllErrors(henv,hdbc,hstmt);
			}
		}

		k = 0;
		while (returncode == SQL_SUCCESS)
		{
			returncode = SQLFetch(hstmt);
			if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			if (returncode == SQL_SUCCESS)
				k++;
		}
		if(k == 0)
		{
            _stprintf(Heading,_T("\n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"),
				printSymbol(TableWC[i].TabQua,displayBuf.cat),
                printSymbol(TableWC[i].TabOwner,displayBuf.sch),
				printSymbol(TableWC[i].TabName,displayBuf.tab),
                printSymbol(TableWC[i].TabType,displayBuf.typ));
            LogMsg(NONE,Heading);
			TEST_FAILED;
			LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n"));
		} else {
            LogMsg(NONE, _T("Number of rows fetched: %d\n"), k);
        }

		for(cols = 0; cols < numOfCols; cols++)
		{
			free(CharOutput[cols]);
		}
		TESTCASE_END;
	}

	// Clean up
	SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[0],SQL_NTS);
	SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[1],SQL_NTS);
	SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[2],SQL_NTS);

//=========================================================================================

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLTables.\n"));
	free_list(var_list);
	TEST_RETURN;
}
コード例 #13
0
	ZeroClickInfo::ZeroClickInfo(json_object *data)
	{
		json_object * tmpObj;
		json_object * tmpObjLvl2;
		json_object * jvalue;
		const char * cstr_value;
		int arraylen = 0;
		int i;
		char charType;
		string value;

		// map the member variable addrs to their string key
		directMappings["Abstract"] = &summary;
		directMappings["AbstractText"] = &textSummary;
		directMappings["AbstractSource"] = &summarySource;
		directMappings["Image"] = &imageURL;
		directMappings["Heading"] = &heading;
		directMappings["Answer"] = &answer;
		directMappings["AnswerType"] = &answerType;
		directMappings["Definition"] = &definition;
		directMappings["DefinitionSource"] = &definitionSource;
		directMappings["DefinitionURL"] = &definitionSourceURL;

		/* Process direct mappings first. */
		for (map<string,string*>::iterator it = directMappings.begin(); it != directMappings.end(); ++it)
		{
			tmpObj = json_object_object_get(data, (it->first).c_str());
			value = jsonObjectToString(tmpObj);

			cout << value << endl;
			cout << it->first << endl;

			// Empty if string is "" so store the string and look for non empty
			if (value == "")
			{
				*it->second = value;
				//cout << it->first << endl;
			}
			else
				*it->second = "";
		}

		/* Now process special API fields. */

		/* The ZeroClickInfo type. */
		value = jsonObjectToString(json_object_object_get(data, "Type"));
		charType = value[1];

		if (charType != '"' && resultTypeMapping.find(charType) != resultTypeMapping.end())
			type = resultTypeMapping[charType];
		else
			type = TYPE_NONE;

		value = "";

		/* Related URLs. */
		tmpObj = json_object_object_get(data, "Results");
		value = string(json_object_to_json_string(tmpObj));

		//cout << value << endl;

		arraylen = json_object_array_length(tmpObj);
		cout << arraylen << endl;

		if (arraylen)
			for (i=0; i< arraylen; i++)
			{
				Result tmpResult;

				jvalue = json_object_array_get_idx(tmpObj, i);

				tmpResult.description = string(json_object_to_json_string(json_object_object_get(jvalue, "Text")));
				tmpResult.URL = json_object_to_json_string(json_object_object_get(jvalue, "FirstURL"));
				tmpResult.iconURL = json_object_to_json_string(json_object_object_get(json_object_object_get(jvalue, "Icon"), "URL"));
				results.push_back(tmpResult);

				//cout << json_object_get_string(jvalue) << endl;
			}

		tmpObj = json_object_object_get(data, "RelatedTopics");
		value = json_object_to_json_string(tmpObj);
		arraylen = json_object_array_length(tmpObj);

		list<Result> tmpList;
		relatedTopics["General"] = tmpList;

		if (arraylen)
			for (i=0; i< arraylen; i++)
			{
				jvalue = json_object_array_get_idx(tmpObj, i);

				tmpObjLvl2 = json_object_object_get(jvalue, "Name");

				if (tmpObjLvl2)
				{
					int arrayLen2 = 0;
					list<Result> tmpList;
					string name = json_object_to_json_string(tmpObjLvl2);
					tmpObjLvl2 = json_object_object_get(jvalue, "Topics");
					arrayLen2 = json_object_array_length(tmpObjLvl2);
					name = removeQuotes(name);

					relatedTopics[name] = tmpList;

					for (int j=0;j<arrayLen2;j++)
					{
						jvalue = json_object_array_get_idx(tmpObjLvl2, j);

						Result tmpResult;

						//cout << json_object_to_json_string(jvalue) << endl;

						tmpResult.description = string(json_object_to_json_string(json_object_object_get(jvalue, "Text")));
						tmpResult.URL = json_object_to_json_string(json_object_object_get(jvalue, "FirstURL"));
						tmpResult.iconURL = json_object_to_json_string(json_object_object_get(json_object_object_get(jvalue, "Icon"), "URL"));

						relatedTopics[name].push_back(tmpResult);
					}
				}
				else
				{
					Result tmpResult;

					tmpResult.description = removeQuotes(string(json_object_to_json_string(json_object_object_get(jvalue, "Text"))));
					tmpResult.URL = json_object_to_json_string(json_object_object_get(jvalue, "FirstURL"));
					tmpResult.iconURL = json_object_to_json_string(json_object_object_get(json_object_object_get(jvalue, "Icon"), "URL"));

					relatedTopics["General"].push_back(tmpResult);
				}
			}
	}
コード例 #14
0
//World file Read
WorldData FileFormats::ReadWorldFile(QFile &inf)
{
    QTextStream in(&inf);   //Read File

    in.setAutoDetectUnicode(true);
    in.setLocale(QLocale::system());
    in.setCodec(QTextCodec::codecForLocale());

    int str_count=0;        //Line Counter
    int file_format=0;        //File format number
    QString line;           //Current Line data

    WorldData FileData = dummyWldDataArray();

    FileData.untitled = false;
    FileData.modified = false;

    WorldTiles tile;
    WorldScenery scen;
    WorldPaths pathitem;
    WorldLevels lvlitem;
    WorldMusic musicbox;

    str_count++;line = in.readLine();   //Read first Line
    if( SMBX64::Int(line) ) //File format number
        goto badfile;
    else file_format=line.toInt();

    str_count++;line = in.readLine();
    if( SMBX64::qStr(line) ) //Episode name
        goto badfile;
    else FileData.EpisodeTitle = removeQuotes(line);

    if(file_format >= 55)
    {
        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Mario
            goto badfile;
        else FileData.nocharacter1 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Luigi
            goto badfile;
        else FileData.nocharacter2 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Peach
            goto badfile;
        else FileData.nocharacter3 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Toad
            goto badfile;
        else FileData.nocharacter4 = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Edisode without Link
            goto badfile;
        else FileData.nocharacter5 = SMBX64::wBoolR(line);
    }

    if(file_format >= 10)
    {
        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Autostart level
            goto badfile;
        else FileData.autolevel = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Don't use world map on this episode
            goto badfile;
        else FileData.noworldmap = SMBX64::wBoolR(line);

        str_count++;line = in.readLine();
        if( SMBX64::wBool(line) ) //Restart level on playable character's death
            goto badfile;
        else FileData.restartlevel = SMBX64::wBoolR(line);
    }

    if(file_format >= 20)
    {
        str_count++;line = in.readLine();
        if( SMBX64::Int(line) ) //Stars quantity
            goto badfile;
        else FileData.stars = line.toInt();
    }

    if(file_format >= 10)
    {
        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 1
            goto badfile;
        else FileData.author1 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 2
            goto badfile;
        else FileData.author2 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 3
            goto badfile;
        else FileData.author3 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 4
            goto badfile;
        else FileData.author4 = removeQuotes(line);

        str_count++;line = in.readLine();
        if( SMBX64::qStr(line) ) //Author 5
            goto badfile;
        else FileData.author5 = removeQuotes(line);
    }


    ////////////Tiles Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        tile = dummyWldTile();
        if(SMBX64::sInt(line)) //Tile x
            goto badfile;
        else tile.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Tile y
            goto badfile;
        else tile.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Tile ID
            goto badfile;
        else tile.id = line.toInt();

        tile.array_id = FileData.tile_array_id;
        FileData.tile_array_id++;
        tile.index = FileData.tiles.size(); //Apply element index

        FileData.tiles.push_back(tile);

        str_count++;line = in.readLine();
    }

    ////////////Scenery Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        scen = dummyWldScen();
        if(SMBX64::sInt(line)) //Scenery x
            goto badfile;
        else scen.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Scenery y
            goto badfile;
        else scen.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Scenery ID
            goto badfile;
        else scen.id = line.toInt();

        scen.array_id = FileData.scene_array_id;
        FileData.scene_array_id++;
        scen.index = FileData.scenery.size(); //Apply element index

        FileData.scenery.push_back(scen);

        str_count++;line = in.readLine();
    }

    ////////////Paths Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        pathitem = dummyWldPath();
        if(SMBX64::sInt(line)) //Path x
            goto badfile;
        else pathitem.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Path y
            goto badfile;
        else pathitem.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Path ID
            goto badfile;
        else pathitem.id = line.toInt();

        pathitem.array_id = FileData.path_array_id;
        FileData.path_array_id++;
        pathitem.index = FileData.paths.size(); //Apply element index

        FileData.paths.push_back(pathitem);

        str_count++;line = in.readLine();
    }

    ////////////LevelBox Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        lvlitem = dummyWldLevel();

        if(SMBX64::sInt(line)) //Level x
            goto badfile;
        else lvlitem.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Level y
            goto badfile;
        else lvlitem.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //Level ID
            goto badfile;
        else lvlitem.id = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::qStr(line)) //Level file
            goto badfile;
        else lvlitem.lvlfile = removeQuotes(line);

        str_count++;line = in.readLine();
        if(SMBX64::qStr(line)) //Level title
            goto badfile;
        else lvlitem.title = removeQuotes(line);

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Top exit
            goto badfile;
        else lvlitem.top_exit = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //Left exit
            goto badfile;
        else lvlitem.left_exit = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //bottom exit
            goto badfile;
        else lvlitem.bottom_exit = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //right exit
            goto badfile;
        else lvlitem.right_exit = line.toInt();

        if(file_format >= 10)
        {
            str_count++;line = in.readLine();
            if(SMBX64::Int(line)) //Enter via Level's warp
                goto badfile;
            else lvlitem.entertowarp = line.toInt();
        }

        if(file_format >= 28)
        {
            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Always Visible
                goto badfile;
            else lvlitem.alwaysVisible = SMBX64::wBoolR(line);

            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Path background
                goto badfile;
            else lvlitem.pathbg = SMBX64::wBoolR(line);

            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Game start point
                goto badfile;
            else lvlitem.gamestart = SMBX64::wBoolR(line);

            str_count++;line = in.readLine();
            if(SMBX64::sInt(line)) //Goto x on World map
                goto badfile;
            else lvlitem.gotox = line.toInt();

            str_count++;line = in.readLine();
            if(SMBX64::sInt(line)) //Goto y on World map
                goto badfile;
            else lvlitem.gotoy = line.toInt();

            str_count++;line = in.readLine();
            if(SMBX64::wBool(line)) //Big Path background
                goto badfile;
            else lvlitem.bigpathbg = SMBX64::wBoolR(line);
        }

        lvlitem.array_id = FileData.level_array_id;
        FileData.level_array_id++;
        lvlitem.index = FileData.levels.size(); //Apply element index

        FileData.levels.push_back(lvlitem);

        str_count++;line = in.readLine();
    }

    ////////////MusicBox Data//////////
    str_count++;line = in.readLine();
    while(line!="\"next\"")
    {
        musicbox = dummyWldMusic();
        if(SMBX64::sInt(line)) //MusicBox x
            goto badfile;
        else musicbox.x = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::sInt(line)) //MusicBox y
            goto badfile;
        else musicbox.y = line.toInt();

        str_count++;line = in.readLine();
        if(SMBX64::Int(line)) //MusicBox ID
            goto badfile;
        else musicbox.id = line.toInt();

        musicbox.array_id = FileData.musicbox_array_id;
        FileData.musicbox_array_id++;
        musicbox.index = FileData.music.size(); //Apply element index

        FileData.music.push_back(musicbox);

        str_count++;line = in.readLine();
    }


    str_count++;line = in.readLine(); // Read last line

    if((line!="")&&(!line.isNull()))
        goto badfile;


FileData.ReadFileValid=true;

return FileData;

badfile:    //If file format not corrects
    BadFileMsg(inf.fileName(), str_count, line);
    FileData.ReadFileValid=false;
return FileData;
}
コード例 #15
0
int main(int argc, char *argv[])
{

    FILE *in=NULL, *wikiout=NULL,*htmlout=NULL;
    char * ptrch;
    char header[MAX_BUFFER][MAX_STRING];
    char col[MAX_BUFFER][MAX_STRING];
    char buffer[4096];
    int c,index, option_index = 0;
    char *param_wiki_output=NULL;
    char *param_html_output=NULL;
    char *param_file_input=NULL;
    int  linecounter=0;
    static struct option long_options[] = {
            {"wiki", 1, 0, 0},
            {"html", 1, 0, 0},
            {"i", 1, 0, 0}
     };

    int j=0,i=0;
    char separator[5];
    separator[0]=',';
    separator[1]='"';
    separator[2]='\0';


    prog_desc(argv);  //program descripton and title
    while(1) {
        c = getopt_long (argc, argv,"",long_options, &option_index);

        if (c == -1)
            break;

        switch (c) {
            case 0:
                index=option_index;
                switch (index) {
                   case 0:  //wiki
                        param_wiki_output = optarg;
                        break;
                   case 1:  // html
                        param_html_output = optarg;
                        break;
                    case 2:  // input
                        param_file_input = optarg;
                        break;
                    default:
                        printf("Unknown Parameter: %i\n",index);
                        helpme(argv);

                }
                break;
            default:
                        printf("Invalid Parameter: %i\n",c);
                        helpme(argv);

        }
    }

    if (optind < argc) {
        printf (" Ignored no option parameter(s): ");
        while (optind < argc)
            printf ("%s ", argv[optind++]);
        printf ("\n");
    }


    if ((param_wiki_output==NULL) &&( param_html_output==NULL)) {

         printf(" Error:  No output file specified:  use --wiki fname or --html fname\n\n");
         helpme(argv);

    }
    else {
		if (param_wiki_output !=NULL){
            wikiout=fopen(param_wiki_output,"w");
            if(wikiout==NULL ){
                printf("Can't create wiki output file %s\n",param_wiki_output);
                exit(1);
            }
		}
		if (param_html_output !=NULL) {
            htmlout=fopen(param_html_output,"w");
            if(htmlout==NULL ){
                printf("Can't create html output file %s\n",param_html_output);
                exit(1);
            }
        }
    }
    if (param_file_input ==NULL){
        printf("input text file required\n");
        helpme(argv);
    }
    else {
       in =fopen(param_file_input,"r");
       if(in==NULL ){
             printf("Can't open input file %s\n",param_file_input);
             exit(1);
       }
    }

	linecounter=0;
	while(!feof(in)) {
		if(fgets(buffer, MAX_STRING, in)) {
			//buflen=strlen(buffer);
			if (linecounter==0){
				// linecounter==0 means we are dealing with a header
				//remove double quotes("), replace comman (,) with !
				// do the column header first

				ptrch = strtok (buffer,",");  //tokens are delimited with pairs of quote comma
				i=0;
				while (ptrch != NULL) {
					   strcpy(header[i],ptrch);
					   removeQuotes(header[i]);
					   i++;
					   ptrch = strtok (NULL, ",");
				}

				if (htmlout!=NULL){
					 fprintf(htmlout,"<table class='wikitable' border='1'>\n");
					 fprintf(htmlout,"<tr>\n");
					 for (j=0; j < i;j++) {
						fprintf(htmlout,"<th scope='col'>%s</th>\n",header[j]);
					 }
					 fprintf(htmlout,"</tr>\n");
				}
				if (wikiout!=NULL){
					 fprintf(wikiout,"== Partlist ==\n\n");
					 fprintf(wikiout,"{| border='1' class='wikitable'\n");
					 fprintf(wikiout,"!%s",header[0]);
					 for(j=1;j < i;j++) {
						fprintf(wikiout,"!!%s",header[j]);
					 }
					// fprintf(wikiout,"\n");
				}



			}   // linecounter =0 only
            else {
                // tokens are separated by pair of quotes

				ptrch = strtok (buffer,"\"");  //tokens are delimited with quotes
				i=0;
				while (ptrch != NULL) {
				       if(*ptrch !=','){
                           strcpy(col[i],ptrch);
                           removeQuotes(col[i]);
                           i++;
                        }
					    ptrch = strtok (NULL, "\"");
				}


				 if (htmlout!=NULL){
					 fprintf(htmlout,"<tr>");
					 for (j=0;j < i-1;j++) {
						fprintf(htmlout,"<td>%s</td> ",col[j]);
					 }
					 fprintf(htmlout,"</tr>\n");

				 }
				  if (wikiout!=NULL){
					 fprintf(wikiout,"|-\n");
					 fprintf(wikiout,"|%s",col[0]);
					 for (j=1;j<i-1;j++) {
						fprintf(wikiout,"||%s",col[j]);
					 }
					  fprintf(wikiout,"\n");

				 }
            }

		}  //if (fgets(
         linecounter++;
	} //while !feof

	if (htmlout!=NULL){
	fprintf(htmlout,"</table>\n\n");
	printf("\n HTML FIle created: %s\n",param_html_output);
	}

   if (wikiout!=NULL){
        fprintf(wikiout,"|}\n\n");
        printf("\n Wiki FIle created: %s\n",param_wiki_output);
   }


   fclose(in);

   if(htmlout!=NULL ){
         fclose(htmlout);
   }
   if(wikiout!=NULL ) {
         fclose(wikiout);
   }
   return 0;
}