Changeset 128 in libcf
- Timestamp:
- 06/22/13 12:03:53 (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_base.h
r119 r128 1 1 /** 2 * \file cf_base.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_base.h 3 * 4 * \author myusgun <myusgun@gmail.com> 5 * 4 6 * \version 0.1 5 7 * -
trunk/include/cf_codec.h
r119 r128 1 1 /** 2 * \file cf_codec.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_codec.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 데이터 변환 … … 11 12 12 13 #include "cf_base.h" 14 #include "cf_type.h" 13 15 14 16 #include <stddef.h> … … 19 21 20 22 CF_EXPORT int 21 CF_Codec_Hex_Encode (const unsigned char* bin,22 const size_t 23 char 23 CF_Codec_Hex_Encode (const cf_byte * bin, 24 const size_t len, 25 char * hex); 24 26 25 27 CF_EXPORT int 26 CF_Codec_Hex_Decode (const char 27 unsigned char* bin,28 size_t 28 CF_Codec_Hex_Decode (const char * hex, 29 cf_byte * bin, 30 size_t * len); 29 31 30 32 CF_EXPORT int 31 CF_Codec_Base64_Encode (const unsigned char* bin,32 const size_t 33 char 33 CF_Codec_Base64_Encode (const cf_byte * bin, 34 const size_t len, 35 char * base64); 34 36 35 37 CF_EXPORT int 36 CF_Codec_Base64_Decode (const char 37 unsigned char* bin,38 size_t 38 CF_Codec_Base64_Decode (const char * base64, 39 cf_byte * bin, 40 size_t * len); 39 41 40 42 #ifdef __cplusplus -
trunk/include/cf_debug.h
r120 r128 1 1 /** 2 * \file cf_debug.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_debug.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 디버그 유틸 … … 17 18 18 19 #include "cf_base.h" 20 #include "cf_type.h" 19 21 20 22 #include <stdio.h> … … 92 94 93 95 CF_EXPORT int 94 CF_Debug_PrintBin (FILE 95 const char 96 const char 97 const int 98 const unsigned char* bin,99 const size_t 100 const char 96 CF_Debug_PrintBin (FILE * fp, 97 const char * file, 98 const char * func, 99 const int line, 100 const cf_byte * bin, 101 const size_t len, 102 const char * fmt, ...); 101 103 102 104 CF_EXPORT int -
trunk/include/cf_error.h
r123 r128 1 1 /** 2 * \file cf_error.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_error.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 오류코드 모음 … … 14 15 15 16 /* file {{{ */ 16 #define CF_ERROR_FILE CF_ERROR_BASE * 217 #define CF_ERROR_FILE CF_ERROR_BASE * 1 17 18 /*------------------------------------------------------------*/ 18 19 #define CF_ERROR_FILE_OPEN CF_ERROR_FILE - 1 … … 24 25 #define CF_ERROR_FILE_GET_SIZE CF_ERROR_FILE - 7 25 26 #define CF_ERROR_FILE_MAKE_DIRECTORY CF_ERROR_FILE - 8 26 27 27 /* }}} file */ 28 28 29 29 /* socket {{{ */ 30 #define CF_ERROR_SOCKET CF_ERROR_BASE * 330 #define CF_ERROR_SOCKET CF_ERROR_BASE * 2 31 31 /*------------------------------------------------------------*/ 32 32 #define CF_ERROR_SOCKET_INITIALIZE CF_ERROR_SOCKET - 1 … … 51 51 52 52 /* thread {{{ */ 53 #define CF_ERROR_THREAD CF_ERROR_BASE * 453 #define CF_ERROR_THREAD CF_ERROR_BASE * 3 54 54 /*------------------------------------------------------------*/ 55 55 #define CF_ERROR_THREAD_CREATE_CTX CF_ERROR_THREAD - 1 … … 64 64 65 65 /* mutex {{{ */ 66 #define CF_ERROR_MUTEX CF_ERROR_BASE * 566 #define CF_ERROR_MUTEX CF_ERROR_BASE * 4 67 67 /*------------------------------------------------------------*/ 68 68 #define CF_ERROR_MUTEX_CREATE_CTX CF_ERROR_MUTEX - 1 … … 73 73 74 74 /* debug {{{ */ 75 #define CF_ERROR_DEBUG CF_ERROR_BASE * 675 #define CF_ERROR_DEBUG CF_ERROR_BASE * 5 76 76 /*------------------------------------------------------------*/ 77 77 #define CF_ERROR_DEBUG_INVALID_CTX CF_ERROR_DEBUG - 1 … … 83 83 84 84 /* log {{{ */ 85 #define CF_ERROR_LOG CF_ERROR_BASE * 785 #define CF_ERROR_LOG CF_ERROR_BASE * 6 86 86 /*------------------------------------------------------------*/ 87 87 #define CF_ERROR_LOG_INITIALIZE CF_ERROR_LOG - 1 … … 103 103 104 104 /* codec {{{ */ 105 #define CF_ERROR_CODEC CF_ERROR_BASE * 8105 #define CF_ERROR_CODEC CF_ERROR_BASE * 7 106 106 /*------------------------------------------------------------*/ 107 107 #define CF_ERROR_CODEC_INVALID_ARGS CF_ERROR_CODEC - 1 … … 111 111 112 112 /* data structure - list/queue/stack {{{ */ 113 #define CF_ERROR_DS CF_ERROR_BASE * 9113 #define CF_ERROR_DS CF_ERROR_BASE * 8 114 114 /*------------------------------------------------------------*/ 115 115 #define CF_ERROR_DS_INVALID_CTX CF_ERROR_DS - 1 … … 121 121 /* }}} data structure - list/queue/stack */ 122 122 123 /* bitwise {{{ */ 124 #define CF_ERROR_BITWISE CF_ERROR_BASE * 9 125 /*------------------------------------------------------------*/ 126 #define CF_ERROR_BITWISE_INVALID_ARGS CF_ERROR_BITWISE - 1 127 #define CF_ERROR_BITWISE_ALLOCATE_BUFFER CF_ERROR_BITWISE - 2 128 /* }}} bitwise */ 129 123 130 #endif // #ifndef __CF_ERROR_H__ -
trunk/include/cf_file.h
r119 r128 1 1 /** 2 * \file cf_file.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_file.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 파일 입출력 -
trunk/include/cf_list.h
r119 r128 1 1 /** 2 * \file cf_list.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_list.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 연결 리스트 -
trunk/include/cf_log.h
r119 r128 1 1 /** 2 * \file cf_log.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_log.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 로그 -
trunk/include/cf_mutex.h
r126 r128 1 1 /** 2 * \file cf_mutex.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_mutex.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 뮤텍스 지원 -
trunk/include/cf_queue.h
r119 r128 1 1 /** 2 * \file cf_queue.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_queue.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 큐 -
trunk/include/cf_socket.h
r119 r128 1 1 /** 2 * \file cf_socket.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_socket.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief TCP 소켓 지원 -
trunk/include/cf_stack.h
r119 r128 1 1 /** 2 * \file cf_stack.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_stack.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 스택 -
trunk/include/cf_thread.h
r126 r128 1 1 /** 2 * \file cf_thread.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_thread.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 멀티스레드 지원 -
trunk/src/cf_codec.c
r119 r128 1 1 /** 2 * \file cf_codec.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_codec.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 데이터 변환 구현 6 7 */ 7 8 #include "cf_codec.h" 9 #include "cf_type.h" 8 10 #include "cf_error.h" 9 11 … … 15 17 return CF_ERROR_CODEC_INVALID_ARGS 16 18 17 const static unsigned charg_ascii_HexDecode[] = {19 const static cf_byte g_ascii_HexDecode[] = { 18 20 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00 - 15 */ 19 21 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16 - 31 */ … … 48 50 }; 49 51 50 const static unsigned charg_ascii_Base64Decode[] = {52 const static cf_byte g_ascii_Base64Decode[] = { 51 53 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, /* 00 - 15 */ 52 54 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, /* 16 - 31 */ … … 82 84 */ 83 85 int 84 CF_Codec_Hex_Encode (const unsigned char* bin,85 const size_t 86 char 86 CF_Codec_Hex_Encode (const cf_byte * bin, 87 const size_t len, 88 char * hex) 87 89 { 88 90 size_t iter = 0; 89 91 size_t hexlen = len * 2 + 1; 90 92 91 const unsigned char* ptr = bin;93 const cf_byte * ptr = bin; 92 94 93 95 const static char hexchar[] = {'0', '1', '2', '3', … … 122 124 */ 123 125 int 124 CF_Codec_Hex_Decode (const char 125 unsigned char* bin,126 size_t 126 CF_Codec_Hex_Decode (const char * hex, 127 cf_byte * bin, 128 size_t * len) 127 129 { 128 size_t length = 0; /* absolutely even-number */129 size_t iter = 0;130 size_t binlen = 0;131 132 const char 133 char 134 unsigned charval = 0;135 unsigned charasciiHex = 0;130 size_t length = 0; /* absolutely even-number */ 131 size_t iter = 0; 132 size_t binlen = 0; 133 134 const char * ptr = hex; 135 char buf = 0; 136 cf_byte val = 0; 137 cf_byte asciiHex = 0; 136 138 137 139 ASSERT_ARGS (hex == NULL); … … 156 158 do { \ 157 159 buf = *(x); \ 158 val = ( unsigned char)(val << 4); \160 val = (cf_byte)(val << 4); \ 159 161 asciiHex = g_ascii_HexDecode[(int)buf]; \ 160 162 \ 161 val |= ( unsigned char) \163 val |= (cf_byte) \ 162 164 (buf - asciiHex + (asciiHex == '0' ? 0 : 10)); \ 163 165 } while (0) … … 188 190 */ 189 191 int 190 CF_Codec_Base64_Encode (const unsigned char* bin,192 CF_Codec_Base64_Encode (const cf_byte * bin, 191 193 const size_t len, 192 194 char * base64) 193 195 { 194 const unsigned char* src = bin;195 char 196 const cf_byte * src = bin; 197 char * dst = base64; 196 198 197 199 ASSERT_ARGS (src == NULL); … … 252 254 int 253 255 CF_Codec_Base64_Decode (const char * base64, 254 unsigned char* bin,256 cf_byte * bin, 255 257 size_t * len) 256 258 { 257 const char 258 unsigned char* dst = bin;259 int 260 int 259 const char * src = base64; 260 cf_byte * dst = bin; 261 int remain = 0; 262 int binlen = 0; 261 263 262 264 ASSERT_ARGS (src == NULL); … … 283 285 for (src = base64 ; remain > 4 ; remain -= 4, src += 4) 284 286 { 285 *dst++ = ( unsigned char)(SEXTUPLE_D_1 (src) | SEXTUPLE_D_2 (src));286 *dst++ = ( unsigned char)(SEXTUPLE_D_3 (src) | SEXTUPLE_D_4 (src));287 *dst++ = ( unsigned char)(SEXTUPLE_D_5 (src) | SEXTUPLE_D_6 (src));287 *dst++ = (cf_byte)(SEXTUPLE_D_1 (src) | SEXTUPLE_D_2 (src)); 288 *dst++ = (cf_byte)(SEXTUPLE_D_3 (src) | SEXTUPLE_D_4 (src)); 289 *dst++ = (cf_byte)(SEXTUPLE_D_5 (src) | SEXTUPLE_D_6 (src)); 288 290 } 289 291 290 292 if (remain > 1) 291 *dst++ = ( unsigned char)(SEXTUPLE_D_1 (src) | SEXTUPLE_D_2 (src));293 *dst++ = (cf_byte)(SEXTUPLE_D_1 (src) | SEXTUPLE_D_2 (src)); 292 294 if (remain > 2) 293 *dst++ = ( unsigned char)(SEXTUPLE_D_3 (src) | SEXTUPLE_D_4 (src));295 *dst++ = (cf_byte)(SEXTUPLE_D_3 (src) | SEXTUPLE_D_4 (src)); 294 296 if (remain > 3) 295 *dst++ = ( unsigned char)(SEXTUPLE_D_5 (src) | SEXTUPLE_D_6 (src));297 *dst++ = (cf_byte)(SEXTUPLE_D_5 (src) | SEXTUPLE_D_6 (src)); 296 298 297 299 return binlen - (4 - remain); -
trunk/src/cf_debug.c
r125 r128 1 1 /** 2 * \file cf_debug.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_debug.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 디버그 유틸 구현 … … 75 76 76 77 static int 77 CF_Debug_Local_PrintBin (FILE 78 const char 79 const char 80 const int 81 const unsigned char* bin,82 const size_t 78 CF_Debug_Local_PrintBin (FILE * fp, 79 const char * file, 80 const char * func, 81 const int line, 82 const cf_byte * bin, 83 const size_t len) 83 84 { 84 85 size_t i, j; … … 156 157 */ 157 158 int 158 CF_Debug_PrintBin (FILE 159 const char 160 const char 161 const int 162 const unsigned char* bin,163 const size_t 164 const char 159 CF_Debug_PrintBin (FILE * fp, 160 const char * file, 161 const char * func, 162 const int line, 163 const cf_byte * bin, 164 const size_t len, 165 const char * fmt, ...) 165 166 { 166 167 va_list valist; -
trunk/src/cf_file.c
r119 r128 1 1 /** 2 * \file cf_file.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_file.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 파일 입출력 구현 -
trunk/src/cf_list.c
r119 r128 1 1 /** 2 * \file cf_list.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_list.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 연결 리스트 구현 -
trunk/src/cf_local.h
r119 r128 1 1 /** 2 * \file cf_local.h 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_local.h 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 */ 5 6 #ifndef __CF_LOCAL_H__ -
trunk/src/cf_log.c
r127 r128 1 1 /** 2 * \file cf_log.c 3 * \author myusgun <myusgun@gmail.com> 4 * \author vfire 2 * \file cf_log.c 3 * 4 * \author myusgun <myusgun@gmail.com> 5 * \author vfire 5 6 * 6 7 * \brief 로그 구현 -
trunk/src/cf_mutex.c
r126 r128 1 1 /** 2 * \file cf_mutex.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_mutex.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 뮤텍스 구현 -
trunk/src/cf_queue.c
r119 r128 1 1 /** 2 * \file cf_queue.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_queue.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 큐 구현 -
trunk/src/cf_socket.c
r119 r128 1 1 /** 2 * \file cf_socket.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_socket.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief TCP 소켓 구현 -
trunk/src/cf_stack.c
r119 r128 1 1 /** 2 * \file cf_stack.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_stack.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 스택 구현 -
trunk/src/cf_thread.c
r126 r128 1 1 /** 2 * \file cf_thread.c 3 * \author myusgun <myusgun@gmail.com> 2 * \file cf_thread.c 3 * 4 * \author myusgun <myusgun@gmail.com> 4 5 * 5 6 * \brief 멀티 스레드 구현 -
trunk/src/makefile
r126 r128 19 19 cf_queue \ 20 20 cf_stack \ 21 cf_bitwise \ 21 22 22 23 TARGET_NAME = cf
Note:
See TracChangeset
for help on using the changeset viewer.