1
0
forked from bip/bip
bip/src/irc.h

273 lines
5.2 KiB
C
Raw Normal View History

2005-04-28 10:26:44 +02:00
/*
* $Id: irc.h,v 1.43 2005/04/21 06:58:50 nohar Exp $
*
* This file is part of the bip project
2008-01-09 23:45:40 +01:00
* Copyright (C) 2004 2005 Arnaud Cornet and Loïc Gomez
2005-04-28 10:26:44 +02:00
*
* 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.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef IRC_H
#define IRC_H
#include "connection.h"
#include "line.h"
#include "log.h"
2005-08-25 10:17:10 +02:00
#define ERR_PROTOCOL (-1)
#define ERR_AUTH (-2)
#define OK_COPY (1)
#define OK_FORGET (2)
#define OK_CLOSE (3)
#define OK_COPY_CLI (4)
#define OK_COPY_WHO (5)
2005-08-25 10:17:10 +02:00
2009-01-10 12:35:59 +01:00
#define P_SERV "b.i.p"
2005-04-28 10:26:44 +02:00
#define S_PING "BIPPING"
2009-01-10 12:35:59 +01:00
#define P_IRCMASK "-bip!bip@" P_SERV
2005-04-28 10:26:44 +02:00
struct server {
char *host;
unsigned short port;
};
2008-12-11 11:00:05 +01:00
#define server_new() bip_calloc(sizeof(struct server), 1)
2005-04-28 10:26:44 +02:00
#define NICKOP 1
#define NICKHALFOP (1<<1)
#define NICKVOICED (1<<2)
2005-04-28 10:26:44 +02:00
struct channel {
char *name;
char *mode;
char *key;
char *topic;
int limit;
char type;
char *creator;
char *create_ts;
hash_t ovmasks;
2005-04-28 10:26:44 +02:00
int running_names;
};
#define IRC_TYPE_CLIENT (0)
#define IRC_TYPE_SERVER (1)
#define IRC_TYPE_LOGING_CLIENT (2)
#define IRC_TYPE_TRUST_CLIENT (3)
2005-04-28 10:26:44 +02:00
struct user {
/** client connection static data **/
char *name;
unsigned char *password;
unsigned int seed;
int admin;
int bip_use_notice;
/* common link options */
char *default_nick;
char *default_username;
char *default_realname;
/* backlog options */
int backlog:1;
int backlog_lines;
int always_backlog:1;
int bl_msg_only:1;
int backlog_no_timestamp:1;
int blreset_on_talk:1;
int blreset_connection:1;
#ifdef HAVE_LIBSSL
int ssl_check_mode;
char *ssl_check_store;
char *ssl_client_certfile;
#endif
hash_t connections;
int in_use:1; /* for mark and sweep on reload */
};
struct network
{
char *name;
#ifdef HAVE_LIBSSL
int ssl;
#endif
int serverc;
struct server *serverv;
};
2005-04-28 10:26:44 +02:00
struct link {
char *name; /* id */
2005-04-28 10:26:44 +02:00
/** link live data **/
struct link_server *l_server;
int l_clientc;
struct link_client **l_clientv;
struct log *log;
/* we honnor the /who from clients one client at a time, this is the
* client that is /who-ing. Now for bans too */
2006-02-21 08:48:12 +01:00
struct link_client *who_client;
2006-07-02 13:50:20 +02:00
/* server related live stuff */
2005-04-28 10:26:44 +02:00
int s_state;
2007-02-10 15:05:37 +01:00
int s_conn_attempt;
2007-01-26 19:52:21 +01:00
char *prev_nick; /* XXX del me */
char *cli_nick;
2005-04-28 10:26:44 +02:00
list_t init_strings;
/* connection state (reconnecting, was_connected ...) */
int recon_timer;
2007-05-26 12:31:44 +02:00
time_t last_connection_attempt;
2005-04-28 10:26:44 +02:00
/** link options */
2009-02-08 12:36:49 +01:00
int follow_nick:1;
int ignore_first_nick:1;
int autojoin_on_kick:1;
int ignore_server_capab:1;
2006-09-18 18:06:23 +02:00
list_t on_connect_send;
2006-09-18 20:05:17 +02:00
char *no_client_away_msg;
2005-04-28 10:26:44 +02:00
char *away_nick;
2005-05-30 20:35:49 +02:00
hash_t chan_infos; /* channels we want */
list_t chan_infos_order; /* for order only */
2005-04-28 10:26:44 +02:00
struct user *user;
2005-04-28 10:26:44 +02:00
/** server connection static data **/
/* server list */
struct network *network;
2005-04-28 10:26:44 +02:00
int cur_server;
char *username;
char *realname;
2005-04-28 10:26:44 +02:00
char *s_password;
char *connect_nick;
/* socket creation info */
char *vhost;
int bind_port;
2005-08-25 10:17:10 +02:00
#ifdef HAVE_LIBSSL
int ssl_check_mode;
2005-08-25 10:17:10 +02:00
STACK_OF(X509) *untrusted_certs;
#endif
2007-10-21 19:35:22 +02:00
int in_use; /* for mark and sweep on reload */
2005-04-28 10:26:44 +02:00
};
struct link_connection {
int type;
connection_t *conn;
struct link *link;
};
struct link_any {
struct link_connection _link_c;
};
#define LINK(s) ((s)->_link_c.link)
#define CONN(s) ((s)->_link_c.conn)
#define TYPE(s) ((s)->_link_c.type)
#define IRCC_NONE (0)
#define IRCC_NICK (1)
#define IRCC_USER (1<<1)
#define IRCC_PASS (1<<2)
#define IRCC_READY (IRCC_NICK|IRCC_PASS|IRCC_USER)
struct link_client {
struct link_connection _link_c;
char *init_nick;
char *init_pass;
int state;
int logging_timer;
2005-08-25 10:17:10 +02:00
list_t who_queue;
int who_count;
time_t whoc_tstamp;
2005-08-25 10:17:10 +02:00
#ifdef HAVE_LIBSSL
int allow_trust;
#endif
2005-04-28 10:26:44 +02:00
};
#define IRCS_NONE (0)
#define IRCS_CONNECTING (1)
#define IRCS_CONNECTED (2)
#define IRCS_WAS_CONNECTED (3)
#define IRCS_RECONNECTING (4)
2007-05-26 12:31:44 +02:00
#define IRCS_TIMER_WAIT (5)
2005-04-28 10:26:44 +02:00
struct log;
struct chan_info {
char *name;
char *key;
2007-09-27 01:08:10 +02:00
int backlog;
2005-04-28 10:26:44 +02:00
};
2008-12-11 11:00:05 +01:00
#define chan_info_new() bip_calloc(sizeof(struct chan_info), 1)
2005-04-28 10:26:44 +02:00
struct link_server {
struct link_connection _link_c;
char *nick;
/* channels we are in */
hash_t channels;
char *user_mode;
int user_mode_len;
/* init stuff */
int lag;
int laginit_ts;
int lagtest_timeout;
};
2007-05-26 12:31:44 +02:00
typedef struct bip {
connection_t *listener;
/* all connected tcp connections */
list_t conn_list;
/* all links */
list_t link_list;
/* connecting clients */
list_t connecting_client_list;
hash_t networks;
hash_t users;
list_t errors;
struct link_client *reloading_client;
#ifdef HAVE_OIDENTD
char *oidentdpath;
#endif
2007-05-26 12:31:44 +02:00
} bip_t;
void bip_init(bip_t *bip);
struct link_client *irc_client_new(void);
2005-04-28 10:26:44 +02:00
struct link_server *irc_server_new(struct link *link, connection_t *conn);
void irc_server_free(struct link_server *is);
struct client *client_new();
2007-05-26 12:31:44 +02:00
void irc_main(bip_t *);
2005-04-28 10:26:44 +02:00
int ischannel(char p);
void irc_client_close(struct link_client *);
void irc_client_free(struct link_client *);
struct link *irc_link_new();
void link_kill(bip_t *bip, struct link *);
2005-08-25 10:17:10 +02:00
void unbind_from_link(struct link_client *ic);
char *nick_from_ircmask(const char *mask);
void irc_cli_backlog(struct link_client *ic, int hours);
#define BIP_FAKEMASK "!bip@bip.bip.bip"
2005-04-28 10:26:44 +02:00
#endif
2007-05-26 12:31:44 +02:00