Changeset 72 in libcf


Ignore:
Timestamp:
04/15/13 10:02:52 (11 years ago)
Author:
cheese
Message:

#1 modify test code and data-type in codec

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_codec.c

    r68 r72  
    1717#define IS_UPPERCASE(x)     (x >= 'A' && x <= 'F')
    1818
     19typedef unsigned char __uchar;
     20
    1921/**
    2022 * 바이너리 데이터를 16진수 문자열로 변환
     
    3335                      char                  * hex)
    3436{
    35     size_t  iter = 0;
    36     size_t  count = len * 2 + 1;
     37    size_t      iter = 0;
     38    size_t      count = len * 2 + 1;
    3739
    38     char    hexchar[] = {'0', '1', '2', '3',
    39                         '4', '5', '6', '7',
    40                         '8', '9', 'a', 'b',
    41                         'c', 'd', 'e', 'f'};
     40    const char  hexchar[] = {'0', '1', '2', '3',
     41                            '4', '5', '6', '7',
     42                            '8', '9', 'a', 'b',
     43                            'c', 'd', 'e', 'f'};
    4244
    43     const unsigned char * ptr = bin;
     45    const __uchar   * ptr = bin;
    4446
    4547    ASSERT_ARGS (bin == NULL);
     
    7274                      size_t        * len)
    7375{
    74     typedef unsigned char __uchar;
    75 
    7676    int     result = 0;
    7777
  • trunk/test/codec.c

    r70 r72  
    1616    size_t length = 0;
    1717
    18     CF_DEBUG_PRINT (stderr, " = Convert binary to hex = \n");
     18    CF_DEBUG_PRINT (stderr, "data   : %s\n", data);
     19    CF_DEBUG_PRINT (stderr, "= Convert binary to hex =\n");
    1920    CF_Codec_BinaryToHex ((unsigned char *)data, strlen (data), hex);
    20     CF_DEBUG_PRINT (stderr, "data : %s\n", data);
    21     CF_DEBUG_PRINT (stderr, "hex : %s\n", hex);
    22     CF_DEBUG_PRINT_BIN (stderr, (unsigned char *) data, strlen (data), "data : %s\n", data);
     21    CF_DEBUG_PRINT (stderr, "hex    : %s\n", hex);
     22    CF_DEBUG_PRINT_BIN (stderr, (unsigned char *) data, strlen (data), "data   : %s\n", data);
    2323
    24     CF_DEBUG_PRINT (stderr, " = Convert hex to binary = \n");
     24    CF_DEBUG_PRINT (stderr, "= Convert hex to binary =\n");
    2525    CF_Codec_HexToBinary (hex, bin, &length);
    26     CF_DEBUG_PRINT (stderr, "bin : %s\n", bin);
    27     CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin : %s\n", bin);
     26    CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
    2827
    2928    return 0;
  • trunk/test/test.c

    r70 r72  
    238238    CF_Log_Write (LOG_SOCKET, "SERVER", "accepted\n");
    239239
    240     for (i = 0 ; i < 100 ; i++)
     240    for (i = 0 ; i < 10 ; i++)
    241241    {
    242242        if ((recvd = CF_Socket_Recv (clntsock, buf, sizeof (buf))) < 0)
     
    246246        }
    247247        CF_Log_Write (LOG_SOCKET, "SERVER", "recv {%s}\n", buf);
     248        CF_DEBUG_PRINT (stderr, "[SERVER] recv {%s}\n", buf);
    248249
    249250        if (CF_Socket_Send (clntsock, buf, recvd) < 0)
     
    252253        }
    253254        CF_Log_Write (LOG_SOCKET, "SERVER", "resp {%s}\n", buf);
     255        CF_DEBUG_PRINT (stderr, "[SERVER] resp {%s}\n", buf);
    254256    }
    255257
     
    278280    CF_Log_Write (LOG_SOCKET, "CLIENT", "connected\n");
    279281
    280     for (i = 0 ; i < 100 ; i++)
     282    for (i = 0 ; i < 10 ; i++)
    281283    {
    282284        if (CF_Socket_Send (sock, buf, sizeof (buf)) < 0)
     
    286288        }
    287289        CF_Log_Write (LOG_SOCKET, "CLIENT", "sent {%s}\n", buf);
     290        CF_DEBUG_PRINT (stderr, "[CLIENT] sent {%s}\n", buf);
    288291
    289292        memset (buf, 0x00, sizeof (buf));
     
    295298        }
    296299        CF_Log_Write (LOG_SOCKET, "CLIENT", "recv {%s}\n", buf);
     300        CF_DEBUG_PRINT (stderr, "[CLIENT] recv {%s}\n", buf);
    297301    }
    298302
     
    387391    size_t length = 0;
    388392
    389     CF_DEBUG_PRINT (stderr, " = Convert binary to hex = \n");
     393    CF_DEBUG_PRINT (stderr, "data   : %s\n", data);
     394    CF_DEBUG_PRINT (stderr, "= Convert binary to hex =\n");
    390395    CF_Codec_BinaryToHex ((unsigned char *)data, strlen (data), hex);
    391     CF_DEBUG_PRINT (stderr, "data : %s\n", data);
    392     CF_DEBUG_PRINT (stderr, "hex : %s\n", hex);
    393     CF_DEBUG_PRINT_BIN (stderr, (unsigned char *) data, strlen (data), "data : %s\n", data);
    394 
    395     CF_DEBUG_PRINT (stderr, " = Convert hex to binary = \n");
     396    CF_DEBUG_PRINT (stderr, "hex    : %s\n", hex);
     397    CF_DEBUG_PRINT_BIN (stderr, (unsigned char *) data, strlen (data), "data   : %s\n", data);
     398
     399    CF_DEBUG_PRINT (stderr, "= Convert hex to binary =\n");
    396400    CF_Codec_HexToBinary (hex, bin, &length);
    397     CF_DEBUG_PRINT (stderr, "bin : %s\n", bin);
    398     CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin : %s\n", bin);
    399 }
     401    CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
     402}
Note: See TracChangeset for help on using the changeset viewer.