[go: up one dir, main page]

Menu

[r456]: / tags / miau-0-6-1 / src / irc.h  Maximize  Restore  History

Download this file

162 lines (126 with data), 4.8 kB

  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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* $Id$
* -------------------------------------------------------
* Copyright (C) 2002-2006 Tommi Saviranta <wnd@iki.fi>
* (C) 2002 Lee Hardy <lee@leeh.co.uk>
* (C) 1998-2002 Sebastian Kienzl <zap@riot.org>
* -------------------------------------------------------
* 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.
*/
#ifndef IRC_H_
#define IRC_H_
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#include "server.h"
#include "client.h"
#define QUEUESIZE 16
/*
* 520 characters should be enough for all PRIVMSGs and ACTIONs.
* RFC2812 says "IRC messages are always lines of characters terminated with a
* CR-LF (Carriage Return - Line Feed) pair, and these messages SHALL NOT
* exceed 512 characters in length, counting all characters including the
* trailing CR-LF.".
*/
#define IRC_MSGLEN 520
/*
* all these function return 0 on error (except sock_open, this will return -1)
* on error net_errstr will point to the error_string
*/
int sock_open(void);
int sock_close(connection_type *connection);
int sock_listen(int sock);
int sock_setnonblock(int sock);
int sock_setblock(int sock);
int sock_setreuse(int sock);
int sock_bind(int sock, char *bindhost, int port);
int sock_bindlookedup(int sock, int port);
int sock_accept(int sock, char **hostname, int checkperm);
/* this one returns -1 if hostname is not permitted to connect */
int rawsock_close(int sock);
struct hostent *name_lookup(char *bindhost);
void irc_process_queue(void);
void irc_clear_queue(void);
int irc_mwrite(clientlist_type *clients, char *format, ...);
int irc_write(connection_type *connection, char *format, ...);
int irc_write_head(connection_type *connection, char *format, ...);
int irc_write_real(connection_type *connection, char *buffer);
/* returns: on success -> number of written bytes; -1 on error */
int irc_read(connection_type *connection);
/* returns: 1/0(no data (if blocking)) on success; -1 on error */
#define CONN_FINALIZING -2 /* Connected, but waiting for thread to die. */
#define CONN_BUSY -1 /* Still connecting... */
#define CONN_OK 0 /* All ok. */
#define CONN_SOCK 1 /* sock_open() failed. */
#define CONN_LOOKUP 2 /* remotelookup failed. */
#define CONN_BIND 3 /* Unable to bind. */
#define CONN_CONNECT 4 /* connect() failed. */
#define CONN_WRITE 5 /* write() failed. */
#define CONN_OTHER 6 /* Other error (setting nonblocking failed) */
/* IMPORTANT! connection->connected does NOT get set ! */
int irc_connect(connection_type *connection, server_type *server,
char *nick, char *username, char *realname, char *bindto);
int irc_mnotice(clientlist_type *clients, char *nick, char *format, ...);
void irc_notice(connection_type *connection, char *nick, char *format, ...);
#define RPL_MYINFO_LEN 4
#define RPL_ISUPPORT_LEN 3
/* Numeric command responses */
#define RPL_WELCOME 1
#define RPL_YOURHOST 2
#define RPL_CREATED 3
#define RPL_MYINFO 4
/*
* 005: http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
* This implementation assumes RPL_BOUNCE has been changed to 010.
*/
#define RPL_ISUPPORT 5
#define RPL_BOUNCE 10
#define RPL_MOTDSTART 375
#define RPL_MOTD 372
#define RPL_ENDOFMOTD 376
#define RPL_LUSERCLIENT 251
#define RPL_LUSEROP 252
#define RPL_LUSERUNKNOWN 253
#define RPL_LUSERCHANNELS 254
#define RPL_LUSERME 255
#define RPL_UNAWAY 305
#define RPL_NOWAWAY 306
#define RPL_CHANNELMODEIS 324
#define RPL_NOTOPIC 331
#define RPL_TOPIC 332
#define RPL_TOPICWHO 333
#define RPL_NAMREPLY 353
#define ERR_NOSUCHCHANNEL 403
#define ERR_TOOMANYCHANNELS 405
#define ERR_TOOMANYTARGETS 407
#define ERR_ERRONEUSNICKNAME 432
#define ERR_NICKNAMEINUSE 433
#define ERR_NICKUNAVAILABLE 437 /* what is this?-) */
#define ERR_UNAVAILRESOURCE 437
#define ERR_NOPERMFORHOST 463
#define ERR_YOUREBANNEDCREEP 465
#define ERR_CHANNELISFULL 471
#define ERR_INVITEONLYCHAN 473
#define ERR_BANNEDFROMCHAN 474
#define ERR_BADCHANNELKEY 475
#define ERR_BADCHANMASK 476
#define RPL_RESTRICTED 484
#define RPL_WHOISUSER 311
#define RPL_WHOISSERVER 312
#define RPL_WHOISOPERATOR 313
#define RPL_WHOISIDLE 317
#define RPL_WHOISCHANNELS 319
#define RPL_ENDOFWHOIS 318
/* export global stuff */
extern int highest_socket;
extern const char *net_errstr;
/* Flood-control counter. If greated than zero, can send messages to server. */
extern int msgtimer;
#endif /* ifndef IRC_H_ */