/*-------------------------------------------------------------------*/ int ProfileConnect ( const unsigned char *param_user_id, const unsigned char *password, const unsigned char *mtm_address, char unsigned *profile_reply, const unsigned char *tlo) { #define number_offset 6 int error_code, timeout = 60, i, j, k, num_size; STR_DESCRIPTOR request, reply; char reply_buffer[MAX_MSG_SIZE],request_buffer[MAX_MSG_SIZE+1]; MTM_MSG_HEADER *mess_header; unsigned char *(header_and_message[6]); unsigned char *(header_strings[6]); unsigned char *(message_strings1[10]); unsigned char *(message_strings2[10]); unsigned char *temp_buffer; request.str = request_buffer; k = 0; strcpy ((char *)passed_mtm_address,(char *)mtm_address); ClConnect(2, mtm_address, &k); error_code = error_check (k,CLCONNECT,(unsigned char*)0,profile_reply); if (error_code != OK) return error_code; memset(reply_buffer,0,sizeof(reply_buffer)); memset(request_buffer,0,sizeof(request_buffer)); j = setup_login_request(&request, param_user_id, password, mtm_address, tlo); k=0; logging (&request,"\nCLIENT LOGON REQUEST\n"); ClExchmsg(4, &request, &reply, timeout, &k); logging (&reply,"\nSERVER RESPONSE TO CLIENT LOGON REQUEST\n"); error_code = error_check (k,CLLOGIN,&reply,profile_reply); if (error_code != OK) return error_code; num_size = get_number_size(reply.length-2); i = move_number(reply_buffer, reply.length-2); memcpy(reply_buffer+i,reply.str+1,reply.length-2); reply.str = reply_buffer; parse_string(reply.str,header_and_message); parse_string(header_and_message[1],header_strings); parse_string(header_and_message[2],message_strings1); parse_string(message_strings1[2],message_strings2); setup_token(message_strings2[1],profile_reply); return 0; }
/* Return the command sent after that with the given gtp id, * or gtp_cmds if the id wasn't used in this game. If a play command * has overwritten a genmoves command, return the play command. * slave_lock is held on both entry and exit of this function. */ static char * next_command(int cmd_id) { if (cmd_id == -1) return gtp_cmds; int last_id = atoi(gtp_cmd); int reply_move = move_number(cmd_id); if (reply_move > move_number(last_id)) return gtp_cmds; int slot; for (slot = 0; slot < MAX_CMDS_PER_MOVE; slot++) { if (cmd_id == history[reply_move][slot].gtp_id) break; } if (slot == MAX_CMDS_PER_MOVE) return gtp_cmds; char *next = history[reply_move][slot].next_cmd; assert(next); return next; }
void turn_right(t_box *box) { int y; y = 0; while (y <= (box->size - 1)) { move_number(box->tab[y], box); move_number(box->tab[y], box); move_number(box->tab[y], box); move_number(box->tab[y], box); add_number(box->tab[y], box); move_number(box->tab[y], box); move_number(box->tab[y], box); move_number(box->tab[y], box); move_number(box->tab[y], box); y++; } }
/*-------------------------------------------------------------------*/ int ProfileSQL (const unsigned char *sql_token, const unsigned char *sql_message, const unsigned char *sql_qualifiers, unsigned char *profile_reply, unsigned char *retry, int time_out) { STR_DESCRIPTOR request, reply; char request_buffer[MAX_MSG_SIZE], reply_buffer[MAX_MSG_SIZE]; int aa, i, j, k, num_size, error_code, error_code2, offset; unsigned char *(header_and_message[6]); unsigned char *(header_strings[6]); unsigned char *(message_strings1[1000]); unsigned char *(message_strings2[1000]); char buffer[MAX_MSG_SIZE]; char *pszSql = NULL,*new_sql_message = NULL, *new_using_clause; long len_new_sql_message, len_new_using_clause; unsigned char *col_attributes= NULL, *new_sql_qualifiers = NULL; char *lpsSelect; char *tokens; int nLen = 0; struct tm *curTime; time_t ltime; char tmpBuf[128]; if(sql_message == NULL) { strcpy((char *)profile_reply,"MSG_8564|Invalid SQL Command"); strcat((char *)profile_reply,(char *)sql_message); return 1; } memset (request_buffer,0,sizeof(request_buffer)); memset (reply_buffer,0,sizeof(reply_buffer)); request.str = request_buffer; reply.str = reply_buffer; /* Get time as number */ time(<ime); curTime = localtime( <ime ); /* Use strftime to build a customized time string. */ strftime( tmpBuf, 128,"OPEN CURSOR CUR%H%M%S AS \n", curTime ); /* For SELECT add open cursor */ tokens = (char *)strstr((char *)sql_message, " "); nLen = tokens - (char *)sql_message; lpsSelect = (char *) calloc(nLen + 1,1); if(NULL == lpsSelect) return -1; strncpy(lpsSelect,(char *)sql_message,nLen); pszSql = (char *)calloc(MAX_MSG_SIZE,1); if(strcasecmp(lpsSelect,"SELECT") == 0) { strcpy(pszSql,tmpBuf); strcat(pszSql,(char *)sql_message); } else strcpy(pszSql,(char *)sql_message); free(lpsSelect); new_sql_message = (char *) calloc(MAX_MSG_SIZE,1); new_using_clause = (char *) calloc(MAX_MSG_SIZE,1); len_new_sql_message = MAX_MSG_SIZE; len_new_using_clause = MAX_MSG_SIZE; error_code = ParseHostSQL(pszSql, strlen(pszSql), NULL ,0 ,new_sql_message, &len_new_sql_message, new_using_clause, &len_new_using_clause ); free(pszSql); logging (NULL, "\nSQL MESSAGE\n"); logging (NULL,(char*) sql_message); logging (NULL, "\nCLEANED SQL MESSAGE\n"); logging (NULL,(char*) new_sql_message); if(len_new_using_clause) { nLen = strlen((char *)sql_qualifiers)+ len_new_using_clause + 1; new_sql_qualifiers = (unsigned char *)calloc(nLen + 1, 1); strcpy((char *)new_sql_qualifiers, (char *)sql_qualifiers); strcat((char *)new_sql_qualifiers,new_using_clause); pack_sql(&request,(unsigned char *)new_sql_message, new_sql_qualifiers,sql_token,retry); } else { pack_sql(&request,(unsigned char *)new_sql_message, sql_qualifiers,sql_token,retry); } /* thoniyim 09/21/2001 memory leak fix */ free(new_sql_message); free(new_using_clause); k=0; logging (&request, "\nSQL MESSAGE SENT TO SERVER\n"); ClExchmsg(4, &request, &reply, time_out, &k); logging (&reply, "\nSERVER RESPONSE TO SQL MESSAGE\n"); error_code = error_check (k,CLSQL,&reply,profile_reply); if (error_code == OK_BUT_EMPTY_MESSAGE_BODY) { profile_reply[0] = 0; return OK; } if (error_code != OK && error_code != SQL_OK) { if (error_code == 4) { total_time_outs++; conseg_time_outs++; if (total_time_outs > 50000 || conseg_time_outs > 5000) { printf ("\nValue of total_time_outs and conseg_time_outs: %d %d\n", total_time_outs, conseg_time_outs); exit (1); } ClDisconnect(2, buffer); ClConnect(2, passed_mtm_address, &k); error_code2 = error_check (k,CLCONNECT,(unsigned char*)0,profile_reply); if (error_code2 != OK) { i = get_message_id (retry,FALSE); return error_code2; } } i = get_message_id (retry,FALSE); return error_code; } conseg_time_outs = 0; i = move_number(reply_buffer, reply.length-2); memcpy(reply_buffer+i,reply.str+1,reply.length-2); reply.str = reply_buffer; parse_string(reply.str,header_and_message); /* * thoniyim - CR 7426 - 01/16/2004 * Check the data from the host for message id. * Check if the message id of request and reply matches. */ parse_string(header_and_message[1],header_strings); i = memcmp(header_array[2].field, header_strings[2]+1, header_array[2].field_size); if (i != 0) { strcpy(profile_reply,"Message Ids for the request and reply does n't match. Disconnect and connect again."); return -1001; }