wmppp.app: Add new command line options.
We add command line options for the user to change the start, stop, speed, ifdown, and stampfile settings at runtime. This closes a Debian wishlist bug [1]. Note that, in order to have the command line options overwrite the defaults set in the configuration file, we split the command line parsing code into a new function (parse_cmdline()). We then merged main() and wmppp_routine(). We document the new options in the help text and in the man page. We also take the opportunity to reformat the help text for the -i option and add the -geometry option to the man page. [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=293839
This commit is contained in:
parent
540b8ac560
commit
2b0feb59f8
|
@ -5,16 +5,7 @@
|
|||
wmppp \- Graphically monitor the average PPP load
|
||||
.P
|
||||
.SH SYNOPSIS
|
||||
.B wmppp
|
||||
.RB [\| \-display
|
||||
.IR <display\ name> \|]
|
||||
.RB [\| \-t \|]
|
||||
.RB [\| \-u
|
||||
.IR <update\ rate> \|]
|
||||
.RB [\| \-i
|
||||
.IR <device> \|]
|
||||
.RB [\| \-h \|]
|
||||
.RB [\| \-v \|]
|
||||
.B wmppp [OPTIONS]
|
||||
.SH DESCRIPTION
|
||||
\fBwmppp.app\fP displays a dynamic representation of the load on the
|
||||
PPP line on a 64x64 miniwindow. It also starts and stops the
|
||||
|
@ -25,6 +16,9 @@ traffic on the interface is also monitored.
|
|||
.B \-display <display\ name>
|
||||
name of display to use
|
||||
.TP
|
||||
.B \-geometry +XPOS+YPOS
|
||||
initial window position
|
||||
.TP
|
||||
.B \-t
|
||||
sets the on-line timer to display MM:SS instead of the default HH:MM.
|
||||
.TP
|
||||
|
@ -37,6 +31,21 @@ choose the net device (ppp1, ippp0, etc.) to monitor. (Note that this
|
|||
feature is EXPERIMENTAL and should be used with caution. Bug reports
|
||||
are welcomed.)
|
||||
.TP
|
||||
.B \-speed <cmd>
|
||||
command to report connection speed
|
||||
.TP
|
||||
.B \-start <cmd>
|
||||
command to connect
|
||||
.TP
|
||||
.B \-stop <cmd>
|
||||
command to disconnect
|
||||
.TP
|
||||
.B \-ifdown <cmd>
|
||||
command to redial
|
||||
.TP
|
||||
.B \-stampfile <path>
|
||||
file used to calculate uptime
|
||||
.TP
|
||||
.B \-h
|
||||
displays a command line summary
|
||||
.TP
|
||||
|
@ -44,7 +53,8 @@ displays a command line summary
|
|||
displays the version number.
|
||||
.SH CONFIGURATION
|
||||
The configuration file (see below) may contain any of the following
|
||||
key-value pairs. The format is \fIkey: value\fP.
|
||||
key-value pairs. The format is \fIkey: value\fP. Note that these values will be
|
||||
overwritten by the corresponding command line options.
|
||||
.TP
|
||||
.I start
|
||||
The program that starts the connection
|
||||
|
|
|
@ -258,24 +258,24 @@ void SetOffLED(int);
|
|||
void ButtonUp(int);
|
||||
void ButtonDown(int);
|
||||
|
||||
void wmppp_routine(int, char **);
|
||||
|
||||
int get_statistics(long *, long *, long *, long *);
|
||||
void get_ppp_stats(struct ppp_stats *cur);
|
||||
int stillonline(char *);
|
||||
|
||||
char *start_action = NULL;
|
||||
char *stop_action = NULL;
|
||||
char *speed_action = NULL;
|
||||
char *ifdown_action = NULL;
|
||||
char *stamp_file = NULL;
|
||||
|
||||
/********/
|
||||
/* Main */
|
||||
/********/
|
||||
/**********************/
|
||||
/* Parse Command Line */
|
||||
/**********************/
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int parse_cmdline(int argc, char *argv[]) {
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
/* Parse Command Line */
|
||||
|
||||
ProgName = argv[0];
|
||||
if (strlen(ProgName) >= 5)
|
||||
ProgName += (strlen(ProgName) - 5);
|
||||
|
@ -298,21 +298,28 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
break;
|
||||
case 'i' :
|
||||
if (!argv[i+1]) {
|
||||
if (!strcmp(arg+1, "i"))
|
||||
active_interface = argv[++i];
|
||||
else if (!strcmp(arg+1, "ifdown"))
|
||||
ifdown_action = argv[++i];
|
||||
else {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
/* following removed to allow experiments with
|
||||
* new devices, i.e. ippp
|
||||
*/
|
||||
#if 0
|
||||
if (strncmp(argv[i+1], "ppp", 3)) {
|
||||
break;
|
||||
case 's' :
|
||||
if (!strcmp(arg+1, "speed"))
|
||||
speed_action = argv[++i];
|
||||
else if (!strcmp(arg+1, "start"))
|
||||
start_action = argv[++i];
|
||||
else if (!strcmp(arg+1, "stop"))
|
||||
stop_action = argv[++i];
|
||||
else if (!strcmp(arg+1, "stampfile"))
|
||||
stamp_file = argv[++i];
|
||||
else {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
active_interface = argv[i+1];
|
||||
i++;
|
||||
break;
|
||||
case 't' :
|
||||
TimerDivisor = 1;
|
||||
|
@ -341,22 +348,14 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
wmppp_routine(argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************/
|
||||
/* wmppp_routine */
|
||||
/*****************/
|
||||
/********/
|
||||
/* Main */
|
||||
/********/
|
||||
|
||||
char *start_action = NULL;
|
||||
char *stop_action = NULL;
|
||||
char *speed_action = NULL;
|
||||
char *ifdown_action = NULL;
|
||||
char *stamp_file = NULL;
|
||||
|
||||
void wmppp_routine(int argc, char **argv) {
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
rckeys wmppp_keys[] = {
|
||||
{ "start", &start_action },
|
||||
|
@ -434,6 +433,8 @@ void wmppp_routine(int argc, char **argv) {
|
|||
strcpy(temp, "/etc/wmppprc.fixed");
|
||||
parse_rcfile(temp, wmppp_keys);
|
||||
|
||||
parse_cmdline(argc, argv);
|
||||
|
||||
/* Open the display */
|
||||
|
||||
createXBMfromXPM(wmppp_mask_bits, wmppp_master_xpm, wmppp_mask_width, wmppp_mask_height);
|
||||
|
@ -664,6 +665,7 @@ void wmppp_routine(int argc, char **argv) {
|
|||
ts.tv_nsec = 50000000L;
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************\
|
||||
|
@ -881,9 +883,15 @@ void usage(void) {
|
|||
fprintf(stderr, "-display <display name>\n");
|
||||
fprintf(stderr, "-geometry +XPOS+YPOS initial window position\n");
|
||||
fprintf(stderr, "-h this help screen\n");
|
||||
fprintf(stderr, "-i <device> (ppp0, ppp1, etc) EXPERIMENTAL! Please send bugreports!\n");
|
||||
fprintf(stderr, "-i <device> (ppp0, ppp1, etc) EXPERIMENTAL! Please send\n");
|
||||
fprintf(stderr, " bugreports!\n");
|
||||
fprintf(stderr, "-t set the on-line timer to MM:SS instead of HH:MM\n");
|
||||
fprintf(stderr, "-u <update rate> (1..10), default 5 seconds\n");
|
||||
fprintf(stderr, "-speed <cmd> command to report connection speed\n");
|
||||
fprintf(stderr, "-start <cmd> command to connect\n");
|
||||
fprintf(stderr, "-stop <cmd> command to disconnect\n");
|
||||
fprintf(stderr, "-ifdown <cmd> command to redial\n");
|
||||
fprintf(stderr, "-stampfile <path> file used to calculate uptime\n");
|
||||
fprintf(stderr, "-v print the version number\n");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue