Added SILC Thread Queue API
[silc.git] / util / robodoc / Source / items.c
1 #include <stddef.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include "robodoc.h"
5 #include "items.h"
6
7 /****v* ROBODoc/item_names [3.0g]
8  * NAME
9  *   item_names
10  * SYNOPSIS
11  *   char *item_names[]
12  * FUNCTION
13  *   Defines the names of items that ROBODoc recognized as
14  *   items. For each name their is a corresponding 
15  *   item type (see ItemType). So if you add a name here
16  *   you have to add an item type to. In addition you
17  *   have to add an item attribute (see item_attributes) 
18  *   entry too.
19  * AUTHOR
20  *   Koessi
21  * SEE ALSO
22  *   RB_Get_Item_Type(), item_attributes, item_attr_names,
23  * SOURCE
24  */
25
26 char *item_names[] =
27 {
28   NULL,
29   "NAME",
30   /* Item name + short description */
31   "COPYRIGHT",
32   /* who own the copyright : "(c) <year>-<year> by <company/person>" */
33   "SYNOPSIS", "USAGE",
34   /* how to use it */
35   "FUNCTION", "DESCRIPTION", "PURPOSE",
36   /* what does it */
37   "AUTHOR",
38   /* who wrote it */
39   "CREATION DATE",
40   /* when did the work start */
41   "MODIFICATION HISTORY", "HISTORY",
42   /* who done what changes when */
43   "INPUTS", "ARGUMENTS", "OPTIONS", "PARAMETERS", "SWITCHES",
44   /* what can we feed into it */
45   "OUTPUT", "SIDE EFFECTS",
46   /* what output will be made */
47   "RESULT", "RETURN VALUE",
48   /* what do we get returned */
49   "EXAMPLE",
50   /* a clear example of the items use */
51   "NOTES",
52   /* any annotations */
53   "DIAGNOSTICS",
54   /* diagnostical output */
55   "WARNINGS", "ERRORS",
56   /* warning & error-messages */
57   "BUGS",
58   /* known bugs */
59   "TODO", "IDEAS",
60   /* what to implement next & ideas */
61   "PORTABILITY",
62   /* where does it come from, where will it work */
63   "SEE ALSO",
64   /* references */
65   "SOURCE",
66   /* source code inclusion */
67   "METHODS", "NEW METHODS",
68   /* oop methods */
69   "ATTRIBUTES", "NEW ATTRIBUTES",
70   /* oop attributes */
71   "TAGS",
72   /* tagitem description */
73   "COMMANDS",
74   /* command description */
75   "DERIVED FROM",
76   /* oop super class */
77   "DERIVED BY",
78   /* oop sub class */
79   "USES", "CHILDREN",
80   /* what modules are used by this one */
81   "USED BY", "PARENTS",
82   /* which modules do use this */
83   NULL,
84 };
85
86 /***********/
87
88
89 /****v* ROBODoc/item_attributes [3.0h]
90  * NAME
91  *   item_attributes -- attributes of the various items
92  * FUNCTION
93  *   links each item type with a text attribute.
94  * SEE ALSO
95  *   RB_Get_Item_Type(), item_names, item_attr_names
96  * SOURCE
97  */
98
99 long item_attributes[NUMBER_OF_ITEMS] =
100 {
101   0,                            /* NO_ITEM */
102   ITEM_NAME_LARGE_FONT | TEXT_BODY_SHINE,       /* NAME_ITEM */
103   ITEM_NAME_LARGE_FONT,         /* COPYRIGHT_ITEM */
104   ITEM_NAME_LARGE_FONT | TEXT_BODY_SHINE,       /* SYNOPSIS_ITEM */
105   ITEM_NAME_LARGE_FONT,         /* USAGE_ITEM */
106   ITEM_NAME_LARGE_FONT,         /* FUNCTION_ITEM */
107   ITEM_NAME_LARGE_FONT | TEXT_BODY_DEFAULT,     /* DESCRIPTION_ITEM */
108   ITEM_NAME_LARGE_FONT,         /* PURPOSE_ITEM */
109   ITEM_NAME_LARGE_FONT | TEXT_BODY_BOLD,        /* AUTHOR_ITEM */
110   ITEM_NAME_LARGE_FONT | TEXT_BODY_BOLD,        /* CREATION_DATE_ITEM */
111   ITEM_NAME_LARGE_FONT,         /* MODIFICATION_HISTORY_ITEM */
112   ITEM_NAME_LARGE_FONT,         /* HISTORY_ITEM */
113   ITEM_NAME_LARGE_FONT,         /* INPUT_ITEM */
114   ITEM_NAME_LARGE_FONT,         /* ARGUMENT_ITEM */
115   ITEM_NAME_LARGE_FONT,         /* OPTION_ITEM */
116   ITEM_NAME_LARGE_FONT,         /* PARAMETER_ITEM */
117   ITEM_NAME_LARGE_FONT,         /* SWITCH_ITEM */
118   ITEM_NAME_LARGE_FONT,         /* OUTPUT_ITEM */
119   ITEM_NAME_LARGE_FONT,         /* SIDE_EFFECTS_ITEM */
120   ITEM_NAME_LARGE_FONT,         /* RESULT_ITEM */
121   ITEM_NAME_LARGE_FONT,         /* RETURN_VALUE_ITEM */
122   ITEM_NAME_LARGE_FONT | TEXT_BODY_SHINE,       /* EXAMPLE_ITEM */
123   ITEM_NAME_LARGE_FONT | TEXT_BODY_DEFAULT,     /* NOTE_ITEM */
124   ITEM_NAME_LARGE_FONT,         /* DIAGNOSTICS_ITEM */
125   ITEM_NAME_LARGE_FONT,         /* WARNING_ITEM */
126   ITEM_NAME_LARGE_FONT,         /* ERROR_ITEM */
127   ITEM_NAME_LARGE_FONT | TEXT_BODY_SHINE,       /* BUGS_ITEM */
128   ITEM_NAME_LARGE_FONT,         /* TODO_ITEM */
129   ITEM_NAME_LARGE_FONT,         /* IDEAS_ITEM */
130   ITEM_NAME_LARGE_FONT,         /* PORTABILITY_ITEM */
131   ITEM_NAME_LARGE_FONT,         /* SEE_ALSO_ITEM */
132   ITEM_NAME_LARGE_FONT | TEXT_BODY_SHINE,       /* SOURCE_ITEM */
133   ITEM_NAME_LARGE_FONT,         /* METHODS_ITEM */
134   ITEM_NAME_LARGE_FONT,         /* NEW_METHODS_ITEM */
135   ITEM_NAME_LARGE_FONT,         /* ATTRIBUTES_ITEM */
136   ITEM_NAME_LARGE_FONT,         /* NEW_ATTRIBUTES_ITEM */
137   ITEM_NAME_LARGE_FONT,         /* TAGS_ITEM */
138   ITEM_NAME_LARGE_FONT,         /* COMMANDS_ITEM */
139   ITEM_NAME_LARGE_FONT,         /* DERIVED_FROM_ITEM */
140   ITEM_NAME_LARGE_FONT,         /* DERIVED_BY_ITEM */
141   ITEM_NAME_LARGE_FONT,         /* USES_ITEM */
142   ITEM_NAME_LARGE_FONT,         /* CHILDREN */
143   ITEM_NAME_LARGE_FONT,         /* USED_BY_ITEM */
144   ITEM_NAME_LARGE_FONT,         /* PARENTS */
145   0                             /* OTHER_ITEM */
146 };
147
148 /**********/
149
150
151 /****v* ROBODoc/item_attr_names [3.0j]
152  * NAME
153  *   item_attr_names
154  * SYNOPSIS
155  *   char *item_attr_names[]
156  * FUNCTION
157  *   used for strcmp() in RB_Get_Item_Attr()
158  * AUTHOR
159  *   Koessi
160  * SEE ALSO
161  *   RB_Get_Item_Attr(), item_attributes, item_names
162  * SOURCE
163  */
164
165 char *item_attr_names[] =
166 {
167 /* "NORMAL", */
168   "LARGE", "ITALICS", "NONPROP", "SMALL", "BOLD",
169   "UNDERLINE", "SHINE", "HIGHLIGHT", "DEFAULT",
170 };
171
172 /*************/
173
174
175 /* ASCII AMIGAGUIDE HTML LATEX RTF */
176
177 char *att_start_command[SIZE_ATTRIBUTES][SIZE_MODES] =
178 {
179   {"", "@{b}", "<FONT SIZE=\"+1\">", "{\\large ", "\\par\\fs28 "}, /* Large Font */
180   {"", "@{i}", "<I>", "{\\it ", "\\i1 "},       /* Italics. */
181   {"", "", "", "", ""},         /* NON-Proportional font. */
182   {"", "", "<SMALL>", "{\\small ", "\\fs16 "},  /* Small Font. */
183   {"", "@{b}", "<B>", "{\\bf ", "\\b1 "},       /* Bold. */
184   {"", "@{u}", "<U>", "\\underline{", "\\ul1 "},        /* Underline */
185   {"", "@{fg shine}", "<FONT FACE=\"courier\" size=\"3\">", "{\\em ", ""},/* Shine */
186   {"", "@{fg highlight}", "<EM>", "{\\em ", ""},        /* Highlight */
187   {"", "", "<FONT FACE=\"Helvetiva,Arial,Sans-serif\">", "", ""}        /* Default */
188 };
189
190 char *att_stop_command[SIZE_ATTRIBUTES][SIZE_MODES] =
191 {
192   {"", "@{ub}", "</FONT>", "}", "\\fs20\\line "},       /* Large Font */
193   {"", "@{ui}", "</I>", "}", "\\i0 "},  /* Italics. */
194   {"", "", "", "", ""},         /* NON-Proportional font. */
195   {"", "", "</SMALL>", "}", "\\fs20 "},         /* Small Font. */
196   {"", "@{ub}", "</B>", "}", "\\b0 "},  /* Bold. */
197   {"", "@{uu}", "</U>", "}", "\\ul0 "},         /* Underline */
198   {"", "@{fg text}", "</FONT>", "}", ""},               /* Shine */
199   {"", "@{fg text}", "</EM>", "}", ""}, /* Highlight */
200   {"", "", "</FONT>", "", ""}   /* Normal */
201 };
202
203
204
205 /****f* ROBODoc/RB_Get_Item_Type [3.0b]
206  * NAME
207  *   RB_Get_Item_Type -- shortcut
208  * SYNOPSIS
209  *   int RB_Get_Item_Type( char *cmp_name )
210  * FUNCTION
211  *   return the item_type represented by the given string
212  * INPUTS
213  *   char *cmp_name          -- item_name to evaluate
214  * RESULT
215  *   int                     -- the right item_type or NO_ITEM
216  * NOTES
217  *   uses global char *item_names[]
218  * AUTHOR
219  *   Koessi
220  * SEE ALSO
221  *   RB_Analyse_Defaults_File(), RB_Get_Item_Attr()
222  * SOURCE
223  */
224
225 int
226 RB_Get_Item_Type (char *cmp_name)
227 {
228   int item_type;
229
230   for (item_type = NAME_ITEM; item_type < OTHER_ITEM; ++item_type)
231     {
232       if (!strncmp (item_names[item_type], cmp_name,
233                     strlen (item_names[item_type])))
234         return (item_type);
235     }
236   return (NO_ITEM);
237 }
238
239 /*** RB_Get_Item_Type ***/
240
241
242
243 /****f* ROBODoc/RB_Get_Item_Attr [3.0b]
244  *
245  * NAME
246  *   RB_Get_Item_Attr -- shortcut
247  * SYNOPSIS
248  *   int RB_Get_Item_Attr( char *cmp_name )
249  * FUNCTION
250  *   return the item_attr represented by the given string
251  * INPUTS
252  *   char *cmp_name  -- item_attr_name to evaluate
253  * RESULT
254  *   int             -- the right item_attr or NULL
255  * NOTES
256  *   uses global char *item_attr_names[]
257  * AUTHOR
258  *   Koessi
259  * SEE ALSO
260  *   RB_Analyse_Defaults_File(), RB_Get_Item_Type()
261  * SOURCE
262  */
263
264 int
265 RB_Get_Item_Attr (char *cmp_name)
266 {
267   int item_attr;
268
269   for (item_attr = MAKE_LARGE; item_attr < SIZE_ATTRIBUTES; ++item_attr)
270     if (!strcmp (item_attr_names[item_attr], cmp_name))
271       return (item_attr);
272   if (strcmp ("NORMAL", cmp_name))
273     {
274       fprintf (stderr, "%s: Warning unknown attribute [%s] in defaults file.\n",
275                whoami, cmp_name);
276     }
277   return (MAKE_NORMAL);
278 }
279
280 /************/