From: Ted Lemon Date: Wed, 2 May 2001 17:00:48 +0000 (+0000) Subject: Add a strcasecmp for comparing omapi_data_type_t's. X-Git-Tag: V3-RC5~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=085b94452bfc6544eb98da2a6d90084bb2b79fd6;p=thirdparty%2Fdhcp.git Add a strcasecmp for comparing omapi_data_type_t's. --- diff --git a/includes/omapip/omapip.h b/includes/omapip/omapip.h index 9824e6cc2..ae856fa4d 100644 --- a/includes/omapip/omapip.h +++ b/includes/omapip/omapip.h @@ -521,6 +521,7 @@ isc_result_t omapi_object_update (omapi_object_t *, omapi_object_t *, int omapi_data_string_cmp (omapi_data_string_t *, omapi_data_string_t *); int omapi_ds_strcmp (omapi_data_string_t *, const char *); int omapi_td_strcmp (omapi_typed_data_t *, const char *); +int omapi_td_strcasecmp (omapi_typed_data_t *, const char *); isc_result_t omapi_make_value (omapi_value_t **, omapi_data_string_t *, omapi_typed_data_t *, const char *, int); isc_result_t omapi_make_const_value (omapi_value_t **, omapi_data_string_t *, diff --git a/omapip/support.c b/omapip/support.c index 51ef3512d..40a4fb99e 100644 --- a/omapip/support.c +++ b/omapip/support.c @@ -621,6 +621,31 @@ int omapi_td_strcmp (omapi_typed_data_t *s1, const char *s2) return 0; } +int omapi_td_strcasecmp (omapi_typed_data_t *s1, const char *s2) +{ + unsigned len, slen; + int rv; + + /* If the data type is not compatible, never equal. */ + if (s1 -> type != omapi_datatype_data && + s1 -> type != omapi_datatype_string) + return -1; + + slen = strlen (s2); + if (slen > s1 -> u.buffer.len) + len = s1 -> u.buffer.len; + else + len = slen; + rv = casecmp (s1 -> u.buffer.value, s2, len); + if (rv) + return rv; + if (s1 -> u.buffer.len > slen) + return 1; + else if (s1 -> u.buffer.len < slen) + return -1; + return 0; +} + isc_result_t omapi_make_value (omapi_value_t **vp, omapi_data_string_t *name, omapi_typed_data_t *value,