23 """
24 Parse command line options and apply them. If invalid input is given,
25 print usage information
26
27 """
28 global user
29 global password
30 global host
31 global port
32 global database
33 global table
34
35 usage = "usage: %prog [options] [input-file [output-file]]\n\n" \
36 "Converts the chan_sip configuration input-file to mysql output-file.\n" \
37 "The input-file defaults to 'sip.conf'.\n" \
38 "The output-file defaults to 'pjsip.sql'."
39 parser = optparse.OptionParser(usage=usage)
40 parser.add_option('-u', '--user', dest='user', default="root",
41 help='mysql username')
42 parser.add_option('-p', '--password', dest='password', default="root",
43 help='mysql password')
44 parser.add_option('-H', '--host', dest='host', default="127.0.0.1",
45 help='mysql host ip')
46 parser.add_option('-P', '--port', dest='port', default="3306",
47 help='mysql port number')
48 parser.add_option('-D', '--database', dest='database', default="asterisk",
49 help='mysql port number')
50 parser.add_option('-t', '--table', dest='table', default="sippeers",
51 help='name of sip realtime peers table')
52
53 options, args = parser.parse_args()
54
55 user = options.user
56 password = options.password
57 host = options.host
58 port = options.port
59 database = options.database
60 table = options.table
61
62 sip_filename = args[0]
if len(args)
else 'sip.conf'
63 pjsip_filename = args[1]
if len(args) == 2
else 'pjsip.sql'
64
65 return sip_filename, pjsip_filename
66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct ast_cli_entry cli_options[]