constchar*command;/* Command sent to the UPS to get answer/to execute an instant command/to set a variable */
charanswer[SMALLBUF];/* Answer from the UPS, filled at runtime */
constintanswer_len;/* Expected min length of the answer. Set it to 0 if there’s no minimum length to look after. */
constcharleading;/* Expected leading character of the answer (optional) */
charvalue[SMALLBUF];/* Value from the answer, filled at runtime (i.e. answer between from and to) */
constintfrom;/* Position of the starting character of the info (i.e. 'value') we're after in the answer */
constintto;/* Position of the ending character of the info (i.e. 'value') we're after in the answer: use 0 if all the remaining of the line is needed */
constchar*dfl;/* Format to store value from the UPS in NUT variables. Not used by the driver for QX_FLAG_{CMD,SETVAR} items.
#define QX_FLAG_STATIC 2 /* Retrieve info only once. */
#define QX_FLAG_SEMI_STATIC 4 /* Retrieve info smartly, i.e. only when a command/setvar is executed and we expect that data could have been changed. */
#define QX_FLAG_ABSENT 8 /* Data is absent in the device, use default value. */
#define QX_FLAG_QUICK_POLL 16 /* Mandatory vars, polled also in QX_WALKMODE_QUICK_UPDATE.
testing_t*testing;/* Testing table: commands and the replies used for testing the subdriver */
#endif /* TESTING */
}subdriver_t;
/* The following functions are exported for the benefit of subdrivers */
/* Execute an instant command. Return STAT_INSTCMD_INVALID if the command is invalid, STAT_INSTCMD_FAILED if it failed, STAT_INSTCMD_HANDLED on success. */
/* Set r/w variable to a value after it has been checked against its info_rw structure. Return STAT_SET_HANDLED on success, otherwise STAT_SET_UNKNOWN. */
intsetvar(constchar*varname,constchar*val);
/* Find an item of item_t type in qx2nut data structure by its info_type, optionally filtered by its qxflags, and return it if found, otherwise return NULL.
/* Send 'command' or, if it is NULL, send the command stored in the item to the UPS and process the reply. Return -1 on errors, 0 on success. */
intqx_process(item_t*item,constchar*command);
/* Process the value we got back from the UPS (set status bits and set the value of other parameters), calling its preprocess function, if any. Return -1 on failure, 0 for a status update and 1 in all other cases. */
intups_infoval_set(item_t*item);
/* Return the currently processed status so that it can be checked with one of the status_bit_t passed to the STATUS() macro. */
intqx_status(void);
/* Edit the current status: it takes one of the NUT status (all but OB are supported, simply set it as not OL), eventually preceded with an exclamation mark to clear it from the status (e.g. !OL). */