Johannes Stezenbach wrote:


+static void show_existing_tuning_data_files(void)
+{
+#ifndef PREFIX
+#define PREFIX "/usr/local"
+#endif
+ static const char* prefixlist[] = { PREFIX"/share/dvb", + "/usr/share/dvb", "/etc/dvb", + "/usr/share/doc/packages/dvb", 0 };


Hm, I don't like that.

The correct way to do it would be to have a configure script,
and have the executable look in the configured location.

But I don't like that either :-(

Sigh...


And here is an updated `showconfigs` patch, picking up DATADIR defs as described earlier. Still it checks in multiple paths.

cheers,
-- guido                                  http://google.de/search?q=guidod
GCS/E/S/P C++/++++$ ULHS L++w- N++@ s+:a d(+-) r+@>+++ y++ 5++X- (geekcode)
Index: util/scan/scan.c
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/scan/scan.c,v
retrieving revision 1.7
diff -u -r1.7 scan.c
--- util/scan/scan.c    15 Feb 2004 00:46:10 -0000      1.7
+++ util/scan/scan.c    15 Feb 2004 07:39:40 -0000
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <assert.h>
+#include <glob.h>
 
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/dmx.h>
@@ -1714,6 +1715,29 @@
        info("Done.\n");
 }
 
+static void show_existing_tuning_data_files(void)
+{
+#ifndef DATADIR
+#define DATADIR "/usr/local/share"
+#endif
+       static const char* prefixlist[] = { DATADIR "/dvb", "/etc/dvb", 
+                                           DATADIR "/doc/packages/dvb", 0 };
+       int i;
+       const char **prefix;
+       fprintf(stderr, "initial tuning data files:\n");
+       for (prefix = prefixlist; *prefix; prefix++) {
+               glob_t globbuf = {0};
+               char* globspec = malloc (strlen(*prefix)+9);
+               strcpy (globspec, *prefix); strcat (globspec, "/dvb-?/*");
+               if (! glob (globspec, 0, 0, &globbuf)) {
+                       for (i=0; i < globbuf.gl_pathc; i++) 
+                               fprintf(stderr, " file: %s\n", globbuf.gl_pathv[i]);
+               }
+               free (globspec);
+               globfree (&globbuf);
+       }
+}
+
 static void handle_sigint(int sig)
 {
        error("interrupted by SIGINT, dumping partial result...\n");
@@ -1750,17 +1774,21 @@
        "       -u      UK DVB-T Freeview channel numbering for VDR\n";
 
 void
-bad_usage(char *pname, int prlnb)
+bad_usage(char *pname, int problem)
 {
-int i;
-struct lnb_types_st *lnbp;
-char **cp;
+       int i;
+       struct lnb_types_st *lnbp;
+       char **cp;
 
-       if (!prlnb) {
+       switch (problem) {
+       default:
+       case 0:
                fprintf (stderr, usage, pname);
-       } else {
+               break;
+       case 1:
                i = 0;
-               fprintf(stderr, "-l <lnb-type> or -l low[,high[,switch]] in Mhz\nwhere 
<lnb-type> is:\n");
+               fprintf(stderr, "-l <lnb-type> or -l low[,high[,switch]] in Mhz\n"
+                       "where <lnb-type> is:\n");
                while(NULL != (lnbp = lnb_enum(i))) {
                        fprintf (stderr, "%s\n", lnbp->name);
                        for (cp = lnbp->desc; *cp ; cp++) {
@@ -1768,6 +1796,10 @@
                        }
                        i++;
                }
+               break;
+       case 2:
+               show_existing_tuning_data_files();
+               fprintf (stderr, usage, pname);
        }
 }
 
@@ -1780,6 +1812,11 @@
        int fe_open_mode;
        const char *initial = NULL;
 
+       if (argc <= 1) {
+           bad_usage(argv[0], 2);
+           return -1;
+       }
+
        /* start with default lnb type */
        lnb_type = *lnb_enum(0);
        while ((opt = getopt(argc, argv, "5cnpa:f:d:s:o:x:e:t:i:l:vqu")) != -1) {

Reply via email to