Navigation


Changeset 1093:44f3e48dfe27 in freeDiameter for include


Ignore:
Timestamp:
May 6, 2013, 5:33:22 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Align the behavior of all fd_*dump functions wrt final \n

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r1088 r1093  
    222222
    223223
    224 /* Helper functions for the *dump functions that add into a buffer */
    225 char * fd_dump_extend(char ** buf, size_t *len, size_t *offset, const char * format, ... ) _ATTRIBUTE_PRINTFLIKE_(4,5);
    226 char * fd_dump_extend_hexdump(char ** buf, size_t *len, size_t *offset, uint8_t *data, size_t datalen, size_t trunc, size_t wrap );
    227 
    228 /* All dump functions follow the same prototype:
    229  * PARAMETERS:
    230  *   buf   : *buf can be NULL on entry, it will be malloc'd. Otherwise it can be realloc'd if needed.
     224/* All dump functions follow this same prototype:
     225 * PARAMETERS:
     226 *   buf   : *buf can be NULL on entry, it will be malloc'd. Otherwise it is realloc'd if needed.
    231227 *   len   : the current size of the buffer (in/out)
    232228 *   offset: (optional) if provided, starts writing dump at offset in the buffer, and updated upon exit. if NULL, starts at offset O.
     
    234230 * RETURN VALUE:
    235231 *   *buf upon success, NULL upon failure.
    236  * After the buffer has been used, it should be freed.
     232 *
     233 * REMARKS:
     234 *  - After the buffer has been used, it should be freed.
     235 *  - Depending on the function, the created string may be multi-line. However, it should never be terminated with a '\n'.
    237236 */
    238237#define DECLARE_FD_DUMP_PROTOTYPE( function_name, args... )     \
    239238        char * function_name(char ** buf, size_t *len, size_t *offset, ##args)
    240239       
     240
     241/* Helper functions for the *dump functions that add into a buffer */
     242DECLARE_FD_DUMP_PROTOTYPE( fd_dump_extend, const char * format, ... ) _ATTRIBUTE_PRINTFLIKE_(4,5);
     243DECLARE_FD_DUMP_PROTOTYPE( fd_dump_extend_hexdump, uint8_t *data, size_t datalen, size_t trunc, size_t wrap );
     244
     245
     246/* Some helpers macro for writing such *_dump routine */
    241247#define FD_DUMP_STD_PARAMS  buf, len, offset
     248#define FD_DUMP_HANDLE_OFFSET()  size_t o = 0; if (!offset) offset = &o
     249#define FD_DUMP_HANDLE_TRAIL()  while ((*buf) && (*offset > 0) && ((*buf)[*offset - 1] == '\n')) { *offset -= 1; (*buf)[*offset] = '\0'; }
     250
    242251
    243252
     
    10161025        VENDOR_BY_ID = 10,      /* "what" points to a vendor_id_t */
    10171026        VENDOR_BY_NAME,         /* "what" points to a char * */
    1018         VENDOR_OF_APPLICATION   /* "what" points to a struct dict_object containing an application (see below) */
     1027        VENDOR_OF_APPLICATION,  /* "what" points to a struct dict_object containing an application (see below) */
     1028        VENDOR_OF_AVP,          /* "what" points to a struct dict_object containing an avp (see below) */
    10191029};
    10201030
     
    14051415
    14061416/* For dumping flags and values */
    1407 #define DUMP_AVPFL_str  "%c%c"
    1408 #define DUMP_AVPFL_val(_val) (_val & AVP_FLAG_VENDOR)?'V':'-' , (_val & AVP_FLAG_MANDATORY)?'M':'-'
     1417#define DUMP_AVPFL_str  "%c%c%s%s%s%s%s%s"
     1418#define DUMP_AVPFL_val(_val) (_val & AVP_FLAG_VENDOR)?'V':'-' , (_val & AVP_FLAG_MANDATORY)?'M':'-',    \
     1419                                (_val & AVP_FLAG_RESERVED3)?"3":"", (_val & AVP_FLAG_RESERVED4)?"4":"", \
     1420                                (_val & AVP_FLAG_RESERVED5)?"5":"", (_val & AVP_FLAG_RESERVED6)?"6":"", (_val & AVP_FLAG_RESERVED7)?"7":"", (_val & AVP_FLAG_RESERVED8)?"8":""
    14091421
    14101422/* Type to hold data associated to an avp */
     
    15551567
    15561568/* For dumping flags and values */
    1557 #define DUMP_CMDFL_str  "%c%c%c%c"
    1558 #define DUMP_CMDFL_val(_val) (_val & CMD_FLAG_REQUEST)?'R':'-' , (_val & CMD_FLAG_PROXIABLE)?'P':'-' , (_val & CMD_FLAG_ERROR)?'E':'-' , (_val & CMD_FLAG_RETRANSMIT)?'T':'-'
     1569#define DUMP_CMDFL_str  "%c%c%c%c%s%s%s%s"
     1570#define DUMP_CMDFL_val(_val) (_val & CMD_FLAG_REQUEST)?'R':'-' , (_val & CMD_FLAG_PROXIABLE)?'P':'-' , (_val & CMD_FLAG_ERROR)?'E':'-' , (_val & CMD_FLAG_RETRANSMIT)?'T':'-', \
     1571                                (_val & CMD_FLAG_RESERVED5)?"5":"", (_val & CMD_FLAG_RESERVED6)?"6":"", (_val & CMD_FLAG_RESERVED7)?"7":"", (_val & CMD_FLAG_RESERVED8)?"8":""
    15591572
    15601573/* Type to hold data associated to a command */
Note: See TracChangeset for help on using the changeset viewer.