]> jfr.im git - irc/evilnet/x3.git/blame - src/helpfile.h
Couple of srvx updates.
[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 *
d0f04f71 6 * x3 is free software; you can redistribute it and/or modify
d76ed9a9 7 * it under the terms of the GNU General Public License as published by
348683aa 8 * the Free Software Foundation; either version 3 of the License, or
d76ed9a9 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? */
a8370a20 40#define TABLE_NO_FOOTER 0x0020 /* Dont send a -----End---- footer */
d76ed9a9 41
42struct helpfile_table {
43 unsigned int length : 16;
44 unsigned int width : 8;
45 unsigned int flags : 8;
46 const char ***contents;
47};
48
49struct helpfile_expansion {
50 enum { HF_STRING, HF_TABLE } type;
51 union {
52 char *str;
53 struct helpfile_table table;
54 } value;
55};
56
57typedef struct helpfile_expansion (*expand_func_t)(const char *variable);
58typedef void (*irc_send_func)(struct userNode *from, const char *to, const char *msg);
59
60struct helpfile {
61 const char *name;
62 struct dict *db;
63 expand_func_t expand;
64};
65
66struct language
67{
68 char *name;
69 struct language *parent;
70 struct dict *messages; /* const char* -> const char* */
71 struct dict *helpfiles; /* phelpfile->name -> phelpfile */
72};
73extern struct language *lang_C;
74extern struct dict *languages;
75
a32da4c7 76#define MSG_TYPE_NOTICE 0
77#define MSG_TYPE_PRIVMSG 1
78#define MSG_TYPE_WALLCHOPS 2
79#define MSG_TYPE_NOXLATE 4
80#define MSG_TYPE_MULTILINE 8
81
d76ed9a9 82int send_message(struct userNode *dest, struct userNode *src, const char *message, ...);
83int send_message_type(int msg_type, struct userNode *dest, struct userNode *src, const char *message, ...);
84int send_target_message(int msg_type, const char *dest, struct userNode *src, const char *format, ...);
85int send_help(struct userNode *dest, struct userNode *src, struct helpfile *hf, const char *topic);
a915f7d4 86int send_help_brief(struct userNode *dest, struct userNode *src, struct helpfile *hf, const char *topic);
d76ed9a9 87/* size is maximum line width (up to MAX_LINE_SIZE); 0 means figure it out.
88 * irc_send is either irc_privmsg or irc_notice; NULL means figure it out. */
89void table_send(struct userNode *from, const char *to, unsigned int size, irc_send_func irc_send, struct helpfile_table table);
90
1136f709 91#if defined(GCC_VARMACROS)
92# define send_channel_message(CHANNEL, ARGS...) send_target_message(5, (CHANNEL)->name, ARGS)
93# define send_channel_notice(CHANNEL, ARGS...) send_target_message(4, (CHANNEL)->name, ARGS)
94# define send_channel_wallchops(CHANNEL, ARGS...) send_target_message(6, (CHANNEL)->name, ARGS)
95#elif defined(C99_VARMACROS)
96# define send_channel_message(CHANNEL, ...) send_target_message(5, (CHANNEL)->name, __VA_ARGS__)
97# define send_channel_notice(CHANNEL, ...) send_target_message(4, (CHANNEL)->name, __VA_ARGS__)
98# define send_channel_wallchops(CHANNEL, ...) send_target_message(6, (CHANNEL)->name, __VA_ARGS__)
99#endif
d76ed9a9 100
101struct message_entry
102{
103 const char *msgid;
104 const char *format;
105};
106void message_register_table(const struct message_entry *table);
107struct language *language_find(const char *name);
108const char *language_find_message(struct language *lang, const char *msgid);
109#define handle_find_message(HANDLE, MSGID) language_find_message((HANDLE) ? (HANDLE)->language : lang_C, (MSGID))
110#define user_find_message(USER, MSGID) language_find_message((USER)->handle_info ? (USER)->handle_info->language : lang_C, (MSGID))
111void helpfile_init(void);
112void helpfile_finalize(void);
113
114struct helpfile *open_helpfile(const char *fname, expand_func_t expand);
115void close_helpfile(struct helpfile *hf);
116
3da28d8e 117#ifdef HAVE_HELPSERV
118const char *get_helpserv_id(const char *nick, struct userNode *user);
119#endif
120
d76ed9a9 121#endif