⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib.c

📁 linux 操作系统下对系统资源监控程序的编写
💻 C
📖 第 1 页 / 共 2 页
字号:
/* lib.c *//* This is a generated file.  Please modify `lib.pl' */#include <config.h>#include <glibtop.h>#include <glibtop/open.h>#include <glibtop/sysdeps.h>#include <glibtop/union.h>#include "libgtop-i18n.h"#include <glibtop/command.h>/* Some required fields are missing. */static void_glibtop_missing_feature (glibtop *server, const char *feature,			  const guint64 present, guint64 *required){	guint64 old_required = *required;	/* Return if we have all required fields. */	if ((~present & old_required) == 0)		return;	switch (server->error_method) {	case GLIBTOP_ERROR_METHOD_WARN_ONCE:		*required &= present;	case GLIBTOP_ERROR_METHOD_WARN:		glibtop_warn_r (server,				_("glibtop_get_%s (): Client requested "				  "field mask %05lx, but only have %05lx."),				 feature, (unsigned long) old_required,				 (unsigned long) present);		break;	case GLIBTOP_ERROR_METHOD_ABORT:		glibtop_error_r (server,				 _("glibtop_get_%s (): Client requested "				  "field mask %05lx, but only have %05lx."),				 feature, (unsigned long) old_required,				 (unsigned long) present);		break;	}}/* Library functions. */voidglibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_CPU), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_CPU)))	{		glibtop_call_l (server, GLIBTOP_CMND_CPU,				send_size, send_ptr,				sizeof (glibtop_cpu), buf);	} else {#if (!GLIBTOP_SUID_CPU)		glibtop_get_cpu_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_cpu");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.cpu)		_glibtop_missing_feature (server, "cpu", buf->flags,					  &server->required.cpu);}voidglibtop_get_mem_l (glibtop *server, glibtop_mem *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_MEM), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_MEM)))	{		glibtop_call_l (server, GLIBTOP_CMND_MEM,				send_size, send_ptr,				sizeof (glibtop_mem), buf);	} else {#if (!GLIBTOP_SUID_MEM)		glibtop_get_mem_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_mem");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.mem)		_glibtop_missing_feature (server, "mem", buf->flags,					  &server->required.mem);}voidglibtop_get_swap_l (glibtop *server, glibtop_swap *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_SWAP), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_SWAP)))	{		glibtop_call_l (server, GLIBTOP_CMND_SWAP,				send_size, send_ptr,				sizeof (glibtop_swap), buf);	} else {#if (!GLIBTOP_SUID_SWAP)		glibtop_get_swap_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_swap");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.swap)		_glibtop_missing_feature (server, "swap", buf->flags,					  &server->required.swap);}voidglibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_UPTIME), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_UPTIME)))	{		glibtop_call_l (server, GLIBTOP_CMND_UPTIME,				send_size, send_ptr,				sizeof (glibtop_uptime), buf);	} else {#if (!GLIBTOP_SUID_UPTIME)		glibtop_get_uptime_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_uptime");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.uptime)		_glibtop_missing_feature (server, "uptime", buf->flags,					  &server->required.uptime);}voidglibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_LOADAVG), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_LOADAVG)))	{		glibtop_call_l (server, GLIBTOP_CMND_LOADAVG,				send_size, send_ptr,				sizeof (glibtop_loadavg), buf);	} else {#if (!GLIBTOP_SUID_LOADAVG)		glibtop_get_loadavg_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_loadavg");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.loadavg)		_glibtop_missing_feature (server, "loadavg", buf->flags,					  &server->required.loadavg);}voidglibtop_get_shm_limits_l (glibtop *server, glibtop_shm_limits *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_SHM_LIMITS)))	{		glibtop_call_l (server, GLIBTOP_CMND_SHM_LIMITS,				send_size, send_ptr,				sizeof (glibtop_shm_limits), buf);	} else {#if (!GLIBTOP_SUID_SHM_LIMITS)		glibtop_get_shm_limits_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_shm_limits");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.shm_limits)		_glibtop_missing_feature (server, "shm_limits", buf->flags,					  &server->required.shm_limits);}voidglibtop_get_msg_limits_l (glibtop *server, glibtop_msg_limits *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_MSG_LIMITS)))	{		glibtop_call_l (server, GLIBTOP_CMND_MSG_LIMITS,				send_size, send_ptr,				sizeof (glibtop_msg_limits), buf);	} else {#if (!GLIBTOP_SUID_MSG_LIMITS)		glibtop_get_msg_limits_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_msg_limits");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.msg_limits)		_glibtop_missing_feature (server, "msg_limits", buf->flags,					  &server->required.msg_limits);}voidglibtop_get_sem_limits_l (glibtop *server, glibtop_sem_limits *buf){	const void *send_ptr = NULL;	const size_t send_size = 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_SEM_LIMITS)))	{		glibtop_call_l (server, GLIBTOP_CMND_SEM_LIMITS,				send_size, send_ptr,				sizeof (glibtop_sem_limits), buf);	} else {#if (!GLIBTOP_SUID_SEM_LIMITS)		glibtop_get_sem_limits_s (server, buf);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_sem_limits");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.sem_limits)		_glibtop_missing_feature (server, "sem_limits", buf->flags,					  &server->required.sem_limits);}unsigned *glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf,                        int64_t which, int64_t arg){	const void *send_ptr = &which;	const size_t send_size =		sizeof (which) + sizeof (arg);	unsigned * retval = (unsigned *) 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROCLIST), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_PROCLIST)))	{		retval = glibtop_call_l (server, GLIBTOP_CMND_PROCLIST,				         send_size, send_ptr,				         sizeof (glibtop_proclist), buf);	} else {#if (!GLIBTOP_SUID_PROCLIST)		retval = glibtop_get_proclist_s (server, buf, which, arg);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proclist");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proclist)		_glibtop_missing_feature (server, "proclist", buf->flags,					  &server->required.proclist);	/* Now we can return. */	return retval;}voidglibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf,                          pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_STATE), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_PROC_STATE)))	{		glibtop_call_l (server, GLIBTOP_CMND_PROC_STATE,				send_size, send_ptr,				sizeof (glibtop_proc_state), buf);	} else {#if (!GLIBTOP_SUID_PROC_STATE)		glibtop_get_proc_state_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_state");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_state)		_glibtop_missing_feature (server, "proc_state", buf->flags,					  &server->required.proc_state);}voidglibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf,                        pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_UID), 0);	/* If neccessary, we ask the server for the requested	 * feature. If not, we call the sysdeps function. */	if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&	    (server->features & (1 << GLIBTOP_SYSDEPS_PROC_UID)))	{		glibtop_call_l (server, GLIBTOP_CMND_PROC_UID,				send_size, send_ptr,				sizeof (glibtop_proc_uid), buf);	} else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -