intern.h 2.37 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
2
3
/*
** intern.h                Definitions and prototypes used internally
**
Per Cederqvist's avatar
Per Cederqvist committed
4
** Copyright (c) 1991 Peter Eriksson and Per Cederqvist of the
Per Cederqvist's avatar
Per Cederqvist committed
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
**                    Lysator Academic Computer Association.
**
** history:
** 910305 pen      initial coding
*/

#ifndef __ISC_INTERNALS_H__
#define __ISC_INTERNALS_H__


/* isc_log.c */
extern void
isc_log(const char *format, ...);


/* isc_abort.c */
extern void
isc_abort(const char *message);


/* isc_alloc.c */
extern void *
isc_malloc(size_t length);

extern void *
isc_realloc(void *buf, size_t length);

extern void
isc_free(void *buf);

extern char *
isc_strdup(const char *str);


/* isc_queue.c */
extern IscMsgQueue *
isc_newqueue(void);

43
#if 0
Per Cederqvist's avatar
Per Cederqvist committed
44
45
extern int
isc_pollqueue(IscMsgQueue *queue);
46
47
48
#else
#define isc_pollqueue(qp)	((qp) != NULL && ((qp)->head != NULL))
#endif
Per Cederqvist's avatar
Per Cederqvist committed
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

extern void
isc_killqueue(IscMsgQueue *queue);

extern void
isc_pushqueue(IscMsgQueue *queue, IscMessage *msg);

extern IscMessage *
isc_topqueue(IscMsgQueue *queue);

extern int
isc_sizequeue(IscMsgQueue *queue);

extern IscMessage *
isc_popqueue(IscMsgQueue *queue);


extern IscMessage *
isc_default_read_fn(IscHandlerList *hl, IscSession *scb);

extern int
isc_default_write_fn(IscHandlerList *hl, IscSession *scb, IscMessage *msg);

extern int
isc_default_close_fn(IscHandlerList *hl, IscSession *scb);


extern IscAddress *
isc_mkipaddress(struct sockaddr *addr);


extern void
isc_oflush(IscSession  * scb);


/*
** Setup a set of functions to handle memory allocation
*/
extern void
isc_setallocfn(void  * (*mallocfn)(size_t size),
               void  * (*reallocfn)(void  * buf, size_t size),
	       void    (*freefn)(void  * buf));



/*
** Setup a function to handle fatal abort requests
*/
extern void
isc_setabortfn(void (*abortfn)(const char  * msg));


101
102
103
104
105
106
107
108
109
110
/*
 * Move a file descriptor FD the first unused file descriptor higher
 * than LIMIT.  Return the new file descriptor.  Close FD.
 *
 * On failure, the old FD will be returned, and errno will be set.
 *
 * Do nothing (and return FD) if LIMIT is 0.
 */
extern int
isc_relocate_fd(int fd, int limit);
Per Cederqvist's avatar
Per Cederqvist committed
111
112
113
114
115
116


#define ISC_XNEW(var)   (var = isc_malloc(sizeof(*var)))


#define ISC_SCALLFUN1(SCB, NAME, ARG) \
117
	ISC_HCALLFUN1(SCB->handlers, NAME, ARG)
Per Cederqvist's avatar
Per Cederqvist committed
118
119
	
#define ISC_SCALLFUN2(SCB, NAME, A1, A2) \
120
	ISC_HCALLFUN2(SCB->handlers, NAME, A1, A2)
Per Cederqvist's avatar
Per Cederqvist committed
121
122
	
#define ISC_SCALLFUN3(SCB, NAME, A1, A2, A3) \
123
	ISC_HCALLFUN3(SCB->handlers, NAME, A1, A2, A3)
Per Cederqvist's avatar
Per Cederqvist committed
124
125
126


#endif