/*
 *  libmodem library, a modem control facility.
 *
 *  modems.h - main header file of the libmodem package
 *
 *  Copyright (C) 1994, 1995  Riccardo Facchetti
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  You can contact the author at this e-mail address:
 *
 *  riccardo@cdc8g5.cdc.polimi.it
 */

/*
 * avoid multiple inclusion
 */
#ifndef _LM_MODEMS_H
#define _LM_MODEMS_H 1

/*
 * standard includes needed for the headers to work
 */
#include <sys/types.h>

/*
 * Some useful defines
 */
#ifndef MAXNAMLEN
#define MAXNAMLEN    255
#endif /* MAXNAMLEN */

#ifndef FAILURE
#define FAILURE        0
#endif /* FAILURE */

#ifndef SUCCESS
#define SUCCESS        1
#endif /* SUCCESS */

#define LIBMODEM_VER    "0.99.2"

#include <dial/mdmerrno.h>

/*
 * MDMFILE: the standard system modems description file
 */
#define MDMFILE        "/etc/modems"

/*
 * LOCKDIR: the locks directory
 */
#define LOCKDIR        "/var/spool/uucp"

/*
 * This is the include file related to /etc/modems file.
 */
#define MAXMDMCMD    20

/*
 * Flow control values in /etc/modems
 */
#define FLOW_HARD        0
#define FLOW_XON_XOFF    1

struct modems {
    char line[MAXNAMLEN];    /* line name (without /dev/) */
    char cp[MAXMDMCMD];        /* command prefix */
    char ce[MAXMDMCMD];        /* command end */
    char at[MAXMDMCMD];        /* attention string */
    time_t    dl;                /* delay waiting answer from modem */
    int bd;                    /* max baud rate */
    char cs[MAXMDMCMD];        /* connect string */
    char ds[MAXMDMCMD];        /* dial string */
    char de[MAXMDMCMD];        /* dial end */
    char im[MAXMDMCMD];        /* initialize modem */
    char hu[MAXMDMCMD];        /* hangup string */
    int fc;                    /* flow control */
};

/*
 * extern declarations (exported functions and variables from libmodem.a)
 */

/* modems.c */
extern struct modems *getmdmnam(char *);
extern void setmdms(void);
extern struct modems *getnextmdm(void);

/* line_manage.c */
extern int dial(char *);
extern int ldial(char *, char *);
extern int bdial(char *, int);
extern int bldial(char *, char *, int);
extern int close_nohangup(int);
extern int hangup(int);
extern struct modems *getopenmodem(void);
extern int hangup_nodev(int);
extern int clear_line(int, int);

extern struct modems *mdmopendevice;

/* mdmlock.c */
extern int mdm_lock(struct modems *);
extern int mdm_unlock(struct modems *);
extern int mdm_chklock(struct modems *);

/* mdmlog.c */
void mdm_log(int, char *, ...);
void open_mdm_log (void);
void close_mdm_log (void);

#endif /* _LM_MODEMS_H */
