1 /** 2 * libqcproto: Vypress/QChat protocol interface library 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 /* 20 * QCS: qChat 1.6/VypressChat link interface 21 * 22 * (c) Saulius Menkevicius 2001-2004 23 */ 24 25 #ifndef QCPROTO_H__ 26 #define QCPROTO_H__ 27 28 /* API constants 29 */ 30 enum qcs_proto { 31 QCS_PROTO_QCHAT, 32 QCS_PROTO_VYPRESS, 33 QCS_PROTO_NUM 34 }; 35 enum qcs_proto_opt { 36 QCS_PROTO_OPT_MULTICAST = 0x01 37 }; 38 39 enum qcs_umode { 40 QCS_UMODE_INVALID, 41 QCS_UMODE_NORMAL, 42 QCS_UMODE_DND, 43 QCS_UMODE_AWAY, 44 QCS_UMODE_OFFLINE 45 }; 46 47 enum qcs_msgid { 48 QCS_MSG_INVALID, 49 50 /* MSG_REFRESH_REQUEST: 51 * QCS_SRC requestor 52 */ 53 QCS_MSG_REFRESH_REQUEST, 54 55 /* MSG_REFRESH_ACK: 56 * QCS_SRC ACK sender 57 * QCS_DST ACK receiver 58 * 59 * umode sender mode 60 * uactive non-0 if the user is active 61 */ 62 QCS_MSG_REFRESH_ACK, 63 64 /* MSG_CHANNEL_BROADCAST: 65 * QCS_SRC sender 66 * QCS_TEXT text that goes to the channel 67 * QCS_CHAN channel name (#chan format) 68 */ 69 QCS_MSG_CHANNEL_BROADCAST, 70 71 /* MSG_CHANNEL_JOIN: 72 * QCS_SRC user 73 * QCS_CHAN channel name (#chan) 74 * 75 * umode user mode 76 */ 77 QCS_MSG_CHANNEL_JOIN, 78 79 /* MSG_CHANNEL_LEAVE: 80 * QCS_SRC user 81 * QCS_CHAN channel name 82 */ 83 QCS_MSG_CHANNEL_LEAVE, 84 85 /* MSG_CHANNEL_ME 86 * QCS_SRC user 87 * QCS_TEXT text 88 * QCS_CHAN channel name 89 */ 90 QCS_MSG_CHANNEL_ME, 91 92 /* MSG_MESSAGE_SEND: 93 * QCS_SRC sender 94 * QCS_DST receiver 95 * QCS_TEXT msg text 96 */ 97 QCS_MSG_MESSAGE_SEND, 98 99 /* MSG_MESSAGE_MASS: 100 * QCS_SRC sender 101 * QCS_DST receiver (each on the net will get this text) 102 * QCS_TEXT msg text 103 */ 104 QCS_MSG_MESSAGE_MASS, 105 106 /* MSG_MESSAGE_ACK: 107 * QCS_SRC sender of ACK 108 * QCS_DST receiver of ACK 109 * QCS_TEXT ack text 110 * 111 * umode mode of the sender 112 */ 113 QCS_MSG_MESSAGE_ACK, 114 115 /* MSG_RENAME: 116 * QCS_SRC previous nickname 117 * QCS_TEXT new nickname 118 */ 119 QCS_MSG_RENAME, 120 121 /* MSG_MODE_CHANGE: 122 * QCS_SRC user 123 * 124 * umode new mode 125 */ 126 QCS_MSG_MODE_CHANGE, 127 128 /* MSG_ACTIVE_CHANGE: 129 * QCS_SRC user 130 * 131 * uactive non-0 if the user became active, 0 otherwise 132 */ 133 QCS_MSG_ACTIVE_CHANGE, 134 135 /* MSG_TOPIC_CHANGE: 136 * QCS_TEXT new topic 137 * QCS_CHAN channel name 138 */ 139 QCS_MSG_TOPIC_CHANGE, 140 141 /* MSG_TOPIC_REPLY: 142 * QCS_DST receiver of topic text 143 * QCS_TEXT current topic 144 */ 145 QCS_MSG_TOPIC_REPLY, 146 147 /* MSG_INFO_REQUEST: 148 * QCS_SRC sender of request-for-info 149 * QCS_DST receiver of request 150 */ 151 QCS_MSG_INFO_REQUEST, 152 153 /* MSG_INFO_REPLY: 154 * QCS_SRC info about this user 155 * QCS_DST receiver of info 156 * QCS_TEXT (login name??) 157 * QCS_CHAN channels the user is on 158 * QCS_SUPP user's motd 159 */ 160 QCS_MSG_INFO_REPLY, 161 162 /* MSG_CHANMEMBER_REQUEST: 163 * QCS_SRC requestor for replies of channel members 164 * (where to send replies) 165 */ 166 QCS_MSG_CHANMEMBER_REQUEST, 167 168 /* MSG_CHANMEMBER_REPLY: 169 * QCS_SRC name of sender 170 * QCS_DST name of receiver of replies 171 * QCS_CHAN channels the sender is on (#..#..#) 172 */ 173 QCS_MSG_CHANMEMBER_REPLY, 174 175 /* MSG_CHANLIST_REQUEST: 176 * QCS_SRC name of requestor 177 */ 178 QCS_MSG_CHANLIST_REQUEST, 179 180 /* MSG_CHANLIST_REPLY: 181 * QCS_DST requestor 182 * QCS_CHAN channels the replier is on 183 */ 184 QCS_MSG_CHANLIST_REPLY, 185 186 /* MSG_BEEP_SEND: 187 * QCS_SRC sender of beep 188 * QCS_DST receiver of beep 189 */ 190 QCS_MSG_BEEP_SEND, 191 192 /* MSG_BEEP_ACK: 193 * QCS_SRC sender of ack (receiver of beep) 194 * QCS_DST receiver of ack 195 */ 196 QCS_MSG_BEEP_ACK, 197 198 /* MSG_PRIVATE_OPEN: 199 * QCS_SRC sender of private open request 200 * QCS_DST receiver of request 201 */ 202 QCS_MSG_PRIVATE_OPEN, 203 204 /* MSG_PRIVATE_CLOSE: 205 * QCS_SRC sender of private-close request 206 * QCS_DST another party of private 207 */ 208 QCS_MSG_PRIVATE_CLOSE, 209 210 /* MSG_PRIVATE_TEXT: 211 * QCS_SRC sender 212 * QCS_DST receiver 213 * QCS_TEXT text 214 * 215 */ 216 QCS_MSG_PRIVATE_TEXT, 217 218 /* MSG_PRIVATE_ME: 219 * QCS_SRC sender 220 * QCS_DST receiver 221 * QCS_TEXT text 222 */ 223 QCS_MSG_PRIVATE_ME 224 }; 225 226 enum qcs_textid { 227 QCS_SRC, 228 QCS_DST, 229 QCS_TEXT, 230 QCS_SUPP, 231 QCS_CHAN 232 }; 233 234 /* qcs_msg: 235 * protocol message type */ 236 typedef struct _qcs_msg { 237 enum qcs_msgid msg; /* message ID */ 238 enum qcs_umode umode; /* user mode: offline/dnd, etc | watch */ 239 unsigned long src_ip; /* IP address of message source */ 240 int uactive; /* used to notify if the user is active */ 241 char * src; /* src nickname */ 242 char * dst; /* dst nickname */ 243 char * text; 244 char * supp; /* supplementary text */ 245 char * chan; /* channels (in '#Main#...#' form) */ 246 } qcs_msg; 247 248 #ifdef __cplusplus 249 extern "C" { 250 #endif 251 252 typedef void* qcs_link; 253 254 /* qcs_open 255 * initializes network link */ 256 qcs_link qcs_open( 257 enum qcs_proto proto, 258 enum qcs_proto_opt, 259 unsigned long broadcast_addr, /* can be multicast addr */ 260 unsigned short port); 261 262 /* qcs_close 263 * close specified link */ 264 int qcs_close(qcs_link link); 265 266 /* qcs_rxsocket 267 * return RX socket identifier */ 268 int qcs_rxsocket( 269 qcs_link link, 270 int * p_rxsocket ); /* pointer to id store */ 271 272 /* qcs_waitinput 273 * for RX input, or return in non-blocking mode (if timeout==0) 274 * returns: 275 * 0 if timed-out 276 * >0 if input pending 277 * <0, if error (see errno) 278 */ 279 int qcs_waitinput( 280 qcs_link link, 281 int timeout_ms ); /* msecs to wait before timeout */ 282 283 /* qcs_send 284 * sends message to the link */ 285 int qcs_send( 286 qcs_link link, 287 const qcs_msg * msg ); 288 289 /* qcs_recv 290 * retrieves message from the link */ 291 int qcs_recv( 292 qcs_link link, 293 qcs_msg * msg ); 294 295 /* qcs_newmsg 296 * qcs_deletemsg 297 * (de)allocates & initializes new message struct */ 298 qcs_msg * qcs_newmsg(); 299 300 void qcs_deletemsg( 301 qcs_msg * msg ); /* msg to delete */ 302 303 /* qcs_msgset 304 * sets message text parameter 305 */ 306 int qcs_msgset( 307 qcs_msg * msg, 308 enum qcs_textid which, 309 const char * new_text ); 310 311 #ifdef __cplusplus 312 } 313 #endif 314 315 #endif /* #ifdef QCPROTO_H__ */ 316