int (*add_signed_int)(void *, const char *, int64_t);
int (*add_unsigned_int)(void *, const char *, uint64_t);
int (*add_double)(void *, const char *, double);
- int (*add_boolean)(void *, const char *, _Bool);
+ int (*add_boolean)(void *, const char *, bool);
} cpy_build_meta_handler_t;
#define FreeAll() \
PyMem_Free(host); \
} while (0)
-#define CPY_BUILD_META_FUNC(meta_type, func, val_type) \
-static int cpy_ ## func(void *meta, const char *key, val_type val) { \
- return func((meta_type *)meta, key, val); \
-}
-
-#define CPY_BUILD_META_HANDLER(func_prefix, meta_type) \
-CPY_BUILD_META_FUNC(meta_type, func_prefix ## _add_string, const char *) \
-CPY_BUILD_META_FUNC(meta_type, func_prefix ## _add_signed_int, int64_t) \
-CPY_BUILD_META_FUNC(meta_type, func_prefix ## _add_unsigned_int, uint64_t) \
-CPY_BUILD_META_FUNC(meta_type, func_prefix ## _add_double, double) \
-CPY_BUILD_META_FUNC(meta_type, func_prefix ## _add_boolean, _Bool) \
- \
-static cpy_build_meta_handler_t cpy_ ## func_prefix = { \
- .add_string = cpy_ ## func_prefix ## _add_string, \
- .add_signed_int = cpy_ ## func_prefix ## _add_signed_int, \
- .add_unsigned_int = cpy_ ## func_prefix ## _add_unsigned_int, \
- .add_double = cpy_ ## func_prefix ## _add_double, \
- .add_boolean = cpy_ ## func_prefix ## _add_boolean \
-}
-
static PyObject *cpy_common_repr(PyObject *s) {
PyObject *ret, *tmp;
- static PyObject *l_type = NULL, *l_type_instance = NULL, *l_plugin = NULL,
- *l_plugin_instance = NULL;
- static PyObject *l_host = NULL, *l_time = NULL;
+ static PyObject *l_type, *l_type_instance, *l_plugin, *l_plugin_instance;
+ static PyObject *l_host, *l_time;
PluginData *self = (PluginData *)s;
if (l_type == NULL)
static PyObject *PluginData_repr(PyObject *s) {
PyObject *ret;
- static PyObject *l_closing = NULL;
+ static PyObject *l_closing;
if (l_closing == NULL)
l_closing = cpy_string_to_unicode_or_bytes(")");
return 0;
}
-static int cpy_build_meta(PyObject *meta, cpy_build_meta_handler_t *meta_func,
- void *m) {
+static int cpy_build_meta_generic(PyObject *meta,
+ cpy_build_meta_handler_t *meta_func,
+ void *m) {
int s;
PyObject *l;
return 0;
}
+#define CPY_BUILD_META_FUNC(meta_type, func, val_type) \
+ static int cpy_##func(void *meta, const char *key, val_type val) { \
+ return func((meta_type *)meta, key, val); \
+ }
+
+#define CPY_BUILD_META_HANDLER(func_prefix, meta_type) \
+ CPY_BUILD_META_FUNC(meta_type, func_prefix##_add_string, const char *) \
+ CPY_BUILD_META_FUNC(meta_type, func_prefix##_add_signed_int, int64_t) \
+ CPY_BUILD_META_FUNC(meta_type, func_prefix##_add_unsigned_int, uint64_t) \
+ CPY_BUILD_META_FUNC(meta_type, func_prefix##_add_double, double) \
+ CPY_BUILD_META_FUNC(meta_type, func_prefix##_add_boolean, bool) \
+ \
+ static cpy_build_meta_handler_t cpy_##func_prefix = { \
+ .add_string = cpy_##func_prefix##_add_string, \
+ .add_signed_int = cpy_##func_prefix##_add_signed_int, \
+ .add_unsigned_int = cpy_##func_prefix##_add_unsigned_int, \
+ .add_double = cpy_##func_prefix##_add_double, \
+ .add_boolean = cpy_##func_prefix##_add_boolean}
+
CPY_BUILD_META_HANDLER(meta_data, meta_data_t);
CPY_BUILD_META_HANDLER(plugin_notification_meta, notification_t);
-static meta_data_t *cpy_build_value_meta(PyObject *meta) {
+static meta_data_t *cpy_build_meta(PyObject *meta) {
meta_data_t *m = meta_data_create();
- if (cpy_build_meta(meta, &cpy_meta_data, (void *)m) < 0) {
+ if (cpy_build_meta_generic(meta, &cpy_meta_data, (void *)m) < 0) {
meta_data_destroy(m);
return NULL;
}
}
static void cpy_build_notification_meta(notification_t *n, PyObject *meta) {
- cpy_build_meta(meta, &cpy_plugin_notification_meta, (void *)n);
+ cpy_build_meta_generic(meta, &cpy_plugin_notification_meta, (void *)n);
}
static PyObject *Values_dispatch(Values *self, PyObject *args, PyObject *kwds) {
}
size = (size_t)PySequence_Length(values);
if (size != ds->ds_num) {
- PyErr_Format(PyExc_RuntimeError, "type %s needs %zu values, got %zu",
+ PyErr_Format(PyExc_RuntimeError,
+ "type %s needs %" PRIsz " values, got %" PRIsz,
value_list.type, ds->ds_num, size);
return NULL;
}
}
}
value_list.values = value;
- value_list.meta = cpy_build_value_meta(meta);
+ value_list.meta = cpy_build_meta(meta);
value_list.values_len = size;
value_list.time = DOUBLE_TO_CDTIME_T(time);
value_list.interval = DOUBLE_TO_CDTIME_T(interval);
}
size = (size_t)PySequence_Length(values);
if (size != ds->ds_num) {
- PyErr_Format(PyExc_RuntimeError, "type %s needs %zu values, got %zu",
+ PyErr_Format(PyExc_RuntimeError,
+ "type %s needs %" PRIsz " values, got %" PRIsz,
value_list.type, ds->ds_num, size);
return NULL;
}
value_list.values_len = size;
value_list.time = DOUBLE_TO_CDTIME_T(time);
value_list.interval = DOUBLE_TO_CDTIME_T(interval);
- value_list.meta = cpy_build_value_meta(meta);
+ value_list.meta = cpy_build_meta(meta);
if (value_list.host[0] == 0)
sstrncpy(value_list.host, hostname_g, sizeof(value_list.host));
if (value_list.plugin[0] == 0)
static PyObject *Values_repr(PyObject *s) {
PyObject *ret, *tmp;
- static PyObject *l_interval = NULL, *l_values = NULL, *l_meta = NULL,
- *l_closing = NULL;
+ static PyObject *l_interval, *l_values, *l_meta, *l_closing;
Values *self = (Values *)s;
if (l_interval == NULL)
PyObject *meta = NULL;
char *type = NULL, *plugin_instance = NULL, *type_instance = NULL,
*plugin = NULL, *host = NULL;
- static char *kwlist[] = {"type", "message", "plugin_instance",
- "type_instance", "plugin", "host",
- "time", "severity", "meta",
- NULL};
+ static char *kwlist[] = {
+ "type", "message", "plugin_instance", "type_instance", "plugin",
+ "host", "time", "severity", "meta", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etetetetetetdiO", kwlist, NULL,
- &type, NULL, &message, NULL,
- &plugin_instance, NULL, &type_instance, NULL,
- &plugin, NULL, &host, &time, &severity, &meta))
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwds, "|etetetetetetdiO", kwlist, NULL, &type, NULL, &message,
+ NULL, &plugin_instance, NULL, &type_instance, NULL, &plugin, NULL,
+ &host, &time, &severity, &meta))
return -1;
if (type && plugin_get_ds(type) == NULL) {
*type_instance = NULL;
char *message = NULL;
- static char *kwlist[] = {"type", "message", "plugin_instance",
- "type_instance", "plugin", "host",
- "time", "severity", "meta",
- NULL};
+ static char *kwlist[] = {
+ "type", "message", "plugin_instance", "type_instance", "plugin",
+ "host", "time", "severity", "meta", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|etetetetetetdiO", kwlist, NULL,
&type, NULL, &message, NULL,
&plugin_instance, NULL, &type_instance, NULL,
static PyObject *Notification_repr(PyObject *s) {
PyObject *ret, *tmp;
- static PyObject *l_severity = NULL, *l_message = NULL, *l_meta = NULL,
- *l_closing = NULL;
+ static PyObject *l_severity, *l_message, *l_meta, *l_closing;
Notification *self = (Notification *)s;
if (l_severity == NULL)
static PyMemberDef Notification_members[] = {
{"severity", T_INT, offsetof(Notification, severity), 0, severity_doc},
- {"meta", T_OBJECT_EX, offsetof(Notification, meta), 0, notification_meta_doc},
+ {"meta", T_OBJECT_EX, offsetof(Notification, meta), 0,
+ notification_meta_doc},
{NULL}};
static PyGetSetDef Notification_getseters[] = {
{NULL}};
PyTypeObject NotificationType = {
- CPY_INIT_TYPE "collectd.Notification", /* tp_name */
- sizeof(Notification), /* tp_basicsize */
- 0, /* Will be filled in later */
- Notification_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- Notification_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
+ CPY_INIT_TYPE "collectd.Notification", /* tp_name */
+ sizeof(Notification), /* tp_basicsize */
+ 0, /* Will be filled in later */
+ Notification_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ Notification_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- Notification_doc, /* tp_doc */
- Notification_traverse, /* tp_traverse */
- Notification_clear, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- Notification_methods, /* tp_methods */
- Notification_members, /* tp_members */
- Notification_getseters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- Notification_init, /* tp_init */
- 0, /* tp_alloc */
- Notification_new /* tp_new */
+ Notification_doc, /* tp_doc */
+ Notification_traverse, /* tp_traverse */
+ Notification_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Notification_methods, /* tp_methods */
+ Notification_members, /* tp_members */
+ Notification_getseters, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ Notification_init, /* tp_init */
+ 0, /* tp_alloc */
+ Notification_new /* tp_new */
};
static char Signed_doc[] =
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Signed_doc /* tp_doc */
};
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Unsigned_doc /* tp_doc */
};