From a38d4e5bfc3b477f08b67ba25e6668802724a929 Mon Sep 17 00:00:00 2001 From: stan Date: Wed, 11 Aug 2004 15:18:01 +0000 Subject: [PATCH] Now also fixes serial ports. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1082 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/Makefile.am | 2 +- src/Makefile.in | 6 +++--- src/zmfix.cpp | 29 ++++++++++++++++++++++------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index b71cd81ef..07c7234ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,7 +41,7 @@ zma_SOURCES = zma.cpp $(zm_SOURCES) zms_SOURCES = zms.cpp $(zm_SOURCES) zmu_SOURCES = zmu.cpp $(zm_SOURCES) zmf_SOURCES = zmf.cpp $(zm_SOURCES) -zmfix_SOURCES = zmfix.cpp zm_debug.c zm_db.cpp zm.cpp +zmfix_SOURCES = zmfix.cpp zm_config.cpp zm_debug.c zm_db.cpp zm.cpp noinst_HEADERS = \ zm.h \ diff --git a/src/Makefile.in b/src/Makefile.in index 85dc68e19..90edc5658 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -167,7 +167,7 @@ zma_SOURCES = zma.cpp $(zm_SOURCES) zms_SOURCES = zms.cpp $(zm_SOURCES) zmu_SOURCES = zmu.cpp $(zm_SOURCES) zmf_SOURCES = zmf.cpp $(zm_SOURCES) -zmfix_SOURCES = zmfix.cpp zm_debug.c zm_db.cpp zm.cpp +zmfix_SOURCES = zmfix.cpp zm_config.cpp zm_debug.c zm_db.cpp zm.cpp noinst_HEADERS = \ zm.h \ @@ -225,8 +225,8 @@ zmf_OBJECTS = $(am_zmf_OBJECTS) zmf_LDADD = $(LDADD) zmf_DEPENDENCIES = zmf_LDFLAGS = -am_zmfix_OBJECTS = zmfix.$(OBJEXT) zm_debug.$(OBJEXT) zm_db.$(OBJEXT) \ - zm.$(OBJEXT) +am_zmfix_OBJECTS = zmfix.$(OBJEXT) zm_config.$(OBJEXT) \ + zm_debug.$(OBJEXT) zm_db.$(OBJEXT) zm.$(OBJEXT) zmfix_OBJECTS = $(am_zmfix_OBJECTS) zmfix_LDADD = $(LDADD) zmfix_DEPENDENCIES = diff --git a/src/zmfix.cpp b/src/zmfix.cpp index 2ae0b7182..305b30123 100644 --- a/src/zmfix.cpp +++ b/src/zmfix.cpp @@ -31,12 +31,8 @@ #include "zm.h" #include "zm_db.h" -bool fixDevice( int device ) +bool fixDevice( const char *device_path ) { - char device_path[64]; - - snprintf( device_path, sizeof(device_path), "/dev/video%d", device ); - struct stat stat_buf; if ( stat( device_path, &stat_buf ) < 0 ) @@ -82,6 +78,15 @@ bool fixDevice( int device ) return( true ); } +bool fixVideoDevice( int device ) +{ + char device_path[64]; + + snprintf( device_path, sizeof(device_path), "/dev/video%d", device ); + + return( fixDevice( device_path ) ); +} + int main( int argc, char *argv[] ) { char dbg_name_string[16] = "zmfix"; @@ -94,7 +99,7 @@ int main( int argc, char *argv[] ) // Do all devices we can find for ( int device = 0; device < 256; device++ ) { - if ( !fixDevice( device ) ) + if ( !fixVideoDevice( device ) ) { break; } @@ -124,7 +129,7 @@ int main( int argc, char *argv[] ) for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) { int device = atoi(dbrow[0]); - fixDevice( device ); + fixVideoDevice( device ); } if ( mysql_errno( &dbconn ) ) @@ -134,6 +139,16 @@ int main( int argc, char *argv[] ) } // Yadda yadda mysql_free_result( result ); + + if ( (bool)config.Item( ZM_OPT_X10 ) ) + { + const char *x10_port = (const char *)config.Item( ZM_X10_DEVICE ); + + if ( x10_port ) + { + fixDevice( x10_port ); + } + } } return( 0 ); }