Merge pull request #816 from onlyjob/PBP
more perlcritic/PBP corrections
This commit is contained in:
commit
3261d974f7
|
@ -72,8 +72,9 @@ BEGIN
|
|||
print( STDERR "Warning, overriding installed $local_config_file file with local copy\n" );
|
||||
$config_file = $local_config_file;
|
||||
}
|
||||
open( CONFIG, "<".$config_file ) or croak( "Can't open config file '$config_file': $!" );
|
||||
foreach my $str ( <CONFIG> )
|
||||
open( my $CONFIG, "<", $config_file )
|
||||
or croak( "Can't open config file '$config_file': $!" );
|
||||
foreach my $str ( <$CONFIG> )
|
||||
{
|
||||
next if ( $str =~ /^\s*$/ );
|
||||
next if ( $str =~ /^\s*#/ );
|
||||
|
@ -85,7 +86,7 @@ BEGIN
|
|||
$name =~ tr/a-z/A-Z/;
|
||||
$Config{$name} = $value;
|
||||
}
|
||||
close( CONFIG );
|
||||
close( $CONFIG );
|
||||
|
||||
use DBI;
|
||||
my $dbh = DBI->connect( "DBI:mysql:database=".$Config{ZM_DB_NAME}.";host=".$Config{ZM_DB_HOST}, $Config{ZM_DB_USER}, $Config{ZM_DB_PASS} ) or croak( "Can't connect to db" );
|
||||
|
|
|
@ -75,7 +75,7 @@ sub AUTOLOAD
|
|||
croak( "Can't access $name member of object of class $class" );
|
||||
}
|
||||
|
||||
sub getKey()
|
||||
sub getKey
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{id} );
|
||||
|
@ -145,7 +145,7 @@ sub executeCommand
|
|||
&{$self->{$command}}( $self, $params );
|
||||
}
|
||||
|
||||
sub printMsg()
|
||||
sub printMsg
|
||||
{
|
||||
my $self = shift;
|
||||
Fatal( "No printMsg method defined for protocol ".$self->{name} );
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
# This module contains the implementation of the Pelco-P camera control
|
||||
# protocol
|
||||
#
|
||||
package ZoneMinder::Control::PelcoD;
|
||||
package ZoneMinder::Control::PelcoP;
|
||||
|
||||
use 5.006;
|
||||
use strict;
|
||||
|
|
|
@ -70,7 +70,7 @@ use Carp;
|
|||
|
||||
our $dbh = undef;
|
||||
|
||||
sub zmDbConnect( ;$ )
|
||||
sub zmDbConnect
|
||||
{
|
||||
my $force = shift;
|
||||
if ( $force )
|
||||
|
@ -94,7 +94,7 @@ sub zmDbConnect( ;$ )
|
|||
return( $dbh );
|
||||
}
|
||||
|
||||
sub zmDbDisconnect()
|
||||
sub zmDbDisconnect
|
||||
{
|
||||
if ( defined( $dbh ) )
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ use constant DB_MON_MOTION => 3; # All monitors that are doing motion detection
|
|||
use constant DB_MON_RECORD => 4; # All monitors that are doing unconditional recording
|
||||
use constant DB_MON_PASSIVE => 5; # All monitors that are in nodect state
|
||||
|
||||
sub zmDbGetMonitors( ;$ )
|
||||
sub zmDbGetMonitors
|
||||
{
|
||||
zmDbConnect();
|
||||
|
||||
|
@ -152,7 +152,7 @@ sub zmDbGetMonitors( ;$ )
|
|||
return( \@monitors );
|
||||
}
|
||||
|
||||
sub zmDbGetMonitor( $ )
|
||||
sub zmDbGetMonitor
|
||||
{
|
||||
zmDbConnect();
|
||||
|
||||
|
@ -168,7 +168,7 @@ sub zmDbGetMonitor( $ )
|
|||
return( $monitor );
|
||||
}
|
||||
|
||||
sub zmDbGetMonitorAndControl( $ )
|
||||
sub zmDbGetMonitorAndControl
|
||||
{
|
||||
zmDbConnect();
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ use ZoneMinder::Database qw(:all);
|
|||
use POSIX;
|
||||
|
||||
# For running general shell commands
|
||||
sub executeShellCommand( $ )
|
||||
sub executeShellCommand
|
||||
{
|
||||
my $command = shift;
|
||||
my $output = qx( $command );
|
||||
|
@ -90,7 +90,7 @@ sub executeShellCommand( $ )
|
|||
return( $status );
|
||||
}
|
||||
|
||||
sub getCmdFormat()
|
||||
sub getCmdFormat
|
||||
{
|
||||
Debug( "Testing valid shell syntax\n" );
|
||||
|
||||
|
@ -162,7 +162,7 @@ our $testedShellSyntax = 0;
|
|||
our ( $cmdPrefix, $cmdSuffix );
|
||||
|
||||
# For running ZM daemons etc
|
||||
sub runCommand( $ )
|
||||
sub runCommand
|
||||
{
|
||||
if ( !$testedShellSyntax )
|
||||
{
|
||||
|
@ -196,7 +196,7 @@ sub runCommand( $ )
|
|||
return( $output );
|
||||
}
|
||||
|
||||
sub getEventPath( $ )
|
||||
sub getEventPath
|
||||
{
|
||||
my $event = shift;
|
||||
|
||||
|
@ -213,7 +213,7 @@ sub getEventPath( $ )
|
|||
return( $event_path );
|
||||
}
|
||||
|
||||
sub createEventPath( $ )
|
||||
sub createEventPath
|
||||
{
|
||||
#
|
||||
# WARNING assumes running from events directory
|
||||
|
@ -250,8 +250,9 @@ sub createEventPath( $ )
|
|||
|
||||
# Create empty id tag file
|
||||
$idFile = sprintf( "%s/.%d", $eventPath, $event->{Id} );
|
||||
open( ID_FP, ">$idFile" ) or Fatal( "Can't open $idFile: $!" );
|
||||
close( ID_FP );
|
||||
open( my $ID_FP, ">", $idFile )
|
||||
or Fatal( "Can't open $idFile: $!" );
|
||||
close( $ID_FP );
|
||||
setFileOwner( $idFile );
|
||||
}
|
||||
else
|
||||
|
@ -260,8 +261,9 @@ sub createEventPath( $ )
|
|||
$eventPath .= '/'.$event->{Id};
|
||||
|
||||
my $idFile = sprintf( "%s/.%d", $eventPath, $event->{Id} );
|
||||
open( ID_FP, ">$idFile" ) or Fatal( "Can't open $idFile: $!" );
|
||||
close( ID_FP );
|
||||
open( my $ID_FP, ">", $idFile )
|
||||
or Fatal( "Can't open $idFile: $!" );
|
||||
close( $ID_FP );
|
||||
setFileOwner( $idFile );
|
||||
}
|
||||
return( $eventPath );
|
||||
|
@ -272,7 +274,7 @@ use Data::Dumper;
|
|||
our $_setFileOwner = undef;
|
||||
our ( $_ownerUid, $_ownerGid );
|
||||
|
||||
sub _checkProcessOwner()
|
||||
sub _checkProcessOwner
|
||||
{
|
||||
if ( !defined($_setFileOwner) )
|
||||
{
|
||||
|
@ -291,7 +293,7 @@ sub _checkProcessOwner()
|
|||
return( $_setFileOwner );
|
||||
}
|
||||
|
||||
sub setFileOwner( $ )
|
||||
sub setFileOwner
|
||||
{
|
||||
my $file = shift;
|
||||
|
||||
|
@ -303,7 +305,7 @@ sub setFileOwner( $ )
|
|||
|
||||
our $_hasImageInfo = undef;
|
||||
|
||||
sub _checkForImageInfo()
|
||||
sub _checkForImageInfo
|
||||
{
|
||||
if ( !defined($_hasImageInfo) )
|
||||
{
|
||||
|
@ -317,7 +319,7 @@ sub _checkForImageInfo()
|
|||
return( $_hasImageInfo );
|
||||
}
|
||||
|
||||
sub createEvent( $;$ )
|
||||
sub createEvent
|
||||
{
|
||||
my $event = shift;
|
||||
|
||||
|
@ -447,7 +449,7 @@ sub createEvent( $;$ )
|
|||
}
|
||||
}
|
||||
|
||||
sub addEventImage( $$ )
|
||||
sub addEventImage
|
||||
{
|
||||
my $event = shift;
|
||||
my $frame = shift;
|
||||
|
@ -455,7 +457,7 @@ sub addEventImage( $$ )
|
|||
# TBD
|
||||
}
|
||||
|
||||
sub updateEvent( $ )
|
||||
sub updateEvent
|
||||
{
|
||||
my $event = shift;
|
||||
|
||||
|
@ -488,7 +490,7 @@ sub updateEvent( $ )
|
|||
my $res = $sth->execute( @values ) or Fatal( "Can't execute sql '$sql': ".$sth->errstr() );
|
||||
}
|
||||
|
||||
sub deleteEventFiles( $;$ )
|
||||
sub deleteEventFiles
|
||||
{
|
||||
#
|
||||
# WARNING assumes running from events directory
|
||||
|
@ -541,7 +543,7 @@ sub deleteEventFiles( $;$ )
|
|||
}
|
||||
}
|
||||
|
||||
sub makePath( $;$ )
|
||||
sub makePath
|
||||
{
|
||||
my $path = shift;
|
||||
my $root = shift;
|
||||
|
@ -585,7 +587,7 @@ sub _testJSON
|
|||
$hasJSONAny = 1 if ( $result );
|
||||
}
|
||||
|
||||
sub _getJSONType( $ )
|
||||
sub _getJSONType
|
||||
{
|
||||
my $value = shift;
|
||||
return( 'null' ) unless( defined($value) );
|
||||
|
@ -596,9 +598,9 @@ sub _getJSONType( $ )
|
|||
return( 'string' );
|
||||
}
|
||||
|
||||
sub jsonEncode( $ );
|
||||
sub jsonEncode;
|
||||
|
||||
sub jsonEncode( $ )
|
||||
sub jsonEncode
|
||||
{
|
||||
my $value = shift;
|
||||
|
||||
|
@ -649,7 +651,7 @@ sub jsonEncode( $ )
|
|||
}
|
||||
}
|
||||
|
||||
sub jsonDecode( $ )
|
||||
sub jsonDecode
|
||||
{
|
||||
my $value = shift;
|
||||
|
||||
|
|
|
@ -126,6 +126,7 @@ our %priorities = (
|
|||
);
|
||||
|
||||
our $logger;
|
||||
our $LOGFILE;
|
||||
|
||||
sub new
|
||||
{
|
||||
|
@ -290,7 +291,7 @@ sub initialise( @ )
|
|||
Debug( "LogOpts: level=".$codes{$this->{level}}."/".$codes{$this->{effectiveLevel}}.", screen=".$codes{$this->{termLevel}}.", database=".$codes{$this->{databaseLevel}}.", logfile=".$codes{$this->{fileLevel}}."->".$this->{logFile}.", syslog=".$codes{$this->{syslogLevel}} );
|
||||
}
|
||||
|
||||
sub terminate()
|
||||
sub terminate
|
||||
{
|
||||
my $this = shift;
|
||||
return unless ( $this->{initialised} );
|
||||
|
@ -300,7 +301,7 @@ sub terminate()
|
|||
$this->termLevel( NOLOG );
|
||||
}
|
||||
|
||||
sub reinitialise()
|
||||
sub reinitialise
|
||||
{
|
||||
my $this = shift;
|
||||
|
||||
|
@ -322,7 +323,7 @@ sub reinitialise()
|
|||
$this->databaseLevel( $databaseLevel ) if ( $databaseLevel > NOLOG );
|
||||
}
|
||||
|
||||
sub limit( $ )
|
||||
sub limit
|
||||
{
|
||||
my $this = shift;
|
||||
my $level = shift;
|
||||
|
@ -331,7 +332,7 @@ sub limit( $ )
|
|||
return( $level );
|
||||
}
|
||||
|
||||
sub getTargettedEnv( $ )
|
||||
sub getTargettedEnv
|
||||
{
|
||||
my $this = shift;
|
||||
my $name = shift;
|
||||
|
@ -354,7 +355,7 @@ sub getTargettedEnv( $ )
|
|||
return( $value );
|
||||
}
|
||||
|
||||
sub fetch()
|
||||
sub fetch
|
||||
{
|
||||
if ( !$logger )
|
||||
{
|
||||
|
@ -364,7 +365,7 @@ sub fetch()
|
|||
return( $logger );
|
||||
}
|
||||
|
||||
sub id( ;$ )
|
||||
sub id
|
||||
{
|
||||
my $this = shift;
|
||||
my $id = shift;
|
||||
|
@ -388,7 +389,7 @@ sub id( ;$ )
|
|||
return( $this->{id} );
|
||||
}
|
||||
|
||||
sub level( ;$ )
|
||||
sub level
|
||||
{
|
||||
my $this = shift;
|
||||
my $level = shift;
|
||||
|
@ -405,20 +406,20 @@ sub level( ;$ )
|
|||
return( $this->{level} );
|
||||
}
|
||||
|
||||
sub debugOn()
|
||||
sub debugOn
|
||||
{
|
||||
my $this = shift;
|
||||
return( $this->{effectiveLevel} >= DEBUG );
|
||||
}
|
||||
|
||||
sub trace( ;$ )
|
||||
sub trace
|
||||
{
|
||||
my $this = shift;
|
||||
$this->{trace} = $_[0] if ( @_ );
|
||||
return( $this->{trace} );
|
||||
}
|
||||
|
||||
sub termLevel( ;$ )
|
||||
sub termLevel
|
||||
{
|
||||
my $this = shift;
|
||||
my $termLevel = shift;
|
||||
|
@ -434,7 +435,7 @@ sub termLevel( ;$ )
|
|||
return( $this->{termLevel} );
|
||||
}
|
||||
|
||||
sub databaseLevel( ;$ )
|
||||
sub databaseLevel
|
||||
{
|
||||
my $this = shift;
|
||||
my $databaseLevel = shift;
|
||||
|
@ -486,7 +487,7 @@ sub databaseLevel( ;$ )
|
|||
return( $this->{databaseLevel} );
|
||||
}
|
||||
|
||||
sub fileLevel( ;$ )
|
||||
sub fileLevel
|
||||
{
|
||||
my $this = shift;
|
||||
my $fileLevel = shift;
|
||||
|
@ -503,7 +504,7 @@ sub fileLevel( ;$ )
|
|||
return( $this->{fileLevel} );
|
||||
}
|
||||
|
||||
sub syslogLevel( ;$ )
|
||||
sub syslogLevel
|
||||
{
|
||||
my $this = shift;
|
||||
my $syslogLevel = shift;
|
||||
|
@ -520,19 +521,19 @@ sub syslogLevel( ;$ )
|
|||
return( $this->{syslogLevel} );
|
||||
}
|
||||
|
||||
sub openSyslog()
|
||||
sub openSyslog
|
||||
{
|
||||
my $this = shift;
|
||||
openlog( $this->{id}, "pid", "local1" );
|
||||
}
|
||||
|
||||
sub closeSyslog()
|
||||
sub closeSyslog
|
||||
{
|
||||
my $this = shift;
|
||||
#closelog();
|
||||
}
|
||||
|
||||
sub logFile( $ )
|
||||
sub logFile
|
||||
{
|
||||
my $this = shift;
|
||||
my $logFile = shift;
|
||||
|
@ -546,18 +547,19 @@ sub logFile( $ )
|
|||
}
|
||||
}
|
||||
|
||||
sub openFile()
|
||||
sub openFile
|
||||
{
|
||||
my $this = shift;
|
||||
if ( open( LOGFILE, ">>".$this->{logFile} ) )
|
||||
if ( open( $LOGFILE, ">>", $this->{logFile} ) )
|
||||
{
|
||||
LOGFILE->autoflush() if ( $this->{autoFlush} );
|
||||
$LOGFILE->autoflush() if ( $this->{autoFlush} );
|
||||
|
||||
my $webUid = (getpwnam( $Config{ZM_WEB_USER} ))[2];
|
||||
my $webGid = (getgrnam( $Config{ZM_WEB_GROUP} ))[2];
|
||||
if ( $> == 0 )
|
||||
{
|
||||
chown( $webUid, $webGid, $this->{logFile} ) or Fatal( "Can't change permissions on log file '".$this->{logFile}."': $!" )
|
||||
chown( $webUid, $webGid, $this->{logFile} )
|
||||
or Fatal( "Can't change permissions on log file '".$this->{logFile}."': $!" )
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -567,13 +569,13 @@ sub openFile()
|
|||
}
|
||||
}
|
||||
|
||||
sub closeFile()
|
||||
sub closeFile
|
||||
{
|
||||
my $this = shift;
|
||||
close( LOGFILE ) if ( fileno(LOGFILE) );
|
||||
close( $LOGFILE ) if ( fileno($LOGFILE) );
|
||||
}
|
||||
|
||||
sub logPrint( $;$ )
|
||||
sub logPrint
|
||||
{
|
||||
my $this = shift;
|
||||
my $level = shift;
|
||||
|
@ -596,7 +598,7 @@ sub logPrint( $;$ )
|
|||
$message = $message."\n";
|
||||
}
|
||||
syslog( $priorities{$level}, $code." [%s]", $string ) if ( $level <= $this->{syslogLevel} );
|
||||
print( LOGFILE $message ) if ( $level <= $this->{fileLevel} );
|
||||
print( $LOGFILE $message ) if ( $level <= $this->{fileLevel} );
|
||||
if ( $level <= $this->{databaseLevel} )
|
||||
{
|
||||
my $sql = "insert into Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) values ( ?, ?, ?, ?, ?, ?, ?, NULL )";
|
||||
|
@ -624,7 +626,7 @@ sub logInit( ;@ )
|
|||
$logger->initialise( %options );
|
||||
}
|
||||
|
||||
sub logReinit()
|
||||
sub logReinit
|
||||
{
|
||||
fetch()->reinitialise();
|
||||
}
|
||||
|
@ -636,7 +638,7 @@ sub logTerm
|
|||
$logger = undef;
|
||||
}
|
||||
|
||||
sub logHupHandler()
|
||||
sub logHupHandler
|
||||
{
|
||||
my $savedErrno = $!;
|
||||
return unless( $logger );
|
||||
|
@ -645,47 +647,47 @@ sub logHupHandler()
|
|||
$! = $savedErrno;
|
||||
}
|
||||
|
||||
sub logSetSignal()
|
||||
sub logSetSignal
|
||||
{
|
||||
$SIG{HUP} = \&logHupHandler;
|
||||
}
|
||||
|
||||
sub logClearSignal()
|
||||
sub logClearSignal
|
||||
{
|
||||
$SIG{HUP} = 'DEFAULT';
|
||||
}
|
||||
|
||||
sub logLevel( ;$ )
|
||||
sub logLevel
|
||||
{
|
||||
return( fetch()->level( @_ ) );
|
||||
}
|
||||
|
||||
sub logDebugging()
|
||||
sub logDebugging
|
||||
{
|
||||
return( fetch()->debugOn() );
|
||||
}
|
||||
|
||||
sub logTermLevel( ;$ )
|
||||
sub logTermLevel
|
||||
{
|
||||
return( fetch()->termLevel( @_ ) );
|
||||
}
|
||||
|
||||
sub logDatabaseLevel( ;$ )
|
||||
sub logDatabaseLevel
|
||||
{
|
||||
return( fetch()->databaseLevel( @_ ) );
|
||||
}
|
||||
|
||||
sub logFileLevel( ;$ )
|
||||
sub logFileLevel
|
||||
{
|
||||
return( fetch()->fileLevel( @_ ) );
|
||||
}
|
||||
|
||||
sub logSyslogLevel( ;$ )
|
||||
sub logSyslogLevel
|
||||
{
|
||||
return( fetch()->syslogLevel( @_ ) );
|
||||
}
|
||||
|
||||
sub Mark( ;$$ )
|
||||
sub Mark
|
||||
{
|
||||
my $level = shift;
|
||||
$level = DEBUG unless( defined($level) );
|
||||
|
@ -693,7 +695,7 @@ sub Mark( ;$$ )
|
|||
fetch()->logPrint( $level, $tag );
|
||||
}
|
||||
|
||||
sub Dump( \$;$ )
|
||||
sub Dump
|
||||
{
|
||||
my $var = shift;
|
||||
my $label = shift;
|
||||
|
|
|
@ -249,7 +249,7 @@ sub zmMemInit
|
|||
|
||||
&zmMemInit();
|
||||
|
||||
sub zmMemVerify( $ )
|
||||
sub zmMemVerify
|
||||
{
|
||||
my $monitor = shift;
|
||||
if ( !zmMemAttach( $monitor, $mem_size ) )
|
||||
|
@ -291,7 +291,7 @@ sub zmMemVerify( $ )
|
|||
return( !undef );
|
||||
}
|
||||
|
||||
sub zmMemRead( $$;$ )
|
||||
sub zmMemRead
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $fields = shift;
|
||||
|
@ -387,7 +387,7 @@ sub zmMemRead( $$;$ )
|
|||
return( $values[0] );
|
||||
}
|
||||
|
||||
sub zmMemInvalidate( $ )
|
||||
sub zmMemInvalidate
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $mem_key = zmMemKey($monitor);
|
||||
|
@ -398,12 +398,12 @@ sub zmMemInvalidate( $ )
|
|||
}
|
||||
}
|
||||
|
||||
sub zmMemTidy()
|
||||
sub zmMemTidy
|
||||
{
|
||||
zmMemClean();
|
||||
}
|
||||
|
||||
sub zmMemWrite( $$;$ )
|
||||
sub zmMemWrite
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $field_values = shift;
|
||||
|
@ -489,21 +489,21 @@ sub zmMemWrite( $$;$ )
|
|||
return( !undef );
|
||||
}
|
||||
|
||||
sub zmGetMonitorState( $ )
|
||||
sub zmGetMonitorState
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, "shared_data:state" ) );
|
||||
}
|
||||
|
||||
sub zmGetAlarmLocation( $ )
|
||||
sub zmGetAlarmLocation
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, [ "shared_data:alarm_x", "shared_data:alarm_y" ] ) );
|
||||
}
|
||||
|
||||
sub zmSetControlState( $$ )
|
||||
sub zmSetControlState
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $control_state = shift;
|
||||
|
@ -511,14 +511,14 @@ sub zmSetControlState( $$ )
|
|||
zmMemWrite( $monitor, { "shared_data:control_state" => $control_state } );
|
||||
}
|
||||
|
||||
sub zmGetControlState( $ )
|
||||
sub zmGetControlState
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, "shared_data:control_state" ) );
|
||||
}
|
||||
|
||||
sub zmSaveControlState( $$ )
|
||||
sub zmSaveControlState
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $control_state = shift;
|
||||
|
@ -526,14 +526,14 @@ sub zmSaveControlState( $$ )
|
|||
zmSetControlState( $monitor, freeze( $control_state ) );
|
||||
}
|
||||
|
||||
sub zmRestoreControlState( $ )
|
||||
sub zmRestoreControlState
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( thaw( zmGetControlState( $monitor ) ) );
|
||||
}
|
||||
|
||||
sub zmIsAlarmed( $ )
|
||||
sub zmIsAlarmed
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -542,7 +542,7 @@ sub zmIsAlarmed( $ )
|
|||
return( $state == STATE_ALARM );
|
||||
}
|
||||
|
||||
sub zmInAlarm( $ )
|
||||
sub zmInAlarm
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -551,7 +551,7 @@ sub zmInAlarm( $ )
|
|||
return( $state == STATE_ALARM || $state == STATE_ALERT );
|
||||
}
|
||||
|
||||
sub zmHasAlarmed( $$ )
|
||||
sub zmHasAlarmed
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $last_event_id = shift;
|
||||
|
@ -569,35 +569,35 @@ sub zmHasAlarmed( $$ )
|
|||
return( undef );
|
||||
}
|
||||
|
||||
sub zmGetLastEvent( $ )
|
||||
sub zmGetLastEvent
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, "shared_data:last_event" ) );
|
||||
}
|
||||
|
||||
sub zmGetLastWriteTime( $ )
|
||||
sub zmGetLastWriteTime
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, "shared_data:last_write_time" ) );
|
||||
}
|
||||
|
||||
sub zmGetLastReadTime( $ )
|
||||
sub zmGetLastReadTime
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, "shared_data:last_read_time" ) );
|
||||
}
|
||||
|
||||
sub zmGetMonitorActions( $ )
|
||||
sub zmGetMonitorActions
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, "shared_data:action" ) );
|
||||
}
|
||||
|
||||
sub zmMonitorEnable( $ )
|
||||
sub zmMonitorEnable
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -606,7 +606,7 @@ sub zmMonitorEnable( $ )
|
|||
zmMemWrite( $monitor, { "shared_data:action" => $action } );
|
||||
}
|
||||
|
||||
sub zmMonitorDisable( $ )
|
||||
sub zmMonitorDisable
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -615,7 +615,7 @@ sub zmMonitorDisable( $ )
|
|||
zmMemWrite( $monitor, { "shared_data:action" => $action } );
|
||||
}
|
||||
|
||||
sub zmMonitorSuspend( $ )
|
||||
sub zmMonitorSuspend
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -624,7 +624,7 @@ sub zmMonitorSuspend( $ )
|
|||
zmMemWrite( $monitor, { "shared_data:action" => $action } );
|
||||
}
|
||||
|
||||
sub zmMonitorResume( $ )
|
||||
sub zmMonitorResume
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -633,14 +633,14 @@ sub zmMonitorResume( $ )
|
|||
zmMemWrite( $monitor, { "shared_data:action" => $action } );
|
||||
}
|
||||
|
||||
sub zmGetTriggerState( $ )
|
||||
sub zmGetTriggerState
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
return( zmMemRead( $monitor, "trigger_data:trigger_state" ) );
|
||||
}
|
||||
|
||||
sub zmTriggerEventOn( $$$;$$ )
|
||||
sub zmTriggerEventOn
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $score = shift;
|
||||
|
@ -659,7 +659,7 @@ sub zmTriggerEventOn( $$$;$$ )
|
|||
zmMemWrite( $monitor, $values );
|
||||
}
|
||||
|
||||
sub zmTriggerEventOff( $ )
|
||||
sub zmTriggerEventOff
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -674,7 +674,7 @@ sub zmTriggerEventOff( $ )
|
|||
zmMemWrite( $monitor, $values );
|
||||
}
|
||||
|
||||
sub zmTriggerEventCancel( $ )
|
||||
sub zmTriggerEventCancel
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -689,7 +689,7 @@ sub zmTriggerEventCancel( $ )
|
|||
zmMemWrite( $monitor, $values );
|
||||
}
|
||||
|
||||
sub zmTriggerShowtext( $$ )
|
||||
sub zmTriggerShowtext
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $showtext = shift;
|
||||
|
|
|
@ -68,13 +68,13 @@ use ZoneMinder::Logger qw(:all);
|
|||
|
||||
use Sys::Mmap;
|
||||
|
||||
sub zmMemKey( $ )
|
||||
sub zmMemKey
|
||||
{
|
||||
my $monitor = shift;
|
||||
return( defined($monitor->{MMapAddr})?$monitor->{MMapAddr}:undef );
|
||||
}
|
||||
|
||||
sub zmMemAttach( $$ )
|
||||
sub zmMemAttach
|
||||
{
|
||||
my ( $monitor, $size ) = @_;
|
||||
if ( ! $size ) {
|
||||
|
@ -96,7 +96,7 @@ sub zmMemAttach( $$ )
|
|||
Error( sprintf( "Memory map file '%s' should have been %d but was instead %d", $mmap_file, $size, $mmap_file_size ) );
|
||||
return ( undef );
|
||||
}
|
||||
if ( !open( MMAP, "+<".$mmap_file ) )
|
||||
if ( !open( MMAP, "+<", $mmap_file ) )
|
||||
{
|
||||
Error( sprintf( "Can't open memory map file '%s': $!\n", $mmap_file ) );
|
||||
return( undef );
|
||||
|
@ -116,7 +116,7 @@ sub zmMemAttach( $$ )
|
|||
return( !undef );
|
||||
}
|
||||
|
||||
sub zmMemDetach( $ )
|
||||
sub zmMemDetach
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
|
@ -138,7 +138,7 @@ sub zmMemDetach( $ )
|
|||
}
|
||||
}
|
||||
|
||||
sub zmMemGet( $$$ )
|
||||
sub zmMemGet
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $offset = shift;
|
||||
|
@ -154,7 +154,7 @@ sub zmMemGet( $$$ )
|
|||
return( $data );
|
||||
}
|
||||
|
||||
sub zmMemPut( $$$$ )
|
||||
sub zmMemPut
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $offset = shift;
|
||||
|
|
|
@ -69,13 +69,13 @@ our $VERSION = $ZoneMinder::Base::VERSION;
|
|||
use ZoneMinder::Config qw(:all);
|
||||
use ZoneMinder::Logger qw(:all);
|
||||
|
||||
sub zmMemKey( $ )
|
||||
sub zmMemKey
|
||||
{
|
||||
my $monitor = shift;
|
||||
return( defined($monitor->{ShmKey})?$monitor->{ShmKey}:undef );
|
||||
}
|
||||
|
||||
sub zmMemAttach( $$ )
|
||||
sub zmMemAttach
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $size = shift;
|
||||
|
@ -94,14 +94,14 @@ sub zmMemAttach( $$ )
|
|||
return( !undef );
|
||||
}
|
||||
|
||||
sub zmMemDetach( $ )
|
||||
sub zmMemDetach
|
||||
{
|
||||
my $monitor = shift;
|
||||
|
||||
delete $monitor->{ShmId};
|
||||
}
|
||||
|
||||
sub zmMemGet( $$$ )
|
||||
sub zmMemGet
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $offset = shift;
|
||||
|
@ -119,7 +119,7 @@ sub zmMemGet( $$$ )
|
|||
return( $data );
|
||||
}
|
||||
|
||||
sub zmMemPut( $$$$ )
|
||||
sub zmMemPut
|
||||
{
|
||||
my $monitor = shift;
|
||||
my $offset = shift;
|
||||
|
@ -143,8 +143,9 @@ sub zmMemClean
|
|||
# Find ZoneMinder shared memory
|
||||
my $command = "ipcs -m | grep '^".substr( sprintf( "0x%x", hex($Config{ZM_SHM_KEY}) ), 0, -2 )."'";
|
||||
Debug( "Checking for shared memory with '$command'\n" );
|
||||
open( CMD, "$command |" ) or Fatal( "Can't execute '$command': $!" );
|
||||
while( <CMD> )
|
||||
open( my $CMD, '<', "$command |" )
|
||||
or Fatal( "Can't execute '$command': $!" );
|
||||
while( <$CMD> )
|
||||
{
|
||||
chomp;
|
||||
my ( $key, $id ) = split( /\s+/ );
|
||||
|
@ -156,7 +157,7 @@ sub zmMemClean
|
|||
qx( $command );
|
||||
}
|
||||
}
|
||||
close( CMD );
|
||||
close( $CMD );
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -63,33 +63,33 @@ sub clone
|
|||
bless $clone, ref $self;
|
||||
}
|
||||
|
||||
sub open()
|
||||
sub open
|
||||
{
|
||||
my $self = shift;
|
||||
my $class = ref($self) or croak( "Can't get class for non object $self" );
|
||||
croak( "Abstract base class method called for object of class $class" );
|
||||
}
|
||||
|
||||
sub close()
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
my $class = ref($self) or croak( "Can't get class for non object $self" );
|
||||
croak( "Abstract base class method called for object of class $class" );
|
||||
}
|
||||
|
||||
sub getState()
|
||||
sub getState
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{state} );
|
||||
}
|
||||
|
||||
sub isOpen()
|
||||
sub isOpen
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{state} eq "open" );
|
||||
}
|
||||
|
||||
sub isConnected()
|
||||
sub isConnected
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{state} eq "connected" );
|
||||
|
|
|
@ -56,13 +56,13 @@ sub new
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub open()
|
||||
sub open
|
||||
{
|
||||
my $self = shift;
|
||||
local *sfh;
|
||||
#sysopen( *sfh, $conn->{path}, O_NONBLOCK|O_RDONLY ) or croak( "Can't sysopen: $!" );
|
||||
#open( *sfh, "<".$conn->{path} ) or croak( "Can't open: $!" );
|
||||
open( *sfh, "+<".$self->{path} ) or croak( "Can't open: $!" );
|
||||
open( *sfh, "+<", $self->{path} ) or croak( "Can't open: $!" );
|
||||
$self->{state} = 'open';
|
||||
$self->{handle} = *sfh;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ sub spawns
|
|||
return( undef );
|
||||
}
|
||||
|
||||
sub close()
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
close( $self->{handle} );
|
||||
|
@ -67,7 +67,7 @@ sub close()
|
|||
$self->{handle} = undef;
|
||||
}
|
||||
|
||||
sub read()
|
||||
sub read
|
||||
{
|
||||
my $self = shift;
|
||||
my $buffer;
|
||||
|
@ -80,7 +80,7 @@ sub read()
|
|||
return( $buffer );
|
||||
}
|
||||
|
||||
sub write()
|
||||
sub write
|
||||
{
|
||||
my $self = shift;
|
||||
my $buffer = shift;
|
||||
|
@ -94,7 +94,7 @@ sub write()
|
|||
return( !undef );
|
||||
}
|
||||
|
||||
sub fileno()
|
||||
sub fileno
|
||||
{
|
||||
my $self = shift;
|
||||
return( defined($self->{handle})?fileno($self->{handle}):-1 );
|
||||
|
|
|
@ -57,7 +57,7 @@ sub new
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub open()
|
||||
sub open
|
||||
{
|
||||
my $self = shift;
|
||||
local *sfh;
|
||||
|
@ -70,7 +70,7 @@ sub open()
|
|||
$self->{handle} = *sfh;
|
||||
}
|
||||
|
||||
sub _spawn( $ )
|
||||
sub _spawn
|
||||
{
|
||||
my $self = shift;
|
||||
my $new_handle = shift;
|
||||
|
@ -80,7 +80,7 @@ sub _spawn( $ )
|
|||
return( $clone );
|
||||
}
|
||||
|
||||
sub accept()
|
||||
sub accept
|
||||
{
|
||||
my $self = shift;
|
||||
local *cfh;
|
||||
|
|
|
@ -54,7 +54,7 @@ sub new
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub open()
|
||||
sub open
|
||||
{
|
||||
my $self = shift;
|
||||
my $device = new Device::SerialPort( $self->{path} );
|
||||
|
@ -72,14 +72,14 @@ sub open()
|
|||
$self->{state} = 'connected';
|
||||
}
|
||||
|
||||
sub close()
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
$self->{device}->close();
|
||||
$self->{state} = 'closed';
|
||||
}
|
||||
|
||||
sub read()
|
||||
sub read
|
||||
{
|
||||
my $self = shift;
|
||||
my $buffer = $self->{device}->lookfor();
|
||||
|
@ -91,7 +91,7 @@ sub read()
|
|||
return( $buffer );
|
||||
}
|
||||
|
||||
sub write()
|
||||
sub write
|
||||
{
|
||||
my $self = shift;
|
||||
my $buffer = shift;
|
||||
|
|
|
@ -57,7 +57,7 @@ sub new
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub open()
|
||||
sub open
|
||||
{
|
||||
my $self = shift;
|
||||
local *sfh;
|
||||
|
@ -69,7 +69,7 @@ sub open()
|
|||
$self->{handle} = *sfh;
|
||||
}
|
||||
|
||||
sub _spawn( $ )
|
||||
sub _spawn
|
||||
{
|
||||
my $self = shift;
|
||||
my $new_handle = shift;
|
||||
|
@ -79,7 +79,7 @@ sub _spawn( $ )
|
|||
return( $clone );
|
||||
}
|
||||
|
||||
sub accept()
|
||||
sub accept
|
||||
{
|
||||
my $self = shift;
|
||||
local *cfh;
|
||||
|
|
|
@ -71,7 +71,7 @@ sub spawns
|
|||
return( $self->{channel}->spawns() );
|
||||
}
|
||||
|
||||
sub _spawn( $ )
|
||||
sub _spawn
|
||||
{
|
||||
my $self = shift;
|
||||
my $new_channel = shift;
|
||||
|
@ -80,50 +80,50 @@ sub _spawn( $ )
|
|||
return( $clone );
|
||||
}
|
||||
|
||||
sub accept()
|
||||
sub accept
|
||||
{
|
||||
my $self = shift;
|
||||
my $new_channel = $self->{channel}->accept();
|
||||
return( $self->_spawn( $new_channel ) );
|
||||
}
|
||||
|
||||
sub open()
|
||||
sub open
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{channel}->open() );
|
||||
}
|
||||
|
||||
sub close()
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{channel}->close() );
|
||||
}
|
||||
|
||||
sub fileno()
|
||||
sub fileno
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{channel}->fileno() );
|
||||
}
|
||||
|
||||
sub isOpen()
|
||||
sub isOpen
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{channel}->isOpen() );
|
||||
}
|
||||
|
||||
sub isConnected()
|
||||
sub isConnected
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{channel}->isConnected() );
|
||||
}
|
||||
|
||||
sub canRead()
|
||||
sub canRead
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{input} && $self->isConnected() );
|
||||
}
|
||||
|
||||
sub canWrite()
|
||||
sub canWrite
|
||||
{
|
||||
my $self = shift;
|
||||
return( $self->{output} && $self->isConnected() );
|
||||
|
|
Loading…
Reference in New Issue