vendor.c revision 1abf7346
1/* $XConsortium: vendor.c,v 1.10 94/04/17 20:43:59 rws Exp $ */ 2/* 3 4Copyright (c) 1987, 1988 X Consortium 5 6Permission is hereby granted, free of charge, to any person obtaining 7a copy of this software and associated documentation files (the 8"Software"), to deal in the Software without restriction, including 9without limitation the rights to use, copy, modify, merge, publish, 10distribute, sublicense, and/or sell copies of the Software, and to 11permit persons to whom the Software is furnished to do so, subject to 12the following conditions: 13 14The above copyright notice and this permission notice shall be included 15in all copies or substantial portions of the Software. 16 17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 21OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23OTHER DEALINGS IN THE SOFTWARE. 24 25Except as contained in this notice, the name of the X Consortium shall 26not be used in advertising or otherwise to promote the sale, use or 27other dealings in this Software without prior written authorization 28from the X Consortium. 29 30*/ 31/* $XFree86: xc/programs/xman/vendor.c,v 1.2 2000/03/03 20:02:25 dawes Exp $ */ 32 33/* Vendor-specific data structures and operations */ 34 35#include "globals.h" 36#include "vendor.h" 37 38typedef struct sectionName { 39 char * name; 40 char * suffix; 41} SectionNameRec; 42 43#if (defined(SYSV) || defined(__osf__) || defined(SVR4)) && !defined(sun) 44 45static SectionNameRec SectionNames[] = { 46 {"(1) User Commands", "1"}, 47 {"(1m) Sys, Administration", "1m"}, 48 {"(2) System Calls", "2"}, 49 {"(3) Subroutines", "3"}, 50 {"(4) File Formats", "4"}, 51 {"(5) Miscellaneous", "5"}, 52 {"(6) Games", "6"}, 53 {"(7) Devices", "7"}, 54 {"(8) Sys. Administration", "8"}, 55 {"(l) Local", "l"}, 56 {"(n) New", "n"}, 57 {"(o) Old", "o"} 58#ifdef __SCO__ 59 , 60 { "(ADM) System Administration", "ADM" }, 61 { "(ADMN) Network Administration", "ADMN" }, 62 { "(ADMP) Protocol Administration", "ADMP" }, 63 { "(C) Commands", "C" }, 64 { "(CMD) DOS Commands", "CMD" }, 65 { "(CP) Programming Commands", "CP" }, 66 { "(DOS) DOS Subroutines and Libraries", "DOS" }, 67 { "(F) File Formats", "F" }, 68 { "(HW) Hardware Dependant", "HW" }, 69 { "(K) Kernel Subroutines", "K" }, 70 { "(LOCAL) Local utilities for your system", "LOCAL" }, 71 { "(M) Miscellaneous", "M" }, 72 { "(NADM) NFS Administration", "NADM" }, 73 { "(NC) Network Commands", "NC" }, 74 { "(NF) Network File Formats", "NF" }, 75 { "(NS) Network Subroutines", "NS" }, 76 { "(NSL) Network Services", "NSL" }, 77 { "(S) Subroutines and Libraries", "S" }, 78 { "(SCO) Product Engineering Toolkit", "SCO" }, 79 { "(SFF) Socket File Formats", "SFF" }, 80 { "(STR) Streams", "STR" }, 81 { "(TC) Transport Layer Commands", "TC" }, 82 { "(X) X Man pages", "X" }, 83 { "(XNX) Xenix Subroutines, Commands and Libs", "XNX" }, 84 { "(XS) X11 Subroutines and Libraries", "XS" }, 85 { "(Xm) Motif Commands and Subroutines", "Xm" }, 86 { "(Xt) X Intrinsics", "Xt" } 87#endif 88}; 89 90#else 91 92#if defined(sun) && defined(SVR4) 93/* losing man.cf is useless because it has no section names */ 94 95static SectionNameRec SectionNames[] = { 96 {"(1) User Commands", "1"}, 97 {"(1b) SunOS/BSD Compatibility Commands", "1b"}, 98 {"(1c) Communication Commands", "1c"}, 99 {"(1f) FMLI Commands", "1f"}, 100 {"(1m) Maintenance Commands", "1m"}, 101 {"(1s) SunOS Specific Commands", "1s"}, 102 {"(2) System Calls", "2"}, 103 {"(3) C Library Functions", "3"}, 104 {"(3b) SunOS/BSD Compatibility Functions", "3b"}, 105 {"(3c) C Library Functions", "3c"}, 106 {"(3e) ELF Library Functions", "3e"}, 107 {"(3g) C Library Functions", "3g"}, 108 {"(3i) Wid Character Functions", "3i"}, 109 {"(3k) Kernel VM Library Functions", "3k"}, 110 {"(3m) Mathematical Library", "3m"}, 111 {"(3n) Network Functions", "3n"}, 112 {"(3r) RPC Services Library", "3r"}, 113 {"(3s) Standard I/O Functions", "3s"}, 114#if OSMINORVERSION == 5 115 {"(3t) Threads Library", "3t"}, 116#endif 117 {"(3x) Miscellaneous Library Functions", "3x"}, 118 {"(4) File Formats", "4"}, 119 {"(4b) Misc. Reference Manual Pages", "4b"}, 120 {"(5) Environments, Tables, and TROFF Macros", "5"}, 121 {"(6) Games and Demos", "6"}, 122 {"(7) Special Files", "7"}, 123#if OSMINORVERSION == 5 124 {"(7d) Devices", "7d"}, 125 {"(7fs) File Systems", "7fs"}, 126 {"(7i) Ioctl Requests", "7i"}, 127 {"(7m) STREAMS Modules", "7m"}, 128 {"(7p) Protocols", "7p"}, 129#endif 130 {"(9) Device Driver Information", "9"}, 131 {"(9e) DDI and DKI Driver Entry Points", "9e"}, 132 {"(9f) DDI and DKI Kernel Functions", "9f"}, 133 {"(9s) DDI and DKI Data Structures", "9s"}, 134 {"(l) Local", "l"}, 135 {"(n) New", "n"}, 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#ifdef Lynx 150 {"(9) Device driver service calls", "9"}, 151#endif 152#if defined(__OpenBSD__) || defined(__NetBSD__) 153 {"(9) Kernel Manual", "9"}, 154#endif 155#if defined(__FreeBSD__) 156 {"(9) Kernel Interfaces", "9"}, 157#endif 158 {"(l) Local", "l"}, 159 {"(n) New", "n"}, 160 {"(o) Old", "o"}, 161#ifdef sony 162 {"(p) Public Domain", "p"}, 163 {"(s) Sony Specific", "s"}, 164#endif 165}; 166 167#endif 168#endif 169 170/* Function Name: AddStandardSections 171 * Description: Adds all the standard sections to the list for this path. 172 * Arguments: list - a pointer to the section list. 173 * path - the path to these standard sections. 174 * Returns: none. 175 */ 176 177void AddStandardSections( 178SectionList **list, 179char * path) 180{ 181#ifdef CRAY 182 AddStandardCraySections(list, path); 183 return; 184#else 185 register int i; 186 char file[BUFSIZ]; 187 int numSections = sizeof(SectionNames) / sizeof(SectionNames[0]); 188 189 for (i=0; i < numSections; i++) { 190 sprintf(file, "%s%s", SEARCHDIR, SectionNames[i].suffix); 191 AddNewSection(list, path, file, SectionNames[i].name, TRUE); 192#ifdef SEARCHOTHER 193 sprintf(file, "%s%s", SEARCHOTHER, SectionNames[i].suffix); 194 AddNewSection(list, path, file, SectionNames[i].name, TRUE); 195#endif 196 } 197#endif 198} 199 200#ifdef CRAY 201/* Function Name: AddStandardCraySections 202 * Description: Add sections specific to the Cray. 203 * Arguments: list - a pointer to the section list. 204 * path - the path to these standard sections. 205 * names - standard section names. 206 * Returns: none. 207 */ 208 209void AddStandardCraySections( 210SectionList **list, 211char *path) 212{ 213 char file[BUFSIZ]; 214 int i; 215#define NoSuf (char *)0 216#define Suffix (char *)1 217#define Fold (char *)2 218#define FoldSuffix (char *)3 219 static char *cname[] = { 220 "(1) User Commands", Suffix, "1", "1bsd", NULL, 221 "(1) User Commands (instant)", NoSuf, "1r", "1rb", NULL, 222 "(1m) System Administration", NoSuf, "1m", NULL, 223 "(2) System Calls", Suffix, "2", NULL, 224 "(3) Subroutines", FoldSuffix, "3", "3bsd", "3c", "3m", "3mt", "3s", "3sl", "3z", NULL, 225 "(3) Subroutines (FORTRAN)", Fold, "3f", NULL, 226 "(3) Subroutines (I/O)", Fold, "3io", NULL, 227 "(3) Subroutines (X11)", NoSuf, "3X11", NULL, 228 "(3) Subroutines (Xt)", NoSuf, "3Xt", NULL, 229 "(3) Subroutines (misc.)", Suffix, "3q", NULL, 230 "(3) Subroutines (misc.)", Fold, "3x", NULL, 231 "(3) Subroutines (networking)", Suffix, "3n", "3rpc", "3svc", "3w", "3yp", NULL, 232 "(3) Subroutines (scientific)", Fold, "3sci", NULL, 233 "(3) Subroutines (utilities)", FoldSuffix, "3db", "3u", NULL, 234 "(4) Devices", Suffix, "4", "4d", "4f", "4n", "4p", "4s", NULL, 235 "(5) File Formats", Suffix, "5", NULL, 236 "(6) Games", Suffix, "6", NULL, 237 "(7) Miscellaneous", Suffix, "7", NULL, 238 "(8) Sys. Administration", NoSuf, "8", NULL, 239 "(l) Local", Suffix, "l", NULL, 240 "(n) New", Suffix, "n", NULL, 241 "(o) Old", Suffix, "o", NULL, 242 "(info) Information", NoSuf, "info", NULL, 243 "(osi) Miscellaneous", NoSuf, "osi", NULL, 244 "(sl) Miscellaneous", NoSuf, "sl", NULL, 245 "(ultra) Miscellaneous", NoSuf, "ultra", NULL, 246 NULL 247 }; 248 char **p = cname; 249 250 while (*p != NULL) { 251 char *message = *p++; 252 int flags = (int) *p++; 253 while (*p != NULL) { 254 sprintf(file, "%s%s", SEARCHDIR, *p++); 255 AddNewSection(list, path, file, message, flags); 256 } 257 p++; 258 } 259} 260#endif /* CRAY */ 261 262 263/* Function Name: CreateManpageName 264 * Description: Creates the manual page name for a given item. 265 * Arguments: entry - the entry to convert. 266 * Returns: the manual page properly allocated. 267 */ 268 269/* 270 * If the filename is foo.3 - Create an entry of the form: foo 271 * If the filename is foo.3X11 - Create an entry of the form: foo(X11) 272 * IF the filename is a.out.1 - Create an entry of the form: a.out 273 */ 274 275char * 276CreateManpageName( 277char * entry, 278int section, /* FIXME: unused */ 279int flags) 280{ 281 char * cp; 282 char page[BUFSIZ]; 283 char sect[BUFSIZ]; 284 285 ParseEntry(entry, NULL, sect, page); 286 287#ifndef CRAY 288 if ( (cp = rindex(page, '.')) != NULL) { 289 if ( (int)strlen(cp) > 2 ) { 290 *cp++ = '('; 291 while( (cp[1] != '\0') ) { 292 *cp = *(cp + 1); 293 cp++; 294 } 295 *cp++ = ')'; 296 *cp = '\0'; 297 } 298 else 299 *cp = '\0'; 300 } 301 302#else /* CRAY - pick up the Cray name from the section */ 303 304 if ( (cp = rindex(page, '.')) == NULL) 305 cp = page + strlen(page); 306 if ((flags & MSUFFIX) && strlen(sect) > 4) { 307 char *p = sect + 4; 308 *cp++ = '('; 309 while (*p) 310 *cp++ = *p++; 311 *cp++ = ')'; 312 } 313 *cp = '\0'; 314 315#endif /* CRAY */ 316 317 return(StrAlloc(page)); 318} 319