#include "MessageInfo.h"
#include "dir_path.h"
#include "snd_rcv_knd.h"
#include "taglnk_frame.h"
#include "hi_packet_format.h"
#include <iconv.h>

#define MSTLIMIT 80
#define MSTLIMIT2 40

struct MESSAGE_FUNC_INFO g_sMessageFuncInfo[] =
{
// 통행처리 관련
    {"00010010" , "Lane Status"             , MessageProc_00010010},
	{"00020010" , "Proc Data"               , MessageProc_00020010},
    {"00030010" , "Card Data"               , MessageProc_00030010},
	{"00040010" , "WORK END"                , MessageProc_00040010},
	{"00050010" , "CLOSE PASS"              , MessageProc_00050010},
	{"00110010" , "AI CarNo"                , MessageProc_00110010},
// 테이블 데이터 관련
	{"00210010" , "Before Count"            , MessageProc_00210010},
	{"00210011" , "Before MST Data"         , MessageProc_00210011},
	{"00210020" , "Before MST End"          , MessageProc_00210020},
	{"00210030" , "Before CHG Data"         , MessageProc_00210030},
	{"00220010" , "Exemption Count"         , MessageProc_00220010},
	{"00220011" , "Exemption MST Data"      , MessageProc_00220011},
	{"00220030" , "Exemption CHG Data"      , MessageProc_00220030},
	{"00230010" , "Low Pollution Count"     , MessageProc_00230010},
	{"00230011" , "Low Pollution MST Data"  , MessageProc_00230011},
	{"00230030" , "Low Pollution CHG Data"  , MessageProc_00230030},
	{"00240010" , "Reduction Count"         , MessageProc_00240010},
	{"00240011" , "Reduction MST Data"      , MessageProc_00240011},
	{"00240030" , "Reduction CHG Data"      , MessageProc_00240030},
// 2019.08.28 사전등록 집계 추가
	{"00310010" , "Adv_Day_End_Total"       , MessageProc_00310010},
	{"00320010" , "Adv_Day_End_Return"      , MessageProc_00320010},
// 2019.08.28 테이블 데이터 추가
	{"90010010" , "Basic Data"              , MessageProc_90010010},
	{"90020010" , "Worker Data"             , MessageProc_90020010},
#if 1
//DUAL TEST
	{"99990010" , "LANE Rcv Data"           , MessageProc_99990010},
#endif
    {""         , ""                        , NULL},
};

// 처리되는 전문의 종류가 많다면 각 전문별로 파일을 분리하는 것이 좋음
// 이 파일에서는 처리되는 구조체와 FindProcessFunction만 보관하고 있어도 됨
// 파일이 분리 된다면 해당 c소스의 헤더 파일을 MessageInfo에 Include 할것

int (*FindProcessFunction(char *pMessageID))(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nIndex = 0;
    int nCompareResult;
    while (g_sMessageFuncInfo[nIndex].szMessageID != NULL)
    {
        nResult = SafeStrCmp(g_sMessageFuncInfo[nIndex].szMessageID, sizeof(g_sMessageFuncInfo[nIndex].szMessageID), pMessageID, &nCompareResult);
        if (nCompareResult == 0)
        {
            return g_sMessageFuncInfo[nIndex].MessageProcessFunc;
        }
        nIndex++;
    }
    return NULL;
}

int MessageProc_00010010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;

    CURLcode nCurlResult;
    long nHttpCode;

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/callANPRStatusInfo.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00010010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Full[%*.*s]!", nThreadIndex, 0, 30, pRecvMessage);
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 9, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 9, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "camId", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"camId\":\"%s\",", szTrimmedFieldData);
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 9);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 9, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "colctTime", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"colctTime\":\"%s\",", szTrimmedFieldData);
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 23);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 23, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "vhcleNum", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"vhcleNum\":\"%s\",", szTrimmedFieldData);
#if 0
    nResult = GetCheckedValue(TYPE_FILENAME, szFieldData, 4, pRecvMessage + 24);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 24, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
#else
	memset(szFieldData, 0x00, sizeof(szFieldData));
	sprintf(szFieldData, "%.4s", pRecvMessage + 23);
#endif
	Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "rtuTp", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"rtuTp\":\"%s\",", szTrimmedFieldData);
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 28, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "bxDoorSttus", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"bxDoorSttus\":\"%s\",", szTrimmedFieldData);
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 29);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 29, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "camSdCardSttus", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"camSdCardSttus\":\"%s\"", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\n}");
//    nPostDataLength = sizeof(szPostDataBuffer);
//    pPostValueKey = curl_escape("id", 0);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);
//    pPostValueKey = curl_escape("name", 0);
//    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 8);
//    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);

    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00020010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
	int chk_carno = 0;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;

    CURLcode nCurlResult;
    long nHttpCode;
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;
	char orgCarNo[255+1];
	char szCarNo[255+1];
#if 0	
	iconv_t ic = iconv_open("UTF-8", "EUC-KR");
	
	if(ic == (iconv_t) -1)
	{
		printf_s("###### Not Supported ICONV Code ###### \n");
	}
#endif
	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));
//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveCarThroughInfo.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00020010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Full[%*.*s]!", nThreadIndex, 0, 138, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 4);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 4, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 6);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 8);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 8, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_date", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_date\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 22);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 22, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_seqno", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_seqno\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 30);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 30, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_rf_seqno", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_rf_seqno\":\"%s\"", szTrimmedFieldData);
#if 0
    sprintf(orgCarNo, "%.16s", pRecvMessage + 38);
    in_size = strlen(orgCarNo);
	out_size = sizeof(wchar_t) * in_size * 4;
	
	in_buf = orgCarNo;
	out_buf = szCarNo;
	out_buf_left = out_size;
	printf("Original Car No[%s]\n", orgCarNo);
	nResult = iconv(ic, (char *)&in_buf, &in_size, (char *)&out_buf, &out_buf_left);
	if(nResult == -1)
	{
		printf_s("ICONV FAILED [%d]\n", nResult);
	}
	printf("Incoding Car No[%s]\n", szCarNo);
#endif

	//nResult = GetCheckedValue(TYPE_FILENAME, szFieldData, 16, pRecvMessage + 38);

#if 0
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 38, 16, pRecvMessage);
        return RC_ERR_FORMAT;
    }
#else
	sprintf(szFieldData, "%.16s", pRecvMessage + 38);
    //sprintf(szFieldData, "67저6731");
#if 0
	iconv_close(ic);
#endif
#endif
	if(strncmp(szFieldData, "????????????", 12) == 0)
		chk_carno = 1;

    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_car", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_car\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 54);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 54, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_collect", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_collect\":\"%s\"", szTrimmedFieldData);

	nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 56);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 9[%*.*s]!", nThreadIndex, 56, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_army", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_army\":\"%s\",", szTrimmedFieldData);
#if 1
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 57);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 10[%*.*s]!", nThreadIndex, 57, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
#else
	sprintf(szFieldData, " ");
#endif
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_stop", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_stop\":\"%s\"", szTrimmedFieldData);
#if 1
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 58);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 11[%*.*s]!", nThreadIndex, 58, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
#else
	sprintf(szFieldData, " ");
#endif
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_move", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_move\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 59);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 12[%*.*s]!", nThreadIndex, 59, 6, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_amount", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_amount\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 65);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 13[%*.*s]!", nThreadIndex, 65, 3, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_x", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_x\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 68);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 14[%*.*s]!", nThreadIndex, 68, 3, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_y", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_y\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 71);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 15[%*.*s]!", nThreadIndex, 71, 3, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_garo", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_garo\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 74);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 16[%*.*s]!", nThreadIndex, 74, 3, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sero", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sero\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 77);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 17[%*.*s]!", nThreadIndex, 77, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_card_ret", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_card_ret\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 78);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 18[%*.*s]!", nThreadIndex, 78, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_other", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_other\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 79);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 79, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_rfid_kbn", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_rfid_kbn\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 48, pRecvMessage + 81);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 81, 48, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_tag", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_tag\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 129);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 21[%*.*s]!", nThreadIndex, 129, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_carkind", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_carkind\":\"%s\"", szTrimmedFieldData);
	
	nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 130);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 22[%*.*s]!", nThreadIndex, 130, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_collect_new", szTrimmedFieldData);
	
	nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 132);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 23[%*.*s]!", nThreadIndex, 132, 6, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sens_time", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sens_time\":\"%s\"", szTrimmedFieldData);

	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\n}");
//    nPostDataLength = sizeof(szPostDataBuffer);
//    pPostValueKey = curl_escape("id", 0);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);
//    pPostValueKey = curl_escape("name", 0);
//    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 8);
//    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);

    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
#if 0 //AI 오류로 잠시 막음
		if(chk_carno == 1)
	    {
		    nResult = MessageProc_00110010(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
WriteLog(LogType_StandardOut, LogLevel_Info, "AI Process Result[%d]!", nResult);
	    }
#endif
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
	
    return nFunctionResult;
}

