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

📄 lib.c

📁 linux 操作系统下对系统资源监控程序的编写
💻 C
📖 第 1 页 / 共 2 页
字号:
#if (!GLIBTOP_SUID_PROC_UID)		glibtop_get_proc_uid_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_uid");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_uid)		_glibtop_missing_feature (server, "proc_uid", buf->flags,					  &server->required.proc_uid);}voidglibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf,                        pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_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_PROC_MEM)))	{		glibtop_call_l (server, GLIBTOP_CMND_PROC_MEM,				send_size, send_ptr,				sizeof (glibtop_proc_mem), buf);	} else {#if (!GLIBTOP_SUID_PROC_MEM)		glibtop_get_proc_mem_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_mem");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_mem)		_glibtop_missing_feature (server, "proc_mem", buf->flags,					  &server->required.proc_mem);}voidglibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf,                         pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_TIME), 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_TIME)))	{		glibtop_call_l (server, GLIBTOP_CMND_PROC_TIME,				send_size, send_ptr,				sizeof (glibtop_proc_time), buf);	} else {#if (!GLIBTOP_SUID_PROC_TIME)		glibtop_get_proc_time_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_time");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_time)		_glibtop_missing_feature (server, "proc_time", buf->flags,					  &server->required.proc_time);}voidglibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf,                           pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL), 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_SIGNAL)))	{		glibtop_call_l (server, GLIBTOP_CMND_PROC_SIGNAL,				send_size, send_ptr,				sizeof (glibtop_proc_signal), buf);	} else {#if (!GLIBTOP_SUID_PROC_SIGNAL)		glibtop_get_proc_signal_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_signal");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_signal)		_glibtop_missing_feature (server, "proc_signal", buf->flags,					  &server->required.proc_signal);}voidglibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf,                           pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_KERNEL), 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_KERNEL)))	{		glibtop_call_l (server, GLIBTOP_CMND_PROC_KERNEL,				send_size, send_ptr,				sizeof (glibtop_proc_kernel), buf);	} else {#if (!GLIBTOP_SUID_PROC_KERNEL)		glibtop_get_proc_kernel_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_kernel");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_kernel)		_glibtop_missing_feature (server, "proc_kernel", buf->flags,					  &server->required.proc_kernel);}voidglibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf,                            pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT), 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_SEGMENT)))	{		glibtop_call_l (server, GLIBTOP_CMND_PROC_SEGMENT,				send_size, send_ptr,				sizeof (glibtop_proc_segment), buf);	} else {#if (!GLIBTOP_SUID_PROC_SEGMENT)		glibtop_get_proc_segment_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_segment");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_segment)		_glibtop_missing_feature (server, "proc_segment", buf->flags,					  &server->required.proc_segment);}char *glibtop_get_proc_args_l (glibtop *server, glibtop_proc_args *buf,                         pid_t pid, unsigned max_len){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid) + sizeof (max_len);	char * retval = (char *) 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_ARGS), 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_ARGS)))	{		retval = glibtop_call_l (server, GLIBTOP_CMND_PROC_ARGS,				         send_size, send_ptr,				         sizeof (glibtop_proc_args), buf);	} else {#if (!GLIBTOP_SUID_PROC_ARGS)		retval = glibtop_get_proc_args_s (server, buf, pid, max_len);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_args");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_args)		_glibtop_missing_feature (server, "proc_args", buf->flags,					  &server->required.proc_args);	/* Now we can return. */	return retval;}glibtop_map_entry *glibtop_get_proc_map_l (glibtop *server, glibtop_proc_map *buf,                        pid_t pid){	const void *send_ptr = &pid;	const size_t send_size =		sizeof (pid);	glibtop_map_entry * retval = (glibtop_map_entry *) 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_MAP), 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_MAP)))	{		retval = glibtop_call_l (server, GLIBTOP_CMND_PROC_MAP,				         send_size, send_ptr,				         sizeof (glibtop_proc_map), buf);	} else {#if (!GLIBTOP_SUID_PROC_MAP)		retval = glibtop_get_proc_map_s (server, buf, pid);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_proc_map");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.proc_map)		_glibtop_missing_feature (server, "proc_map", buf->flags,					  &server->required.proc_map);	/* Now we can return. */	return retval;}glibtop_mountentry *glibtop_get_mountlist_l (glibtop *server, glibtop_mountlist *buf,                         int all_fs){	const void *send_ptr = &all_fs;	const size_t send_size =		sizeof (all_fs);	glibtop_mountentry * retval = (glibtop_mountentry *) 0;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_MOUNTLIST), 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_MOUNTLIST)))	{		retval = glibtop_call_l (server, GLIBTOP_CMND_MOUNTLIST,				         send_size, send_ptr,				         sizeof (glibtop_mountlist), buf);	} else {		retval = glibtop_get_mountlist_s (server, buf, all_fs);	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.mountlist)		_glibtop_missing_feature (server, "mountlist", buf->flags,					  &server->required.mountlist);	/* Now we can return. */	return retval;}voidglibtop_get_fsusage_l (glibtop *server, glibtop_fsusage *buf,                       const char *mount_dir){	const void *send_ptr = mount_dir;	const size_t send_size =		strlen (mount_dir) + 1;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_FSUSAGE), 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_FSUSAGE)))	{		glibtop_call_l (server, GLIBTOP_CMND_FSUSAGE,				send_size, send_ptr,				sizeof (glibtop_fsusage), buf);	} else {		glibtop_get_fsusage_s (server, buf, mount_dir);	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.fsusage)		_glibtop_missing_feature (server, "fsusage", buf->flags,					  &server->required.fsusage);}voidglibtop_get_netload_l (glibtop *server, glibtop_netload *buf,                       const char *interface){	const void *send_ptr = interface;	const size_t send_size =		strlen (interface) + 1;	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_NETLOAD), 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_NETLOAD)))	{		glibtop_call_l (server, GLIBTOP_CMND_NETLOAD,				send_size, send_ptr,				sizeof (glibtop_netload), buf);	} else {#if (!GLIBTOP_SUID_NETLOAD)		glibtop_get_netload_s (server, buf, interface);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_netload");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.netload)		_glibtop_missing_feature (server, "netload", buf->flags,					  &server->required.netload);}voidglibtop_get_ppp_l (glibtop *server, glibtop_ppp *buf,                   unsigned short device){	const void *send_ptr = &device;	const size_t send_size =		sizeof (device);	glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PPP), 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_PPP)))	{		glibtop_call_l (server, GLIBTOP_CMND_PPP,				send_size, send_ptr,				sizeof (glibtop_ppp), buf);	} else {#if (!GLIBTOP_SUID_PPP)		glibtop_get_ppp_s (server, buf, device);#else		errno = ENOSYS;		glibtop_error_io_r (server, "glibtop_get_ppp");#endif	}	/* Make sure that all required fields are present. */	if (buf->flags & server->required.ppp)		_glibtop_missing_feature (server, "ppp", buf->flags,					  &server->required.ppp);}

⌨️ 快捷键说明

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