1 /* $Id$ */
2 /* Copyright (c) 2014-2015 Pierre Pronchery <khorben@defora.org> */
3 /* This file is part of DeforaOS Desktop Phone */
4 /* This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>. */
15 
16 
17 
18 #include "../src/modems/hayes/channel.c"
19 #include "../src/modems/hayes/command.c"
20 #include "../src/modems/hayes/common.c"
21 #include "../src/modems/hayes/pdu.c"
22 #include "../src/modems/hayes/quirks.c"
23 #include "../src/modems/hayes.c"
24 
25 
26 /* private */
27 /* prototypes */
28 static int _ussd(void);
29 
30 
31 /* functions */
32 /* ussd */
_ussd(void)33 static int _ussd(void)
34 {
35 	int ret = 0;
36 	const char * codes[] = { "*100#", "*109*72348937857623#" };
37 	const char * notcodes[] = { "*#06#0" };
38 	size_t i;
39 
40 	for(i = 0; i < sizeof(codes) / sizeof(*codes); i++)
41 		if(!_is_ussd_code(codes[i]))
42 		{
43 			printf("%s: %s: %s\n", "ussd", codes[i],
44 					"Is a valid USSD code");
45 			ret = 2;
46 		}
47 	for(i = 0; i < sizeof(notcodes) / sizeof(*notcodes); i++)
48 		if(_is_ussd_code(notcodes[i]))
49 		{
50 			printf("%s: %s: %s\n", "ussd", notcodes[i],
51 					"Is not a valid USSD code");
52 			ret = 2;
53 		}
54 	return ret;
55 }
56 
57 
58 /* public */
59 /* functions */
60 /* main */
main(void)61 int main(void)
62 {
63 	return (_ussd() == 0) ? 0 : 2;
64 }
65