File: ptest.h

package info (click to toggle)
teknap 1.4-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,428 kB
  • ctags: 6,297
  • sloc: ansic: 55,591; makefile: 545; sh: 112
file content (96 lines) | stat: -rw-r--r-- 2,394 bytes parent folder | download
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
 /* $Id: ptest.h,v 1.1.1.1 2000/06/24 11:08:42 edwards Exp $ */
 
/*
 * cdns.h: header for cdns.c
 */

#ifndef _PTEST_H_
#define _PTEST_H_

/* We gotta know about the fd_set type, so we gonna inclue this  */
#include "teknap.h"
#if defined(TEKNAP)
#include "struct.h"
#include "newio.h"
#endif

typedef struct ptest_struct {
	/* 'host': This is the string we want to resolve. It can be
	 * either a host or ip. The string WILL be malloc'ed by
	 * the "add" function. Do NOT malloc or free this variable!
	 */
        char *host;

	char *alias;
	
	/* 'port': This is the port we want to connect to. It can be
	 * either a host or ip.
	 */
        int port;

	/* 'result': This is the "result" of the connect. "man connect"
	 * for the possible ints that could be returned.
	 */
        int result;

	/* 'r_errno': If the connect failed, This will contain
	 * the result errno that was set to when it failed.
	 */
        int r_errno;

	/* 'callback': This is our callback function. When our 'in' gets
	 * resolved, we will call this function, with this structure
	 * as our parameter. Do NOT malloc or free this variable.
	 */
	void (*callback) (int, int, void *); /* Our callback function */

	/* 'callinfo': This allows us to store information that you might
	 * need for later use when in your 'callback' function. This is
	 * just a void pointer, so you MUST malloc any of the data you want to
	 * store here. Once you are done with this variable, you must
	 * free it!!! BEWARE BEWARE, YOU MUST FREE THIS VARIABLE YOURSELF!
	 */
	void *callinfo;

	/* 'next': Internally used. our "next" pointer. */
        struct ptest_struct *next;
} PTEST_QUEUE;

void start_ptest(void);
void stop_ptest(void);
void kill_ptest(void);
void set_ptest_output_fd(fd_set *);
void ptest_check(fd_set *);
void check_ptest_queue(void);
void add_to_ptest_queue(char *, int, void (*) (int, int, void *), char *, void *, int);
void start_ptest(void);
void stop_ptest(void);
void do_ptestcall(char *, char *, char *);

#define PTEST_URGENT 1
#define PTEST_NORMAL 2

#ifndef Q_NEXT
#define Q_NEXT(tmp) ((tmp)->next)
#endif
#ifndef Q_OPEN
#define Q_OPEN(headp, tailp) (*(headp) = *(tailp) = NULL)
#endif

typedef struct {
	char *from;
	char *to;
	char *ip;
	int port;
	int server;
} PT_INFO;

typedef struct {
	/* Check for repeats */
	char *last_ip;
	int last_port;
} PT_STATS;

void free_pt_info(PT_INFO *);

#endif