improve checking of "lpt_enable" variable
This commit is contained in:
parent
828d9323cc
commit
233f9ffab0
11
yasnd.c
11
yasnd.c
@ -53,6 +53,8 @@ void* allocate_memory(int bytes)
|
||||
*/
|
||||
void lpt_init()
|
||||
{
|
||||
if (lpt_enable)
|
||||
{
|
||||
if (ioperm (lpt_port, 3, 1))
|
||||
{
|
||||
log_event("Error: Unlocking the circuit fails due to LPT port access error");
|
||||
@ -62,6 +64,7 @@ void lpt_init()
|
||||
}
|
||||
// Unlock circuit
|
||||
outb (0, lpt_port);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -71,6 +74,8 @@ void lpt_init()
|
||||
*/
|
||||
void lpt_lock()
|
||||
{
|
||||
if (lpt_enable)
|
||||
{
|
||||
if (ioperm (lpt_port, 3, 1))
|
||||
{
|
||||
log_event("Error: Locking the circuit fails due to LPT port access error");
|
||||
@ -80,6 +85,7 @@ void lpt_lock()
|
||||
}
|
||||
// Lock circuit
|
||||
outb (1, lpt_port);
|
||||
}
|
||||
}
|
||||
|
||||
// Function, that checks that defined host entry is valid
|
||||
@ -164,7 +170,6 @@ void init()
|
||||
if (sms_enable)
|
||||
gammu_init();
|
||||
// initialize LPT control circuit
|
||||
if (lpt_enable)
|
||||
lpt_init();
|
||||
}
|
||||
|
||||
@ -198,6 +203,8 @@ void check_host(int num,host_decl* host)
|
||||
*/
|
||||
void reset_pin(int pin_num)
|
||||
{
|
||||
if (lpt_enable)
|
||||
{
|
||||
if (pin_num==0)
|
||||
return; // there is no LPT control for target host
|
||||
if (pin_num<0 || pin_num>8)
|
||||
@ -215,6 +222,7 @@ void reset_pin(int pin_num)
|
||||
outb (pins, lpt_port);
|
||||
sleep(1);
|
||||
outb (0, lpt_port);
|
||||
}
|
||||
}
|
||||
|
||||
int loop_function()
|
||||
@ -319,7 +327,6 @@ void signal_handler(int signum)
|
||||
{
|
||||
log_event("SIGTERM captured, daemon stopping");
|
||||
// block LPT control circuit
|
||||
if (lpt_enable)
|
||||
lpt_lock();
|
||||
// close log decriptor
|
||||
closelog();
|
||||
|
Loading…
Reference in New Issue
Block a user