~ubuntu-branches/ubuntu/saucy/nut/saucy

« back to all changes in this revision

Viewing changes to include/upscommon.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-07-20 19:48:50 UTC
  • mto: (16.1.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050720194850-oo61wjr33rrx2mre
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* upscommon.h - prototypes for upscommon.c
2
 
 
3
 
   Copyright (C) 1999  Russell Kroll <rkroll@exploits.org>
4
 
 
5
 
   This program is free software; you can redistribute it and/or modify
6
 
   it under the terms of the GNU General Public License as published by
7
 
   the Free Software Foundation; either version 2 of the License, or
8
 
   (at your option) any later version.
9
 
 
10
 
   This program is distributed in the hope that it will be useful,
11
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
   GNU General Public License for more details.
14
 
 
15
 
   You should have received a copy of the GNU General Public License
16
 
   along with this program; if not, write to the Free Software
17
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
 
*/
19
 
 
20
 
#include "config.h"
21
 
 
22
 
#if defined(HAVE_SYS_TERMIOS_H)
23
 
#  include <sys/termios.h>      /* for speed_t */
24
 
#else
25
 
#  error "No <sys/termios.h> available.  Unable to continue."
26
 
#endif /* HAVE_SYS_TERMIOS_H */
27
 
 
28
 
#include "shared.h"
29
 
#include "upshandler.h"
30
 
 
31
 
/* useful values for new set/instcmd handlers */
32
 
 
33
 
#define STAT_INSTCMD_HANDLED    0x0001          /* all we do for now */
34
 
#define STAT_INSTCMD_UNKNOWN    0x0002
35
 
/* FUTURE: add details: pass/fail, etc */
36
 
 
37
 
#define STAT_SET_HANDLED        0x0010
38
 
#define STAT_SET_UNKNOWN        0x0011
39
 
/* FUTURE: same */
40
 
 
41
 
/* called by alarm signal when the port open fails */
42
 
void openfail(int sig);
43
 
 
44
 
/* lock the serial port using flock or uu_lock */
45
 
void lockport(int upsfd, const char *port);
46
 
 
47
 
/* try to open the port at a given speed */
48
 
void open_serial_simple(const char *port, speed_t speed, int flags);
49
 
void open_serial(const char *port, speed_t speed);
50
 
 
51
 
/* function for erasing "timeout"-conditions */
52
 
void nolongertimeout(void);
53
 
 
54
 
/* alarm signal handler for when serial reads time out */
55
 
void timeout(int sig);
56
 
 
57
 
/* receive up to buflen bytes from the ups into buf until endchar is read */
58
 
/* any characters received that match members of ignchars are discarded */
59
 
int upsrecv(char *buf, int buflen, char endchar, const char *ignchars);
60
 
 
61
 
/* read buflen chars and store in buf */
62
 
int upsrecvchars(char *buf, int buflen);
63
 
 
64
 
/* send a byte to the ups */
65
 
int upssendchar(char data);
66
 
/* send a string to the ups */
67
 
int upssend(const char *fmt, ...);
68
 
 
69
 
/* flush any pending input from the ups, with reporting */
70
 
void upsflushin(int expected, int debugit, const char *ignchars);
71
 
 
72
 
/* --- old stuff starts here --- */
73
 
 
74
 
/* store data into the array */
75
 
void setinfo(int infotype, const char *fmt, ...);
76
 
 
77
 
/* set the flags on an existing member of the array */
78
 
void setflag(int infotype, int newflags);
79
 
 
80
 
/* return the data in the info array with type infotype */
81
 
const char *getdata(int infotype);
82
 
 
83
 
/* add another type to the info array */
84
 
void addinfo(int type, const char *value, int flags, int auxdata);
85
 
 
86
 
/* add a new ENUM info entry and do other related housekeeping */
87
 
void addenum(int basetype, const char *value);
88
 
 
89
 
/* --- old stuff ends here --- */
90
 
 
91
 
/* clean out the temp space for a new pass */
92
 
void status_init(void);
93
 
 
94
 
/* add a status element */
95
 
void status_set(char *buf);
96
 
 
97
 
/* write the temporary status_buf into ups.status */
98
 
void status_commit(void);
99
 
 
100
 
extern struct ups_handler upsh;
101
 
extern int upsfd;
102
 
extern int flag_timeoutfailure;
103
 
extern unsigned int upssend_delay;
104
 
 
105
 
extern int experimental_driver;
106
 
 
107
 
void rtrim(char *in, char sep);
108
 
void unlockport(int upsfd, const char *port);
109
 
void exit_cleanup(void);
110
 
 
111
 
/* install handlers for TERM/QUIT/INT and HUP/PIPE */
112
 
void setup_signals(void);