[Redbutton-devel] SF.net SVN: redbutton: [296]
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-04-27 09:38:35
|
Revision: 296
http://svn.sourceforge.net/redbutton/?rev=296&view=rev
Author: skilvington
Date: 2007-04-27 02:38:23 -0700 (Fri, 27 Apr 2007)
Log Message:
-----------
search for channels.conf is ~/.tzap/, ~/.szap/, etc depending on card type
Modified Paths:
--------------
redbutton-download/trunk/channels.c
redbutton-download/trunk/channels.h
redbutton-download/trunk/rb-download.c
www/index.html
Modified: redbutton-download/trunk/channels.c
===================================================================
--- redbutton-download/trunk/channels.c 2007-04-26 14:37:47 UTC (rev 295)
+++ redbutton-download/trunk/channels.c 2007-04-27 09:38:23 UTC (rev 296)
@@ -42,16 +42,79 @@
static bool get_dvbc_tune_params(uint16_t, struct dvb_frontend_parameters *);
static bool get_atsc_tune_params(uint16_t, struct dvb_frontend_parameters *);
+/*
+ * returns "tzap" if the given DVB adapter is DVB-T,
+ * "szap" if it is DVB-S
+ * "czap" if it is DVB-C
+ * or "azap" if it is ATSC
+ * (may have been better to call one of these to retune rather than doing it ourselves?)
+ */
+
+char *
+zap_name(unsigned int adapter)
+{
+ char fe_dev[PATH_MAX];
+ int fe_fd;
+ struct dvb_frontend_info fe_info;
+ bool got_info;
+
+ /* see what type of DVB device the adapter is */
+ snprintf(fe_dev, sizeof(fe_dev), FE_DEVICE, adapter);
+
+ if((fe_fd = open(fe_dev, O_RDONLY | O_NONBLOCK)) < 0)
+ fatal("open '%s': %s", fe_dev, strerror(errno));
+
+ vverbose("Getting frontend info");
+
+ do
+ {
+ /* maybe interrupted by a signal */
+ got_info = (ioctl(fe_fd, FE_GET_INFO, &fe_info) >= 0);
+ if(!got_info && errno != EINTR)
+ fatal("ioctl FE_GET_INFO: %s", strerror(errno));
+ }
+ while(!got_info);
+
+ close(fe_fd);
+
+ if(fe_info.type == FE_OFDM)
+ {
+ vverbose("Adapter %u is a '%s' DVB-T card", adapter, fe_info.name);
+ return "tzap";
+ }
+ else if(fe_info.type == FE_QPSK)
+ {
+ vverbose("Adapter %u is a '%s' DVB-S card", adapter, fe_info.name);
+ return "szap";
+ }
+ else if(fe_info.type == FE_QAM)
+ {
+ vverbose("Adapter %u is a '%s' DVB-C card", adapter, fe_info.name);
+ return "czap";
+ }
+ else if(fe_info.type == FE_ATSC)
+ {
+ vverbose("Adapter %u is a '%s' ATSC card", adapter, fe_info.name);
+ return "azap";
+ }
+ else
+ {
+ vverbose("Adapter %u (%s); unknown card type %d", adapter, fe_info.name, fe_info.type);
+ return "";
+ }
+}
+
static FILE *_channels = NULL;
/*
* if filename is NULL, it searches for:
- * ~/.tzap/channels.conf
+ * ~/.<zap_name>/channels.conf
* /etc/channels.conf
+ * zap_name should be tzap for DVB-T, szap for DVB-S, czap for DVB-C or azap for ATSC cards
*/
bool
-init_channels_conf(char *filename)
+init_channels_conf(char *zap_name, char *filename)
{
char *home;
char pathname[PATH_MAX];
@@ -63,7 +126,7 @@
{
if((home = getenv("HOME")) != NULL)
{
- snprintf(pathname, sizeof(pathname), "%s/.tzap/channels.conf", home);
+ snprintf(pathname, sizeof(pathname), "%s/.%s/channels.conf", home, zap_name);
verbose("Trying to open %s", pathname);
_channels = fopen(pathname, "r");
}
Modified: redbutton-download/trunk/channels.h
===================================================================
--- redbutton-download/trunk/channels.h 2007-04-26 14:37:47 UTC (rev 295)
+++ redbutton-download/trunk/channels.h 2007-04-27 09:38:23 UTC (rev 296)
@@ -26,8 +26,10 @@
#include <stdint.h>
#include <stdbool.h>
-bool init_channels_conf(char *);
+char *zap_name(unsigned int);
+bool init_channels_conf(char *, char *);
+
bool tune_service_id(unsigned int, unsigned int, uint16_t);
#endif /* __CHANNELS_H__ */
Modified: redbutton-download/trunk/rb-download.c
===================================================================
--- redbutton-download/trunk/rb-download.c 2007-04-26 14:37:47 UTC (rev 295)
+++ redbutton-download/trunk/rb-download.c 2007-04-27 09:38:23 UTC (rev 296)
@@ -20,7 +20,7 @@
* if not specified with -f, rb-download will search for:
* ~/.tzap/channels.conf
* /etc/channels.conf
- *
+ *
* rb-download listens on the network for commands from a remote rb-browser
* the default IP to listen on is 0.0.0.0 (ie all interfaces), the default TCP port is 10101
* the -l option changes the default IP and port
@@ -148,7 +148,7 @@
}
/* initialise channels.conf */
- if(!init_channels_conf(channels_file))
+ if(!init_channels_conf(zap_name(adapter), channels_file))
error("Unable to open channels.conf file");
/* do we need to change the base directory */
Modified: www/index.html
===================================================================
--- www/index.html 2007-04-26 14:37:47 UTC (rev 295)
+++ www/index.html 2007-04-27 09:38:23 UTC (rev 296)
@@ -54,11 +54,12 @@
<PRE>
scan ./uk-Malvern > ~/.tzap/channels.conf
</PRE>
-If not specified with -f, rb-download will search for:
+If not specified with -f, rb-download will search for (in the case of DVB-T cards):
<UL>
<LI>~/.tzap/channels.conf</LI>
<LI>/etc/channels.conf</LI>
</UL>
+For DVB-S cards it will look in ~/.szap/, for DVB-C cards it will look in ~/.czap/ and for ATSC cards it will look in the ~/.azap/ directory.
<P>
rb-download listens on the network for commands from a remote rb-browser.
The default IP to listen on is 0.0.0.0 (ie all interfaces), the default TCP port is 10101.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|