Example #1
0
int main(void) {
	// Parse (GET/COOKIE/POST) queries.
	Q_ENTRY *req = qCgiRequestParse(NULL, 0);

	const char *mode = req->getStr(req, "mode", false);
	const char *name = req->getStr(req, "cname", false);
	const char *value = req->getStr(req, "cvalue", false);

	if (mode == NULL) { // View Cookie
		qCgiResponseSetContentType(req, "text/plain");
		printf("Total %d entries\n", req->getNum(req));
		req->print(req, stdout, true);
	} else if (!strcmp(mode, "set")) { // Set Cookie
		if (name == NULL || value == NULL) qCgiResponseError(req, "Query not found");
		if (strlen(name) == 0) qCgiResponseError(req, "Empty cookie name can not be stored.");

		qCgiResponseSetCookie(req, name, value, 0, NULL, NULL, false);
		qCgiResponseSetContentType(req, "text/html");
		printf("Cookie('%s'='%s') entry is stored.<br>Click <a href='cookie.cgi'>here</a> to view your cookies\n", name, value);
	} else if (!strcmp(mode, "remove")) { // Remove Cookie
		if (name == NULL) qCgiResponseError(req, "Query not found");
		if (!strcmp(name, "")) qCgiResponseError(req, "Empty cookie name can not be removed.");

		qCgiResponseRemoveCookie(req, name, NULL, NULL, false);
		qCgiResponseSetContentType(req, "text/html");
		printf("Cookie('%s') entry is removed.<br>Click <a href='cookie.cgi'>here</a> to view your cookies\n", name);
	} else {
		qCgiResponseError(req, "Unknown mode.");
	}

	req->free(req);
	return 0;
}
Example #2
0
int	main(int argc, char **argv)
{
	REQ_CREATE_PRODUCTID_T	Query;
	PRODUCTID_T	*Data;
	int	ErrorCode = NO_ERROR;
	int	Count = 0;
	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	gettimeofday(&tp_start, 0);

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	memset(&Query, 0, sizeof(REQ_CREATE_PRODUCTID_T));

	SvcLog = NULL;
	if((SvcLog = openLog("CreateProductID", SERVICE_LOG_PATH_CREATE_PRODUCTID, LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "text/html");
		printf("File Open Error...(%s)\n", SERVICE_LOG_PATH_CREATE_PRODUCTID);
		return	-1;
	}
	if((ErrorCode = GetParamsReqCreateProductID(req, &Query)) == NO_ERROR)	{
		if((Data = ProcessCreateProductID(Query, &Count, &ErrorCode)) == NULL)	{
			printLog(HEAD, "CreateProductID Error...ErrorCode(%d)\n", ErrorCode);
		}
	}

	if(Query.Mode == 'T')	{
		qCgiResponseSetContentType(req, "text/html");
		PrintResultCreateProductIDWithTable(Count, ErrorCode, Data);
	}
	else	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintResultCreateProductID(Count, ErrorCode, Data);
	}

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(HEAD, "STAT::MSG_CREATE_PRODUCTID_T %d %4.6f\n", ErrorCode, real_time);
	printLog(HEAD, "---------------------------------------------------------------\n");

	if(Data != NULL)
		free(Data);

	req->free(req);

	closeLog(SvcLog);

	return	0;
}
Example #3
0
int	main(int argc, char **argv)
{
	PRODUCTID_T	Query;
	RES_SEARCH_PRODUCT_ERROR_T	*Data;
	int	ErrorCode = NO_ERROR;
	int	Count = 0;
	char	Mode;
	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	gettimeofday(&tp_start, 0);

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	memset(&Query, 0, sizeof(PRODUCTID_T));

	SvcLog = openLog("SearchProductError", SERVICE_LOG_PATH_SEARCH_PRODUCT_ERROR, LOG_MODE);
	if((ErrorCode = GetParamsReqSearchProductError(req, &Query, &Mode)) == NO_ERROR)	{
		if((Data = ProcessSearchProductError(Query, &Count, &ErrorCode)) == NULL)	{
			printLog(HEAD, "SearchProductError Error...ErrorCode(%d)\n", ErrorCode);
		}
	}

	if(Mode == 'T')	{
		qCgiResponseSetContentType(req, "text/html");
		PrintResultSearchProductErrorWithTable(Count, ErrorCode, Data);
	}
	else	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintResultSearchProductError(Count, ErrorCode, Data);
	}

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(HEAD, "STAT::MSG_SEARCH_PRODUCT_ERROR_T %d %4.6f\n", ErrorCode, real_time);
	printLog(HEAD, "---------------------------------------------------------------\n");

	if(Data != NULL)
		free(Data);

	req->free(req);

	closeLog(SvcLog);

	return	0;
}
Example #4
0
int	main(int argc, char **argv)
{
	REQ_CREATE2_T	Query;
	RES_COUPONID_T	*Data = NULL;
	int	ResultCount = 0, ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	memset(&Query, 0, sizeof(REQ_CREATE2_T));

	SvcLog = openLog("CreateCoupon", SERVICE_LOG_PATH_CREATE, LOG_MODE);
	if((ErrorCode = GetParamsReqCreate2(req, &Query)) == NO_ERROR)	{
		if((Data = ProcessCreateCoupon(Query, &ResultCount, &ErrorCode)) == NULL)	{
			printLog(HEAD, "CreateCoupon Error...Count(%d)ErrorCode(%d)\n", ResultCount, ErrorCode);
		}
	}

//	qCgiResponseSetContentType(req, "text/html");
	qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
	PrintResultCouponIDList(ErrorCode, ResultCount, Data);
	printLog(HEAD, "---------------------------------------------------------------\n");

	if(Data != NULL)	
		free(Data);

	req->free(req);

	closeLog(SvcLog);

	return	0;
}
Example #5
0
int	main(int argc, char **argv)
{
	B2B_LOGIN_T	Query;
	CONFIG_T	Config;
	char	LogPath[256];
	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	memset(&Query, 0, sizeof(B2B_LOGIN_T));
	memset(&Config, 0, sizeof(CONFIG_T));

	ReadConfig(CONFIGFILE_PATH, &Config);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_ADMIN);
	if((SvcLog = openLog("ADMIN", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "text/html");
		printf("LogFile Open Error..\n");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintAuthError();
		return  ErrorCode;
	}

	if((ErrorCode = GetParamsReqAuth(req, &Query)) == NO_ERROR)	{
		if((ErrorCode = CheckPasswd(Config.AUTHENTICATION_FILE, Query)) != NO_ERROR)	{
			printLog(HEAD, "ADMIN Error...ErrorCode(%d)\n", ErrorCode);
		}
		else	{
			qCgiResponseSetContentType(req, "text/html");
			PrintQueryHTML(Config.QUERY_FILE);
		}
	}
	else	{
		qCgiResponseSetContentType(req, "text/html");
		PrintAuthError();
		printLog(HEAD, "Parameter Error...(%d)\n", ErrorCode);
	}


//	req->free(req);

	closeLog(SvcLog);

	return	0;
}
Example #6
0
int main(int argc, char **argv)
{
	char	EncodingString[2048];
	int	Index = 0;
	int	ErrorCode = 0;
	DEVICE_INFO_T	DeviceInfo;
	Q_ENTRY	*req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	SvcLog = NULL;
	SvcLog = openLog("DEVICEINFO", LOG_FILE, LOG_MODE);

	memset(&DeviceInfo, 0x00, sizeof(DEVICE_INFO_T));
	memset(EncodingString, 0x00, 2048);

	if((ErrorCode = GetParams(req, EncodingString)) == SDRM_NO_ERROR)	{
		if(strncmp(EncodingString, "IA", 2) == 0)  {
			Index = 2;
		}
		else if(strncmp(EncodingString, "EA", 2) == 0)  {
			Index = 2;
		}

		ErrorCode = DecodingDeviceString4MGR(EncodingString+Index, &DeviceInfo);
		ToUpperString(DeviceInfo.UUID, strlen(DeviceInfo.UUID));
		ToUpperString(DeviceInfo.SecondaryUUID, strlen(DeviceInfo.SecondaryUUID));

		printLog(HEAD, "ClientIP(%s)Input(%s)\t\n<=>UUID(%s)SecondaryUUID(%s)UUIDTypes(%s)DeviceName(%s)OSVersion(%s)AppVersion(%s)RegVersion(%s)BuildNum(%s)ErrorCode(%d)\n",
			getenv("REMOTE_ADDR"), EncodingString, DeviceInfo.UUID, DeviceInfo.SecondaryUUID, DeviceInfo.UUIDTypes, 
			DeviceInfo.DeviceName, DeviceInfo.OSVersion, DeviceInfo.AppVersion, DeviceInfo.RegisterVersion, DeviceInfo.BuildNumber, ErrorCode);

	}
	else	{
		printLog(HEAD, "CientIP(%s)InvalidParams...\n", getenv("REMOTE_ADDR"));
	}
	qCgiResponseSetContentType(req, "text/html");
	printResultDeviceInfo(ErrorCode, DeviceInfo);

	closeLog(SvcLog);

	return 0;
}
Example #7
0
int	main(int argc, char **argv)
{
	REQ_EXCHANGE_UUID_T	Query;
	int	ErrorCode = NO_ERROR;
	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	gettimeofday(&tp_start, 0);

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	memset(&Query, 0, sizeof(REQ_EXCHANGE_UUID_T));

	SvcLog = openLog("ExchangeUUID", SERVICE_LOG_PATH_EXCHANGE_UUID, LOG_MODE);
	if((ErrorCode = GetParamsReqExchangeUUID(req, &Query)) == NO_ERROR)	{
		if((ErrorCode = ProcessExchangeUUID(Query)) != NO_ERROR)	{
			printLog(HEAD, "ExchangeUUID Error...ErrorCode(%d)\n", ErrorCode);
		}
	}

//	qCgiResponseSetContentType(req, "text/html");
	qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
	PrintResultExchangeUUID(ErrorCode);

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(HEAD, "STAT::MSG_EXCHANGE_UUID %d %4.6f\n", ErrorCode, real_time);
	printLog(HEAD, "---------------------------------------------------------------\n");

	req->free(req);

	closeLog(SvcLog);

	return	0;
}
Example #8
0
int main(void) {
	// Parse queries.
	Q_ENTRY *req = qCgiRequestParse(NULL, 0);

	// get queries
	const char *text = req->getStr(req, "text", false);
	const char *filedata   = req->getStr(req, "binary", false);
	int filelength = req->getInt(req, "binary.length");
	const char *filename   = req->getStr(req, "binary.filename", false);
	const char *contenttype = req->getStr(req, "binary.contenttype", false);

	// check queries
	if (text == NULL) qCgiResponseError(req, "Invalid usages.");
	if (filename == NULL || filelength == 0) qCgiResponseError(req, "Select file, please.");

	char  filepath[1024];
	sprintf(filepath, "%s/%s", BASEPATH, filename);

	if (savefile(filepath, filedata, filelength) < 0) {
		qCgiResponseError(req, "File(%s) open fail. Please make sure CGI or directory has right permission.", filepath);
	}

	// result out
	qCgiResponseSetContentType(req, "text/html");
	printf("You entered: <b>%s</b>\n", text);
	printf("<br><a href=\"%s\">%s</a> (%d bytes, %s) saved.", filepath, filename, filelength, contenttype);

	// dump
	printf("\n<p><hr>--[ DUMP INTERNAL DATA STRUCTURE ]--\n<pre>");
	req->print(req, stdout, false);
	printf("\n</pre>\n");

	// de-allocate
	req->free(req);
	return 0;
}
Example #9
0
int	main(int argc, char **argv)
{
	B2B_CHANGE_STATUS_T	Query;
	B2B_PRODUCT_T	ProductInfo;
	CONFIG_T	Config;
	char	LogPath[256];

	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	SvcLog = NULL;
	Log = NULL;
	StatLog = NULL;

	gettimeofday(&tp_start, 0);

	memset(&Query, 0, sizeof(B2B_CHANGE_STATUS_T));
	memset(&ProductInfo, 0, sizeof(B2B_PRODUCT_T));
	memset(&Config, 0, sizeof(CONFIG_T));

	if((ErrorCode = ReadConfig(CONFIGFILE_PATH, &Config)) != NO_ERROR)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	//	Set Random Value
	srand(tp_start.tv_usec);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_CHANGEPRODUCTSTATUS);
	if((SvcLog = openLog("ChangeProductStatus", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_CHANGEPRODUCTSTATUS_DEB);
	if((Log = openLog("ChangeProductStatus", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_STATISTICS);
	if((StatLog = openLog("ChangeProductStatus", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	if((ErrorCode = Connect2DB(Config)) == NO_ERROR)	{
		if((ErrorCode = GetParamsReqChangeStatus(req, &Query)) == NO_ERROR)	{
			if((ErrorCode = DB_SelectProductInfoByProductID(Query.ProductID, &ProductInfo)) != NO_ERROR)	{
				printLog(HEAD, "Select Prodcut Info Error...ErrorCode(%d)\n", ErrorCode);
			}
			else	{
				switch(ProductInfo.Status)	{
					case 'N' :
						if(Query.Status != 'R' && Query.Status != 'E' && Query.Status != 'N')
							ErrorCode = ERROR_CHANGE_STATUS;
						break;
					case 'R' :
						if(Query.Status != 'B' && Query.Status != 'E' && Query.Status != 'N' && Query.Status != 'R')
							ErrorCode = ERROR_CHANGE_STATUS;
						break;

					case 'E' : 
						ErrorCode = ERROR_CHANGE_STATUS;
						break;
					case 'B' :
						if(Query.Status != 'R' && Query.Status != 'B')
							ErrorCode = ERROR_CHANGE_STATUS;
						break;
					default :
						ErrorCode = ERROR_CHANGE_STATUS;
						break;
				}

				if(ErrorCode == NO_ERROR)	{
					printLog(HEAD, "Now change (%s) status (%c) to (%c)\n", ProductInfo.ProductID, ProductInfo.Status, Query.Status);
					ProductInfo.Status = Query.Status;
					if((ErrorCode = DB_ChangeStatus(ProductInfo)) != NO_ERROR)	{
						printLog(HEAD, "Change Product Status Error...ErrorCode(%d)\n", ErrorCode);
					}
				}
			}
		}
		else	{
			printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "DBConnection Error...(%d)\n", ErrorCode);
	}

	qCgiResponseSetContentType(req, "application/json;charset=euc-kr");

	PrintResultChangeProductStatus(ErrorCode);

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "CHANGE_STATUS_%c %d %4.6f\n", Query.Status, ErrorCode, real_time);
	printLog(HEAD, "---------------------------------------------------------------\n");

	closeLog(SvcLog);
	closeLog(Log);
	closeLog(StatLog);

	return	0;
}
Example #10
0
int	main(int argc, char **argv)
{
	B2B_AUTHENTICATION_T	Query;
	B2B_AUTH_INFO_T AuthInfo;
	CONFIG_T	Config;
	char	LogPath[256];

	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	gettimeofday(&tp_start, 0);

	memset(&Query, 0, sizeof(B2B_AUTHENTICATION_T));
	memset(&AuthInfo, 0, sizeof(B2B_AUTH_INFO_T));
	memset(&Config, 0, sizeof(CONFIG_T));

	ReadConfig(CONFIGFILE_PATH, &Config);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_AUTHENTICATION);
	if((SvcLog = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}
	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_AUTHENTICATION_DEB);

	if((Log = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_STATISTICS);
	if((StatLog = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

//	printLog(HEAD, "HERE\n");

//	printLog(HEAD, "REM(%s)(%d)\n", Config.REMIP, Config.REMPort);
//	printf("HRE\n");

	Query.Mode = SID_AUTHENTICATION;
	if((ErrorCode = Connect2DB(Config)) == NO_ERROR)	{
		if((ErrorCode = GetParamsReqAuth(req, &Query)) == NO_ERROR)	{
			if((ErrorCode = SetAuthKeyInfo_V1(Query, &AuthInfo)) != NO_ERROR)	{
				printLog(HEAD, "Authentication Error...ErrorCode(%d)\n", ErrorCode);
			}
		}
		else	{
			printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "DBConnection Error...(%d)\n", ErrorCode);
	}

//	qCgiResponseSetContentType(req, "text/html");
	qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
	PrintResultAuthentication(ErrorCode, AuthInfo);
	printLog(HEAD, "---------------------------------------------------------------\n");

	/*
	if(Query.DeviceInfo != NULL)	
		free(Query.DeviceInfo);
	*/
	
	if(AuthInfo.DeviceInfo != NULL)	
		free(AuthInfo.DeviceInfo);

//	req->free(req);

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "AUTHEENTICATION %d %4.6f\n", ErrorCode, real_time);

	closeLog(SvcLog);
    closeLog(Log);
    closeLog(StatLog);

	return	0;
}
int	main(int argc, char **argv)
{
	char	ProductID[B2B_PRODUCTID_SIZE+1];
	char	Mode;
	B2B_PRODUCT_T 	Data;
	CONFIG_T	Config;
	char	LogPath[256];
	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;
	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	gettimeofday(&tp_start, 0);

	//	Set Random Value
	srand(tp_start.tv_usec);

	memset(ProductID, 0, B2B_PRODUCTID_SIZE+1);
	memset(&Data, 0, sizeof(B2B_PRODUCT_T));

	ReadConfig(CONFIGFILE_PATH, &Config);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_SEARCHPRODUCTDETAIL);
	SvcLog = openLog("SearchProductDetailInfo", LogPath,  LOG_MODE);
	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_SEARCHPRODUCTDETAIL_DEB);
	Log = openLog("SearchProductDetailInfo", LogPath,  LOG_MODE);
	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_STATISTICS);
	StatLog = openLog("SearchProductDetailInfo", LogPath,  LOG_MODE);

	if((ErrorCode = Connect2DB(Config)) == NO_ERROR)	{
		if((ErrorCode = GetParamsReqSearchDetail(req, ProductID, &Mode)) == NO_ERROR)	{
			if((ErrorCode = DB_SelectProductInfoByProductID(ProductID, &Data)) != NO_ERROR)	{
				printLog(HEAD, "Search Error...ErrorCode(%d)\n", ErrorCode);
			}
		}
		else	{
			printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "DBConnection Error...(%d)\n", ErrorCode);
	}

	if(Mode == 'T')	{
		qCgiResponseSetContentType(req, "text/html");
		PrintResultProductDInfoListWithTable(ErrorCode, Data);
	}
	else	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintResultProductDInfoList(ErrorCode, Data);
	}

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "SEARCH_PRODUCT_D %d %4.6f\n", ErrorCode, real_time);
	printLog(HEAD, "---------------------------------------------------------------\n");

	closeLog(SvcLog);
	closeLog(Log);
	closeLog(StatLog);

	return	0;
}
Example #12
0
int	main(int argc, char **argv)
{
	B2B_CREATE_T	Query;
	B2B_PRODUCTID_T 	Data[B2B_MAX_CREATE_COUNT];
	CONFIG_T	Config;
	char	LogPath[256];

	int	Count = 0;
	time_t	t1;
	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	int	ErrorCode = NO_ERROR;
	int	i = 0;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	SvcLog = NULL;
	Log = NULL;
	StatLog = NULL;

	gettimeofday(&tp_start, 0);

	memset(&Query, 0, sizeof(B2B_CREATE_T));
	memset(Data, 0, sizeof(B2B_PRODUCTID_T) * B2B_MAX_CREATE_COUNT);
	memset(&Config, 0, sizeof(CONFIG_T));

	if((ErrorCode = ReadConfig(CONFIGFILE_PATH, &Config)) != NO_ERROR)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	//	Set Random Value
	time(&t1);
	srand(t1);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_CREATEPRODUCT);
	if((SvcLog = openLog("CreateProduct", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_CREATEPRODUCT_DEB);
	if((Log = openLog("CreateProduct", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_STATISTICS);
	if((StatLog = openLog("CreateProduct", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return	ErrorCode;
	}

	printLog(HEAD, "HERE..\n");

	if((ErrorCode = Connect2DB(Config)) == NO_ERROR)	{
		if((ErrorCode = GetParamsReqCreate(req, &Query)) == NO_ERROR)	{
			/*
			if((Data = (B2B_PRODUCTID_T *) malloc(sizeof(B2B_PRODUCTID_T) * Query.Count)) == NULL)	{
				printLog(HEAD, "Memory Allocation Error...\n");
				ErrorCode = ERROR_EXCEPTION_MEMORY;
			}
			memset(Data, 0, sizeof(B2B_PRODUCTID_T) * Query.Count);
			*/
			if((ErrorCode = DB_CreateProductIDList(Query, Data, &Count)) != NO_ERROR)	{
				printLog(HEAD, "CreateProduct Error...ErrorCode(%d)\n", ErrorCode);
			}
		}
		else	{
			printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "DBConnection Error...(%d)\n", ErrorCode);
	}


	for(i = 0; i < Count; i++)	{
		printLog(HEAD, "(%d)(%s)\n", i+1, Data[i].ProductID);
	}
	
	if(Query.Mode == 'T')	{
		qCgiResponseSetContentType(req, "text/html");
		PrintResultCreateProductWithTable(ErrorCode, Data, Count);
	}
	else if(Query.Mode== 'X')	{
		qCgiResponseSetContentType(req, "text/html");
		PrintResultCreateProductLikeCVS(ErrorCode, Data, Count);
	}
	else	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintResultCreateProduct(ErrorCode, Data, Count);
	}

	/*
	if(Data != NULL)	
		free(Data);
	*/

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "CREATE_PRODUCT %d %4.6f\n", ErrorCode, real_time);
	printLog(HEAD, "---------------------------------------------------------------\n");

	closeLog(SvcLog);
	closeLog(Log);
	closeLog(StatLog);

	return	0;
}
Example #13
0
int	main(int argc, char **argv)
{
	B2B_AUTHENTICATION_T	Query;
	B2B_AUTH_INFO_T AuthInfo;
	DEVICE_INFO_T DevInfo;
	DEVICE_INFO_T DevInfoAuth;
	CONFIG_T	Config;
	char	LogPath[256];

	double start_time=0, end_time=0;
	double real_time = 0;
	struct timeval tp_start;
	struct timeval tp_end;

	int	ErrorCode = NO_ERROR;

	Q_ENTRY *req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	gettimeofday(&tp_start, 0);

	memset(&Query, 0, sizeof(B2B_AUTHENTICATION_T));
	memset(&AuthInfo, 0, sizeof(B2B_AUTH_INFO_T));
	memset(&DevInfo, 0, sizeof(DEVICE_INFO_T));
	memset(&DevInfoAuth, 0, sizeof(DEVICE_INFO_T));
	memset(&Config, 0, sizeof(CONFIG_T));

	ReadConfig(CONFIGFILE_PATH, &Config);

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_DEVICEINFO);
	if((SvcLog = openLog("DeviceInfo", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "text/html");
		ErrorCode = ERROR_CREATE_LOG_FILE;
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

	if((ErrorCode = GetParamsReqAuth(req, &Query)) == NO_ERROR)	{
		if((ErrorCode = GetInformations(Query.DeviceInfo, Query.SecurityKey, &DevInfo, &DevInfoAuth, &AuthInfo)) != NO_ERROR)	{
			printLog(HEAD, "Authentication Error...ErrorCode(%d)\n", ErrorCode);
		}
	}
	else	{
		printLog(HEAD, "Invalid Paramters Error...(%d)\n", ErrorCode);
	}

//	qCgiResponseSetContentType(req, "text/html");
	qCgiResponseSetContentType(req, "text/html");
	PrintInformations(ErrorCode, DevInfo, DevInfoAuth, AuthInfo);
	printLog(HEAD, "---------------------------------------------------------------\n");

	if(AuthInfo.DeviceInfo != NULL)	
		free(AuthInfo.DeviceInfo);

//	req->free(req);

	DisConnectDB();

	gettimeofday(&tp_end, 0);
	start_time = (double)tp_start.tv_sec + (double)tp_start.tv_usec/1000000;
	end_time = (double)tp_end.tv_sec + (double)tp_end.tv_usec/1000000;
	real_time = end_time - start_time;

	printLog(STAT_HEAD, "AUTHEENTICATION %d %4.6f\n", ErrorCode, real_time);

	closeLog(SvcLog);

	return	0;
}