Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > by-pkgid > 4fa43fa91fdbe099e81e2303752d5429 > files > 33

nut-1.4.2-2.1.100mdk.i586.rpm

Desc: Commands sent to the UPS drivers
File: commands.txt
Date: 30 June 2003
Auth: Russell Kroll <rkroll@exploits.org>

upsd can call drivers to store values in read/write variables and to kick
off instant commands.  This is how you register handlers for those events.

upscommon has a structure called upsh.  You should populate it with
function pointers in your upsdrv_initinfo() function.  Right now, there
are only two possibilities:

Note: these have "new_" in front as a temporary measure to allow old
drivers and new drivers to coexist in the tree for a little while.  The 
final names will not have that prefix, and this note will disappear from
this file.

	- new_setvar  = setting UPS variables (SET VAR protocol command)
	- new_instcmd = instant UPS commands (INSTCMD protocol command)

SET
---

If your driver's function for handling variable set events is called 
my_ups_set(), then you'd do this to add the pointer:

	upsh.new_setvar = my_ups_set;

my_ups_set() will receive two parameters:

	const char * - the variable being changed
	const char * - the new value

You should return either STAT_SET_HANDLED if your driver recognizes the
command, or STAT_SET_UNKNOWN if it doesn't.  Other possibilities will be
added at some point in the future.

INSTCMD
-------

This works just like the set process, with slightly different values
arriving from the server.

	upsh.new_instcmd = my_ups_cmd;

Your function will receive two args:

	const char * - the command name
	const char * - (reserved)

You should return eeither STAT_INSTCMD_HANDLED or STAT_INSTCMD_UNKNOWN
depending on whether your driver can handle the requested command.

Notes
-----

Use strcasecmp.  The command names arriving from upsd should be treated
without regards to case.

Responses
---------

Drivers will eventually be expected to send responses to commands.
Right now, there is no channel to get these back through upsd to
the client, so this is not implemented.

This will probably be implemented with a polling scheme in the clients.