int MessageProc_00030010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;

    CURLcode nCurlResult;
    long nHttpCode;

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveCardPaymentInfo.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00030010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Full[%*.*s]!", nThreadIndex, 0, 188, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 4);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 4, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 6);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 8);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 8, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_date", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_date\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 16);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 16, 6, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_time", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_time\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 22);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 22, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_seqno", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_seqno\":\"%s\"", szTrimmedFieldData);

	nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 30);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 30, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_kbn", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_kbn\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 16, pRecvMessage + 31);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 31, 16, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_card", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_card\":\"%s\"", szTrimmedFieldData);

	nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 47);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 9[%*.*s]!", nThreadIndex, 47, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_collect", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_collect\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 49);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 10[%*.*s]!", nThreadIndex, 49, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_be_amount", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_be_amount\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 57);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 11[%*.*s]!", nThreadIndex, 57, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_amount", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_amount\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 65);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 12[%*.*s]!", nThreadIndex, 65, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_re_amount", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_re_amount\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 9, pRecvMessage + 73);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 13[%*.*s]!", nThreadIndex, 73, 9, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_terminal_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_terminal_id\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 16, pRecvMessage + 82);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 14[%*.*s]!", nThreadIndex, 82, 16, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_id\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 98);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 15[%*.*s]!", nThreadIndex, 98, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_seqno", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_seqno\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 108);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 16[%*.*s]!", nThreadIndex, 108, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_card_seqno", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_card_seqno\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 118);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 17[%*.*s]!", nThreadIndex, 118, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_algorithm_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_algorithm_id\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 120);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 18[%*.*s]!", nThreadIndex, 120, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_key_version", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_key_version\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 122);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 122, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_e_cash", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_e_cash\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 124);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 124, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_tot_seqno", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_tot_seqno\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 5, pRecvMessage + 134);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 21[%*.*s]!", nThreadIndex, 134, 5, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_collect_cnt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_collect_cnt\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 139);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 22[%*.*s]!", nThreadIndex, 139, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_tot_amount", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_tot_amount\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 149);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 23[%*.*s]!", nThreadIndex, 149, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sign_value", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sign_value\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 157);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 24[%*.*s]!", nThreadIndex, 157, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_person_code", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_person_code\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 12, pRecvMessage + 159);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 25[%*.*s]!", nThreadIndex, 159, 12, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_zipge_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_zipge_id\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 171);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 26[%*.*s]!", nThreadIndex, 171, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_alias_no", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_alias_no\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 7, pRecvMessage + 181);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 27[%*.*s]!", nThreadIndex, 181, 7, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_issue_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_issue_id\":\"%s\"", szTrimmedFieldData);

	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\n}");
//    nPostDataLength = sizeof(szPostDataBuffer);
//    pPostValueKey = curl_escape("id", 0);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);
//    pPostValueKey = curl_escape("name", 0);
//    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 8);
//    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);

    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00040010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;

    CURLcode nCurlResult;
    long nHttpCode;

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveWorkInfo.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00040010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Full[%*.*s]!", nThreadIndex, 0, 129, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 4);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 4, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 6);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 8);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 8, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_st_date", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_st_date\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 22);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 22, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_ed_date", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_ed_date\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 36);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 36, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_cash", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_cash\":\"%s\"", szTrimmedFieldData);

	nResult = GetCheckedValue(TYPE_FILENAME, szFieldData, 4, pRecvMessage + 40);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 40, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_cash", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_cash\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 44);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 44, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_free", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_free\":\"%s\"", szTrimmedFieldData);

	nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 48);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 9[%*.*s]!", nThreadIndex, 48, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_minap", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_minap\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 52);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 10[%*.*s]!", nThreadIndex, 52, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_coupon", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_coupon\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 56);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 11[%*.*s]!", nThreadIndex, 56, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_coupon", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_coupon\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 60);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 12[%*.*s]!", nThreadIndex, 60, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sun", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sun\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 64);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 13[%*.*s]!", nThreadIndex, 64, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_sun", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_sun\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 68);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 14[%*.*s]!", nThreadIndex, 68, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_who", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_who\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 72);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 15[%*.*s]!", nThreadIndex, 72, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_who", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_who\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 76);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 16[%*.*s]!", nThreadIndex, 76, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sale", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sale\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 80);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 17[%*.*s]!", nThreadIndex, 80, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_sale", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_sale\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 84);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 18[%*.*s]!", nThreadIndex, 84, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_total_amount", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_total_amount\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 92);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 92, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_repay_q", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 96);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 96, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_repay_m", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 104);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 104, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_prp_q", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 108);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 108, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_prp_m", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 116);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 116, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_prp_q", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 120);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 120, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_prp_m", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 128);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 21[%*.*s]!", nThreadIndex, 128, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_seqno", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_seqno\":\"%s\"", szTrimmedFieldData);
	
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\n}");
//    nPostDataLength = sizeof(szPostDataBuffer);
//    pPostValueKey = curl_escape("id", 0);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);
//    pPostValueKey = curl_escape("name", 0);
//    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 8);
//    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
//    pPostValueData = curl_escape(szTrimmedFieldData, 0);
//    snprintf(szPostDataBuffer + nPostDataBufferOffset, sizeof(szPostDataBuffer) - nPostDataBufferOffset, "%s=%s&", pPostValueKey, pPostValueData);
//    nPostDataBufferOffset = strnlen(szPostDataBuffer, sizeof(szPostDataBuffer));
//    curl_free(pPostValueKey);
//    curl_free(pPostValueData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);

    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00050010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char orgCarNo[255+1];
	char szCarNo[255+1];
	char putCarNp[16];
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveDayTrafficInfo.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00050010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Full[%*.*s]!", nThreadIndex, 0, 42, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 2, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 4);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 4, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_date", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_date\":\"%s\",", szTrimmedFieldData);
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 18);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 18, 6, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "d_seq", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"d_seq\":\"%s\",", szTrimmedFieldData);
	memset(szFieldData, 0x00, sizeof(szFieldData));
    sprintf(szFieldData, "%.16s", pRecvMessage + 24);

    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_car", szTrimmedFieldData);
	//sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_car\":\"%s\",", szTrimmedFieldData);
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 40);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 40, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_carkind", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_carkind\":\"%s\"", szTrimmedFieldData);
	nResult = GetCheckedValue(TYPE_FILENAME, szFieldData, 1, pRecvMessage + 41);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 41, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "c_id", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
	printf("CarNo[%s]\n", szCarNo);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
	}
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    return nFunctionResult;
}

#if 1

