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(sun) && defined(SVR4) 42/* losing man.cf is useless because it has no section names */ 43 44static SectionNameRec SectionNames[] = { 45 {"(1) User Commands", "1"}, 46 {"(1b) SunOS/BSD Compatibility Commands", "1b"}, 47 {"(1c) Communication Commands", "1c"}, 48 {"(1f) FMLI Commands", "1f"}, 49 {"(1m) Maintenance Commands", "1m"}, 50 {"(1s) SunOS Specific Commands", "1s"}, 51 {"(2) System Calls", "2"}, 52 {"(3) Introduction to Library Functions", "3"}, 53 {"(3adm) General Administrative Library Functions", "3adm"}, 54 {"(3aio) Asynchronous I/O Library Functions", "3aio"}, 55 {"(3b) SunOS/BSD Compatibility Functions", "3b"}, 56 {"(3bsm) Security and Auditing Library Functions", "3bsm"}, 57 {"(3c) C Library Functions", "3c"}, 58 {"(3cfgadm) Configuration Administration Library Functions", "3cfgadm"}, 59 {"(3crypt) Encryption and Decryption Library", "3crypt"}, 60 {"(3curses) Curses Library Functions", "3curses"}, 61 {"(3devid) Device ID Library Functions", "3devid"}, 62 {"(3devinfo) Device Information Library Functions", "3devinfo"}, 63 {"(3dl) Dynamic Linking Library Functions", "3dl"}, 64 {"(3dmi) DMI Library Functions", "3dmi"}, 65 {"(3door) Door Library Functions", "3door"}, 66 {"(3e) ELF Library Functions", "3e"}, 67 {"(3elf) ELF Library Functions", "3elf"}, 68 {"(3ext) Extended Library Functions", "3ext"}, 69 {"(3g) C Library Functions", "3g"}, 70 {"(3gen) String Pattern-Matching Library Functions", "3gen"}, 71 {"(3head) Headers", "3head"}, 72 {"(3i) Wide Character Functions", "3i"}, 73 {"(3k) Kernel VM Library Functions", "3k"}, 74 {"(3krb) Kerberos Library Functions", "3krb"}, 75 {"(3kstat) Kernel Statistics Library Functions", "3kstat"}, 76 {"(3kvm) Kernel VM Library Functions", "3kvm"}, 77 {"(3layout) Layout Services Library Functions", "3layout"}, 78 {"(3ldap) LDAP Library Functions", "3ldap"}, 79 {"(3lib) Interface Libraries", "3lib"}, 80 {"(3libucb) SunOS/BSD Compatibility Interface Libraries", "3libucb"}, 81 {"(3m) Mathematical Library Functions", "3m"}, 82 {"(3mail) User Mailbox Library Functions", "3mail"}, 83 {"(3malloc) Memory Allocation Library Functions", "3malloc"}, 84 {"(3mp) Integer Mathematical Library Functions", "3mp"}, 85 {"(3n) Network Functions", "3n"}, 86 {"(3nsl) Networking Services Library Functions", "3nsl"}, 87 {"(3pam) PAM Library Functions", "3pam"}, 88 {"(3plot) Graphics Interface Library Functions", "3plot"}, 89 {"(3proc) Process Control Library Functions", "3proc"}, 90 {"(3r) Realtime Library", "3r"}, 91 {"(3rac) Remote Asynchronous Calls Library Functions", "3rac"}, 92 {"(3resolv) Resolver Library Functions", "3resolv"}, 93 {"(3rpc) RPC Library Functions", "3rpc"}, 94 {"(3rt) Realtime Library Functions", "3rt"}, 95 {"(3s) Standard I/O Functions", "3s"}, 96 {"(3sched) LWP Scheduling Library Functions", "3sched"}, 97 {"(3sec) File Access Control Library Functions", "3sec"}, 98 {"(3secdb) Security Attributes Database Library Functions", "3secdb"}, 99 {"(3snmp) SNMP Library Functions", "3snmp"}, 100 {"(3socket) Sockets Library Functions", "3socket"}, 101 {"(3t) Threads Library Functions", "3t"}, 102 {"(3thr) Threads Library Functions", "3thr"}, 103 {"(3tnf) TNF Library Functions", "3tnf"}, 104 {"(3ucb) SunOS/BSD Compatibility Library Functions", "3ucb"}, 105 {"(3volmgt) Volume Management Library Functions", "3volmgt"}, 106 {"(3x) Miscellaneous Library Functions", "3x"}, 107 {"(3xc) X/Open Curses Library Functions", "3xc"}, 108 {"(3xcurses) X/Open Curses Library Functions", "3xcurses"}, 109 {"(3xfn) XFN Interface Library Functions", "3xfn"}, 110 {"(3xn) X/Open Networking Services Library Functions", "3xn"}, 111 {"(3xnet) X/Open Networking Services Library Functions", "3xnet"}, 112 {"(3x11) X Window System: Xlib Functions", "3x11"}, 113 {"(3xcb) X Window System: X C Binding Functions", "3xcb"}, 114 {"(3xext) X Window System: Protocol Extension Functions", "3xext"}, 115 {"(3xi) X Window System: Input Extension Functions", "3xi"}, 116 {"(3xmu) X Window System: Miscellaneous Utility Functions","3xmu"}, 117 {"(3xp) X Window System: Print Extension Functions", "3xp"}, 118 {"(3xt) X Window System: Toolkit Intrinsics Functions", "3xt"}, 119 {"(4) File Formats", "4"}, 120 {"(4b) Misc. Reference Manual Pages", "4b"}, 121 {"(5) Environments, Tables, and TROFF Macros", "5"}, 122 {"(6) Games and Demos", "6"}, 123 {"(7) Special Files", "7"}, 124 {"(7d) Devices", "7d"}, 125 {"(7fs) File Systems", "7fs"}, 126 {"(7i) Ioctl Requests", "7i"}, 127 {"(7m) STREAMS Modules", "7m"}, 128 {"(7p) Protocols", "7p"}, 129 {"(9) Device Driver Information", "9"}, 130 {"(9e) DDI and DKI Driver Entry Points", "9e"}, 131 {"(9f) DDI and DKI Kernel Functions", "9f"}, 132 {"(9s) DDI and DKI Data Structures", "9s"}, 133 {"(l) Local", "l"}, 134 {"(n) New", "n"}, 135 {"(o) Old", "o"} 136}; 137 138#else 139 140static SectionNameRec SectionNames[] = { 141 {"(1) User Commands", "1"}, 142 {"(2) System Calls", "2"}, 143 {"(3) Subroutines", "3"}, 144 {"(4) Devices", "4"}, 145 {"(5) File Formats", "5"}, 146 {"(6) Games", "6"}, 147 {"(7) Miscellaneous", "7"}, 148 {"(8) Sys. Administration", "8"}, 149#if defined(__OpenBSD__) || defined(__NetBSD__) 150 {"(9) Kernel Manual", "9"}, 151#endif 152#if defined(__FreeBSD__) 153 {"(9) Kernel Interfaces", "9"}, 154#endif 155 {"(l) Local", "l"}, 156 {"(n) New", "n"}, 157 {"(o) Old", "o"}, 158}; 159 160#endif 161 162 163/* Function Name: AddStandardSections 164 * Description: Adds all the standard sections to the list for this path. 165 * Arguments: list - a pointer to the section list. 166 * path - the path to these standard sections. 167 * Returns: none. 168 */ 169 170void 171AddStandardSections(SectionList ** list, const char *path) 172{ 173 register int i; 174 char file[BUFSIZ]; 175 int numSections = sizeof(SectionNames) / sizeof(SectionNames[0]); 176 177 for (i = 0; i < numSections; i++) { 178 snprintf(file, sizeof(file), "%s%s", SEARCHDIR, SectionNames[i].suffix); 179 AddNewSection(list, path, file, SectionNames[i].name, TRUE); 180#ifdef SEARCHOTHER 181 snprintf(file, sizeof(file), "%s%s", SEARCHOTHER, 182 SectionNames[i].suffix); 183 AddNewSection(list, path, file, SectionNames[i].name, TRUE); 184#endif 185 } 186} 187 188 189 190/* Function Name: CreateManpageName 191 * Description: Creates the manual page name for a given item. 192 * Arguments: entry - the entry to convert. 193 * Returns: the manual page properly allocated. 194 */ 195 196/* 197 * If the filename is foo.3 - Create an entry of the form: foo 198 * If the filename is foo.3X11 - Create an entry of the form: foo(X11) 199 * IF the filename is a.out.1 - Create an entry of the form: a.out 200 */ 201 202char * 203CreateManpageName(const char *entry, int section, /* FIXME: unused */ 204 int flags) 205{ 206 char *cp; 207 char page[BUFSIZ]; 208 char sect[BUFSIZ]; 209 210 ParseEntry(entry, NULL, sect, page); 211 212 if ((cp = strrchr(page, '.')) != NULL) { 213 if ((int) strlen(cp) > 2) { 214 *cp++ = '('; 215 while ((cp[1] != '\0')) { 216 *cp = *(cp + 1); 217 cp++; 218 } 219 *cp++ = ')'; 220 *cp = '\0'; 221 } 222 else 223 *cp = '\0'; 224 } 225 226 227 return (XtNewString(page)); 228} 229