added chunk_equals_or_null()
This commit is contained in:
+13
-18
@@ -45,23 +45,10 @@ mapping_t status_m[] = {
|
|||||||
{MAPPING_END, NULL}
|
{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.
|
* Empty chunk.
|
||||||
*/
|
*/
|
||||||
chunk_t CHUNK_INITIALIZER = {NULL,0};
|
chunk_t CHUNK_INITIALIZER = { NULL, 0 };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Described in header.
|
* Described in header.
|
||||||
@@ -106,10 +93,18 @@ chunk_t chunk_alloc(size_t bytes)
|
|||||||
*/
|
*/
|
||||||
bool chunk_equals(chunk_t a, chunk_t b)
|
bool chunk_equals(chunk_t a, chunk_t b)
|
||||||
{
|
{
|
||||||
return a.len == b.len &&
|
return a.ptr != NULL && b.ptr != NULL &&
|
||||||
a.ptr != NULL &&
|
a.len == b.len && memeq(a.ptr, b.ptr, a.len);
|
||||||
b.ptr != NULL &&
|
}
|
||||||
memcmp(a.ptr, b.ptr, a.len) == 0;
|
|
||||||
|
/**
|
||||||
|
* 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 */
|
CERT_NO_SEND = 4 /* synonym for CERT_NEVER_SEND */
|
||||||
} certpolicy_t;
|
} 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.
|
* String mappings for type status_t.
|
||||||
*/
|
*/
|
||||||
@@ -154,17 +171,16 @@ struct chunk_t {
|
|||||||
/**
|
/**
|
||||||
* Pointer to start of data
|
* Pointer to start of data
|
||||||
*/
|
*/
|
||||||
u_char *ptr;
|
u_char *ptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Length of data in bytes
|
* Length of data in bytes
|
||||||
*/
|
*/
|
||||||
size_t len;
|
size_t len;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {NULL, 0}-chunk, handy for initialization
|
* used to initialize a chunk to { NULL, 0 }.
|
||||||
* of chunks.
|
|
||||||
*/
|
*/
|
||||||
extern chunk_t CHUNK_INITIALIZER;
|
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);
|
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
|
* Print a chunk in hexadecimal form
|
||||||
* with each byte separated by a colon
|
* with each byte separated by a colon
|
||||||
|
|||||||
Reference in New Issue
Block a user