int MessageProc_00110010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char orgCarNo[255+1];
	char szCarNo[255+1];
	char putCarNp[16];
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;

    CURLcode nCurlResult;
    long nHttpCode;

	char in_date[8+1];
	char in_time[6+1];
	char in_seq[6+1];
	char in_hnd_div[2+1];
	char in_fare[2+1];
	char in_booth[2+1];
	char in_div[1+1];
	char in_car[16+1];
	char in_stop[50+1];
	char in_carkind[1+1];
	
	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/callCarNoDecision.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00110010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Full[%*.*s]!", nThreadIndex, 0, 108, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	sprintf(szFieldData, "00000001");
	Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "aiCarNoReqSeq", szTrimmedFieldData);
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "workerId", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"workerId\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 4);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 4, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "fareOfficeId", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"fareOfficeId\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 6);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "boothId", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"boothId\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 8);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 8, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "year", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"year\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 12);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 12, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "month", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"month\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 14, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "day", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"day\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 16);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 16, 6, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "workTimes", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"workTimes\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 22);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 22, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "seqno", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"seqno\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 54);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 54, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "collectId", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"collectId\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 77);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 77, 1, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "cardRet", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"cardRet\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 8);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 9[%*.*s]!", nThreadIndex, 8, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "passDate", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"passDate\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 56);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]AI Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 56, 6, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "passAmount", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"passAmount\":\"%s\",", szTrimmedFieldData);

	sprintf((char *)in_date, "%.8s", pRecvMessage + 8);
	sprintf((char *)in_time, "%.6s", pRecvMessage + 16);
	sprintf((char *)in_seq, "%.6s", pRecvMessage + 24);
	sprintf((char *)in_hnd_div, "%.2s", pRecvMessage + 54);
	sprintf((char *)in_fare, "%.2s", pRecvMessage + 4);
	sprintf((char *)in_booth, "%.2s", pRecvMessage + 6);
	sprintf((char *)in_div, "%.1s", pRecvMessage + 132);
	sprintf((char *)in_car, "%.16s", pRecvMessage + 38);
	sprintf((char *)in_carkind, "%.1s", pRecvMessage + 129);
	
    sprintf(in_stop, "%.8s_%.6s00_%.6s%.2s_%c%.2s%.1s_%.16s_%.1s", in_date, in_time, in_seq, in_hnd_div, in_fare[1], in_booth, in_div, in_car, in_carkind);
	memcpy(szFieldData, in_stop, strlen(in_stop));
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "carNoImgPath", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"carNoImgPath\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
	printf("CarNo[%s]\n", szCarNo);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00210010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
    char path[128], spath[128], tpath[128];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char* out_buf;
	char *sArr[10] = { NULL, };
	char *ptr;

    unsigned int  totCount = 0;
	unsigned int  repCount = 0;
	unsigned int  modCount = 0;
	
    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectPreRegistCarInfoMstCount.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00210010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BEF_MST Request Full[%*.*s]!", nThreadIndex, 0, 28, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BEF_MST Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BEF_MST Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		SafeStrCopy(szResult, nRespMessageLength, HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "Rcv 00210010[%s]\n", szResult);
		ptr = strtok(szResult, ",");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, ",");
		}

		for( i = 0; i < 10 ; i++)
		{
			if(sArr[i] != NULL)
				printf_s("Tok[%s]\n", sArr[i]);
			
			if(i == 1)
				sprintf(szTmp, "%s", sArr[i]);
		}

		//printf("[%s]\n", szTmp);
		memset(szResult, 0x00, sizeof(szResult));

		for(i = 0; i < strlen(szTmp); i++)
		{
			if(szTmp[i] >= '0' && szTmp[i] <= '9')
			{
				szResult[j] = szTmp[i];
				j++;
			}
		}

		printf("Count [%010d]\n", atoi(szResult));
		totCount = atoi(szResult);
		
		repCount = totCount / MSTLIMIT;
		modCount = totCount % MSTLIMIT;

		for(i = 0; i < repCount ; i++)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", i*MSTLIMIT+1, i*MSTLIMIT+MSTLIMIT, 1);
		    nResult = MessageProc_00210011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}

        if(modCount > 0)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", repCount*MSTLIMIT+1, repCount*MSTLIMIT+modCount, 1);
		    nResult = MessageProc_00210011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}
		//sprintf(pRecvMessage+28, "%010d%010d%010d", 1, 10000, atoi(szResult));
		nResult = MessageProc_00210020(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    if(lb_data2atoi(pRespCode, 4) == 0)
    {
        /*------------------------------------------------------*/
        /* OLD    ADVMST  ==>  ADVMST_O                */
        /*------------------------------------------------------*/
        sprintf(path, "%s/%s/ADVMST_O", DIR_TCS,DIR_BASEINFO);
        unlink(path);
    
        sprintf(spath, "%s/%s/ADVMST", DIR_TCS, DIR_BASEINFO);
        sprintf(tpath, "%s/%s/ADVMST_O", DIR_TCS, DIR_BASEINFO);
        lb_rename(spath, tpath);
    
        /*------------------------------------------------------*/
        /* NEW    ADVMST_S ==>  ADVMST                 */
        /*------------------------------------------------------*/
        sprintf(path, "%s/%s/ADVMST", DIR_TCS,DIR_BASEINFO);
        unlink(path);
    
        sprintf(spath, "%s/%s/ADVMST_S", DIR_TCS, DIR_BASEINFO);
        sprintf(tpath, "%s/%s/ADVMST", DIR_TCS, DIR_BASEINFO);
        lb_rename(spath, tpath);
    }
    
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00210011(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
	char szTmp2[MAX_STRING_SIZE + 1];
    int  nPostDataBufferOffset;
    int  nPostDataLength;
	int  nRecvCount = 0;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;
	unsigned int repCount = 0;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));
	memset(szTmp2, 0x00, sizeof(szTmp2));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectPreRegistCarInfoMst.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00210011 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
	repCount = atoi(szTrimmedFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

//WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "BEF MST[%s]\n", szResult);
		memcpy(szTmp2, szResult, sizeof(szResult));
		//printf("szResult[%s]\n", szResult);
		ptr = strstr(szTmp2, "result");
		//printf("listen[%s]\n", ptr);
		memset(szTmp, 0x00, sizeof(szTmp));
		sprintf(szTmp, "%s", ptr);
		//printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			if(i == 2)
			{
				sprintf(szTmp2, "%s", ptr);
			}
			sArr[i] = ptr;
			i++;
			//printf("[%d][%s]\n",i, ptr);
			ptr = strtok(NULL, "\"");
		}

		//sprintf(szTmp2, "%s", sArr[2]);

		//printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			//printf("STR 1 [%s]\n", szTmp2);
			ptr = strstr(szTmp2, "data");
			sprintf(szTmp, "%s", ptr);
			//printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);
			//printf("STR3 [%s]\n", szTmp2);
			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				nResult = make_befmst(repCount, &szTmp2);
			}

			//printf("szResult [%s]\n", szTmp2);
		}
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00210020(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
    char path[128], spath[128], tpath[128];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char* out_buf;
	char *sArr[10] = { NULL, };
	char *ptr;

    unsigned int  totCount = 0;
	unsigned int  repCount = 0;
	unsigned int  modCount = 0;
	
    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/updatePreRegistCarInfoMstFlag.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00210020 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BEF_MST Request Full[%*.*s]!", nThreadIndex, 0, 28, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		SafeStrCopy(szResult, nRespMessageLength, HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "Rcv 00210020[%s]\n", szResult);

	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00210030(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE*20 + 1];
	char szTmp[MAX_STRING_SIZE*20 + 1];
	char szTmp2[MAX_STRING_SIZE*20 + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    int chk = 0;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectPreRegistCarInfoChange.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00210030 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 48);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Bef_Data Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 48, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "req_seq", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"req_seq\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
        memset(szTmp2, 0x00, sizeof(szTmp2));
		sprintf(szResult, "%s", HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "BEF CHG[%s]\n", szResult);
		//sprintf(szResult, "%s", HtmlContextData.pData);
        //sprintf(szTmp2, "%s", szResult);
		memcpy(szTmp2, szResult, sizeof(szTmp2));
WriteLog(LogType_StandardOut, LogLevel_Info, "BEF CHG2[%s]\n", szTmp2);
		ptr = strstr(szTmp2, "result");
		printf("listen[%s]\n", ptr);
		memcpy(szTmp, ptr, strlen(ptr));
		printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, "\"");
		}

		sprintf(szTmp2, "%s", sArr[2]);

		printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			ptr = strstr(szTmp2, "data");
			memcpy(szTmp, ptr, strlen(ptr));
			printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);

			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				printf("szTmp2 [%s]\n", szTmp2);
				nResult = make_befchg(&szTmp2);
			}
		}
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);

    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}


