Skip to content

Commit 9833056

Browse files
committed
script_helper: Fix build
Move flags parser in a .h file, so script_helper sees it as well.
1 parent f2d2a0d commit 9833056

4 files changed

Lines changed: 63 additions & 53 deletions

File tree

modules/dialog/dialog.c

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "../../script_var.h"
4040
#include "../../mem/mem.h"
4141
#include "../../mi/mi.h"
42-
#include "../../lib/csv.h"
4342
#include "../rr/api.h"
4443
#include "../../bin_interface.h"
4544
#include "../clusterer/api.h"
@@ -605,60 +604,14 @@ static int free_fixup_route(void** param)
605604
return 0;
606605
}
607606

608-
/*
609-
* Keep this array in sync with create_dlg_flags[] below: if you add, remove
610-
* or reorder a create_dialog() flag here, make the identical change there.
611-
*/
612-
static str create_dlg_flag_names[] = {
613-
str_init("bye-on-timeout"), /* DLG_FLAG_BYEONTIMEOUT */
614-
str_init("options-ping-caller"), /* DLG_FLAG_PING_CALLER */
615-
str_init("options-ping-callee"), /* DLG_FLAG_PING_CALLEE */
616-
str_init("reinvite-ping-caller"), /* DLG_FLAG_REINVITE_PING_CALLER */
617-
str_init("reinvite-ping-callee"), /* DLG_FLAG_REINVITE_PING_CALLEE */
618-
str_init("end-on-race-condition"), /* DLG_FLAG_END_ON_RACE_CONDITION */
619-
str_init("auto-prack"), /* DLG_FLAG_AUTOPRACK */
620-
STR_NULL
621-
};
622-
623607
static int fixup_create_dlg_flags(void **param)
624608
{
625-
static const unsigned int create_dlg_flags[] = {
626-
DLG_FLAG_BYEONTIMEOUT,
627-
DLG_FLAG_PING_CALLER,
628-
DLG_FLAG_PING_CALLEE,
629-
DLG_FLAG_REINVITE_PING_CALLER,
630-
DLG_FLAG_REINVITE_PING_CALLEE,
631-
DLG_FLAG_END_ON_RACE_CONDITION,
632-
DLG_FLAG_AUTOPRACK
633-
};
634609
str *flags_str = (str *)*param;
635-
csv_record *list, *rec;
636-
unsigned int flags = 0;
637-
int i;
610+
int flags;
638611

639-
list = parse_csv_record(flags_str);
640-
if (!list) {
641-
LM_ERR("Failed to parse list of create_dialog flags\n");
612+
flags = parse_create_dlg_flags(flags_str);
613+
if (flags < 0)
642614
return -1;
643-
}
644-
645-
for (rec = list; rec; rec = rec->next) {
646-
for (i = 0; create_dlg_flag_names[i].s; i++) {
647-
if (str_strcasecmp(&rec->s, &create_dlg_flag_names[i]) == 0) {
648-
flags |= create_dlg_flags[i];
649-
break;
650-
}
651-
}
652-
653-
if (!create_dlg_flag_names[i].s) {
654-
LM_ERR("Unknown create_dialog flag: %.*s\n",
655-
rec->s.len, rec->s.s);
656-
free_csv_record(list);
657-
return -1;
658-
}
659-
}
660-
661-
free_csv_record(list);
662615
*param = (void *)(unsigned long)flags;
663616
return 0;
664617
}

modules/dialog/dlg_load.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
#ifndef _DIALOG_DLG_LOAD_H_
2323
#define _DIALOG_DLG_LOAD_H_
2424

25+
#include "../../lib/csv.h"
2526
#include "dlg_cb.h"
2627
#include "dlg_ctx.h"
28+
#include "dlg_hash.h"
2729
#include "dlg_handlers.h"
2830
#include "dlg_profile.h"
2931
#include "dlg_vals.h"
@@ -87,6 +89,62 @@ typedef int(*load_dlg_f)( struct dlg_binds *dlgb );
8789
int load_dlg( struct dlg_binds *dlgb);
8890

8991

92+
static inline int parse_create_dlg_flags(str *flags_str)
93+
{
94+
/* Keep this array in sync with create_dlg_flags[] below: if you add,
95+
* remove or reorder a create_dialog() flag here, make the identical
96+
* change there as well.
97+
*/
98+
static const str create_dlg_flag_names[] = {
99+
str_init("bye-on-timeout"),
100+
str_init("options-ping-caller"),
101+
str_init("options-ping-callee"),
102+
str_init("reinvite-ping-caller"),
103+
str_init("reinvite-ping-callee"),
104+
str_init("end-on-race-condition"),
105+
str_init("auto-prack"),
106+
STR_NULL
107+
};
108+
static const unsigned int create_dlg_flags[] = {
109+
DLG_FLAG_BYEONTIMEOUT,
110+
DLG_FLAG_PING_CALLER,
111+
DLG_FLAG_PING_CALLEE,
112+
DLG_FLAG_REINVITE_PING_CALLER,
113+
DLG_FLAG_REINVITE_PING_CALLEE,
114+
DLG_FLAG_END_ON_RACE_CONDITION,
115+
DLG_FLAG_AUTOPRACK
116+
};
117+
csv_record *list, *rec;
118+
unsigned int flags = 0;
119+
int i;
120+
121+
list = parse_csv_record(flags_str);
122+
if (!list) {
123+
LM_ERR("failed to parse list of create_dialog flags\n");
124+
return -1;
125+
}
126+
127+
for (rec = list; rec; rec = rec->next) {
128+
for (i = 0; create_dlg_flag_names[i].s; i++) {
129+
if (str_strcasecmp(&rec->s, &create_dlg_flag_names[i]) == 0) {
130+
flags |= create_dlg_flags[i];
131+
break;
132+
}
133+
}
134+
135+
if (!create_dlg_flag_names[i].s) {
136+
LM_ERR("unknown create_dialog flag: %.*s\n",
137+
rec->s.len, rec->s.s);
138+
free_csv_record(list);
139+
return -1;
140+
}
141+
}
142+
143+
free_csv_record(list);
144+
return (int)flags;
145+
}
146+
147+
90148
static inline int load_dlg_api( struct dlg_binds *dlgb )
91149
{
92150
load_dlg_f load_dlg;

modules/script_helper/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ modparam("script_helper", "use_dialog", 1)
106106

107107
Example 1.2. Setting create_dialog_flags
108108
...
109-
modparam("script_helper", "create_dialog_flags", "PpB")
109+
modparam("script_helper", "create_dialog_flags", "options-ping-caller,options-ping-callee,bye-on-timeout")
110110
...
111111

112112
1.4.3. sequential_route (string)

modules/script_helper/doc/script_helper_admin.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ modparam("script_helper", "use_dialog", 1)
122122
<title>Setting <varname>create_dialog_flags</varname></title>
123123
<programlisting format="linespecific">
124124
...
125-
modparam("script_helper", "create_dialog_flags", "PpB")
125+
modparam("script_helper", "create_dialog_flags", "options-ping-caller,options-ping-callee,bye-on-timeout")
126126
...
127127
</programlisting>
128128
</example>
@@ -164,4 +164,3 @@ route [sequential_handling]
164164

165165
</section>
166166
</chapter>
167-

0 commit comments

Comments
 (0)