library: combine 4 files into new 'misc.h' header file
Prior to this patch, we had four separate header files dealing with miscellaneous functions. Those four files were documented in the single man page: procps_misc.3. Now, we will have just a single header file documented in a single man page (that is what's called symmetry). [ and while we're at it, we will shorten that overly ] [ long struct 'procps_namespaces' name to agree with ] [ the function naming conventions, e.g. 'procps_ns'. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
38c38a317b
commit
1fdd7d4966
88
proc/misc.h
Normal file
88
proc/misc.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* libprocps - Library to read proc filesystem
|
||||||
|
*
|
||||||
|
* Copyright 1992-1998 Michael K. Johnson <johnsonm@redhat.com>
|
||||||
|
* Copyright ???? Larry Greenfield <greenfie@gauss.rutgers.edu>
|
||||||
|
* Copyright 1993 J. Cowley
|
||||||
|
* Copyright 1995 Martin Schulze <joey@infodrom.north.de>
|
||||||
|
* Copyright 1996 Charles Blake <cblake@bbn.com>
|
||||||
|
* Copyright 1998-2003 Albert Cahalan
|
||||||
|
* Copyright 2015 Craig Small <csmall@enc.com.au>
|
||||||
|
* Copyright 2021 Jim Warner <james.warner@comcast.net>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PROC_MISC_H
|
||||||
|
#define PROC_MISC_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// Platform Particulars /////////////////////////////////////////////
|
||||||
|
|
||||||
|
long procps_cpu_count (void);
|
||||||
|
long procps_hertz_get (void);
|
||||||
|
unsigned int procps_pid_length (void);
|
||||||
|
|
||||||
|
// Convenience macros for composing/decomposing version codes
|
||||||
|
#define LINUX_VERSION(x,y,z) (0x10000*((x)&0x7fff) + 0x100*((y)&0xff) + ((z)&0xff))
|
||||||
|
#define LINUX_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
|
||||||
|
#define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
|
||||||
|
#define LINUX_VERSION_PATCH(x) ( (x) & 0xFF)
|
||||||
|
|
||||||
|
int procps_linux_version(void);
|
||||||
|
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// Runtime Particulars //////////////////////////////////////////////
|
||||||
|
|
||||||
|
int procps_loadavg (double *av1, double *av5, double *av15);
|
||||||
|
int procps_uptime(double *uptime_secs, double *idle_secs);
|
||||||
|
char *procps_uptime_sprint(void);
|
||||||
|
char *procps_uptime_sprint_short(void);
|
||||||
|
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// Namespace Particulars ////////////////////////////////////////////
|
||||||
|
|
||||||
|
enum namespace_type {
|
||||||
|
PROCPS_NS_IPC,
|
||||||
|
PROCPS_NS_MNT,
|
||||||
|
PROCPS_NS_NET,
|
||||||
|
PROCPS_NS_PID,
|
||||||
|
PROCPS_NS_USER,
|
||||||
|
PROCPS_NS_UTS,
|
||||||
|
PROCPS_NS_COUNT // total namespaces (fencepost)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct procps_ns {
|
||||||
|
unsigned long ns[PROCPS_NS_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *procps_ns_get_name (const int id);
|
||||||
|
int procps_ns_get_id (const char *name);
|
||||||
|
int procps_ns_read_pid (const int pid, struct procps_ns *nsp);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* libprocps - Library to read proc filesystem
|
|
||||||
*
|
|
||||||
* Copyright (C) 1996 Charles Blake <cblake@bbn.com>
|
|
||||||
* Copyright (C) 1998 Michael K. Johnson
|
|
||||||
* Copyright (C) 1998-2003 Albert Cahalan
|
|
||||||
* Copyright (C) 2015 Craig Small <csmall@enc.com.au>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
#ifndef PROC_NAMESPACE_H
|
|
||||||
#define PROC_NAMESPACE_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum namespace_type {
|
|
||||||
PROCPS_NS_IPC,
|
|
||||||
PROCPS_NS_MNT,
|
|
||||||
PROCPS_NS_NET,
|
|
||||||
PROCPS_NS_PID,
|
|
||||||
PROCPS_NS_USER,
|
|
||||||
PROCPS_NS_UTS,
|
|
||||||
PROCPS_NS_COUNT // total namespaces (fencepost)
|
|
||||||
};
|
|
||||||
|
|
||||||
struct procps_namespaces {
|
|
||||||
unsigned long ns[PROCPS_NS_COUNT];
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *procps_ns_get_name(const int id);
|
|
||||||
|
|
||||||
int procps_ns_get_id(const char *name);
|
|
||||||
|
|
||||||
int procps_ns_read_pid(const int pid, struct procps_namespaces *nsp);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
#ifndef PROC_SYSINFO_H
|
|
||||||
#define PROC_SYSINFO_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
long procps_cpu_count(void);
|
|
||||||
long procps_hertz_get(void);
|
|
||||||
int procps_loadavg(double *av1, double *av5, double *av15);
|
|
||||||
unsigned int procps_pid_length(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* uptime - uptime related functions - part of procps
|
|
||||||
*
|
|
||||||
* Copyright (C) 1992-1998 Michael K. Johnson <johnsonm@redhat.com>
|
|
||||||
* Copyright (C) ???? Larry Greenfield <greenfie@gauss.rutgers.edu>
|
|
||||||
* Copyright (C) 1993 J. Cowley
|
|
||||||
* Copyright (C) 1998-2003 Albert Cahalan
|
|
||||||
* Copyright (C) 2015 Craig Small <csmall@enc.com.au>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
#ifndef PROC_UPTIME_H
|
|
||||||
#define PROC_UPTIME_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int procps_uptime(double *uptime_secs, double *idle_secs);
|
|
||||||
char *procps_uptime_sprint(void);
|
|
||||||
char *procps_uptime_sprint_short(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* libprocps - Library to read proc filesystem
|
|
||||||
*
|
|
||||||
* Copyright (C) 1995 Martin Schulze <joey@infodrom.north.de>
|
|
||||||
* Copyright (C) 1996 Charles Blake <cblake@bbn.com>
|
|
||||||
* Copyright (C) 2003 Albert Cahalan
|
|
||||||
* Copyright (C) 2015 Craig Small <csmall@enc.com.au>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
#ifndef PROC_VERSION_H
|
|
||||||
#define PROC_VERSION_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Convenience macros for composing/decomposing version codes */
|
|
||||||
#define LINUX_VERSION(x,y,z) (0x10000*((x)&0x7fff) + 0x100*((y)&0xff) + ((z)&0xff))
|
|
||||||
#define LINUX_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
|
|
||||||
#define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
|
|
||||||
#define LINUX_VERSION_PATCH(x) ( (x) & 0xFF)
|
|
||||||
|
|
||||||
int procps_linux_version(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user