|
From: SVN U. <dde...@li...> - 2007-02-17 02:46:22
|
Author: ddennedy
Date: 2007-02-16 18:24:16 -0800 (Fri, 16 Feb 2007)
New Revision: 170
Modified:
trunk/src/main.c
Log:
add support for RAW1394DEV environment variable to override default /dev/raw1394, but also attempt to failover to default.
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2007-02-14 05:29:18 UTC (rev 169)
+++ trunk/src/main.c 2007-02-17 02:24:16 UTC (rev 170)
@@ -115,6 +115,7 @@
struct raw1394_handle *raw1394_new_handle(void)
{
struct raw1394_handle *handle;
+ const char *defaultDevice = "/dev/raw1394";
handle = malloc(sizeof(struct raw1394_handle));
if (!handle) {
@@ -122,17 +123,31 @@
return NULL;
}
- handle->fd = open("/dev/raw1394", O_RDWR);
+ handle->fd = open(getenv("RAW1394DEV") ? getenv("RAW1394DEV"): defaultDevice, O_RDWR);
if (handle->fd < 0) {
- free(handle);
- return NULL;
+ /* failover to default in attempt to idiot proof */
+ handle->fd = open(defaultDevice, O_RDWR);
+ if (handle->fd < 0) {
+ free(handle);
+ return NULL;
+ }
}
handle->generation = init_rawdevice(handle);
if (handle->generation == -1) {
+ /* failover to default in attempt to idiot proof */
close(handle->fd);
- free(handle);
- return NULL;
+ handle->fd = open(defaultDevice, O_RDWR);
+ if (handle->fd < 0) {
+ free(handle);
+ return NULL;
+ }
+ handle->generation = init_rawdevice(handle);
+ if (handle->generation == -1) {
+ close(handle->fd);
+ free(handle);
+ return NULL;
+ }
}
handle->err = 0;
|