--- szap.c.orig	2003-06-06 12:59:22.000000000 +0200
+++ szap.c	2003-06-06 12:43:45.000000000 +0200
@@ -71,6 +71,7 @@
 #define LOF_HI 10600000
 #define LOF_LO 9750000
 
+int do_monitoring = 0;
 
 static char *usage_str =
     "\nusage: szap -l\n"
@@ -80,7 +81,9 @@
     "     -a number : use given adapter (default 0)\n"
     "     -f number : use given frontend (default 0)\n"
     "     -d number : use given demux (default 0)\n"
-    "     -r        : set up /dev/dvb/adapterX/dvr0 for TS recording\n\n";
+    "     -r        : set up /dev/dvb/adapterX/dvr0 for TS recording\n"
+    "     -c file   : read channels list from 'file'\n"
+    "     -m        : monitoring parameters (SNR, BER, etc.)\n\n";
 
 
 static void usage(void)
@@ -209,7 +212,7 @@
 
       printf("\n");
       usleep(1000000);
-   } while (1);
+   } while (do_monitoring);
 
    return 0;
 }
@@ -399,8 +402,8 @@
    const char *chan_name = NULL;
    unsigned int adapter = 0, frontend = 0, demux = 0, dvr = 0;
    int opt;
-
-   while ((opt = getopt(argc, argv, "hlrn:a:f:d:")) != -1) {
+   
+   while ((opt = getopt(argc, argv, "hlrmn:a:f:d:c:")) != -1) {
       switch (opt)
       {
 	 case '?':
@@ -424,6 +427,12 @@
 	    break;
 	 case 'd':
 	    demux = strtoul(optarg, NULL, 0);
+	    break;
+	 case 'c':
+	    strncpy(chanfile, optarg, sizeof(chanfile));
+	    break;
+	 case 'm':
+	    do_monitoring = 1;
       }
    }
    if (optind < argc)
@@ -435,13 +444,16 @@
    if (!list_channels && !chan_name && !chan_no)
       usage();
 
-   if (!(home = getenv("HOME"))) {
-      fprintf(stderr, "error: $HOME not set\n");
-      return TRUE;
+   if (open(chanfile, O_RDONLY) < 0) {
+      if (!(home = getenv("HOME"))) {
+         fprintf(stderr, "error: $HOME not set\n");
+         return TRUE;
+      }
+      strncpy(chanfile, home, sizeof(chanfile));
+      strcat(chanfile, "/.szap/" CHANNEL_FILE);
    }
-
-   strncpy(chanfile, home, sizeof(chanfile));
-   strcat(chanfile, "/.szap/" CHANNEL_FILE);
+   
+   printf("reading channels from file '%s'\n", chanfile);
 
    if (!read_channels(chanfile, list_channels, chan_no, chan_name,
 	    adapter, frontend, demux, dvr))
