libksba  1.6.0
About: KSBA is a library to make the tasks of working with X.509 certificates, CMS data and related objects more easy.
  Fossies Dox: libksba-1.6.0.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

util.h File Reference
#include "visibility.h"
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define xtrymalloc(a)   ksba_malloc((a))
 
#define xtrycalloc(a, b)   ksba_calloc((a),(b))
 
#define xtryrealloc(a, b)   ksba_realloc((a),(b))
 
#define xtrystrdup(a)   ksba_strdup((a))
 
#define xfree(a)   ksba_free((a))
 
#define xmalloc(a)   _ksba_xmalloc((a))
 
#define xcalloc(a, b)   _ksba_xcalloc((a),(b))
 
#define xrealloc(a, b)   _ksba_xrealloc((a),(b))
 
#define xstrdup(a)   _ksba_xstrdup((a))
 
#define DIM(v)   (sizeof(v)/sizeof((v)[0]))
 
#define DIMof(type, member)   DIM(((type *)0)->member)
 
#define STR(v)   #v
 
#define STR2(v)   STR(v)
 
#define return_if_fail(expr)
 
#define return_null_if_fail(expr)
 
#define return_val_if_fail(expr, val)
 
#define never_reached()
 
#define stpcpy(a, b)   _ksba_stpcpy ((a), (b))
 
#define ascii_memcasecmp(a, b, n)   _ksba_ascii_memcasecmp ((a),(b),(n))
 
#define spacep(p)   (*(p) == ' ' || *(p) == '\t')
 
#define digitp(p)   (*(p) >= '0' && *(p) <= '9')
 
#define hexdigitp(a)
 
#define atoi_1(p)   (*(p) - '0' )
 
#define atoi_2(p)   ((atoi_1(p) * 10) + atoi_1((p)+1))
 
#define atoi_4(p)   ((atoi_2(p) * 100) + atoi_2((p)+2))
 
#define xtoi_1(p)
 
#define xtoi_2(p)   ((xtoi_1(p) * 16) + xtoi_1((p)+1))
 

Functions

gpg_error_t _ksba_hash_buffer (const char *oid, const void *buffer, size_t length, size_t resultsize, unsigned char *result, size_t *resultlen)
 
void * _ksba_reallocarray (void *a, size_t oldnmemb, size_t nmemb, size_t size)
 
void * _ksba_xmalloc (size_t n)
 
void * _ksba_xcalloc (size_t n, size_t m)
 
void * _ksba_xrealloc (void *p, size_t n)
 
char * _ksba_xstrdup (const char *p)
 
char * _ksba_stpcpy (char *a, const char *b)
 
int _ksba_ascii_memcasecmp (const void *a_arg, const void *b_arg, size_t n)
 

Macro Definition Documentation

◆ ascii_memcasecmp

#define ascii_memcasecmp (   a,
  b,
 
)    _ksba_ascii_memcasecmp ((a),(b),(n))

Definition at line 105 of file util.h.

◆ atoi_1

#define atoi_1 (   p)    (*(p) - '0' )

Definition at line 114 of file util.h.

◆ atoi_2

#define atoi_2 (   p)    ((atoi_1(p) * 10) + atoi_1((p)+1))

Definition at line 115 of file util.h.

◆ atoi_4

#define atoi_4 (   p)    ((atoi_2(p) * 100) + atoi_2((p)+2))

Definition at line 116 of file util.h.

◆ digitp

#define digitp (   p)    (*(p) >= '0' && *(p) <= '9')

Definition at line 109 of file util.h.

◆ DIM

#define DIM (   v)    (sizeof(v)/sizeof((v)[0]))

Definition at line 66 of file util.h.

◆ DIMof

#define DIMof (   type,
  member 
)    DIM(((type *)0)->member)

Definition at line 67 of file util.h.

◆ hexdigitp

#define hexdigitp (   a)
Value:
(digitp (a) \
|| (*(a) >= 'A' && *(a) <= 'F') \
|| (*(a) >= 'a' && *(a) <= 'f'))
#define digitp(p)
Definition: util.h:109

Definition at line 110 of file util.h.

◆ never_reached

#define never_reached ( )
Value:
do { \
fprintf (stderr, "%s:%d: oops; should never get here\n", \
__FILE__, __LINE__ ); \
} while (0)

Definition at line 93 of file util.h.

◆ return_if_fail

