Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] linuxtv-dvb-apps per-adapter channel.conf
Up to now I am using wrapper scripts to set -c /abs/path/to/channel.conf
for secondary adapter(s). Since I am there patching dvb-apps, here are
some patches that will make the channel switchters to look into
per-adapter subdirectories first - i.e.
$ dvb_szap -a 1 pro7
reading channels from file '/home/guidod/.szap/1/channels.conf'
zapping to 57 'Pro7':
sat 0, frequency = 12480 MHz V, symbolrate 27500000, vpid = 0x00ff, apid = 0x0100
using '/dev/dvb/adapter1/frontend0' and '/dev/dvb/adapter1/demux0'
and note the .szap/*1*/c.f - actually rather simple stuff but at the
same time it fixes some possible buffer overruns from strcats around
by using singlecall snprintf everywhere.
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)
--- util/szap/czap.c.orig 2004-01-17 17:59:46.000000000 +0100
+++ util/szap/czap.c 2004-02-13 23:38:45.000000000 +0100
@@ -17,7 +17,7 @@
static char FRONTEND_DEV [80];
static char DEMUX_DEV [80];
-#define CHANNEL_FILE "/.czap/channels.conf"
+#define CHANNEL_FILE "channels.conf"
#define ERROR(x...) \
do { \
@@ -319,12 +319,15 @@
if (!confname)
{
+ int len = strlen(homedir) + strlen(CHANNEL_FILE) + 18;
if (!homedir)
ERROR("$HOME not set");
- confname = malloc(strlen(homedir) + strlen(CHANNEL_FILE) + 1);
- memcpy(confname, homedir, strlen(homedir));
- memcpy(confname + strlen(homedir), CHANNEL_FILE,
- strlen(CHANNEL_FILE) + 1);
+ confname = malloc(len);
+ if (1) snprintf(confname, len, "%s/.czap/%i/%s",
+ homedir, adapter, CHANNEL_FILE);
+ if (access(confname, R_OK))
+ snprintf(confname, len, "%s/.czap/%s",
+ homedir, CHANNEL_FILE);
}
memset(&frontend_param, 0, sizeof(struct dvb_frontend_parameters));
--- util/szap/szap.c.orig 2004-01-17 17:59:46.000000000 +0100
+++ util/szap/szap.c 2004-02-13 23:36:47.000000000 +0100
@@ -545,8 +545,11 @@
fprintf(stderr, "error: $HOME not set\n");
return TRUE;
}
- strncpy(chanfile, home, sizeof(chanfile));
- strcat(chanfile, "/.szap/" CHANNEL_FILE);
+ if (1) snprintf(chanfile, sizeof(chanfile),
+ "%s/.szap/%i/%s", home, adapter, CHANNEL_FILE);
+ if (access(chanfile, R_OK))
+ snprintf(chanfile, sizeof(chanfile),
+ "%s/.szap/%s", home, CHANNEL_FILE);
}
printf("reading channels from file '%s'\n", chanfile);
--- util/szap/tzap.c.orig 2004-01-17 17:59:46.000000000 +0100
+++ util/szap/tzap.c 2004-02-13 23:39:30.000000000 +0100
@@ -17,7 +17,7 @@
static char FRONTEND_DEV [80];
static char DEMUX_DEV [80];
-#define CHANNEL_FILE "/.tzap/channels.conf"
+#define CHANNEL_FILE "channels.conf"
#define ERROR(x...) \
do { \
@@ -428,12 +428,15 @@
if (!confname)
{
+ int len = strlen(homedir) + strlen(CHANNEL_FILE) + 18;
if (!homedir)
ERROR ("$HOME not set");
- confname = malloc (strlen(homedir) + strlen(CHANNEL_FILE) + 1);
- memcpy (confname, homedir, strlen(homedir));
- memcpy (confname + strlen(homedir), CHANNEL_FILE,
- strlen(CHANNEL_FILE) + 1);
+ confname = malloc (len);
+ if (1) snprintf (confname, len, "%s/.tzap/%i/%s",
+ homedir, adapter, CHANNEL_FILE);
+ if (access (confname, R_OK))
+ snprintf (confname, len, "%s/.tzap/%s",
+ homedir, CHANNEL_FILE);
}
memset(&frontend_param, 0, sizeof(struct dvb_frontend_parameters));
Home |
Main Index |
Thread Index