(*
Module: NutUpsConf
 Parses @CONFPATH@/ups.conf

Author: Raphael Pinson <raphink@gmail.com>
        Frederic Bohe  <fredericbohe@eaton.com>
        Arnaud Quette <arnaud.quette@gmail.com>

About: License
  This file is licensed under the GPL.

About: Lens Usage
  Sample usage of this lens in augtool

    * Print all drivers used
      > print /files/@CONFPATH@/ups.conf/*/driver

About: Configuration files
  This lens applies to @CONFPATH@/ups.conf. See <filter>.
*)

module NutUpsConf =
  autoload ups_xfm

(************************************************************************
 * Group:                 UPS.CONF
 *************************************************************************)

let ups_comment  = IniFile.comment IniFile.comment_re IniFile.comment_default

let ups_sep      = IniFile.sep IniFile.sep_re IniFile.sep_default

let ups_global   = "chroot"
                 | "driverpath"
                 | "maxstartdelay"
                 | "maxretry"
                 | "retrydelay"
                 | "pollinterval"
                 | "synchronous"
                 | "user"

let ups_fields   = "driver"
                 | "port"
                 | "sdorder"
                 | "desc"
                 | "nolock"
                 | "ignorelb"
                 | "maxstartdelay"
                 | "synchronous"
                 | "BYPASS"
                 | "CHRG_addr"
                 | "CHRG_noro"
                 | "CHRG_regtype"
                 | "CP"
                 | "CS"
                 | "Could not addvar(%s)"
                 | "DISCHRG_addr"
                 | "DISCHRG_noro"
                 | "DISCHRG_regtype"
                 | "FSD_addr"
                 | "FSD_noro"
                 | "FSD_pulse_duration"
                 | "FSD_regtype"
                 | "HB_addr"
                 | "HB_noro"
                 | "HB_regtype"
                 | "ID"
                 | "LB"
                 | "LB_addr"
                 | "LB_noro"
                 | "LB_regtype"
                 | "LowBatt"
                 | "OB_addr"
                 | "OB_noro"
                 | "OB_regtype"
                 | "OL"
                 | "OL_addr"
                 | "OL_noro"
                 | "OL_regtype"
                 | "OffDelay"
                 | "OnDelay"
                 | "RB"
                 | "RB_addr"
                 | "RB_noro"
                 | "RB_regtype"
                 | "SD"
                 | "advanced_eco_mode"
                 | "advorder"
                 | "alarm_control"
                 | "authPassword"
                 | "authProtocol"
                 | "authtype"
                 | "awd"
                 | "batteryPercentage"
                 | "battery_alarm"
                 | "battery_max"
                 | "battery_min"
                 | "battery_number"
                 | "battery_open_status_check"
                 | "battext"
                 | "battvoltmult"
                 | "baud_rate"
                 | "baudrate"
                 | "bus"
                 | "bypass_alarm"
                 | "bypass_forbidding"
                 | "bypass_when_off"
                 | "cable"
                 | "cablepower"
                 | "chargetime"
                 | "community"
                 | "constant_phase_angle"
                 | "converter_mode"
                 | "cshdelay"
                 | "daysoff"
                 | "daysweek"
                 | "dev_slave_id"
                 | "device"
                 | "device_mfr"
                 | "device_model"
                 | "do_convert_deci"
                 | "dumbterm"
                 | "eco_mode"
                 | "explore"
                 | "fake_lowbatt"
                 | "fault_1"
                 | "fault_2"
                 | "fault_3"
                 | "fault_4"
                 | "fault_5"
                 | "flash"
                 | "frequency"
                 | "fruid"
                 | "full_update"
                 | "hb"
                 | "houroff"
                 | "houron"
                 | "i2c_address"
                 | "idleload"
                 | "ignoresab"
                 | "input_fault_voltage"
                 | "input_timeout"
                 | "interruptonly"
                 | "interruptsize"
                 | "langid_fix"
                 | "lb"
                 | "limited_runtime_on_battery"
                 | "linevoltage"
                 | "load.off"
                 | "load.on"
                 | "load.status"
                 | "loadPercentage"
                 | "login"
                 | "lowbatt"
                 | "manufacturer"
                 | "max_bypass_freq"
                 | "max_bypass_volt"
                 | "max_load"
                 | "max_polls_without_data"
                 | "maxreport"
                 | "methodOfFlowControl"
                 | "mfr"
                 | "mibs"
                 | "min_bypass_freq"
                 | "min_bypass_volt"
                 | "mincharge"
                 | "minruntime"
                 | "mod_byte_to_s"
                 | "mod_byte_to_us"
                 | "mod_resp_to_s"
                 | "mod_resp_to_us"
                 | "model"
                 | "modelname"
                 | "nobt"
                 | "nohang"
                 | "nombattvolt"
                 | "nominal_cell_voltage"
                 | "norating"
                 | "noscanlangid"
                 | "notification"
                 | "notransferoids"
                 | "novendor"
                 | "nowarn_noimp"
                 | "numOfBytesFromUPS"
                 | "number_of_battery_cells"
                 | "offdelay"
                 | "oldmac"
                 | "ondelay"
                 | "onlinedischarge"
                 | "output_pace"
                 | "output_phase_angle"
                 | "output_voltages"
                 | "password"
                 | "pins_shutdown_mode"
                 | "pollfreq"
                 | "pollonly"
                 | "powerup"
                 | "prefix"
                 | "prgshut"
                 | "privPassword"
                 | "privProtocol"
                 | "product"
                 | "productid"
                 | "protocol"
                 | "rebootdelay"
                 | "recharge_time"
                 | "reset_to_default"
                 | "rio_slave_id"
                 | "runtime_full"
                 | "runtime_half"
                 | "runtimecal"
                 | "sdtime"
                 | "sdtype"
                 | "secLevel"
                 | "secName"
                 | "semistaticfreq"
                 | "ser_baud_rate"
                 | "ser_data_bit"
                 | "ser_parity"
                 | "ser_stop_bit"
                 | "serial"
                 | "serialnumber"
                 | "series"
                 | "shutdownArguments"
                 | "shutdown_delay"
                 | "shutdown_duration"
                 | "shutdown_timer"
                 | "silent"
                 | "site_fault_detection"
                 | "slave_address"
                 | "snmp_retries"
                 | "snmp_timeout"
                 | "snmp_version"
                 | "startdelay"
                 | "status_only"
                 | "stayoff"
                 | "subdriver"
                 | "subscribe"
                 | "symmetrathreephase"
                 | "testing"
                 | "testtime"
                 | "timeout"
                 | "ttymode"
                 | "type"
                 | "ups.delay.shutdown"
                 | "ups.delay.start"
                 | "upstype"
                 | "usb_set_altinterface"
                 | "usd"
                 | "use_crlf"
                 | "use_pre_lf"
                 | "username"
                 | "validationSequence"
                 | "vendor"
                 | "vendorid"
                 | "voltage"
                 | "wait"
                 | "work_range_type"
                 | "wugrace"


let ups_entry    = IniFile.indented_entry (ups_global|ups_fields) ups_sep ups_comment

let ups_title    = IniFile.indented_title IniFile.record_re

let ups_record   = IniFile.record ups_title ups_entry

let ups_lns      = IniFile.lns ups_record ups_comment

let ups_filter   = (incl "@CONFPATH@/ups.conf")
                . Util.stdexcl

let ups_xfm      = transform ups_lns ups_filter