#define return_if_fail (   expr)
Value:
do { \
if (!(expr)) { \
fprintf (stderr, "%s:%d: assertion `%s' failed\n", \
__FILE__, __LINE__, #expr ); \
return; \
} } while (0)

Definition at line 75 of file util.h.

◆ return_null_if_fail

#define return_null_if_fail (   expr)
Value:
do { \
if (!(expr)) { \
fprintf (stderr, "%s:%d: assertion `%s' failed\n", \
__FILE__, __LINE__, #expr ); \
return NULL; \
} } while (0)

Definition at line 81 of file util.h.

◆ return_val_if_fail

#define return_val_if_fail (   expr,
  val 
)
Value:
do { \
if (!(expr)) { \
fprintf (stderr, "%s:%d: assertion `%s' failed\n", \
__FILE__, __LINE__, #expr ); \
return (val); \
} } while (0)

Definition at line 87 of file util.h.

◆ spacep

#define spacep (   p)    (*(p) == ' ' || *(p) == '\t')

Definition at line 108 of file util.h.

◆ stpcpy

#define stpcpy (   a,
 
)    _ksba_stpcpy ((a), (b))

Definition at line 101 of file util.h.

◆ STR

#define STR (   v)    #v

Definition at line 69 of file util.h.

◆ STR2

#define STR2 (   v)    STR(v)

Definition at line 72 of file util.h.

◆ xcalloc

#define xcalloc (   a,
 
)    _ksba_xcalloc((a),(b))

Definition at line 61 of file util.h.

◆ xfree

#define xfree (   a)    ksba_free((a))

Definition at line 58 of file util.h.

◆ xmalloc

#define xmalloc (   a)    _ksba_xmalloc((a))

Definition at line 60 of file util.h.

◆ xrealloc

#define xrealloc (   a,
 
)    _ksba_xrealloc((a),(b))

Definition at line 62 of file util.h.

◆ xstrdup

#define xstrdup (   a)    _ksba_xstrdup((a))

Definition at line 63 of file util.h.

◆ xtoi_1

#define xtoi_1 (   p)
Value:
(*(p) <= '9'? (*(p)- '0'): \
*(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))

Definition at line 117 of file util.h.

◆ xtoi_2

#define xtoi_2 (   p)    ((xtoi_1(p) * 16) + xtoi_1((p)+1))

Definition at line 119 of file util.h.

◆ xtrycalloc

#define xtrycalloc (   a,
 
)    ksba_calloc((a),(b))

Definition at line 55 of file util.h.

◆ xtrymalloc

#define xtrymalloc (   a)    ksba_malloc((a))

Definition at line 54 of file util.h.

◆ xtryrealloc

#define xtryrealloc (   a,
 
)    ksba_realloc((a),(b))

Definition at line 56 of file util.h.

◆ xtrystrdup

#define xtrystrdup (   a)    ksba_strdup((a))

Definition at line 57 of file util.h.

Function Documentation

◆ _ksba_ascii_memcasecmp()

int _ksba_ascii_memcasecmp ( const void *  a_arg,
const void *  b_arg,
size_t  n 
)

Definition at line 296 of file util.c.

References ascii_toupper().

◆ _ksba_hash_buffer()

gpg_error_t _ksba_hash_buffer ( const char *  oid,
const void *  buffer,
size_t  length,
size_t  resultsize,
unsigned char *  result,
size_t *  resultlen 
)

Definition at line 111 of file util.c.

References gpg_error, hash_buffer_fnc, hash_buffer_fnc_arg, and oid.

Referenced by issuer_key_hash(), and issuer_name_hash().

◆ _ksba_reallocarray()

void* _ksba_reallocarray ( void *  a,
size_t  oldnmemb,
size_t  nmemb,
size_t  size 
)

Definition at line 187 of file util.c.

References ksba_realloc(), and xfree.

Referenced by ensure_space().

◆ _ksba_stpcpy()

char* _ksba_stpcpy ( char *  a,
const char *  b 
)

Definition at line 275 of file util.c.

◆ _ksba_xcalloc()

void* _ksba_xcalloc ( size_t  n,
size_t  m 
)

Definition at line 245 of file util.c.

References ksba_calloc(), and out_of_core().

◆ _ksba_xmalloc()

void* _ksba_xmalloc ( size_t  n)

Definition at line 236 of file util.c.

References ksba_malloc(), and out_of_core().

◆ _ksba_xrealloc()

void* _ksba_xrealloc ( void *  p,
size_t  n 
)

Definition at line 254 of file util.c.

References ksba_realloc(), and out_of_core().

◆ _ksba_xstrdup()

char* _ksba_xstrdup ( const char *  p)

Definition at line 264 of file util.c.

References ksba_strdup(), and out_of_core().