/*
   queue/shutdown.h --- shutdown queue definitions.

   (c) Copyright 1995 SHW Wabnitz
   Written by Bernhard Fastenrath (fasten@shw.com)

   This file may be distributed under the terms
   of the GNU General Public License.
*/

#ifndef QUEUE_SHUTDOWN_H
#define QUEUE_SHUTDOWN_H

/* definitions for the sm_Status field:
   SHUTDOWN_WARN:   system might go down
   SHUTDOWN_INFO:   check sm_Info field
   SHUTDOWN_ABORT:  shutdown cancelled
   SHUTDOWN_NOW:    system is going down in a few seconds
   SHUTDOWN_UMOUNT: accessing files is pointless from now on
   SHUTDOWN_HALT:   the system is down
*/
#define SHUTDOWN_WARN   0x01
#define SHUTDOWN_INFO   0x02
#define SHUTDOWN_ABORT  0x04
#define SHUTDOWN_NOW    0x08
#define SHUTDOWN_UMOUNT 0x10
#define SHUTDOWN_HALT   0x20

/* definitions for the sm_Info field:
   SDMI_UPS_MONITOR: UPS monitor report (sm_Extra points to struct UpsInfo)
*/
#define SDMI_UPS_MONITOR 0x01

typedef struct {
  ULONG    sm_Status;
  ULONG    sm_TimeLeft;
  ULONG    sm_Info;
  void    *sm_Extra;
  ULONG    sm_Reserved[2];
} ShutdownMessage;

typedef struct UpsInfo {
  ULONG ui_Event;
  ULONG ui_Charge; /* Charge in percent */
  ULONG ui_Time;   /* Remaining time    */
  ULONG ui_Reserved[8];
} UpsInfo;

#define UPS_EV_OKAY         0x00
#define UPS_EV_LINE_FAIL    0x01
#define UPS_EV_RECOVERY     0x02
#define UPS_EV_BYPASS       0x03
#define UPS_EV_NO_BYPASS    0x04
#define UPS_EV_LOW_BATTERY  0x05
#define UPS_EV_RECHARGED    0x06
#define UPS_EV_SHUTDOWN_RECOMMENDED 0x07
#define UPS_EV_SHORT_POWER_FAIL     0x08
#define UPS_EV_FAULT        0x0a
#define UPS_EV_NO_FAULT     0x0b
#define UPS_EV_INVERTER     0x0c
#define UPS_EV_NO_INVERTER  0x0d
#define UPS_EV_SPECIAL_ON   0x0e
#define UPS_EV_SPECIAL_OFF  0x0f
#define UPS_EV_CONNECTION_LOST 0x11
#define UPS_EV_CONNECTION_OKAY 0x12
#define UPS_EV_MAX          0x12

#define UPS_EV_NAMES { \
  "Okay", "Line Fail", "Recovery", \
  "Bypass", "No Bypass", "Low Battery", \
  "Recharged", "Shutdown Recommended", \
  "Short Power Fail", "", \
  "Fault",      "No Fault", \
  "Inverter",   "No Inverter", \
  "Special On", "Special Off", "", \
  "Connection Lost", "Connection Restored" \
}

#endif /* QUEUE_SHUTDOWN_H */
