File: linuxinfo.h

package info (click to toggle)
linuxinfo 4.2.2-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,332 kB
  • sloc: sh: 4,837; ansic: 1,379; makefile: 99; sed: 16
file content (162 lines) | stat: -rw-r--r-- 3,230 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
	linuxinfo.h

	Header file for linuxinfo

	Copyright (C) 1998-2000
	All Rights Reserved.

	Alex Buell <alex.buell@munted.eu>

	Copyright (C) 1999 
	Erick Kinnee <cerb@debian.org>

	Copyright (C) 2002
	Gerhard Tonn <gt@debian.org>

	Copyright (C) 2002 
	John R. Daily <jdaily@progeny.com>

	Copyright (C) 2002
	Ola Lundqvist <opal@debian.org>

	Copyright (C) 2004
	Andreas Jochens <aj@andaco.de>

	Copyright (C) 2004,2010 
	Helge Kreutzmann <debian@helgefjell.de>

	Copyright (C) 2010 
	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>


        Version Author  Date            Comments
        ----------------------------------------------------------------------
        1.0.1   AIB     199803??        Initial development
	1.0.2	AIB	1998????	Modification for compatibility with 
					both libc5 & glibc2 libraries
	1.0.4	AIB	1998????	Removed the glibc ifdefs.
	1.0.5	AIB	1998????	Added a new field to hw_stat struct.
	1.0.8	AIB	1999????	Ported to ARM architecture.
	1.1.3	AIB	1999????	mc68000 define replaced with __mc68000__
	1.1.4	AIB	20000405	Moved strstr() to linuxinfo_common.h
        1.1.5   OPAL	20021225	Added hppa
	1.1.8   KRE     20040429        Added mips
	1.1.8   KRE     20040807        Add support for HIGHMEM
	1.1.8   KRE     20010201        Added sh (Nobuhiro Iwamatsu)
	1.1.8   KRE     20010201        Added avr32
	1.1.8   AB      20220529        Added RiscV
	1.1.8   JZ      20230919        Added LoongArch

*/

#ifndef _LINUXINFO_H_
#define _LINUXINFO_H_

#if !defined(linux)
#define system_unknown
#endif

#if defined(__i386__) || defined(__x86_64__)
#define system_intel
#endif

#if defined(__mc68000__)
#define system_m68k
#endif 

#if defined(__alpha__)
#define system_alpha
#endif

#if defined(__sparc__)
#define system_sparc
#endif

#if defined(__s390__)
#define system_s390
#endif

#if defined(__hppa__)
#define system_hppa
#endif

#if defined(__PPC__)
#define system_ppc
#endif

#if defined(__arm__) || defined(__aarch64__)
#define system_arm
#endif

#if defined(__ia64__)
#define system_ia64
#endif

#if defined(__mips__)
#define system_mips
#endif

#if defined(__sh__)
#define system_sh
#endif

#if defined(__avr32__)
#define system_avr32
#endif

#if defined(__riscv)
#define system_riscv
#endif

#if defined(__loongarch__)
#define system_loongarch
#endif

#if (SIZEOF_LONG > 4)
#define LONGLONG long int
#define LONGSPEC "%ld"
#else
#define LONGLONG long long int
#define LONGSPEC "%lld"
#endif

struct os_stat 
{
	char os_hostname[BUFSIZ];
	char os_name[BUFSIZ];
	char os_version[BUFSIZ];
	char os_revision[BUFSIZ];
}; 

struct hw_stat 
{
	char hw_cpuinfo[BUFSIZ];
	char hw_bogomips[BUFSIZ];
	char hw_memory[BUFSIZ];
	char hw_megahertz[BUFSIZ];
	int hw_processors;
};

struct lib_stat 
{
	char lib_version[BUFSIZ];
};

void GetOperatingSystemInfo(struct os_stat *os);
void GetHardwareInfo(int fd, struct hw_stat *hw);
void GetSystemLibcInfo(struct lib_stat *lib);

int read_line(int fd, char *buffer, size_t length);
int splitstring(char *first_string, char *second_string); 

LONGLONG getphysicalmemory(void);

#define CPUINFO_FILE	"/proc/cpuinfo"
#define MEMINFO_FILE	"/proc/meminfo"

#ifdef use_regexp
int regstrcmp(const char *subjstring, const char *pstring);
#endif

#endif /* _LINUXINFO_H_ */