2
* Worldvisions Weaver Software:
3
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5
* WvDial configuration utility. Generates a basic wvdial.conf file.
7
#include "wvmodemscan.h"
13
void check_ppp_options()
15
WvFile file("/etc/ppp/options", O_RDONLY);
18
while ((line = file.getline(0)) != NULL)
20
line = trim_string(line);
22
// comments and blank lines are ignored
23
if (line[0] == '#' || !line[0])
26
// IP addresses are allowed
27
if (strchr(line, '.') || strchr(line, ':'))
30
// but baud rates and tty names are not!
31
// a 'connect' line is usually bad too.
33
|| !strncmp(line, "/dev", 4)
34
|| !strncmp(line, "tty", 3)
35
|| !strncmp(line, "cua", 3)
36
|| !strncmp(line, "connect", 7))
38
wvcon->print("\n*** WARNING! Line \"%s\"\n"
39
" in /etc/ppp/options may conflict with wvdial!\n\n", line);
45
int main(int argc, char **argv)
48
free(malloc(1)); // for electric fence
51
if (argc != 2 || argv[1][0]=='-')
53
wvcon->print("Usage: %s <configfile-name>\n"
54
"\t(create/update a wvdial.conf file automatically)\n",
59
wvcon->print("Scanning your serial ports for a modem.\n\n");
68
"Sorry, no modem was detected! "
69
"Is it in use by another program?\n"
70
"Did you configure it properly with setserial?\n\n"
72
"Please read the FAQ at http://open.nit.ca/wvdial/\n\n"
74
"If you still have problems, send mail to "
75
"wvdial-list@lists.nit.ca.\n");
79
WvModemScanList::Iter i(l);
83
WvString fn = m.filename(), init = m.initstr();
85
wvcon->print("\nFound %s on %s",
86
m.is_isdn() ? "an ISDN TA" :
87
strncmp("/dev/ttyACM",fn,11) ? "a modem" : "an USB modem", (const char *)fn);
88
if (m.use_modem_link) {
89
wvcon->print(", using link /dev/modem in config.\n");
94
WvConf cfg(argv[1],0660); // Create it read/write owner and group only
95
static char s[]="Dialer Defaults";
96
cfg.set(s, "Modem", fn);
97
cfg.setint(s, "Baud", m.maxbaud());
98
cfg.set(s, "Init1", m.is_isdn() ? "AT&F" : "ATZ");
99
cfg.set(s, "Init2", init);
100
cfg.set(s, "ISDN", m.use_default_asyncmap() ? "1" : "0");
101
cfg.set(s, "Modem Name", m.modem_name ? (const char *)m.modem_name : "");
102
cfg.set(s, "Modem Type", m.is_isdn() ? "ISDN Terminal Adapter" :
103
strncmp("/dev/ttyACM",fn,11) ? "Analog Modem" : "USB Modem");
106
wvcon->print("Config for %s written to %s.\n", (const char *)m.modem_name, argv[1]);
108
wvcon->print("Modem configuration written to %s.\n", argv[1]);
110
// insert some entries to let people know what they need to edit
111
if (!cfg.get(s, "Phone"))
112
cfg.set(s, "; Phone", "<Target Phone Number>");
113
if (!cfg.get(s, "Username"))
114
cfg.set(s, "; Username", "<Your Login Name>");
115
if (!cfg.get(s, "Password"))
116
cfg.set(s, "; Password", "<Your Password>");