int MessageProc_00220010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char* out_buf;
	char *sArr[10] = { NULL, };
	char *ptr;

    unsigned int  totCount = 0;
	unsigned int  repCount = 0;
	unsigned int  modCount = 0;
	
    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectExemptCarMstCount.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00220010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem_Cnt Request Full[%*.*s]!", nThreadIndex, 0, 28, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem_Cnt Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem_Cnt Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		SafeStrCopy(szResult, nRespMessageLength, HtmlContextData.pData);

		ptr = strtok(szResult, ",");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, ",");
		}

		for( i = 0; i < 10 ; i++)
		{
			if(sArr[i] != NULL)
				printf_s("Tok[%s]\n", sArr[i]);
			
			if(i == 1)
				sprintf(szTmp, "%s", sArr[i]);
		}

		//printf("[%s]\n", szTmp);
		memset(szResult, 0x00, sizeof(szResult));

		for(i = 0; i < strlen(szTmp); i++)
		{
			if(szTmp[i] >= '0' && szTmp[i] <= '9')
			{
				szResult[j] = szTmp[i];
				j++;
			}
		}

		printf("Count [%010d]\n", atoi(szResult));
		totCount = atoi(szResult);
		
		repCount = totCount / MSTLIMIT;
		modCount = totCount % MSTLIMIT;

		for(i = 0; i < repCount ; i++)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", i*MSTLIMIT+1, i*MSTLIMIT+MSTLIMIT, 1);
		    nResult = MessageProc_00220011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}

        if(modCount > 0)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", repCount*MSTLIMIT+1, repCount*MSTLIMIT+modCount, 1);
		    nResult = MessageProc_00220011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}
		//sprintf(pRecvMessage+28, "%010d%010d%010d", 1, 10000, atoi(szResult));
		//nResult = MessageProc_00210011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);

	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00220011(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
	char szTmp2[MAX_STRING_SIZE + 1];
    int  nPostDataBufferOffset;
    int  nPostDataLength;
	int  nRecvCount = 0;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;
	unsigned int repCount = 0;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectExemptCarMst.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00220011 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
	repCount = atoi(szTrimmedFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
		memcpy(szTmp2, szResult, sizeof(szResult));
		//printf("szResult[%s]\n", szResult);
		ptr = strstr(szTmp2, "result");
		//printf("listen[%s]\n", ptr);
		memset(szTmp, 0x00, sizeof(szTmp));
		sprintf(szTmp, "%s", ptr);
		//printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			if(i == 2)
			{
				sprintf(szTmp2, "%s", ptr);
			}
			sArr[i] = ptr;
			i++;
			//printf("[%d][%s]\n",i, ptr);
			ptr = strtok(NULL, "\"");
		}

		//sprintf(szTmp2, "%s", sArr[2]);

		//printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			//printf("STR 1 [%s]\n", szTmp2);
			ptr = strstr(szTmp2, "data");
			sprintf(szTmp, "%s", ptr);
			//printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);
			//printf("STR3 [%s]\n", szTmp2);
			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				nResult = make_exemptmst(repCount, &szTmp2);
			}

			//printf("szResult [%s]\n", szTmp2);
		}
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00220030(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE*20 + 1];
	char szTmp[MAX_STRING_SIZE*20 + 1];
	char szTmp2[MAX_STRING_SIZE*20 + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectExemptCarChange.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00220030 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 48);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Exem Data Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 48, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "req_seq", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"req_seq\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
		memcpy(szTmp2, szResult, sizeof(szResult));
		ptr = strstr(szTmp2, "result");
		//printf("listen[%s]\n", ptr);
		memcpy(szTmp, ptr, strlen(ptr));
		//printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, "\"");
		}

		sprintf(szTmp2, "%s", sArr[2]);

		//printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			ptr = strstr(szTmp2, "data");
			memcpy(szTmp, ptr, strlen(ptr));
			//printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);

			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				printf("szTmp2 [%s]\n", szTmp2);
				nResult = make_exemptchg(&szTmp2);
			}
		}
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00230010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char* out_buf;
	char *sArr[10] = { NULL, };
	char *ptr;

    unsigned int  totCount = 0;
	unsigned int  repCount = 0;
	unsigned int  modCount = 0;
	
    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectRfidMstCount.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00210010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Cnt Request Full[%*.*s]!", nThreadIndex, 0, 28, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Cnt Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Cnt Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		SafeStrCopy(szResult, nRespMessageLength, HtmlContextData.pData);

		ptr = strtok(szResult, ",");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, ",");
		}

		for( i = 0; i < 10 ; i++)
		{
			if(sArr[i] != NULL)
				printf_s("Tok[%s]\n", sArr[i]);
			
			if(i == 1)
				sprintf(szTmp, "%s", sArr[i]);
		}

		//printf("[%s]\n", szTmp);
		memset(szResult, 0x00, sizeof(szResult));

		for(i = 0; i < strlen(szTmp); i++)
		{
			if(szTmp[i] >= '0' && szTmp[i] <= '9')
			{
				szResult[j] = szTmp[i];
				j++;
			}
		}

		printf("Count [%010d]\n", atoi(szResult));
		totCount = atoi(szResult);
		
		repCount = totCount / MSTLIMIT2;
		modCount = totCount % MSTLIMIT2;

		for(i = 0; i < repCount ; i++)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", i*MSTLIMIT2+1, i*MSTLIMIT2+MSTLIMIT2, 1);
		    nResult = MessageProc_00230011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}

        if(modCount > 0)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", repCount*MSTLIMIT2+1, repCount*MSTLIMIT2+modCount, 1);
		    nResult = MessageProc_00230011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}
		//sprintf(pRecvMessage+28, "%010d%010d%010d", 1, 10000, atoi(szResult));
		//nResult = MessageProc_00210011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);

	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00230011(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
	char szTmp2[MAX_STRING_SIZE + 1];
    int  nPostDataBufferOffset;
    int  nPostDataLength;
	int  nRecvCount = 0;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;
	unsigned int repCount = 0;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));
	memset(szTmp2, 0x00, sizeof(szTmp2));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectRfidMst.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00230011 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
	repCount = atoi(szTrimmedFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
		memcpy(szTmp2, szResult, sizeof(szResult));
		//printf("szResult[%s]\n", szResult);
		ptr = strstr(szTmp2, "result");
		//printf("listen[%s]\n", ptr);
		memset(szTmp, 0x00, sizeof(szTmp));
		sprintf(szTmp, "%s", ptr);
		//printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			if(i == 2)
			{
				sprintf(szTmp2, "%s", ptr);
			}
			sArr[i] = ptr;
			i++;
			//printf("[%d][%s]\n",i, ptr);
			ptr = strtok(NULL, "\"");
		}

		//sprintf(szTmp2, "%s", sArr[2]);

		//printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			//printf("STR 1 [%s]\n", szTmp2);
			ptr = strstr(szTmp2, "data");
			sprintf(szTmp, "%s", ptr);
			//printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);
			//printf("STR3 [%s]\n", szTmp2);
			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				nResult = make_rfidmst(repCount, &szTmp2);
			}

			//printf("szResult [%s]\n", szTmp2);
		}
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00230030(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE*20 + 1];
	char szTmp[MAX_STRING_SIZE*20 + 1];
	char szTmp2[MAX_STRING_SIZE*20 + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectRfidChange.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00230030 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 48);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Low Pollution Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 48, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "req_seq", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"req_seq\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
		memcpy(szTmp2, szResult, sizeof(szResult));
		ptr = strstr(szTmp2, "result");
		printf("listen[%s]\n", ptr);
		memcpy(szTmp, ptr, strlen(ptr));
		printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, "\"");
		}

		sprintf(szTmp2, "%s", sArr[2]);

		printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			ptr = strstr(szTmp2, "data");
			memcpy(szTmp, ptr, strlen(ptr));
			printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);

			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				printf("szTmp2 [%s]\n", szTmp2);
				nResult = make_rfidchg(&szTmp2);
			}
		}
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00240010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char* out_buf;
	char *sArr[10] = { NULL, };
	char *ptr;

    unsigned int  totCount = 0;
	unsigned int  repCount = 0;
	unsigned int  modCount = 0;
	
    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectSmallCarMstCount.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00240010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Cnt Request Full[%*.*s]!", nThreadIndex, 0, 28, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Cnt Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Cnt Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		SafeStrCopy(szResult, nRespMessageLength, HtmlContextData.pData);

		ptr = strtok(szResult, ",");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, ",");
		}

		for( i = 0; i < 10 ; i++)
		{
			if(sArr[i] != NULL)
				printf_s("Tok[%s]\n", sArr[i]);
			
			if(i == 1)
				sprintf(szTmp, "%s", sArr[i]);
		}

		//printf("[%s]\n", szTmp);
		memset(szResult, 0x00, sizeof(szResult));

		for(i = 0; i < strlen(szTmp); i++)
		{
			if(szTmp[i] >= '0' && szTmp[i] <= '9')
			{
				szResult[j] = szTmp[i];
				j++;
			}
		}

		printf("Count [%010d]\n", atoi(szResult));
		totCount = atoi(szResult);
		
		repCount = totCount / MSTLIMIT;
		modCount = totCount % MSTLIMIT;

		for(i = 0; i < repCount ; i++)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", i*MSTLIMIT+1, i*MSTLIMIT+MSTLIMIT, 1);
		    nResult = MessageProc_00240011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}

        if(modCount > 0)
		{
			sprintf(pRecvMessage+28, "%010d%010d%010d", repCount*MSTLIMIT+1, repCount*MSTLIMIT+modCount, 1);
		    nResult = MessageProc_00240011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		}
		//sprintf(pRecvMessage+28, "%010d%010d%010d", 1, 10000, atoi(szResult));
		//nResult = MessageProc_00210011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);

	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00240011(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE + 1];
	char szTmp[MAX_STRING_SIZE + 1];
	char szTmp2[MAX_STRING_SIZE + 1];
    int  nPostDataBufferOffset;
    int  nPostDataLength;
	int  nRecvCount = 0;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;
	unsigned int repCount = 0;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectSmallCarMst.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00240011 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
	repCount = atoi(szTrimmedFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);


    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
		memcpy(szTmp2, szResult, sizeof(szResult));
		//printf("szResult[%s]\n", szResult);
		ptr = strstr(szTmp2, "result");
		//printf("listen[%s]\n", ptr);
		memset(szTmp, 0x00, sizeof(szTmp));
		sprintf(szTmp, "%s", ptr);
		//printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			if(i == 2)
			{
				sprintf(szTmp2, "%s", ptr);
			}
			sArr[i] = ptr;
			i++;
			//printf("[%d][%s]\n",i, ptr);
			ptr = strtok(NULL, "\"");
		}

		//sprintf(szTmp2, "%s", sArr[2]);

		//printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			//printf("STR 1 [%s]\n", szTmp2);
			ptr = strstr(szTmp2, "data");
			sprintf(szTmp, "%s", ptr);
			//printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);
			//printf("STR3 [%s]\n", szTmp2);
			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				nResult = make_scarmst(repCount, &szTmp2);
			}

			//printf("szResult [%s]\n", szTmp2);
		}
	}
//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

int MessageProc_00240030(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
	int i = 0, j = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE*20 + 1];
	char szTmp[MAX_STRING_SIZE*20 + 1];
	char szTmp2[MAX_STRING_SIZE*20 + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(szResult, 0x00, sizeof(szResult));
	memset(szTmp, 0x00, sizeof(szTmp));

//    @POST
//    curl -d "id=pyo&name=pyobeomhee" -X POST http://localhost:7080/users

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectSmallCarChange.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00240030 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Full[%*.*s]!", nThreadIndex, 0, 58, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "start_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"start_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 14);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 14, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "end_dt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"end_dt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 28);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 28, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_start", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_start\":\"%s\",", szTrimmedFieldData);
	
    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 38);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 38, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "index_end", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"index_end\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 48);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Reduction Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 48, 10, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "req_seq", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"req_seq\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);

WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
#if 0 //json 검색하여 반영
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYPEER, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함 
    curl_easy_setopt(pCurlContext, CURLOPT_SSL_VERIFYHOST, 1L); // 값을 false 하면 에러가 떠서 공식 문서 참고함
#endif
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 0
    iconv_close(ic);
