mtree: coherent indentation
authorDaniel-Constantin Mierla <miconda@gmail.com>
Sat, 13 Feb 2016 10:41:24 +0000 (11:41 +0100)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Wed, 17 Feb 2016 07:43:52 +0000 (08:43 +0100)
modules/mtree/mtree.c
modules/mtree/mtree.h
modules/mtree/mtree_mod.c

index 91f3e63..9d0ce99 100644 (file)
@@ -49,7 +49,7 @@ extern int _mt_ignore_duplicates;
 extern int _mt_allow_duplicates;
 
 /** structures containing prefix-value pairs */
-static m_tree_t **_ptree = NULL; 
+static m_tree_t **_ptree = NULL;
 
 /* quick transaltion table */
 unsigned char _mt_char_table[256];
@@ -210,7 +210,7 @@ int mt_add_to_tree(m_tree_t *pt, str *sp, str *svalue)
        }
 
        LM_DBG("adding to tree <%.*s> of type <%d>\n", pt->tname.len,
-              pt->tname.s, pt->type);
+                       pt->tname.s, pt->type);
 
        if ((pt->type == MT_TREE_IVAL) && (str2sint(svalue, &ivalue) != 0)) {
                LM_ERR("bad integer string <%.*s>\n", svalue->len, svalue->s);
@@ -236,7 +236,7 @@ int mt_add_to_tree(m_tree_t *pt, str *sp, str *svalue)
        {
                LM_ERR("invalid char %d in prefix [%c (0x%x)]\n",
                                l, sp->s[l], sp->s[l]);
-               return -1;                      
+               return -1;
        }
        itn = itn0[_mt_char_table[(unsigned int)sp->s[l]]].child;
 
@@ -255,12 +255,12 @@ int mt_add_to_tree(m_tree_t *pt, str *sp, str *svalue)
                        pt->memsize +=  MT_NODE_SIZE*sizeof(mt_node_t);
                        itn0[_mt_char_table[(unsigned int)sp->s[l]]].child = itn;
                }
-               l++;    
+               l++;
                if(_mt_char_table[(unsigned int)sp->s[l]]==255)
                {
                        LM_ERR("invalid char %d in prefix [%c (0x%x)]\n",
                                        l, sp->s[l], sp->s[l]);
-                       return -1;                      
+                       return -1;
                }
                itn0 = itn;
                itn = itn0[_mt_char_table[(unsigned int)sp->s[l]]].child;
@@ -376,7 +376,7 @@ is_t* mt_get_tvalue(m_tree_t *pt, str *tomatch, int *len)
                }
 
                itn = itn[_mt_char_table[(unsigned int)tomatch->s[l]]].child;
-               l++;    
+               l++;
        }
 
        *len = l;
@@ -386,7 +386,7 @@ is_t* mt_get_tvalue(m_tree_t *pt, str *tomatch, int *len)
 
 int mt_add_tvalues(struct sip_msg *msg, m_tree_t *pt, str *tomatch)
 {
-        int l, n;
+       int l, n;
        mt_node_t *itn;
        int_str val, values_avp_name;
        unsigned short values_name_type;
@@ -434,13 +434,13 @@ int mt_add_tvalues(struct sip_msg *msg, m_tree_t *pt, str *tomatch)
                }
 
                itn = itn[_mt_char_table[(unsigned int)tomatch->s[l]]].child;
-               l++;    
+               l++;
        }
 
        if (n > 0)
-               return 0;
+               return 0;
        else
-               return -1;
+               return -1;
 }
 
 int mt_match_prefix(struct sip_msg *msg, m_tree_t *it,
@@ -471,7 +471,7 @@ int mt_match_prefix(struct sip_msg *msg, m_tree_t *it,
        l = len = 0;
        n = 0;
        if ((it->type==MT_TREE_SVAL) || (it->type==MT_TREE_IVAL)) {
-               if (mode == 2) 
+               if (mode == 2)
                        return mt_add_tvalues(msg, it, tomatch);
                tvalue = mt_get_tvalue(it, tomatch, &k);
                if (tvalue == NULL) {
@@ -543,7 +543,7 @@ int mt_match_prefix(struct sip_msg *msg, m_tree_t *it,
                        break;
 
                itn = itn[_mt_char_table[(unsigned int)tomatch->s[l]]].child;
-               l++;    
+               l++;
        }
 
        if(n==0)
@@ -627,7 +627,7 @@ void mt_free_tree(m_tree_t *pt)
        if(pt == NULL)
                return;
 
-       if(pt->head!=NULL) 
+       if(pt->head!=NULL)
                mt_free_node(pt->head, pt->type);
        if(pt->next!=NULL)
                mt_free_tree(pt->next);
@@ -818,7 +818,7 @@ int mt_table_spec(char* val)
                LM_ERR("unknown multi value <%d>\n", tmp.multi);
                goto error;
        }
-       
+
        /* check for same tree */
        if(_ptree == 0)
        {
@@ -835,7 +835,7 @@ int mt_table_spec(char* val)
        prev = NULL;
        /* search the it position before which to insert new tvalue */
        while(it!=NULL && str_strcmp(&it->tname, &tmp.tname)<0)
-       {       
+       {
                prev = it;
                it = it->next;
        }
@@ -844,7 +844,7 @@ int mt_table_spec(char* val)
        if(it!=NULL && str_strcmp(&it->tname, &tmp.tname)==0)
        {
                LM_ERR("duplicate tree with name [%s]\n", tmp.tname.s);
-               goto error; 
+               goto error;
        }
        /* add new tname*/
        if(it==NULL || str_strcmp(&it->tname, &tmp.tname)>0)
@@ -852,12 +852,12 @@ int mt_table_spec(char* val)
                LM_DBG("adding new tname [%s]\n", tmp.tname.s);
 
                ndl = mt_init_tree(&tmp.tname, &tmp.dbtable, &tmp.scols[0], tmp.type,
-                                  tmp.multi);
+                                       tmp.multi);
                if(ndl==NULL)
                {
                        LM_ERR("cannot init the tree [%.*s]\n",
                                        tmp.tname.len, tmp.tname.s);
-                       goto error; 
+                       goto error;
                }
 
                ndl->next = it;
index 583e365..d76b2e3 100644 (file)
@@ -21,7 +21,7 @@
  *
  */
 
-                      
+
 #ifndef _MTREE_H_
 #define _MTREE_H_
 
 #include "../../lib/kmi/mi.h"
 #include "../../rpc.h"
 
-#define MT_TREE_SVAL   0       
+#define MT_TREE_SVAL   0
 #define MT_TREE_DW     1
 #define MT_TREE_IVAL   2
 
 typedef union {
-    int n;
-    str s;
+       int n;
+       str s;
 } is_t;
 
 typedef struct _mt_dw
@@ -48,15 +48,15 @@ typedef struct _mt_dw
 
 typedef struct _mt_is
 {
-    is_t tvalue;
-    struct _mt_is *next;
+       is_t tvalue;
+       struct _mt_is *next;
 } mt_is_t;
 
 typedef struct _mt_node
 {
-    mt_is_t *tvalues;
-    void *data;
-    struct _mt_node *child;
+       mt_is_t *tvalues;
+       void *data;
+       struct _mt_node *child;
 } mt_node_t;
 
 #define MT_MAX_DEPTH   64
@@ -91,7 +91,7 @@ m_tree_t* mt_get_first_tree();
 
 is_t* mt_get_tvalue(m_tree_t *pt, str *tomatch, int *len);
 int mt_match_prefix(struct sip_msg *msg, m_tree_t *pt,
-                   str *tomatch, int mode);
+                       str *tomatch, int mode);
 
 m_tree_t* mt_init_tree(str* tname, str* dbtable, str *scols, int type,
                int multi);
@@ -110,11 +110,11 @@ int mt_defined_trees(void);
 m_tree_t *mt_swap_list_head(m_tree_t *ntree);
 int mt_init_list_head(void);
 m_tree_t *mt_add_tree(m_tree_t **dpt, str *tname, str *dbtable,
-                     str *cols, int type, int multi);
+                       str *cols, int type, int multi);
 
 int mt_mi_match_prefix(struct mi_node *rpl, m_tree_t *pt,
-                   str *tomatch, int mode);
+                       str *tomatch, int mode);
 int mt_rpc_match_prefix(rpc_t* rpc, void* ctx, m_tree_t *pt,
-                   str *tomatch, int mode);
+                       str *tomatch, int mode);
 #endif
 
