~ubuntu-branches/debian/lenny/net-snmp/lenny

« back to all changes in this revision

Viewing changes to snmplib/tools.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-10 22:20:23 UTC
  • Revision ID: james.westby@ubuntu.com-20070510222023-3fr07xb9i17xvq32
Tags: upstream-5.3.1
ImportĀ upstreamĀ versionĀ 5.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
403
403
 *
404
404
 * @param buf_len pointer to a size_t containing the initial size of buf.
405
405
 *
406
 
 * @param out_len On input, a pointer to a size_t indicating an offset into buf.
 
406
 * @param offset On input, a pointer to a size_t indicating an offset into buf.
407
407
 *                The  binary data will be stored at this offset.
408
408
 *                On output, this pointer will have updated the offset to be
409
409
 *                the first byte after the converted data.
422
422
 * @retval 0  error
423
423
 */
424
424
int
425
 
netsnmp_hex_to_binary(u_char ** buf, size_t * buf_len, size_t * out_len,
 
425
netsnmp_hex_to_binary(u_char ** buf, size_t * buf_len, size_t * offset,
426
426
                      int allow_realloc, const char *hex, const char *delim)
427
427
{
428
428
    int             subid = 0;
429
429
    const char     *cp = hex;
430
430
 
431
 
    if (buf == NULL || buf_len == NULL || out_len == NULL || hex == NULL) {
 
431
    if (buf == NULL || buf_len == NULL || offset == NULL || hex == NULL) {
432
432
        return 0;
433
433
    }
434
434
 
451
451
         * if we dont' have enough space, realloc.
452
452
         * (snmp_realloc will adjust buf_len to new size)
453
453
         */
454
 
        if ((*out_len >= *buf_len) &&
 
454
        if ((*offset >= *buf_len) &&
455
455
            !(allow_realloc && snmp_realloc(buf, buf_len))) {
456
456
            return 0;
457
457
        }
458
 
        *(*buf + *out_len) = (u_char) subid;
459
 
        (*out_len)++;
 
458
        *(*buf + *offset) = (u_char) subid;
 
459
        (*offset)++;
460
460
        if (*++cp == '\0') {
461
461
            /*
462
462
             * Odd number of hex digits is an error.  
481
481
 * @retval 0  error
482
482
 */
483
483
int
484
 
snmp_hex_to_binary(u_char ** buf, size_t * buf_len, size_t * out_len,
 
484
snmp_hex_to_binary(u_char ** buf, size_t * buf_len, size_t * offset,
485
485
                   int allow_realloc, const char *hex)
486
486
{
487
 
    return netsnmp_hex_to_binary(buf, buf_len, out_len, allow_realloc, hex, " ");
 
487
    return netsnmp_hex_to_binary(buf, buf_len, offset, allow_realloc, hex, " ");
488
488
}
489
489
 
490
490
/*******************************************************************-o-******