xref: /netbsd-src/external/gpl2/texinfo/dist/info/doc.h (revision 29619d2afe564e54d657b83e5a3ae89584f83720)
1 /*	$NetBSD: doc.h,v 1.1.1.1 2016/01/14 00:11:29 christos Exp $	*/
2 
3 /* doc.h -- Structures associating function pointers with documentation.
4    Id: doc.h,v 1.3 2004/04/11 17:56:45 karl Exp
5 
6    Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc.
7 
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2, or (at your option)
11    any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22    Written by Brian Fox (bfox@ai.mit.edu). */
23 
24 #if !defined (DOC_H)
25 #define DOC_H
26 
27 #include "info.h" /* for NAMED_FUNCTIONS, VFunction, etc.  */
28 
29 #if defined (INFOKEY)
30 /* For each function, we keep track of the first defined key sequence
31    which invokes that function, for each different map.  This is so that
32    the dynamic documentation generation in infodoc.c (a) doesn't have to
33    search through copious KEYMAP_ENTRYs, and, more importantly, (b) the
34    user and programmer can choose the preferred key sequence that is
35    printed for any given function -- it's just the first one that
36    appears in the user's infokey file or the default keymaps in
37    infomap.c.
38 
39    Each FUNCTION_DOC has a linked list of FUNCTION_KEYSEQ structs
40    hanging off it, which are created on startup when the user and/or
41    default keymaps are being parsed.  */
42 typedef struct function_keyseq
43 {
44   struct function_keyseq *next;
45   struct keymap_entry *map;
46   char *keyseq;
47 } FUNCTION_KEYSEQ;
48 
49 #endif /* INFOKEY */
50 
51 
52 /* An array of FUNCTION_DOC structures is defined in doc.c, which is
53    automagically generated by the makedoc utility, whose job is to scan
54    through the source files for command function declarations and
55    compile a list of all the ones it finds.  This saves tedious
56    housekeeping and avoids errors of omission.  */
57 typedef struct
58 {
59   VFunction *func;
60 #if defined (NAMED_FUNCTIONS)
61   char *func_name;
62 #endif /* NAMED_FUNCTIONS */
63 #if defined (INFOKEY)
64   FUNCTION_KEYSEQ *keys;
65 #endif /* INFOKEY */
66    char *doc;
67 } FUNCTION_DOC;
68 
69 extern FUNCTION_DOC function_doc_array[];
70 
71 /* Under the old key-binding system, an info command is specified by
72    the pointer to its function.  Under the new INFOKEY binding system,
73    it is specified by a pointer to the command's FUNCTION_DOC structure,
74    defined in doc.c, from which the pointer to the function can be
75    easily divined using the InfoFunction() extractor.  */
76 #if defined(INFOKEY)
77 typedef FUNCTION_DOC InfoCommand;
78 /* The cast to VFunction * prevents pgcc from complaining about
79    dereferencing a void *.  */
80 #define InfoFunction(ic) ((ic) ? (ic)->func : (VFunction *) NULL)
81 #define InfoCmd(fn) (&function_doc_array[A_##fn])
82 #define DocInfoCmd(fd) ((fd) && (fd)->func ? (fd) : NULL)
83 #else /* !INFOKEY */
84 typedef VFunction InfoCommand;
85 #define InfoFunction(vf) ((vf))
86 #define InfoCmd(fn) fn
87 #define DocInfoCmd(fd) ((fd)->func)
88 #endif /* !INFOKEY */
89 
90 #include "infomap.h" /* for Keymap.  */
91 
92 #if defined (NAMED_FUNCTIONS)
93 extern char *function_name (InfoCommand *cmd);
94 extern InfoCommand *named_function (char *name);
95 #endif /* NAMED_FUNCTIONS */
96 
97 extern char *function_documentation (InfoCommand *cmd);
98 extern char *key_documentation (char key, Keymap map);
99 extern char *pretty_keyname (unsigned char key);
100 extern char *pretty_keyseq (char *keyseq);
101 extern char *where_is (Keymap map, InfoCommand *cmd);
102 extern char *replace_in_documentation (char *string, int help_is_only_window_p);
103 extern void dump_map_to_message_buffer (char *prefix, Keymap map);
104 
105 #endif /* !DOC_H */
106