unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
h.h (78499B)
1 /************************************************************************ 2 * Unreal Internet Relay Chat Daemon, include/h.h 3 * Copyright (C) 1992 Darren Reed 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 1, or (at your option) 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * 19 * $Id$ 20 */ 21 22 /* 23 * "h.h". - Headers file. 24 * 25 * Most of the externs and prototypes thrown in here to 'cleanup' things. 26 * -avalon 27 */ 28 #include "setup.h" 29 #include "fdlist.h" 30 31 extern int dorehash, dorestart, doreloadcert; 32 #ifndef _WIN32 33 extern char **myargv; 34 #else 35 extern LPCSTR cmdLine; 36 #endif 37 /* Externals */ 38 extern MODVAR char *buildid; 39 extern MODVAR char backupbuf[8192]; 40 extern EVENT(unrealdns_removeoldrecords); 41 extern EVENT(unrealdb_expire_secret_cache); 42 extern void init_glines(void); 43 extern void tkl_init(void); 44 extern void process_clients(void); 45 extern void unrealdb_test(void); 46 extern void ignore_this_signal(); 47 extern void s_rehash(); 48 extern void s_reloadcert(); 49 extern void s_restart(); 50 extern void s_die(); 51 #ifndef _WIN32 52 // nix specific 53 extern char unreallogo[]; 54 #else 55 // windows specific 56 extern SERVICE_STATUS_HANDLE IRCDStatusHandle; 57 extern SERVICE_STATUS IRCDStatus; 58 #endif 59 extern MODVAR char *extraflags; 60 extern MODVAR int tainted; 61 extern MODVAR Member *freemember; 62 extern MODVAR Membership *freemembership; 63 extern MODVAR Client me; 64 extern MODVAR Channel *channels; 65 extern MODVAR ModData local_variable_moddata[MODDATA_MAX_LOCAL_VARIABLE]; 66 extern MODVAR ModData global_variable_moddata[MODDATA_MAX_GLOBAL_VARIABLE]; 67 extern MODVAR IRCStatistics ircstats; 68 extern MODVAR int bootopt; 69 extern MODVAR time_t timeofday; 70 extern MODVAR struct timeval timeofday_tv; 71 extern MODVAR char cmodestring[512]; 72 extern MODVAR char umodestring[UMODETABLESZ+1]; 73 /* newconf */ 74 #define get_sendq(x) ((x)->local->class ? (x)->local->class->sendq : DEFAULT_SENDQ) 75 /* get_recvq is only called in send.c for local connections */ 76 #define get_recvq(x) ((x)->local->class->recvq ? (x)->local->class->recvq : DEFAULT_RECVQ) 77 78 /* Configuration preprocessor */ 79 extern PreprocessorItem parse_preprocessor_item(char *start, char *end, const char *filename, int linenumber, ConditionalConfig **cc); 80 extern void preprocessor_cc_duplicate_list(ConditionalConfig *r, ConditionalConfig **out); 81 extern void preprocessor_cc_free_level(ConditionalConfig **cc_list, int level); 82 extern void preprocessor_cc_free_list(ConditionalConfig *cc); 83 extern void preprocessor_resolve_conditionals_ce(ConfigEntry **ce_list, PreprocessorPhase phase); 84 extern void preprocessor_resolve_conditionals_all(PreprocessorPhase phase); 85 extern void free_config_defines(void); 86 extern void preprocessor_replace_defines(char **item, ConfigEntry *ce); 87 88 /* 89 * Configuration linked lists 90 */ 91 extern MODVAR ConfigItem_me *conf_me; 92 extern MODVAR ConfigItem_files *conf_files; 93 extern MODVAR ConfigItem_class *conf_class; 94 extern MODVAR ConfigItem_class *default_class; 95 extern MODVAR ConfigItem_admin *conf_admin; 96 extern MODVAR ConfigItem_admin *conf_admin_tail; 97 extern MODVAR ConfigItem_drpass *conf_drpass; 98 extern MODVAR ConfigItem_ulines *conf_ulines; 99 extern MODVAR ConfigItem_tld *conf_tld; 100 extern MODVAR ConfigItem_oper *conf_oper; 101 extern MODVAR ConfigItem_listen *conf_listen; 102 extern MODVAR ConfigItem_allow *conf_allow; 103 extern MODVAR ConfigItem_vhost *conf_vhost; 104 extern MODVAR ConfigItem_link *conf_link; 105 extern MODVAR ConfigItem_sni *conf_sni; 106 extern MODVAR ConfigItem_ban *conf_ban; 107 extern MODVAR ConfigItem_deny_channel *conf_deny_channel; 108 extern MODVAR ConfigItem_allow_channel *conf_allow_channel; 109 extern MODVAR ConfigItem_deny_version *conf_deny_version; 110 extern MODVAR ConfigItem_alias *conf_alias; 111 extern MODVAR ConfigItem_help *conf_help; 112 extern MODVAR ConfigItem_offchans *conf_offchans; 113 extern void completed_connection(int, int, void *); 114 extern void clear_unknown(); 115 extern EVENT(e_unload_module_delayed); 116 extern EVENT(throttling_check_expire); 117 118 extern void module_loadall(void); 119 extern long set_usermode(const char *umode); 120 extern const char *get_usermode_string(Client *acptr); 121 extern const char *get_usermode_string_r(Client *client, char *buf, size_t buflen); 122 extern const char *get_usermode_string_raw(long umodes); 123 extern const char *get_usermode_string_raw_r(long umodes, char *buf, size_t buflen); 124 extern ConfigFile *config_parse(const char *filename, char *confdata); 125 extern ConfigFile *config_parse_with_offset(const char *filename, char *confdata, unsigned int line_offset); 126 extern void config_error(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2))); 127 extern void config_warn(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2))); 128 extern void config_error_missing(const char *filename, int line, const char *entry); 129 extern void config_error_unknown(const char *filename, int line, const char *block, const char *entry); 130 extern void config_error_unknownflag(const char *filename, int line, const char *block, const char *entry); 131 extern void config_error_unknownopt(const char *filename, int line, const char *block, const char *entry); 132 extern void config_error_noname(const char *filename, int line, const char *block); 133 extern void config_error_blank(const char *filename, int line, const char *block); 134 extern void config_error_empty(const char *filename, int line, const char *block, const char *entry); 135 extern void config_warn_duplicate(const char *filename, int line, const char *entry); 136 extern int config_is_blankorempty(ConfigEntry *cep, const char *block); 137 extern MODVAR int config_verbose; 138 extern void config_entry_free(ConfigEntry *ce); 139 extern void config_entry_free_all(ConfigEntry *ce); 140 extern ConfigFile *config_load(const char *filename, const char *displayname); 141 extern void config_free(ConfigFile *cfptr); 142 extern void ipport_seperate(const char *string, char **ip, char **port); 143 extern ConfigItem_class *find_class(const char *name); 144 extern ConfigItem_oper *find_oper(const char *name); 145 extern ConfigItem_operclass *find_operclass(const char *name); 146 extern ConfigItem_listen *find_listen(const char *ipmask, int port, SocketType socket_type); 147 extern ConfigItem_sni *find_sni(const char *name); 148 extern ConfigItem_ulines *find_uline(const char *host); 149 extern ConfigItem_tld *find_tld(Client *cptr); 150 extern ConfigItem_link *find_link(const char *servername); 151 extern ConfigItem_ban *find_ban(Client *, const char *host, short type); 152 extern ConfigItem_ban *find_banEx(Client *,const char *host, short type, short type2); 153 extern ConfigItem_vhost *find_vhost(const char *name); 154 extern ConfigItem_deny_channel *find_channel_allowed(Client *cptr, const char *name); 155 extern ConfigItem_alias *find_alias(const char *name); 156 extern ConfigItem_help *find_Help(const char *command); 157 158 extern OperPermission ValidatePermissionsForPath(const char *path, Client *client, Client *victim, Channel *channel, const void *extra); 159 extern void OperClassValidatorDel(OperClassValidator *validator); 160 161 extern ConfigItem_ban *find_ban_ip(Client *client); 162 extern void add_ListItem(ListStruct *, ListStruct **); 163 extern void append_ListItem(ListStruct *item, ListStruct **list); 164 extern void add_ListItemPrio(ListStructPrio *, ListStructPrio **, int); 165 extern void del_ListItem(ListStruct *, ListStruct **); 166 extern MODVAR LoopStruct loop; 167 extern int del_banid(Channel *channel, const char *banid); 168 extern int del_exbanid(Channel *channel, const char *banid); 169 #define REPORT_DO_DNS "NOTICE * :*** Looking up your hostname...\r\n" 170 #define REPORT_FIN_DNS "NOTICE * :*** Found your hostname\r\n" 171 #define REPORT_FIN_DNSC "NOTICE * :*** Found your hostname (cached)\r\n" 172 #define REPORT_FAIL_DNS "NOTICE * :*** Couldn't resolve your hostname; using your IP address instead\r\n" 173 #define REPORT_DO_ID "NOTICE * :*** Checking ident...\r\n" 174 #define REPORT_FIN_ID "NOTICE * :*** Received identd response\r\n" 175 #define REPORT_FAIL_ID "NOTICE * :*** No ident response; username prefixed with ~\r\n" 176 extern MODVAR int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns, R_do_id, R_fin_id, R_fail_id; 177 extern MODVAR struct list_head client_list; 178 extern MODVAR struct list_head lclient_list; 179 extern MODVAR struct list_head server_list; 180 extern MODVAR struct list_head oper_list; 181 extern MODVAR struct list_head unknown_list; 182 extern MODVAR struct list_head control_list; 183 extern MODVAR struct list_head global_server_list; 184 extern MODVAR struct list_head dead_list; 185 extern MODVAR struct list_head rpc_remote_list; 186 extern RealCommand *find_command(const char *cmd, int flags); 187 extern RealCommand *find_command_simple(const char *cmd); 188 extern Membership *find_membership_link(Membership *lp, Channel *ptr); 189 extern Member *find_member_link(Member *, Client *); 190 extern int remove_user_from_channel(Client *client, Channel *channel, int dont_log); 191 extern void add_server_to_table(Client *); 192 extern void remove_server_from_table(Client *); 193 extern void iNAH_host(Client *client, const char *host); 194 extern void set_snomask(Client *client, const char *snomask); 195 extern int check_tkls(Client *cptr); 196 /* for services */ 197 extern void send_user_joins(Client *, Client *); 198 extern int valid_channelname(const char *); 199 extern int valid_server_name(const char *name); 200 extern Cmode *find_channel_mode_handler(char letter); 201 extern int valid_channel_access_mode_letter(char letter); 202 extern int check_channel_access(Client *client, Channel *channel, const char *modes); 203 extern int check_channel_access_membership(Membership *mb, const char *modes); 204 extern int check_channel_access_member(Member *mb, const char *modes); 205 extern int check_channel_access_string(const char *current_modes, const char *modes); 206 extern int check_channel_access_letter(const char *current_modes, const char letter); 207 extern const char *get_channel_access(Client *client, Channel *channel); 208 extern void add_member_mode_fast(Member *mb, Membership *mbs, char letter); 209 extern void del_member_mode_fast(Member *mb, Membership *mbs, char letter); 210 extern void add_member_mode(Client *client, Channel *channel, char letter); 211 extern void del_member_mode(Client *client, Channel *channel, char letter); 212 extern char sjoin_prefix_to_mode(char s); 213 extern char mode_to_sjoin_prefix(char s); 214 extern char mode_to_prefix(char s); 215 extern char prefix_to_mode(char s); 216 extern const char *modes_to_prefix(const char *modes); 217 extern const char *modes_to_sjoin_prefix(const char *modes); 218 extern char rank_to_mode(int rank); 219 extern int mode_to_rank(char mode); 220 extern char lowest_ranking_mode(const char *modes); 221 extern char lowest_ranking_prefix(const char *prefix); 222 extern void channel_member_modes_generate_equal_or_greater(const char *modes, char *buf, size_t buflen); 223 extern int ban_check_mask(BanContext *b); 224 extern int extban_is_ok_nuh_extban(BanContext *b); 225 extern const char *extban_conv_param_nuh_or_extban(BanContext *b, Extban *extban); 226 extern const char *extban_conv_param_nuh(BanContext *b, Extban *extban); 227 extern Ban *is_banned(Client *, Channel *, int, const char **, const char **); 228 extern Ban *is_banned_with_nick(Client *, Channel *, int, const char *, const char **, const char **); 229 extern int ban_exists(Ban *lst, const char *str); 230 extern int ban_exists_ignore_time(Ban *lst, const char *str); 231 232 extern Client *find_client(const char *, Client *); 233 extern Client *find_name(const char *, Client *); 234 extern Client *find_nickserv(const char *, Client *); 235 extern Client *find_user(const char *, Client *); 236 extern Client *find_server(const char *, Client *); 237 extern Client *find_server_by_uid(const char *uid); 238 extern Client *find_service(const char *, Client *); 239 #define find_server_quick(x) find_server(x, NULL) 240 extern char *find_or_add(char *); 241 extern void inittoken(); 242 extern void reset_help(); 243 244 extern MODVAR char *debugmode, *configfile, *sbrk0; 245 extern void set_sockhost(Client *, const char *); 246 #ifdef _WIN32 247 extern const char *sock_strerror(int); 248 #endif 249 250 #ifdef _WIN32 251 extern MODVAR int debuglevel; 252 #else 253 extern int debuglevel, errno, h_errno; 254 #endif 255 extern MODVAR int OpenFiles; /* number of files currently open */ 256 extern MODVAR int debuglevel, portnum, debugtty, maxusersperchannel; 257 extern MODVAR int readcalls, udpfd, resfd; 258 extern Client *add_connection(ConfigItem_listen *, int); 259 extern int check_server_init(Client *); 260 extern void close_connection(Client *); 261 extern void close_unbound_listeners(); 262 extern int get_sockerr(Client *); 263 extern int inetport(ConfigItem_listen *, char *, int, int); 264 extern void init_sys(); 265 extern void check_user_limit(void); 266 extern void init_modef(); 267 extern int verify_hostname(const char *name); 268 269 extern int setup_ping(); 270 271 extern void set_channel_mlock(Client *, Channel *, const char *, int); 272 273 extern void restart(const char *); 274 extern void server_reboot(const char *); 275 extern void terminate(), write_pidfile(); 276 extern void *safe_alloc(size_t size); 277 extern void set_socket_buffers(int fd, int rcvbuf, int sndbuf); 278 extern int send_queued(Client *); 279 extern void send_queued_cb(int fd, int revents, void *data); 280 extern void sendto_serv_butone_nickcmd(Client *one, MessageTag *mtags, Client *client, const char *umodes); 281 extern void sendto_message_one(Client *to, Client *from, const char *sender, const char *cmd, const char *nick, const char *msg); 282 extern void sendto_channel(Channel *channel, Client *from, Client *skip, 283 char *member_modes, long clicap, int sendflags, 284 MessageTag *mtags, 285 FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,8,9))); 286 extern void sendto_local_common_channels(Client *user, Client *skip, 287 long clicap, MessageTag *mtags, 288 FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,5,6))); 289 extern void quit_sendto_local_common_channels(Client *user, MessageTag *mtags, const char *reason); 290 extern void sendto_match_servs(Channel *, Client *, FORMAT_STRING(const char *), ...) __attribute__((format(printf,3,4))); 291 extern void sendto_match_butone(Client *, Client *, const char *, int, MessageTag *, 292 FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,6,7))); 293 extern void sendto_all_butone(Client *, Client *, FORMAT_STRING(const char *), ...) __attribute__((format(printf,3,4))); 294 extern void sendto_ops(FORMAT_STRING(const char *), ...) __attribute__((format(printf,1,2))); 295 extern void sendto_prefix_one(Client *, Client *, MessageTag *, FORMAT_STRING(const char *), ...) __attribute__((format(printf,4,5))); 296 extern void vsendto_prefix_one(Client *to, Client *from, MessageTag *mtags, const char *pattern, va_list vl); 297 extern void sendto_opers(FORMAT_STRING(const char *), ...) __attribute__((format(printf,1,2))); 298 extern void sendto_umode(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf,2,3))); 299 extern void sendto_umode_global(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf,2,3))); 300 extern void sendnotice(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,2,3))); 301 /** Send numeric message to a client. 302 * @param to The recipient 303 * @param numeric The numeric, one of RPL_* or ERR_*, see include/numeric.h 304 * @param ... The parameters for the numeric 305 * @note Be sure to provide the correct number and type of parameters that belong to the numeric. Check include/numeric.h when in doubt! 306 * @section sendnumeric_examples Examples 307 * @subsection sendnumeric_permission_denied Send "Permission Denied" numeric 308 * This numeric has no parameter, so is simple: 309 * @code 310 * sendnumeric(client, ERR_NOPRIVILEGES); 311 * @endcode 312 * @subsection sendnumeric_notenoughparameters Send "Not enough parameters" numeric 313 * This numeric requires 1 parameter: the name of the command. 314 * @code 315 * sendnumeric(client, ERR_NEEDMOREPARAMS, "SOMECOMMAND"); 316 * @endcode 317 * @ingroup SendFunctions 318 */ 319 #define sendnumeric(to, numeric, ...) sendtaggednumericfmt(to, NULL, numeric, STR_ ## numeric, ##__VA_ARGS__) 320 321 /** Send numeric message to a client - format to user specific needs. 322 * This will ignore the numeric definition of src/numeric.c and always send ":me.name numeric clientname " 323 * followed by the pattern and format string you choose. 324 * @param to The recipient 325 * @param numeric The numeric, one of RPL_* or ERR_*, see src/numeric.c 326 * @param pattern The format string / pattern to use. 327 * @param ... Format string parameters. 328 * @note Don't forget to add a colon if you need it (eg `:%%s`), this is a common mistake. 329 */ 330 #define sendnumericfmt(to, numeric, ...) sendtaggednumericfmt(to, NULL, numeric, __VA_ARGS__) 331 332 /** Send numeric message to a client - format to user specific needs. 333 * This will ignore the numeric definition of src/numeric.c and always send ":me.name numeric clientname " 334 * followed by the pattern and format string you choose. 335 * @param to The recipient 336 * @param mtags NULL, or NULL-terminated array of message tags 337 * @param numeric The numeric, one of RPL_* or ERR_*, see src/numeric.c 338 * @param pattern The format string / pattern to use. 339 * @param ... Format string parameters. 340 * @note Don't forget to add a colon if you need it (eg `:%%s`), this is a common mistake. 341 */ 342 #define sendtaggednumeric(to, mtags, numeric, ...) sendtaggednumericfmt(to, mtags, numeric, STR_ ## numeric, ##__VA_ARGS__) 343 344 extern void sendtaggednumericfmt(Client *to, MessageTag *mtags, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,4,5))); 345 346 extern void sendtxtnumeric(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,2,3))); 347 /** Build numeric message so it is ready to be sent to a client - rarely used, normally you use sendnumeric() instead. 348 * This function is normally only used in eg CAN_KICK and CAN_SET_TOPIC, where 349 * you need to set an 'errbuf' with a full IRC protocol line to reject the request 350 * (which then may or may not be sent depending on operoverride privileges). 351 * @param buf The buffer where the message should be stored to (full IRC protocol line) 352 * @param buflen The size of the buffer 353 * @param to The recipient 354 * @param numeric The numeric, one of RPL_* or ERR_*, see include/numeric.h 355 * @param ... The parameters for the numeric 356 * @note Be sure to provide the correct number and type of parameters that belong to the numeric. Check include/numeric.h when in doubt! 357 * @ingroup SendFunctions 358 */ 359 #define buildnumeric(buf, buflen, to, numeric, ...) buildnumericfmt(buf, buflen, to, numeric, STR_ ## numeric, ##__VA_ARGS__) 360 extern void buildnumericfmt(char *buf, size_t buflen, Client *to, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,5,6))); 361 extern void sendto_server(Client *one, unsigned long caps, unsigned long nocaps, MessageTag *mtags, FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 5, 6))); 362 extern void send_raw_direct(Client *user, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 2, 3))); 363 extern MODVAR int writecalls, writeb[]; 364 extern int deliver_it(Client *cptr, char *str, int len, int *want_read); 365 extern int target_limit_exceeded(Client *client, void *target, const char *name); 366 extern char *canonize(const char *buffer); 367 extern int check_registered(Client *); 368 extern int check_registered_user(Client *); 369 extern const char *get_client_name(Client *, int); 370 extern const char *get_client_host(Client *); 371 extern const char *myctime(time_t); 372 extern const char *short_date(time_t, char *buf); 373 extern const char *long_date(time_t); 374 extern const char *pretty_time_val(long); 375 extern const char *pretty_time_val_r(char *buf, size_t buflen, long timeval); 376 extern const char *pretty_date(time_t t); 377 extern time_t server_time_to_unix_time(const char *tbuf); 378 extern time_t rfc2616_time_to_unix_time(const char *tbuf); 379 extern const char *rfc2616_time(time_t clock); 380 extern void exit_client(Client *client, MessageTag *recv_mtags, const char *comment); 381 extern void exit_client_fmt(Client *client, MessageTag *recv_mtags, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 3, 4))); 382 extern void exit_client_ex(Client *client, Client *origin, MessageTag *recv_mtags, const char *comment); 383 extern void initstats(); 384 extern const char *check_string(const char *); 385 extern char *make_nick_user_host(const char *, const char *, const char *); 386 extern char *make_nick_user_host_r(char *namebuf, size_t namebuflen, const char *nick, const char *name, const char *host); 387 extern char *make_user_host(const char *, const char *); 388 extern void parse(Client *cptr, char *buffer, int length); 389 extern int hunt_server(Client *, MessageTag *, const char *, int, int, const char **); 390 extern int cmd_server_estab(Client *); 391 extern void umode_init(void); 392 #define UMODE_GLOBAL 1 393 #define UMODE_LOCAL 0 394 extern int umode_allow_all(Client *client, int what); 395 extern int umode_allow_unset(Client *client, int what); 396 extern int umode_allow_opers(Client *client, int what); 397 extern int umode_allow_none(Client *client, int what); 398 extern int umode_delete(char ch, long val); 399 extern void build_umode_string(Client *client, long old, long sendmask, char *umode_buf); 400 extern void send_umode_out(Client *client, int show_to_user, long old); 401 402 extern void free_client(Client *); 403 extern void free_link(Link *); 404 extern void free_ban(Ban *); 405 extern void free_user(Client *); 406 extern int link_list_length(Link *lp); 407 extern int find_str_match_link(Link *, const char *); 408 extern void free_str_list(Link *); 409 extern Link *make_link(); 410 extern Ban *make_ban(); 411 extern User *make_user(Client *); 412 extern Server *make_server(); 413 extern Client *make_client(Client *, Client *); 414 extern Channel *make_channel(const char *name); 415 extern Member *find_channel_link(Member *, Channel *); 416 extern char *pretty_mask(const char *); 417 extern void add_client_to_list(Client *); 418 extern void remove_client_from_list(Client *); 419 extern void initlists(void); 420 extern void initlist_channels(void); 421 extern struct hostent *get_res(const char *); 422 extern struct hostent *gethost_byaddr(const char *, Link *); 423 extern struct hostent *gethost_byname(const char *, Link *); 424 extern void flush_cache(); 425 extern void init_resolver(int firsttime); 426 extern time_t timeout_query_list(time_t); 427 extern time_t expire_cache(time_t); 428 extern void del_queries(const char *); 429 430 /* Hash stuff */ 431 #define NICK_HASH_TABLE_SIZE 32768 432 #define CHAN_HASH_TABLE_SIZE 32768 433 #define WHOWAS_HASH_TABLE_SIZE 32768 434 #define THROTTLING_HASH_TABLE_SIZE 8192 435 extern uint64_t siphash(const char *in, const char *k); 436 extern uint64_t siphash_raw(const char *in, size_t len, const char *k); 437 extern uint64_t siphash_nocase(const char *in, const char *k); 438 extern void siphash_generate_key(char *k); 439 extern void init_hash(void); 440 extern void add_whowas_to_clist(WhoWas **, WhoWas *); 441 extern void del_whowas_from_clist(WhoWas **, WhoWas *); 442 extern void add_whowas_to_list(WhoWas **, WhoWas *); 443 extern void del_whowas_from_list(WhoWas **, WhoWas *); 444 extern uint64_t hash_whowas_name(const char *name); 445 extern void create_whowas_entry(Client *client, WhoWas *e, WhoWasEvent event); 446 extern void free_whowas_fields(WhoWas *e); 447 extern int add_to_client_hash_table(const char *, Client *); 448 extern int del_from_client_hash_table(const char *, Client *); 449 extern int add_to_id_hash_table(const char *, Client *); 450 extern int del_from_id_hash_table(const char *, Client *); 451 extern int add_to_channel_hash_table(const char *, Channel *); 452 extern void del_from_channel_hash_table(const char *, Channel *); 453 extern Channel *hash_get_chan_bucket(uint64_t); 454 extern Client *hash_find_client(const char *, Client *); 455 extern Client *hash_find_id(const char *, Client *); 456 extern Client *hash_find_nickatserver(const char *, Client *); 457 extern Channel *find_channel(const char *name); 458 extern Client *hash_find_server(const char *, Client *); 459 extern struct MODVAR ThrottlingBucket *ThrottlingHash[THROTTLING_HASH_TABLE_SIZE]; 460 461 462 463 /* Mode externs 464 */ 465 extern MODVAR long UMODE_INVISIBLE; /* makes user invisible */ 466 extern MODVAR long UMODE_OPER; /* Operator */ 467 extern MODVAR long UMODE_REGNICK; /* Nick set by services as registered */ 468 extern MODVAR long UMODE_SERVNOTICE;/* server notices such as kill */ 469 extern MODVAR long UMODE_HIDE; /* Hide from Nukes */ 470 extern MODVAR long UMODE_SECURE; /* User is a secure connect */ 471 extern MODVAR long UMODE_DEAF; /* Deaf */ 472 extern MODVAR long UMODE_HIDEOPER; /* Hide oper mode */ 473 extern MODVAR long UMODE_SETHOST; /* used sethost */ 474 extern MODVAR long UMODE_HIDLE; /* hides oper idle times */ 475 extern MODVAR long AllUmodes, SendUmodes; 476 477 extern MODVAR long SNO_KILLS; 478 extern MODVAR long SNO_CLIENT; 479 extern MODVAR long SNO_FLOOD; 480 extern MODVAR long SNO_FCLIENT; 481 extern MODVAR long SNO_JUNK; 482 extern MODVAR long SNO_VHOST; 483 extern MODVAR long SNO_EYES; 484 extern MODVAR long SNO_TKL; 485 extern MODVAR long SNO_NICKCHANGE; 486 extern MODVAR long SNO_FNICKCHANGE; 487 extern MODVAR long SNO_QLINE; 488 extern MODVAR long SNO_SNOTICE; 489 extern MODVAR long SNO_SPAMF; 490 extern MODVAR long SNO_OPER; 491 492 #ifndef HAVE_STRNLEN 493 extern size_t strnlen(const char *s, size_t maxlen); 494 #endif 495 #ifndef HAVE_STRLCPY 496 extern size_t strlcpy(char *dst, const char *src, size_t size); 497 #endif 498 #ifndef HAVE_STRLNCPY 499 extern size_t strlncpy(char *dst, const char *src, size_t size, size_t n); 500 #endif 501 #ifndef HAVE_STRLCAT 502 extern size_t strlcat(char *dst, const char *src, size_t size); 503 #endif 504 #ifndef HAVE_STRLNCAT 505 extern size_t strlncat(char *dst, const char *src, size_t size, size_t n); 506 #endif 507 extern void strlcat_letter(char *buf, char c, size_t buflen); 508 extern char *strldup(const char *src, size_t n); 509 510 extern void dopacket(Client *, char *, int); 511 512 extern void debug(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf,2,3))); 513 #if defined(DEBUGMODE) 514 extern void send_usage(Client *, const char *); 515 extern void count_memory(Client *, const char *); 516 extern int checkprotoflags(Client *, int, const char *, int); 517 #endif 518 519 extern const char *inetntop(int af, const void *in, char *local_dummy, size_t the_size); 520 521 extern void delletterfromstring(char *s, char letter); 522 extern void addlettertodynamicstringsorted(char **str, char letter); 523 extern int sort_character_lowercase_before_uppercase(char x, char y); 524 525 /* Internal command stuff - not for modules */ 526 extern MODVAR RealCommand *CommandHash[256]; 527 extern void init_CommandHash(void); 528 529 /* CRULE */ 530 extern struct CRuleNode* crule_parse(const char*); 531 extern void crule_free(struct CRuleNode**); 532 extern int crule_eval(struct CRuleNode* rule); 533 extern int crule_test(const char *rule); 534 extern const char *crule_errstring(int errcode); 535 536 /* 537 * Close all local socket connections, invalidate client fd's 538 * WIN32 cleanup winsock lib 539 */ 540 extern void close_connections(void); 541 542 extern int b64_encode(unsigned char const *src, size_t srclength, char *target, size_t targsize); 543 extern int b64_decode(char const *src, unsigned char *target, size_t targsize); 544 545 extern AuthenticationType Auth_FindType(const char *hash, const char *type); 546 extern AuthConfig *AuthBlockToAuthConfig(ConfigEntry *ce); 547 extern void Auth_FreeAuthConfig(AuthConfig *as); 548 extern int Auth_Check(Client *cptr, AuthConfig *as, const char *para); 549 extern const char *Auth_Hash(int type, const char *para); 550 extern int Auth_CheckError(ConfigEntry *ce); 551 extern int Auth_AutoDetectHashType(const char *hash); 552 553 extern void make_cloakedhost(Client *client, const char *curr, char *buf, size_t buflen); 554 extern int channel_canjoin(Client *client, const char *name); 555 extern char *collapse(char *pattern); 556 extern void dcc_sync(Client *client); 557 extern void request_rehash(Client *client); 558 extern int rehash_internal(Client *client); 559 extern void s_die(); 560 extern int match_simple(const char *mask, const char *name); 561 extern int match_esc(const char *mask, const char *name); 562 extern int add_listener(ConfigItem_listen *conf); 563 extern void link_cleanup(ConfigItem_link *link_ptr); 564 extern void listen_cleanup(); 565 extern int numeric_collides(long numeric); 566 extern void flag_add(char ch); 567 extern void flag_del(char ch); 568 extern void init_dynconf(void); 569 extern int config_read_start(void); 570 extern int is_config_read_finished(void); 571 extern int config_test(void); 572 extern void config_run(void); 573 extern void rehash_motdrules(); 574 extern void read_motd(const char *filename, MOTDFile *motd); /* s_serv.c */ 575 extern void send_proto(Client *, ConfigItem_link *); 576 extern void unload_all_modules(void); 577 extern void set_sock_opts(int fd, Client *cptr, SocketType socket_type); 578 extern void stripcrlf(char *line); 579 extern int strnatcmp(char const *a, char const *b); 580 extern int strnatcasecmp(char const *a, char const *b); 581 extern void outofmemory(size_t bytes); 582 583 /** Memory allocation and deallocation functions and macros that should be used in UnrealIRCd. 584 * Use these instead of malloc/calloc/free. 585 * @defgroup MemoryRoutines Memory allocation and deallocation 586 * @{ 587 */ 588 extern void *safe_alloc(size_t size); 589 /** Free previously allocate memory pointer. 590 * This also sets the pointer to NULL, since that would otherwise be common to forget. 591 */ 592 #define safe_free(x) do { if (x) free(x); x = NULL; } while(0) 593 /** Free previously allocated memory pointer. 594 * Raw version which does not touch the pointer itself. You most likely don't 595 * need this, as it's only used in 1 place in UnrealIRCd. 596 */ 597 #define safe_free_raw(x) free(x) 598 599 /** Free previous memory (if any) and then save a duplicate of the specified string. 600 * @param dst The current pointer and the pointer where a new copy of the string will be stored. 601 * @param str The string you want to copy 602 */ 603 #define safe_strdup(dst,str) do { if (dst) free(dst); if ((str) == NULL) dst = NULL; else dst = our_strdup(str); } while(0) 604 605 /** Return a copy of the string. Do not free any existing memory. 606 * @param str The string to duplicate 607 * @returns A pointer to the new copy. 608 * @note 609 * Generally you need to use safe_strdup() instead(!). But when clearly initializing 610 * a variable that does not have a previous value, then raw_strdup() usage is fine, eg: 611 * int somefunc() 612 * { 613 * char *somevar = raw_strdup("IRC"); 614 * And, similarly if you want to return a duplicate (there is no destination variable): 615 * return raw_strdup(something); 616 */ 617 #define raw_strdup(str) strdup(str) 618 619 /** Free previous memory (if any) and then save a duplicate of the specified string with a length limit. 620 * @param dst The current pointer and the pointer where a new copy of the string will be stored. 621 * @param str The string you want to copy 622 * @param sz Length limit including the NUL byte, usually sizeof(dst) 623 */ 624 #define safe_strldup(dst,str,sz) do { if (dst) free(dst); if (!str) dst = NULL; else dst = our_strldup(str,sz); } while(0) 625 626 /** Return a duplicate of the specified string with a length limit. Do not free any existing memory. 627 * @param str The string you want to copy 628 * @param sz Length limit including the NUL byte, usually sizeof(dst) 629 * @returns A pointer to the new copy. 630 * @note 631 * Generally you need to use safe_strldup() instead(!). But when clearly initializing 632 * a variable that does not have a previous value, then raw_strldup() usage is fine, eg: 633 * int somefunc(char *str) 634 * { 635 * char *somevar = raw_strldup(str, 16); 636 * And, similarly if you want to return a duplicate (there is no destination variable): 637 * return raw_strldup(something); 638 */ 639 #define raw_strldup(str, max) our_strldup(str, max) 640 641 extern void *safe_alloc_sensitive(size_t size); 642 643 /** Free previously allocate memory pointer - this is the sensitive version which 644 * may ONLY be called on allocations returned by safe_alloc_sensitive() / safe_strdup_sensitive(). 645 * This will set the memory to all zeroes before actually deallocating. 646 * It also sets the pointer to NULL, since that would otherwise be common to forget. 647 * @note If you call this function on normally allocated memory (non-sensitive) then we will crash. 648 */ 649 #define safe_free_sensitive(x) do { if (x) sodium_free(x); x = NULL; } while(0) 650 651 /** Free previous memory (if any) and then save a duplicate of the specified string - 652 * This is the 'sensitive' version which should only be used for HIGHLY sensitive data, 653 * as it wastes about 8000 bytes even if you only duplicate a string of 32 bytes (this is by design). 654 * @param dst The current pointer and the pointer where a new copy of the string will be stored. 655 * @param str The string you want to copy 656 */ 657 #define safe_strdup_sensitive(dst,str) do { if (dst) sodium_free(dst); if (!(str)) dst = NULL; else dst = our_strdup_sensitive(str); } while(0) 658 659 /** Safely destroy a string in memory (but do not free!) */ 660 #define destroy_string(str) sodium_memzero(str, strlen(str)) 661 662 /** @} */ 663 extern char *our_strdup(const char *str); 664 extern char *our_strldup(const char *str, size_t max); 665 extern char *our_strdup_sensitive(const char *str); 666 667 extern long config_checkval(const char *value, unsigned short flags); 668 extern void config_status(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2))); 669 extern void init_random(); 670 extern u_char getrandom8(); 671 extern uint16_t getrandom16(); 672 extern uint32_t getrandom32(); 673 extern void gen_random_alnum(char *buf, int numbytes); 674 675 /* Check config entry for empty/missing parameter */ 676 #define CheckNull(x) if ((!(x)->value) || (!(*((x)->value)))) { config_error("%s:%i: missing parameter", (x)->file->filename, (x)->line_number); errors++; continue; } 677 /* as above, but accepting empty string */ 678 #define CheckNullAllowEmpty(x) if ((!(x)->value)) { config_error("%s:%i: missing parameter", (x)->file->filename, (x)->line_number); errors++; continue; } 679 680 extern MODVAR char extchmstr[4][64]; 681 682 extern int extcmode_default_requirechop(Client *, Channel *, char, const char *, int, int); 683 extern int extcmode_default_requirehalfop(Client *, Channel *, char, const char *, int, int); 684 extern Cmode_t extcmode_get(Cmode *); 685 extern void extcmode_init(void); 686 extern void make_extcmodestr(); 687 extern void extcmode_duplicate_paramlist(void **xi, void **xo); 688 extern void extcmode_free_paramlist(void **ar); 689 690 extern void chmode_str(struct ChMode *, char *, char *, size_t, size_t); 691 extern const char *get_client_status(Client *); 692 extern void SocketLoop(void *); 693 #ifdef _WIN32 694 extern void InitDebug(void); 695 extern int InitUnrealIRCd(int argc, char **); 696 extern void win_error(); 697 extern void win_log(FORMAT_STRING(const char *format), ...); 698 extern int GetOSName(char *pszOS); 699 extern void CleanUp(void); 700 extern int CountRTFSize(unsigned char *buffer); 701 extern void IRCToRTF(unsigned char *buffer, unsigned char *string); 702 #endif 703 extern void verify_opercount(Client *, const char *); 704 extern int valid_host(const char *host, int strict); 705 extern int valid_username(const char *username); 706 extern int valid_vhost(const char *userhost); 707 extern int count_oper_sessions(const char *); 708 extern char *unreal_mktemp(const char *dir, const char *suffix); 709 extern char *unreal_getpathname(const char *filepath, char *path); 710 extern const char *unreal_getfilename(const char *path); 711 extern const char *unreal_getmodfilename(const char *path); 712 extern int unreal_create_directory_structure_for_file(const char *fname, mode_t mode); 713 extern int unreal_create_directory_structure(const char *dname, mode_t mode); 714 extern int unreal_mkdir(const char *pathname, mode_t mode); 715 extern int unreal_copyfile(const char *src, const char *dest); 716 extern int unreal_copyfileex(const char *src, const char *dest, int tryhardlink); 717 extern time_t unreal_getfilemodtime(const char *filename); 718 extern void unreal_setfilemodtime(const char *filename, time_t mtime); 719 extern void DeleteTempModules(void); 720 extern MODVAR Extban *extbaninfo; 721 extern Extban *findmod_by_bantype(const char *str, const char **remainder); 722 extern Extban *findmod_by_bantype_raw(const char *str, int ban_name_length); 723 extern Extban *ExtbanAdd(Module *reserved, ExtbanInfo req); 724 extern void ExtbanDel(Extban *); 725 extern void extban_init(void); 726 extern char *trim_str(char *str, int len); 727 extern MODVAR char *ban_realhost, *ban_virthost, *ban_ip; 728 extern BanAction banact_stringtoval(const char *s); 729 extern const char *banact_valtostring(BanAction val); 730 extern BanAction banact_chartoval(char c); 731 extern char banact_valtochar(BanAction val); 732 extern int spamfilter_gettargets(const char *s, Client *client); 733 extern char *spamfilter_target_inttostring(int v); 734 extern char *our_strcasestr(const char *haystack, const char *needle); 735 extern int spamfilter_getconftargets(const char *s); 736 extern void remove_all_snomasks(Client *client); 737 extern void remove_oper_modes(Client *client); 738 extern char *spamfilter_inttostring_long(int v); 739 extern int is_invited(Client *client, Channel *channel); 740 extern void channel_modes(Client *client, char *mbuf, char *pbuf, size_t mbuf_size, size_t pbuf_size, Channel *channel, int hide_local_modes); 741 extern int op_can_override(const char *acl, Client *client,Channel *channel,void* extra); 742 extern Client *find_chasing(Client *client, const char *user, int *chasing); 743 extern MODVAR long opermode; 744 extern MODVAR long sajoinmode; 745 extern void add_user_to_channel(Channel *channel, Client *who, const char *modes); 746 extern int add_banid(Client *, Channel *, const char *); 747 extern int add_exbanid(Client *cptr, Channel *channel, const char *banid); 748 extern int sub1_from_channel(Channel *); 749 extern MODVAR CoreChannelModeTable corechannelmodetable[]; 750 extern char *unreal_encodespace(const char *s); 751 extern char *unreal_decodespace(const char *s); 752 extern MODVAR Link *helpign; 753 extern void reread_motdsandrules(); 754 extern MODVAR int SVSNOOP; 755 extern int callbacks_check(void); 756 extern void callbacks_switchover(void); 757 extern int efunctions_check(void); 758 extern void efunctions_switchover(void); 759 extern const char *encode_ip(const char *); 760 extern const char *decode_ip(const char *); 761 extern void sendto_one_nickcmd(Client *server, MessageTag *mtags, Client *client, const char *umodes); 762 extern int on_dccallow_list(Client *to, Client *from); 763 extern int add_dccallow(Client *client, Client *optr); 764 extern int del_dccallow(Client *client, Client *optr); 765 extern void delete_linkblock(ConfigItem_link *link_ptr); 766 extern void delete_classblock(ConfigItem_class *class_ptr); 767 extern void del_async_connects(void); 768 extern void isupport_init(void); 769 extern void clicap_init(void); 770 extern void efunctions_init(void); 771 extern void do_cmd(Client *client, MessageTag *mtags, const char *cmd, int parc, const char *parv[]); 772 extern MODVAR char *me_hash; 773 extern MODVAR int dontspread; 774 extern MODVAR int labeled_response_inhibit; 775 extern MODVAR int labeled_response_inhibit_end; 776 extern MODVAR int labeled_response_force; 777 778 /* Efuncs */ 779 extern MODVAR void (*do_join)(Client *, int, const char **); 780 extern MODVAR void (*join_channel)(Channel *channel, Client *client, MessageTag *mtags, const char *flags); 781 extern MODVAR int (*can_join)(Client *client, Channel *channel, const char *key, char **errmsg); 782 extern MODVAR void (*do_mode)(Channel *channel, Client *client, MessageTag *mtags, int parc, const char *parv[], time_t sendts, int samode); 783 extern MODVAR MultiLineMode *(*set_mode)(Channel *channel, Client *cptr, int parc, const char *parv[], u_int *pcount, 784 char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]); 785 extern MODVAR void (*set_channel_mode)(Channel *channel, MessageTag *mtags, const char *modes, const char *parameters); 786 extern MODVAR void (*set_channel_topic)(Client *client, Channel *channel, MessageTag *recv_mtags, const char *topic, const char *set_by, time_t set_at); 787 extern MODVAR void (*cmd_umode)(Client *, MessageTag *, int, const char **); 788 extern MODVAR int (*register_user)(Client *client); 789 extern MODVAR int (*tkl_hash)(unsigned int c); 790 extern MODVAR char (*tkl_typetochar)(int type); 791 extern MODVAR int (*tkl_chartotype)(char c); 792 extern MODVAR char (*tkl_configtypetochar)(const char *name); 793 extern MODVAR const char *(*tkl_type_string)(TKL *tk); 794 extern MODVAR const char *(*tkl_type_config_string)(TKL *tk); 795 extern MODVAR TKL *(*tkl_add_serverban)(int type, const char *usermask, const char *hostmask, const char *reason, const char *setby, 796 time_t expire_at, time_t set_at, int soft, int flags); 797 extern MODVAR TKL *(*tkl_add_banexception)(int type, const char *usermask, const char *hostmask, SecurityGroup *match, 798 const char *reason, const char *set_by, 799 time_t expire_at, time_t set_at, int soft, const char *bantypes, int flags); 800 extern MODVAR TKL *(*tkl_add_nameban)(int type, const char *name, int hold, const char *reason, const char *setby, 801 time_t expire_at, time_t set_at, int flags); 802 extern MODVAR TKL *(*tkl_add_spamfilter)(int type, unsigned short target, unsigned short action, Match *match, const char *setby, 803 time_t expire_at, time_t set_at, 804 time_t spamf_tkl_duration, const char *spamf_tkl_reason, 805 int flags); 806 extern MODVAR TKL *(*find_tkl_serverban)(int type, const char *usermask, const char *hostmask, int softban); 807 extern MODVAR TKL *(*find_tkl_banexception)(int type, const char *usermask, const char *hostmask, int softban); 808 extern MODVAR TKL *(*find_tkl_nameban)(int type, const char *name, int hold); 809 extern MODVAR TKL *(*find_tkl_spamfilter)(int type, const char *match_string, unsigned short action, unsigned short target); 810 extern MODVAR void (*sendnotice_tkl_del)(const char *removed_by, TKL *tkl); 811 extern MODVAR void (*sendnotice_tkl_add)(TKL *tkl); 812 extern MODVAR void (*free_tkl)(TKL *tkl); 813 extern MODVAR TKL *(*tkl_del_line)(TKL *tkl); 814 extern MODVAR void (*tkl_check_local_remove_shun)(TKL *tmp); 815 extern MODVAR int (*find_tkline_match)(Client *cptr, int skip_soft); 816 extern MODVAR int (*find_shun)(Client *cptr); 817 extern MODVAR int (*find_spamfilter_user)(Client *client, int flags); 818 extern MODVAR TKL *(*find_qline)(Client *cptr, const char *nick, int *ishold); 819 extern MODVAR TKL *(*find_tkline_match_zap)(Client *cptr); 820 extern MODVAR void (*tkl_stats)(Client *cptr, int type, const char *para, int *cnt); 821 extern MODVAR void (*tkl_sync)(Client *client); 822 extern MODVAR void (*cmd_tkl)(Client *client, MessageTag *recv_mtags, int parc, const char *parv[]); 823 extern MODVAR int (*place_host_ban)(Client *client, BanAction action, const char *reason, long duration); 824 extern MODVAR int (*match_spamfilter)(Client *client, const char *str_in, int type, const char *cmd, const char *target, int flags, TKL **rettk); 825 extern MODVAR int (*match_spamfilter_mtags)(Client *client, MessageTag *mtags, const char *cmd); 826 extern MODVAR int (*join_viruschan)(Client *client, TKL *tk, int type); 827 extern MODVAR const char *(*StripColors)(const char *text); 828 extern MODVAR void (*spamfilter_build_user_string)(char *buf, const char *nick, Client *acptr); 829 extern MODVAR void (*send_protoctl_servers)(Client *client, int response); 830 extern MODVAR ConfigItem_link *(*verify_link)(Client *client); 831 extern MODVAR void (*send_server_message)(Client *client); 832 extern MODVAR void (*broadcast_md_client)(ModDataInfo *mdi, Client *acptr, ModData *md); 833 extern MODVAR void (*broadcast_md_channel)(ModDataInfo *mdi, Channel *channel, ModData *md); 834 extern MODVAR void (*broadcast_md_member)(ModDataInfo *mdi, Channel *channel, Member *m, ModData *md); 835 extern MODVAR void (*broadcast_md_membership)(ModDataInfo *mdi, Client *acptr, Membership *m, ModData *md); 836 extern MODVAR void (*broadcast_md_client_cmd)(Client *except, Client *sender, Client *acptr, const char *varname, const char *value); 837 extern MODVAR void (*broadcast_md_channel_cmd)(Client *except, Client *sender, Channel *channel, const char *varname, const char *value); 838 extern MODVAR void (*broadcast_md_member_cmd)(Client *except, Client *sender, Channel *channel, Client *acptr, const char *varname, const char *value); 839 extern MODVAR void (*broadcast_md_membership_cmd)(Client *except, Client *sender, Client *acptr, Channel *channel, const char *varname, const char *value); 840 extern MODVAR void (*moddata_add_s2s_mtags)(Client *client, MessageTag **mtags); 841 extern MODVAR void (*moddata_extract_s2s_mtags)(Client *client, MessageTag *mtags); 842 extern MODVAR void (*send_moddata_client)(Client *srv, Client *acptr); 843 extern MODVAR void (*send_moddata_channel)(Client *srv, Channel *channel); 844 extern MODVAR void (*send_moddata_members)(Client *srv); 845 extern MODVAR void (*broadcast_moddata_client)(Client *acptr); 846 extern MODVAR void (*introduce_user)(Client *to, Client *acptr); 847 extern MODVAR int (*check_deny_version)(Client *cptr, const char *software, int protocol, const char *flags); 848 extern MODVAR int (*match_user)(const char *rmask, Client *acptr, int options); 849 extern MODVAR void (*userhost_save_current)(Client *client); 850 extern MODVAR void (*userhost_changed)(Client *client); 851 extern MODVAR void (*send_join_to_local_users)(Client *client, Channel *channel, MessageTag *mtags); 852 extern MODVAR int (*do_nick_name)(char *nick); 853 extern MODVAR int (*do_remote_nick_name)(char *nick); 854 extern MODVAR const char *(*charsys_get_current_languages)(void); 855 extern MODVAR void (*broadcast_sinfo)(Client *acptr, Client *to, Client *except); 856 extern MODVAR void (*connect_server)(ConfigItem_link *aconf, Client *by, struct hostent *hp); 857 extern MODVAR int (*is_services_but_not_ulined)(Client *client); 858 extern MODVAR void (*parse_message_tags)(Client *cptr, char **str, MessageTag **mtag_list); 859 extern MODVAR const char *(*mtags_to_string)(MessageTag *m, Client *acptr); 860 extern MODVAR int (*can_send_to_channel)(Client *cptr, Channel *channel, const char **msgtext, const char **errmsg, int notice); 861 extern MODVAR void (*broadcast_md_globalvar)(ModDataInfo *mdi, ModData *md); 862 extern MODVAR void (*broadcast_md_globalvar_cmd)(Client *except, Client *sender, const char *varname, const char *value); 863 extern MODVAR int (*tkl_ip_hash)(const char *ip); 864 extern MODVAR int (*tkl_ip_hash_type)(int type); 865 extern MODVAR int (*find_tkl_exception)(int ban_type, Client *cptr); 866 extern MODVAR int (*server_ban_parse_mask)(Client *client, int add, char type, const char *str, char **usermask_out, char **hostmask_out, int *soft, const char **error); 867 extern MODVAR int (*server_ban_exception_parse_mask)(Client *client, int add, const char *bantypes, const char *str, char **usermask_out, char **hostmask_out, int *soft, const char **error); 868 extern MODVAR void (*tkl_added)(Client *client, TKL *tkl); 869 extern MODVAR int (*del_silence)(Client *client, const char *mask); 870 extern MODVAR int (*add_silence)(Client *client, const char *mask, int senderr); 871 extern MODVAR int (*is_silenced)(Client *client, Client *acptr); 872 extern MODVAR void *(*labeled_response_save_context)(void); 873 extern MODVAR void (*labeled_response_set_context)(void *ctx); 874 extern MODVAR void (*labeled_response_force_end)(void); 875 extern MODVAR void (*kick_user)(MessageTag *mtags, Channel *channel, Client *client, Client *victim, const char *comment); 876 extern MODVAR int (*watch_add)(const char *nick, Client *client, int flags); 877 extern MODVAR int (*watch_del)(const char *nick, Client *client, int flags); 878 extern MODVAR int (*watch_del_list)(Client *client, int flags); 879 extern MODVAR Watch *(*watch_get)(const char *nick); 880 extern MODVAR int (*watch_check)(Client *client, int reply, int (*watch_notify)(Client *client, Watch *watch, Link *lp, int event)); 881 extern MODVAR char *(*tkl_uhost)(TKL *tkl, char *buf, size_t buflen, int options); 882 extern MODVAR void (*do_unreal_log_remote_deliver)(LogLevel loglevel, const char *subsystem, const char *event_id, MultiLine *msg, const char *json_serialized); 883 extern MODVAR char *(*get_chmodes_for_user)(Client *client, const char *flags); 884 extern MODVAR WhoisConfigDetails (*whois_get_policy)(Client *client, Client *target, const char *name); 885 extern MODVAR int (*make_oper)(Client *client, const char *operblock_name, const char *operclass, ConfigItem_class *clientclass, long modes, const char *snomask, const char *vhost); 886 extern MODVAR int (*unreal_match_iplist)(Client *client, NameList *l); 887 extern MODVAR void (*webserver_send_response)(Client *client, int status, char *msg); 888 extern MODVAR void (*webserver_close_client)(Client *client); 889 extern MODVAR int (*webserver_handle_body)(Client *client, WebRequest *web, const char *readbuf, int length); 890 extern MODVAR void (*rpc_response)(Client *client, json_t *request, json_t *result); 891 extern MODVAR void (*rpc_error)(Client *client, json_t *request, JsonRpcError error_code, const char *error_message); 892 extern MODVAR void (*rpc_error_fmt)(Client *client, json_t *request, JsonRpcError error_code, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf,4,5))); 893 extern MODVAR void (*rpc_send_request_to_remote)(Client *source, Client *target, json_t *request); 894 extern MODVAR void (*rpc_send_response_to_remote)(Client *source, Client *target, json_t *request); 895 extern MODVAR int (*rrpc_supported_simple)(Client *target, char **problem_server); 896 extern MODVAR int (*rrpc_supported)(Client *target, const char *module, const char *minimum_version, char **problem_server); 897 extern MODVAR int (*websocket_handle_websocket)(Client *client, WebRequest *web, const char *readbuf2, int length2, int callback(Client *client, char *buf, int len)); 898 extern MODVAR int (*websocket_create_packet)(int opcode, char **buf, int *len); 899 extern MODVAR int (*websocket_create_packet_ex)(int opcode, char **buf, int *len, char *sendbuf, size_t sendbufsize); 900 extern MODVAR int (*websocket_create_packet_simple)(int opcode, const char **buf, int *len); 901 extern MODVAR const char *(*check_deny_link)(ConfigItem_link *link, int auto_connect); 902 extern MODVAR void (*mtag_add_issued_by)(MessageTag **mtags, Client *client, MessageTag *recv_mtags); 903 /* /Efuncs */ 904 905 /* TLS functions */ 906 extern int early_init_tls(); 907 extern int init_tls(); 908 extern int ssl_handshake(Client *); /* Handshake the accpeted con.*/ 909 extern int ssl_client_handshake(Client *, ConfigItem_link *); /* and the initiated con.*/ 910 extern int unreal_tls_accept(Client *acptr, int fd); 911 extern int unreal_tls_connect(Client *acptr, int fd); 912 extern int SSL_smart_shutdown(SSL *ssl); 913 extern const char *ssl_error_str(int err, int my_errno); 914 extern void unreal_tls_client_handshake(int, int, void *); 915 extern void SSL_set_nonblocking(SSL *s); 916 extern SSL_CTX *init_ctx(TLSOptions *tlsoptions, int server); 917 extern const char *tls_get_cipher(Client *client); 918 extern TLSOptions *get_tls_options_for_client(Client *acptr); 919 extern int outdated_tls_client(Client *acptr); 920 extern const char *outdated_tls_client_build_string(const char *pattern, Client *acptr); 921 extern int check_certificate_expiry_ctx(SSL_CTX *ctx, char **errstr); 922 extern EVENT(tls_check_expiry); 923 extern MODVAR EVP_MD *sha256_function; 924 extern MODVAR EVP_MD *sha1_function; 925 extern MODVAR EVP_MD *md5_function; 926 /* End of TLS functions */ 927 928 /* Default handlers for efunctions */ 929 extern void parse_message_tags_default_handler(Client *client, char **str, MessageTag **mtag_list); 930 extern const char *mtags_to_string_default_handler(MessageTag *m, Client *client); 931 extern void *labeled_response_save_context_default_handler(void); 932 extern void labeled_response_set_context_default_handler(void *ctx); 933 extern void labeled_response_force_end_default_handler(void); 934 extern int add_silence_default_handler(Client *client, const char *mask, int senderr); 935 extern int del_silence_default_handler(Client *client, const char *mask); 936 extern int is_silenced_default_handler(Client *client, Client *acptr); 937 extern void do_unreal_log_remote_deliver_default_handler(LogLevel loglevel, const char *subsystem, const char *event_id, MultiLine *msg, const char *json_serialized); 938 extern int make_oper_default_handler(Client *client, const char *operblock_name, const char *operclass, ConfigItem_class *clientclass, long modes, const char *snomask, const char *vhost); 939 extern void webserver_send_response_default_handler(Client *client, int status, char *msg); 940 extern void webserver_close_client_default_handler(Client *client); 941 extern int webserver_handle_body_default_handler(Client *client, WebRequest *web, const char *readbuf, int length); 942 extern void rpc_response_default_handler(Client *client, json_t *request, json_t *result); 943 extern void rpc_error_default_handler(Client *client, json_t *request, JsonRpcError error_code, const char *error_message); 944 extern void rpc_error_fmt_default_handler(Client *client, json_t *request, JsonRpcError error_code, const char *fmt, ...); 945 extern void rpc_send_request_to_remote_default_handler(Client *source, Client *target, json_t *request); 946 extern void rpc_send_response_to_remote_default_handler(Client *source, Client *target, json_t *response); 947 extern int rrpc_supported_simple_default_handler(Client *target, char **problem_server); 948 extern int rrpc_supported_default_handler(Client *target, const char *module, const char *minimum_version, char **problem_server); 949 extern int websocket_handle_websocket_default_handler(Client *client, WebRequest *web, const char *readbuf2, int length2, int callback(Client *client, char *buf, int len)); 950 extern int websocket_create_packet_default_handler(int opcode, char **buf, int *len); 951 extern int websocket_create_packet_ex_default_handler(int opcode, char **buf, int *len, char *sendbuf, size_t sendbufsize); 952 extern int websocket_create_packet_simple_default_handler(int opcode, const char **buf, int *len); 953 extern void mtag_add_issued_by_default_handler(MessageTag **mtags, Client *client, MessageTag *recv_mtags); 954 /* End of default handlers for efunctions */ 955 956 extern MODVAR MOTDFile opermotd, svsmotd, motd, botmotd, smotd, rules; 957 extern MODVAR int max_connection_count; 958 extern int add_listmode(Ban **list, Client *cptr, Channel *channel, const char *banid); 959 extern int add_listmode_ex(Ban **list, Client *cptr, Channel *channel, const char *banid, const char *setby, time_t seton); 960 extern int del_listmode(Ban **list, Channel *channel, const char *banid); 961 extern int Halfop_mode(long mode); 962 extern const char *convert_regular_ban(char *mask, char *buf, size_t buflen); 963 extern const char *clean_ban_mask(const char *, int, Client *, int); 964 extern int find_invex(Channel *channel, Client *client); 965 extern void DoMD5(char *mdout, const char *src, unsigned long n); 966 extern char *md5hash(char *dst, const char *src, unsigned long n); 967 extern char *sha256hash(char *dst, const char *src, unsigned long n); 968 extern void sha256hash_binary(char *dst, const char *src, unsigned long n); 969 extern void sha1hash_binary(char *dst, const char *src, unsigned long n); 970 extern MODVAR TKL *tklines[TKLISTLEN]; 971 extern MODVAR TKL *tklines_ip_hash[TKLIPHASHLEN1][TKLIPHASHLEN2]; 972 extern const char *cmdname_by_spamftarget(int target); 973 extern void unrealdns_delreq_bycptr(Client *cptr); 974 extern void unrealdns_gethostbyname_link(const char *name, ConfigItem_link *conf, int ipv4_only); 975 extern void unrealdns_delasyncconnects(void); 976 extern EVENT(unrealdns_timeout); 977 extern int is_autojoin_chan(const char *chname); 978 extern void unreal_free_hostent(struct hostent *he); 979 extern struct hostent *unreal_create_hostent(const char *name, const char *ip); 980 extern const char *unreal_time_sync_error(void); 981 extern int unreal_time_synch(int timeout); 982 extern const char *getcloak(Client *client); 983 extern MODVAR unsigned char param_to_slot_mapping[256]; 984 extern const char *cm_getparameter(Channel *channel, char mode); 985 extern const char *cm_getparameter_ex(void **p, char mode); 986 extern void cm_putparameter(Channel *channel, char mode, const char *str); 987 extern void cm_putparameter_ex(void **p, char mode, const char *str); 988 extern void cm_freeparameter(Channel *channel, char mode); 989 extern void cm_freeparameter_ex(void **p, char mode, char *str); 990 extern int file_exists(const char *file); 991 extern time_t get_file_time(const char *fname); 992 extern long get_file_size(const char *fname); 993 extern void free_motd(MOTDFile *motd); /* s_serv.c */ 994 extern void fix_timers(void); 995 extern const char *chfl_to_sjoin_symbol(int s); 996 extern char chfl_to_chanmode(int s); 997 extern void add_pending_net(Client *client, const char *str); 998 extern void free_pending_net(Client *client); 999 extern Client *find_non_pending_net_duplicates(Client *cptr); 1000 extern PendingNet *find_pending_net_by_sid_butone(const char *sid, Client *exempt); 1001 extern Client *find_pending_net_duplicates(Client *cptr, Client **srv, char **sid); 1002 extern MODVAR char serveropts[]; 1003 extern MODVAR char *ISupportStrings[]; 1004 extern void read_packet(int fd, int revents, void *data); 1005 extern int process_packet(Client *cptr, char *readbuf, int length, int killsafely); 1006 extern int parse_chanmode(ParseMode *pm, const char *modebuf_in, const char *parabuf_in); 1007 extern int dead_socket(Client *to, const char *notice); 1008 extern Match *unreal_create_match(MatchType type, const char *str, char **error); 1009 extern void unreal_delete_match(Match *m); 1010 extern int unreal_match(Match *m, const char *str); 1011 extern int unreal_match_method_strtoval(const char *str); 1012 extern char *unreal_match_method_valtostr(int val); 1013 #ifdef _WIN32 1014 extern MODVAR BOOL IsService; 1015 #endif 1016 extern void extcmodes_check_for_changes(void); 1017 extern void umodes_check_for_changes(void); 1018 extern int config_parse_flood(const char *orig, int *times, int *period); 1019 extern int swhois_add(Client *acptr, const char *tag, int priority, const char *swhois, Client *from, Client *skip); 1020 extern int swhois_delete(Client *acptr, const char *tag, const char *swhois, Client *from, Client *skip); 1021 extern void remove_oper_privileges(Client *client, int broadcast_mode_change); 1022 extern int client_starttls(Client *acptr); 1023 extern void start_server_handshake(Client *cptr); 1024 extern void reject_insecure_server(Client *cptr); 1025 extern void report_crash(void); 1026 extern void modulemanager(int argc, char *argv[]); 1027 extern int inet_pton4(const char *src, unsigned char *dst); 1028 extern int inet_pton6(const char *src, unsigned char *dst); 1029 extern int unreal_bind(int fd, const char *ip, int port, SocketType socket_type); 1030 extern int unreal_connect(int fd, const char *ip, int port, SocketType socket_type); 1031 extern int is_valid_ip(const char *str); 1032 extern int ipv6_capable(void); 1033 extern int unix_sockets_capable(void); 1034 #ifdef _WIN32 1035 extern void init_winsock(void); 1036 #endif 1037 extern MODVAR Client *remote_rehash_client; 1038 extern MODVAR json_t *json_rehash_log; 1039 extern MODVAR int debugfd; 1040 extern void convert_to_absolute_path(char **path, const char *reldir); 1041 extern int has_user_mode(Client *acptr, char mode); 1042 extern int has_channel_mode(Channel *channel, char mode); 1043 extern int has_channel_mode_raw(Cmode_t m, char mode); 1044 extern Cmode_t get_extmode_bitbychar(char m); 1045 extern long find_user_mode(char mode); 1046 extern void start_listeners(void); 1047 extern void buildvarstring(const char *inbuf, char *outbuf, size_t len, const char *name[], const char *value[]); 1048 extern int reinit_tls(void); 1049 extern CMD_FUNC(cmd_error); 1050 extern CMD_FUNC(cmd_dns); 1051 extern CMD_FUNC(cmd_info); 1052 extern CMD_FUNC(cmd_summon); 1053 extern CMD_FUNC(cmd_users); 1054 extern CMD_FUNC(cmd_version); 1055 extern CMD_FUNC(cmd_dalinfo); 1056 extern CMD_FUNC(cmd_credits); 1057 extern CMD_FUNC(cmd_license); 1058 extern CMD_FUNC(cmd_module); 1059 extern CMD_FUNC(cmd_rehash); 1060 extern CMD_FUNC(cmd_die); 1061 extern CMD_FUNC(cmd_restart); 1062 extern void cmd_alias(Client *client, MessageTag *recv_mtags, int parc, const char *parv[], const char *cmd); /* special! */ 1063 extern const char *pcre2_version(void); 1064 extern int get_terminal_width(void); 1065 extern int has_common_channels(Client *c1, Client *c2); 1066 extern int user_can_see_member(Client *user, Client *target, Channel *channel); 1067 extern int invisible_user_in_channel(Client *target, Channel *channel); 1068 extern MODVAR int tls_client_index; 1069 extern TLSOptions *FindTLSOptionsForUser(Client *acptr); 1070 extern int IsWebsocket(Client *acptr); 1071 extern Policy policy_strtoval(const char *s); 1072 extern const char *policy_valtostr(Policy policy); 1073 extern char policy_valtochar(Policy policy); 1074 extern int verify_certificate(SSL *ssl, const char *hostname, char **errstr); 1075 extern const char *certificate_name(SSL *ssl); 1076 extern void start_of_normal_client_handshake(Client *acptr); 1077 extern void clicap_pre_rehash(void); 1078 extern void clicap_check_for_changes(void); 1079 extern void unload_all_unused_mtag_handlers(void); 1080 extern void send_cap_notify(int add, const char *token); 1081 extern void sendbufto_one(Client *to, char *msg, unsigned int quick); 1082 extern MODVAR int current_serial; 1083 extern const char *spki_fingerprint(Client *acptr); 1084 extern const char *spki_fingerprint_ex(X509 *x509_cert); 1085 extern int is_module_loaded(const char *name); 1086 extern int is_blacklisted_module(const char *name); 1087 extern void close_std_descriptors(void); 1088 extern void banned_client(Client *acptr, const char *bantype, const char *reason, int global, int noexit); 1089 extern char *mystpcpy(char *dst, const char *src); 1090 extern size_t add_sjsby(char *buf, const char *setby, time_t seton); 1091 extern MaxTarget *findmaxtarget(const char *cmd); 1092 extern void setmaxtargets(const char *cmd, int limit); 1093 extern void freemaxtargets(void); 1094 extern int max_targets_for_command(const char *cmd); 1095 extern void set_targmax_defaults(void); 1096 extern void parse_chanmodes_protoctl(Client *client, const char *str); 1097 extern void concat_params(char *buf, int len, int parc, const char *parv[]); 1098 extern void charsys_check_for_changes(void); 1099 extern MODVAR int maxclients; 1100 extern int fast_badword_match(ConfigItem_badword *badword, const char *line); 1101 extern int fast_badword_replace(ConfigItem_badword *badword, const char *line, char *buf, int max); 1102 extern const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *blocked); 1103 extern int badword_config_process(ConfigItem_badword *ca, const char *str); 1104 extern void badword_config_free(ConfigItem_badword *ca); 1105 extern const char *badword_config_check_regex(const char *s, int fastsupport, int check_broadness); 1106 extern AllowedChannelChars allowed_channelchars_strtoval(const char *str); 1107 extern const char *allowed_channelchars_valtostr(AllowedChannelChars v); 1108 extern HideIdleTimePolicy hideidletime_strtoval(const char *str); 1109 extern const char *hideidletime_valtostr(HideIdleTimePolicy v); 1110 extern long ClientCapabilityBit(const char *token); 1111 extern int is_handshake_finished(Client *client); 1112 extern void SetCapability(Client *acptr, const char *token); 1113 extern void ClearCapability(Client *acptr, const char *token); 1114 extern void new_message(Client *sender, MessageTag *recv_mtags, MessageTag **mtag_list); 1115 extern void new_message_special(Client *sender, MessageTag *recv_mtags, MessageTag **mtag_list, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,4,5))); 1116 extern void generate_batch_id(char *str); 1117 extern MessageTag *find_mtag(MessageTag *mtags, const char *token); 1118 extern MessageTag *duplicate_mtag(MessageTag *mtag); 1119 #define safe_free_message_tags(x) do { if (x) free_message_tags(x); x = NULL; } while(0) 1120 extern void free_message_tags(MessageTag *m); 1121 extern int history_set_limit(const char *object, int max_lines, long max_t); 1122 extern int history_add(const char *object, MessageTag *mtags, const char *line); 1123 extern HistoryResult *history_request(const char *object, HistoryFilter *filter); 1124 extern int history_destroy(const char *object); 1125 extern int can_receive_history(Client *client); 1126 extern void history_send_result(Client *client, HistoryResult *r); 1127 extern void free_history_result(HistoryResult *r); 1128 extern void free_history_filter(HistoryFilter *f); 1129 extern void special_delayed_unloading(void); 1130 extern int write_int64(FILE *fd, uint64_t t); 1131 extern int write_int32(FILE *fd, uint32_t t); 1132 extern int read_int64(FILE *fd, uint64_t *t); 1133 extern int read_int32(FILE *fd, uint32_t *t); 1134 extern int read_data(FILE *fd, void *buf, size_t len); 1135 extern int write_data(FILE *fd, const void *buf, size_t len); 1136 extern int write_str(FILE *fd, const char *x); 1137 extern int read_str(FILE *fd, char **x); 1138 extern void _free_entire_name_list(NameList *n); 1139 extern void _add_name_list(NameList **list, const char *name); 1140 extern void _del_name_list(NameList **list, const char *name); 1141 extern NameList *find_name_list(NameList *list, const char *name); 1142 extern NameList *find_name_list_match(NameList *list, const char *name); 1143 extern int minimum_msec_since_last_run(struct timeval *tv_old, long minimum); 1144 extern int unrl_utf8_validate(const char *str, const char **end); 1145 extern char *unrl_utf8_make_valid(const char *str, char *outputbuf, size_t outputbuflen, int strict_length_check); 1146 extern void utf8_test(void); 1147 extern MODVAR int non_utf8_nick_chars_in_use; 1148 extern void short_motd(Client *client); 1149 extern int should_show_connect_info(Client *client); 1150 extern void send_invalid_channelname(Client *client, const char *channelname); 1151 extern int is_extended_ban(const char *str); 1152 extern int is_extended_server_ban(const char *str); 1153 extern int empty_mode(const char *m); 1154 extern void free_multilinemode(MultiLineMode *m); 1155 #define safe_free_multilinemode(m) do { if (m) free_multilinemode(m); m = NULL; } while(0) 1156 extern int valid_sid(const char *name); 1157 extern int valid_uid(const char *name); 1158 extern void parse_client_queued(Client *client); 1159 extern const char *sha256sum_file(const char *fname); 1160 extern char *filename_strip_suffix(const char *fname, const char *suffix); 1161 extern char *filename_add_suffix(const char *fname, const char *suffix); 1162 extern int filename_has_suffix(const char *fname, const char *suffix); 1163 extern void addmultiline(MultiLine **l, const char *line); 1164 extern void freemultiline(MultiLine *l); 1165 #define safe_free_multiline(x) do { if (x) freemultiline(x); x = NULL; } while(0) 1166 extern MultiLine *line2multiline(const char *str); 1167 extern void sendnotice_multiline(Client *client, MultiLine *m); 1168 extern void unreal_del_quotes(char *i); 1169 extern const char *unreal_add_quotes(const char *str); 1170 extern int unreal_add_quotes_r(const char *i, char *o, size_t len); 1171 extern void user_account_login(MessageTag *recv_mtags, Client *client); 1172 extern void link_generator(void); 1173 extern void update_throttling_timer_settings(void); 1174 extern int hide_idle_time(Client *client, Client *target); 1175 extern void lost_server_link(Client *serv, const char *tls_error_string); 1176 extern const char *sendtype_to_cmd(SendType sendtype); 1177 extern MODVAR MessageTagHandler *mtaghandlers; 1178 extern MODVAR RPCHandler *rpchandlers; 1179 #define nv_find_by_name(stru, name) do_nv_find_by_name(stru, name, ARRAY_SIZEOF((stru))) 1180 extern long do_nv_find_by_name(NameValue *table, const char *cmd, int numelements); 1181 #define nv_find_by_value(stru, value) do_nv_find_by_value(stru, value, ARRAY_SIZEOF((stru))) 1182 extern const char *do_nv_find_by_value(NameValue *table, long value, int numelements); 1183 extern void add_nvplist(NameValuePrioList **lst, int priority, const char *name, const char *value); 1184 extern void add_fmt_nvplist(NameValuePrioList **lst, int priority, const char *name, FORMAT_STRING(const char *format), ...) __attribute__((format(printf,4,5))); 1185 /** Combination of add_nvplist() and buildnumeric() for convenience - only used in WHOIS response functions. 1186 * @param lst The NameValuePrioList &head 1187 * @param priority The priority of the item being added 1188 * @param name The name of the item being added (eg: "certfp") 1189 * @param to The recipient 1190 * @param numeric The numeric, one of RPL_* or ERR_*, see include/numeric.h 1191 * @param ... The parameters for the numeric 1192 * @note Be sure to provide the correct number and type of parameters that belong to the numeric. Check include/numeric.h when in doubt! 1193 */ 1194 #define add_nvplist_numeric(lst, priority, name, to, numeric, ...) add_nvplist_numeric_fmt(lst, priority, name, to, numeric, STR_ ## numeric, ##__VA_ARGS__) 1195 extern void add_nvplist_numeric_fmt(NameValuePrioList **lst, int priority, const char *name, Client *to, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,6,7))); 1196 extern NameValuePrioList *find_nvplist(NameValuePrioList *list, const char *name); 1197 extern const char *get_nvplist(NameValuePrioList *list, const char *name); 1198 extern void free_nvplist(NameValuePrioList *lst); 1199 extern void unreal_add_name_values(NameValuePrioList **n, const char *name, ConfigEntry *ce); 1200 extern const char *namevalue(NameValuePrioList *n); 1201 extern const char *namevalue_nospaces(NameValuePrioList *n); 1202 extern const char *get_connect_extinfo(Client *client); 1203 extern char *unreal_strftime(const char *str); 1204 extern void strtolower(char *str); 1205 extern void strtolower_safe(char *dst, const char *src, int size); 1206 extern void strtoupper(char *str); 1207 extern void strtoupper_safe(char *dst, const char *src, int size); 1208 extern int running_interactively(void); 1209 extern int terminal_supports_color(void); 1210 extern void skip_whitespace(char **p); 1211 extern void read_until(char **p, char *stopchars); 1212 extern int is_ip_valid(const char *ip); 1213 extern int is_file_readable(const char *file, const char *dir); 1214 /* json.c */ 1215 extern int log_json_filter; 1216 extern json_t *json_string_unreal(const char *s); 1217 extern const char *json_object_get_string(json_t *j, const char *name); 1218 extern int json_object_get_integer(json_t *j, const char *name, int default_value); 1219 extern int json_object_get_boolean(json_t *j, const char *name, int default_value); 1220 extern json_t *json_timestamp(time_t v); 1221 extern const char *timestamp_iso8601_now(void); 1222 extern const char *timestamp_iso8601(time_t v); 1223 extern const char *json_get_value(json_t *t); 1224 extern void json_expand_client(json_t *j, const char *key, Client *client, int detail); 1225 extern void json_expand_client_security_groups(json_t *parent, Client *client); 1226 extern void json_expand_channel(json_t *j, const char *key, Channel *channel, int detail); 1227 extern void json_expand_tkl(json_t *j, const char *key, TKL *tkl, int detail); 1228 /* end of json.c */ 1229 /* securitygroup.c start */ 1230 extern MODVAR SecurityGroup *securitygroups; 1231 extern void unreal_delete_masks(ConfigItem_mask *m); 1232 extern void unreal_add_masks(ConfigItem_mask **head, ConfigEntry *ce); 1233 extern int unreal_mask_match(Client *acptr, ConfigItem_mask *m); 1234 extern int unreal_mask_match_string(const char *name, ConfigItem_mask *m); 1235 extern int test_match_item(ConfigFile *conf, ConfigEntry *cep, int *errors); 1236 extern int test_match_block(ConfigFile *conf, ConfigEntry *ce, int *errors_out); 1237 extern int test_match_block_too_broad(ConfigFile *conf, ConfigEntry *ce); 1238 extern int security_group_valid_name(const char *name); 1239 extern int security_group_exists(const char *name); 1240 extern SecurityGroup *add_security_group(const char *name, int order); 1241 extern SecurityGroup *find_security_group(const char *name); 1242 extern void free_security_group(SecurityGroup *s); 1243 extern void set_security_group_defaults(void); 1244 extern int user_allowed_by_security_group(Client *client, SecurityGroup *s); 1245 extern int user_allowed_by_security_group_name(Client *client, const char *secgroupname); 1246 extern const char *get_security_groups(Client *client); 1247 extern int test_match_item(ConfigFile *conf, ConfigEntry *cep, int *errors); 1248 extern int conf_match_item(ConfigFile *conf, ConfigEntry *cep, SecurityGroup **block); 1249 extern int test_match_block(ConfigFile *conf, ConfigEntry *ce, int *errors_out); 1250 extern int conf_match_block(ConfigFile *conf, ConfigEntry *ce, SecurityGroup **block); 1251 extern int test_extended_list(Extban *extban, ConfigEntry *cep, int *errors); 1252 /* securitygroup.c end */ 1253 /* src/unrealdb.c start */ 1254 extern UnrealDB *unrealdb_open(const char *filename, UnrealDBMode mode, char *secret_block); 1255 extern int unrealdb_close(UnrealDB *c); 1256 extern char *unrealdb_test_db(const char *filename, char *secret_block); 1257 extern int unrealdb_write_int64(UnrealDB *c, uint64_t t); 1258 extern int unrealdb_write_int32(UnrealDB *c, uint32_t t); 1259 extern int unrealdb_write_int16(UnrealDB *c, uint16_t t); 1260 extern int unrealdb_write_str(UnrealDB *c, const char *x); 1261 extern int unrealdb_write_char(UnrealDB *c, char t); 1262 extern int unrealdb_read_int64(UnrealDB *c, uint64_t *t); 1263 extern int unrealdb_read_int32(UnrealDB *c, uint32_t *t); 1264 extern int unrealdb_read_int16(UnrealDB *c, uint16_t *t); 1265 extern int unrealdb_read_str(UnrealDB *c, char **x); 1266 extern int unrealdb_read_char(UnrealDB *c, char *t); 1267 extern const char *unrealdb_test_secret(const char *name); 1268 extern UnrealDBConfig *unrealdb_copy_config(UnrealDBConfig *src); 1269 extern UnrealDBConfig *unrealdb_get_config(UnrealDB *db); 1270 extern void unrealdb_free_config(UnrealDBConfig *c); 1271 extern UnrealDBError unrealdb_get_error_code(void); 1272 extern const char *unrealdb_get_error_string(void); 1273 /* src/unrealdb.c end */ 1274 /* secret { } related stuff */ 1275 extern Secret *find_secret(const char *secret_name); 1276 extern void free_secret_cache(SecretCache *c); 1277 extern void free_secret(Secret *s); 1278 extern Secret *secrets; 1279 /* end */ 1280 extern int check_password_strength(const char *pass, int min_length, int strict, char **err); 1281 extern int valid_secret_password(const char *pass, char **err); 1282 extern int flood_limit_exceeded(Client *client, FloodOption opt); 1283 extern FloodSettings *find_floodsettings_block(const char *name); 1284 extern FloodSettings *get_floodsettings_for_user(Client *client, FloodOption opt); 1285 extern MODVAR const char *floodoption_names[]; 1286 extern void flood_limit_exceeded_log(Client *client, const char *floodname); 1287 /* logging */ 1288 extern int config_test_log(ConfigFile *conf, ConfigEntry *ce); 1289 extern int config_run_log(ConfigFile *conf, ConfigEntry *ce); 1290 extern const char *log_level_terminal_color(LogLevel loglevel); 1291 #define TERMINAL_COLOR_RESET "\033[0m" 1292 extern LogType log_type_stringtoval(const char *str); 1293 extern const char *log_type_valtostring(LogType v); 1294 #ifdef DEBUGMODE 1295 #define unreal_log(...) do_unreal_log(__VA_ARGS__, log_data_source(__FILE__, __LINE__, __FUNCTION__), NULL) 1296 #define unreal_log_raw(...) do_unreal_log_raw(__VA_ARGS__, log_data_source(__FILE__, __LINE__, __FUNCTION__), NULL) 1297 #else 1298 #define unreal_log(...) do_unreal_log(__VA_ARGS__, NULL) 1299 #define unreal_log_raw(...) do_unreal_log_raw(__VA_ARGS__, NULL) 1300 #endif 1301 extern void do_unreal_log(LogLevel loglevel, const char *subsystem, const char *event_id, Client *client, const char *msg, ...) __attribute__((format(printf,5,0))); 1302 extern void do_unreal_log_raw(LogLevel loglevel, const char *subsystem, const char *event_id, Client *client, const char *msg, ...); 1303 extern void do_unreal_log_internal_from_remote(LogLevel loglevel, const char *subsystem, const char *event_id, MultiLine *msg, json_t *json, const char *json_serialized, Client *from_server); 1304 extern LogData *log_data_string(const char *key, const char *str); 1305 extern LogData *log_data_char(const char *key, const char c); 1306 extern LogData *log_data_integer(const char *key, int64_t integer); 1307 extern LogData *log_data_timestamp(const char *key, time_t ts); 1308 extern LogData *log_data_client(const char *key, Client *client); 1309 extern LogData *log_data_channel(const char *key, Channel *channel); 1310 extern LogData *log_data_source(const char *file, int line, const char *function); 1311 extern LogData *log_data_socket_error(int fd); 1312 extern LogData *log_data_link_block(ConfigItem_link *link); 1313 extern LogData *log_data_tkl(const char *key, TKL *tkl); 1314 extern LogData *log_data_tls_error(void); 1315 extern void log_pre_rehash(void); 1316 extern int log_tests(void); 1317 extern void config_pre_run_log(void); 1318 extern void log_blocks_switchover(void); 1319 extern void postconf_defaults_log_block(void); 1320 extern int valid_loglevel(int v); 1321 extern LogLevel log_level_stringtoval(const char *str); 1322 extern const char *log_level_valtostring(LogLevel loglevel); 1323 extern LogLevel log_level_stringtoval(const char *str); 1324 extern int valid_event_id(const char *s); 1325 extern int valid_subsystem(const char *s); 1326 extern LogSource *add_log_source(const char *str); 1327 extern void free_log_sources(LogSource *l); 1328 extern int log_sources_match(LogSource *logsource, LogLevel loglevel, const char *subsystem, const char *event_id, int matched_already); 1329 extern const char *timestamp_iso8601_now(void); 1330 extern const char *timestamp_iso8601(time_t v); 1331 extern int is_valid_snomask(char c); 1332 extern int is_valid_snomask_string_testing(const char *str, char **wrong); 1333 /* end of logging */ 1334 extern void add_fake_lag(Client *client, long msec); 1335 extern char *prefix_with_extban(const char *remainder, BanContext *b, Extban *extban, char *buf, size_t buflen); 1336 extern GeoIPResult *geoip_client(Client *client); 1337 extern GeoIPResult *geoip_lookup(const char *ip); 1338 extern void free_geoip_result(GeoIPResult *r); 1339 extern const char *get_operlogin(Client *client); 1340 extern const char *get_operclass(Client *client); 1341 /* url stuff */ 1342 extern const char *unreal_mkcache(const char *url); 1343 extern int has_cached_version(const char *url); 1344 extern int url_is_valid(const char *); 1345 extern const char *displayurl(const char *url); 1346 extern char *url_getfilename(const char *url); 1347 extern void download_file_async(const char *url, time_t cachetime, vFP callback, void *callback_data, char *original_url, int maxredirects); 1348 extern void url_init(void); 1349 extern void url_cancel_handle_by_callback_data(void *ptr); 1350 extern EVENT(url_socket_timeout); 1351 /* end of url stuff */ 1352 extern char *collapse(char *pattern); 1353 extern void clear_scache_hash_table(void); 1354 extern void sendto_one(Client *, MessageTag *mtags, FORMAT_STRING(const char *), ...) __attribute__((format(printf,3,4))); 1355 extern void mark_data_to_send(Client *to); 1356 extern EVENT(garbage_collect); 1357 extern EVENT(loop_event); 1358 extern EVENT(check_pings); 1359 extern EVENT(handshake_timeout); 1360 extern EVENT(check_deadsockets); 1361 extern EVENT(try_connections); 1362 extern const char *my_itoa(int i); 1363 extern void load_tunefile(void); 1364 extern EVENT(save_tunefile); 1365 extern void read_motd(const char *filename, MOTDFile *motd); 1366 extern int target_limit_exceeded(Client *client, void *target, const char *name); 1367 extern void make_umodestr(void); 1368 extern void initwhowas(void); 1369 extern void uid_init(void); 1370 extern const char *uid_get(void); 1371 /* proc i/o */ 1372 extern void add_proc_io_server(void); 1373 extern void procio_post_rehash(int failure); 1374 /* end of proc i/o */ 1375 extern int minimum_msec_since_last_run(struct timeval *tv_old, long minimum); 1376 extern long get_connected_time(Client *client); 1377 extern time_t get_creationtime(Client *client); 1378 extern const char *StripControlCodes(const char *text); 1379 extern const char *StripControlCodesEx(const char *text, char *output, size_t outputlen, int strip_flags); 1380 extern MODVAR Module *Modules; 1381 extern const char *command_issued_by_rpc(MessageTag *mtags);