vendor.c revision 1abf7346
11abf7346Smrg/* $XConsortium: vendor.c,v 1.10 94/04/17 20:43:59 rws Exp $ */
21abf7346Smrg/*
31abf7346Smrg
41abf7346SmrgCopyright (c) 1987, 1988  X Consortium
51abf7346Smrg
61abf7346SmrgPermission is hereby granted, free of charge, to any person obtaining
71abf7346Smrga copy of this software and associated documentation files (the
81abf7346Smrg"Software"), to deal in the Software without restriction, including
91abf7346Smrgwithout limitation the rights to use, copy, modify, merge, publish,
101abf7346Smrgdistribute, sublicense, and/or sell copies of the Software, and to
111abf7346Smrgpermit persons to whom the Software is furnished to do so, subject to
121abf7346Smrgthe following conditions:
131abf7346Smrg
141abf7346SmrgThe above copyright notice and this permission notice shall be included
151abf7346Smrgin all copies or substantial portions of the Software.
161abf7346Smrg
171abf7346SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
181abf7346SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
191abf7346SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
201abf7346SmrgIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
211abf7346SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
221abf7346SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
231abf7346SmrgOTHER DEALINGS IN THE SOFTWARE.
241abf7346Smrg
251abf7346SmrgExcept as contained in this notice, the name of the X Consortium shall
261abf7346Smrgnot be used in advertising or otherwise to promote the sale, use or
271abf7346Smrgother dealings in this Software without prior written authorization
281abf7346Smrgfrom the X Consortium.
291abf7346Smrg
301abf7346Smrg*/
311abf7346Smrg/* $XFree86: xc/programs/xman/vendor.c,v 1.2 2000/03/03 20:02:25 dawes Exp $ */
321abf7346Smrg
331abf7346Smrg/* Vendor-specific data structures and operations */
341abf7346Smrg
351abf7346Smrg#include "globals.h"
361abf7346Smrg#include "vendor.h"
371abf7346Smrg
381abf7346Smrgtypedef struct sectionName {
391abf7346Smrg    char *	name;
401abf7346Smrg    char *	suffix;
411abf7346Smrg} SectionNameRec;
421abf7346Smrg
431abf7346Smrg#if (defined(SYSV) || defined(__osf__) || defined(SVR4)) && !defined(sun)
441abf7346Smrg
451abf7346Smrgstatic SectionNameRec SectionNames[] = {
461abf7346Smrg    {"(1) User Commands",		"1"},
471abf7346Smrg    {"(1m) Sys, Administration",	"1m"},
481abf7346Smrg    {"(2) System Calls",		"2"},
491abf7346Smrg    {"(3) Subroutines",			"3"},
501abf7346Smrg    {"(4) File Formats",		"4"},
511abf7346Smrg    {"(5) Miscellaneous",		"5"},
521abf7346Smrg    {"(6) Games",			"6"},
531abf7346Smrg    {"(7) Devices",			"7"},
541abf7346Smrg    {"(8) Sys. Administration",		"8"},
551abf7346Smrg    {"(l) Local",			"l"},
561abf7346Smrg    {"(n) New",				"n"},
571abf7346Smrg    {"(o) Old",				"o"}
581abf7346Smrg#ifdef __SCO__
591abf7346Smrg      ,
601abf7346Smrg      { "(ADM) System Administration", "ADM" },
611abf7346Smrg      { "(ADMN) Network Administration", "ADMN" },
621abf7346Smrg      { "(ADMP) Protocol Administration", "ADMP" },
631abf7346Smrg      { "(C) Commands", "C" },
641abf7346Smrg      { "(CMD) DOS Commands", "CMD" },
651abf7346Smrg      { "(CP) Programming Commands", "CP" },
661abf7346Smrg      { "(DOS) DOS Subroutines and Libraries", "DOS" },
671abf7346Smrg      { "(F) File Formats", "F" },
681abf7346Smrg      { "(HW) Hardware Dependant", "HW" },
691abf7346Smrg      { "(K) Kernel Subroutines", "K" },
701abf7346Smrg      { "(LOCAL) Local utilities for your system", "LOCAL" },
711abf7346Smrg      { "(M) Miscellaneous", "M" },
721abf7346Smrg      { "(NADM) NFS Administration", "NADM" },
731abf7346Smrg      { "(NC) Network Commands", "NC" },
741abf7346Smrg      { "(NF) Network File Formats", "NF" },
751abf7346Smrg      { "(NS) Network Subroutines", "NS" },
761abf7346Smrg      { "(NSL) Network Services", "NSL" },
771abf7346Smrg      { "(S) Subroutines and Libraries", "S" },
781abf7346Smrg      { "(SCO) Product Engineering Toolkit", "SCO" },
791abf7346Smrg      { "(SFF) Socket File Formats", "SFF" },
801abf7346Smrg      { "(STR) Streams", "STR" },
811abf7346Smrg      { "(TC) Transport Layer Commands", "TC" },
821abf7346Smrg      { "(X) X Man pages", "X" },
831abf7346Smrg      { "(XNX) Xenix Subroutines, Commands and Libs", "XNX" },
841abf7346Smrg      { "(XS) X11 Subroutines and Libraries", "XS" },
851abf7346Smrg      { "(Xm) Motif Commands and Subroutines", "Xm" },
861abf7346Smrg      { "(Xt) X Intrinsics", "Xt" }
871abf7346Smrg#endif
881abf7346Smrg};
891abf7346Smrg
901abf7346Smrg#else
911abf7346Smrg
921abf7346Smrg#if defined(sun) && defined(SVR4)
931abf7346Smrg/* losing man.cf is useless because it has no section names */
941abf7346Smrg
951abf7346Smrgstatic SectionNameRec SectionNames[] = {
961abf7346Smrg    {"(1)  User Commands",			"1"},
971abf7346Smrg    {"(1b) SunOS/BSD Compatibility Commands",	"1b"},
981abf7346Smrg    {"(1c) Communication Commands",		"1c"},
991abf7346Smrg    {"(1f) FMLI Commands",			"1f"},
1001abf7346Smrg    {"(1m) Maintenance Commands",		"1m"},
1011abf7346Smrg    {"(1s) SunOS Specific Commands",		"1s"},
1021abf7346Smrg    {"(2)  System Calls",			"2"},
1031abf7346Smrg    {"(3)  C Library Functions",		"3"},
1041abf7346Smrg    {"(3b) SunOS/BSD Compatibility Functions",	"3b"},
1051abf7346Smrg    {"(3c) C Library Functions",		"3c"},
1061abf7346Smrg    {"(3e) ELF Library Functions",		"3e"},
1071abf7346Smrg    {"(3g) C Library Functions",		"3g"},
1081abf7346Smrg    {"(3i) Wid Character Functions",		"3i"},
1091abf7346Smrg    {"(3k) Kernel VM Library Functions",	"3k"},
1101abf7346Smrg    {"(3m) Mathematical Library",		"3m"},
1111abf7346Smrg    {"(3n) Network Functions",			"3n"},
1121abf7346Smrg    {"(3r) RPC Services Library",		"3r"},
1131abf7346Smrg    {"(3s) Standard I/O Functions",		"3s"},
1141abf7346Smrg#if OSMINORVERSION == 5
1151abf7346Smrg    {"(3t) Threads Library",			"3t"},
1161abf7346Smrg#endif
1171abf7346Smrg    {"(3x) Miscellaneous Library Functions",	"3x"},
1181abf7346Smrg    {"(4)  File Formats",			"4"},
1191abf7346Smrg    {"(4b) Misc. Reference Manual Pages",	"4b"},
1201abf7346Smrg    {"(5)  Environments, Tables, and TROFF Macros", "5"},
1211abf7346Smrg    {"(6)  Games and Demos",			"6"},
1221abf7346Smrg    {"(7)  Special Files",			"7"},
1231abf7346Smrg#if OSMINORVERSION == 5
1241abf7346Smrg    {"(7d)  Devices",				"7d"},
1251abf7346Smrg    {"(7fs) File Systems",			"7fs"},
1261abf7346Smrg    {"(7i)  Ioctl Requests",			"7i"},
1271abf7346Smrg    {"(7m)  STREAMS Modules",			"7m"},
1281abf7346Smrg    {"(7p)  Protocols",				"7p"},
1291abf7346Smrg#endif
1301abf7346Smrg    {"(9)  Device Driver Information",		"9"},
1311abf7346Smrg    {"(9e) DDI and DKI Driver Entry Points",	"9e"},
1321abf7346Smrg    {"(9f) DDI and DKI Kernel Functions",	"9f"},
1331abf7346Smrg    {"(9s) DDI and DKI Data Structures",	"9s"},
1341abf7346Smrg    {"(l)  Local",				"l"},
1351abf7346Smrg    {"(n)  New",				"n"},
1361abf7346Smrg};
1371abf7346Smrg
1381abf7346Smrg#else
1391abf7346Smrg
1401abf7346Smrgstatic SectionNameRec SectionNames[] = {
1411abf7346Smrg    {"(1) User Commands",		"1"},
1421abf7346Smrg    {"(2) System Calls",		"2"},
1431abf7346Smrg    {"(3) Subroutines",			"3"},
1441abf7346Smrg    {"(4) Devices",			"4"},
1451abf7346Smrg    {"(5) File Formats",		"5"},
1461abf7346Smrg    {"(6) Games",			"6"},
1471abf7346Smrg    {"(7) Miscellaneous",		"7"},
1481abf7346Smrg    {"(8) Sys. Administration",		"8"},
1491abf7346Smrg#ifdef Lynx
1501abf7346Smrg    {"(9) Device driver service calls",	"9"},
1511abf7346Smrg#endif
1521abf7346Smrg#if defined(__OpenBSD__) || defined(__NetBSD__)
1531abf7346Smrg    {"(9) Kernel Manual",		"9"},
1541abf7346Smrg#endif
1551abf7346Smrg#if defined(__FreeBSD__)
1561abf7346Smrg    {"(9) Kernel Interfaces",		"9"},
1571abf7346Smrg#endif
1581abf7346Smrg    {"(l) Local",			"l"},
1591abf7346Smrg    {"(n) New",				"n"},
1601abf7346Smrg    {"(o) Old",				"o"},
1611abf7346Smrg#ifdef sony
1621abf7346Smrg    {"(p) Public Domain",		"p"},
1631abf7346Smrg    {"(s) Sony Specific",		"s"},
1641abf7346Smrg#endif
1651abf7346Smrg};
1661abf7346Smrg
1671abf7346Smrg#endif
1681abf7346Smrg#endif
1691abf7346Smrg
1701abf7346Smrg/*	Function Name: AddStandardSections
1711abf7346Smrg *	Description: Adds all the standard sections to the list for this path.
1721abf7346Smrg *	Arguments: list - a pointer to the section list.
1731abf7346Smrg *                 path - the path to these standard sections.
1741abf7346Smrg *	Returns: none.
1751abf7346Smrg */
1761abf7346Smrg
1771abf7346Smrgvoid AddStandardSections(
1781abf7346SmrgSectionList **list,
1791abf7346Smrgchar * path)
1801abf7346Smrg{
1811abf7346Smrg#ifdef CRAY
1821abf7346Smrg    AddStandardCraySections(list, path);
1831abf7346Smrg    return;
1841abf7346Smrg#else
1851abf7346Smrg  register int i;
1861abf7346Smrg  char file[BUFSIZ];
1871abf7346Smrg  int numSections = sizeof(SectionNames) / sizeof(SectionNames[0]);
1881abf7346Smrg
1891abf7346Smrg  for (i=0; i < numSections; i++) {
1901abf7346Smrg    sprintf(file, "%s%s", SEARCHDIR, SectionNames[i].suffix);
1911abf7346Smrg    AddNewSection(list, path, file, SectionNames[i].name, TRUE);
1921abf7346Smrg#ifdef SEARCHOTHER
1931abf7346Smrg    sprintf(file, "%s%s", SEARCHOTHER, SectionNames[i].suffix);
1941abf7346Smrg    AddNewSection(list, path, file, SectionNames[i].name, TRUE);
1951abf7346Smrg#endif
1961abf7346Smrg  }
1971abf7346Smrg#endif
1981abf7346Smrg}
1991abf7346Smrg
2001abf7346Smrg#ifdef CRAY
2011abf7346Smrg/*	Function Name: AddStandardCraySections
2021abf7346Smrg *	Description: Add sections specific to the Cray.
2031abf7346Smrg *	Arguments: list - a pointer to the section list.
2041abf7346Smrg *                 path - the path to these standard sections.
2051abf7346Smrg *                 names - standard section names.
2061abf7346Smrg *	Returns: none.
2071abf7346Smrg */
2081abf7346Smrg
2091abf7346Smrgvoid AddStandardCraySections(
2101abf7346SmrgSectionList **list,
2111abf7346Smrgchar *path)
2121abf7346Smrg{
2131abf7346Smrg  char file[BUFSIZ];
2141abf7346Smrg  int i;
2151abf7346Smrg#define NoSuf  (char *)0
2161abf7346Smrg#define Suffix (char *)1
2171abf7346Smrg#define Fold (char *)2
2181abf7346Smrg#define FoldSuffix (char *)3
2191abf7346Smrg  static char *cname[] = {
2201abf7346Smrg    "(1) User Commands",	Suffix,	"1",	"1bsd",	NULL,
2211abf7346Smrg    "(1) User Commands (instant)",	NoSuf,	"1r",	"1rb",	NULL,
2221abf7346Smrg    "(1m) System Administration",	NoSuf,	"1m",	NULL,
2231abf7346Smrg    "(2) System Calls",		Suffix,	"2",	NULL,
2241abf7346Smrg    "(3) Subroutines",		FoldSuffix,	"3",	"3bsd",	"3c",	"3m",	"3mt",	"3s",	"3sl",	"3z",	NULL,
2251abf7346Smrg    "(3) Subroutines (FORTRAN)", Fold,	"3f",	NULL,
2261abf7346Smrg    "(3) Subroutines (I/O)",	Fold,	"3io",	NULL,
2271abf7346Smrg    "(3) Subroutines (X11)",	NoSuf,	"3X11",	NULL,
2281abf7346Smrg    "(3) Subroutines (Xt)",	NoSuf,	"3Xt",	NULL,
2291abf7346Smrg    "(3) Subroutines (misc.)",	Suffix,	"3q",	NULL,
2301abf7346Smrg    "(3) Subroutines (misc.)",	Fold,	"3x",	NULL,
2311abf7346Smrg    "(3) Subroutines (networking)",	Suffix,	"3n",	"3rpc",	"3svc",	"3w",	"3yp",	NULL,
2321abf7346Smrg    "(3) Subroutines (scientific)",	Fold,	"3sci",	NULL,
2331abf7346Smrg    "(3) Subroutines (utilities)",	FoldSuffix,	"3db",	"3u",	NULL,
2341abf7346Smrg    "(4) Devices",		Suffix,	"4",	"4d",	"4f",	"4n",	"4p",	"4s",	NULL,
2351abf7346Smrg    "(5) File Formats",		Suffix,	"5",	NULL,
2361abf7346Smrg    "(6) Games",		Suffix,	"6",	NULL,
2371abf7346Smrg    "(7) Miscellaneous",	Suffix,	"7",	NULL,
2381abf7346Smrg    "(8) Sys. Administration",	NoSuf,	"8",	NULL,
2391abf7346Smrg    "(l) Local",		Suffix,	"l",	NULL,
2401abf7346Smrg    "(n) New",			Suffix,	"n",	NULL,
2411abf7346Smrg    "(o) Old",			Suffix,	"o",	NULL,
2421abf7346Smrg    "(info) Information",	NoSuf,	"info",	NULL,
2431abf7346Smrg    "(osi) Miscellaneous",	NoSuf,	"osi",	NULL,
2441abf7346Smrg    "(sl) Miscellaneous",	NoSuf,	"sl",	NULL,
2451abf7346Smrg    "(ultra) Miscellaneous",	NoSuf,	"ultra",	NULL,
2461abf7346Smrg    NULL
2471abf7346Smrg  };
2481abf7346Smrg  char **p = cname;
2491abf7346Smrg
2501abf7346Smrg  while (*p != NULL) {
2511abf7346Smrg    char *message = *p++;
2521abf7346Smrg    int flags = (int) *p++;
2531abf7346Smrg    while (*p != NULL) {
2541abf7346Smrg      sprintf(file, "%s%s", SEARCHDIR, *p++);
2551abf7346Smrg      AddNewSection(list, path, file, message, flags);
2561abf7346Smrg    }
2571abf7346Smrg    p++;
2581abf7346Smrg  }
2591abf7346Smrg}
2601abf7346Smrg#endif /* CRAY */
2611abf7346Smrg
2621abf7346Smrg
2631abf7346Smrg/*	Function Name: CreateManpageName
2641abf7346Smrg *	Description: Creates the manual page name for a given item.
2651abf7346Smrg *	Arguments: entry - the entry to convert.
2661abf7346Smrg *	Returns: the manual page properly allocated.
2671abf7346Smrg */
2681abf7346Smrg
2691abf7346Smrg/*
2701abf7346Smrg * If the filename is foo.3     - Create an entry of the form:  foo
2711abf7346Smrg * If the filename is foo.3X11  - Create an entry of the form:  foo(X11)
2721abf7346Smrg * IF the filename is a.out.1   - Create an entry of the form:  a.out
2731abf7346Smrg */
2741abf7346Smrg
2751abf7346Smrgchar *
2761abf7346SmrgCreateManpageName(
2771abf7346Smrgchar * entry,
2781abf7346Smrgint section,	/* FIXME: unused */
2791abf7346Smrgint flags)
2801abf7346Smrg{
2811abf7346Smrg  char * cp;
2821abf7346Smrg  char page[BUFSIZ];
2831abf7346Smrg  char sect[BUFSIZ];
2841abf7346Smrg
2851abf7346Smrg  ParseEntry(entry, NULL, sect, page);
2861abf7346Smrg
2871abf7346Smrg#ifndef CRAY
2881abf7346Smrg  if ( (cp = rindex(page, '.')) != NULL) {
2891abf7346Smrg    if ( (int)strlen(cp) > 2 ) {
2901abf7346Smrg      *cp++ = '(';
2911abf7346Smrg      while( (cp[1] != '\0') ) {
2921abf7346Smrg	*cp = *(cp + 1);
2931abf7346Smrg	cp++;
2941abf7346Smrg      }
2951abf7346Smrg      *cp++ = ')';
2961abf7346Smrg      *cp = '\0';
2971abf7346Smrg    }
2981abf7346Smrg    else
2991abf7346Smrg      *cp = '\0';
3001abf7346Smrg  }
3011abf7346Smrg
3021abf7346Smrg#else	/* CRAY	- pick up the Cray name from the section */
3031abf7346Smrg
3041abf7346Smrg  if ( (cp = rindex(page, '.')) == NULL)
3051abf7346Smrg    cp = page + strlen(page);
3061abf7346Smrg  if ((flags & MSUFFIX) && strlen(sect) > 4) {
3071abf7346Smrg    char *p = sect + 4;
3081abf7346Smrg    *cp++ = '(';
3091abf7346Smrg    while (*p)
3101abf7346Smrg      *cp++ = *p++;
3111abf7346Smrg    *cp++ = ')';
3121abf7346Smrg  }
3131abf7346Smrg  *cp = '\0';
3141abf7346Smrg
3151abf7346Smrg#endif	/* CRAY */
3161abf7346Smrg
3171abf7346Smrg  return(StrAlloc(page));
3181abf7346Smrg}
319