]>
Commit | Line | Data |
---|---|---|
189935b1 | 1 | #ifndef INCLUDED_msgq_h |
2 | #define INCLUDED_msgq_h | |
3 | /* | |
4 | * IRC - Internet Relay Chat, include/msgq.h | |
5 | * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2, or (at your option) | |
10 | * any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | */ | |
21 | /** @file | |
22 | * @brief Outbound message queue interface and declarations. | |
23 | * @version $Id: msgq.h,v 1.8 2004/10/05 04:21:37 entrope Exp $ | |
24 | */ | |
25 | #ifndef INCLUDED_ircd_defs_h | |
26 | #include "ircd_defs.h" /* BUFSIZE */ | |
27 | #endif | |
28 | #ifndef INCLUDED_sys_types_h | |
29 | #include <sys/types.h> | |
30 | #define INCLUDED_sys_types_h | |
31 | #endif | |
32 | #ifndef INCLUDED_stdarg_h | |
33 | #include <stdarg.h> | |
34 | #define INCLUDED_stdarg_h | |
35 | #endif | |
36 | ||
37 | struct iovec; | |
38 | ||
39 | struct Client; | |
40 | struct StatDesc; | |
41 | ||
42 | struct Msg; | |
43 | struct MsgBuf; | |
44 | ||
45 | /** Queue of individual messages. */ | |
46 | struct MsgQList { | |
47 | struct Msg *head; /**< First Msg in queue list */ | |
48 | struct Msg *tail; /**< Last Msg in queue list */ | |
49 | }; | |
50 | ||
51 | /** Entire two-priority message queue for a destination. */ | |
52 | struct MsgQ { | |
53 | unsigned int length; /**< Current number of bytes stored */ | |
54 | unsigned int count; /**< Current number of messages stored */ | |
55 | struct MsgQList queue; /**< Normal Msg queue */ | |
56 | struct MsgQList prio; /**< Priority Msg queue */ | |
57 | }; | |
58 | ||
59 | /** Returns the current number of bytes stored in \a mq. */ | |
60 | #define MsgQLength(mq) ((mq)->length) | |
61 | ||
62 | /** Returns the current number of messages stored in \a mq. */ | |
63 | #define MsgQCount(mq) ((mq)->count) | |
64 | ||
65 | /** Scratch the current content of the buffer. | |
66 | * Release all allocated buffers and make it empty. | |
67 | */ | |
68 | #define MsgQClear(mq) msgq_delete((mq), MsgQLength(mq)) | |
69 | ||
70 | /* | |
71 | * Prototypes | |
72 | */ | |
73 | extern void msgq_init(struct MsgQ *mq); | |
74 | extern void msgq_delete(struct MsgQ *mq, unsigned int length); | |
75 | extern int msgq_mapiov(const struct MsgQ *mq, struct iovec *iov, int count, | |
76 | unsigned int *len); | |
77 | extern struct MsgBuf *msgq_make(struct Client *dest, const char *format, ...); | |
78 | extern struct MsgBuf *msgq_vmake(struct Client *dest, const char *format, | |
79 | va_list args); | |
80 | extern void msgq_append(struct Client *dest, struct MsgBuf *mb, | |
81 | const char *format, ...); | |
82 | extern void msgq_clean(struct MsgBuf *mb); | |
83 | extern void msgq_add(struct MsgQ *mq, struct MsgBuf *mb, int prio); | |
84 | extern void msgq_count_memory(struct Client *cptr, | |
85 | size_t *msg_alloc, size_t *msg_used); | |
86 | extern void msgq_histogram(struct Client *cptr, const struct StatDesc *sd, | |
87 | char *param); | |
88 | extern unsigned int msgq_bufleft(struct MsgBuf *mb); | |
89 | ||
90 | #endif /* INCLUDED_msgq_h */ |