Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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_REAUTHENTICATION);
	if((SvcLog = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

	sprintf(LogPath, "%s/%s", Config.LOG_PATH, LOG_NAME_REAUTHENTICATION_DEB);
	if((Log = openLog("Authentication", LogPath,  LOG_MODE)) == NULL)	{
		qCgiResponseSetContentType(req, "application/json;charset=euc-kr");
		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");
		PrintErrorResult(ErrorCode);
		return  ErrorCode;
	}

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

	Query.Mode = SID_REAUTHENTICATION;
	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, "REAUTHENTICATION %d %4.6f\n", ErrorCode, real_time);

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


	return	0;
}