
#ifndef __RESTFULCONVERTER_H__
#define __RESTFULCONVERTER_H__

#ifdef __cplusplus
#ifndef BEGIN_DECLS
#define BEGIN_DECLS extern "C" {
#endif
#ifndef END_DECLS
#define END_DECLS }
#endif
#else
#ifndef BEGIN_DECLS
#define BEGIN_DECLS
#endif
#ifndef END_DECLS
#define END_DECLS
#endif
#endif

BEGIN_DECLS


#include <limits.h>

#ifdef _WIN32
#include <wchar.h>
#endif

#include <curl/curl.h>

#include "Common.h"
#include "StringUtil.h"
#include "Log.h"
#include "MessageQueue.h"
#include "SystemUtil.h"
#include "SecureCodingUtil.h"
#include "MessageInfo.h"


#define MP_ERR_SUCCESS              0
#define MP_ERR_CONFIG               -1

#define RC_RESTFULAPI_BASE_URL_KEY  "RESTFULAPI_BASE_URL"
#define RC_RESPONSE_TIMEOUT_KEY     "RESPONSE_TIMEOUT"

extern char g_szProcessname[MAX_STRING_SIZE + 1];
extern char g_szProcessPath[PATH_MAX + 1];
extern char g_szBaseRestfulURL[MAX_STRING_SIZE + 1];
extern int g_nResponseTimeout;

struct MESSAGE_FRAME
{
    char szMessageLength[4 + 1];
    char szOrganizationCode[6 + 1];
    char cOccurType;
    char szWorkType[4 + 1];
    char szMsgType[4 + 1];
    char szSerialNo[8 + 1];
    char szRequestDateTime[14 + 1];
    char szRespCode[4 + 1];
    char szData[MAX_STRING_SIZE + 1];
};
// 각 컬럼별로 하나씩 하는 이유는 배열 전체로 할 경우 byte alignment로 인해 실제 사이즈와 다를 수 있기 때문이다.
#define MESSAGE_FRAME_SIZE (sizeof(((struct MESSAGE_FRAME *)0)->szMessageLength) - 1 + sizeof(((struct MESSAGE_FRAME *)0)->szOrganizationCode) - 1 + 1 + sizeof(((struct MESSAGE_FRAME *)0)->szWorkType) + sizeof(((struct MESSAGE_FRAME *)0)->szMsgType) + sizeof(((struct MESSAGE_FRAME *)0)->szSerialNo) + sizeof(((struct MESSAGE_FRAME *)0)->szRequestDateTime) + sizeof(((struct MESSAGE_FRAME *)0)->szRespCode))

int InitMessageProcessConfig();
void *WorkThread(void *pData);

END_DECLS

#endif
