home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume26
/
modempool
/
part01
/
modempool.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-05
|
6KB
|
203 lines
/*******************************************************************
*
* Module: @(#)modempool.h 4.4 92/04/22
*
* Description:
* Header file fore the modempool package.
*
* Revision:
* Date By Reason
* ---- -- ------
* 910414 Lars Berntzon Created
*
*******************************************************************/
#include "patchlevel.h"
static char SccsId_modempool_h[] = "@(#)modempool.h 4.4 92/04/22";
#ifndef _MODEMPOOL_H
#define _MODEMPOOL_H
#ifdef DEBUG
# define USERS "Users"
# define LINES "Lines"
# define LOGFILE "log"
# define ERRLOGFILE "errlog"
# define GREETINGSFILE "Greetings"
# define GREETINGSFILE "Greetings"
# define SERVERDB "serverdb"
# define LOCKFILE "serverdb.lock"
#else
# define USERS "/etc/local/modempool/Users"
# define LINES "/etc/local/modempool/Lines"
# define LOGFILE "/etc/local/modempool/log"
# define ERRLOGFILE "/etc/local/modempool/errlog"
# define GREETINGSFILE "/etc/local/modempool/Greetings"
# define SERVERDB "/etc/local/modempool/serverdb"
# define LOCKFILE "/etc/local/modempool/serverdb.lock"
#endif
#define LOCKDIR "/usr/spool/locks"
#define E_OK 0 /* No errors */
#define E_FAIL -1 /* Generic fail */
#define E_TMOUT -2 /* Got timeout */
#define E_SYNTAX -3 /* Syntax error */
#define E_OPEN -4 /* Failed to open file */
#define E_READ -5 /* Failed to read file */
#define E_WRITE -6 /* Failed to write file */
#define E_LOCK -7 /* Failed to lock */
#define E_UNLINK -8 /* Failed to unlink */
#define E_PROC_EXIST -9 /* Process alldready exist */
#define E_LOGIN -10 /* Failed to login */
#define E_NOTFOUND -11 /* Key not found */
#define E_EOF -12 /* Reached enf of file/data */
#define E_RETRY -13 /* Not completely wrong, try again */
#define INITSTRING "AT&FQ0E0S0=1&D2&C1\r" /* Modem init string */
/*
* Various messages to user.
*/
#define MSG_LOGIN "login: "
#define MSG_NAME "Name: "
#define MSG_PASSWD "Password: "
#define MSG_ABORTED "login aborted\r\n"
#define MSG_LOGINFAIL "login failed\r\n"
#define MSG_HANGUP "hanging up\r\n"
#define MSG_TIMEOUT "timed out\r\n"
#define MSG_CALLING "I will call you back, hang on.\r\n"
#define MSG_NOLINES "There are currently no free lines.\r\n"
#define MSG_USAGE "usage: modempool [-p prefix] [-i initstr] [-d] speed ttyxx\r\n"
#define MSG_PHONE "Phone: "
/*
* Return codes and arguments to/from mod_exp.
*/
#define MOD_ANY 0 /* Wait for any of the below */
#define MOD_CONNECT 1
#define MOD_CONNECT_300 2
#define MOD_CONNECT_1200 3
#define MOD_CONNECT_2400 4
#define MOD_RING 5
#define MOD_BUSY 6
#define MOD_ERRO 7
#define MOD_NO_CARRIER 8
#define MOD_OK 9
#define MOD_CONNECT_4800 10
#define MOD_CONNECT_9600 11
#define NAME_SIZE 200 /* Generic string size */
#define MATCH_SIZE 400 /* Maximum size of expected data from modem */
#define MAX_RETRY 3
#define OPEN_TMOUT (10*60) /* Timeout for opening the tty port */
#define LOGIN_TMOUT 30 /* Timeout for login */
#define MODEM_TMOUT 1 /* Default timeout for avaiting modem answer */
#define RESET_TMOUT 180 /* Interval for resetting modem when waiting */
#define DIALUP_TMOUT 60 /* Time for dialing a number */
#define DIALUP_DELAY 15 /* Time to wait before dialing */
#ifdef RLOGIN
#define N_FIELDS 4 /* Number if valid fields in user database */
#else
#define N_FIELDS 3
#endif
#define SLOT_FREE 0 /* Server is free for allocation */
#define SLOT_BUSY 1 /* Server is busy dialing person */
#define SLOT_LOGIN 2 /* Server is handling login */
#define SLOT_FAULT 3 /* Server has detected fault */
#define SIG_SERVER SIGUSR1
/*
* Types and structs.
*/
struct slot {
int id; /* Id for this slot */
char line[15]; /* Line this server controls */
char name[30]; /* Synonym for calling person */
#ifdef RLOGIN
char host[20]; /* Host for rlogin. */
#endif
int status; /* Status of server, SLOT_FREE e.t.c. */
int pid; /* pid of server */
char phone[15]; /* Phone number this server should dial */
int baud; /* What baud to use when dialing */
};
typedef struct slot slot_t; /* Type for slots */
/*
* Globals.
*/
extern char line[NAME_SIZE]; /* Name port this program is using */
extern char portname[NAME_SIZE];/* Full pathname of port */
extern char prefix[NAME_SIZE]; /* Prefix string before phone number */
extern slot_t slot; /* Slotid for this server in serverdb */
extern int signalled; /* Tells server it should dial a number */
extern int port_fd; /* File descriptor for open port */
extern int debug_lvl; /* Nonzero if debugging is active */
extern char *initstr; /* Modem initializing string */
/* support routines */
extern int debug(char *fmt, ...);
extern int debugnonl(char *fmt, ...);
extern int log(char *fmt, ...);
extern int logerr(char *fmt, ...);
extern void fatal(char *msg);
extern void usage(void);
extern int trig(int tmout);
extern int istimeout(void);
/* db routines */
extern int db_find(char *file, char **ptrs, int n_ptrs,int key, char *key_val);
/* mod routines */
extern mod_put(char *msg);
extern mod_exp(int cmd, int tmout);
extern mod_dial(char *prefix, char *phone);
extern int mod_setup(void);
/* slot routines */
extern int slot_alloc(slot_t *sp);
extern int slot_free(slot_t *sp);
extern int slot_open(void);
extern int slot_close(void);
extern int slot_traverse(slot_t *sp);
extern int slot_read(slot_t *sp);
extern int slot_write(slot_t *sp);
extern int slot_lock(void);
extern int slot_unlock(void);
/* tty routines */
extern int tty_open(char *filename, int baud, int flags);
extern int tty_close(void);
extern int tty_read(char *buf, int len);
extern int tty_write(char *buf, int len);
extern int tty_ndelay(int on);
extern int tty_hangup(void);
extern int tty_raw(void);
extern int tty_sane(void);
extern int tty_baud(int baud);
extern int tty_setup(void);
extern int tty_clocal(void);
extern int tty_echo(void);
extern int tty_noecho(void);
extern int tty_drain(void);
extern int tty_flush(void);
/* lock routines */
extern int lock_line(char *line, int pid);
extern int unlock_line(char *line);
extern int relock_line(char *line);
extern int lock_wait(char *line);
/* getargs */
extern int getargs(int *argc, char ***argv);
/* dialup and login routines */
extern int do_login(slot_t *sp);
extern int callback(slot_t *sp);
#endif /* _MODEMPOOL_H */