#endif
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // Post Data 화면 표시
    //printf("Http Request Data : %s\n", szPostDataBuffer);
    // 응답 데이터 화면 표시
    //printf("Http Response Data : %s\n", HtmlContextData.pData);
    // Http 결과 코드 화면 표시
    //printf("Http Result Code:%ld\n", nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)

	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
		memset(szResult, 0x00, sizeof(szResult));
        memset(szTmp2, 0x00, sizeof(szTmp2));
		sprintf(szResult, "%s", HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "RED CHG[%s]\n", szResult);
		//sprintf(szResult, "%s", HtmlContextData.pData);
        //sprintf(szTmp2, "%s", szResult);
		memcpy(szTmp2, szResult, sizeof(szTmp2));
WriteLog(LogType_StandardOut, LogLevel_Info, "RED CHG2[%s]\n", szTmp2);
		ptr = strstr(szTmp2, "result");
		printf("listen[%s]\n", ptr);
		memcpy(szTmp, ptr, strlen(ptr));
		printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;
			
			ptr = strtok(NULL, "\"");
		}

		sprintf(szTmp2, "%s", sArr[2]);

		printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			ptr = strstr(szTmp2, "data");
			memcpy(szTmp, ptr, strlen(ptr));
			printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
				i++;
			
				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[2]);

			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				printf("szTmp2 [%s]\n", szTmp2);
				nResult = make_scarchg(&szTmp2);
			}
		}
	}

//printf_s("httpcode [%s]\n", nHttpCode);
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.

    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    //curl_easy_cleanup(pCurlContext);
    //curl_global_cleanup();
    return nFunctionResult;
}

#endif

#if 1 //2019.08.28 신규추가
int MessageProc_00310010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char orgCarNo[255+1];
	char szCarNo[255+1];
	char putCarNp[16];
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/callPreRegistDayCloseSummary.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00310010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Total Request Full[%*.*s]!", nThreadIndex, 0, 45, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 12, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Total Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 12, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "insttNo", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"insttNo\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 12);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Total Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 12, 3, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "insttCntcJobSe", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"insttCntcJobSe\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 15);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Total Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 15, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "requstDt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"requstDt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 29);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Total Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 29, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "startClosDt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"startClosDt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 37);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Total Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 37, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "endClosDt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"endClosDt\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00310010 Rcv Result[%s]\n", pRespMessage);
	    //nResult = MessageProc_00230011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);
		//sprintf(pRecvMessage+28, "%010d%010d%010d", 1, 10000, atoi(szResult));
		//nResult = MessageProc_00210011(nThreadIndex, pCurlContext, pRecvMessage, nRecvMessageLength, pRespMessage, nRespMessageLength, pRespCode);

	}
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
	}

    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.
    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00310010 pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    return nFunctionResult;
}

int MessageProc_00320010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char orgCarNo[255+1];
	char szCarNo[255+1];
	char putCarNp[16];
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/callPreRegistDayCloseReturn.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00320010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Return Request Full[%*.*s]!", nThreadIndex, 0, 45, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 12, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Return Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 12, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "insttNo", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"insttNo\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 12);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Return Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 12, 3, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "insttCntcJobSe", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"insttCntcJobSe\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 15);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Return Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 15, 14, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "requstDt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"requstDt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 29);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Return Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 29, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "startClosDt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"startClosDt\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 37);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]ADV_Return Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 37, 8, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "endClosDt", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"endClosDt\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00320010 Rcv Result[%s]\n", pRespMessage);
	}

    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.
    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG00320010 pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    return nFunctionResult;
}

int MessageProc_90010010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE*20 + 1];
	char szTmp[MAX_STRING_SIZE*20 + 1];
	char szTmp2[MAX_STRING_SIZE*20 + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char orgCarNo[255+1];
	char szCarNo[255+1];
	char putCarNp[16];
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;

    int i = 0, j = 0;
    char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectCreateBasicData.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG90010010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BASIC_TABLE Request Full[%*.*s]!", nThreadIndex, 0, 8, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BASIC_TABLE Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 4);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BASIC_TABLE Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 4, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 6);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]BASIC_TABLE Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "##### Rcv[%d][%s]\n", nRespMessageLength, HtmlContextData.pData);

		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
		memcpy(szTmp2, szResult, sizeof(szResult));
		ptr = strstr(szTmp2, "result");
		//printf("listen[%s]\n", ptr);
		memcpy(szTmp, ptr, strlen(ptr));
		//printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;

			ptr = strtok(NULL, "\"");
		}

		sprintf(szTmp2, "%s", sArr[2]);

		//printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			ptr = strstr(szTmp2, "data");
			memcpy(szTmp, ptr, strlen(ptr));
			//printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
//printf("### BASIC [%s] \n", sArr[i]);
				i++;

				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[4]);

			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				//printf("szTmp2 [%s]\n", szTmp2);
				nResult = make_basic(&szTmp2);
			}
		}

	}

    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.
    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    return nFunctionResult;
}

int MessageProc_90020010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
	char szResult[MAX_STRING_SIZE*20 + 1];
	char szTmp[MAX_STRING_SIZE*20 + 1];
	char szTmp2[MAX_STRING_SIZE*20 + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char orgCarNo[255+1];
	char szCarNo[255+1];
	char putCarNp[16];
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;

    int i = 0, j = 0;
    char *sArr[10] = { NULL, };
	char *ptr;

    CURLcode nCurlResult;
    long nHttpCode;

	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));

    // Base URL에 해당 함수의 URL 추가
    snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/selectWorkerInfo.do");
    curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
    curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

    // 메모리 데이터 수신 부 설정(수정 불필요)
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
    curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
WriteLog(LogType_StandardOut, LogLevel_Info, "MSG90020010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]WORKER_TABLE Request Full[%*.*s]!", nThreadIndex, 0, 42, pRecvMessage);

	memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
	//sprintf(szPostDataBuffer, "{\n");

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]WORKER_TABLE Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 0, 4, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    // 양쪽 트림 처리
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 4);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]WORKER_TABLE Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 4, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 6);
    if (nResult != STR_ERR_SUCCESS)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]WORKER_TABLE Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
        return RC_ERR_FORMAT;
    }
    Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
    nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
    //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
WriteLog(LogType_StandardOut, LogLevel_Info, "##### Rcv[%d][%s]\n", nRespMessageLength, HtmlContextData.pData);

		memset(szResult, 0x00, sizeof(szResult));
		sprintf(szResult, "%s", HtmlContextData.pData);
		memcpy(szTmp2, szResult, sizeof(szResult));
		ptr = strstr(szTmp2, "result");
		//printf("listen[%s]\n", ptr);
		memcpy(szTmp, ptr, strlen(ptr));
		//printf("STR [%s]\n", szTmp);
		memset(szTmp2, 0x00, sizeof(szTmp2));
		
		ptr = strtok(szTmp, "\"");
		while(ptr != NULL)
		{
			sArr[i] = ptr;
			i++;

			ptr = strtok(NULL, "\"");
		}

		sprintf(szTmp2, "%s", sArr[2]);

		//printf("Re [%s]\n", szTmp2);
		
		if(strncmp(szTmp2, "FAIL", 4) != 0)
		{
			memset(szTmp2, 0x00, sizeof(szTmp2));
			memset(szTmp, 0x00, sizeof(szTmp));
			i = 0;
			memcpy(szTmp2, szResult, sizeof(szResult));
			ptr = strstr(szTmp2, "data");
			memcpy(szTmp, ptr, strlen(ptr));
			//printf("STR 2 [%s]\n", szTmp);
			memset(szTmp2, 0x00, sizeof(szTmp2));
		
			ptr = strtok(szTmp, "\"");
			while(ptr != NULL)
			{
				sArr[i] = ptr;
//printf("### BASIC [%s] \n", sArr[i]);
				i++;

				ptr = strtok(NULL, "\"");
			}

			sprintf(szTmp2, "%s", sArr[4]);

			if(strcmp(szTmp2, "조회결과가 없습니다.") != 0)
			{
				//printf("szTmp2 [%s]\n", szTmp2);
				nResult = make_worker(&szTmp2);
			}
		}

	}

    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.
    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    return nFunctionResult;
}

#endif

