|
cvsextras |
a5b6cf2 |
--- bwbar.c.orig 2004-07-23 08:03:24.184266598 +0200
|
|
cvsextras |
a5b6cf2 |
+++ bwbar.c 2004-07-23 08:04:45.377702561 +0200
|
|
cvsextras |
a5b6cf2 |
@@ -147,6 +147,7 @@
|
|
cvsextras |
a5b6cf2 |
const struct option longopts[] = {
|
|
cvsextras |
a5b6cf2 |
{ "input", 0, 0, 'i' },
|
|
cvsextras |
a5b6cf2 |
{ "output", 0, 0, 'o' },
|
|
cvsextras |
a5b6cf2 |
+ { "directory", 1, 0, 'd' },
|
|
cvsextras |
a5b6cf2 |
{ "text-file", 1, 0, 'f' },
|
|
cvsextras |
a5b6cf2 |
{ "png-file", 1, 0, 'p' },
|
|
cvsextras |
a5b6cf2 |
{ "interval", 1, 0, 't' },
|
|
cvsextras |
a5b6cf2 |
@@ -170,6 +171,7 @@
|
|
cvsextras |
a5b6cf2 |
"Options: (defaults in parenthesis)\n"
|
|
cvsextras |
a5b6cf2 |
" --input -i Measure input bandwidth\n"
|
|
cvsextras |
a5b6cf2 |
" --output -o Measure output bandwidth (default)\n"
|
|
cvsextras |
a5b6cf2 |
+ " --directory -d Output directory\n"
|
|
cvsextras |
a5b6cf2 |
" --text-file <file> -f The name of the text output file (ubar.txt)\n"
|
|
cvsextras |
a5b6cf2 |
" --png-file <file> -p The name of the graphical bar file (ubar.png)\n"
|
|
cvsextras |
a5b6cf2 |
" --interval <seconds> -t The poll interval in seconds (15)\n"
|
|
cvsextras |
a5b6cf2 |
@@ -207,6 +209,8 @@
|
|
cvsextras |
a5b6cf2 |
int measure_input = 0; /* Input instead of output */
|
|
cvsextras |
a5b6cf2 |
char *text_file = "ubar.txt"; /* Text filename */
|
|
cvsextras |
a5b6cf2 |
char *graphics_file = "ubar.png"; /* Graphics filename */
|
|
cvsextras |
a5b6cf2 |
+ char *directory = ""; /* Directory name */
|
|
cvsextras |
a5b6cf2 |
+ char *tmp_char;
|
|
cvsextras |
a5b6cf2 |
char *unit_name = "Mbit/s"; /* Unit name */
|
|
cvsextras |
a5b6cf2 |
double unit = 1.0e+6; /* Unit multiplier */
|
|
cvsextras |
a5b6cf2 |
int interval = 15; /* Interval between measurements (s) */
|
|
cvsextras |
a5b6cf2 |
@@ -217,7 +221,7 @@
|
|
cvsextras |
a5b6cf2 |
|
|
cvsextras |
a5b6cf2 |
program = argv[0];
|
|
cvsextras |
a5b6cf2 |
|
|
cvsextras |
a5b6cf2 |
- while ( (opt = getopt_long(argc, argv, "iof:p:t:x:y:b:kMGhD", longopts, NULL)) != -1 ) {
|
|
cvsextras |
a5b6cf2 |
+ while ( (opt = getopt_long(argc, argv, "iof:p:t:x:y:b:kMGhDd:", longopts, NULL)) != -1 ) {
|
|
cvsextras |
a5b6cf2 |
switch ( opt ) {
|
|
cvsextras |
a5b6cf2 |
case 'i':
|
|
cvsextras |
a5b6cf2 |
measure_input = 1;
|
|
cvsextras |
a5b6cf2 |
@@ -231,6 +235,9 @@
|
|
cvsextras |
a5b6cf2 |
case 'p':
|
|
cvsextras |
a5b6cf2 |
graphics_file = optarg;
|
|
cvsextras |
a5b6cf2 |
break;
|
|
cvsextras |
a5b6cf2 |
+ case 'd':
|
|
cvsextras |
a5b6cf2 |
+ directory = optarg;
|
|
cvsextras |
a5b6cf2 |
+ break;
|
|
cvsextras |
a5b6cf2 |
case 't':
|
|
cvsextras |
a5b6cf2 |
interval = atoi(optarg);
|
|
cvsextras |
a5b6cf2 |
break;
|
|
cvsextras |
a5b6cf2 |
@@ -270,6 +277,18 @@
|
|
cvsextras |
a5b6cf2 |
if ( argc-optind != 2 )
|
|
cvsextras |
a5b6cf2 |
usage(1);
|
|
cvsextras |
a5b6cf2 |
|
|
cvsextras |
a5b6cf2 |
+ tmp_char = text_file;
|
|
cvsextras |
a5b6cf2 |
+ text_file = malloc(strlen(text_file) + strlen(directory) + 5);
|
|
cvsextras |
a5b6cf2 |
+ strcpy(text_file, directory);
|
|
cvsextras |
a5b6cf2 |
+ strcat(text_file, "/");
|
|
cvsextras |
a5b6cf2 |
+ strcat(text_file, tmp_char);
|
|
cvsextras |
a5b6cf2 |
+
|
|
cvsextras |
a5b6cf2 |
+ tmp_char = graphics_file;
|
|
cvsextras |
a5b6cf2 |
+ graphics_file = malloc(strlen(graphics_file) + strlen(directory) + 5);
|
|
cvsextras |
a5b6cf2 |
+ strcpy(graphics_file, directory);
|
|
cvsextras |
a5b6cf2 |
+ strcat(graphics_file, "/");
|
|
cvsextras |
a5b6cf2 |
+ strcat(graphics_file, tmp_char);
|
|
cvsextras |
a5b6cf2 |
+
|
|
cvsextras |
a5b6cf2 |
t_tmp = malloc(strlen(text_file) + 5);
|
|
cvsextras |
a5b6cf2 |
g_tmp = malloc(strlen(graphics_file) + 5);
|
|
cvsextras |
a5b6cf2 |
if ( !t_tmp || !g_tmp ) {
|