index b8106ea..05f69ac 100644 (file)
@@ -258,7 +258,7 @@ static int mod_init(void)
        db_con = mt_dbf.init(&db_url);
        if(db_con==NULL)
        {
-               LM_ERR("failed to connect to the database\n");        
+               LM_ERR("failed to connect to the database\n");
                return -1;
        }
 
@@ -281,8 +281,8 @@ static int mod_init(void)
 
                while(pt!=NULL)
                {
-                       LM_DBG("loading from tree <%.*s>\n",
-                               pt->tname.len, pt->tname.s);
+                       LM_DBG("loading from tree <%.*s>\n",
+                                       pt->tname.len, pt->tname.s);
 
                        /* loading all information from database */
                        if(mt_load_db(pt)!=0)
@@ -546,9 +546,9 @@ static int mt_load_db(m_tree_t *pt)
        str tprefix, tvalue;
        db1_res_t* db_res = NULL;
        int i, ret, c;
-       m_tree_t new_tree; 
-       m_tree_t *old_tree = NULL; 
-       mt_node_t *bk_head = NULL; 
+       m_tree_t new_tree;
+       m_tree_t *old_tree = NULL;
+       mt_node_t *bk_head = NULL;
 
        if(pt->ncols>0) {
                for(c=0; c<pt->ncols; c++) {
@@ -574,7 +574,7 @@ static int mt_load_db(m_tree_t *pt)
        if(old_tree==NULL)
        {
                LM_ERR("tree definition not found [%.*s]\n", pt->tname.len,
-                      pt->tname.s);
+                               pt->tname.s);
                return -1;
        }
        memcpy(&new_tree, old_tree, sizeof(m_tree_t));
@@ -792,7 +792,7 @@ static int mt_load_db_trees()
                                continue;
                        }
                        new_tree = mt_add_tree(&new_head, &tname, &db_table, NULL,
-                                              _mt_tree_type, 0);
+                                                       _mt_tree_type, 0);
                        if(new_tree==NULL)
                        {
                                LM_ERR("New tree cannot be initialized\n");
@@ -894,7 +894,7 @@ static struct mi_root* mt_mi_reload(struct mi_root *cmd_tree, void *param)
                                /* re-loading table from database */
                                if(mt_load_db(pt)!=0)
                                {
-                                       LM_ERR("cannot re-load info from database\n");  
+                                       LM_ERR("cannot re-load info from database\n");
                                        goto error;
                                }
                        }
@@ -1009,9 +1009,9 @@ struct mi_root* mt_mi_list(struct mi_root* cmd_tree, void* param)
 
        while(pt!=NULL)
        {
-               if(tname.s==NULL || 
-                               (tname.s!=NULL && pt->tname.len>=tname.len && 
-                                strncmp(pt->tname.s, tname.s, tname.len)==0))
+               if(tname.s==NULL ||
+                               (tname.s!=NULL && pt->tname.len>=tname.len &&
+                                       strncmp(pt->tname.s, tname.s, tname.len)==0))
                {
                        len = 0;
                        if(mt_print_mi_node(pt, pt->head, rpl, code_buf, len)<0)
@@ -1096,7 +1096,7 @@ error:
        return 0;
 }
 
-void rpc_mtree_summary(rpc_t* rpc, void* c) 
+void rpc_mtree_summary(rpc_t* rpc, void* c)
 {
        str tname = {0, 0};
        m_tree_t *pt;
@@ -1225,7 +1225,7 @@ void rpc_mtree_reload(rpc_t* rpc, void* c)
                                /* re-loading table from database */
                                if(mt_load_db(pt)!=0)
                                {
-                                       LM_ERR("cannot re-load mtree from database\n"); 
+                                       LM_ERR("cannot re-load mtree from database\n");
                                        goto error;
                                }
                        }