e = calloc(1, sizeof(*e));
if (e == NULL) {
ERROR("md_entry_alloc: calloc failed.");
e = calloc(1, sizeof(*e));
if (e == NULL) {
ERROR("md_entry_alloc: calloc failed.");
} /* }}} meta_entry_t *md_entry_alloc */
/* XXX: The lock on md must be held while calling this function! */
} /* }}} meta_entry_t *md_entry_alloc */
/* XXX: The lock on md must be held while calling this function! */
copy->type = orig->type;
if (copy->type == MD_TYPE_STRING)
copy->value.mv_string = strdup(orig->value.mv_string);
else
copy->value = orig->value;
copy->type = orig->type;
if (copy->type == MD_TYPE_STRING)
copy->value.mv_string = strdup(orig->value.mv_string);
else
copy->value = orig->value;
} /* }}} meta_entry_t *md_entry_clone_contents */
static meta_entry_t *md_entry_clone(const meta_entry_t *orig) /* {{{ */
} /* }}} meta_entry_t *md_entry_clone_contents */
static meta_entry_t *md_entry_clone(const meta_entry_t *orig) /* {{{ */
} /* }}} int md_entry_insert_clone */
/* XXX: The lock on md must be held while calling this function! */
} /* }}} int md_entry_insert_clone */
/* XXX: The lock on md must be held while calling this function! */
for (e = md->head; e != NULL; e = e->next)
if (strcasecmp(key, e->key) == 0)
break;
for (e = md->head; e != NULL; e = e->next)
if (strcasecmp(key, e->key) == 0)
break;
md = calloc(1, sizeof(*md));
if (md == NULL) {
ERROR("meta_data_create: calloc failed.");
md = calloc(1, sizeof(*md));
if (md == NULL) {
ERROR("meta_data_create: calloc failed.");
pthread_mutex_lock(&orig->lock);
copy->head = md_entry_clone(orig->head);
pthread_mutex_unlock(&orig->lock);
pthread_mutex_lock(&orig->lock);
copy->head = md_entry_clone(orig->head);
pthread_mutex_unlock(&orig->lock);
} /* }}} meta_data_t *meta_data_clone */
int meta_data_clone_merge(meta_data_t **dest, meta_data_t *orig) /* {{{ */
{
if (orig == NULL)
} /* }}} meta_data_t *meta_data_clone */
int meta_data_clone_merge(meta_data_t **dest, meta_data_t *orig) /* {{{ */
{
if (orig == NULL)
int meta_data_exists(meta_data_t *md, const char *key) /* {{{ */
{
if ((md == NULL) || (key == NULL))
int meta_data_exists(meta_data_t *md, const char *key) /* {{{ */
{
if ((md == NULL) || (key == NULL))
pthread_mutex_lock(&md->lock);
for (meta_entry_t *e = md->head; e != NULL; e = e->next) {
if (strcasecmp(key, e->key) == 0) {
pthread_mutex_unlock(&md->lock);
pthread_mutex_lock(&md->lock);
for (meta_entry_t *e = md->head; e != NULL; e = e->next) {
if (strcasecmp(key, e->key) == 0) {
pthread_mutex_unlock(&md->lock);
} /* }}} int meta_data_exists */
int meta_data_type(meta_data_t *md, const char *key) /* {{{ */
} /* }}} int meta_data_exists */
int meta_data_type(meta_data_t *md, const char *key) /* {{{ */
e->value.mv_string = md_strdup(value);
if (e->value.mv_string == NULL) {
ERROR("meta_data_add_string: md_strdup failed.");
md_entry_free(e);
e->value.mv_string = md_strdup(value);
if (e->value.mv_string == NULL) {
ERROR("meta_data_add_string: md_strdup failed.");
md_entry_free(e);
} /* }}} int meta_data_add_string */
int meta_data_add_signed_int(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_add_string */
int meta_data_add_signed_int(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_add_signed_int */
int meta_data_add_unsigned_int(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_add_signed_int */
int meta_data_add_unsigned_int(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_add_unsigned_int */
int meta_data_add_double(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_add_unsigned_int */
int meta_data_add_double(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_add_double */
int meta_data_add_boolean(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_add_double */
int meta_data_add_boolean(meta_data_t *md, /* {{{ */
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_STRING) {
ERROR("meta_data_get_string: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_STRING) {
ERROR("meta_data_get_string: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
}
temp = md_strdup(e->value.mv_string);
if (temp == NULL) {
pthread_mutex_unlock(&md->lock);
ERROR("meta_data_get_string: md_strdup failed.");
}
temp = md_strdup(e->value.mv_string);
if (temp == NULL) {
pthread_mutex_unlock(&md->lock);
ERROR("meta_data_get_string: md_strdup failed.");
} /* }}} int meta_data_get_string */
int meta_data_get_signed_int(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_get_string */
int meta_data_get_signed_int(meta_data_t *md, /* {{{ */
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_SIGNED_INT) {
ERROR("meta_data_get_signed_int: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_SIGNED_INT) {
ERROR("meta_data_get_signed_int: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
} /* }}} int meta_data_get_signed_int */
int meta_data_get_unsigned_int(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_get_signed_int */
int meta_data_get_unsigned_int(meta_data_t *md, /* {{{ */
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_UNSIGNED_INT) {
ERROR("meta_data_get_unsigned_int: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_UNSIGNED_INT) {
ERROR("meta_data_get_unsigned_int: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
} /* }}} int meta_data_get_unsigned_int */
int meta_data_get_double(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_get_unsigned_int */
int meta_data_get_double(meta_data_t *md, /* {{{ */
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_DOUBLE) {
ERROR("meta_data_get_double: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_DOUBLE) {
ERROR("meta_data_get_double: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
} /* }}} int meta_data_get_double */
int meta_data_get_boolean(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_get_double */
int meta_data_get_boolean(meta_data_t *md, /* {{{ */
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_BOOLEAN) {
ERROR("meta_data_get_boolean: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
}
if (e->type != MD_TYPE_BOOLEAN) {
ERROR("meta_data_get_boolean: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock(&md->lock);
} /* }}} int meta_data_get_boolean */
int meta_data_as_string(meta_data_t *md, /* {{{ */
} /* }}} int meta_data_get_boolean */
int meta_data_as_string(meta_data_t *md, /* {{{ */
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
pthread_mutex_lock(&md->lock);
e = md_entry_lookup(md, key);
if (e == NULL) {
pthread_mutex_unlock(&md->lock);
- ssnprintf(buffer, sizeof(buffer), "%" PRIi64, e->value.mv_signed_int);
+ snprintf(buffer, sizeof(buffer), "%" PRIi64, e->value.mv_signed_int);
- ssnprintf(buffer, sizeof(buffer), "%" PRIu64, e->value.mv_unsigned_int);
+ snprintf(buffer, sizeof(buffer), "%" PRIu64, e->value.mv_unsigned_int);
- ssnprintf(buffer, sizeof(buffer), GAUGE_FORMAT, e->value.mv_double);
+ snprintf(buffer, sizeof(buffer), GAUGE_FORMAT, e->value.mv_double);
default:
pthread_mutex_unlock(&md->lock);
ERROR("meta_data_as_string: unknown type %d for key `%s'", type, key);
default:
pthread_mutex_unlock(&md->lock);
ERROR("meta_data_as_string: unknown type %d for key `%s'", type, key);
if (temp == NULL) {
pthread_mutex_unlock(&md->lock);
ERROR("meta_data_as_string: md_strdup failed for key `%s'.", key);
if (temp == NULL) {
pthread_mutex_unlock(&md->lock);
ERROR("meta_data_as_string: md_strdup failed for key `%s'.", key);