vendor.c revision 6d36ef34
1/*
2
3Copyright (c) 1987, 1988  X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining
6a copy of this software and associated documentation files (the
7"Software"), to deal in the Software without restriction, including
8without limitation the rights to use, copy, modify, merge, publish,
9distribute, sublicense, and/or sell copies of the Software, and to
10permit persons to whom the Software is furnished to do so, subject to
11the following conditions:
12
13The above copyright notice and this permission notice shall be included
14in all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
20OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22OTHER DEALINGS IN THE SOFTWARE.
23
24Except as contained in this notice, the name of the X Consortium shall
25not be used in advertising or otherwise to promote the sale, use or
26other dealings in this Software without prior written authorization
27from the X Consortium.
28
29*/
30
31/* Vendor-specific data structures and operations */
32
33#include "globals.h"
34#include "vendor.h"
35
36typedef struct sectionName {
37    const char *name;
38    const char *suffix;
39} SectionNameRec;
40
41#if (defined(__osf__) || defined(SVR4)) && !defined(sun)
42
43static SectionNameRec SectionNames[] = {
44    {"(1) User Commands",               "1"},
45    {"(1m) Sys, Administration",        "1m"},
46    {"(2) System Calls",                "2"},
47    {"(3) Subroutines",                 "3"},
48    {"(4) File Formats",                "4"},
49    {"(5) Miscellaneous",               "5"},
50    {"(6) Games",                       "6"},
51    {"(7) Devices",                     "7"},
52    {"(8) Sys. Administration",         "8"},
53    {"(l) Local",                       "l"},
54    {"(n) New",                         "n"},
55    {"(o) Old",                         "o"}
56#ifdef __SCO__
57    ,
58    {"(ADM) System Administration", "ADM"},
59    {"(ADMN) Network Administration", "ADMN"},
60    {"(ADMP) Protocol Administration", "ADMP"},
61    {"(C) Commands", "C"},
62    {"(CMD) DOS Commands", "CMD"},
63    {"(CP) Programming Commands", "CP"},
64    {"(DOS) DOS Subroutines and Libraries", "DOS"},
65    {"(F) File Formats", "F"},
66    {"(HW) Hardware Dependant", "HW"},
67    {"(K) Kernel Subroutines", "K"},
68    {"(LOCAL) Local utilities for your system", "LOCAL"},
69    {"(M) Miscellaneous", "M"},
70    {"(NADM) NFS Administration", "NADM"},
71    {"(NC) Network Commands", "NC"},
72    {"(NF) Network File Formats", "NF"},
73    {"(NS) Network Subroutines", "NS"},
74    {"(NSL) Network Services", "NSL"},
75    {"(S) Subroutines and Libraries", "S"},
76    {"(SCO) Product Engineering Toolkit", "SCO"},
77    {"(SFF) Socket File Formats", "SFF"},
78    {"(STR) Streams", "STR"},
79    {"(TC) Transport Layer Commands", "TC"},
80    {"(X) X Man pages", "X"},
81    {"(XNX) Xenix Subroutines, Commands and Libs", "XNX"},
82    {"(XS) X11 Subroutines and Libraries", "XS"},
83    {"(Xm) Motif Commands and Subroutines", "Xm"},
84    {"(Xt) X Intrinsics", "Xt"}
85#endif
86};
87
88#else
89
90#if defined(sun) && defined(SVR4)
91/* losing man.cf is useless because it has no section names */
92
93static SectionNameRec SectionNames[] = {
94    {"(1)  User Commands",                      "1"},
95    {"(1b) SunOS/BSD Compatibility Commands",   "1b"},
96    {"(1c) Communication Commands",             "1c"},
97    {"(1f) FMLI Commands",                      "1f"},
98    {"(1m) Maintenance Commands",               "1m"},
99    {"(1s) SunOS Specific Commands",            "1s"},
100    {"(2)  System Calls",                       "2"},
101    {"(3)  Introduction to Library Functions",  "3"},
102    {"(3adm) General Administrative Library Functions", "3adm"},
103    {"(3aio) Asynchronous I/O Library Functions",       "3aio"},
104    {"(3b) SunOS/BSD Compatibility Functions",  "3b"},
105    {"(3bsm) Security and Auditing Library Functions",  "3bsm"},
106    {"(3c) C Library Functions",                "3c"},
107    {"(3cfgadm) Configuration Administration Library Functions",  "3cfgadm"},
108    {"(3crypt) Encryption and Decryption Library",  "3crypt"},
109    {"(3curses) Curses Library Functions",      "3curses"},
110    {"(3devid) Device ID Library Functions",    "3devid"},
111    {"(3devinfo) Device Information Library Functions",  "3devinfo"},
112    {"(3dl) Dynamic Linking Library Functions", "3dl"},
113    {"(3dmi) DMI Library Functions",            "3dmi"},
114    {"(3door) Door Library Functions",          "3door"},
115    {"(3e) ELF Library Functions",              "3e"},
116    {"(3elf) ELF Library Functions",            "3elf"},
117    {"(3ext) Extended Library Functions",       "3ext"},
118    {"(3g) C Library Functions",                "3g"},
119    {"(3gen) String Pattern-Matching Library Functions", "3gen"},
120    {"(3head) Headers",                         "3head"},
121    {"(3i) Wide Character Functions",           "3i"},
122    {"(3k) Kernel VM Library Functions",        "3k"},
123    {"(3krb) Kerberos Library Functions",       "3krb"},
124    {"(3kstat) Kernel Statistics Library Functions",    "3kstat"},
125    {"(3kvm) Kernel VM Library Functions",      "3kvm"},
126    {"(3layout) Layout Services Library Functions",     "3layout"},
127    {"(3ldap) LDAP Library Functions",          "3ldap"},
128    {"(3lib) Interface Libraries",              "3lib"},
129    {"(3libucb) SunOS/BSD Compatibility Interface Libraries",   "3libucb"},
130    {"(3m) Mathematical Library Functions",     "3m"},
131    {"(3mail) User Mailbox Library Functions",  "3mail"},
132    {"(3malloc) Memory Allocation Library Functions",   "3malloc"},
133    {"(3mp) Integer Mathematical Library Functions",    "3mp"},
134    {"(3n) Network Functions",                  "3n"},
135    {"(3nsl) Networking Services Library Functions",    "3nsl"},
136    {"(3pam) PAM Library Functions",                    "3pam"},
137    {"(3plot) Graphics Interface Library Functions",    "3plot"},
138    {"(3proc) Process Control Library Functions",       "3proc"},
139    {"(3r) Realtime Library",                   "3r"},
140    {"(3rac) Remote Asynchronous Calls Library Functions", "3rac"},
141    {"(3resolv) Resolver Library Functions",    "3resolv"},
142    {"(3rpc) RPC Library Functions",            "3rpc"},
143    {"(3rt) Realtime Library Functions",        "3rt"},
144    {"(3s) Standard I/O Functions",             "3s"},
145    {"(3sched) LWP Scheduling Library Functions",       "3sched"},
146    {"(3sec) File Access Control Library Functions",    "3sec"},
147    {"(3secdb) Security Attributes Database Library Functions", "3secdb"},
148    {"(3snmp) SNMP Library Functions",          "3snmp"},
149    {"(3socket) Sockets Library Functions",     "3socket"},
150    {"(3t) Threads Library Functions",          "3t"},
151    {"(3thr) Threads Library Functions",        "3thr"},
152    {"(3tnf) TNF Library Functions",            "3tnf"},
153    {"(3ucb) SunOS/BSD Compatibility Library Functions", "3ucb"},
154    {"(3volmgt) Volume Management Library Functions",   "3volmgt"},
155    {"(3x) Miscellaneous Library Functions",    "3x"},
156    {"(3xc) X/Open Curses Library Functions",   "3xc"},
157    {"(3xcurses) X/Open Curses Library Functions",      "3xcurses"},
158    {"(3xfn) XFN Interface Library Functions",  "3xfn"},
159    {"(3xn) X/Open Networking Services Library Functions",      "3xn"},
160    {"(3xnet) X/Open Networking Services Library Functions",    "3xnet"},
161    {"(3x11)  X Window System: Xlib Functions", "3x11"},
162    {"(3xcb)  X Window System: X C Binding Functions",          "3xcb"},
163    {"(3xext) X Window System: Protocol Extension Functions",   "3xext"},
164    {"(3xi)   X Window System: Input Extension Functions",      "3xi"},
165    {"(3xmu)  X Window System: Miscellaneous Utility Functions","3xmu"},
166    {"(3xp)   X Window System: Print Extension Functions",      "3xp"},
167    {"(3xt)   X Window System: Toolkit Intrinsics Functions",   "3xt"},
168    {"(4)  File Formats",                       "4"},
169    {"(4b) Misc. Reference Manual Pages",       "4b"},
170    {"(5)  Environments, Tables, and TROFF Macros", "5"},
171    {"(6)  Games and Demos",                    "6"},
172    {"(7)  Special Files",                      "7"},
173    {"(7d)  Devices",                           "7d"},
174    {"(7fs) File Systems",                      "7fs"},
175    {"(7i)  Ioctl Requests",                    "7i"},
176    {"(7m)  STREAMS Modules",                   "7m"},
177    {"(7p)  Protocols",                         "7p"},
178    {"(9)  Device Driver Information",          "9"},
179    {"(9e) DDI and DKI Driver Entry Points",    "9e"},
180    {"(9f) DDI and DKI Kernel Functions",       "9f"},
181    {"(9s) DDI and DKI Data Structures",        "9s"},
182    {"(l)  Local",                              "l"},
183    {"(n)  New",                                "n"},
184    {"(o)  Old",                                "o"}
185};
186
187#else
188
189static SectionNameRec SectionNames[] = {
190    {"(1) User Commands",                       "1"},
191    {"(2) System Calls",                        "2"},
192    {"(3) Subroutines",                         "3"},
193    {"(4) Devices",                             "4"},
194    {"(5) File Formats",                        "5"},
195    {"(6) Games",                               "6"},
196    {"(7) Miscellaneous",                       "7"},
197    {"(8) Sys. Administration",                 "8"},
198#if defined(__OpenBSD__) || defined(__NetBSD__)
199    {"(9) Kernel Manual",                       "9"},
200#endif
201#if defined(__FreeBSD__)
202    {"(9) Kernel Interfaces",                   "9"},
203#endif
204    {"(l) Local",                               "l"},
205    {"(n) New",                                 "n"},
206    {"(o) Old",                                 "o"},
207#ifdef sony
208    {"(p) Public Domain",                       "p"},
209    {"(s) Sony Specific",                       "s"},
210#endif
211};
212
213#endif
214#endif
215
216/*	Function Name: AddStandardSections
217 *	Description: Adds all the standard sections to the list for this path.
218 *	Arguments: list - a pointer to the section list.
219 *                 path - the path to these standard sections.
220 *	Returns: none.
221 */
222
223void
224AddStandardSections(SectionList ** list, const char *path)
225{
226    register int i;
227    char file[BUFSIZ];
228    int numSections = sizeof(SectionNames) / sizeof(SectionNames[0]);
229
230    for (i = 0; i < numSections; i++) {
231        snprintf(file, sizeof(file), "%s%s", SEARCHDIR, SectionNames[i].suffix);
232        AddNewSection(list, path, file, SectionNames[i].name, TRUE);
233#ifdef SEARCHOTHER
234        snprintf(file, sizeof(file), "%s%s", SEARCHOTHER,
235                 SectionNames[i].suffix);
236        AddNewSection(list, path, file, SectionNames[i].name, TRUE);
237#endif
238    }
239}
240
241
242
243/*	Function Name: CreateManpageName
244 *	Description: Creates the manual page name for a given item.
245 *	Arguments: entry - the entry to convert.
246 *	Returns: the manual page properly allocated.
247 */
248
249/*
250 * If the filename is foo.3     - Create an entry of the form:  foo
251 * If the filename is foo.3X11  - Create an entry of the form:  foo(X11)
252 * IF the filename is a.out.1   - Create an entry of the form:  a.out
253 */
254
255char *
256CreateManpageName(const char *entry, int section,     /* FIXME: unused */
257                  int flags)
258{
259    char *cp;
260    char page[BUFSIZ];
261    char sect[BUFSIZ];
262
263    ParseEntry(entry, NULL, sect, page);
264
265    if ((cp = strrchr(page, '.')) != NULL) {
266        if ((int) strlen(cp) > 2) {
267            *cp++ = '(';
268            while ((cp[1] != '\0')) {
269                *cp = *(cp + 1);
270                cp++;
271            }
272            *cp++ = ')';
273            *cp = '\0';
274        }
275        else
276            *cp = '\0';
277    }
278
279
280    return (XtNewString(page));
281}
282