]> jfr.im git - irc/evilnet/x3.git/blame - src/helpfile.h
Snoop now tracks channel (excluding X3 modes to reduce flooding) and user modes,...
[irc/evilnet/x3.git] / src / helpfile.h
CommitLineData
d76ed9a9 1/* helpfile.h - Help file loading and display
2 * Copyright 2000-2004 srvx Development Team
3 *
83ff05c3 4 * This file is part of x3.
d76ed9a9 5 *
6 * srvx is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21#if !defined(HELPFILE_H)
22#define HELPFILE_H
23
24#include "common.h"
25
26struct userNode;
27struct handle_info;
28struct string_list;
29
30extern struct userNode *message_dest; /* message destination; useful in expansion callbacks */
31
32#define MIN_LINE_SIZE 40
33#define MAX_LINE_SIZE 450
34
35#define TABLE_REPEAT_HEADERS 0x0001 /* repeat the headers for each columnset? */
36#define TABLE_PAD_LEFT 0x0002 /* pad cells on the left? */
37#define TABLE_REPEAT_ROWS 0x0004 /* put more than one row on a line? */
38#define TABLE_NO_FREE 0x0008 /* don't free the contents? */
39#define TABLE_NO_HEADERS 0x0010 /* is there actually no header? */
40
41struct helpfile_table {
42 unsigned int length : 16;
43 unsigned int width : 8;
44 unsigned int flags : 8;
45 const char ***contents;
46};
47
48struct helpfile_expansion {
49 enum { HF_STRING, HF_TABLE } type;
50 union {
51 char *str;
52 struct helpfile_table table;
53 } value;
54};
55
56typedef struct helpfile_expansion (*expand_func_t)(const char *variable);
57typedef void (*irc_send_func)(struct userNode *from, const char *to, const char *msg);
58
59struct helpfile {
60 const char *name;
61 struct dict *db;
62 expand_func_t expand;
63};
64
65struct language
66{
67 char *name;
68 struct language *parent;
69 struct dict *messages; /* const char* -> const char* */
70 struct dict *helpfiles; /* phelpfile->name -> phelpfile */
71};
72extern struct language *lang_C;
73extern struct dict *languages;
74
a32da4c7 75#define MSG_TYPE_NOTICE 0
76#define MSG_TYPE_PRIVMSG 1
77#define MSG_TYPE_WALLCHOPS 2
78#define MSG_TYPE_NOXLATE 4
79#define MSG_TYPE_MULTILINE 8
80
d76ed9a9 81int send_message(struct userNode *dest, struct userNode *src, const char *message, ...);
82int send_message_type(int msg_type, struct userNode *dest, struct userNode *src, const char *message, ...);
83int send_target_message(int msg_type, const char *dest, struct userNode *src, const char *format, ...);
84int send_help(struct userNode *dest, struct userNode *src, struct helpfile *hf, const char *topic);
a915f7d4 85int send_help_brief(struct userNode *dest, struct userNode *src, struct helpfile *hf, const char *topic);
d76ed9a9 86/* size is maximum line width (up to MAX_LINE_SIZE); 0 means figure it out.
87 * irc_send is either irc_privmsg or irc_notice; NULL means figure it out. */
88void table_send(struct userNode *from, const char *to, unsigned int size, irc_send_func irc_send, struct helpfile_table table);
89
90#define send_channel_message(CHANNEL, ARGS...) send_target_message(5, (CHANNEL)->name, ARGS)
91#define send_channel_notice(CHANNEL, ARGS...) send_target_message(4, (CHANNEL)->name, ARGS)
92#define send_channel_wallchops(CHANNEL, ARGS...) send_target_message(6, (CHANNEL)->name, ARGS)
93
94struct message_entry
95{
96 const char *msgid;
97 const char *format;
98};
99void message_register_table(const struct message_entry *table);
100struct language *language_find(const char *name);
101const char *language_find_message(struct language *lang, const char *msgid);
102#define handle_find_message(HANDLE, MSGID) language_find_message((HANDLE) ? (HANDLE)->language : lang_C, (MSGID))
103#define user_find_message(USER, MSGID) language_find_message((USER)->handle_info ? (USER)->handle_info->language : lang_C, (MSGID))
104void helpfile_init(void);
105void helpfile_finalize(void);
106
107struct helpfile *open_helpfile(const char *fname, expand_func_t expand);
108void close_helpfile(struct helpfile *hf);
109
110#endif