131 lines
3.2 KiB
C++
131 lines
3.2 KiB
C++
|
|
#ifndef _Included_CODITSCAN_COMMON_H
|
|
#define _Included_CODITSCAN_COMMON_H
|
|
|
|
#pragma once
|
|
|
|
#if defined(WIN32)
|
|
#include <wtypes.h>
|
|
#else
|
|
//#define wchar_t char
|
|
//#define WCHAR char
|
|
#define BOOL bool
|
|
#define HANDLE void*
|
|
|
|
//#include <pthread.h>
|
|
#include <stdint.h>
|
|
#include <unistd.h>
|
|
#include <iostream>
|
|
#endif
|
|
|
|
#include <fstream>
|
|
|
|
#if !defined(WIN32)
|
|
|
|
#ifndef NULL
|
|
#define NULL 0
|
|
#endif
|
|
|
|
#define ARRAYSIZE(x) ( sizeof((x))/sizeof((x)[0]) ) // 배열 길이
|
|
#define ABS(x) ( ((x)<0)?-(x):(x) ) // 절대 값
|
|
#define SQUARE(x) ( (x)*(x) ) // 제곱근
|
|
//#define max(x,y) ((x)>(y) ? (x):(y)) // 최대 값
|
|
//#define min(x,y) ( (x) < (y) ? (x) : (y) ) // 최소 값
|
|
#define UPCASE(c) ( ( (c)>='a' && (c)<='z') ? (c)-('a'-'A') : (c) ) // 소문자->대문자
|
|
#define LOWCASE(c) ( ( (c)>='A' && (c)<='Z') ? (c)+('a'-'A') : (c) ) // 대문자->소문자
|
|
|
|
|
|
|
|
#define vsprintf_s(buf, size, fmt, ...) vsprintf(buf, fmt, ##__VA_ARGS__)
|
|
#define strcpy_s(dst, size, src) strcpy(dst, src)
|
|
#define strcat_s(dst, size, src) strcat(dst, src)
|
|
#define scanf_s(fmt, size, ...) scanf(fmt, ##__VA_ARGS__)
|
|
#define memmove_s(dst, size, src, count) memmove(dst, src, count)
|
|
#define gets_s(buf, size) gets(buf)
|
|
#define printf_s printf
|
|
#define fprintf_s fprintf
|
|
#define sprintf_s snprintf
|
|
#define _strdup strdup
|
|
#define _stricmp strcasecmp
|
|
#define _strnicmp strncasecmp
|
|
|
|
#define MAX_PATH 260
|
|
typedef signed long long __int64;
|
|
#define _fseeki64 fseeko
|
|
#define _ftelli64 ftello
|
|
typedef uint32_t DWORD;
|
|
|
|
#ifndef _vsnprintf
|
|
#define _vsnprintf vsnprintf
|
|
#endif
|
|
|
|
#ifndef _unlink
|
|
#define _unlink unlink
|
|
#endif
|
|
|
|
#ifndef _access
|
|
#define _access access
|
|
#endif
|
|
|
|
#ifndef Sleep
|
|
#define Sleep usleep
|
|
#endif
|
|
|
|
|
|
#define STR_BACKSLASH "/"
|
|
#define CHAR_BACKSLASH '/'
|
|
|
|
#define CDS_MSLEEP(x) usleep((1000 * x))
|
|
#define CDS_SSLEEP(x) sleep(x)
|
|
#else //!WIN32
|
|
|
|
#define CHAR_BACKSLASH '\\'
|
|
#define STR_BACKSLASH "\\"
|
|
|
|
#define CDS_MSLEEP(x) Sleep(x)
|
|
#define CDS_SSLEEP(x) Sleep((1000 * x))
|
|
#endif
|
|
|
|
#define STRING_TO_NUM1(x) (x-48)
|
|
#define STRING_TO_NUM2(x,y) ((x-48)*10+(y-48))
|
|
#define STRING_TO_NUM3(x,y,z) ((x-48)*100+(y-48)*10+(z-48))
|
|
#define STRING_TO_NUM4(x,y,z,a) ((x-48)*1000+(y-48)*100+(z-48)*10+(a-48))
|
|
#define STRING_TO_NUM6(x,y,z,a,b,c) ((x-48)*100000+(y-48)*10000+(z-48)*1000+(a-48)*100+(b-48)*10+(c-48))
|
|
|
|
|
|
|
|
#define IS_NUMBER(a) ((const char)a >= (const char)'0' && (const char)a <= (const char)'9')
|
|
#define IN_RANGE(var,minval,maxval) ((uint32_t)var >= (uint32_t)minval && (uint32_t)var <= (uint32_t)maxval) ? true : false
|
|
|
|
|
|
#if defined(WIN32)
|
|
#if !defined(CDS_CALL)
|
|
// for FAR PASCAL as default(DLL), or __cdecl for static...
|
|
#if defined(FAR) && defined(PASCAL)
|
|
#define CDS_CALL FAR PASCAL
|
|
#else
|
|
#define CDS_CALL _far __stdcall
|
|
#endif
|
|
#endif // !defined(CDS_CALL)
|
|
#else // defined(WIN32) // 기타 모든 경우(리눅스/Unix류)
|
|
#define CDS_CALL
|
|
#endif // defined(WIN32)
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
#ifdef _WIN64
|
|
#define GetPtr(a,b) (uint64_t)((uint64_t)a+(uint64_t)b)
|
|
#else
|
|
#define GetPtr(a,b) (uint32_t)((uint32_t)a+(uint32_t)b)
|
|
#endif
|
|
#elif __linux__
|
|
#define GetPtr(a,b) (uint64_t)((uint64_t)a+(uint64_t)b)
|
|
#elif __unix__
|
|
#elif defined(_POSIX_VERSION)
|
|
#else
|
|
# error "Unknown compiler"
|
|
#endif
|
|
|
|
#endif //_Included_CODITSCAN_COMMON_H
|