home *** CD-ROM | disk | FTP | other *** search
- /*
- ** c o m m o n . h
- **
- ** common header file for UPS monitor daemon
- **
- ** Arthur W. Neilson III
- ** art@pilikia.pegasus.com
- ** Sat Mar 30 1991
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <fcntl.h>
- #include <time.h>
- #include <sys/types.h>
- #include <sys/termio.h>
- #include <sys/signal.h>
- #include <sys/stat.h>
-
- #define ERR -1 /* error return value */
- #define SH "/bin/sh" /* shell to exec shutdown command */
- #define ROOT "/" /* root directory for chdir */
- #define CONSOLE "/dev/console" /* console device */
- #define SECS_PER_MIN 60 /* number of secs in a minute */
- #define MAX_TIME 30 /* maximum delay time allowed */
- #define SHUT_PERMS 0500 /* shutdown command permissions mask */
- #define LOG_PERMS 0600 /* logfile permissions on create */
- #define LOG_FLAGS O_WRONLY | O_CREAT | O_APPEND /* logfile open flags */
-
- /* default tuneable parameter values */
- #define UPS_PORT "/dev/ttyFM00" /* UPS port device name */
- #define UPS_SHUT "/etc/shutdown -y -g0" /* shutdown command */
- #define UPS_LOG "/etc/upslog" /* UPS log file pathname */
- #define UPS_TIME 10 /* default delay time (minutes) */
-
- /* environment variable names */
- #define UPSPORT "UPSPORT"
- #define UPSSHUT "UPSSHUT"
- #define UPSLOG "UPSLOG"
- #define UPSTIME "UPSTIME"
-
- /* UPS log messages */
- #define START_MSG "UPS daemon started"
- #define OPEN_MSG "Error opening UPS port"
- #define BATTERY_MSG "UPS switch to battery backup"
- #define ONLINE_MSG "UPS switch to online power"
- #define SHUTDOWN_MSG "Shutdown command executed"
- #define TERM_MSG "Caught termination signal"
-
- /* common globals */
- extern char *ups_port; /* UPS device name */
- extern char *ups_shut; /* system shutdown command */
- extern char *ups_log; /* UPS log file name */
- extern int ups_time; /* delay time before shutdown */
- extern int ups_fd; /* UPS port descriptor */
- extern int log_fd; /* log file descriptor */
-