#if 1
int MessageProc_99990010(int nThreadIndex, CURL *pCurlContext, char *pRecvMessage, int nRecvMessageLength, char *pRespMessage, int nRespMessageLength, char *pRespCode)
{
    int nResult;
    int nFunctionResult = 0;
    char szURLString[MAX_STRING_SIZE + 1];
    char szPostDataBuffer[MAX_STRING_SIZE + 1];
    char szFieldData[MAX_STRING_SIZE + 1];
    char szTrimmedFieldData[MAX_STRING_SIZE + 1];
    int nPostDataBufferOffset;
    int nPostDataLength;
    struct HTML_CONTEXT_DATA HtmlContextData = {NULL, 0};
    struct curl_slist *pHttpHeader;
    char *pPostValueKey;
    char *pPostValueData;
	
	char orgCarNo[255+1];
	char szCarNo[255+1];
	char putCarNp[16];
    
    char rcvhnd[2+1];
    char in_collect[2+1];
    char in_rfid_kbn[2+1];
    char buffer[100+1]; memset(buffer, 0x00, sizeof(buffer));
    char tmpFare[8+1]; memset(tmpFare, 0x00, sizeof(tmpFare));
    char iSeq[6+1]; memset(iSeq, 0x00, sizeof(iSeq));
    char pkind[2+1];
    int  jbcd, ii, chk_carno;
    int  in_cash = 0;
    int  in_k_cash = 0;
    int  in_free = 0;
    int  in_minap = 0;
    int  in_coupon = 0;
    int  in_k_coupon = 0;
    int  in_sun = 0;
    int  in_k_sun = 0;
    int  in_who = 0;
    int  in_k_who = 0;
    int  in_sale = 0;
    int  in_k_sale = 0;
    int  in_repay_q = 0;
    int  in_repay_m = 0;
	int  in_prp_q = 0;
    int  in_prp_m = 0;
	int  in_k_prp_q = 0;
    int  in_k_prp_m = 0;
    struct hi_wrk_start *wrk_start;
    struct hi_wrk_end *wrk_end;
    
	size_t in_size;
	size_t out_size;
	size_t out_buf_left;
	char* in_buf;
	char* out_buf;
    iconv_t ic = iconv_open("UTF-8", "EUC-KR");

	if(ic == (iconv_t) -1)
	{
		proc_log("###### Not Supported ICONV Code ###### \n");
	}

    CURLcode nCurlResult;
    long nHttpCode;

	memset(orgCarNo, 0x00, sizeof(orgCarNo));
	memset(szCarNo, 0x00, sizeof(szCarNo));

WriteLog(LogType_StandardOut, LogLevel_Info, "MSG99990010 Start!", nThreadIndex, 2, 2, pRecvMessage);
    // 프로토콜 0001 0010에 데이터가 아이디 8 바이트 이름 8 바이트 수신되는 기준 샘플 작성
    // 함수화 필요
    nPostDataBufferOffset = 0;
    // pRecvMessage에서 영문 및 숫자 8자까지 szFieldData로 포맷체크해서 복사
WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]DUAL TEST Full[%*.*s]!", nThreadIndex, 0, 2108, pRecvMessage);

    memcpy(pkind, pRecvMessage, 2);
    pkind[2] = '\0';
    
    //sprintf(szPostDataBuffer, "{\n");
    memset(szPostDataBuffer, 0x00, sizeof(szPostDataBuffer));
    
    jbcd = strtoul(pkind, NULL, 16);
    
    switch (jbcd)
    {
        case NS_CLOSE_PASS:
            // Base URL에 해당 함수의 URL 추가
            snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveDayTrafficInfo.do");
            curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
            curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

            // 메모리 데이터 수신 부 설정(수정 불필요)
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 2, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            // 양쪽 트림 처리
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage +2+2+14+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 2+2+14+1, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage +2+2+14+1+2+4+4+1+10+10+10+8+2+8+2+6);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+2+6, 14, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_date", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_date\":\"%s\",", szTrimmedFieldData);
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage +2+2+14+1+2+4+4+1+10+10+10+8+2+8+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+2, 6, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "d_seq", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"d_seq\":\"%s\",", szTrimmedFieldData);
            
            sprintf(orgCarNo, "%.16s", pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+2+6+14+1+2+1+1);
            del_space(orgCarNo);
            
            if(strlen(orgCarNo) == 0)
            {
                strncpy(szCarNo, "????????????", 12);
                chk_carno = 1;
            }else
            {
                in_size = strlen(orgCarNo);
                out_size = sizeof(wchar_t) * in_size * 4;
                in_buf = orgCarNo;
                out_buf = szCarNo;
                out_buf_left = out_size;
                printf("Original Car No[%s]\n", orgCarNo);
                nResult = iconv(ic, (char *)&in_buf, &in_size, (char *)&out_buf, &out_buf_left);
                if(nResult == -1)
                {
                    printf_s("ICONV FAILED [%d]\n", nResult);
                }
            }
            
            iconv_close(ic);
            
            printf("Incoding Car No[%s]\n", szCarNo);

            sprintf(szFieldData, "%.16s", szCarNo);

            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_car", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_car\":\"%s\",", szTrimmedFieldData);
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+2+6+14+1+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+2+6+14+1+2, 1, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_carkind", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_carkind\":\"%s\"", szTrimmedFieldData);
            
            nResult = GetCheckedValue(TYPE_FILENAME, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+2+6+14);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]CLOSE Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+2+6+14, 1, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "c_id", szTrimmedFieldData);
        break;
        case NS_HND_DATA:
        case NS_REFUND_DATA:
            // Base URL에 해당 함수의 URL 추가
            snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveCarThroughInfo.do");
            curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
            curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

            // 메모리 데이터 수신 부 설정(수정 불필요)
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
            
            memcpy(rcvhnd, pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1, 2);
            rcvhnd[2] = '\0';
            
            memcpy(iSeq, pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4, 6);
            iSeq[6] = '\0';

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4, 4, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            // 양쪽 트림 처리
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6, 14, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_date", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_date\":\"%s\",", szTrimmedFieldData);

            if(lb_data2atoi(rcvhnd, 2) > 19 && lb_data2atoi(rcvhnd, 2) < 30)
            {
                sprintf(buffer, "%.1s%.2s%5u%c", pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+1, pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2, lb_data2atoi(iSeq, 6), '\0');
            }else
            {
                sprintf(buffer, "%08u%c", lb_data2atoi(iSeq, 6), '\0');
            }

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 0, 8, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_seqno", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_seqno\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 0, 8, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_rf_seqno", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_rf_seqno\":\"%s\"", szTrimmedFieldData);

            sprintf(orgCarNo, "%.16s", pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1);
            del_space(orgCarNo);
            
            if(strlen(orgCarNo) == 0)
            {
                strncpy(szCarNo, "????????????", 12);
                chk_carno = 1;
            }else
            {
                in_size = strlen(orgCarNo);
                out_size = sizeof(wchar_t) * in_size * 4;
                in_buf = orgCarNo;
                out_buf = szCarNo;
                out_buf_left = out_size;
                printf("Original Car No[%s]\n", orgCarNo);
                nResult = iconv(ic, (char *)&in_buf, &in_size, (char *)&out_buf, &out_buf_left);
                if(nResult == -1)
                {
                    printf_s("ICONV FAILED [%d]\n", nResult);
                }
            }
            
            iconv_close(ic);
            
            printf("Incoding Car No[%s]\n", szCarNo);

            sprintf(szFieldData, "%.16s", szCarNo);
            //sprintf(szFieldData, "67저6731");
        
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_car", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_car\":\"%s\",", szTrimmedFieldData);

            switch(lb_data2atoi(rcvhnd, 2))
            {
                case 10:
                    sprintf(in_collect, "10");
                    break;
                case 11:
                case 12:
                case 13:
                case 14:
                    sprintf(in_collect, "11");
                    break;
                case 20:
                    sprintf(in_collect, "20");
                    break;
                case 21:
                    sprintf(in_collect, "21");
                    break;
                case 22:
                    sprintf(in_collect, "22");
                    break;
                case 23:
                case 25:
                case 27:
                    sprintf(in_collect, "23");
                    break;
                case 24:
                case 26:
                case 28:
                    sprintf(in_collect, "24");
                    break;
                case 30:
                    sprintf(in_collect, "30");
                    break;
                case 31:
                case 35:
                case 36:
                case 37:
                case 38:
                case 39:
                case 70:
                case 72:
                case 73:
                case 75:
                case 76:
                case 77:
                case 78:
                case 79:
                    sprintf(in_collect, "34");
                    break;
                case 32:
                    sprintf(in_collect, "32");
                    break;
                case 33:
                    sprintf(in_collect, "33");
                    break;
                case 34:
                case 65:
                case 67:
                    sprintf(in_collect, "30");
                    break;
                case 71:
                case 74:
                    sprintf(in_collect, "31");
                    break;
                case 40:
                case 41:
                case 60:
                case 61:
                case 62:
                case 63:
                case 64:
                case 66:
                    sprintf(in_collect, "40");
                    break;
                case 50:
                    sprintf(in_collect, "50");
                    break;
                case 51:
                    sprintf(in_collect, "51");
                    break;
                case 52:
                    sprintf(in_collect, "52");
                    break;
                case 53:
                case 55:
                case 56:
                    sprintf(in_collect, "53");
                    break;
                case 54:
                    sprintf(in_collect, "54");
                    break;
                default:
                    sprintf(in_collect, "00");
                    break;
            }
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, in_collect);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 0, 2, in_collect);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_collect", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_collect\":\"%s\"", szTrimmedFieldData);

            sprintf(szFieldData, "0");
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_army", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_army\":\"%s\",", szTrimmedFieldData);
        
            sprintf(szFieldData, " ");
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_stop", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_stop\":\"%s\"", szTrimmedFieldData);
        
            sprintf(szFieldData, " ");
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_move", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_move\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 12[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6, 6, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_amount", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_amount\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 13[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+1, 3, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_x", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_x\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 14[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+1, 3, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_y", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_y\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+4+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 15[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+4+1, 3, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_garo", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_garo\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 3, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+4+4+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 16[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+4+4+1, 3, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sero", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sero\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 17[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6, 1, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_card_ret", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_card_ret\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+3);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 18[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+3, 1, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_other", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_other\":\"%s\"", szTrimmedFieldData);
            switch(lb_data2atoi(rcvhnd, 2))
            {
                case 10:
                case 11:
                case 20:
                case 21:
                case 22:
                case 23:
                case 24:
                case 30:
                case 31:
                case 32:
                case 34:
                case 35:
                case 36:
                case 37:
                case 38:
                case 39:
                case 70:
                case 71:
                case 72:
                case 73:
                case 74:
                case 75:
                case 76:
                case 77:
                case 78:
                case 79:
                case 40:
                case 41:
                case 50:
                case 51:
                case 52:
                case 53:
                case 54:
                case 60:
                case 61:
                case 62:
                case 63:
                case 64:
                case 65:
                case 66:
                case 67:
                    sprintf(in_rfid_kbn, "00");
                    break;
                case 12:
                case 25:
                case 26:
                case 55:
                    sprintf(in_rfid_kbn, "01");
                    break;
                case 13:
                case 14:
                case 27:
                case 28:
                case 56:
                    sprintf(in_rfid_kbn, "03");
                    break;
                case 33:
                    sprintf(in_rfid_kbn, "02");
                    break;
                default:
                    sprintf(in_rfid_kbn, "00");
                    break;
            }
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, in_rfid_kbn);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 0, 2, in_rfid_kbn);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_rfid_kbn", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_rfid_kbn\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 48, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+4+4+4+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1+2+1+7+20+2+1+1+16+16+4+4+4+4+2, 48, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_tag", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_tag\":\"%s\"", szTrimmedFieldData);

            switch(lb_data2atoi(rcvhnd, 2))
            {
                case 31:
                    sprintf(szFieldData, "6");
                break;
                case 36:
                    sprintf(szFieldData, "7");
                break;
                default :
                    nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2);
                    if (nResult != STR_ERR_SUCCESS)
                    {
                        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 21[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2, 1, pRecvMessage);
                        return RC_ERR_FORMAT;
                    }
                break;
            }
            
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_carkind", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_carkind\":\"%s\"", szTrimmedFieldData);
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 22[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6+6+14+6+6+6+1+1, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_collect_new", szTrimmedFieldData);
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 23[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+2+1+6, 6, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sens_time", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sens_time\":\"%s\"", szTrimmedFieldData);
/*
            if(jbcd == NS_HND_DATA)
            {
                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 23[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6, 1, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "c_io", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"c_io\":\"%s\"", szTrimmedFieldData);
            }
*/
        break;
        case NS_CRD_HND_DATA:
            // Base URL에 해당 함수의 URL 추가
            snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveCardPaymentInfo.do");
            curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
            curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

            // 메모리 데이터 수신 부 설정(수정 불필요)
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
            
            memcpy(rcvhnd, pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8, 2);
            rcvhnd[2] = '\0';
            
            memcpy(iSeq, pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4, 6);
            iSeq[6] = '\0';
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4);

            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4, 4, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            // 양쪽 트림 처리
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2, 8, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_date", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_date\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 6, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+8);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+8, 6, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_time", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_time\":\"%s\",", szTrimmedFieldData);

            sprintf(buffer, "%.1s%.2s%5u%c", pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1, pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8, lb_data2atoi(iSeq, 6), '\0');

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 0, 8, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_seqno", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_seqno\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2, 1, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_kbn", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_kbn\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 16, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1, 16, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_card", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_card\":\"%s\"", szTrimmedFieldData);

            switch(lb_data2atoi(rcvhnd, 2))
            {
                case 10:
                    sprintf(in_collect, "10");
                    break;
                case 11:
                case 12:
                case 13:
                case 14:
                    sprintf(in_collect, "11");
                    break;
                case 20:
                    sprintf(in_collect, "20");
                    break;
                case 21:
                    sprintf(in_collect, "21");
                    break;
                case 22:
                    sprintf(in_collect, "22");
                    break;
                case 23:
                case 25:
                case 27:
                    sprintf(in_collect, "23");
                    break;
                case 24:
                case 26:
                case 28:
                    sprintf(in_collect, "24");
                    break;
                case 30:
                    sprintf(in_collect, "30");
                    break;
                case 31:
                case 35:
                case 36:
                case 37:
                case 38:
                case 39:
                case 70:
                case 72:
                case 73:
                case 75:
                case 76:
                case 77:
                case 78:
                case 79:
                    sprintf(in_collect, "34");
                    break;
                case 32:
                    sprintf(in_collect, "32");
                    break;
                case 33:
                    sprintf(in_collect, "33");
                    break;
                case 34:
                case 65:
                case 67:
                    sprintf(in_collect, "30");
                    break;
                case 71:
                case 74:
                    sprintf(in_collect, "31");
                    break;
                case 40:
                case 41:
                case 60:
                case 61:
                case 62:
                case 63:
                case 64:
                case 66:
                    sprintf(in_collect, "40");
                    break;
                case 50:
                    sprintf(in_collect, "50");
                    break;
                case 51:
                    sprintf(in_collect, "51");
                    break;
                case 52:
                    sprintf(in_collect, "52");
                    break;
                case 53:
                case 55:
                case 56:
                    sprintf(in_collect, "53");
                    break;
                case 54:
                    sprintf(in_collect, "54");
                    break;
                default:
                    sprintf(in_collect, "00");
                    break;
            }

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, in_collect);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 9[%*.*s]!", nThreadIndex, 0, 2, in_collect);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_collect", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_collect\":\"%s\",", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 10[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6, 8, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_be_amount", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_be_amount\":\"%s\"", szTrimmedFieldData);

            memset(buffer, 0x00, sizeof(buffer));
            memcpy(tmpFare, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6, 6);
            buffer[6] = '\0';
            
            sprintf(buffer, "%08u", lb_data2atoi(tmpFare, 6));
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 11[%*.*s]!", nThreadIndex, 0, 8, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_amount", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_amount\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 12[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8, 8, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_re_amount", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_re_amount\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 9, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+1);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 13[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+1, 9, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_terminal_id", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_terminal_id\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 16, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 14[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2, 16, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_id", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_id\":\"%s\"", szTrimmedFieldData);

            memset(buffer, 0x00, sizeof(buffer));
            memset(tmpFare, 0x00, sizeof(tmpFare));
            memcpy(tmpFare, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8, 8);
            tmpFare[8] = '\0';
            sprintf(buffer, "%010u%c", strtoul(tmpFare, NULL, 16), '\0');

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 15[%*.*s]!", nThreadIndex, 0, 10, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_seqno", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_seqno\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 16[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8, 10, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_card_seqno", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_card_seqno\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 17[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_algorithm_id", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_algorithm_id\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 18[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_key_version", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_key_version\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2+8+2+8);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2+8+2+8, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_e_cash", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_e_cash\":\"%s\"", szTrimmedFieldData);

            memset(buffer, 0x00, sizeof(buffer));
            memset(tmpFare, 0x00, sizeof(tmpFare));
            memcpy(tmpFare, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4, 8);
            tmpFare[8] = '\0';
            sprintf(buffer, "%010u%c", strtoul(tmpFare, NULL, 16), '\0');
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 0, 10, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_tot_seqno", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_tot_seqno\":\"%s\"", szTrimmedFieldData);

            memset(buffer, 0x00, sizeof(buffer));
            memset(tmpFare, 0x00, sizeof(tmpFare));
            memcpy(tmpFare, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8, 4);
            tmpFare[4] = '\0';
            sprintf(buffer, "%05u%c", strtoul(tmpFare, NULL, 16), '\0');

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 5, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 21[%*.*s]!", nThreadIndex, 0, 5, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_collect_cnt", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_collect_cnt\":\"%s\"", szTrimmedFieldData);

            memset(buffer, 0x00, sizeof(buffer));
            memset(tmpFare, 0x00, sizeof(tmpFare));
            memcpy(tmpFare, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10, 8);
            tmpFare[8] = '\0';
            sprintf(buffer, "%05u%c", strtoul(tmpFare, NULL, 16), '\0');

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 139);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 22[%*.*s]!", nThreadIndex, 139, 10, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sam_tot_amount", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sam_tot_amount\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 23[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2, 8, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sign_value", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sign_value\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2+8+2+8+2+7);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 24[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2+8+2+8+2+7, 2, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_person_code", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_person_code\":\"%s\"", szTrimmedFieldData);

            memset(buffer, 0x00, sizeof(buffer));
            sprintf(buffer, "9100000000%.2s%c", pRecvMessage+2+2+14+1+2+4+4+1+10+10+10+8+2+8, '\0');
            
            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 12, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 25[%*.*s]!", nThreadIndex, 0, 12, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_zipge_id", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_zipge_id\":\"%s\"", szTrimmedFieldData);

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 10, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2+8+2+8+2+7+2);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 26[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+8+4+4+6+1+2+14+6+6+8+8+2+2+1+1+20+2+10+10+2+16+8+2+6+10+8+8+10+8+4+8+2+8+2+8+2+7+2, 10, pRecvMessage);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_alias_no", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_alias_no\":\"%s\"", szTrimmedFieldData);

            //프로시져에서 수정
            memset(buffer, 0x00, sizeof(buffer));
            sprintf(buffer, "2000700%c", '\0');

            nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 7, buffer);
            if (nResult != STR_ERR_SUCCESS)
            {
                WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 27[%*.*s]!", nThreadIndex, 0, 7, buffer);
                return RC_ERR_FORMAT;
            }
            Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
            nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_issue_id", szTrimmedFieldData);
            //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_issue_id\":\"%s\"", szTrimmedFieldData);
        break;
        case NS_WRK_START:
        case NS_WRK_END:
            // Base URL에 해당 함수의 URL 추가
            snprintf(szURLString, sizeof(szURLString), "%s/%s", g_szBaseRestfulURL, "/cfs/trsmrcv/saveWorkInfo.do");
            curl_easy_setopt(pCurlContext, CURLOPT_URL, szURLString);
            curl_easy_setopt(pCurlContext, CURLOPT_NOPROGRESS, 1L);

            // 메모리 데이터 수신 부 설정(수정 불필요)
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEDATA, &HtmlContextData);
            curl_easy_setopt(pCurlContext, CURLOPT_WRITEFUNCTION, CURL_WriteMemoryCallback);
            
            if(jbcd == NS_WRK_START)
            {
                wrk_start = pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10;
                
                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+2+2+4+14+1+1+1+1);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+2+2+4+14+1+1+1+1, 4, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                // 양쪽 트림 처리
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 2, 2, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+2+2+4);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+2+2+4, 14, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_st_date", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_st_date\":\"%s\",", szTrimmedFieldData);
                
                memset(buffer, 0x30, sizeof(buffer));
                
                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 0, 14, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_ed_date", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_ed_date\":\"%s\",", szTrimmedFieldData);
                
                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_cash", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_cash\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_FILENAME, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_cash", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_cash\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_free", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_free\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 9[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_minap", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_minap\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 10[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_coupon", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_coupon\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 11[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_coupon", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_coupon\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 12[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sun", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sun\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 13[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_sun", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_sun\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 14[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_who", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_who\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 15[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_who", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_who\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 16[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sale", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sale\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 17[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_sale", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_sale\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 18[%*.*s]!", nThreadIndex, 0, 8, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_total_amount", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_total_amount\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 0, 4, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_repay_q", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 0, 8, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_repay_m", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_prp_q", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 0, 8, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_prp_m", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_prp_q", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 0, 8, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_prp_m", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+2+2+4+14+1+1+1+1+3);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 21[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+2+2+4+14+1+1+1+1+3, 1, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_seqno", szTrimmedFieldData);
            }else
            {
                wrk_end = pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10;
                
                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 1[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2, 4, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                // 양쪽 트림 처리
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_id", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_id\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 2[%*.*s]!", nThreadIndex, 2, 2, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_fare", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_fare\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 2, pRecvMessage + 2+2+14+1);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 3[%*.*s]!", nThreadIndex, 6, 2, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_booth", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_booth\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 4[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4, 14, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_st_date", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_st_date\":\"%s\",", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 14, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 5[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14, 14, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_ed_date", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_ed_date\":\"%s\",", szTrimmedFieldData);

                for(ii = 0; ii < 50; ii++)
                {
                    switch(lb_data2atoi(wrk_end->hnd_cnt[ii].div, 2))
                    {
                        case 10:
                            in_cash += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 11:
                        case 12:
                        case 13:
                        case 14:
                            in_k_cash += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 30:
                        case 31:
                        case 32:
                        case 33:
                        case 34:
                        case 35:
                        case 36:
                        case 37:
                        case 38:
                        case 39:
                        case 70:
                        case 71:
                        case 72:
                        case 73:
                        case 74:
                        case 75:
                        case 76:
                        case 77:
                        case 78:
                        case 79:
                            in_free += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 40:
                        case 41:
                        case 60:
                        case 61:
                        case 62:
                        case 63:
                        case 64:
                        case 65:
                        case 66:
                        case 67:
                            in_minap += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 51:
                            in_coupon += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 53:
                        case 55:
                        case 56:
                            in_k_coupon += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 21:
                            in_sun += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 23:
                        case 25:
                        case 27:
                            in_k_sun += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 22:
                            in_who += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 24:
                        case 26:
                        case 28:
                            in_k_who += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 52:
                            in_sale += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                        case 54:
                            in_k_sale += lb_data2atoi(wrk_end->hnd_cnt[ii].cnt, 4);
                            break;
                    }
                }

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_cash);
                
                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 6[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_cash", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_cash\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_k_cash);

                nResult = GetCheckedValue(TYPE_FILENAME, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 7[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_cash", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_cash\":\"%s\",", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_free);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 8[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_free", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_free\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_minap);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 9[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_minap", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_minap\":\"%s\",", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_coupon);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 10[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_coupon", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_coupon\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_k_coupon);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 11[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_coupon", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_coupon\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_sun);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 12[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sun", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sun\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_k_sun);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 13[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_sun", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_sun\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_who);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 14[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_who", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_who\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_k_who);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 15[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_who", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_who\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_sale);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 16[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_sale", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_sale\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_k_sale);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 17[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_sale", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_k_sale\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14+14+1+1+1+8+8+8+8+560+4+8);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 18[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14+14+1+1+1+8+8+8+8+560+4+8, 8, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_total_amount", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_total_amount\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14+14+1+1+1+8+8+8+8+560);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14+14+1+1+1+8+8+8+8+560, 4, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_repay_q", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14+14+1+1+1+8+8+8+8+560+4);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+4+14+14+1+1+1+8+8+8+8+560+4, 8, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_repay_m", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_prp_q);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_prp_q", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 8+1, "%08d", in_prp_m);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 0, 8, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_prp_m", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 4+1, "%04d", in_k_prp_q);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 4, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 19[%*.*s]!", nThreadIndex, 0, 4, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_prp_q", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_q\":\"%s\"", szTrimmedFieldData);

                memset(buffer, 0x00, sizeof(buffer));
                snprintf(buffer, 8+1, "%08d", in_k_prp_m);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 8, buffer);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 20[%*.*s]!", nThreadIndex, 0, 8, buffer);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_k_prp_m", szTrimmedFieldData);
                //sprintf(szPostDataBuffer+strlen(szPostDataBuffer), "\"in_repay_m\":\"%s\"", szTrimmedFieldData);

                nResult = GetCheckedValue(TYPE_ALPHA_NUMERIC, szFieldData, 1, pRecvMessage + 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+3);
                if (nResult != STR_ERR_SUCCESS)
                {
                    WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]Request Parsing FormatError 21[%*.*s]!", nThreadIndex, 2+2+14+1+2+4+4+1+10+10+10+8+2+4+8+3, 1, pRecvMessage);
                    return RC_ERR_FORMAT;
                }
                Trim(szTrimmedFieldData, sizeof(szTrimmedFieldData), szFieldData);
                nPostDataBufferOffset = CURL_SetEncodedPostData(nThreadIndex, pCurlContext, szPostDataBuffer, nPostDataBufferOffset, sizeof(szPostDataBuffer), "in_seqno", szTrimmedFieldData);
            }
        break;
    }
	
	
    // POST 데이터 설정
    curl_easy_setopt( pCurlContext , CURLOPT_POSTFIELDS ,szPostDataBuffer);
	printf("CarNo[%s]\n", szCarNo);
