home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3163 / common.h next >
Encoding:
C/C++ Source or Header  |  1991-04-04  |  1.8 KB  |  57 lines

  1. /*
  2. **    c o m m o n . h
  3. **
  4. **    common header file for UPS monitor daemon
  5. **
  6. **    Arthur W. Neilson III
  7. **    art@pilikia.pegasus.com
  8. **    Sat Mar 30 1991
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <fcntl.h>
  14. #include <time.h>
  15. #include <sys/types.h>
  16. #include <sys/termio.h>
  17. #include <sys/signal.h>
  18. #include <sys/stat.h>
  19.  
  20. #define ERR        -1        /* error return value */
  21. #define SH        "/bin/sh"    /* shell to exec shutdown command */
  22. #define ROOT        "/"        /* root directory for chdir */
  23. #define CONSOLE        "/dev/console"    /* console device */
  24. #define SECS_PER_MIN    60        /* number of secs in a minute */
  25. #define MAX_TIME    30        /* maximum delay time allowed */
  26. #define SHUT_PERMS    0500        /* shutdown command permissions mask */
  27. #define LOG_PERMS    0600        /* logfile permissions on create */
  28. #define LOG_FLAGS    O_WRONLY | O_CREAT | O_APPEND    /* logfile open flags */
  29.  
  30. /* default tuneable parameter values */
  31. #define UPS_PORT    "/dev/ttyFM00"    /* UPS port device name */
  32. #define UPS_SHUT    "/etc/shutdown -y -g0"    /* shutdown command */
  33. #define UPS_LOG        "/etc/upslog"    /* UPS log file pathname */
  34. #define UPS_TIME    10        /* default delay time (minutes) */
  35.  
  36. /* environment variable names */
  37. #define UPSPORT        "UPSPORT"
  38. #define UPSSHUT        "UPSSHUT"
  39. #define UPSLOG        "UPSLOG"
  40. #define UPSTIME        "UPSTIME"
  41.  
  42. /* UPS log messages */
  43. #define START_MSG    "UPS daemon started"
  44. #define OPEN_MSG    "Error opening UPS port"
  45. #define BATTERY_MSG    "UPS switch to battery backup"
  46. #define ONLINE_MSG    "UPS switch to online power"
  47. #define SHUTDOWN_MSG    "Shutdown command executed"
  48. #define TERM_MSG    "Caught termination signal"
  49.  
  50. /* common globals */
  51. extern char   *ups_port;        /* UPS device name */
  52. extern char   *ups_shut;        /* system shutdown command */
  53. extern char   *ups_log;            /* UPS log file name */
  54. extern int     ups_time;        /* delay time before shutdown */
  55. extern int     ups_fd;            /* UPS port descriptor */
  56. extern int     log_fd;            /* log file descriptor */
  57.