[asterisk-commits] branch kpfleming/stringfields - r7754 /team/kpfleming/stringfields/include/as...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jan 3 17:49:57 CST 2006


Author: kpfleming
Date: Tue Jan  3 17:49:57 2006
New Revision: 7754

URL: http://svn.digium.com/view/asterisk?rev=7754&view=rev
Log:
would be good if the new header file was actually in the repository...

Added:
    team/kpfleming/stringfields/include/asterisk/stringfields.h

Added: team/kpfleming/stringfields/include/asterisk/stringfields.h
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/include/asterisk/stringfields.h?rev=7754&view=auto
==============================================================================
--- team/kpfleming/stringfields/include/asterisk/stringfields.h (added)
+++ team/kpfleming/stringfields/include/asterisk/stringfields.h Tue Jan  3 17:49:57 2006
@@ -1,0 +1,61 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief String fields in structures
+ */
+
+#ifndef _ASTERISK_STRINGFIELDS_H
+#define _ASTERISK_STRINGFIELDS_H
+
+#include <string.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+#include "asterisk/inline_api.h"
+#include "asterisk/compiler.h"
+#include "asterisk/compat.h"
+
+typedef const char const * ast_string_field;
+
+#define AST_STRING_FIELD(name) ast_string_field name;
+
+#define AST_DECLARE_STRING_FIELDS(field_list) \
+	char *__begin_field[0]; \
+	field_list \
+	char *__end_field[0];
+
+#define ast_string_field_count(x) \
+	(offsetof(typeof(*x), __end_field) - offsetof(typeof(*x), __begin_field)) / sizeof(ast_string_field)
+
+#define ast_string_field_set(x, field, data) \
+	x->field = strdup(data)
+
+#define ast_string_field_build(x, field, fmt, args...) \
+	asprintf((char **) &x->field, fmt, args)
+
+#define ast_string_field_free(x, field) \
+	free((char *) x->field)
+
+#define ast_string_field_free_all(x) { \
+	int index; \
+	for (index = 0; index < ast_string_field_count(x); index ++) \
+		free(x->__begin_field[index]); \
+	}
+
+#endif /* _ASTERISK_STRINGFIELDS_H */



More information about the asterisk-commits mailing list