Changeset 96 in libcf for trunk/test/codec.c


Ignore:
Timestamp:
05/27/13 09:37:51 (11 years ago)
Author:
cheese
Message:

#1 fix hex decoder exception and rollback function interface of decoders

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/codec.c

    r90 r96  
    1414    char encode[512] = {0x00,};
    1515    unsigned char bin[512] = {0x00,};
    16     int length = 0;
     16    size_t length = 0;
    1717
    1818    /* hex */
     
    2525
    2626    CF_DEBUG_PRINT (stderr, "= Convert hex to binary =\n");
    27     length = CF_Codec_Hex_Decode (encode, bin);
    28     if (length < 0) {
     27    if (CF_Codec_Hex_Decode (encode, bin, &length) < 0) {
    2928        // error
    3029    }
    31     CF_DEBUG_PRINT_BIN (stderr, bin, (size_t)length, "bin    : %s\n", bin);
     30    else
     31        CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
    3232
    3333    memset (bin   , 0x00, sizeof (bin));
     
    4343
    4444    CF_DEBUG_PRINT (stderr, "= Convert base64 to binary =\n");
    45     length = CF_Codec_Base64_Decode (encode, bin);
    46     if (length < 0) {
     45    if (CF_Codec_Base64_Decode (encode, bin, &length) < 0) {
    4746        // error
    4847    }
    49     CF_DEBUG_PRINT_BIN (stderr, bin, (size_t)length, "bin    : %s\n", bin);
     48    else
     49        CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
    5050
    5151    return 0;
Note: See TracChangeset for help on using the changeset viewer.