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

Revision 12269, 2.8 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 * Get architecture information
15 */
16
17#include "defs.h"
18
19extern char                    *AppArchCmds[];
20extern char                    *AppArchFiles[];
21extern char                    *KernArchCmds[];
22extern char                    *KernArchFiles[];
23
24/*
25 * Get kernel arch using sysinfo() system call.
26 */
27extern char *GetKernArchSysinfo()
28{
29    static char                 Buff[128];
30
31#if     defined(HAVE_SYSINFO)
32    if (Buff[0])
33        return(Buff);
34
35    if (sysinfo(SI_MACHINE, Buff, sizeof(Buff)) < 0)
36        return((char *) NULL);
37
38#endif  /* HAVE_SYSINFO */
39
40    return( (Buff[0]) ? Buff : (char *) NULL );
41}
42
43/*
44 * Get kernel arch using uname() system call.
45 */
46extern char *GetKernArchUname()
47{
48    static char                 Buff[128];
49#if     defined(HAVE_UNAME)
50    static struct utsname       un;
51
52    if (Buff[0])
53        return(Buff);
54
55    if (uname(&un) < 0)
56        return((char *) NULL);
57
58    strcpy(Buff, un.machine);
59#endif  /* HAVE_UNAME */
60
61    return( (Buff[0]) ? Buff : (char *) NULL );
62}
63
64/*
65 * Get application arch using sysinfo() system call.
66 */
67extern char *GetAppArchSysinfo()
68{
69    static char                 Buff[128];
70
71#if     defined(HAVE_SYSINFO)
72    if (Buff[0])
73        return(Buff);
74
75    if (sysinfo(SI_ARCHITECTURE, Buff, sizeof(Buff)) < 0)
76        return((char *) NULL);
77#endif  /* HAVE_SYSINFO */
78
79    return( (Buff[0]) ? Buff : (char *) NULL );
80}
81
82/*
83 * Use predefined name.
84 */
85extern char *GetAppArchDef()
86{
87#if     defined(ARCH_TYPE)
88    return(ARCH_TYPE);
89#else
90    return((char *)NULL);
91#endif  /* ARCH_TYPE */
92}
93
94/*
95 * Try running the App Arch test commands
96 */
97extern char *GetAppArchCmds()
98{
99    return(RunCmds(AppArchCmds, FALSE));
100}
101
102/*
103 * Try testing Architecture files
104 */
105extern char *GetAppArchTest()
106{
107    return(RunTestFiles(AppArchFiles));
108}
109
110/*
111 * Get application architecture.
112 */
113extern char *GetAppArch()
114{
115    extern PSI_t               GetAppArchPSI[];
116    static char               *Str = NULL;
117
118    if (Str)
119        return(Str);
120
121    return(Str = PSIquery(GetAppArchPSI));
122}
123
124/*
125 * Try running the KArch test commands
126 */
127extern char *GetKernArchCmds()
128{
129    return(RunCmds(KernArchCmds, FALSE));
130}
131
132/*
133 * Try testing Kernel Architecture files
134 */
135extern char *GetKernArchTest()
136{
137    return(RunTestFiles(KernArchFiles));
138}
139
140/*
141 * Use predefined name.
142 */
143extern char *GetKernArchDef()
144{
145#if     defined(KARCH_TYPE)
146    return(KARCH_TYPE);
147#else
148    return((char *)NULL);
149#endif  /* KARCH_TYPE */
150}
151
152/*
153 * Get kernel architecture
154 */
155extern char *GetKernArch()
156{
157    extern PSI_t               GetKernArchPSI[];
158    static char               *Str = NULL;
159
160    if (Str)
161        return(Str);
162
163    return(Str = PSIquery(GetKernArchPSI));
164}
Note: See TracBrowser for help on using the repository browser.