Skip to content

Commit

Permalink
Convert flag_list_to_bitmask() to use const str_const *.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Jan 26, 2021
1 parent 5e04676 commit 7c6d618
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions flags.c
Expand Up @@ -119,11 +119,11 @@ str bitmask_to_flag_list(enum flag_type type, int bitmask)
return ret;
}

int flag_list_to_bitmask(str *flags, enum flag_type type, char delim)
int flag_list_to_bitmask(const str_const *flags, enum flag_type type, char delim)
{
char *p, *lim;
char *crt_flag;
str name;
const char *p, *lim;
const char *crt_flag;
str_const name;
struct flag_entry *e;
int ret = 0;

Expand Down
2 changes: 1 addition & 1 deletion flags.h
Expand Up @@ -80,7 +80,7 @@ str bitmask_to_flag_list(enum flag_type type, int bitmask);
* Note: flags which are not used at script level and are not instantiated with
* get_flag_id_by_name will be ignored
*/
int flag_list_to_bitmask(str *flags, enum flag_type type, char delim);
int flag_list_to_bitmask(const str_const *flags, enum flag_type type, char delim);

unsigned int fixup_flag(int flag_type, const str *flag_name);
int get_flag_id_by_name(int flag_type, char *flag_name, int flag_name_len);
Expand Down
6 changes: 3 additions & 3 deletions modules/usrloc/dlist.c
Expand Up @@ -122,7 +122,6 @@ static int get_domain_db_ucontacts(udomain_t *d, void *buf, int *len,
db_res_t *res = NULL;
db_row_t *row;
db_val_t *val;
str flag_list;
int i, no_rows = 10;
time_t now;
char *p, *p1;
Expand Down Expand Up @@ -199,9 +198,10 @@ static int get_domain_db_ucontacts(udomain_t *d, void *buf, int *len,

do {
for (i = 0; i < RES_ROW_N(res); i++) {
str_const flag_list;
row = RES_ROWS(res) + i;
val = ROW_VALUES(row) + 3; /* cflags */
flag_list.s = (char *)VAL_STRING(val);
flag_list.s = VAL_STRING(val);
flag_list.len = flag_list.s ? strlen(flag_list.s) : 0;

LM_DBG("contact cflags: '%.*s'\n", flag_list.len, flag_list.s);
Expand Down Expand Up @@ -427,7 +427,7 @@ cdb_pack_ping_data(const str *aor, const cdb_pair_t *contact,
break;

case 'f':
cflags = flag_list_to_bitmask(&pair->val.val.st,
cflags = flag_list_to_bitmask(str2const(&pair->val.val.st),
FLAG_TYPE_BRANCH, FLAG_DELIM);
cols_needed &= ~COL_CFLAGS;
break;
Expand Down
7 changes: 4 additions & 3 deletions modules/usrloc/udomain.c
Expand Up @@ -190,7 +190,7 @@ cdb_ctdict2info(const cdb_dict_t *ct_fields, str *contact)
ci.callid = &callid;
break;
case 'f':
ci.cflags = flag_list_to_bitmask(&pair->val.val.st,
ci.cflags = flag_list_to_bitmask(str2const(&pair->val.val.st),
FLAG_TYPE_BRANCH, FLAG_DELIM);
break;
case 'o':
Expand Down Expand Up @@ -271,7 +271,7 @@ static inline ucontact_info_t* dbrow2info(db_val_t *vals, str *contact)
{
static ucontact_info_t ci;
static str callid, ua, received, host, path, instance;
static str attr, packed_kv, flags;
static str attr, packed_kv;
int port, proto;
char *p;

Expand Down Expand Up @@ -323,7 +323,8 @@ static inline ucontact_info_t* dbrow2info(db_val_t *vals, str *contact)
ci.flags = VAL_BITMAP(vals+6);

if (!VAL_NULL(vals+7)) {
flags.s = (char *)VAL_STRING(vals+7);
str_const flags;
flags.s = VAL_STRING(vals+7);
flags.len = strlen(flags.s);
LM_DBG("flag str: '%.*s'\n", flags.len, flags.s);

Expand Down
2 changes: 1 addition & 1 deletion pvar.c
Expand Up @@ -3243,7 +3243,7 @@ static int pv_set_branch_fields(struct sip_msg* msg, pv_param_t *param,
return -1;
}
flags = (!val||val->flags&PV_VAL_NULL)?
0 : flag_list_to_bitmask(&val->rs, FLAG_TYPE_BRANCH, FLAG_DELIM);
0 : flag_list_to_bitmask(str2const(&val->rs), FLAG_TYPE_BRANCH, FLAG_DELIM);
return update_branch( idx, NULL, NULL,
NULL, NULL, &flags, NULL);
case BR_SOCKET_ID: /* set SOCKET */
Expand Down

0 comments on commit 7c6d618

Please sign in to comment.