MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / load_re

Function load_re

modules/group/re_group.c:77–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76
77int load_re( str *table )
78{
79 db_key_t cols[2];
80 db_res_t* res = NULL;
81 db_row_t* row;
82 int n;
83
84 cols[0] = &re_exp_column;
85 cols[1] = &re_gid_column;
86
87 if (group_dbf.use_table(group_dbh, table) < 0) {
88 LM_ERR("failed to set table <%s>\n", table->s);
89 goto error;
90 }
91
92 if (group_dbf.query(group_dbh, 0, 0, 0, cols, 0, 2, 0, &res) < 0) {
93 LM_ERR("failed to query database\n");
94 goto error;
95 }
96
97 for( n=0 ; n<RES_ROW_N(res) ; n++) {
98 row = &res->rows[n];
99 /* validate row */
100 if (row->values[0].nul || row->values[0].type!=DB_STRING) {
101 LM_ERR("empty or non-string "
102 "value for <%s>(re) column\n",re_exp_column.s);
103 goto error1;
104 }
105 if (row->values[1].nul || row->values[1].type!=DB_INT) {
106 LM_ERR("empty or non-integer "
107 "value for <%s>(gid) column\n",re_gid_column.s);
108 goto error1;
109 }
110
111 if ( add_re( row->values[0].val.string_val,
112 row->values[1].val.int_val)!=0 ) {
113 LM_ERR("failed to add row\n");
114 goto error1;
115 }
116 }
117 LM_DBG("%d rules were loaded\n", n);
118
119 group_dbf.free_result(group_dbh, res);
120 return 0;
121error1:
122 group_dbf.free_result(group_dbh, res);
123error:
124 return -1;
125}
126
127
128

Callers 1

mod_initFunction · 0.85

Calls 1

add_reFunction · 0.85

Tested by

no test coverage detected