Changeset 66 in libcf


Ignore:
Timestamp:
04/11/13 13:02:05 (11 years ago)
Author:
cheese
Message:

#1 add codec module (bin <-> hex-string)

Location:
trunk
Files:
3 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_debug.h

    r64 r66  
    22 * @file    cf_debug.h
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 *
    65 * @remark
     
    87 * Preprocessor에 _DEBUG가 정의되어 있는 경우에 만
    98 * 디버그 코드가 동작하도록 할 수 있음 <br />
    10  * 디버그 메시지는 stdout 및 stderr를 이용한 파일 포인터 출력을 지원하고,
    11  * 환경에 적합하도록 사용자가 구성한 컨텍스트를 이용하여 사용할 수도 있음 <br />
    12  * (단, 콜스택의 푸시/팝은 컨텍스트를 이용해야만 사용 가능)
     9 * 디버그 메시지는 stdout 및 stderr 등의 파일 포인터 출력을 지원함
    1310 *
    1411 * @example debug.c
     
    2017
    2118#include <stdio.h>
     19#include <stddef.h>
    2220
    2321/** Windows 함수 이름 매크로 재정의 */
     
    121119                         const int              line,
    122120                         const unsigned char    * bin,
    123                          const int              len,
     121                         const size_t           len,
    124122                         const char             * fmt, ...);
    125123
  • trunk/include/cf_error.h

    r51 r66  
     1/**
     2 * @file    cf_error.h
     3 * @author  myusgun <myusgun@gmail.com>
     4 */
    15#ifndef __CF_ERROR_H__
    26#define __CF_ERROR_H__
     
    8892/* }}} log */
    8993
     94/* codec {{{ */
     95#define CF_ERROR_CODEC                      CF_ERROR_BASE * 8
     96/*------------------------------------------------------------*/
     97#define CF_ERROR_CODEC_INVALID_ARGS         CF_ERROR_CODEC - 1
     98#define CF_ERROR_CODEC_NOT_HEXSTRING        CF_ERROR_CODEC - 2
     99/* }}} codec */
     100
    90101
    91102#endif // #ifndef __CF_ERROR_H__
  • trunk/include/cf_file.h

    r41 r66  
    22 * @file    cf_file.h
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 *
    65 * @example file.c
  • trunk/include/cf_log.h

    r40 r66  
    22 * @file    cf_log.h
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
     4 *
     5 * @remark
     6 * 매핑 ID 값을 이용하여 해당 로그에 기록 <br />
     7 * 로그 레벨을 적용할 때도 용이하며 define 이나 enumeration 등을 활용하면 좋음
    58 *
    69 * @example log.c
  • trunk/include/cf_socket.h

    r53 r66  
    22 * @file    cf_socket.h
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 *
    65 * @remark TCP 소켓만 지원됨
  • trunk/include/cf_thread.h

    r59 r66  
    22 * @file    cf_thread.h
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 *
    65 * @remark 멀티스레드 및 뮤텍스 지원
  • trunk/src/cf_debug.c

    r63 r66  
    22 * @file    cf_debug.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_debug.h"
     
    105104                         const int              line,
    106105                         const unsigned char    * bin,
    107                          const int              len)
     106                         const size_t           len)
    108107{
    109108    int i, j;
     
    186185                   const int            line,
    187186                   const unsigned char  * bin,
    188                    const int            len,
     187                   const size_t         len,
    189188                   const char           * fmt, ...)
    190189{
  • trunk/src/cf_file.c

    r58 r66  
    22 * @file    cf_file.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_file.h"
     6#include "cf_local.h"
    77#include "cf_error.h"
    88
     
    1818# define mkdir(a,b)     _mkdir (a)
    1919# define access(a,b)    _access (a,b)
    20 # define snprintf       _snprintf
    2120
    2221# define F_OK           0
  • trunk/src/cf_local.h

    r23 r66  
    11/**
    2  * cf_local.h
     2 * @file    cf_local.h
     3 * @author  myusgun <myusgun@gmail.com>
    34 */
    45#ifndef __CF_LOCAL_H__
     
    1213#define CATCH_ELSE              else
    1314
     15#if defined(_WIN32) || defined(_WIN64)
     16# define snprintf       _snprintf
     17#else
     18#endif
     19
    1420#endif // #ifndef __CF_LOCAL_H__
  • trunk/src/cf_log.c

    r64 r66  
    22 * @file    cf_log.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#if defined(_WIN32) || defined(_WIN64)
     
    2120
    2221#if defined(_WIN32) || defined(_WIN64)
    23 # define snprintf       _snprintf
    2422# include <Windows.h>
    2523#else
     
    7674
    7775#if defined(_WIN32) || defined(_WIN64)
    78 /* #if defined(_WIN32) || defined(_WIN64) {{{ */
     76/* {{{ */
    7977struct timezone
    8078{
    81     int tz_minuteswest; /* minutes W of Greenwich */
    82     int tz_dsttime;     /* type of dst correction */
     79    int tz_minuteswest; /* minutes W of Greenwich */
     80    int tz_dsttime;     /* type of dst correction */
    8381};
    8482
    85 // Definition of a gettimeofday function
    86 int gettimeofday(struct timeval *tv, struct timezone *tz)
    87 {
    88     // Define a structure to receive the current Windows filetime
    89     FILETIME ft;
    90 
    91     // Initialize the present time to 0 and the timezone to UTC
    92     unsigned __int64 ui64 =0;
     83int gettimeofday (struct timeval *tv, struct timezone *tz)
     84{
     85    FILETIME            ft;
     86    unsigned __int64    buf =0;
    9387    //static int tzflag = 0;
    9488
    9589    if (NULL != tv)
    9690    {
    97         GetSystemTimeAsFileTime(&ft);
    98 
    99         ui64 = (((unsigned __int64) ft.dwHighDateTime << 32)
    100                 + (unsigned __int64) ft.dwLowDateTime);
    101 
    102         if (ui64)
    103         {
    104             ui64 /= 10;
    105             ui64 -= ((369 * 365 + 89) * (unsigned __int64) 86400) * 1000000;
    106         }
    107 
    108         // Finally change microseconds to seconds and place in the seconds value.
    109         // The modulus picks up the microseconds.
    110         tv->tv_sec = (long)(ui64 / 1000000UL);
    111         tv->tv_usec = (long)(ui64 % 1000000UL);
     91        GetSystemTimeAsFileTime (&ft);
     92
     93        buf |=  ft.dwHighDateTime;
     94        buf <<= 32
     95        buf |=  ft.dwLowDateTime;
     96
     97        if (buf)
     98        {
     99            buf /= 10;
     100            buf -= ((369 * 365 + 89) * (unsigned __int64) 86400) * 1000000;
     101        }
     102
     103        tv->tv_sec = (long)(buf / 1000000UL);
     104        tv->tv_usec = (long)(buf % 1000000UL);
    112105    }
    113106
     
    129122    return 0;
    130123}
    131 /* }}} #if defined(_WIN32) || defined(_WIN64) */
     124/* }}} */
    132125#endif
    133126
  • trunk/src/cf_socket.c

    r55 r66  
    22 * @file    cf_socket.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_socket.h"
  • trunk/src/cf_thread.c

    r65 r66  
    22 * @file    cf_thread.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_thread.h"
  • trunk/src/makefile

    r14 r66  
    4242                    cf_debug        \
    4343                    cf_log          \
     44                    cf_codec        \
    4445
    4546TARGET_NAME     = cf
  • trunk/test/debug.c

    r64 r66  
    22 * @file    debug.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_file.h"
  • trunk/test/file.c

    r41 r66  
    22 * @file    file.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_file.h"
  • trunk/test/log.c

    r40 r66  
    22 * @file    log.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_log.h"
  • trunk/test/socket_client.c

    r48 r66  
    22 * @file    socket_client.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_socket.h"
  • trunk/test/socket_server.c

    r53 r66  
    22 * @file    socket_server.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_socket.h"
  • trunk/test/test.c

    r64 r66  
    22 * @file    test.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_file.h"
  • trunk/test/thread.c

    r57 r66  
    22 * @file    thread.c
    33 * @author  myusgun <myusgun@gmail.com>
    4  * @version 0.1
    54 */
    65#include "cf_thread.h"
Note: See TracChangeset for help on using the changeset viewer.