]>
jfr.im git - irc/evilnet/x3.git/blob - src/helpfile.h
1 /* helpfile.h - Help file loading and display
2 * Copyright 2000-2004 srvx Development Team
4 * This file is part of x3.
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.
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.
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.
21 #if !defined(HELPFILE_H)
30 extern struct userNode
*message_dest
; /* message destination; useful in expansion callbacks */
32 #define MIN_LINE_SIZE 40
33 #define MAX_LINE_SIZE 450
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? */
41 struct helpfile_table
{
42 unsigned int length
: 16;
43 unsigned int width
: 8;
44 unsigned int flags
: 8;
45 const char ***contents
;
48 struct helpfile_expansion
{
49 enum { HF_STRING
, HF_TABLE
} type
;
52 struct helpfile_table table
;
56 typedef struct helpfile_expansion (*expand_func_t
)(const char *variable
);
57 typedef void (*irc_send_func
)(struct userNode
*from
, const char *to
, const char *msg
);
68 struct language
*parent
;
69 struct dict
*messages
; /* const char* -> const char* */
70 struct dict
*helpfiles
; /* phelpfile->name -> phelpfile */
72 extern struct language
*lang_C
;
73 extern struct dict
*languages
;
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
81 int send_message(struct userNode
*dest
, struct userNode
*src
, const char *message
, ...);
82 int send_message_type(int msg_type
, struct userNode
*dest
, struct userNode
*src
, const char *message
, ...);
83 int send_target_message(int msg_type
, const char *dest
, struct userNode
*src
, const char *format
, ...);
84 int send_help(struct userNode
*dest
, struct userNode
*src
, struct helpfile
*hf
, const char *topic
);
85 int send_help_brief(struct userNode
*dest
, struct userNode
*src
, struct helpfile
*hf
, const char *topic
);
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. */
88 void table_send(struct userNode
*from
, const char *to
, unsigned int size
, irc_send_func irc_send
, struct helpfile_table table
);
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)
99 void message_register_table(const struct message_entry
*table
);
100 struct language
*language_find(const char *name
);
101 const 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))
104 void helpfile_init(void);
105 void helpfile_finalize(void);
107 struct helpfile
*open_helpfile(const char *fname
, expand_func_t expand
);
108 void close_helpfile(struct helpfile
*hf
);