42 "1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"
50 {
"123456789",
"0,1",
"1" },
51 {
"123456789",
"0,-8",
"1" },
52 {
"123456789",
"-9,1",
"1" },
53 {
"123456789",
"-9,-8",
"1" },
55 {
"123456789",
"0,0",
"" },
56 {
"123456789",
"-9,0",
"" },
57 {
"123456789",
"-9,-9",
"" },
59 {
"123456789",
"5,-6",
"" },
60 {
"123456789",
"-5,-6",
"" },
62 {
"123456789",
"-5",
"56789" },
63 {
"123456789",
"4",
"56789" },
65 {
"123456789",
"8,10",
"9" },
66 {
"123456789",
"10,1",
"" },
68 {
"123456789",
"2,5",
"34567" },
69 {
"123456789",
"-7,5",
"34567" },
71 {
"123\n456\n789\n",
"0,1,l",
"123\n" },
72 {
"123\n456\n789\n",
"-3,1,l",
"123\n" },
73 {
"123\n456\n789\n",
"0,-2,l",
"123\n" },
74 {
"123\n456\n789\n",
"-3,-2,l",
"123\n" },
76 {
"123\n456\n789\n",
"0,0,l",
"" },
77 {
"123\n456\n789\n",
"-3,0,l",
"" },
78 {
"123\n456\n789\n",
"-3,-3,l",
"" },
80 {
"123\n456\n789\n",
"2,-2,l",
"" },
81 {
"123\n456\n789\n",
"-2,-3,l",
"" },
83 {
"123\n456\n789\n",
"1,,l",
"456\n789\n" },
84 {
"123\n456\n789\n",
"-2,,l",
"456\n789\n" },
94 {
"123456789",
"0,1",
"a",
"a23456789" },
95 {
"123456789",
"-9,1",
"a",
"a23456789" },
96 {
"123456789",
"0,-8",
"a",
"a23456789" },
97 {
"123456789",
"-9,-8",
"a",
"a23456789" },
98 {
"123456789",
"5,1",
"b",
"12345b789" },
99 {
"123456789",
"-4,1",
"b",
"12345b789" },
100 {
"123456789",
"5,-3",
"b",
"12345b789" },
101 {
"123456789",
"-4,-3",
"b",
"12345b789" },
103 {
"123456789",
"0,2",
"c",
"c3456789" },
104 {
"123456789",
"-9,2",
"c",
"c3456789" },
105 {
"123456789",
"0,-7",
"c",
"c3456789" },
106 {
"123456789",
"-9,-7",
"c",
"c3456789" },
107 {
"123456789",
"4,2",
"d",
"1234d789" },
108 {
"123456789",
"-5,2",
"d",
"1234d789" },
109 {
"123456789",
"4,-3",
"d",
"1234d789" },
110 {
"123456789",
"-5,-3",
"d",
"1234d789" },
112 {
"123456789",
"5",
"e",
"12345e" },
113 {
"123456789",
"5",
"",
"12345" },
114 {
"123456789",
"-4",
"e",
"12345e" },
115 {
"123456789",
"-4",
"",
"12345" },
117 {
"123456789",
"0,1",
"fg",
"fg23456789" },
118 {
"123456789",
"0,-8",
"fg",
"fg23456789" },
119 {
"123456789",
"-9,1",
"fg",
"fg23456789" },
120 {
"123456789",
"-9,-8",
"fg",
"fg23456789" },
122 {
"123456789",
"",
"h",
"h" },
123 {
"123456789",
",,,",
"h",
"h" },
124 {
"123\n456\n789\n",
",,l",
"h",
"h\n" },
125 {
"123\n456\n789\n",
",,ld",
"h",
"h" },
127 {
"123\n456\n789\n",
"0,1,l",
"abc",
"abc\n456\n789\n" },
128 {
"123\n456\n789\n",
"-3,1,l",
"abc",
"abc\n456\n789\n" },
129 {
"123\n456\n789\n",
"0,-2,l",
"abc",
"abc\n456\n789\n" },
130 {
"123\n456\n789\n",
"-3,-2,l",
"abc",
"abc\n456\n789\n" },
131 {
"123\n456\n789\n",
"1,1,l",
"abc",
"123\nabc\n789\n" },
132 {
"123\n456\n789\n",
"1,-1,l",
"abc",
"123\nabc\n789\n" },
133 {
"123\n456\n789\n",
"-2,1,l",
"abc",
"123\nabc\n789\n" },
134 {
"123\n456\n789\n",
"-2,-1,l",
"abc",
"123\nabc\n789\n" },
136 {
"123\n456\n789\n",
"0,1,l",
"ab",
"ab\n456\n789\n" },
137 {
"123\n456\n789\n",
"-3,1,l",
"ab",
"ab\n456\n789\n" },
138 {
"123\n456\n789\n",
"0,-2,l",
"ab",
"ab\n456\n789\n" },
139 {
"123\n456\n789\n",
"-3,-2,l",
"ab",
"ab\n456\n789\n" },
140 {
"123\n456\n789\n",
"1,1,l",
"ab",
"123\nab\n789\n" },
141 {
"123\n456\n789\n",
"1,-1,l",
"ab",
"123\nab\n789\n" },
142 {
"123\n456\n789\n",
"-2,1,l",
"ab",
"123\nab\n789\n" },
143 {
"123\n456\n789\n",
"-2,-1,l",
"ab",
"123\nab\n789\n" },
145 {
"123\n456\n789\n",
"0,1,l",
"abcd",
"abcd\n456\n789\n" },
146 {
"123\n456\n789\n",
"-3,1,l",
"abcd",
"abcd\n456\n789\n" },
147 {
"123\n456\n789\n",
"0,-2,l",
"abcd",
"abcd\n456\n789\n" },
148 {
"123\n456\n789\n",
"-3,-2,l",
"abcd",
"abcd\n456\n789\n" },
149 {
"123\n456\n789\n",
"1,1,l",
"abcd",
"123\nabcd\n789\n" },
150 {
"123\n456\n789\n",
"1,-1,l",
"abcd",
"123\nabcd\n789\n" },
151 {
"123\n456\n789\n",
"-2,1,l",
"abcd",
"123\nabcd\n789\n" },
152 {
"123\n456\n789\n",
"-2,-1,l",
"abcd",
"123\nabcd\n789\n" },
154 {
"123\n456\n789\n",
"0,2,l",
"abcdefg",
"abcdefg\n789\n" },
155 {
"123\n456\n789\n",
"-3,2,l",
"abcdefg",
"abcdefg\n789\n" },
156 {
"123\n456\n789\n",
"0,-1,l",
"abcdefg",
"abcdefg\n789\n" },
157 {
"123\n456\n789\n",
"-3,-1,l",
"abcdefg",
"abcdefg\n789\n" },
158 {
"123\n456\n789\n",
"1,2,l",
"abcdefg",
"123\nabcdefg\n" },
159 {
"123\n456\n789\n",
"1,,l",
"abcdefg",
"123\nabcdefg\n" },
160 {
"123\n456\n789\n",
"-2,2,l",
"abcdefg",
"123\nabcdefg\n" },
161 {
"123\n456\n789\n",
"-2,,l",
"abcdefg",
"123\nabcdefg\n" },
163 {
"123\n456\n789\n",
"0,2,l",
"abcd",
"abcd\n789\n" },
164 {
"123\n456\n789\n",
"-3,2,l",
"abcd",
"abcd\n789\n" },
165 {
"123\n456\n789\n",
"0,-1,l",
"abcd",
"abcd\n789\n" },
166 {
"123\n456\n789\n",
"-3,-1,l",
"abcd",
"abcd\n789\n" },
167 {
"123\n456\n789\n",
"1,2,l",
"abcd",
"123\nabcd\n" },
168 {
"123\n456\n789\n",
"1,,l",
"abcd",
"123\nabcd\n" },
169 {
"123\n456\n789\n",
"-2,2,l",
"abcd",
"123\nabcd\n" },
170 {
"123\n456\n789\n",
"-2,,l",
"abcd",
"123\nabcd\n" },
172 {
"123\n456\n789\n",
"0,2,l",
"abcdefghijklmnop",
"abcdefghijklmnop\n789\n" },
173 {
"123\n456\n789\n",
"-3,2,l",
"abcdefghijklmnop",
"abcdefghijklmnop\n789\n" },
174 {
"123\n456\n789\n",
"0,-1,l",
"abcdefghijklmnop",
"abcdefghijklmnop\n789\n" },
175 {
"123\n456\n789\n",
"-3,-1,l",
"abcdefghijklmnop",
"abcdefghijklmnop\n789\n" },
176 {
"123\n456\n789\n",
"1,2,l",
"abcdefghijklmnop",
"123\nabcdefghijklmnop\n" },
177 {
"123\n456\n789\n",
"1,,l",
"abcdefghijklmnop",
"123\nabcdefghijklmnop\n" },
178 {
"123\n456\n789\n",
"-2,2,l",
"abcdefghijklmnop",
"123\nabcdefghijklmnop\n" },
179 {
"123\n456\n789\n",
"-2,,l",
"abcdefghijklmnop",
"123\nabcdefghijklmnop\n" },
181 {
"123\n456\n789\n",
"0,0,l",
"abcd",
"abcd\n123\n456\n789\n" },
182 {
"123\n456\n789\n",
"-3,0,l",
"abcd",
"abcd\n123\n456\n789\n" },
183 {
"123\n456\n789\n",
"1,0,l",
"abcd",
"123\nabcd\n456\n789\n" },
184 {
"123\n456\n789\n",
"-2,0,l",
"abcd",
"123\nabcd\n456\n789\n" },
185 {
"123\n456\n789\n",
"2,0,l",
"abcd",
"123\n456\nabcd\n789\n" },
186 {
"123\n456\n789\n",
"-1,0,l",
"abcd",
"123\n456\nabcd\n789\n" },
187 {
"123\n456\n789\n",
"3,0,l",
"abcd",
"123\n456\n789\nabcd\n" },
188 {
"123\n456\n789\n",
",,la",
"abcd",
"123\n456\n789\nabcd\n" },
190 {
"123\n456\n789\n",
"0,1,l",
"",
"\n456\n789\n" },
191 {
"123\n456\n789\n",
"-3,1,l",
"",
"\n456\n789\n" },
192 {
"123\n456\n789\n",
"0,-2,l",
"",
"\n456\n789\n" },
193 {
"123\n456\n789\n",
"-3,-2,l",
"",
"\n456\n789\n" },
194 {
"123\n456\n789\n",
"1,1,l",
"",
"123\n\n789\n" },
195 {
"123\n456\n789\n",
"1,-1,l",
"",
"123\n\n789\n" },
196 {
"123\n456\n789\n",
"-2,1,l",
"",
"123\n\n789\n" },
197 {
"123\n456\n789\n",
"-2,-1,l",
"",
"123\n\n789\n" },
199 {
"123\n456\n789\n",
"0,1,ld",
"",
"456\n789\n" },
200 {
"123\n456\n789\n",
"-3,1,ld",
"",
"456\n789\n" },
201 {
"123\n456\n789\n",
"0,-2,ld",
"",
"456\n789\n" },
202 {
"123\n456\n789\n",
"-3,-2,ld",
"",
"456\n789\n" },
203 {
"123\n456\n789\n",
"1,1,ld",
"",
"123\n789\n" },
204 {
"123\n456\n789\n",
"1,-1,ld",
"",
"123\n789\n" },
205 {
"123\n456\n789\n",
"-2,1,ld",
"",
"123\n789\n" },
206 {
"123\n456\n789\n",
"-2,-1,ld",
"",
"123\n789\n" },
232 for (ptr =
input; *ptr; ptr++) {
235 }
else if (*ptr ==
'\r') {
237 }
else if (*ptr ==
'\t') {
239 }
else if (*ptr < ' ' || *ptr > 125) {
252 char dir[] =
"/tmp/test_func_file.XXXXXX";
253 char file[80], expression[256];
260 info->name =
"func_file";
261 info->category =
"/funcs/func_env/";
262 info->summary =
"Verify behavior of the FILE() dialplan function";
264 "Verifies that the examples of the FILE() dialplan function documentation work as described.";
285 snprintf(
file,
sizeof(
file),
"%s/test.txt", dir);
288 if (!(fh = fopen(
file,
"w"))) {
324 if (!(fh = fopen(
file,
"w"))) {
348 if (!(fh = fopen(
file,
"r"))) {
357 memset(fbuf, 0,
sizeof(fbuf));
358 if (!fread(fbuf, 1,
sizeof(fbuf), fh)) {
static int input(yyscan_t yyscanner)
Asterisk main include file. File version handling, generic pbx functions.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
char * mkdtemp(char *template_s)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Support for dynamic strings.
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
static char * file2display(struct ast_str **buf, ssize_t len, const char *input)
static struct @498 read_tests[]
static int load_module(void)
static int unload_module(void)
AST_TEST_DEFINE(test_func_file)
static struct @499 write_tests[]