WriteLog(LogType_StandardOut, LogLevel_Info, "Param[%s]\n", szPostDataBuffer);
    // POST 요청 여부 설정
    curl_easy_setopt(pCurlContext, CURLOPT_POST, 1L);

    // Request Header 설정
    pHttpHeader = NULL;
    pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705) ");
	//pHttpHeader = curl_slist_append(pHttpHeader, "User-Agent: KOLIS-NET Z-Server");
    pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/x-www-form-urlencoded");
	//pHttpHeader = curl_slist_append(pHttpHeader, "Content-Type: application/json");
    curl_easy_setopt(pCurlContext, CURLOPT_HTTPHEADER, pHttpHeader);
    // Timeout 설정(소스코드 바꾸지 말고 설정파일에 값을 변경한다.
    curl_easy_setopt(pCurlContext, CURLOPT_TIMEOUT_MS, g_nResponseTimeout);
#if 1
    // Restful 요청
    nCurlResult = curl_easy_perform(pCurlContext);
    if (nCurlResult != CURLE_OK)
    {
        WriteLog(LogType_StandardOut, LogLevel_Info, "[Thread:%02d]curl_easy_perform() failed[%s]!", nThreadIndex, curl_easy_strerror(nCurlResult));
    }

    // Restful 처리 결과 코드 수신
    curl_easy_getinfo(pCurlContext, CURLINFO_HTTP_CODE, &nHttpCode);

    // 응답 데이터 변수 설정(수신된 응답 데이터를 파싱해서 클라이언트 응답으로 전송해야 될 경우 추가 처리 필요)
	
	if(HtmlContextData.pData != 0x00)
	{
		SafeStrCopy(pRespMessage, nRespMessageLength, HtmlContextData.pData);
	}
    // 처리 결과 코드 전송 : HTTP 200이면 정상 나머지 기타 오류 설정 HTTP결과 코드 추가 확인 후 변경 필요.
#endif
    switch (nHttpCode)
    {
    case 200:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_NORMAL));
        break;
    default:
        SafeStrCopy(pRespCode, SOCK_FRAME_LEN_RESP_CODE + 1, GetSocketRespCode(RESP_ETC));
    }
WriteLog(LogType_StandardOut, LogLevel_Info, "pRespCode [%s]\n", pRespCode);
    curl_slist_free_all(pHttpHeader);
    return nFunctionResult;
}
#endif
