]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/blobdiff - tc/m_ematch.h
Add reference to tc-codel(8) to the SEE ALSO section
[lisovros/iproute2_canprio.git] / tc / m_ematch.h
index 2b5d29386298e9cfdff662bc41c27fa66621c3eb..5036e9b6bf474b8c020cf8192142577dfbb3cd49 100644 (file)
@@ -18,23 +18,7 @@ struct bstr
        struct bstr     *next;
 };
 
-static inline struct bstr * bstr_alloc(const char *text)
-{
-       struct bstr *b = calloc(1, sizeof(*b));
-
-       if (b == NULL)
-               return NULL;
-
-       b->data = strdup(text);
-       if (b->data == NULL) {
-               free(b);
-               return NULL;
-       }
-
-       b->len = strlen(text);
-
-       return b;
-}
+extern struct bstr * bstr_alloc(const char *text);
 
 static inline struct bstr * bstr_new(char *data, unsigned int len)
 {
@@ -60,45 +44,15 @@ static inline int bstrcmp(struct bstr *b, const char *text)
        return d;
 }
 
-static inline unsigned long bstrtoul(struct bstr *b)
-{
-       char *inv = NULL;
-       unsigned long l;
-       char buf[b->len+1];
-
-       memcpy(buf, b->data, b->len);
-       buf[b->len] = '\0';
-
-       l = strtol(buf, &inv, 0);
-       if (l == ULONG_MAX || inv == buf)
-               return LONG_MAX;
-
-       return l;
-}
-
-static inline void bstr_print(FILE *fd, struct bstr *b, int ascii)
-{
-       int i;
-       char *s = b->data;
-
-       if (ascii)
-               for (i = 0; i < b->len; i++)
-                   fprintf(fd, "%c", isprint(s[i]) ? s[i] : '.');
-       else {
-               for (i = 0; i < b->len; i++)
-                   fprintf(fd, "%02x", s[i]);
-               fprintf(fd, "\"");
-               for (i = 0; i < b->len; i++)
-                   fprintf(fd, "%c", isprint(s[i]) ? s[i] : '.');
-               fprintf(fd, "\"");
-       }
-}
-
 static inline struct bstr *bstr_next(struct bstr *b)
 {
        return b->next;
 }
 
+extern unsigned long bstrtoul(const struct bstr *b);
+extern void bstr_print(FILE *fd, const struct bstr *b, int ascii);
+
+
 struct ematch
 {
        struct bstr     *args;
@@ -123,30 +77,8 @@ static inline struct ematch * new_ematch(struct bstr *args, int inverted)
        return e;
 }
 
-static inline void print_ematch_tree(struct ematch *tree)
-{
-       struct ematch *t;
-
-       for (t = tree; t; t = t->next) {
-               if (t->inverted)
-                       printf("NOT ");
-
-               if (t->child) {
-                       printf("(");
-                       print_ematch_tree(t->child);
-                       printf(")");
-               } else {
-                       struct bstr *b;
-                       for (b = t->args; b; b = b->next)
-                               printf("%s%s", b->data, b->next ? " " : "");
-               }
-
-               if (t->relation == TCF_EM_REL_AND)
-                       printf(" AND ");
-               else if (t->relation == TCF_EM_REL_OR)
-                       printf(" OR ");
-       }
-}
+extern void print_ematch_tree(const struct ematch *tree);
+
 
 struct ematch_util
 {