source: trunk/third/sysinfo/getman.c @ 12269

Revision 12269, 2.4 KB checked in by ghudson, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12268, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (c) 1992-1998 Michael A. Cooper.
3 * This software may be freely used and distributed provided it is not
4 * sold for profit or used in part or in whole for commercial gain
5 * without prior written agreement, and the author is credited
6 * appropriately.
7 */
8
9#ifndef lint
10static char *RCSid = "$Revision: 1.1.1.3 $";
11#endif
12
13/*
14
15 * Get architecture information
16 */
17
18#include "defs.h"
19
20/*
21 * Return the predefined symbol MAN_SHORT
22 */
23extern char *GetManShortDef()
24{
25#if     defined(MAN_SHORT)
26    return(MAN_SHORT);
27#else   /* !MAN_SHORT */
28    return((char *) NULL);
29#endif  /* MAN_SHORT */
30}
31
32/*
33 * Try the sysinfo() call.
34 */
35extern char *GetManShortSysinfo()
36{
37    static char                 Buff[256];
38#if     defined(HAVE_SYSINFO)
39    register char              *cp;
40
41    if (sysinfo(SI_HW_PROVIDER, Buff, sizeof(Buff)) < 0)
42            SImsg(SIM_GERR, "sysinfo SI_HW_PROVIDER failed.");
43    else
44        if (cp = strchr(Buff, '_'))
45            *cp = C_NULL;
46#endif  /* HAVE_SYSINFO */
47
48    return( (Buff[0]) ? Buff : (char *) NULL );
49}
50
51/*
52 * Get the short manufacturer name
53 */
54extern char *GetManShort()
55{
56    extern PSI_t               GetManShortPSI[];
57    static char               *Str = NULL;
58
59    if (Str)
60        return(Str);
61
62    return(Str = PSIquery(GetManShortPSI));
63}
64
65/*
66 * Return the predefined symbol MAN_LONG
67 */
68extern char *GetManLongDef()
69{
70#if     defined(MAN_LONG)
71    return(MAN_LONG);
72#else   /* !MAN_LONG */
73    return((char *) NULL);
74#endif  /* MAN_LONG */
75}
76
77/*
78 * Try the sysinfo() call
79 */
80extern char *GetManLongSysinfo()
81{
82    static char                 Buff[256];
83#if     defined(HAVE_SYSINFO)
84    register char              *cp;
85
86    if (sysinfo(SI_HW_PROVIDER, Buff, sizeof(Buff)) < 0)
87        SImsg(SIM_GERR, "sysinfo SI_HW_PROVIDER failed.");
88    else {
89        cp = Buff;
90        while (cp && (cp = strchr(cp, '_')))
91            *cp++ = ' ';
92    }
93#endif  /* HAVE_SYSINFO */
94
95    return((Buff[0]) ? Buff : (char *)NULL);
96}
97
98/*
99 * Get the long manufacturer name
100 */
101extern char *GetManLong()
102{
103    extern PSI_t               GetManLongPSI[];
104    static char               *Str = NULL;
105
106    if (Str)
107        return(Str);
108
109    return(Str = PSIquery(GetManLongPSI));
110}
111
112/*
113 * Get the manufacturer info.
114 */
115extern char *GetMan()
116{
117    char                       *ms, *ml;
118    static char                 Buf[256];
119
120    Buf[0] = CNULL;
121    ms = GetManShort();
122    ml = GetManLong();
123
124    if (!ms || !ml)
125        return((char *) NULL);
126
127    if (!VL_TERSE && !VL_BRIEF)
128        (void) snprintf(Buf, sizeof(Buf),  "%s (%s)", ms, ml);
129    else
130        (void) snprintf(Buf, sizeof(Buf),  "%s", ms);
131
132    return(Buf);
133}
134
Note: See TracBrowser for help on using the repository browser.