int ProcessFinalizeFactoryAuth(int new_sock) { int ErrorCode; MYSQL *conn = NULL; V6_AUTHENTICATION_REQUEST_T in; FINALIZE_FACTORYAUTH_T Request; printLog(HEAD, "==[MSG_REGISTER_FAC_PRODUCT_REQ]==\n") ; memset(&in, 0, sizeof(V6_AUTHENTICATION_REQUEST_T)) ; if((ErrorCode = ReadFinalizeFactory(&Request, new_sock)) != NO_ERROR) { return ErrorCode; } memcpy(in.uuid, Request.UUID, UUID_SIZE); memcpy(in.device_type, Request.DeviceType, UUID_SIZE); printLog(HEAD, "INPUT DATA: UUID(%s)DEVICE_TYPE(%s)\n", in.uuid, in.device_type); if((ErrorCode = getDBConn(&conn)) == TRUE) { if((ErrorCode = can_We_Register_The_Product(in.uuid, in.device_type, &conn)) == TRUE) { if((ErrorCode = DB_InsertFactoyAuthHistory(&conn, in, DBMODE_FAC_AUTH_SUCCESS)) != DB_SUCCESS) { ErrorCode = ERROR_DB ; return ErrorCode; } } DB_EndProcess(&conn, DBEND_POSITION); } WriteProcessingResult("MSG_REGISTER_FAC_PRODUCT_REQ", MSG_FINALIZE_FAC_PRODUCT_REQ, MSG_PDA_ERROR, ErrorCode, new_sock); return ErrorCode; }
rc_t SettingDB::execSQL(const char_t* strSQL) { ASSERT(strSQL); if (0 >= STRLEN(strSQL)) { return RC_S_NULL_VALUE; } // get dblink AutoRelease<IConnection*> autoRelIDBConn((IConnection*)getDBConn()); if (NULL == autoRelIDBConn) { return RC_S_FAILED; } return autoRelIDBConn->execute((const char_t*)strSQL, FALSE); }
int ProcessOrionAuthenticationV6(int new_sock) { int ErrorCode = NO_ERROR; V6_AUTHENTICATION_REQUEST_T Request; V6_AUTHENTICATION_RESULT_T Result; MYSQL *conn = NULL; int isInit = 1; printLog(HEAD, "==[MSG_INTER5_AUTH_REQ]==\n"); memset(&Request, 0, sizeof(V6_AUTHENTICATION_REQUEST_T)); if((ErrorCode = ReadAuthRequestVersion6(new_sock, &Request)) == FAIL) { if(Request.AuthFileInfo != NULL) free(Request.AuthFileInfo); return FAIL; } memset(&Result, 0, sizeof(V6_AUTHENTICATION_RESULT_T)); if((Result.AuthResultData = (AUTH_RESULT_DATA_T*) malloc(sizeof(AUTH_RESULT_DATA_T)*Request.reqEncCnt)) == NULL) { printLog(HEAD, "ERR: Memory Allocation Error... size(%d)\n", sizeof(AUTH_RESULT_DATA_T)*Request.reqEncCnt); if(Request.AuthFileInfo != NULL) free(Request.AuthFileInfo); return FAIL; } isInit = 1; if((ErrorCode = getDBConn(&conn)) == TRUE) { ErrorCode = checkUUIDIntegrity(Request); if(ErrorCode == TRUE) ErrorCode = checkProductIDAndClass(Request, &conn); if(ErrorCode == TRUE) ErrorCode = DBProcessOrion(Request, &conn, &isInit); if(ErrorCode == TRUE) ErrorCode = processEncoding(Request, &Result, &conn); if(ErrorCode == TRUE) ErrorCode = DB_UpdateNInsertProductNowHistoryOrion(&conn, Request, isInit); DB_EndProcess(&conn, DBEND_POSITION); } WriteAuthRequestVersion6("MSG_INTER5_AUTH_REQ", MSG_INTER5_AUTH_REQ, MSG_PDA_ERROR, Request, Result, ErrorCode, new_sock); if(Request.AuthFileInfo != NULL) free(Request.AuthFileInfo); if(Result.AuthResultData != NULL) free(Result.AuthResultData); return ErrorCode; }
int GetErrorInfo(PRODUCTID_T ProductID, int *ErrorCount, ERRORINFO_T *ErrorInfo) { int i; MYSQL *conn = NULL ; MYSQL_RES *res_set = NULL ; MYSQL_ROW row = NULL ; int ErrorCode = DB_SUCCESS; int cnt ; char sqltxt[SQL_STMT_SIZE+1] = {'\0'} ; printLog(HEAD, "work_errorInfo_get(): productid(%.18s)\n", ProductID.ProductID) ; if((ErrorCode = getDBConn(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: getDBConn(%d)\n", ErrorCode); ErrorCode = ERROR_DB ; return ErrorCode ; } sprintf(sqltxt, "select error_code, master_uuid, now_uuid, old_uuid, e_date, req_type from error_info where productid = '%.18s' order by e_date desc limit %d", ProductID.ProductID, MAX_RETURN_NUM) ; printLog(HEAD, "sql(%s)\n", sqltxt) ; if((ErrorCode = mydbc_execute_get_result(&conn, sqltxt, &cnt, &res_set)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_exectue_get_result:(%d)\n", ErrorCode); ErrorCode = ERROR_DB ; DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode; } if(cnt == 0) { printLog(HEAD, "ERR: NO DATA ABOUT product(%.18s)\n", ProductID.ProductID) ; ErrorCode = ERROR_NO_ERROR_HISTORY ; } for(i = 0 ; i < cnt ; i++) { if( (row = mydbc_next_row(&res_set)) == NULL ) break; if(row[0] != NULL) ErrorInfo[i].ErrorCode = row[0][0] ; if(row[1] != NULL) strcpy(ErrorInfo[i].MasterUUID, row[1]) ; if(row[2] != NULL) strcpy(ErrorInfo[i].NowUUID, row[2]) ; if(row[3] != NULL) strcpy(ErrorInfo[i].OldUUID, row[3]) ; if(row[4] != NULL) strcpy(ErrorInfo[i].TimeStamp, row[4]) ; if(row[5] != NULL) ErrorInfo[i].RequestType = row[5][0] ; } *ErrorCount = cnt ; DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return ErrorCode ; }
rc_t SettingDB::execSQL(IGetSetParam* pIGetSetParam, const char_t* strSQL) { ASSERT(pIGetSetParam); ASSERT(strSQL); if (0 >= STRLEN(strSQL)) { return RC_S_NULL_VALUE; } // get dblink AutoRelease<IConnection*> autoRelIDBConn((IConnection*)getDBConn()); if (NULL == autoRelIDBConn) { return RC_S_FAILED; } if (RC_S_OK != autoRelIDBConn->execute(strSQL, TRUE)) { return RC_S_FAILED; } AutoRelease<IRecordSet*> autoRelRecSet(autoRelIDBConn->get_record_set()); if (NULL == autoRelRecSet) { return RC_S_FAILED; } uint32_t nRowIdx = 0; uint32_t nFieldCount; if (RC_S_OK != autoRelRecSet->get_field_count(&nFieldCount)) { return RC_S_FAILED; } rc_t rc = RC_S_OK; while (RC_S_OK == rc && RC_S_OK == autoRelRecSet->fetch()) { AutoRelease<IRecord*> autoRelRec(autoRelRecSet->get_record()); if (NULL == autoRelRec) { goto next_rec; } // for (uint32_t idxField = 0; idxField < nFieldCount; ++idxField) { uint8_t* data; uint32_t len; if (RC_S_OK != autoRelRec->get_data(idxField, &data, &len)) { break; } pIGetSetParam->SetResult(nRowIdx, idxField, (const char_t*)data, len); } next_rec: ++nRowIdx; rc = autoRelRecSet->next(); } return RC_S_OK; }
int processRegistProductClass(REGIST_PRODUCTCLASS_T ProductClass) { MYSQL *conn = NULL; int ErrorCode = DB_SUCCESS; if((ErrorCode = getDBConn(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: getDBConn(%d)\n", ErrorCode); return ERROR_DB ; } if((ErrorCode = DB_UpdateProductClass(&conn, ProductClass)) != DB_SUCCESS) { printLog(HEAD, "Update ProductClass Error..\n"); } else { printLog(HEAD, "ClassCode(%s)ClassName(%s)AuthFlag(%c)ClassType(%s)RunMode(%c)\n", ProductClass.ClassCode, ProductClass.ClassName, ProductClass.AuthFlag, ProductClass.ClassType, ProductClass.RunMode); } DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode; }
int Process3DAuthenticationV6(int new_sock) { int ErrorCode; V6_AUTHENTICATION_REQUEST_T Request; V6_AUTHENTICATION_RESULT_T Result; MYSQL *conn = NULL; double start_time=0, end_time=0; double t1=0, t2=0; struct timeval tp_start; struct timeval tp_end; gettimeofday(&tp_start, 0); printLog(HEAD, "==[MSG_INTER4_AUTH_REQ]==\n"); memset(&Request, 0, sizeof(V6_AUTHENTICATION_REQUEST_T)); memset(&Result, 0, sizeof(V6_AUTHENTICATION_RESULT_T)); if((ErrorCode = ReadAuthRequestVersion6(new_sock, &Request)) == FAIL) { if(Request.AuthFileInfo != NULL) free(Request.AuthFileInfo); return FAIL; } if((Result.AuthResultData = (AUTH_RESULT_DATA_T*) malloc(sizeof(AUTH_RESULT_DATA_T)*Request.reqEncCnt)) == NULL) { printLog(HEAD, "ERR: Memory Allocation Error... size(%d)\n", sizeof(AUTH_RESULT_DATA_T)*Request.reqEncCnt); if(Request.AuthFileInfo != NULL) free(Request.AuthFileInfo); return FAIL; } if(strcmp("USER", Request.userType) == 0) { if((ErrorCode = getDBConn(&conn)) == TRUE) { ErrorCode = checkProduct_From_DB(Request, &conn); if(ErrorCode == TRUE) ErrorCode = processEncoding(Request, &Result, &conn); if(ErrorCode == TRUE) ErrorCode = DB_UpdateNInsertProductNowHistory(&conn, Request); DB_EndProcess(&conn, DBEND_POSITION); } } else if(strcmp("FACT", Request.userType) == 0) { if((ErrorCode = getDBConn(&conn)) == TRUE) { ErrorCode = checkUUID(Request, &conn); if(ErrorCode == TRUE) ErrorCode = processEncoding_Fac(Request, &Result, &conn); if(ErrorCode == TRUE) { if((ErrorCode = DB_InsertFactoyAuthHistory(&conn, Request, DBMODE_FAC_AUTH_INITED)) != DB_SUCCESS) { ErrorCode = ERROR_DB ; } } DB_EndProcess(&conn, DBEND_POSITION); } } else { printLog(HEAD, "ERR: User type(%s) is not acceptable \n", Request.userType); ErrorCode = ERROR_USER_WRONG; } WriteAuthRequestVersion6("MSG_INTER4_AUTH_REQ", MSG_INTER4_AUTH_REQ, MSG_PDA_ERROR, Request, Result, ErrorCode, new_sock); if(Request.AuthFileInfo != NULL) free(Request.AuthFileInfo); if(Result.AuthResultData != NULL) free(Result.AuthResultData); gettimeofday(&tp_end, 0); t1 = (double)tp_start.tv_sec; t2 = ((double)tp_start.tv_usec)/1000000; start_time = t1 + t2; t1 = (double)tp_end.tv_sec; t2 = ((double)tp_end.tv_usec)/1000000; end_time = t1 + t2; printLog(HEAD, "Authetication Elapsed for Processing... (%f) seconds\n", end_time-start_time); return ErrorCode; }
DBConn *DBModule::getConn() { ICQ_ASSERT(getDBConn != NULL); return getDBConn(); }
int CreateProductID(CREATE_SERIALNO_T Request, PRODUCTID_T *ProductList) { MYSQL *conn = NULL ; int ErrorCode; int i; int num ; char sqltxt[SQL_STMT_SIZE+1] = {'\0'} ; char sqltxt2[SQL_STMT_SIZE+1] = {'\0'} ; int order = 0 ; time_t t1; time(&t1) ; printLog(HEAD, "CLASS(%s) QUANTITY(%d)\n", Request.Class, Request.Quantity) ; if((ErrorCode = getDBConn(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: getDBConn(%d)\n", ErrorCode); ErrorCode = ERROR_DB ; return ErrorCode; } // class exist memset(sqltxt, 0, sizeof(sqltxt)) ; sprintf(sqltxt, "select class from product_class WHERE class='%s'" , Request.Class) ; printLog(HEAD, "sql(%s)\n", sqltxt) ; if((ErrorCode = DB_SQLExistData(&conn, sqltxt, &num)) != DB_SUCCESS) { printLog(HEAD, "SQL Excution Error...\n"); DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode ; } if(num == 0) { // 신규 추가되는 class code에 // Class Code가 3글자 보다 작거나, 영문자+숫자 조합 중 '0', '1', '2', '8', 'B', 'I', 'O', 'Z'를 포함할 경우 에러 처리 // 기존에 등록된 제품번호는 어쩔 수 없음.. // 2011.05.23 by yjkim if((ErrorCode = CheckValidClassCode(Request.Class)) != NO_ERROR) { DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode ; } if((ErrorCode = mydbc_refresh(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_refresh(%d)\n", ErrorCode); ErrorCode = ERROR_DB ; DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode ; } memset(sqltxt, 0, sizeof(sqltxt)) ; sprintf(sqltxt, "insert into product_class(class, c_date) values('%s', now())", Request.Class) ; printLog(HEAD, "sqltxt(%s)\n", sqltxt) ; if((ErrorCode = mydbc_execute(&conn, sqltxt)) != DB_SUCCESS) { printLog(HEAD, "sqltxt(%s)errorcode(%d)\n", sqltxt, ErrorCode) ; ErrorCode = ERROR_DB ; DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode ; } } for(i = 0, order = 1; i < Request.Quantity; i++) { MakeSerialNumber(Request.Class, order+i, ProductList[i].ProductID) ; if((ErrorCode = mydbc_refresh(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_refresh(%d)\n", ErrorCode); ErrorCode = ERROR_DB ; DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode; } memset(sqltxt, 0, sizeof(sqltxt)) ; sprintf(sqltxt, "select productid from product_now where productid='%s'", ProductList[i].ProductID) ; printLog(HEAD, "sqltxt(%s)\n", sqltxt) ; if((ErrorCode = DB_SQLExistData(&conn, sqltxt, &num)) != DB_SUCCESS){ printLog(HEAD, "SQL(%s) Has ErrorNo(%d)\n", sqltxt, ErrorCode); DB_EndProcess(&conn, DBEND_POSITION); ErrorCode = ERROR_DB ; return ErrorCode; } if(num > 0) { printLog(HEAD, "EXIST ProductID(%s) retry\n", ProductList[i].ProductID) ; time(&t1); // 중복키 발생시 seed새로 설정 srand48((long) t1 + order + i); continue ; } if((ErrorCode = mydbc_refresh(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_refresh(%d)\n", ErrorCode); ErrorCode = ERROR_DB ; DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode; } memset(sqltxt, 0, sizeof(sqltxt)) ; sprintf(sqltxt, "insert into product_now(productid, status, p_date) values('%s', 'N', now())", ProductList[i].ProductID) ; printLog(HEAD, "order(%d) sqltxt(%s)\n", order, sqltxt) ; if((ErrorCode = mydbc_execute(&conn, sqltxt)) != DB_SUCCESS) { printLog(HEAD, "SQL(%s) Has ErrorNo(%d)\n", sqltxt, ErrorCode); DB_EndProcess(&conn, DBEND_POSITION); ErrorCode = ERROR_DB ; return ErrorCode; } ///////Inserting Productid-Create History 090728-hwyoon////// if((ErrorCode = mydbc_refresh(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_refresh(%d)\n", ErrorCode); ErrorCode = ERROR_DB ; DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode; } memset(sqltxt2, 0, sizeof(sqltxt2)) ; sprintf(sqltxt2, "insert into product_history(productid,userid,status,version,master_uuid,uuid2,h_date,route,softversion,mapdate,mapinfo,pda_type,register_ver,app_ver,app_build_num,map_ver,os_ver,file_folder_size,expire_date,prev_auth) select productid,userid,status,version,master_uuid,uuid2,p_date,'W',softversion,mapdate,mapinfo,pda_type,register_ver,app_ver,app_build_num,map_ver,os_ver,file_folder_size,expire_date,prev_auth from product_now where productid='%s'", ProductList[i].ProductID) ; printLog(HEAD, "sql(%s)\n", sqltxt2) ; if((ErrorCode = mydbc_execute(&conn, sqltxt2)) != DB_SUCCESS) { printLog(HEAD, "SQL(%s) Has ErrorNo(%d)\n", sqltxt2, ErrorCode); DB_EndProcess(&conn, DBEND_POSITION); ErrorCode = ERROR_DB ; return ErrorCode; } ///////Inserting Productid-Create History 090728-hwyoon////// } DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode ; }
int processFactAuthInfoGet(PRODUCTINFO_REQ_DEVICE_T Request, FACTORYAUTH_RES_T *Result) { MYSQL *conn = NULL; MYSQL_RES *res_set = NULL; MYSQL_ROW row = NULL; int ErrorCode, i, cnt, n = 0; char sqltxt[SQL_STMT_SIZE+1] ; char db_status; char db_time[TIME_LEN_SIZE+1]; char db_expire_date[EXPIRE_DATE_SIZE+1]; if((ErrorCode = getDBConn(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_init(%d)\n", ErrorCode); return ERROR_DB ; } sprintf(sqltxt, "select i_date, status, expire_date from fac_auth_history where master_uuid = '%s' and pda_type = '%s' order by i_date desc", Request.uuid_3d, Request.deviceType); printLog(HEAD, "SQL(%s)\n", sqltxt); if((ErrorCode = mydbc_execute_get_result(&conn, sqltxt, &cnt, &res_set)) != DB_SUCCESS) { printLog(HEAD, "ERR : mydbc_execure_get_result(%d)\n", ErrorCode); DB_EndProcess(&conn, DBEND_POSITION); return ERROR_DB ; } if(cnt == 0) { Result->ResCount=0; } else { Result->ResCount = cnt; if((Result->ResultData = (FACTORYAUTH_DATA_T *) malloc(sizeof(FACTORYAUTH_DATA_T) * Result->ResCount)) == NULL) { printLog(HEAD, "Memory Allocation Error... SYS ERROR... Result->ResCount(%d) RecordSize(%d)\n", Result->ResCount, sizeof(FACTORYAUTH_DATA_T)); DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return SYSERROR_MALLOC; } memset(Result->ResultData, 0, sizeof(FACTORYAUTH_DATA_T) * Result->ResCount); } for(i = 0; i < cnt; i++) { if((row = mydbc_next_row(&res_set)) == NULL) break; n = -1; memset(db_time, 0, TIME_LEN_SIZE+1); memset(db_expire_date, 0, EXPIRE_DATE_SIZE+1); if(row[++n] != NULL) strcpy(db_time, row[n]); if(row[++n] != NULL) db_status = row[n][0]; if(row[++n] != NULL) strcpy(db_expire_date, row[n]); memcpy(Result->ResultData[i].deviceType, Request.deviceType, DEVICE_TYPE_SIZE); memcpy(Result->ResultData[i].uuid_3d, Request.uuid_3d, UUID_SIZE_3D); Result->ResultData[i].status = db_status; memcpy(Result->ResultData[i].time, db_time, TIME_LEN_SIZE); if(db_status == 'R') memcpy(Result->ResultData[i].initDate, db_expire_date, EXPIRE_DATE_SIZE); } DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return ErrorCode; }
int processProductInfoGetByDeviceInfo(PRODUCTINFO_REQ_DEVICE_T Request, PRODUCTINFO_RES_T *Result) { MYSQL *conn = NULL; MYSQL_RES *res_set = NULL; MYSQL_ROW row = NULL; int ErrorCode, i, cnt, j, n; char sqltxt[SQL_STMT_SIZE+1] ; DB_PRODUCTINFO_T ProductInfo; if((ErrorCode = getDBConn(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_init(%d)\n", ErrorCode); return ERROR_DB ; } sprintf(sqltxt, "select productid, userid, status, version, master_uuid, uuid2, p_date, softversion, mapdate, mapinfo, pda_type, register_ver, app_ver, app_build_num, map_ver, os_ver, file_folder_size, expire_date, prev_auth from product_now where master_uuid = '%s' and pda_type = '%s' order by p_date desc", Request.uuid_3d, Request.deviceType); printLog(HEAD, "SQL(%s)\n", sqltxt); if((ErrorCode = mydbc_execute_get_result(&conn, sqltxt, &cnt, &res_set)) != DB_SUCCESS) { printLog(HEAD, "ERR : mydbc_execure_get_result(%d)\n", ErrorCode); DB_EndProcess(&conn, DBEND_POSITION); return ERROR_DB ; } i = 0; if(cnt == 0) { printLog(HEAD, "No Data exist ...\n"); Result[i].ResCount = 1; if((Result[i].ResultData = (PRODUCTINFO_DATA_T *) malloc(sizeof(PRODUCTINFO_DATA_T) * Result[i].ResCount)) == NULL) { printLog(HEAD, "Memory Allocation Error... SYS ERROR... Result->ResCount(%d) RecordSize(%d)\n", Result->ResCount, sizeof(FACTORYAUTH_DATA_T)); DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return SYSERROR_MALLOC; } memset(Result[i].ResultData, 0, sizeof(PRODUCTINFO_DATA_T) * Result[i].ResCount); memcpy(Result[i].ResultData[0].device_type, Request.deviceType, DEVICE_TYPE_SIZE); Result[i].ResultData[0].exist = 'F'; Result[i].ResultData[0].last_use = 'F'; Result[i].ResultData[0].status = 'F'; } else { Result->ResCount = cnt; if((Result->ResultData = (PRODUCTINFO_DATA_T *) malloc(sizeof(PRODUCTINFO_DATA_T) * Result->ResCount)) == NULL) { printLog(HEAD, "Memory Allocation Error... SYS ERROR... Result->ResCount(%d) RecordSize(%d)\n", Result->ResCount, sizeof(FACTORYAUTH_DATA_T)); DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return SYSERROR_MALLOC; } memset(Result->ResultData, 0, sizeof(PRODUCTINFO_DATA_T) * Result->ResCount); } for(j = 0; j < cnt; j++) { if((row = mydbc_next_row(&res_set)) == NULL) break; n = -1; memset(&ProductInfo, 0, sizeof(DB_PRODUCTINFO_T)); if(row[++n] != NULL) strcpy(ProductInfo.ProductID, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.UserID, row[n]); if(row[++n] != NULL) ProductInfo.Status = row[n][0]; if(row[++n] != NULL) strcpy(ProductInfo.Version, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.MasterUUID, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.UUID2, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.TimeStamp, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.SoftwareVersion, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.MapDate, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.MapInfo, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.DeviceType, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.RegisterVersion, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.AppVersion, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.AppBuildNum, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.MapVersion, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.OSVersion, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.FileFolderSize, row[n]); if(row[++n] != NULL) strcpy(ProductInfo.ExpireDate, row[n]); if(row[++n] != NULL) ProductInfo.PrevAuth = row[n][0]; ProductInfo.PrevAuth = toupper(ProductInfo.PrevAuth); ProductInfo.Status = toupper(ProductInfo.Status); Result->ResultData[j].exist = 'T'; memcpy(Result->ResultData[j].userid, ProductInfo.UserID, USER_ID_SIZE); memcpy(Result->ResultData[j].productid, ProductInfo.ProductID, PRODUCT_SIZE); Result->ResultData[j].last_use = ProductInfo.PrevAuth; if(ProductInfo.Status == 'D' || ProductInfo.Status == 'V') { Result->ResultData[j].status = ProductInfo.Status; } else if(ProductInfo.PrevAuth == 'K' && ProductInfo.Status == 'H') { Result->ResultData[j].status = 'K'; } else if(ProductInfo.PrevAuth == 'K' && ProductInfo.Status == 'N') { Result->ResultData[j].status = 'N'; } else if(strlen(ProductInfo.UUID2) == 0 && ProductInfo.Status == 'H' && ProductInfo.PrevAuth != 'K') { Result->ResultData[j].status = 'H'; } else if(strlen(ProductInfo.UUID2) > 0 && ProductInfo.Status == 'H' && ProductInfo.PrevAuth != 'K') { Result->ResultData[j].status = 'M'; } else if(strlen(ProductInfo.UUID2) > 0 && ProductInfo.Status == 'N' && ProductInfo.PrevAuth != 'K') { Result->ResultData[j].status = 'O'; } else if(strlen(ProductInfo.UUID2) == 0 && ProductInfo.Status == 'N') { Result->ResultData[j].status = 'N'; } else { printLog(HEAD, "fatal error::no permit status status(%c)prev_auth(%c)uuid2(%s)uuid2len(%d)product(%s)\n", ProductInfo.Status, ProductInfo.PrevAuth, ProductInfo.UUID2, strlen(ProductInfo.UUID2), ProductInfo.ProductID); DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return ERROR_UNKNOWN; } memcpy(Result->ResultData[j].time, ProductInfo.TimeStamp, TIME_LEN_SIZE); memcpy(Result->ResultData[j].version, ProductInfo.Version, VERSION_SIZE); memcpy(Result->ResultData[j].softversion, ProductInfo.SoftwareVersion, VERSION_SIZE); memcpy(Result->ResultData[j].mapdate, ProductInfo.MapDate, MAP_DATE_SIZE); memcpy(Result->ResultData[j].mapinfo, ProductInfo.MapInfo, MAP_INFO_SIZE); memcpy(Result->ResultData[j].device_type, ProductInfo.DeviceType, DEVICE_TYPE_SIZE); memcpy(Result->ResultData[j].register_version, ProductInfo.RegisterVersion, REGISTER_VERSION_SIZE); memcpy(Result->ResultData[j].app_version, ProductInfo.AppVersion, APP_VERSION_SIZE); memcpy(Result->ResultData[j].app_build_num, ProductInfo.AppBuildNum, APP_BUILD_NUM_SIZE); memcpy(Result->ResultData[j].map_version, ProductInfo.MapVersion, MAP_VER_SIZE); memcpy(Result->ResultData[j].os_version, ProductInfo.OSVersion, OS_VER_SIZE_M31); memcpy(Result->ResultData[j].file_folder_size, ProductInfo.FileFolderSize, FILE_SIZE); memcpy(Result->ResultData[j].expire_date, ProductInfo.ExpireDate, EXPIRE_DATE_SIZE); } DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return ErrorCode; }
int processProductHistoryInfoGet(PRODUCTID_T Request, PRODUCTHISTORY_RES_T *Result) { MYSQL *conn = NULL; MYSQL_RES *res_set = NULL; MYSQL_ROW row = NULL; int ErrorCode, cnt, i, n; char sqltxt[SQL_STMT_SIZE+1] ; DB_PRODUCTINFO_HISTORY_T HistoryData; if((ErrorCode = getDBConn(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_init(%d)\n", ErrorCode); return ERROR_DB ; } sprintf(sqltxt, "select userid, status, version, master_uuid, uuid2, h_date, route, softversion, mapdate, mapinfo, pda_type, register_ver, app_ver, app_build_num, map_ver, os_ver, file_folder_size, expire_date, prev_auth from product_history where productid = '%s' order by h_date desc", Request.ProductID); printLog(HEAD, "SQL(%s)\n", sqltxt); if((ErrorCode = mydbc_execute_get_result(&conn, sqltxt, &cnt, &res_set)) != DB_SUCCESS) { printLog(HEAD, "ERR : mydbc_execure_get_result(%d)\n", ErrorCode); DB_EndProcess(&conn, DBEND_POSITION); return ERROR_DB ; } if(cnt == 0) { printLog(HEAD, "productid (%s) has No history...\n", Request.ProductID); Result->ResCount = 0; DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return TRUE; } else { Result->ResCount=cnt; if((Result->ResultData = (PRODUCTHISTORY_DATA_T *)malloc(sizeof(PRODUCTHISTORY_DATA_T)*cnt)) == NULL ) { printLog(HEAD, "ERROR : Memory Allocation failed...size(%d) now returns...\n", sizeof(PRODUCTHISTORY_DATA_T)*cnt); DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return ERROR_MEMORY_WRONG; } memset(Result->ResultData, 0, sizeof(PRODUCTHISTORY_DATA_T)*cnt); } for(i = 0; i < cnt; i++) { if((row = mydbc_next_row(&res_set)) == NULL) break; n = -1; memset(&HistoryData, 0, sizeof(DB_PRODUCTINFO_HISTORY_T)); if(row[++n] != NULL) strcpy(HistoryData.UserID, row[n]); if(row[++n] != NULL) HistoryData.Status = row[n][0]; if(row[++n] != NULL) strcpy(HistoryData.Version, row[n]); if(row[++n] != NULL) strcpy(HistoryData.MasterUUID, row[n]); if(row[++n] != NULL) strcpy(HistoryData.UUID2, row[n]); if(row[++n] != NULL) strcpy(HistoryData.TimeStamp, row[n]); if(row[++n] != NULL) HistoryData.Route = row[n][0]; if(row[++n] != NULL) strcpy(HistoryData.SoftwareVersion, row[n]); if(row[++n] != NULL) strcpy(HistoryData.MapDate, row[n]); if(row[++n] != NULL) strcpy(HistoryData.MapInfo, row[n]); if(row[++n] != NULL) strcpy(HistoryData.DeviceType, row[n]); if(row[++n] != NULL) strcpy(HistoryData.RegisterVersion, row[n]); if(row[++n] != NULL) strcpy(HistoryData.AppVersion, row[n]); if(row[++n] != NULL) strcpy(HistoryData.AppBuildNum, row[n]); if(row[++n] != NULL) strcpy(HistoryData.MapVersion, row[n]); if(row[++n] != NULL) strcpy(HistoryData.OSVersion, row[n]); if(row[++n] != NULL) strcpy(HistoryData.FileFolderSize, row[n]); if(row[++n] != NULL) strcpy(HistoryData.ExpireDate, row[n]); if(row[++n] != NULL) HistoryData.PrevAuth = row[n][0]; memcpy(Result->ResultData[i].userid, HistoryData.UserID, USER_ID_SIZE); memcpy(Result->ResultData[i].productid, Request.ProductID, PRODUCT_SIZE); Result->ResultData[i].last_use = HistoryData.PrevAuth; if(HistoryData.Status == 'D' || HistoryData.Status == 'V') { Result->ResultData[i].status = HistoryData.Status; } else if(HistoryData.PrevAuth == 'K' && HistoryData.Status == 'H') { Result->ResultData[i].status = 'K'; } else if(HistoryData.PrevAuth == 'K' && HistoryData.Status == 'N') { Result->ResultData[i].status = 'N'; } else if(strlen(HistoryData.UUID2) == 0 && HistoryData.Status == 'H' && HistoryData.PrevAuth != 'K') { Result->ResultData[i].status = 'H'; } else if(strlen(HistoryData.UUID2) > 0 && HistoryData.Status == 'H' && HistoryData.PrevAuth != 'K') { Result->ResultData[i].status = 'M'; } else if(strlen(HistoryData.UUID2) > 0 && HistoryData.Status == 'N' && HistoryData.PrevAuth != 'K') { Result->ResultData[i].status = 'O'; } else if(strlen(HistoryData.UUID2) == 0 && HistoryData.Status == 'N') { Result->ResultData[i].status = 'N'; } else { printLog(HEAD, "FATAL ERROR::No permit status status(%c)prev_auth(%c)uuid2(%s)uuid2Len(%d)product(%s)\n", HistoryData.Status, HistoryData.PrevAuth, HistoryData.UUID2, strlen(HistoryData.UUID2), Request.ProductID); DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); //exit(-1); return ERROR_UNKNOWN; } memcpy(Result->ResultData[i].time, HistoryData.TimeStamp, TIME_LEN_SIZE); memcpy(Result->ResultData[i].version, HistoryData.Version, VERSION_SIZE); memcpy(Result->ResultData[i].softversion, HistoryData.SoftwareVersion, VERSION_SIZE); memcpy(Result->ResultData[i].mapdate, HistoryData.MapDate, MAP_DATE_SIZE); memcpy(Result->ResultData[i].mapinfo, HistoryData.MapInfo, MAP_INFO_SIZE); memcpy(Result->ResultData[i].device_type, HistoryData.DeviceType, DEVICE_TYPE_SIZE); memcpy(Result->ResultData[i].register_version, HistoryData.RegisterVersion, REGISTER_VERSION_SIZE); memcpy(Result->ResultData[i].app_version, HistoryData.AppVersion, APP_VERSION_SIZE); memcpy(Result->ResultData[i].app_build_num, HistoryData.AppBuildNum, APP_BUILD_NUM_SIZE); memcpy(Result->ResultData[i].map_version, HistoryData.MapVersion, MAP_VER_SIZE); memcpy(Result->ResultData[i].os_version, HistoryData.OSVersion, OS_VER_SIZE_M31); memcpy(Result->ResultData[i].file_folder_size, HistoryData.FileFolderSize, FILE_SIZE); memcpy(Result->ResultData[i].expire_date, HistoryData.ExpireDate, EXPIRE_DATE_SIZE); Result->ResultData[i].route = HistoryData.Route; } DB_EndProcessWithResultSet(&conn, &res_set, DBEND_POSITION); return ErrorCode; }
int processProductSimpleInfoGet(PRODUCTID_T Request, SIMPLE_PRODUCTINFO_RES_T *Result) { MYSQL *conn = NULL; int cnt; int ErrorCode = TRUE; DB_PRODUCTINFO_T ProductInfo; memset(&ProductInfo, 0, sizeof(DB_PRODUCTINFO_T)); if((ErrorCode = getDBConn(&conn)) != DB_SUCCESS) { printLog(HEAD, "ERR: mydbc_init(%d)\n", ErrorCode); return ERROR_DB ; } if((ErrorCode = DB_getProductInfoByProductID(&conn, Request.ProductID, &cnt, &ProductInfo)) != DB_SUCCESS) { return ErrorCode; } if(cnt == 0) { memcpy(Result->productid, Request.ProductID, PRODUCT_SIZE); Result->status = 'E'; ErrorCode = ERROR_NO_PRODUCT; } else { // ProductID의 조회 결과는 항상 1개 memcpy(Result->userid, ProductInfo.UserID, USER_ID_SIZE); memcpy(Result->productid, Request.ProductID, PRODUCT_SIZE); if(ProductInfo.Status == 'D' || ProductInfo.Status == 'V') { Result->status = ProductInfo.Status; } else if(ProductInfo.PrevAuth == 'K' && ProductInfo.Status == 'H') { Result->status = 'K'; } else if(ProductInfo.PrevAuth == 'K' && ProductInfo.Status == 'N') { Result->status = 'N'; } else if(strlen(ProductInfo.UUID2) == 0 && ProductInfo.Status == 'H' && ProductInfo.PrevAuth != 'K') { Result->status = 'H'; } else if(strlen(ProductInfo.UUID2) > 0 && ProductInfo.Status == 'H' && ProductInfo.PrevAuth != 'K') { Result->status = 'M'; } else if(strlen(ProductInfo.UUID2) > 0 && ProductInfo.Status == 'N' && ProductInfo.PrevAuth != 'K') { Result->status = 'O'; } else if(strlen(ProductInfo.UUID2) == 0 && ProductInfo.Status == 'N') { Result->status = 'N'; } else { printLog(HEAD, "FATAL ERROR::PRODCUTID(%s) No permit status status(%c)prev_auth(%c)uuid(%s)uuid2(%s)uuid2Len(%d)\n", Request.ProductID, ProductInfo.Status, ProductInfo.PrevAuth, ProductInfo.MasterUUID, ProductInfo.UUID2, strlen(ProductInfo.UUID2)); DB_EndProcess(&conn, DBEND_POSITION); //exit(-1); return ERROR_UNKNOWN; } memcpy(Result->device_type, ProductInfo.DeviceType, DEVICE_TYPE_SIZE); if(Result->status == 'O') memcpy(Result->uuid, ProductInfo.UUID2, UUID_SIZE); else memcpy(Result->uuid, ProductInfo.MasterUUID, UUID_SIZE); if(strlen(Result->userid) == 0) memset(Result->userid, ' ', USER_ID_SIZE); if(strlen(Result->uuid) == 0) memset(Result->uuid, ' ', UUID_SIZE); if(strlen(Result->device_type) == 0) memset(Result->device_type, ' ', DEVICE_TYPE_SIZE); printLog(HEAD, "DEBUG::productid(%.18s)userid(%.20s)uuid(%.50s)devicetype(%.8s)status(%c)\n", Result->productid, Result->userid, Result->uuid, Result->device_type, Result->status); } DB_EndProcess(&conn, DBEND_POSITION); return ErrorCode; }