File: muxpect.h

package info (click to toggle)
mon 0.99.2-9%2Betch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 908 kB
  • ctags: 299
  • sloc: perl: 9,801; ansic: 778; sh: 372; makefile: 122
file content (72 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (5)
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
/*
 * $Id: muxpect.h 1.1 Sat, 26 Aug 2000 15:22:34 -0400 trockij $
 */

/*
 * Copyright (C) 1998 Jim Trocki
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program 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 General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _MUXPECT_H
#define _MUXPECT_H

struct chat_sess
{
    char		expect[BUFSIZ];
    char		send[BUFSIZ];
    struct chat_sess	*next;
};

typedef struct chat_sess chat_sess_t;

struct muxconn
{
    int			fd;
    char		hostname[80];
    struct sockaddr_in	saddr;
    unsigned short	port;
    time_t		timeout;
    char		buf[8192];
    int			buf_offset;
    chat_sess_t		*ch_sess;
    regex_t		re_preg;
    char		re_errbuf[100];
    int			status;
    char		summ[80];
    char		detail[8192];
    struct muxconn	*next;
};

typedef struct muxconn muxconn_t;

/* status values */

#define MUXCONN_FAILURE		0	/* chat failure */
#define MUXCONN_SUCCESS		1	/* chat success */
#define MUXCONN_TIMEOUT		2	/* chat timeout */
#define MUXCONN_INPROGRESS	3	/* in progress (not complete) */
#define MUXCONN_SETUP		4	/* setup state */

int match_buffer (regex_t *, char *, char *, char *, int);
struct chat_sess *read_expect (char *file);
void dump_chat_sess (chat_sess_t *);
void usage (void);
muxconn_t * setup_muxconn_struct (char **, int, chat_sess_t *,
	unsigned short port, char *, int);
int setup_connect (muxconn_t *, char *, int);
int io_loop (muxconn_t *, int, char *, int);

#endif /* _MUXPECT_H */