summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgr@lsx.localdomain>2008-05-15 13:56:13 +0200
committerThomas Graf <tgr@lsx.localdomain>2008-05-15 13:56:13 +0200
commit8cd39c9f4ca8731279ea6467a9d489902fcae7f9 (patch)
tree96d760b473839fe14effc6848b3250d13d469355 /include
parentef50a38fbd8682a5c9efd559e7db68664977f080 (diff)
downloadandroid_external_libnl-8cd39c9f4ca8731279ea6467a9d489902fcae7f9.tar.gz
android_external_libnl-8cd39c9f4ca8731279ea6467a9d489902fcae7f9.tar.bz2
android_external_libnl-8cd39c9f4ca8731279ea6467a9d489902fcae7f9.zip
Uninline various functions to save 7K code
Diffstat (limited to 'include')
-rw-r--r--include/netlink-local.h197
1 files changed, 10 insertions, 187 deletions
diff --git a/include/netlink-local.h b/include/netlink-local.h
index 1592138..b7b9b7f 100644
--- a/include/netlink-local.h
+++ b/include/netlink-local.h
@@ -6,7 +6,7 @@
* License as published by the Free Software Foundation version 2.1
* of the License.
*
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
*/
#ifndef NETLINK_LOCAL_H_
@@ -88,198 +88,21 @@ extern int __nl_read_num_str_file(const char *path,
#define dp_new_line(params, line) nl_new_line(params)
#define dp_dump(params, fmt, arg...) nl_dump(params, fmt, ##arg)
-static inline int __trans_list_add(int i, const char *a,
- struct nl_list_head *head)
-{
- struct trans_list *tl;
-
- tl = calloc(1, sizeof(*tl));
- if (!tl)
- return -NLE_NOMEM;
-
- tl->i = i;
- tl->a = strdup(a);
-
- nl_list_add_tail(&tl->list, head);
-
- return 0;
-}
-
-static inline void __trans_list_clear(struct nl_list_head *head)
-{
- struct trans_list *tl, *next;
-
- nl_list_for_each_entry_safe(tl, next, head, list) {
- free(tl->a);
- free(tl);
- }
-}
-
-static inline char *__type2str(int type, char *buf, size_t len,
- struct trans_tbl *tbl, size_t tbl_len)
-{
- int i;
- for (i = 0; i < tbl_len; i++) {
- if (tbl[i].i == type) {
- snprintf(buf, len, "%s", tbl[i].a);
- return buf;
- }
- }
+extern int __trans_list_add(int, const char *, struct nl_list_head *);
+extern void __trans_list_clear(struct nl_list_head *);
- snprintf(buf, len, "0x%x", type);
- return buf;
-}
-
-static inline char *__list_type2str(int type, char *buf, size_t len,
- struct nl_list_head *head)
-{
- struct trans_list *tl;
-
- nl_list_for_each_entry(tl, head, list) {
- if (tl->i == type) {
- snprintf(buf, len, "%s", tl->a);
- return buf;
- }
- }
-
- snprintf(buf, len, "0x%x", type);
- return buf;
-}
+extern char *__type2str(int, char *, size_t, struct trans_tbl *, size_t);
+extern int __str2type(const char *, struct trans_tbl *, size_t);
-static inline char *__flags2str(int flags, char *buf, size_t len,
- struct trans_tbl *tbl, size_t tbl_len)
-{
- int i;
- int tmp = flags;
-
- memset(buf, 0, len);
-
- for (i = 0; i < tbl_len; i++) {
- if (tbl[i].i & tmp) {
- tmp &= ~tbl[i].i;
- strncat(buf, tbl[i].a, len - strlen(buf) - 1);
- if ((tmp & flags))
- strncat(buf, ",", len - strlen(buf) - 1);
- }
- }
-
- return buf;
-}
-
-static inline int __str2type(const char *buf, struct trans_tbl *tbl,
- size_t tbl_len)
-{
- unsigned long l;
- char *end;
- int i;
+extern char *__list_type2str(int, char *, size_t, struct nl_list_head *);
+extern int __list_str2type(const char *, struct nl_list_head *);
- if (*buf == '\0')
- return -1;
-
- for (i = 0; i < tbl_len; i++)
- if (!strcasecmp(tbl[i].a, buf))
- return tbl[i].i;
-
- l = strtoul(buf, &end, 0);
- if (l == ULONG_MAX || *end != '\0')
- return -1;
-
- return (int) l;
-}
-
-static inline int __list_str2type(const char *buf, struct nl_list_head *head)
-{
- struct trans_list *tl;
- unsigned long l;
- char *end;
-
- if (*buf == '\0')
- return -1;
-
- nl_list_for_each_entry(tl, head, list) {
- if (!strcasecmp(tl->a, buf))
- return tl->i;
- }
-
- l = strtoul(buf, &end, 0);
- if (l == ULONG_MAX || *end != '\0')
- return -1;
-
- return (int) l;
-}
-
-static inline int __str2flags(const char *buf, struct trans_tbl *tbl,
- size_t tbl_len)
-{
- int i, flags = 0, len;
- char *p = (char *) buf, *t;
-
- for (;;) {
- if (*p == ' ')
- p++;
-
- t = strchr(p, ',');
- len = t ? t - p : strlen(p);
- for (i = 0; i < tbl_len; i++)
- if (!strncasecmp(tbl[i].a, p, len))
- flags |= tbl[i].i;
-
- if (!t)
- return flags;
-
- p = ++t;
- }
-
- return 0;
-}
-
-static inline void __dp_dump(struct nl_dump_params *parms, const char *fmt,
- va_list args)
-{
- if (parms->dp_fd)
- vfprintf(parms->dp_fd, fmt, args);
- else if (parms->dp_buf || parms->dp_cb) {
- char *buf = NULL;
- vasprintf(&buf, fmt, args);
- if (parms->dp_cb)
- parms->dp_cb(parms, buf);
- else
- strncat(parms->dp_buf, buf,
- parms->dp_buflen - strlen(parms->dp_buf) - 1);
- free(buf);
- }
-}
+extern char *__flags2str(int, char *, size_t, struct trans_tbl *, size_t);
+extern int __str2flags(const char *, struct trans_tbl *, size_t);
#define dp_dump_line(params, line, fmt, arg...) nl_dump_line(params, fmt, ##arg)
-static inline void dump_from_ops(struct nl_object *obj,
- struct nl_dump_params *params)
-{
- int type = params->dp_type;
-
- if (type < 0 || type > NL_DUMP_MAX)
- BUG();
-
- params->dp_line = 0;
-
- if (params->dp_dump_msgtype) {
-#if 0
- /* XXX */
- char buf[64];
-
- dp_dump_line(params, 0, "%s ",
- nl_cache_mngt_type2name(obj->ce_ops,
- obj->ce_ops->co_protocol,
- obj->ce_msgtype,
- buf, sizeof(buf)));
-#endif
- params->dp_pre_dump = 1;
- } else
- nl_new_line(params);
-
- if (obj->ce_ops->oo_dump[type])
- obj->ce_ops->oo_dump[type](obj, params);
-}
+extern void dump_from_ops(struct nl_object *, struct nl_dump_params *);
static inline struct nl_cache *dp_cache(struct nl_object *obj)
{