added chunk_equals_or_null()
This commit is contained in:
+13
-18
@@ -45,23 +45,10 @@ mapping_t status_m[] = {
|
||||
{MAPPING_END, NULL}
|
||||
};
|
||||
|
||||
#define UNDEFINED_TIME 0
|
||||
|
||||
/**
|
||||
* @brief Display a date either in local or UTC time
|
||||
*
|
||||
* @param buf buffer where displayed time will be written
|
||||
* @param buflen buffer length
|
||||
* @param time time to be displayed
|
||||
* @param utc UTC (TRUE) or local time (FALSE)
|
||||
*
|
||||
*/
|
||||
void timetoa(char *buf, size_t buflen, const time_t *time, bool utc);
|
||||
|
||||
/**
|
||||
* Empty chunk.
|
||||
*/
|
||||
chunk_t CHUNK_INITIALIZER = {NULL,0};
|
||||
chunk_t CHUNK_INITIALIZER = { NULL, 0 };
|
||||
|
||||
/**
|
||||
* Described in header.
|
||||
@@ -106,10 +93,18 @@ chunk_t chunk_alloc(size_t bytes)
|
||||
*/
|
||||
bool chunk_equals(chunk_t a, chunk_t b)
|
||||
{
|
||||
return a.len == b.len &&
|
||||
a.ptr != NULL &&
|
||||
b.ptr != NULL &&
|
||||
memcmp(a.ptr, b.ptr, a.len) == 0;
|
||||
return a.ptr != NULL && b.ptr != NULL &&
|
||||
a.len == b.len && memeq(a.ptr, b.ptr, a.len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
bool chunk_equals_or_null(chunk_t a, chunk_t b)
|
||||
{
|
||||
if (a.ptr == NULL || b.ptr == NULL)
|
||||
return TRUE;
|
||||
return a.len == b.len && memeq(a.ptr, b.ptr, a.len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -122,6 +122,23 @@ typedef enum certpolicy {
|
||||
CERT_NO_SEND = 4 /* synonym for CERT_NEVER_SEND */
|
||||
} certpolicy_t;
|
||||
|
||||
/**
|
||||
* RFC 2459 CRL reason codes
|
||||
*/
|
||||
|
||||
/* TODO extern enum_names crl_reason_names; */
|
||||
|
||||
typedef enum {
|
||||
REASON_UNSPECIFIED = 0,
|
||||
REASON_KEY_COMPROMISE = 1,
|
||||
REASON_CA_COMPROMISE = 2,
|
||||
REASON_AFFILIATION_CHANGED = 3,
|
||||
REASON_SUPERSEDED = 4,
|
||||
REASON_CESSATION_OF_OPERATON = 5,
|
||||
REASON_CERTIFICATE_HOLD = 6,
|
||||
REASON_REMOVE_FROM_CRL = 8
|
||||
} crl_reason_t;
|
||||
|
||||
/**
|
||||
* String mappings for type status_t.
|
||||
*/
|
||||
@@ -154,17 +171,16 @@ struct chunk_t {
|
||||
/**
|
||||
* Pointer to start of data
|
||||
*/
|
||||
u_char *ptr;
|
||||
|
||||
/**
|
||||
* Length of data in bytes
|
||||
*/
|
||||
size_t len;
|
||||
u_char *ptr;
|
||||
|
||||
/**
|
||||
* Length of data in bytes
|
||||
*/
|
||||
size_t len;
|
||||
};
|
||||
|
||||
/**
|
||||
* {NULL, 0}-chunk, handy for initialization
|
||||
* of chunks.
|
||||
* used to initialize a chunk to { NULL, 0 }.
|
||||
*/
|
||||
extern chunk_t CHUNK_INITIALIZER;
|
||||
|
||||
@@ -194,6 +210,12 @@ chunk_t chunk_alloc(size_t bytes);
|
||||
*/
|
||||
bool chunk_equals(chunk_t a, chunk_t b);
|
||||
|
||||
/**
|
||||
* Compare two chunks for equality,
|
||||
* NULL chunks are always equal.
|
||||
*/
|
||||
bool chunk_equals_or_null(chunk_t a, chunk_t b);
|
||||
|
||||
/**
|
||||
* Print a chunk in hexadecimal form
|
||||
* with each byte separated by a colon
|
||||
|
||||
Reference in New Issue
Block a user