1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
|
#ifndef ___MGETTY_H
#define ___MGETTY_H
#ident "$Id: mgetty.h,v 4.35 2018/03/06 11:37:51 gert Exp $ Copyright (c) Gert Doering"
/* mgetty.h
*
* contains most of the constants and prototypes necessary for
* mgetty+sendfax (except some fax constants, they are in fax_lib.h)
*
* $Log: mgetty.h,v $
* Revision 4.35 2018/03/06 11:37:51 gert
* Alex Manoussakis: cid-program patch set
*
* Revision 4.34 2014/01/31 13:02:08 gert
* move clean_line() from modem.c to clean_line.c
*
* Revision 4.33 2014/01/31 10:05:45 gert
* add prototype for connect_to_remote_tty()
* move clean_line() prototype to "modem.c" section
* add port_type_t enum to differenciate modem handling on port type
*
* Revision 4.32 2014/01/28 12:21:15 gert
* add safe_strdup()
*
* Revision 4.31 2010/09/22 09:00:29 gert
* move handle_incoming_sms() prototype from mgetty.h to mgetty.c - the easy
* way to work around uid_t and gid_t not being defined in all .c files
*
* Revision 4.30 2010/09/17 15:37:06 gert
* add new action enums: A_SMS_IN, A_SMS_REPORT (SMS handler)
* add prototype for handle_incoming_sms() -> sms.c
*
* Revision 4.29 2005/12/31 15:52:45 gert
* move typedef...uch from class1.h to mgetty.h
*
* Revision 4.28 2005/11/26 13:48:16 gert
* GNU/kFreeBSD portability changes
*
* Revision 4.27 2005/04/25 15:29:20 gert
* proper prototype for rmlocks()
* set SIG_HDLR_ARGS correctly on AIX5 (needs -DAIX5 in CFLAGS)
*
*/
#include "ugly.h"
/* some generic, useful defines */
#ifndef ERROR
#define ERROR -1
#define NOERROR 0
#endif
#ifndef TRUE
#define TRUE (1==1)
#define FALSE (1==0)
#endif
#define FAIL -1
#define SUCCESS 0
/* defines for FIDO mailers */
#define TSYNC 0xae
#define YOOHOO 0xf1
/* defines for auto detection of incoming PPP calls (->PAP/CHAP) */
#define PPP_FRAME 0x7e /* PPP Framing character */
#define PPP_STATION 0xff /* "All Station" character */
#define PPP_ESCAPE 0x7d /* Escape Character */
#define PPP_CONTROL 0x03 /* PPP Control Field */
#define PPP_LCP_HI 0xc0 /* LCP protocol - high byte */
#define PPP_LCP_LOW 0x21 /* LCP protocol - low byte */
#define PPP_UNESCAPE(c) ((c) ^ 0x20) /* un-escape character */
/* stuff in logfile.c */
#define L_FATAL 0
#define L_ERROR 1
#define L_AUDIT 2
#define L_WARN 3
#define L_MESG 4
#define L_NOISE 5
#define L_JUNK 6
void log_init_paths _PROTO(( char * program, char * path, char * infix ));
void log_set_llevel _PROTO(( int level ));
void log_close _PROTO((void));
int lputc _PROTO(( int level, char ch ));
int lputs _PROTO(( int level, char * s ));
#ifdef USE_VARARGS
int lprintf _PROTO(());
#else
int lprintf _PROTO((int level, const char *format, ...));
#endif
/* various defines */
/* bsd stuff */
#if defined(__BSD_NET2__) || defined(__386BSD__) || \
defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \
defined(__MACH__)
# include <sys/param.h> /* defines BSD, BSD4_3 and BSD4_4 */
# ifndef BSD
# define BSD /* just in case... */
# endif
# if defined(__FreeBSD__) && !defined(__FreeBSD_version)
# include <osreldate.h> /* FreeBSD version */
# endif
#endif
/* some versions of BSD have their own variant of fgetline that
* behaves differently. Just change the name for now...
* FIXME.
*/
#ifdef BSD
# define fgetline mgetty_fgetline
#endif
/* define here what function to use for polling for characters
* Chose one of the following: USE_SELECT, USE_POLL, USE_READ
* I recommend USE_SELECT on all machines that have it, except SCO Unix,
* since the tv_usec timer is not exact at all on SCO.
* If your System has the "nap(S)" call, you can use this instead of
* select(S) or poll(S) for sleeping less than one second.
* Ditto for usleep(S), for systems having it.
*/
#if defined(linux) || defined(_AIX)
# define USE_USLEEP
#endif
#if !defined(USE_POLL) && !defined(USE_READ)
#define USE_SELECT
#endif
/* SunOS4 does not have memmove, but bcopy handles overlapping copies
* as well. Watch out for src/dst argument order!
*/
#if defined(sunos4) || defined(NEED_MEMMOVE)
# define memmove(dst, src, len) bcopy(src, dst, len)
#endif
/* these definitions specify the return value type and the arguments
* for signal handler functions - if your compiler barfs, change them
*/
typedef void RETSIGTYPE;
# define SIG_HDLR_ARGS int signo
typedef char boolean;
typedef unsigned char uch;
/* the cpp directive "sun" isn't useful at all, since is defined on
* SunOS 4, Solaris 2, and even Solaris x86...
* So, you have to define -Dsunos4, -Dsolaris2, or -Dsolaris86.
* Otherwise: barf!
*/
#ifdef sun
# if !defined( sunos4 ) && !defined( solaris2 ) && !defined( solaris86 )
# error "Please define -Dsunos4 or -Dsolaris2 or -Dsolaris86"
# endif
#endif
#ifdef solaris2
# define SVR4
# define SVR42
# ifndef sun
# define sun
# endif
#endif
/* SGI's are SVR4... (jwz@netscape.com) */
#ifdef __sgi
# define SVR4
# define SVR42
#endif
/* assume that all BSD systems have the siginterrupt() function
* for GNU libc 2.x, we need it as well (default behaviour is now "restart")
*/
#if defined(BSD) || defined(sunos4) ||\
( defined(__GLIBC__) && __GLIBC__ >= 2 )
# ifndef NO_SIGINTERRUPT
# define HAVE_SIGINTERRUPT
# endif
#endif
/* assume that some systems do not have long filenames...
*/
#if ( defined(m88k) && !defined(SVR4) )
# ifndef SHORT_FILENAMES
# define SHORT_FILENAMES
# endif
#endif
/* On systems we know mmap() works, it will be used for reading G3
* files in the tools (g3topbm.c, g3cat.c), because it is a lot faster
*/
#if defined(linux) || defined(BSD)
# define HAVE_MMAP
#endif
/* recent systems have mkstemp(), and it's more secure than mktemp()
* SCO does not have it, though :-(
*/
#if !defined(M_UNIX) && !defined(_3B1_)
# define HAVE_MKSTEMP
#endif
/* On a ALPHA, the config routines won't work, unless we change the
* union to use "void *" and "long", instead of "int" (see config.h).
* Same for Sparc Ultra machines [at least with SparcLinux]
*/
#ifdef __LP64__
# define PTR_IS_LONG
#endif
#define MAXLINE 1024 /* max. # chars in a line */
#define MAXPATH MAXLINE
#define STDIN 0
typedef enum {
A_TIMOUT, A_FAIL, A_FAX, A_VCON, A_CONN,
A_RING1, A_RING2, A_RING3, A_RING4, A_RING5,
A_SMS_IN, A_SMS_REPORT
} action_t;
typedef struct chat_actions {
char * expect;
action_t action; } chat_action_t ;
/* what sort of file descriptor are we talking to? */
typedef enum {
PT_TTY, /* regular unix tty with POSIX */
PT_RAW_SOCKET, /* network socket, no modem control */
PT_2217_SOCKET /* network socket, RFC2217, telnet proto */
} port_type_t;
/* do_chat.c */
int do_chat _PROTO(( int filedesc, char * expect_send[],
chat_action_t actions[], action_t * action,
int chat_timeout_time, boolean timeout_first ));
int do_chat_send _PROTO(( int filedesc, char * send_str_with_esc ));
/* ring.c */
int wait_for_ring _PROTO(( int filedesc, char ** msn_list, int timeout,
chat_action_t actions[], action_t * action,
int * dist_ring_number ));
/* do_stat.c */
void get_statistics _PROTO(( int filedesc, char ** chat, char * file ));
/* goodies.c */
char * get_basename _PROTO(( char * ));
char * mydup _PROTO(( char *s ));
char * get_ps_args _PROTO(( int pid ));
char * safe_strdup _PROTO(( char * ));
/* io.c */
boolean check_for_input _PROTO (( int fd ));
boolean wait_for_input _PROTO (( int fd, int seconds ));
void delay _PROTO(( int waittime ));
/* locks.c */
#define NO_LOCK 0 /* returned by checklock() if no lock found */
int makelock _PROTO((char * device));
int makelock_file _PROTO(( char * lockname ));
int checklock _PROTO((char * device));
void rmlocks _PROTO ((void));
int steal_lock _PROTO((char * device, int pid ));
/* fax stuff */
void faxrec _PROTO(( char * spool_dir, unsigned int switchbd,
int uid, int gid, int mode, char * mail_to ));
char * fax_strerror _PROTO(( int fax_hangup_code ));
void faxlib_init _PROTO((void));
extern int modem_quirks;
/* initialization stuff: mg_m_init.c */
int mg_init_data _PROTO(( int fd, char * chat_seq[],
boolean need_dsr, char * force_seq[]));
int mg_init_fax _PROTO(( int fd, char * mclass, char * fax_id,
boolean fax_only, int fax_max_speed ));
int mg_init_voice _PROTO(( int fd ));
void faxpoll_server_init _PROTO(( int fd, char * fax_server_file ));
int mg_open_device _PROTO(( char * devname, boolean blocking ));
int mg_init_device _PROTO(( int fd, boolean toggle_dtr,
int toggle_dtr_waittime,
unsigned int portspeed ));
int mg_get_device _PROTO(( char * devname, boolean blocking,
boolean toggle_dtr, int toggle_dtr_waittime,
unsigned int portspeed ));
int mg_get_ctty _PROTO(( int fd, char * devname ));
int mg_drop_ctty _PROTO(( int fd ));
/* modem.c */
int mdm_send _PROTO(( char * send, int fd ));
int mdm_read_byte _PROTO(( int fd, char * c ));
char * mdm_get_line _PROTO(( int fd ));
int mdm_command _PROTO(( char * send, int fd ));
char * mdm_get_idstring _PROTO(( char * send, int n, int fd ));
/* clean_line.c */
int clean_line _PROTO(( int filedesc, int tenths ));
/* socket.c */
#ifdef FAX_SEND_SOCKETS
int connect_to_remote_tty _PROTO(( char * fax_tty ));
#endif
/* logname.c */
char * ln_escape_prompt _PROTO(( char * prompt ));
void set_env_var _PROTO(( char * var, char * string ));
/* login stuff */
void login_dispatch _PROTO(( char * user, boolean is_callback, char * cf));
void setup_environment _PROTO(( void ));
/* how long should I wait for a string from modem */
#define FAX_RESPONSE_TIMEOUT 120
/* how much time may pass while receiving a fax without getting data */
#define FAX_PAGE_TIMEOUT 60
/* cnd.c */
extern char *Connect;
extern char *CallerId;
extern char *CallDate;
extern char *CallTime;
extern char *CallName;
extern char *CalledNr;
void cndfind _PROTO((char *str));
int cndlookup _PROTO((void));
int cnd_call _PROTO((char *name, char *tty, int dist_ring ));
/* disk statistics retrieval in getdisk.c */
struct mountinfo {
long mi_bsize; /* fundamental block size */
long mi_blocks; /* number of blocks in file system */
long mi_bfree; /* number of free blocks in file system */
long mi_bavail; /* blocks available to non-super user */
long mi_files; /* number of file nodes in file system */
long mi_ffree; /* number of free nodes in fs */
};
typedef struct mountinfo mntinf;
extern long minfreespace;
int checkspace _PROTO((char *path));
int getdiskstats _PROTO ((char *path, mntinf *mi));
/********* system prototypes **************/
extern char * mktemp _PROTO(( char * template ));
#if !defined(linux) && !defined(SVR4) && !defined(__hpux) && \
!defined(BSD) && !defined(M_UNIX) && !defined(_AIX) && !defined(__GLIBC__)
extern int getopt _PROTO(( int, char **, char * ));
#endif
extern int optind;
extern char * optarg;
/* system specific stuff */
#ifdef ISC
#define fileno(p) (p)->_file
# ifndef O_NDELAY
# define O_NDELAY O_NONBLOCK
# endif
#endif
#if defined(_3B1_) || defined(MEIBE)
typedef ushort uid_t;
typedef ushort gid_t;
#endif
#if defined(NeXT)
# define NEED_PUTENV
# define NEED_STRDUP
char * strdup _PROTO(( char *src ));
#endif
/* hardware handshake flags for tio.c/tio.h
* we have to define them here, because otherwise config.c would break
*/
#define FLOW_NONE 0x00
#define FLOW_HARD 0x01 /* rts/cts */
#define FLOW_XON_IN 0x02 /* incoming data, send xon/xoff */
#define FLOW_XON_OUT 0x04 /* send data, honor xon/xoff */
#define FLOW_SOFT (FLOW_XON_IN | FLOW_XON_OUT)
#define FLOW_BOTH (FLOW_HARD | FLOW_SOFT )
#define FLOW_XON_IXANY 0x08 /* set IXANY flag together with IXON */
#endif /* ___MGETTY_H */
|