Compare commits

...

80 Commits

Author SHA1 Message Date
Martin Baulig
d334a77447 Importing from xemacs-20.3 1998-06-14 17:04:10 +00:00
Martin Baulig
1b7d7976b1 Initial revision 1998-06-14 17:04:10 +00:00
Martin Baulig
d7770a12c6 Committing changes from `src/daemon'. 1998-06-14 17:03:32 +00:00
Martin Baulig
5fef6560bf Importing from xemacs-20.3 1998-06-14 17:02:44 +00:00
Martin Baulig
75605116d0 Initial revision 1998-06-14 17:02:44 +00:00
Martin Baulig
35943ea8fc Committing changes I made in 'src/daemon'. 1998-06-14 16:54:23 +00:00
Martin Baulig
e166f54328 Importing from xemacs-20.3 1998-06-14 16:50:30 +00:00
Martin Baulig
c1cc35ac17 Initial revision 1998-06-14 16:50:30 +00:00
Martin Baulig
0acb497216 New tag.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* acconfig.h (HAVE_XAUTH): New tag.

	* configure.in: Added check for `HAVE_XAUTH'.
1998-06-14 16:48:06 +00:00
Martin Baulig
58707dac42 New function - same as glibtop_error_r', but doesn't call exit'.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* sysdeps/common/error.c (glibtop_warn_r): New function -
	same as `glibtop_error_r', but doesn't call `exit'.
	(glibtop_error_io_r, glibtop_warn_io_r): New functions,
	display `strerror (errno)' together with message.
1998-06-14 16:47:09 +00:00
Martin Baulig
8f14d30d11 Compiles and links correctly. 1998-06-14 14:45:57 +00:00
Martin Baulig
bde0d74282 including correct headers; (HAVE_UNISTD_H): Added conditional. Added
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* include/glibtop/global.h (TIME_WITH_SYS_TIME): including
	correct headers; (HAVE_UNISTD_H): Added conditional.
	Added `#include <sys/param.h>' and `#include <sys/stat.h>'.
1998-06-14 14:44:53 +00:00
Martin Baulig
026e93121e Forgot to import this file. 1998-06-14 14:39:34 +00:00
Martin Baulig
f87722233a Initial revision 1998-06-14 14:39:34 +00:00
Martin Baulig
03c5a235ef Importing gnuserv and gnuclient from XEmacs 20.3. 1998-06-14 14:09:34 +00:00
Martin Baulig
215ab9f17b Initial revision 1998-06-14 14:09:34 +00:00
Martin Baulig
794a8efaed Added README.
1998-06-14  Martin Baulig  <baulig@taurus.uni-trier.de>

	* README: Added README.

	* kernel.patch: Patch for the Linux kernel to add the
	new system call.
1998-06-14 12:40:59 +00:00
Martin Baulig
b56c327ccc This new system call now provides all information required for libgtop. 1998-06-14 12:29:52 +00:00
Martin Baulig
8f43551d68 New file - declaration of the table () function via _syscall3 (); due to a
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* kernel.s: New file - declaration of the table () function
	via _syscall3 (); due to a bug in egcs, we cannot put this
	into a C file.
1998-06-14 12:19:18 +00:00
Martin Baulig
23cccaf87f Removed declararion of table () function again. 1998-06-14 12:18:39 +00:00
Martin Baulig
c75b77affc Removed deleted files. 1998-06-14 02:30:25 +00:00
Martin Baulig
7ffc53f45e *** empty log message *** 1998-06-14 02:26:32 +00:00
Martin Baulig
6ea7e47194 New tag.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* acconfig.h (HAVE_LINUX_TABLE): New tag.
1998-06-14 02:23:25 +00:00
Martin Baulig
6130f0a4f9 New file. Creates lib.c' depending upon features.def'.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* lib/lib.awk: New file.
	Creates `lib.c' depending upon `features.def'.

	* lib/<feature>.c: Removed.
1998-06-14 02:13:50 +00:00
Martin Baulig
44dcb69c41 Added missing `const'. 1998-06-14 01:01:24 +00:00
Martin Baulig
13148c632f New file. Creates gulie.c' depending upon features.def'.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* sysdeps/guile/guile.awk: New file.
	Creates `gulie.c' depending upon `features.def'.

	* sysdeps/guile/*.c: Removed.
1998-06-14 00:57:03 +00:00
Martin Baulig
6fd3c113ec List of features for `guile-names.awk'.
1998-06-13  Martin Baulig  <martin@home-of-linux.org>

	* features.def: List of features for `guile-names.awk'.

	* sysdeps/guile/names/guile-names.awk: New file.
	Creates `guile-names.c' depending upon `features.def'.

	* sysdeps/guile/names/*.c: Removed.
1998-06-13 22:53:55 +00:00
Martin Baulig
9661c4becc New directory. Contains some kernel code to implement a new system call
1998-06-13  Martin Baulig  <martin@home-of-linux.org>

	* kernel: New directory. Contains some kernel code to
	implement a new system call table () to fetch information
	directly from the Linux kernel.

	* sysdeps/kernel: New directory. Uses the table () function
	from the `kernel' directory to fetch things directly from
	the Linux kernel.

	* sysdeps/Makefile.am (DIST_SUBDIRS): Added `kernel'.

	* configure.in: Removed `build_CC' again.
1998-06-13 21:26:49 +00:00
Martin Baulig
c60d1d5449 The code in this directory fetches all information directly from the
1998-06-13  Martin Baulig  <martin@home-of-linux.org>

	The code in this directory fetches all information
	directly from the kernel. It uses the new table ()
	system call from the `kernel' directory.
1998-06-13 21:20:48 +00:00
Martin Baulig
eedc64096c New file.
1998-06-12  Martin Baulig  <martin@home-of-linux.org>

	* test.scm: New file.
1998-06-12 00:41:00 +00:00
Martin Baulig
cf8068049f Forgot to change declaration on Jun 6.
1998-06-12  Martin Baulig  <baulig@taurus.uni-trier.de>

	* include/glibtop/sysdeps.h (glibtop_types_sysdeps):
	Forgot to change declaration on Jun 6.

	* sysdeps/names/sysdeps.c (glibtop_types_sysdeps):
	Using numeric constants from `types.h' instead of string
	constants; forgot to change this on Jun 6. Added information
	about new `features' field of `_glibtop_sysdeps'.
1998-06-12 00:40:17 +00:00
Martin Baulig
5e3d6bdf18 Merged bug fixes from stable branch. 1998-06-11 23:56:06 +00:00
Martin Baulig
aff6786e71 Replaced call to gh_append2 ()' with gh_append ()'.
1998-06-12  Martin Baulig  <baulig@taurus.uni-trier.de>

	* sysdeps/guile/proclist.c: Replaced call to
	`gh_append2 ()' with `gh_append ()'.

	* sysdeps/guile/names/*.c: dito.
1998-06-11 23:03:07 +00:00
Martin Baulig
2408a0731c Kernel stuff: We use a new system call `table ()' instead of the /proc
filesystem to fetch data.
1998-06-11 22:42:11 +00:00
Martin Baulig
a3c345e79e Initial revision 1998-06-11 22:42:11 +00:00
Martin Baulig
b2950457ce *** empty log message *** 1998-06-08 00:50:25 +00:00
Martin Baulig
9ce768bc4b Forgot to checkin. 1998-06-08 00:43:32 +00:00
Martin Baulig
c9e7e3a862 Added again.
1998-06-08  Martin Baulig  <martin@home-of-linux.org>

	* support: Added again.

	* Makefile.am (SUBDIRS): Added `support' again.

	* configure.in: First, we check for gnome. If it is not
	found, we run GNOME_SUPPORT_CHECKS; otherwise use
	`$GNOME_LIBDIR -lgnomesupport'.
1998-06-08 00:40:51 +00:00
Martin Baulig
33eefd46c7 Minor fixes for SunOS. 1998-06-08 00:25:47 +00:00
Martin Baulig
be91463190 More profiling stuff. 1998-06-07 21:14:30 +00:00
Martin Baulig
28324c38cc Disable optimize.
1998-06-07  Martin Baulig  <martin@home-of-linux.org>

	* Makefile.am (CFLAGS): Disable optimize.

	* first.c (PROFILE_COUNT): Number of times each function
	should be called. Defaults to 1; to profile the code, you
	can increase this when compiling.
1998-06-07 20:46:21 +00:00
Martin Baulig
4cb95e1477 New file.
1998-06-07  Martin Baulig  <martin@home-of-linux.org>

	* examples/ChangeLog: New file.
1998-06-07 20:46:05 +00:00
Martin Baulig
691cd81192 Bug fix. 1998-06-07 20:42:53 +00:00
Martin Baulig
9c9ad03d60 New file.
1998-06-07  Martin Baulig  <martin@home-of-linux.org>

	* sysdeps/linux/glibtop_machine.h: New file.

	* sysdeps/linux/*.c: Performance optimizations. We now use
	`open' and `read' instead of `fopen' and `fscanf'.
1998-06-07 20:38:02 +00:00
Martin Baulig
c84923132a Using single underscore instead of two underscores for function prefixes
1998-06-07  Martin Baulig  <martin@home-of-linux.org>

	* *.[ch]: Using single underscore instead of two underscores
	for function prefixes (regexp: ``s,__([rspl])\b,_$1,g'') to
	avoid ambiguity with mangled C++ names.
1998-06-07 13:57:45 +00:00
Martin Baulig
85f31a1707 removed that directory.
1998-06-05  Martin Baulig  <baulig@taurus.uni-trier.de>

        * support: removed that directory.

        * configure.in: we check whether '-lgnomesupport' is
        included in $GNOME_LIBS and add it together with
        $GNOME_LIBDIR to LIBSUPPORT in this case.

        Gnome (gnome-libs) is now required to build libgtop,
        added short comment to configure.in how to revert this
        change.

        * Makefile.am: removed `support' subdir.

1998-06-03  Martin Baulig  <baulig@merkur.uni-trier.de>

        * libgtop.spec: New file.

        * Makefile.am (EXTRA_DIST): Added `autogen.sh' and
        `libgtop.spec'.

        * configure.in (LIBGTOP_INCS): is now identically to
        `LIBGTOP_GUILE_INCS'.

        * include/glibtop/global.h: only including intl headers
        while compiling libgtop.

Merging changes from LIBGTOP_STABLE_0_20 into the main trunk.
1998-06-06 22:26:40 +00:00
Martin Baulig
92ec7c6d33 Forgot to checkin the ChangeLog on last three commits. 1998-06-06 18:49:07 +00:00
Martin Baulig
0a323e5080 New file.
1998-06-06  Martin Baulig  <martin@home-of-linux.org>

        * sysdeps/osf1/glibtop_server.h: New file.

        * sysdeps/osf1/*.c: renamed all functions implementing
        features that don't need to be suid to '__s'.
1998-06-06 18:48:17 +00:00
Martin Baulig
222df2c7d6 Removed that file.
1998-06-06  Martin Baulig  <martin@home-of-linux.org>

        * sysdeps/names/procdata.c: Removed that file.

	* sysdeps/names/*.c: Fixed declaration of `glibtop_types_*'.
1998-06-06 18:42:14 +00:00
Martin Baulig
f92d7f9ee7 Changed declaration.
1998-06-06  Martin Baulig  <martin@home-of-linux.org>

        * include/glibtop/*.h (glibtop_types_*): Changed declaration.
1998-06-06 18:41:08 +00:00
Martin Baulig
de5cf356c9 Added `#include <types.h>'.
1998-06-06  Martin Baulig  <martin@home-of-linux.org>

        * glibtop.h: Added `#include <types.h>'.

        * include/glibtop/types.h: New file - numeric constants
        for `glibtop_types_<feature>'.

        * sysdeps/names/*.c (glibtop_types_*): Using numeric
        constants from `types.h' instead of string constants.
1998-06-06 18:19:16 +00:00
rhlabs
d3f9cb80d7 For now just remove the gnomesupport stuff libgtop builds after
its installed and before we make the package

These files are really supposed to be created by gnome-libs

Dr Mike <msf@redhat.com>
1998-06-04 20:55:18 +00:00
rhlabs
fb61de47a0 More file list fun
Dr Mike <msf@redhat.com>
1998-06-04 20:20:00 +00:00
rhlabs
0727d0911c Fixed file list
Dr Mike <msf@redhat.com>
1998-06-04 20:13:51 +00:00
rhlabs
fbb3070abe This file mysteriously disappeared from CVS, I'm putting it back.
Dr Mike <msf@redhat.com>
1998-06-04 19:34:17 +00:00
Arturo Espinosa
402c96e473 #include <locale.h> for several files - Federico 1998-06-03 04:33:37 +00:00
Federico Mena Quintero
44f28a486b #include <locale.h>
1998-06-02  Federico Mena Quintero  <federico@nuclecu.unam.mx>

	* src/server/main.c: #include <locale.h>
1998-06-03 04:30:15 +00:00
Martin Baulig
4aeb33b2b9 Removed this file.
* examples/third.scm: Removed this file.
1998-06-02 22:48:32 +00:00
Martin Baulig
3728e4c34e renamed all functions implementing features to '__p' (since they need to
*  sysdeps/sun4/*.c: renamed all functions implementing
   features to '__p' (since they need to be SGID kmem on SunOS).
1998-06-02 22:23:45 +00:00
Martin Baulig
e71eb0e75b *** empty log message *** 1998-06-02 19:42:53 +00:00
Martin Baulig
f233a1673f renamed to `glibtop_open__r'.
* sysdeps/linux/open.c (glibtop_open): renamed to
`glibtop_open__r'.
1998-06-02 19:41:29 +00:00
Martin Baulig
b96843a960 renamed to `glibtop_open__l'.
* lib/open.c (glibtop_open): renamed to `glibtop_open__l'.
1998-06-02 19:40:53 +00:00
Martin Baulig
eb69a5547f *** empty log message *** 1998-06-02 16:26:07 +00:00
Martin Baulig
7f39d62371 tells `glibtop_open' to use the default server and not to check the
* include/glibtop/open.h (GLIBTOP_OPEN_NO_OVERRIDE):
tells `glibtop_open' to use the default server and not
to check the environment variables.

* include/glibtop/sysdeps.h (_glibtop_sysdeps):
renamed 'dummy' member to 'features'.

* include/glibtop/command.h (GLIBTOP_CMND_SYSDEPS):
added definition here.
1998-06-02 16:20:15 +00:00
Martin Baulig
6f179a3141 swapped lib and src directories. 1998-06-02 16:14:49 +00:00
Martin Baulig
cad4b8f2f5 new directory - proxy server.
* src/proxy/*: new directory - proxy server.
1998-06-02 16:13:31 +00:00
Martin Baulig
beb68e2fc4 new command to get glibtop_server_features.
* src/server/main.c (GLIBTOP_CMND_SYSDEPS): new
command to get glibtop_server_features.
1998-06-02 16:12:28 +00:00
Martin Baulig
b4a16ccd89 If someone needs a stable version of libgtop, please fetch the one from May 27,
stuff is _really_ unstable and under development at the moment and only works
under Linux. Please look in the ChangeLog and NEWS for a more detailed description
of the latest changes.

I'm going to town now. Have fun,

Martin
1998-06-01 15:54:49 +00:00
Martin Baulig
15e73d9b7d *** empty log message *** 1998-06-01 15:25:11 +00:00
Martin Baulig
344bdd330f now using '__r' functions, they are #defined either as the '__p' or the
* sysdeps/common/sysdeps.c: now using '__r' functions,
they are #defined either as the '__p' or the '__s' ones.
1998-06-01 15:22:00 +00:00
Martin Baulig
2546fa37eb changed call of 'glibtop_init__r', it now takes two additional arguments.
* sysdeps/linux/*.c: changed call of 'glibtop_init__r',
it now takes two additional arguments.
1998-06-01 15:21:19 +00:00
Martin Baulig
080dd0850b now using 'glibtop_init' instead of 'glibtop_init__r'.
* examples/{first.c, second.c}: now using 'glibtop_init'
instead of 'glibtop_init__r'.
1998-06-01 15:15:56 +00:00
Martin Baulig
b7be9a7141 added 'dummy' member so 'GLIBTOP_SYSDEPS_<feature>' now start with 1.
* include/glibtop/sysdeps.h: added 'dummy' member so
'GLIBTOP_SYSDEPS_<feature>' now start with 1.

* include/glibtop/*.h: we now #define 'glibtop_get_<feature>'
as 'glibtop_get_<feature>__l' and 'glibtop_get_<feature>__r'
either as the '__p' or the '__s' function.
1998-06-01 15:14:50 +00:00
Martin Baulig
67798e0d7d removed #if's - we now decide at runtime whether to use the server or to
* lib/*.c: removed #if's - we now decide at runtime
whether to use the server or to call the appropriate
function for the sysdeps directory.
1998-06-01 15:09:03 +00:00
Vincent Renardias
6de9ad750b Sun, 31 May 1998 22:52:48 +0200 [Vincent]
* Yet more .FR translations. (and fixed a typo in gxsnmp ;)
1998-05-31 20:54:43 +00:00
Martin Baulig
68162783dc always use `-I$(top_srcdir)/sysdeps/@sysdeps_dir@'; it's no longer
* configure.in (@machine_incs@): always use
`-I$(top_srcdir)/sysdeps/@sysdeps_dir@'; it's no
longer conditional.

* examples/Makefile.am: removed the '_linux' examples.

* src/server/main.c: we now use the '__p' functions,
but only if the appropriate 'GLIBTOP_SUID_<feature>'
has a non-zero value.
1998-05-28 19:29:29 +00:00
Martin Baulig
95b9d824ea renamed all functions implementing features to '__s'.
* sysdeps/linux/*.c: renamed all functions implementing
features to '__s'.
1998-05-28 19:24:24 +00:00
Martin Baulig
7dd0c2eac3 renamed all functions that implementing features to '__l'; we only emit
* lib/*.c: renamed all functions that implementing features
to '__l'; we only emit code for those functions if the
corresponding 'GLIBTOP_SUID_<feature>' has a positive value.
1998-05-28 19:22:48 +00:00
Martin Baulig
62dda3b782 added some new function suffixes: '__l' is a function defined in the
* sysdeps/linux/*.h: added some new function suffixes:
'__l' is a function defined in the client part;
'__s' is a function defined in the sysdeps part and
'__p' is a function that needs special priviledges.
'__r' is mapped either on '__l' or on '__s'.

* sysdeps/linux/glibtop_server.h: New file -
defines system dependent constants 'GLIBTOP_SUID_<feature>'
being either 'GLIBTOP_SYSDEPS_<feature>'+1 depending upon
whether or not this feature requires using the server.

Things may now temporarily get instable; I'm currently implementing some
suggestions Sebastian Wilhelmi has made.
1998-05-28 19:19:49 +00:00
Martin Baulig
4e1e1ccb9f removed that file; it is no longer needed.
* lib/sysdeps.c: removed that file; it is no longer
needed.
1998-05-28 19:08:35 +00:00
247 changed files with 8534 additions and 3863 deletions

235
ChangeLog
View File

@@ -1,3 +1,238 @@
1998-06-14 Martin Baulig <martin@home-of-linux.org>
* acconfig.h (HAVE_XAUTH): New tag.
* configure.in: Added check for `HAVE_XAUTH'.
* sysdeps/common/error.c (glibtop_warn_r): New function -
same as `glibtop_error_r', but doesn't call `exit'.
(glibtop_error_io_r, glibtop_warn_io_r): New functions,
display `strerror (errno)' together with message.
* include/glibtop/global.h (TIME_WITH_SYS_TIME): including
correct headers; (HAVE_UNISTD_H): Added conditional.
Added `#include <sys/param.h>' and `#include <sys/stat.h>'.
* acconfig.h (HAVE_LINUX_TABLE): New tag.
* lib/lib.awk: New file.
Creates `lib.c' depending upon `features.def'.
* lib/<feature>.c: Removed.
* sysdeps/guile/guile.awk: New file.
Creates `guile.c' depending upon `features.def'.
* sysdeps/guile/*.c: Removed.
1998-06-13 Martin Baulig <martin@home-of-linux.org>
* features.def: List of features for `guile-names.awk'.
* sysdeps/guile/names/guile-names.awk: New file.
Creates `guile-names.c' depending upon `features.def'.
* sysdeps/guile/names/*.c: Removed.
* kernel: New directory. Contains some kernel code to
implement a new system call table () to fetch information
directly from the Linux kernel.
* sysdeps/kernel: New directory. Uses the table () function
from the `kernel' directory to fetch things directly from
the Linux kernel.
* sysdeps/Makefile.am (DIST_SUBDIRS): Added `kernel'.
* configure.in: Removed `build_CC' again.
1998-06-12 Martin Baulig <baulig@taurus.uni-trier.de>
* include/glibtop/sysdeps.h (glibtop_types_sysdeps):
Forgot to change declaration on Jun 6.
* sysdeps/names/sysdeps.c (glibtop_types_sysdeps):
Using numeric constants from `types.h' instead of string
constants; forgot to change this on Jun 6. Added information
about new `features' field of `_glibtop_sysdeps'.
* sysdeps/guile/names/*.c (glibtop_guile_types_*):
Using `gh_ulong2scm' instead of `gh_str02scm'.
* sysdeps/guile/proclist.c: Replaced call to
`gh_append2 ()' with `gh_append ()'.
* sysdeps/guile/names/*.c: dito.
1998-06-08 Martin Baulig <martin@home-of-linux.org>
* support: Added again.
* Makefile.am (SUBDIRS): Added `support' again.
* configure.in: First, we check for gnome. If it is not
found, we run GNOME_SUPPORT_CHECKS; otherwise use
`$GNOME_LIBDIR -lgnomesupport'.
1998-06-07 Martin Baulig <martin@home-of-linux.org>
* examples/ChangeLog: New file.
* macros/gnome-libgtop-sysdeps.m4: Include
`glibtop_machine.h' for Linux.
* sysdeps/linux/glibtop_machine.h: New file.
* sysdeps/linux/*.c: Performance optimizations. We now use
`open' and `read' instead of `fopen' and `fscanf'.
* *.[ch]: Using single underscore instead of two underscores
for function prefixes (regexp: ``s,__([rspl])\b,_$1,g'') to
avoid ambiguity with mangled C++ names.
1998-06-06 Martin Baulig <martin@home-of-linux.org>
* sysdeps/osf1/glibtop_server.h: New file.
* sysdeps/osf1/*.c: renamed all functions implementing
features that don't need to be suid to '__s'.
* sysdeps/names/procdata.c: Removed that file.
* include/glibtop/*.h (glibtop_types_*): Changed declaration.
* glibtop.h: Added `#include <types.h>'.
* include/glibtop/types.h: New file - numeric constants
for `glibtop_types_<feature>'.
* sysdeps/names/*.c (glibtop_types_*): Using numeric
constants from `types.h' instead of string constants.
1998-06-05 Martin Baulig <baulig@taurus.uni-trier.de>
* support: removed that directory.
* configure.in: we check whether '-lgnomesupport' is
included in $GNOME_LIBS and add it together with
$GNOME_LIBDIR to LIBSUPPORT in this case.
Gnome (gnome-libs) is now required to build libgtop,
added short comment to configure.in how to revert this
change.
* Makefile.am: removed `support' subdir.
1998-06-03 Martin Baulig <baulig@merkur.uni-trier.de>
* libgtop.spec: New file.
* Makefile.am (EXTRA_DIST): Added `autogen.sh' and
`libgtop.spec'.
* configure.in (LIBGTOP_INCS): is now identically to
`LIBGTOP_GUILE_INCS'.
* include/glibtop/global.h: only including intl headers
while compiling libgtop.
1998-06-02 Federico Mena Quintero <federico@nuclecu.unam.mx>
* src/server/main.c: #include <locale.h>
1998-06-02 Martin Baulig <baulig@merkur.uni-trier.de>
* lib/open.c (glibtop_open): renamed to `glibtop_open__l'.
* sysdeps/linux/open.c (glibtop_open): renamed to
`glibtop_open__r'.
* include/glibtop/open.h (GLIBTOP_OPEN_NO_OVERRIDE):
tells `glibtop_open' to use the default server and not
to check the environment variables.
* include/glibtop/sysdeps.h (_glibtop_sysdeps):
renamed 'dummy' member to 'features'.
* src/proxy/*: new directory - proxy server.
* include/glibtop/command.h (GLIBTOP_CMND_SYSDEPS):
added definition here.
* src/server/main.c (GLIBTOP_CMND_SYSDEPS): new
command to get glibtop_server_features.
1998-06-01 Martin Baulig <martin@home-of-linux.org>
* NEWS: added more detailed description of today's and
yesterday's changes.
* include/glibtop/*.h: to use the ChangeLog entry from May 28:
'__l' is a function defined in the client part;
'__s' is a function defined in the sysdeps part and
'__p' is a function that needs special priviledges.
'__r' is mapped either on '__p' or on '__s'.
the function without suffix is mapped on '__l'.
* sysdeps/common/sysdeps.c: now using '__r' functions,
they are #defined either as the '__p' or the '__s' ones.
* sysdeps/linux/*.c: changed call of 'glibtop_init__r',
it now takes two additional arguments.
* examples/{first.c, second.c}: now using 'glibtop_init'
instead of 'glibtop_init__r'.
* include/glibtop/sysdeps.h: added 'dummy' member so
'GLIBTOP_SYSDEPS_<feature>' now start with 1.
* include/glibtop/*.h: we now #define 'glibtop_get_<feature>'
as 'glibtop_get_<feature>__l' and 'glibtop_get_<feature>__r'
either as the '__p' or the '__s' function.
* lib/*.c: removed #if's - we now decide at runtime
whether to use the server or to call the appropriate
function for the sysdeps directory.
1998-05-28 Martin Baulig <baulig@merkur.uni-trier.de>
* src/server/main.c: we now use the '__p' functions,
but only if the appropriate 'GLIBTOP_SUID_<feature>'
has a non-zero value.
* configure.in (@machine_incs@): always use
`-I$(top_srcdir)/sysdeps/@sysdeps_dir@'; it's no
longer conditional.
* examples/Makefile.am: removed the '_linux' examples.
* sysdeps/linux/*.c: renamed all functions implementing
features to '__s'.
* lib/*.c: renamed all functions implementing features
to '__l'; we only emit code for those functions if the
corresponding 'GLIBTOP_SUID_<feature>' has a positive value.
* include/glibtop/*.h: added some new function suffixes:
'__l' is a function defined in the client part;
'__s' is a function defined in the sysdeps part and
'__p' is a function that needs special priviledges.
'__r' is mapped either on '__l' or on '__s'.
* sysdeps/linux/glibtop_server.h: New file -
defines system dependent constants 'GLIBTOP_SUID_<feature>'
being either 'GLIBTOP_SYSDEPS_<feature>'+1 depending upon
whether or not this feature requires using the server.
* lib/sysdeps.c: removed that file; it is no longer
needed.
1998-05-25 Martin Baulig <baulig@merkur.uni-trier.de>
* src/server/main.c: Fixed `broken pipe' error when server
is running SUID; accidentally uses setreuid () instead of
setregid ().
1998-05-24 Martin Baulig <martin@home-of-linux.org>
* sysdeps/sun4/{open.c, mem.c, glibtop_machine.h}: added

View File

@@ -4,15 +4,15 @@ if GLIBTOP_EXAMPLES
examples_SUBDIRS = examples
endif
built_SUBDIRS = include sysdeps src lib
built_SUBDIRS = include sysdeps lib src
SUBDIRS = po intl support macros $(built_SUBDIRS) $(examples_SUBDIRS)
DIST_SUBDIRS = po intl support macros include sysdeps src lib examples
DIST_SUBDIRS = po intl macros include sysdeps src lib examples
include_HEADERS = glibtop.h
EXTRA_DIST = copyright.txt libgtopConf.sh.in
EXTRA_DIST = autogen.sh libgtop.spec copyright.txt libgtopConf.sh.in
release:
$(MAKE) dist distdir=$(PACKAGE)$(VERSION)

111
NEWS
View File

@@ -1,5 +1,116 @@
$Id$
Jun/01/1998
===========
* We have some new ``suffix rules'':
'__l' is a function defined in the client part;
'__s' is a function defined in the sysdeps part and
'__p' is a function that needs special priviledges.
'__r' is mapped either on '__p' or on '__s'.
the function without suffix is mapped on '__l'.
* We now decide at runtime whether or not using the server
is required for a particular function. All user programs
now call the '__l' function defined in '-lgtop' (in the lib
subdir). These functions either use 'glibtop_call__l' to
call the server or call the '__r' function.
* A function in the sysdeps directory now has the '__s' suffix
if it do not need any priviledges (and thus can be called directly
from client code) and the '__p' suffix otherwise (when it has to
be called from the server).
* If you call one of these functions:
-> use the '__p' suffix to be sure to get the SUID-safe one
(used in the server).
-> use the '__s' suffix to be sure to get a function that
doesn't need any priviledges.
-> use the '__r' suffix otherwise (it is mapped either on the
'__p' or on the '__s' one).
Only use the '__p' and '__s' functions in a 'GLIBTOP_SUID_<feature>'
conditional, otherwise you'll get undefined symbols !
* The server is now started from 'glibtop_init__r', but only when
it's really needed; for instance on DEC OSF/1 you only need it
for the proc* features - if you program only fetches the CPU usage,
now server will be started.
* Sorry, at the moment everything is a little bit unstable, I'm doing
heavy changes. I've just some great ideas which still need some work:
-> I want to have a SUID server that only implements those features
that need to be SUID; everything else uses the sysdeps code directly.
-> If a program only uses stuff that do not need the server, the
server will not be started at all.
-> I'm working on some kind of proxy server that can be used on a remote
host; in feature one can then use the MDI stuff from ghex in gtop to
have notebook pages displaying processes from different hosts.
* Well it is as much unstable that it only works under Linux at the moment.
1998-06-01 Martin Baulig <martin@home-of-linux.org>
* sysdeps/common/sysdeps.c: now using '__r' functions,
they are #defined either as the '__p' or the '__s' ones.
* sysdeps/linux/*.c: changed call of 'glibtop_init__r',
it now takes two additional arguments.
* examples/{first.c, second.c}: now using 'glibtop_init'
instead of 'glibtop_init__r'.
* include/glibtop/sysdeps.h: added 'dummy' member so
'GLIBTOP_SYSDEPS_<feature>' now start with 1.
* include/glibtop/*.h: we now #define 'glibtop_get_<feature>'
as 'glibtop_get_<feature>__l' and 'glibtop_get_<feature>__r'
either as the '__p' or the '__s' function.
* lib/*.c: removed #if's - we now decide at runtime
whether to use the server or to call the appropriate
function for the sysdeps directory.
1998-05-28 Martin Baulig <baulig@merkur.uni-trier.de>
* src/server/main.c: we now use the '__p' functions,
but only if the appropriate 'GLIBTOP_SUID_<feature>'
has a non-zero value.
* configure.in (@machine_incs@): always use
`-I$(top_srcdir)/sysdeps/@sysdeps_dir@'; it's no
longer conditional.
* examples/Makefile.am: removed the '_linux' examples.
* sysdeps/linux/*.c: renamed all functions implementing
features to '__s'.
* lib/*.c: renamed all functions implementing features
to '__l'; we only emit code for those functions if the
corresponding 'GLIBTOP_SUID_<feature>' has a positive value.
* include/glibtop/*.h: added some new function suffixes:
'__l' is a function defined in the client part;
'__s' is a function defined in the sysdeps part and
'__p' is a function that needs special priviledges.
'__r' is mapped either on '__l' or on '__s'.
* sysdeps/linux/glibtop_server.h: New file -
defines system dependent constants 'GLIBTOP_SUID_<feature>'
being either 'GLIBTOP_SYSDEPS_<feature>'+1 depending upon
whether or not this feature requires using the server.
* lib/sysdeps.c: removed that file; it is no longer
needed.
May/21/1998
===========

View File

@@ -33,3 +33,7 @@
#undef GLIBTOP_EXAMPLES
#undef NEED_LIBGTOP
#undef HAVE_LINUX_TABLE
#undef HAVE_XAUTH

View File

@@ -101,512 +101,86 @@ AC_DEFUN([AC_LC_SYSDEPS],[
AC_SUBST(libgtop_want_examples)
])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN(AM_CONFIG_HEADER,
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
dnl This file resides in the same directory as the config header
dnl that is generated. We must strip everything past the first ":",
dnl and everything past the last "/".
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
<<am_indx=1
for am_file in <<$1>>; do
case " <<$>>CONFIG_HEADERS " in
*" <<$>>am_file "*<<)>>
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
;;
esac
am_indx=`expr "<<$>>am_indx" + 1`
done<<>>dnl>>)
changequote([,]))])
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AM_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
# serial 1
AC_DEFUN(AM_PROG_INSTALL,
[AC_REQUIRE([AC_PROG_INSTALL])
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
AC_SUBST(INSTALL_SCRIPT)dnl
])
######################################################################
# progtest.m4 from gettext 0.32
######################################################################
# Search path for a program which passes the given test.
# Ulrich Drepper <drepper@cygnus.com>, 1996.
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])
# Add --enable-maintainer-mode option to configure.
# From Jim Meyering
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 1
AC_DEFUN(AM_MAINTAINER_MODE,
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode,
[ --enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer],
USE_MAINTAINER_MODE=$enableval,
USE_MAINTAINER_MODE=no)
AC_MSG_RESULT($USE_MAINTAINER_MODE)
if test $USE_MAINTAINER_MODE = yes; then
MAINT=
else
MAINT='#M#'
fi
AC_SUBST(MAINT)dnl
]
)
# aclocal-include.m4
#
# This macro adds the name macrodir to the set of directories
# that `aclocal' searches for macros.
# serial 1
dnl AM_ACLOCAL_INCLUDE(macrodir)
AC_DEFUN([AM_ACLOCAL_INCLUDE],
[ACLOCAL="$ACLOCAL -I $1"])
dnl
dnl GNOME_CHECK_GUILE (failflag)
dnl
dnl if failflag is "fail" then GNOME_CHECK_GUILE will abort if guile is not found.
dnl
AC_DEFUN([GNOME_CHECK_GUILE],
[
saved_ldflags="$LDFLAGS"
saved_cppflags="$CPPFLAGS"
LDFLAGS="$LDFLAGS $GNOME_LIBDIR"
AC_CHECK_LIB(qthreads,main,[
QTTHREADS_LIB="-lqthreads"
],[
AC_CHECK_LIB(qt, qt_null, QTTHREADS_LIB="-lqt")
],$LIBS)
AC_SUBST(QTTHREADS_LIB)
AC_CHECK_LIB(termcap,main,TERMCAP_LIB="-ltermcap")
AC_CHECK_LIB(readline,main,READLINE_LIB="-lreadline",,$TERMCAP_LIB)
AC_SUBST(TERMCAP_LIB)
AC_SUBST(READLINE_LIB)
AC_CHECK_PROG(BUILD_GUILE, build-guile, yes, no)
if test "x$BUILD_GUILE" = "xyes"; then
AC_MSG_CHECKING(whether build-guile works)
if test x`build-guile --version >/dev/null 2>&1 || \
echo no` = xno; then
BUILD_GUILE=no
fi
AC_MSG_RESULT($BUILD_GUILE)
fi
AC_CHECK_LIB(m, sin)
if test "x$BUILD_GUILE" = "xyes"; then
AC_MSG_CHECKING(for guile libraries)
GUILE_LIBS="-L`build-guile info libdir` `build-guile link`"
AC_MSG_RESULT($GUILE_LIBS)
AC_MSG_CHECKING(for guile headers)
GUILE_INCS="-I`build-guile info includedir`"
AC_MSG_RESULT($GUILE_INCS)
else
GUILE_LIBS="$GNOME_LIBDIR"
GUILE_INCS="$GNOME_INCLUDEDIR"
AC_CHECK_LIB(rx, main, GUILE_LIBS="-lrx $GUILE_LIBS")
AC_CHECK_LIB(qt, main, GUILE_LIBS="-lqt $GUILE_LIBS")
AC_CHECK_LIB(dl, dlopen, GUILE_LIBS="-ldl $GUILE_LIBS")
GUILE_LIBS="-lguile $GUILE_LIBS $QTTHREADS_LIB $TERMCAP_LIB $READLINE_LIB"
fi
AC_SUBST(GUILE_LIBS)
AC_SUBST(GUILE_INCS)
LDFLAGS="$saved_ldflags $GUILE_LIBS"
CPPFLAGS="$saved_cppflags $GUILE_INCS"
AC_MSG_CHECKING(whether guile works)
AC_TRY_LINK([
#include <libguile.h>
#include <guile/gh.h>
],[
gh_eval_str("(newline)");
scm_boot_guile(0,NULL,NULL,NULL);
],[
ac_cv_guile_found=yes
AC_DEFINE(HAVE_GUILE)
],[
ac_cv_guile_found=no
])
AC_MSG_RESULT($ac_cv_guile_found)
if test x$ac_cv_guile_found = xno ; then
if test x$1 = xfail ; then
AC_MSG_ERROR(Can not find Guile 1.2 on this system)
else
AC_MSG_WARN(Can not find Guile 1.2 on this system)
fi
ac_cv_guile_found=no
fi
LDFLAGS="$saved_ldflags"
CPPFLAGS="$saved_cppflags"
AC_SUBST(GUILE_LIBS)
AM_CONDITIONAL(GUILE, test x$ac_cv_guile_found = xyes)
])
# Define a conditional.
AC_DEFUN(AM_CONDITIONAL,
[AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE)
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi])
dnl AM_PROG_LEX
dnl Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT
AC_DEFUN(AM_PROG_LEX,
[AC_CHECK_PROGS(LEX, flex lex, "$1/missing flex")
AC_PROG_LEX
AC_DECL_YYTEXT])
# serial 18 AM_PROG_LIBTOOL
AC_DEFUN(AM_PROG_LIBTOOL,
[AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_RANLIB])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AM_PROG_LD])
AC_REQUIRE([AM_PROG_NM])
AC_REQUIRE([AC_PROG_LN_S])
# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
AC_SUBST(LIBTOOL)
dnl Allow the --disable-shared flag to stop us from building shared libs.
AC_ARG_ENABLE(shared,
[ --enable-shared build shared libraries [default=yes]],
[if test "$enableval" = no; then
libtool_enable_shared=no
else
libtool_enable_shared=yes
fi])
test -n "$libtool_enable_shared" && enable_shared="$libtool_enable_shared"
libtool_shared=
test "$enable_shared" = no && libtool_shared=" --disable-shared"
dnl Allow the --disable-static flag to stop us from building static libs.
AC_ARG_ENABLE(static,
[ --enable-static build static libraries [default=yes]],
[if test "$enableval" = no; then
libtool_enable_static=no
else
libtool_enable_static=yes
fi])
test -n "$libtool_enable_static" && enable_static="$libtool_enable_static"
libtool_static=
test "$enable_static" = no && libtool_static=" --disable-static"
libtool_flags="$libtool_shared$libtool_static"
test "$silent" = yes && libtool_flags="$libtool_flags --silent"
test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
# Some flags need to be propagated to the compiler or linker for good
# libtool support.
[case "$host" in
*-*-irix6*)
ac_save_CFLAGS="$CFLAGS"
flag_passed=no
for f in -32 -64 -n32 ABI -cckr -mips1 -mips2 -mips3 -mips4; do
case "$f" in
ABI)
test -n "$SGI_ABI" && flag_passed=yes
if test "$flag_passed" = no && test "$ac_cv_prog_gcc" = yes; then
# Choose the ABI flag according to GCC's specs.
if $CC -dumpspecs 2>&1 | sed '/^\*link:$/,/^$/!d' | egrep -e '[ ]-32' >/dev/null; then
LD="${LD-ld} -32"
else
LD="${LD-ld} -n32"
fi
fi
;;
*)
if echo " $CC $CFLAGS " | egrep -e "[ ]$f[ ]" > /dev/null; then
flag_passed=yes
LD="${LD-ld} $f"
fi
;;
esac
done
CFLAGS="$ac_save_CFLAGS"
;;
*-*-sco3.2v5*)
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
CFLAGS="$CFLAGS -belf"
;;
esac]
# Actually configure libtool. ac_aux_dir is where install-sh is found.
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
|| AC_MSG_ERROR([libtool configure failed])
])
# AM_PROG_LD - find the path to the GNU or non-GNU linker
AC_DEFUN(AM_PROG_LD,
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])
ac_prog=ld
if test "$ac_cv_prog_gcc" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
ac_prog=`($CC -print-prog-name=ld) 2>&5`
case "$ac_prog" in
# Accept absolute paths.
dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
AC_DEFUN(AM_PATH_PROG_WITH_TEST,
[# Extract the first word of "$2", so it can be a program name with args.
set dummy $2; ac_word=[$]2
AC_MSG_CHECKING([for $ac_word])
AC_CACHE_VAL(ac_cv_path_$1,
[case "[$]$1" in
/*)
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(ac_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
for ac_dir in $PATH; do
for ac_dir in ifelse([$5], , $PATH, [$5]); do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog"; then
ac_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
test "$with_gnu_ld" != no && break
else
test "$with_gnu_ld" != yes && break
if test -f $ac_dir/$ac_word; then
if [$3]; then
ac_cv_path_$1="$ac_dir/$ac_word"
break
fi
fi
done
IFS="$ac_save_ifs"
else
ac_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$ac_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
dnl If no 4th arg is given, leave the cache variable unset,
dnl so AC_PATH_PROGS will keep looking.
ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
])dnl
;;
esac])dnl
$1="$ac_cv_path_$1"
if test -n "[$]$1"; then
AC_MSG_RESULT([$]$1)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_SUBST(LD)
AM_PROG_LD_GNU
AC_SUBST($1)dnl
])
AC_DEFUN(AM_PROG_LD_GNU,
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
ac_cv_prog_gnu_ld=yes
else
ac_cv_prog_gnu_ld=no
fi])
])
# AM_PROG_NM - find the path to a BSD-compatible name lister
AC_DEFUN(AM_PROG_NM,
[AC_MSG_CHECKING([for BSD-compatible nm])
AC_CACHE_VAL(ac_cv_path_NM,
[case "$NM" in
/*)
ac_cv_path_NM="$NM" # Let the user override the test with a path.
;;
*)
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
test -z "$ac_dir" && dir=.
if test -f $ac_dir/nm; then
# Check to see if the nm accepts a BSD-compat flag.
# Adding the `sed 1!d' prevents false positives on HP-UX, which says:
# nm: unknown option "B" ignored
if ($ac_dir/nm -B /dev/null 2>&1 | sed '1!d'; exit 0) | egrep /dev/null >/dev/null; then
ac_cv_path_NM="$ac_dir/nm -B"
elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1!d'; exit 0) | egrep /dev/null >/dev/null; then
ac_cv_path_NM="$ac_dir/nm -p"
else
ac_cv_path_NM="$ac_dir/nm"
fi
break
######################################################################
# lcmessage.m4 from gettext 0.32
######################################################################
# Check whether LC_MESSAGES is available in <locale.h>.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 1
AC_DEFUN(AM_LC_MESSAGES,
[if test $ac_cv_header_locale_h = yes; then
AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
if test $am_cv_val_LC_MESSAGES = yes; then
AC_DEFINE(HAVE_LC_MESSAGES)
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
;;
esac])
NM="$ac_cv_path_NM"
AC_MSG_RESULT([$NM])
AC_SUBST(NM)
])
fi])
dnl LIBGTOP_SUPPORT_CHECKS
dnl Check for various support functions needed by the standard
dnl Gnome libraries. Sets LIBOBJS, might define some macros,
dnl and will set the need_libgtop_support shell variable to "yes"
dnl or "no". Also sets up the Automake BUILD_LIBGTOP_SUPPORT
dnl conditional.
AC_DEFUN([LIBGTOP_SUPPORT_CHECKS],[
need_libgtop_support=no
save_LIBOBJS="$LIBOBJS"
LIBOBJS=
AC_CACHE_CHECK([for program_invocation_short_name], libgtop_cv_short_name, [
AC_TRY_LINK([#include <errno.h>],[
char *foo = program_invocation_short_name],
libgtop_cv_short_name=yes, libgtop_cv_short_name=no)])
if test "$libgtop_cv_short_name" = yes; then
AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
fi
AC_CACHE_CHECK([for program_invocation_name], libgtop_cv_invocation_name, [
AC_TRY_LINK([#include <errno.h>],[
char *foo = program_invocation_name],
libgtop_cv_invocation_name=yes, libgtop_cv_invocation_name=no)])
if test "$libgtop_cv_invocation_name" = yes; then
AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME)
fi
AC_REPLACE_FUNCS(strtok_r strcasecmp strndup strnlen strerror)
if test "$LIBOBJS" != ""; then
need_libgtop_support=yes
fi
# Turn our LIBOBJS into libtool objects. This is gross, but it
# requires changes to autoconf before it goes away.
LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'`
AC_SUBST(LTLIBOBJS)
LIBOBJS="$save_LIBOBJS"
AM_CONDITIONAL(BUILD_LIBGTOP_SUPPORT, test "$need_libgtop_support" = yes)
])
######################################################################
# gettext.m4 from gettext 0.32
######################################################################
# Macro to add for using GNU gettext.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
@@ -915,72 +489,3 @@ __argz_count __argz_stringify __argz_next])
sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
< $srcdir/po/POTFILES.in > po/POTFILES
])
# Search path for a program which passes the given test.
# Ulrich Drepper <drepper@cygnus.com>, 1996.
#
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 1
dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
AC_DEFUN(AM_PATH_PROG_WITH_TEST,
[# Extract the first word of "$2", so it can be a program name with args.
set dummy $2; ac_word=[$]2
AC_MSG_CHECKING([for $ac_word])
AC_CACHE_VAL(ac_cv_path_$1,
[case "[$]$1" in
/*)
ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
;;
*)
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
for ac_dir in ifelse([$5], , $PATH, [$5]); do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if [$3]; then
ac_cv_path_$1="$ac_dir/$ac_word"
break
fi
fi
done
IFS="$ac_save_ifs"
dnl If no 4th arg is given, leave the cache variable unset,
dnl so AC_PATH_PROGS will keep looking.
ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
])dnl
;;
esac])dnl
$1="$ac_cv_path_$1"
if test -n "[$]$1"; then
AC_MSG_RESULT([$]$1)
else
AC_MSG_RESULT(no)
fi
AC_SUBST($1)dnl
])
# Check whether LC_MESSAGES is available in <locale.h>.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
# serial 1
AC_DEFUN(AM_LC_MESSAGES,
[if test $ac_cv_header_locale_h = yes; then
AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
if test $am_cv_val_LC_MESSAGES = yes; then
AC_DEFINE(HAVE_LC_MESSAGES)
fi
fi])

View File

@@ -4,19 +4,19 @@ dnl
AC_INIT(copyright.txt)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(libgtop, 0.01)
AM_MAINTAINER_MODE
AC_CANONICAL_SYSTEM
AM_ACLOCAL_INCLUDE(macros)
AC_CANONICAL_HOST
AC_ISC_POSIX
AC_PROG_CC
AC_STDC_HEADERS
AC_ARG_PROGRAM
AC_PROG_AWK
AC_CHECK_TOOL(CC,gcc)
AC_CHECK_TOOL(CXX,g++)
AC_CHECK_TOOL(RANLIB,ranlib)
AC_CHECK_TOOL(LD,ld)
AC_CHECK_TOOL(AS,as)
AC_CHECK_TOOL(AR,ar)
AC_CHECK_TOOL(NM,nm)
@@ -24,6 +24,26 @@ AC_CHECK_TOOL(NM,nm)
NM=`which $NM`
export CC CXX RANLIB LD AS AR NM
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
export cross_compiling
AM_PROG_LIBTOOL
AM_INIT_AUTOMAKE(libgtop, 0.01)
dnl If you want to use libgtop without gnome, comment the following line out.
GNOME_INIT_HOOK(gnome_found=yes)
if test "x$gnome_found" != xyes; then
GNOME_SUPPORT_CHECKS
else
AM_CONDITIONAL(BUILD_GNOME_SUPPORT, false)
AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
fi
AC_LC_SYSDEPS
if test x$libgtop_want_guile = xyes ; then
@@ -32,7 +52,7 @@ if test x$libgtop_want_guile = xyes ; then
if test x$libgtop_want_names = xyes ; then
AC_DEFINE(GLIBTOP_GUILE_NAMES)
fi
guile_examples='third third_static third_linux'
guile_examples='third third_static'
guile_subdirs='guile'
else
guile_examples=
@@ -46,21 +66,10 @@ fi
AC_SUBST(guile_examples)
AC_SUBST(guile_subdirs)
AC_ISC_POSIX
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_STDC_HEADERS
AC_ARG_PROGRAM
AM_PROG_LEX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
export cross_compiling
AM_PROG_LIBTOOL
GNOME_SUPPORT_CHECKS
dnl You need to uncomment the following line if you want to use libgtop without Gnome.
dnl GNOME_SUPPORT_CHECKS
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -90,9 +99,33 @@ AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv strdup strtoul uname)
ALL_LINGUAS=""
ALL_LINGUAS="fr"
AM_GNU_GETTEXT
AC_PATH_XTRA
dnl The construct foo=`echo $w1 $w2 $w3` fails on some systems if $w1 = -e or -n
dnl So we use the following instead.
dnl XE_SPACE(var, words)
define([XE_SPACE],[
T=""
for W in $2; do if test -z "$T"; then T="$W"; else T="$T $W"; fi; done
$1="$T"
])dnl
dnl Autodetect Xauth
dnl -lXau is only used by gnuclient, so use a special variable for Xauth X libs
test -z "$with_xauth" && test "$window_system" = "none" && with_xauth=no
test -z "$with_xauth" && { AC_CHECK_HEADER(X11/Xauth.h, ,with_xauth=no) }
test -z "$with_xauth" && { AC_CHECK_LIB(Xau, XauGetAuthByAddr,[:],with_xauth=no, $X_LIBS) }
test -z "$with_xauth" && with_xauth=yes
if test "$with_xauth" = "yes"; then
AC_DEFINE(HAVE_XAUTH)
XE_SPACE(libs_xauth, $X_EXTRA_LIBS -lXau $libs_x $X_PRE_LIBS)
fi
AC_SUBST(libs_xauth)
CFLAGS="$CFLAGS -D_IN_LIBGTOP"
AC_SUBST(CFLAGS)
@@ -101,12 +134,24 @@ AC_SUBST(LDFLAGS)
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]],AC_DEFINE(GNOME_ENABLE_DEBUG),)
LIBSUPPORT=
SUPPORTINCS=
if test "$need_gnome_support" = yes; then
LIBSUPPORT='$(top_builddir)/support/libgnomesupport.la'
SUPPORTINCS='-I$(top_srcdir)/support'
dnl If you want to use libgtop without gnome, uncomment the following paragraph:
dnl LIBSUPPORT=
dnl SUPPORTINCS=
dnl if test "$need_gnome_support" = yes; then
dnl LIBSUPPORT='$(top_builddir)/support/libgnomesupport.la'
dnl SUPPORTINCS='-I$(top_srcdir)/support'
dnl fi
dnl AC_SUBST(LIBSUPPORT)
dnl AC_SUBST(SUPPORTINCS)
dnl Some ugly hack; if '-lgnomesupport' is part of $GNOME_LIBS, we include it here.
echo "$GNOME_LIBS" | grep -q -e '-lgnomesupport'
if test $? = 0 ; then
LIBSUPPORT="$GNOME_LIBDIR -lgnomesupport"
SUPPORTINCS="$GNOME_INCLUDEDIR"
fi
AC_SUBST(LIBSUPPORT)
AC_SUBST(SUPPORTINCS)
dnl These definitions are expanded in make.
LIBGTOP_LIBS='-L$(libdir)'
@@ -153,13 +198,12 @@ else
fi
if test "x$ac_cv_guile_found" = "xyes" ; then
LIBGTOP_INCS="$LIBGTOP_INCS $GUILE_INCS"
LIBGTOP_GUILE_INCS="$LIBGTOP_INCS $GUILE_INCS"
LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS $GUILE_LIBS"
fi
if test "x$libgtop_use_machine_h" = "xyes" ; then
machine_incs='-I$(top_srcdir)/sysdeps/@sysdeps_dir@'
fi
machine_incs='-I$(top_srcdir)/sysdeps/@sysdeps_dir@'
AC_SUBST(machine_incs)
@@ -170,8 +214,17 @@ AC_SUBST(LIBGTOP_GUILE_INCS)
AC_SUBST(LIBGTOP_BINDIR)
AC_SUBST(LIBGTOP_SERVER)
AC_SUBST(LIBSUPPORT)
AC_SUBST(SUPPORTINCS)
LIBSUPPORT=
SUPPORTINCS=
if test "$need_gnome_support" = yes; then
if test "x$gnome_found" = xyes ; then
LIBSUPPORT="$GNOME_LIBDIR -lgnomesupport"
SUPPORTINCS="$GNOME_INCLUDEDIR"
else
LIBSUPPORT='$(top_builddir)/support/libgnomesupport.la'
SUPPORTINCS='-DNEED_GNOMESUPPORT_H -I$(top_builddir)/support -I$(top_srcdir)/support'
fi
fi
AC_OUTPUT([
Makefile
@@ -188,8 +241,11 @@ sysdeps/stub/Makefile
sysdeps/sun4/Makefile
sysdeps/osf1/Makefile
sysdeps/linux/Makefile
sysdeps/kernel/Makefile
src/Makefile
src/server/Makefile
src/proxy/Makefile
src/daemon/Makefile
lib/Makefile
examples/Makefile
support/Makefile

11
examples/ChangeLog Normal file
View File

@@ -0,0 +1,11 @@
1998-06-12 Martin Baulig <martin@home-of-linux.org>
* test.scm: New file.
1998-06-07 Martin Baulig <martin@home-of-linux.org>
* Makefile.am (CFLAGS): Disable optimize.
* first.c (PROFILE_COUNT): Number of times each function
should be called. Defaults to 1; to profile the code, you
can increase this when compiling.

View File

@@ -6,46 +6,35 @@ INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
CFLAGS = -Wall -W @CFLAGS@
CFLAGS = -Wall -W @CFLAGS@ -O0
DEFS = @DEFS@
bin_PROGRAMS = first first_static first_linux \
second second_static second_linux \
bin_PROGRAMS = first first_static second second_static \
@guile_examples@
EXTRA_PROGRAMS = third third_static third_linux
EXTRA_PROGRAMS = third third_static
first_SOURCES = first.c
first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/lib/libgtop.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@
first_static_SOURCES = $(first_SOURCES)
first_static_LDADD = $(first_LDADD)
first_static_LDFLAGS = -static
first_linux_SOURCES = $(first_SOURCES)
first_linux_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@
first_linux_LDFLAGS = -static
second_SOURCES = second.c
second_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/lib/libgtop.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@
second_static_SOURCES = $(second_SOURCES)
second_static_LDADD = $(second_LDADD)
second_static_LDFLAGS = -static
second_linux_SOURCES = $(second_SOURCES)
second_linux_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@
second_linux_LDFLAGS = -static
if GLIBTOP_NAMES
third_guile_names_LIBS = $(top_builddir)/sysdeps/guile/names/libgtop_guile_names.la
third_names_LIBS = $(top_builddir)/sysdeps/names/libgtop_names.la
@@ -54,18 +43,11 @@ endif
third_SOURCES = third.c
third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \
$(third_guile_names_LIBS) $(third_names_LIBS) \
$(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/lib/libgtop.la \
$(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@
third_static_SOURCES = $(third_SOURCES)
third_static_LDADD = $(third_LDADD)
third_static_LDFLAGS = -static
third_linux_SOURCES = $(third_SOURCES)
third_linux_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \
$(third_guile_names_LIBS) $(third_names_LIBS) \
$(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@
third_linux_LDFLAGS = -static

View File

@@ -19,6 +19,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <locale.h>
#include <glibtop.h>
#include <glibtop/open.h>
#include <glibtop/close.h>
@@ -27,57 +29,70 @@
#include <glibtop/union.h>
#include <glibtop/sysdeps.h>
#ifndef PROFILE_COUNT
#define PROFILE_COUNT 1
#endif
int
main (int argc, char *argv [])
{
glibtop_union data;
glibtop_sysdeps sysdeps;
unsigned i, *ptr;
unsigned c, count, i, *ptr;
pid_t pid, ppid;
count = PROFILE_COUNT;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
textdomain (PACKAGE);
glibtop_init__r (&glibtop_global_server);
glibtop_init ();
glibtop_get_cpu (&data.cpu);
for (c = 0; c < count; c++)
glibtop_get_cpu (&data.cpu);
fprintf (stderr, "CPU (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu\n",
data.cpu.flags, data.cpu.total, data.cpu.user, data.cpu.nice,
data.cpu.sys, data.cpu.idle, data.cpu.frequency);
glibtop_get_mem (&data.mem);
for (c = 0; c < count; c++)
glibtop_get_mem (&data.mem);
fprintf (stderr, "Memory (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n",
data.mem.flags, data.mem.total, data.mem.used, data.mem.free,
data.mem.shared, data.mem.buffer, data.mem.cached,
data.mem.user, data.mem.locked);
glibtop_get_swap (&data.swap);
for (c = 0; c < count; c++)
glibtop_get_swap (&data.swap);
fprintf (stderr, "Swap (0x%08lx): %lu, %lu, %lu\n", data.swap.flags,
data.swap.total, data.swap.used, data.swap.free);
glibtop_get_uptime (&data.uptime);
for (c = 0; c < count; c++)
glibtop_get_uptime (&data.uptime);
fprintf (stderr, "Uptime (0x%08lx): %f, %f\n", data.uptime.flags,
data.uptime.uptime, data.uptime.idletime);
glibtop_get_loadavg (&data.loadavg);
for (c = 0; c < count; c++)
glibtop_get_loadavg (&data.loadavg);
fprintf (stderr, "Loadavg (0x%08lx): %f, %f, %f\n", data.loadavg.flags,
data.loadavg.loadavg [0], data.loadavg.loadavg [1],
data.loadavg.loadavg [2]);
glibtop_get_shm_limits (&data.shm_limits);
for (c = 0; c < count; c++)
glibtop_get_shm_limits (&data.shm_limits);
fprintf (stderr, "Shm Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld\n",
data.shm_limits.flags, data.shm_limits.shmmax,
data.shm_limits.shmmin, data.shm_limits.shmmni,
data.shm_limits.shmseg, data.shm_limits.shmall);
glibtop_get_msg_limits (&data.msg_limits);
for (c = 0; c < count; c++)
glibtop_get_msg_limits (&data.msg_limits);
fprintf (stderr, "Msg Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
data.msg_limits.flags, data.msg_limits.msgpool,
@@ -85,7 +100,8 @@ main (int argc, char *argv [])
data.msg_limits.msgmnb, data.msg_limits.msgmni,
data.msg_limits.msgssz, data.msg_limits.msgtql);
glibtop_get_sem_limits (&data.sem_limits);
for (c = 0; c < count; c++)
glibtop_get_sem_limits (&data.sem_limits);
fprintf (stderr, "Sem Limits (0x%08lx): "
"%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
@@ -132,14 +148,16 @@ main (int argc, char *argv [])
fprintf (stderr, "\n");
glibtop_get_proc_state (&data.proc_state, pid);
for (c = 0; c < count; c++)
glibtop_get_proc_state (&data.proc_state, pid);
fprintf (stderr, "Proc_State PID %5u (0x%08lx): '%s', %c, %u, %u\n",
pid, data.proc_state.flags, data.proc_state.cmd,
data.proc_state.state, data.proc_state.uid,
data.proc_state.gid);
glibtop_get_proc_uid (&data.proc_uid, pid);
for (c = 0; c < count; c++)
glibtop_get_proc_uid (&data.proc_uid, pid);
fprintf (stderr, "Proc_Uid PID %5u (0x%08lx): "
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
@@ -151,7 +169,8 @@ main (int argc, char *argv [])
data.proc_uid.tpgid, data.proc_uid.priority,
data.proc_uid.nice);
glibtop_get_proc_mem (&data.proc_mem, pid);
for (c = 0; c < count; c++)
glibtop_get_proc_mem (&data.proc_mem, pid);
fprintf (stderr, "Proc_Mem PID %5u (0x%08lx): "
"%ld %ld %ld %ld %ld %ld\n", pid, data.proc_mem.flags,
@@ -159,7 +178,8 @@ main (int argc, char *argv [])
data.proc_mem.resident, data.proc_mem.share,
data.proc_mem.rss, data.proc_mem.rss_rlim);
glibtop_get_proc_time (&data.proc_time, pid);
for (c = 0; c < count; c++)
glibtop_get_proc_time (&data.proc_time, pid);
fprintf (stderr, "Proc_Time PID %5u (0x%08lx): "
"%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags,
@@ -168,14 +188,16 @@ main (int argc, char *argv [])
data.proc_time.cstime, data.proc_time.timeout,
data.proc_time.it_real_value);
glibtop_get_proc_signal (&data.proc_signal, pid);
for (c = 0; c < count; c++)
glibtop_get_proc_signal (&data.proc_signal, pid);
fprintf (stderr, "Proc_Signal PID %5u (0x%08lx): "
"%d %d %d %d\n", pid, data.proc_signal.flags,
data.proc_signal.signal, data.proc_signal.blocked,
data.proc_signal.sigignore, data.proc_signal.sigcatch);
glibtop_get_proc_kernel (&data.proc_kernel, pid);
for (c = 0; c < count; c++)
glibtop_get_proc_kernel (&data.proc_kernel, pid);
fprintf (stderr, "Proc_Kernel PID %5u (0x%08lx): "
"%lu %lu %lu %lu %lu %lu %lu %lu\n", pid,
@@ -185,7 +207,8 @@ main (int argc, char *argv [])
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
data.proc_kernel.wchan);
glibtop_get_proc_segment (&data.proc_segment, pid);
for (c = 0; c < count; c++)
glibtop_get_proc_segment (&data.proc_segment, pid);
fprintf (stderr, "Proc_Segment PID %5u (0x%08lx): "
"%ld %ld %ld %ld %lu %lu %lu\n", pid, data.proc_segment.flags,
@@ -196,14 +219,16 @@ main (int argc, char *argv [])
fprintf (stderr, "\n");
glibtop_get_proc_state (&data.proc_state, ppid);
for (c = 0; c < count; c++)
glibtop_get_proc_state (&data.proc_state, ppid);
fprintf (stderr, "Proc_State PPID %5u (0x%08lx): '%s', %c, %u, %u\n",
ppid, data.proc_state.flags, data.proc_state.cmd,
data.proc_state.state, data.proc_state.uid,
data.proc_state.gid);
glibtop_get_proc_uid (&data.proc_uid, ppid);
for (c = 0; c < count; c++)
glibtop_get_proc_uid (&data.proc_uid, ppid);
fprintf (stderr, "Proc_Uid PPID %5u (0x%08lx): "
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
@@ -215,7 +240,8 @@ main (int argc, char *argv [])
data.proc_uid.tpgid, data.proc_uid.priority,
data.proc_uid.nice);
glibtop_get_proc_mem (&data.proc_mem, ppid);
for (c = 0; c < count; c++)
glibtop_get_proc_mem (&data.proc_mem, ppid);
fprintf (stderr, "Proc_Mem PPID %5u (0x%08lx): "
"%ld %ld %ld %ld %ld %ld\n", ppid, data.proc_mem.flags,
@@ -223,7 +249,8 @@ main (int argc, char *argv [])
data.proc_mem.resident, data.proc_mem.share,
data.proc_mem.rss, data.proc_mem.rss_rlim);
glibtop_get_proc_time (&data.proc_time, ppid);
for (c = 0; c < count; c++)
glibtop_get_proc_time (&data.proc_time, ppid);
fprintf (stderr, "Proc_Time PPID %5u (0x%08lx): "
"%ld %ld %ld %ld %ld %ld %ld\n", ppid, data.proc_time.flags,
@@ -232,14 +259,16 @@ main (int argc, char *argv [])
data.proc_time.cstime, data.proc_time.timeout,
data.proc_time.it_real_value);
glibtop_get_proc_signal (&data.proc_signal, ppid);
for (c = 0; c < count; c++)
glibtop_get_proc_signal (&data.proc_signal, ppid);
fprintf (stderr, "Proc_Signal PPID %5u (0x%08lx): "
"%d %d %d %d\n", ppid, data.proc_signal.flags,
data.proc_signal.signal, data.proc_signal.blocked,
data.proc_signal.sigignore, data.proc_signal.sigcatch);
glibtop_get_proc_kernel (&data.proc_kernel, ppid);
for (c = 0; c < count; c++)
glibtop_get_proc_kernel (&data.proc_kernel, ppid);
fprintf (stderr, "Proc_Kernel PPID %5u (0x%08lx): "
"%lu %lu %lu %lu %lu %lu %lu %lu\n", ppid,
@@ -249,7 +278,8 @@ main (int argc, char *argv [])
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
data.proc_kernel.wchan);
glibtop_get_proc_segment (&data.proc_segment, ppid);
for (c = 0; c < count; c++)
glibtop_get_proc_segment (&data.proc_segment, ppid);
fprintf (stderr, "Proc_Segment PPID %5u (0x%08lx): "
"%ld %ld %ld %ld %lu %lu %lu\n", ppid, data.proc_segment.flags,
@@ -260,14 +290,16 @@ main (int argc, char *argv [])
fprintf (stderr, "\n");
glibtop_get_proc_state (&data.proc_state, 1);
for (c = 0; c < count; c++)
glibtop_get_proc_state (&data.proc_state, 1);
fprintf (stderr, "Proc_State INIT %5u (0x%08lx): '%s', %c, %u, %u\n",
1, data.proc_state.flags, data.proc_state.cmd,
data.proc_state.state, data.proc_state.uid,
data.proc_state.gid);
glibtop_get_proc_uid (&data.proc_uid, 1);
for (c = 0; c < count; c++)
glibtop_get_proc_uid (&data.proc_uid, 1);
fprintf (stderr, "Proc_Uid INIT %5u (0x%08lx): "
"%d %d %d %d %d %d %d %d %d %d %d %d\n",
@@ -279,7 +311,8 @@ main (int argc, char *argv [])
data.proc_uid.tpgid, data.proc_uid.priority,
data.proc_uid.nice);
glibtop_get_proc_mem (&data.proc_mem, 1);
for (c = 0; c < count; c++)
glibtop_get_proc_mem (&data.proc_mem, 1);
fprintf (stderr, "Proc_Mem INIT %5u (0x%08lx): "
"%ld %ld %ld %ld %ld %ld\n", 1, data.proc_mem.flags,
@@ -287,7 +320,8 @@ main (int argc, char *argv [])
data.proc_mem.resident, data.proc_mem.share,
data.proc_mem.rss, data.proc_mem.rss_rlim);
glibtop_get_proc_time (&data.proc_time, 1);
for (c = 0; c < count; c++)
glibtop_get_proc_time (&data.proc_time, 1);
fprintf (stderr, "Proc_Time INIT %5u (0x%08lx): "
"%ld %ld %ld %ld %ld %ld %ld\n", 1, data.proc_time.flags,
@@ -296,14 +330,16 @@ main (int argc, char *argv [])
data.proc_time.cstime, data.proc_time.timeout,
data.proc_time.it_real_value);
glibtop_get_proc_signal (&data.proc_signal, 1);
for (c = 0; c < count; c++)
glibtop_get_proc_signal (&data.proc_signal, 1);
fprintf (stderr, "Proc_Signal INIT %5u (0x%08lx): "
"%d %d %d %d\n", 1, data.proc_signal.flags,
data.proc_signal.signal, data.proc_signal.blocked,
data.proc_signal.sigignore, data.proc_signal.sigcatch);
glibtop_get_proc_kernel (&data.proc_kernel, 1);
for (c = 0; c < count; c++)
glibtop_get_proc_kernel (&data.proc_kernel, 1);
fprintf (stderr, "Proc_Kernel INIT %5u (0x%08lx): "
"%lu %lu %lu %lu %lu %lu %lu %lu\n", 1,
@@ -313,7 +349,8 @@ main (int argc, char *argv [])
data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip,
data.proc_kernel.wchan);
glibtop_get_proc_segment (&data.proc_segment, 1);
for (c = 0; c < count; c++)
glibtop_get_proc_segment (&data.proc_segment, 1);
fprintf (stderr, "Proc_Segment INIT %5u (0x%08lx): "
"%ld %ld %ld %ld %lu %lu %lu\n", 1, data.proc_segment.flags,

View File

@@ -19,6 +19,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <locale.h>
#include <glibtop.h>
#include <glibtop/open.h>
#include <glibtop/close.h>
@@ -39,7 +41,7 @@ main (int argc, char *argv [])
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
textdomain (PACKAGE);
glibtop_init__r (&glibtop_global_server);
glibtop_init ();
glibtop_get_sysdeps (&sysdeps);

80
examples/test.scm Normal file
View File

@@ -0,0 +1,80 @@
(display (glibtop-names-sysdeps)) (newline)
(display (glibtop-labels-sysdeps)) (newline)
(display (glibtop-descriptions-sysdeps)) (newline)
(display (glibtop-types-sysdeps)) (newline)
(newline)
(display (glibtop-names-cpu)) (newline)
(display (glibtop-names-mem)) (newline)
(display (glibtop-names-swap)) (newline)
(display (glibtop-names-uptime)) (newline)
(display (glibtop-names-loadavg)) (newline)
(display (glibtop-names-shm_limits)) (newline)
(display (glibtop-names-msg_limits)) (newline)
(display (glibtop-names-sem_limits)) (newline)
(display (glibtop-names-proclist)) (newline)
(display (glibtop-names-proc_state)) (newline)
(display (glibtop-names-proc_uid)) (newline)
(display (glibtop-names-proc_mem)) (newline)
(display (glibtop-names-proc_time)) (newline)
(display (glibtop-names-proc_signal)) (newline)
(display (glibtop-names-proc_kernel)) (newline)
(display (glibtop-names-proc_segment)) (newline)
(newline)
(display (glibtop-labels-cpu)) (newline)
(display (glibtop-labels-mem)) (newline)
(display (glibtop-labels-swap)) (newline)
(display (glibtop-labels-uptime)) (newline)
(display (glibtop-labels-loadavg)) (newline)
(display (glibtop-labels-shm_limits)) (newline)
(display (glibtop-labels-msg_limits)) (newline)
(display (glibtop-labels-sem_limits)) (newline)
(display (glibtop-labels-proclist)) (newline)
(display (glibtop-labels-proc_state)) (newline)
(display (glibtop-labels-proc_uid)) (newline)
(display (glibtop-labels-proc_mem)) (newline)
(display (glibtop-labels-proc_time)) (newline)
(display (glibtop-labels-proc_signal)) (newline)
(display (glibtop-labels-proc_kernel)) (newline)
(display (glibtop-labels-proc_segment)) (newline)
(newline)
(display (glibtop-descriptions-cpu)) (newline)
(display (glibtop-descriptions-mem)) (newline)
(display (glibtop-descriptions-swap)) (newline)
(display (glibtop-descriptions-uptime)) (newline)
(display (glibtop-descriptions-loadavg)) (newline)
(display (glibtop-descriptions-shm_limits)) (newline)
(display (glibtop-descriptions-msg_limits)) (newline)
(display (glibtop-descriptions-sem_limits)) (newline)
(display (glibtop-descriptions-proclist)) (newline)
(display (glibtop-descriptions-proc_state)) (newline)
(display (glibtop-descriptions-proc_uid)) (newline)
(display (glibtop-descriptions-proc_mem)) (newline)
(display (glibtop-descriptions-proc_time)) (newline)
(display (glibtop-descriptions-proc_signal)) (newline)
(display (glibtop-descriptions-proc_kernel)) (newline)
(display (glibtop-descriptions-proc_segment)) (newline)
(newline)
(display (glibtop-types-cpu)) (newline)
(display (glibtop-types-mem)) (newline)
(display (glibtop-types-swap)) (newline)
(display (glibtop-types-uptime)) (newline)
(display (glibtop-types-loadavg)) (newline)
(display (glibtop-types-shm_limits)) (newline)
(display (glibtop-types-msg_limits)) (newline)
(display (glibtop-types-sem_limits)) (newline)
(display (glibtop-types-proclist)) (newline)
(display (glibtop-types-proc_state)) (newline)
(display (glibtop-types-proc_uid)) (newline)
(display (glibtop-types-proc_mem)) (newline)
(display (glibtop-types-proc_time)) (newline)
(display (glibtop-types-proc_signal)) (newline)
(display (glibtop-types-proc_kernel)) (newline)
(display (glibtop-types-proc_segment)) (newline)

View File

@@ -19,6 +19,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <locale.h>
#include <glibtop.h>
#include <glibtop/open.h>

View File

@@ -1,10 +0,0 @@
(display (get-cpu)) (newline)
(display (get-mem)) (newline)
(display (get-swap)) (newline)
(display (get-uptime)) (newline)
(display (get-loadavg)) (newline)
(display (get-shm_limits)) (newline)
(display (get-msg_limits)) (newline)
(display (get-sem_limits)) (newline)
(display (get-sysdeps)) (newline)
(display (get-proclist)) (newline)

16
features.def Normal file
View File

@@ -0,0 +1,16 @@
cpu ulong(total,user,nice,sys,idle,frequency)
mem ulong(total,used,free,shared,buffer,cached,user,locked)
swap ulong(total,used,free)
uptime double(uptime,idletime)
loadavg double(loadavg[0],loadavg[1],loadavg[2])
shm_limits ulong(shmmax,shmmin,shmmni,shmseg,shmall)
msg_limits ulong(msgpool,msgmap,msgmax,msgmnb,msgmni,msgssz,msgtql)
sem_limits ulong(semmap,semmni,semmns,semmnu,semmsl,semopm,semume,semusz,semvmx,semaem)
proclist ulong(number,size,total)
proc_state str(cmd):char(state):ulong(uid,gid)
proc_uid long(uid,euid,gid,egid,pid,ppid,pgrp,session,tty,tpgid,priority,nice)
proc_mem long(size,vsize,resident,share,rss,rss_rlim)
proc_time long(start_time,utime,stime,cutime,cstime,timeout,it_real_value)
proc_signal long(signal,blocked,sigignore,sigcatch)
proc_kernel ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,wchan)
proc_segment long(trs,lrs,drs,dt):ulong(start_code,end_code,start_stack)

View File

@@ -24,6 +24,9 @@
#include <glibtop/global.h>
#include <glibtop_server.h>
#include <glibtop/types.h>
#ifdef HAVE_GLIBTOP_MACHINE_H
#include <glibtop_machine.h>
#endif
@@ -40,14 +43,23 @@ struct _glibtop
int output [2]; /* Pipe client -> server */
unsigned long os_version_code; /* Version code of the operating system */
const char *name; /* Program name for error messages */
const char *server_command; /* Command used to invoke server */
const char *server_host; /* Host the server should run on */
const char *server_user; /* Name of the user on the target host */
const char *server_rsh; /* Command used to connect to the target host */
unsigned long features; /* Server is required for this features */
pid_t pid; /* PID of the server */
};
extern glibtop *glibtop_global_server;
#define glibtop_init() glibtop_init__r(&glibtop_global_server);
extern const unsigned long glibtop_server_features;
extern glibtop *glibtop_init__r __P((glibtop **));
#define glibtop_init() glibtop_init_r(&glibtop_global_server, 0, 0);
#define glibtop_close() glibtop_close_r(&glibtop_global_server);
extern glibtop *glibtop_init_r __P((glibtop **, const unsigned long, const unsigned));
#ifdef HAVE_GUILE

View File

@@ -26,7 +26,7 @@
__BEGIN_DECLS
extern void glibtop_close __P((glibtop *));
extern void glibtop_close_r __P((glibtop *));
__END_DECLS

View File

@@ -29,6 +29,7 @@ __BEGIN_DECLS
#define GLIBTOP_CMND_QUIT 0
#define GLIBTOP_CMND_SYSDEPS 1
#define GLIBTOP_CMND_CPU 2
#define GLIBTOP_CMND_MEM 3
#define GLIBTOP_CMND_SWAP 4
@@ -58,9 +59,10 @@ struct _glibtop_command
size_t size;
};
#define glibtop_call(p1, p2, p3, p4) glibtop_call__r(glibtop_global_server, p1, p2, p3, p4)
#define glibtop_call(p1, p2, p3, p4) glibtop_call_r(glibtop_global_server, p1, p2, p3, p4)
extern void *glibtop_call__r __P((glibtop *, unsigned, size_t, void *, size_t, void *));
extern void *glibtop_call_l __P((glibtop *, unsigned, size_t, void *, size_t, void *));
extern void *glibtop_call_s __P((glibtop *, unsigned, size_t, void *, size_t, void *));
__END_DECLS

View File

@@ -49,9 +49,21 @@ struct _glibtop_cpu
frequency; /* GLIBTOP_CPU_FREQUENCY */
};
#define glibtop_get_cpu(cpu) glibtop_get_cpu__r(glibtop_global_server, cpu)
#define glibtop_get_cpu(cpu) glibtop_get_cpu_l(glibtop_global_server, cpu)
extern void glibtop_get_cpu__r __P((glibtop *, glibtop_cpu *));
#if GLIBTOP_SUID_CPU
#define glibtop_get_cpu_r glibtop_get_cpu_p
#else
#define glibtop_get_cpu_r glibtop_get_cpu_s
#endif
extern void glibtop_get_cpu_l __P((glibtop *, glibtop_cpu *));
#if GLIBTOP_SUID_CPU
extern void glibtop_get_cpu_p __P((glibtop *, glibtop_cpu *));
#else
extern void glibtop_get_cpu_s __P((glibtop *, glibtop_cpu *));
#endif
#ifdef HAVE_GUILE
@@ -77,7 +89,7 @@ extern SCM glibtop_guile_descriptions_cpu __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_cpu [];
extern const char *glibtop_types_cpu [];
extern const unsigned glibtop_types_cpu [];
extern const char *glibtop_labels_cpu [];
extern const char *glibtop_descriptions_cpu [];

View File

@@ -26,9 +26,17 @@
__BEGIN_DECLS
#define glibtop_error(p1, args...) glibtop_error__r(glibtop_global_server , p1 , ## args)
#define glibtop_error(p1, args...) glibtop_error_r(glibtop_global_server , p1 , ## args)
#define glibtop_warn(p1, args...) glibtop_warn_r(glibtop_global_server , p1 , ## args)
extern void glibtop_error__r __P((glibtop *, char *, ...));
#define glibtop_error_io(p1, args...) glibtop_error_io_r(glibtop_global_server , p1 , ## args)
#define glibtop_warn_io(p1, args...) glibtop_warn_io_r(glibtop_global_server , p1 , ## args)
extern void glibtop_error_r __P((glibtop *, char *, ...));
extern void glibtop_warn_r __P((glibtop *, char *, ...));
extern void glibtop_error_io_r __P((glibtop *, char *, ...));
extern void glibtop_warn_io_r __P((glibtop *, char *, ...));
__END_DECLS

View File

@@ -51,21 +51,37 @@
# define __P(protos) ()
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#ifdef HAVE_GUILE
#include <guile/gh.h>
#endif
#ifdef _IN_LIBGTOP
#if (defined HAVE_LIBINTL_H) || (defined HAVE_GETTEXT)
#include <libintl.h>
#else
#include <libgettext.h>
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_MEMORY_H
#include <memory.h>
@@ -73,7 +89,9 @@
#include <string.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <signal.h>
#include <errno.h>

191
include/glibtop/gnuserv.h Normal file
View File

@@ -0,0 +1,191 @@
/* -*-C-*-
Header file for the GNU Emacs server and client C code.
This file is part of GNU Emacs.
Copying is permitted under those conditions described by the GNU
General Public License.
Copyright (C) 1989 Free Software Foundation, Inc.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
/* HISTORY
* 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
/*
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
* Please see the note at the end of the README file for details.
*
* (If gnuserv came bundled with your emacs, the README file is probably
* ../etc/gnuserv.README relative to the directory containing this file)
*/
#if 0
static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup alpha !";
#endif
#define NO_SHORTNAMES
#define PATCHLEVEL 2
#define NO_SHORTNAMES
/* gnuserv should not be compiled using SOCKS */
#define DO_NOT_SOCKSIFY
#include <glibtop.h>
#include <glibtop/error.h>
#undef read
#undef write
#undef open
#undef close
#undef signal
/* Define the communication method between server and clients:
* You can have either or both kinds of sockets, but you can't mix
* sockets with sysv ipc
*/
#define INTERNET_DOMAIN_SOCKETS
#define UNIX_DOMAIN_SOCKETS
/* #define SYSV_IPC */
/*
* Define additional authentication protocols to be used. These methods will
* be tried before falling back to the default gnuserv protocol (based on
* the GNU_SECURE environment variable). Currently, only MIT-MAGIC-COOKIE-1
* is also supported.
*
* Comment out the next line(s) if you don't want to enable the
* appropriate authentication protocol.
*/
#if defined (HAVE_XAUTH)
#define AUTH_MAGIC_COOKIE
#endif /* HAVE_XAUTH */
/*
* stuff related to supporting MIT-MAGIC-COOKIE-1
*/
#define MCOOKIE_SCREEN "999" /* screen # to use as the gnuserv cookie */
#define MCOOKIE_NAME "MAGIC-1" /* authentication protocol name */
#define MCOOKIE_X_NAME "MIT-MAGIC-COOKIE-1" /* as needed by X */
#define DEFAUTH_NAME "GNU-SECURE" /* name of default auth protocol */
#define AUTH_TIMEOUT 15 /* # seconds to wait for auth data */
#define AUTH_NAMESZ 15 /* max allows auth protocol name size */
/*
* Pick a default communication scheme, if none was specified.
*/
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
#ifdef HAVE_SYSVIPC
#define SYSV_IPC /* SYSV systems use SYSV IPC by default */
#endif /* HAVE_SYSVIPC */
#ifdef BSD
#define UNIX_DOMAIN_SOCKETS /* BSD systems use Unix Domain sockets by default */
#endif /* BSD */
#endif /* No communication method pre-defined */
/*
* If you are using SYSV_IPC, you might want to make the buffer size bigger
* since it limits the size of requests and responses. Don't make it bigger
* than your system's max message size though (usually a couple of k) or else
* msgsend will start failing. For sockets, using the system BUFSIZ is usually
* what you want.
*/
# define GSERV_BUFSZ BUFSIZ
#ifdef SYSV_IPC
#include <sys/ipc.h>
#include <sys/msg.h>
#define send_string(s,str) \
if (strlen(msgp->mtext) + strlen(str) < GSERV_BUFSZ) \
strcat(msgp->mtext,str); \
else \
{ \
fprintf(stderr,"%s: not enough message buffer space\n",progname); \
exit(1); \
} \
#endif /* SYSV_IPC */
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
#include <sys/socket.h>
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
#ifdef INTERNET_DOMAIN_SOCKETS
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define TABLE_SIZE 101 /* The number of entries in the hash table */
#define HASH(host) host /* Rather simplistic hash function */
#define DEFAULT_PORT 21490 /* default port number to use is
* DEFAULT_PORT + uid */
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef UNIX_DOMAIN_SOCKETS
#include <sys/un.h>
#define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */
#endif /* UNIX_DOMAIN_SOCKETS */
#define HOSTNAMSZ 255 /* max size of a hostname */
#define REPLYSIZ 300 /* max size of reply from server to client */
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE 1
extern char *optarg;
extern int optind;
extern char *progname;
/* The casts shut Sun's compiler up and are safe in the context these
are actually used. */
#define max2(x,y) (((int) (x) > (int) (y)) ? (x) : (y))
#define min2(x,y) (((int) (x) < (int) (y)) ? (x) : (y))
#ifndef _NFILE /* rough guess at maximum number of open files */
#define _NFILE 20
#endif
#define EOT_STR "\004"
#define EOT_CHR '\004'
/* connection types */
#define CONN_UNIX 0
#define CONN_INTERNET 1
#define CONN_IPC 2
/* function declarations */
int make_connection (char *hostarg, int portarg, int *s);
#ifdef SYSV_IPC
void disconnect_from_ipc_server();
#endif
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
void send_string (int s, const char *msg);
void disconnect_from_server (int s, int echo);
int read_line (int s, char *dest);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS
int internet_addr (char *host);
#endif

View File

@@ -39,9 +39,21 @@ struct _glibtop_loadavg
double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */
};
#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg__r(glibtop_global_server, loadavg)
#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg_l(glibtop_global_server, loadavg)
extern void glibtop_get_loadavg__r __P((glibtop *, glibtop_loadavg *));
#if GLIBTOP_SUID_LOADAVG
#define glibtop_get_loadavg_r glibtop_get_loadavg_p
#else
#define glibtop_get_loadavg_r glibtop_get_loadavg_s
#endif
extern void glibtop_get_loadavg_l __P((glibtop *, glibtop_loadavg *));
#if GLIBTOP_SUID_LOADAVG
extern void glibtop_get_loadavg_p __P((glibtop *, glibtop_loadavg *));
#else
extern void glibtop_get_loadavg_s __P((glibtop *, glibtop_loadavg *));
#endif
#ifdef HAVE_GUILE
@@ -67,7 +79,7 @@ extern SCM glibtop_guile_descriptions_loadavg __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_loadavg [];
extern const char *glibtop_types_loadavg [];
extern const unsigned glibtop_types_loadavg [];
extern const char *glibtop_labels_loadavg [];
extern const char *glibtop_descriptions_loadavg [];

View File

@@ -53,9 +53,21 @@ struct _glibtop_mem
locked; /* GLIBTOP_MEM_LOCKED */
};
#define glibtop_get_mem(mem) glibtop_get_mem__r(glibtop_global_server, mem)
#define glibtop_get_mem(mem) glibtop_get_mem_l(glibtop_global_server, mem)
extern void glibtop_get_mem__r __P((glibtop *, glibtop_mem *));
#if GLIBTOP_SUID_MEM
#define glibtop_get_mem_r glibtop_get_mem_p
#else
#define glibtop_get_mem_r glibtop_get_mem_s
#endif
extern void glibtop_get_mem_l __P((glibtop *, glibtop_mem *));
#if GLIBTOP_SUID_MEM
extern void glibtop_get_mem_p __P((glibtop *, glibtop_mem *));
#else
extern void glibtop_get_mem_s __P((glibtop *, glibtop_mem *));
#endif
#ifdef HAVE_GUILE
@@ -81,7 +93,7 @@ extern SCM glibtop_guile_descriptions_mem __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_mem [];
extern const char *glibtop_types_mem [];
extern const unsigned glibtop_types_mem [];
extern const char *glibtop_labels_mem [];
extern const char *glibtop_descriptions_mem [];

View File

@@ -51,9 +51,21 @@ struct _glibtop_msg_limits
msgtql; /* GLIBTOP_IPC_MSGTQL */
};
#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits__r(glibtop_global_server, msg)
#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits_l(glibtop_global_server, msg)
extern void glibtop_get_msg_limits__r __P((glibtop *, glibtop_msg_limits *));
#if GLIBTOP_SUID_MSG_LIMITS
#define glibtop_get_msg_limits_r glibtop_get_msg_limits_p
#else
#define glibtop_get_msg_limits_r glibtop_get_msg_limits_s
#endif
extern void glibtop_get_msg_limits_l __P((glibtop *, glibtop_msg_limits *));
#if GLIBTOP_SUID_MSG_LIMITS
extern void glibtop_get_msg_limits_p __P((glibtop *, glibtop_msg_limits *));
#else
extern void glibtop_get_msg_limits_s __P((glibtop *, glibtop_msg_limits *));
#endif
#ifdef HAVE_GUILE
@@ -79,7 +91,7 @@ extern SCM glibtop_guile_descriptions_msg_limits __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_msg_limits [];
extern const char *glibtop_types_msg_limits [];
extern const unsigned glibtop_types_msg_limits [];
extern const char *glibtop_labels_msg_limits [];
extern const char *glibtop_descriptions_msg_limits [];

View File

@@ -26,7 +26,11 @@
__BEGIN_DECLS
extern void glibtop_open __P((glibtop *, const char *));
#define GLIBTOP_OPEN_NO_OVERRIDE 1
extern void glibtop_open_l __P((glibtop *, const char *, const unsigned long, const unsigned));
extern void glibtop_open_r __P((glibtop *, const char *, const unsigned long, const unsigned));
__END_DECLS

View File

@@ -60,9 +60,21 @@ struct _glibtop_proc_kernel
* proc is sleeping in */
};
#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel__r(glibtop_global_server, p1, p2)
#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel_l(glibtop_global_server, p1, p2)
extern void glibtop_get_proc_kernel__r __P((glibtop *, glibtop_proc_kernel *, pid_t));
#if GLIBTOP_SUID_PROC_KERNEL
#define glibtop_get_proc_kernel_r glibtop_get_proc_kernel_p
#else
#define glibtop_get_proc_kernel_r glibtop_get_proc_kernel_s
#endif
extern void glibtop_get_proc_kernel_l __P((glibtop *, glibtop_proc_kernel *, pid_t));
#if GLIBTOP_SUID_PROC_KERNEL
extern void glibtop_get_proc_kernel_p __P((glibtop *, glibtop_proc_kernel *, pid_t));
#else
extern void glibtop_get_proc_kernel_s __P((glibtop *, glibtop_proc_kernel *, pid_t));
#endif
#ifdef HAVE_GUILE
@@ -87,8 +99,8 @@ extern SCM glibtop_guile_descriptions_proc_kernel __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_types_proc_kernel [];
extern const char *glibtop_names_proc_kernel [];
extern const unsigned glibtop_types_proc_kernel [];
extern const char *glibtop_labels_proc_kernel [];
extern const char *glibtop_descriptions_proc_kernel [];

View File

@@ -43,9 +43,21 @@ struct _glibtop_proclist
size; /* GLIBTOP_PROCLIST_SIZE */
};
#define glibtop_get_proclist(proclist) glibtop_get_proclist__r(glibtop_global_server, proclist)
#define glibtop_get_proclist(proclist) glibtop_get_proclist_l(glibtop_global_server, proclist)
extern unsigned *glibtop_get_proclist__r __P((glibtop *, glibtop_proclist *));
#if GLIBTOP_SUID_PROCLIST
#define glibtop_get_proclist_r glibtop_get_proclist_p
#else
#define glibtop_get_proclist_r glibtop_get_proclist_s
#endif
extern unsigned *glibtop_get_proclist_l __P((glibtop *, glibtop_proclist *));
#if GLIBTOP_SUID_PROCLIST
extern unsigned *glibtop_get_proclist_p __P((glibtop *, glibtop_proclist *));
#else
extern unsigned *glibtop_get_proclist_s __P((glibtop *, glibtop_proclist *));
#endif
#ifdef HAVE_GUILE
@@ -71,7 +83,7 @@ extern SCM glibtop_guile_descriptions_proclist __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_proclist [];
extern const char *glibtop_types_proclist [];
extern const unsigned glibtop_types_proclist [];
extern const char *glibtop_labels_proclist [];
extern const char *glibtop_descriptions_proclist [];

View File

@@ -53,9 +53,21 @@ struct _glibtop_proc_mem
* of the process; usually 2,147,483,647 */
};
#define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem__r(glibtop_global_server, p1, p2)
#define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem_l(glibtop_global_server, p1, p2)
extern void glibtop_get_proc_mem__r __P((glibtop *, glibtop_proc_mem *, pid_t));
#if GLIBTOP_SUID_PROC_MEM
#define glibtop_get_proc_mem_r glibtop_get_proc_mem_p
#else
#define glibtop_get_proc_mem_r glibtop_get_proc_mem_s
#endif
extern void glibtop_get_proc_mem_l __P((glibtop *, glibtop_proc_mem *, pid_t));
#if GLIBTOP_SUID_PROC_MEM
extern void glibtop_get_proc_mem_p __P((glibtop *, glibtop_proc_mem *, pid_t));
#else
extern void glibtop_get_proc_mem_s __P((glibtop *, glibtop_proc_mem *, pid_t));
#endif
#ifdef HAVE_GUILE
@@ -81,7 +93,7 @@ extern SCM glibtop_guile_descriptions_proc_mem __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_proc_mem [];
extern const char *glibtop_types_proc_mem [];
extern const unsigned glibtop_types_proc_mem [];
extern const char *glibtop_labels_proc_mem [];
extern const char *glibtop_descriptions_proc_mem [];

View File

@@ -54,9 +54,21 @@ struct _glibtop_proc_segment
start_stack; /* address of the bottom of stack segment */
};
#define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment__r(glibtop_global_server, p1, p2)
#define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment_l(glibtop_global_server, p1, p2)
extern void glibtop_get_proc_segment__r __P((glibtop *, glibtop_proc_segment *, pid_t));
#if GLIBTOP_SUID_PROC_SEGMENT
#define glibtop_get_proc_segment_r glibtop_get_proc_segment_p
#else
#define glibtop_get_proc_segment_r glibtop_get_proc_segment_s
#endif
extern void glibtop_get_proc_segment_l __P((glibtop *, glibtop_proc_segment *, pid_t));
#if GLIBTOP_SUID_PROC_SEGMENT
extern void glibtop_get_proc_segment_p __P((glibtop *, glibtop_proc_segment *, pid_t));
#else
extern void glibtop_get_proc_segment_s __P((glibtop *, glibtop_proc_segment *, pid_t));
#endif
#ifdef HAVE_GUILE
@@ -81,8 +93,8 @@ extern SCM glibtop_guile_descriptions_proc_segment __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_types_proc_segment [];
extern const char *glibtop_names_proc_segment [];
extern const unsigned glibtop_types_proc_segment [];
extern const char *glibtop_labels_proc_segment [];
extern const char *glibtop_descriptions_proc_segment [];

View File

@@ -47,9 +47,21 @@ struct _glibtop_proc_signal
sigcatch; /* mask of caught signals */
};
#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal__r(glibtop_global_server, p1, p2)
#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal_l(glibtop_global_server, p1, p2)
extern void glibtop_get_proc_signal__r __P((glibtop *, glibtop_proc_signal *, pid_t));
#if GLIBTOP_SUID_PROC_SIGNAL
#define glibtop_get_proc_signal_r glibtop_get_proc_signal_p
#else
#define glibtop_get_proc_signal_r glibtop_get_proc_signal_s
#endif
extern void glibtop_get_proc_signal_l __P((glibtop *, glibtop_proc_signal *, pid_t));
#if GLIBTOP_SUID_PROC_SIGNAL
extern void glibtop_get_proc_signal_p __P((glibtop *, glibtop_proc_signal *, pid_t));
#else
extern void glibtop_get_proc_signal_s __P((glibtop *, glibtop_proc_signal *, pid_t));
#endif
#ifdef HAVE_GUILE
@@ -75,7 +87,7 @@ extern SCM glibtop_guile_descriptions_proc_signal __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_proc_signal [];
extern const char *glibtop_types_proc_signal [];
extern const unsigned glibtop_types_proc_signal [];
extern const char *glibtop_labels_proc_signal [];
extern const char *glibtop_descriptions_proc_signal [];

View File

@@ -54,9 +54,21 @@ struct _glibtop_proc_state
gid; /* GID of process */
};
#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state__r(glibtop_global_server, p1, p2)
#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state_l(glibtop_global_server, p1, p2)
extern void glibtop_get_proc_state__r __P((glibtop *, glibtop_proc_state *, pid_t));
#if GLIBTOP_SUID_PROC_STATE
#define glibtop_get_proc_state_r glibtop_get_proc_state_p
#else
#define glibtop_get_proc_state_r glibtop_get_proc_state_s
#endif
extern void glibtop_get_proc_state_l __P((glibtop *, glibtop_proc_state *, pid_t));
#if GLIBTOP_SUID_PROC_STATE
extern void glibtop_get_proc_state_p __P((glibtop *, glibtop_proc_state *, pid_t));
#else
extern void glibtop_get_proc_state_s __P((glibtop *, glibtop_proc_state *, pid_t));
#endif
#ifdef HAVE_GUILE
@@ -82,7 +94,7 @@ extern SCM glibtop_guile_descriptions_proc_state __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_proc_state [];
extern const char *glibtop_types_proc_state [];
extern const unsigned glibtop_types_proc_state [];
extern const char *glibtop_labels_proc_state [];
extern const char *glibtop_descriptions_proc_state [];

View File

@@ -59,9 +59,21 @@ struct _glibtop_proc_time
* due to an interval timer. */
};
#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time__r(glibtop_global_server, p1, p2)
#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time_l(glibtop_global_server, p1, p2)
extern void glibtop_get_proc_time__r __P((glibtop *, glibtop_proc_time *, pid_t));
#if GLIBTOP_SUID_PROC_TIME
#define glibtop_get_proc_time_r glibtop_get_proc_time_p
#else
#define glibtop_get_proc_time_r glibtop_get_proc_time_s
#endif
extern void glibtop_get_proc_time_l __P((glibtop *, glibtop_proc_time *, pid_t));
#if GLIBTOP_SUID_PROC_TIME
extern void glibtop_get_proc_time_p __P((glibtop *, glibtop_proc_time *, pid_t));
#else
extern void glibtop_get_proc_time_s __P((glibtop *, glibtop_proc_time *, pid_t));
#endif
#ifdef HAVE_GUILE
@@ -87,7 +99,7 @@ extern SCM glibtop_guile_descriptions_proc_time __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_proc_time [];
extern const char *glibtop_types_proc_time [];
extern const unsigned glibtop_types_proc_time [];
extern const char *glibtop_labels_proc_time [];
extern const char *glibtop_descriptions_proc_time [];

View File

@@ -63,9 +63,21 @@ struct _glibtop_proc_uid
nice; /* standard unix nice level of process */
};
#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid__r(glibtop_global_server, p1, p2)
#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid_l(glibtop_global_server, p1, p2)
extern void glibtop_get_proc_uid__r __P((glibtop *, glibtop_proc_uid *, pid_t));
#if GLIBTOP_SUID_PROC_UID
#define glibtop_get_proc_uid_r glibtop_get_proc_uid_p
#else
#define glibtop_get_proc_uid_r glibtop_get_proc_uid_s
#endif
extern void glibtop_get_proc_uid_l __P((glibtop *, glibtop_proc_uid *, pid_t));
#if GLIBTOP_SUID_PROC_UID
extern void glibtop_get_proc_uid_p __P((glibtop *, glibtop_proc_uid *, pid_t));
#else
extern void glibtop_get_proc_uid_s __P((glibtop *, glibtop_proc_uid *, pid_t));
#endif
#ifdef HAVE_GUILE
@@ -91,7 +103,7 @@ extern SCM glibtop_guile_descriptions_proc_uid __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_proc_uid [];
extern const char *glibtop_types_proc_uid [];
extern const unsigned glibtop_types_proc_uid [];
extern const char *glibtop_labels_proc_uid [];
extern const char *glibtop_descriptions_proc_uid [];

View File

@@ -29,7 +29,8 @@ __BEGIN_DECLS
#define glibtop_read(p1, p2) glibtop_read(glibtop_global_server, p1, p2)
extern void glibtop_read__r __P((glibtop *, size_t, void *));
extern void glibtop_read_l __P((glibtop *, size_t, void *));
extern void glibtop_read_s __P((glibtop *, size_t, void *));
__END_DECLS

View File

@@ -27,9 +27,10 @@
__BEGIN_DECLS
#define glibtop_read_data() glibtop_read_data__r(glibtop_global_server)
#define glibtop_read_data() glibtop_read_data_r(glibtop_global_server)
extern void *glibtop_read_data__r __P((glibtop *));
extern void *glibtop_read_data_l __P((glibtop *));
extern void *glibtop_read_data_s __P((glibtop *));
__END_DECLS

View File

@@ -57,9 +57,21 @@ struct _glibtop_sem_limits
semaem; /* GLIBTOP_IPC_SEMAEM */
};
#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits__r(glibtop_global_server, sem)
#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits_l(glibtop_global_server, sem)
extern void glibtop_get_sem_limits__r __P((glibtop *, glibtop_sem_limits *));
#if GLIBTOP_SUID_SEM_LIMITS
#define glibtop_get_sem_limits_r glibtop_get_sem_limits_p
#else
#define glibtop_get_sem_limits_r glibtop_get_sem_limits_s
#endif
extern void glibtop_get_sem_limits_l __P((glibtop *, glibtop_sem_limits *));
#if GLIBTOP_SUID_SEM_LIMITS
extern void glibtop_get_sem_limits_p __P((glibtop *, glibtop_sem_limits *));
#else
extern void glibtop_get_sem_limits_s __P((glibtop *, glibtop_sem_limits *));
#endif
#ifdef HAVE_GUILE
@@ -85,7 +97,7 @@ extern SCM glibtop_guile_descriptions_sem_limits __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_sem_limits [];
extern const char *glibtop_types_sem_limits [];
extern const unsigned glibtop_types_sem_limits [];
extern const char *glibtop_labels_sem_limits [];
extern const char *glibtop_descriptions_sem_limits [];

View File

@@ -47,9 +47,21 @@ struct _glibtop_shm_limits
shmall; /* GLIBTOP_IPC_SHMALL */
};
#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits__r(glibtop_global_server, shm)
#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits_l(glibtop_global_server, shm)
extern void glibtop_get_shm_limits__r __P((glibtop *, glibtop_shm_limits *));
#if GLIBTOP_SUID_SHM_LIMITS
#define glibtop_get_shm_limits_r glibtop_get_shm_limits_p
#else
#define glibtop_get_shm_limits_r glibtop_get_shm_limits_s
#endif
extern void glibtop_get_shm_limits_l __P((glibtop *, glibtop_shm_limits *));
#if GLIBTOP_SUID_SHM_LIMITS
extern void glibtop_get_shm_limits_p __P((glibtop *, glibtop_shm_limits *));
#else
extern void glibtop_get_shm_limits_s __P((glibtop *, glibtop_shm_limits *));
#endif
#ifdef HAVE_GUILE
@@ -75,7 +87,7 @@ extern SCM glibtop_guile_descriptions_shm_limits __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_shm_limits [];
extern const char *glibtop_types_shm_limits [];
extern const unsigned glibtop_types_shm_limits [];
extern const char *glibtop_labels_shm_limits [];
extern const char *glibtop_descriptions_shm_limits [];

View File

@@ -43,9 +43,21 @@ struct _glibtop_swap
free; /* GLIBTOP_SWAP_FREE */
};
#define glibtop_get_swap(swap) glibtop_get_swap__r(glibtop_global_server, swap)
#define glibtop_get_swap(swap) glibtop_get_swap_l(glibtop_global_server, swap)
extern void glibtop_get_swap__r __P((glibtop *, glibtop_swap *));
#if GLIBTOP_SUID_SWAP
#define glibtop_get_swap_r glibtop_get_swap_p
#else
#define glibtop_get_swap_r glibtop_get_swap_s
#endif
extern void glibtop_get_swap_l __P((glibtop *, glibtop_swap *));
#if GLIBTOP_SUID_SWAP
extern void glibtop_get_swap_p __P((glibtop *, glibtop_swap *));
#else
extern void glibtop_get_swap_s __P((glibtop *, glibtop_swap *));
#endif
#ifdef HAVE_GUILE
@@ -71,7 +83,7 @@ extern SCM glibtop_guile_descriptions_swap __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_swap [];
extern const char *glibtop_types_swap [];
extern const unsigned glibtop_types_swap [];
extern const char *glibtop_labels_swap [];
extern const char *glibtop_descriptions_swap [];

View File

@@ -27,30 +27,34 @@
__BEGIN_DECLS
#define GLIBTOP_SYSDEPS_CPU 0
#define GLIBTOP_SYSDEPS_MEM 1
#define GLIBTOP_SYSDEPS_SWAP 2
#define GLIBTOP_SYSDEPS_UPTIME 3
#define GLIBTOP_SYSDEPS_LOADAVG 4
#define GLIBTOP_SYSDEPS_SHM_LIMITS 5
#define GLIBTOP_SYSDEPS_MSG_LIMITS 6
#define GLIBTOP_SYSDEPS_SEM_LIMITS 7
#define GLIBTOP_SYSDEPS_PROCLIST 8
#define GLIBTOP_SYSDEPS_PROC_STATE 9
#define GLIBTOP_SYSDEPS_PROC_UID 10
#define GLIBTOP_SYSDEPS_PROC_MEM 11
#define GLIBTOP_SYSDEPS_PROC_TIME 12
#define GLIBTOP_SYSDEPS_PROC_SIGNAL 13
#define GLIBTOP_SYSDEPS_PROC_KERNEL 14
#define GLIBTOP_SYSDEPS_PROC_SEGMENT 15
#define GLIBTOP_SYSDEPS_FEATURES 0
#define GLIBTOP_SYSDEPS_CPU 1
#define GLIBTOP_SYSDEPS_MEM 2
#define GLIBTOP_SYSDEPS_SWAP 3
#define GLIBTOP_SYSDEPS_UPTIME 4
#define GLIBTOP_SYSDEPS_LOADAVG 5
#define GLIBTOP_SYSDEPS_SHM_LIMITS 6
#define GLIBTOP_SYSDEPS_MSG_LIMITS 7
#define GLIBTOP_SYSDEPS_SEM_LIMITS 8
#define GLIBTOP_SYSDEPS_PROCLIST 9
#define GLIBTOP_SYSDEPS_PROC_STATE 10
#define GLIBTOP_SYSDEPS_PROC_UID 11
#define GLIBTOP_SYSDEPS_PROC_MEM 12
#define GLIBTOP_SYSDEPS_PROC_TIME 13
#define GLIBTOP_SYSDEPS_PROC_SIGNAL 14
#define GLIBTOP_SYSDEPS_PROC_KERNEL 15
#define GLIBTOP_SYSDEPS_PROC_SEGMENT 16
#define GLIBTOP_MAX_SYSDEPS 16
#define GLIBTOP_MAX_SYSDEPS 17
#define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1)
typedef struct _glibtop_sysdeps glibtop_sysdeps;
struct _glibtop_sysdeps
{
unsigned long flags,
features, /* server features */
cpu, /* glibtop_cpu */
mem, /* glibtop_mem */
swap, /* glibtop_swap */
@@ -69,9 +73,9 @@ struct _glibtop_sysdeps
proc_segment; /* glibtop_proc_segment */
};
#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps__r(glibtop_global_server,sysdeps)
#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps_r(glibtop_global_server,sysdeps)
extern void glibtop_get_sysdeps__r __P((glibtop *, glibtop_sysdeps *));
extern void glibtop_get_sysdeps_r __P((glibtop *, glibtop_sysdeps *));
#ifdef HAVE_GUILE
@@ -97,7 +101,7 @@ extern SCM glibtop_guile_descriptions_sysdeps __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_sysdeps [];
extern const char *glibtop_types_sysdeps [];
extern const unsigned glibtop_types_sysdeps [];
extern const char *glibtop_labels_sysdeps [];
extern const char *glibtop_descriptions_sysdeps [];

View File

@@ -19,14 +19,18 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop/sysdeps.h>
#include <glibtop/command.h>
#ifndef __GLIBTOP_TYPES_H__
#define __GLIBTOP_TYPES_H__
/* Checks which features are implemented. */
__BEGIN_DECLS
void
glibtop_get_sysdeps__r (glibtop *server, glibtop_sysdeps *buf)
{
glibtop_init__r (&server);
glibtop_call__r (server, GLIBTOP_CMND_SYSDEPS, 0, NULL, sizeof (glibtop_sysdeps), buf);
}
#define GLIBTOP_TYPE_LONG 1
#define GLIBTOP_TYPE_ULONG 2
#define GLIBTOP_TYPE_DOUBLE 3
#define GLIBTOP_TYPE_INT 4
#define GLIBTOP_TYPE_CHAR 5
#define GLIBTOP_TYPE_STRING 6
__END_DECLS
#endif

View File

@@ -41,9 +41,21 @@ struct _glibtop_uptime
idletime; /* GLIBTOP_UPTIME_IDLETIME */
};
#define glibtop_get_uptime(uptime) glibtop_get_uptime__r(glibtop_global_server, uptime)
#define glibtop_get_uptime(uptime) glibtop_get_uptime_l(glibtop_global_server, uptime)
extern void glibtop_get_uptime__r __P((glibtop *, glibtop_uptime *));
#if GLIBTOP_SUID_UPTIME
#define glibtop_get_uptime_r glibtop_get_uptime_p
#else
#define glibtop_get_uptime_r glibtop_get_uptime_s
#endif
extern void glibtop_get_uptime_l __P((glibtop *, glibtop_uptime *));
#if GLIBTOP_SUID_UPTIME
extern void glibtop_get_uptime_p __P((glibtop *, glibtop_uptime *));
#else
extern void glibtop_get_uptime_s __P((glibtop *, glibtop_uptime *));
#endif
#ifdef HAVE_GUILE
@@ -69,7 +81,7 @@ extern SCM glibtop_guile_descriptions_uptime __P((void));
/* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_uptime [];
extern const char *glibtop_types_uptime [];
extern const unsigned glibtop_types_uptime [];
extern const char *glibtop_labels_uptime [];
extern const char *glibtop_descriptions_uptime [];

View File

@@ -29,7 +29,8 @@ __BEGIN_DECLS
#define glibtop_write(p1, p2) glibtop_write(glibtop_global_server, p1, p2)
extern void glibtop_write__r __P((glibtop *, size_t, void *));
extern void glibtop_write_l __P((glibtop *, size_t, void *));
extern void glibtop_write_s __P((glibtop *, size_t, void *));
__END_DECLS

View File

@@ -27,15 +27,15 @@
__BEGIN_DECLS
#define glibtop_malloc(p1) glibtop_malloc__r(glibtop_global_server, p1)
#define glibtop_calloc(p1, p2) glibtop_calloc__r(glibtop_global_server, p1, p2)
#define glibtop_realloc(p1, p2) glibtop_realloc__r(glibtop_global_server, p1, p2)
#define glibtop_free(p1) glibtop_free__r(glibtop_global_server, p1)
#define glibtop_malloc(p1) glibtop_malloc_r(glibtop_global_server, p1)
#define glibtop_calloc(p1, p2) glibtop_calloc_r(glibtop_global_server, p1, p2)
#define glibtop_realloc(p1, p2) glibtop_realloc_r(glibtop_global_server, p1, p2)
#define glibtop_free(p1) glibtop_free_r(glibtop_global_server, p1)
extern void *glibtop_malloc__r __P((glibtop *, size_t));
extern void *glibtop_calloc__r __P((glibtop *, size_t, size_t));
extern void *glibtop_realloc__r __P((glibtop *, void *, size_t));
extern void glibtop_free__r __P((glibtop *, void *));
extern void *glibtop_malloc_r __P((glibtop *, size_t));
extern void *glibtop_calloc_r __P((glibtop *, size_t, size_t));
extern void *glibtop_realloc_r __P((glibtop *, void *, size_t));
extern void glibtop_free_r __P((glibtop *, void *));
__END_DECLS

6
kernel/ChangeLog Normal file
View File

@@ -0,0 +1,6 @@
1998-06-14 Martin Baulig <baulig@taurus.uni-trier.de>
* README: Added README.
* kernel.patch: Patch for the Linux kernel to add the
new system call.

13
kernel/Makefile Normal file
View File

@@ -0,0 +1,13 @@
#
# Makefile for the linux system information tables.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#
# Note 2! The CFLAGS definition is now in the main makefile...
O_TARGET := table.o
O_OBJS := main.o
include $(TOPDIR)/Rules.make

21
kernel/README Normal file
View File

@@ -0,0 +1,21 @@
This is a new system call `table ()' for the Linux table. It is faster
than reading from /proc and can be used to fetch all information required
for libgtop until whe have some other function (extended sysctl, ...) in
standard kernels.
I didn't want to change sysctl or some other function myself cause this may
cause other applications relying upon those function to fail. This is
something for the ``real'' kernel gurus ...
To use this new system call for libgtop, do the following:
* Copy this directory to /usr/src/linux/table
* Make /usr/src/linux/include/linux/table.h symlink to /usr/src/linux/table/table.h
* Apply the patch `kernel.patch' to the kernel, compile, install and reboot
* Recompile libgtop (remove `config.cache' and run the `autogen.sh' again).
If you want to change and/or add something - feel free to do so !
Have fun,
Martin

49
kernel/kernel.patch Normal file
View File

@@ -0,0 +1,49 @@
diff -ur linux-2.0.32/Makefile linux-hacked/Makefile
--- linux-2.0.32/Makefile Fri Nov 7 19:51:05 1997
+++ linux-hacked/Makefile Thu Jun 11 20:41:12 1998
@@ -87,7 +87,7 @@
# standard CFLAGS
#
-CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strength-reduce
+CFLAGS = -Wall -Wstrict-prototypes -g -O2 -fomit-frame-pointer -fno-strength-reduce
ifdef CONFIG_CPP
CFLAGS := $(CFLAGS) -x c++
@@ -113,12 +113,12 @@
# Include the make variables (CC, etc...)
#
-ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o net/network.a
+ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o net/network.a table/table.o
FILESYSTEMS =fs/filesystems.a
DRIVERS =drivers/block/block.a \
drivers/char/char.a
LIBS =$(TOPDIR)/lib/lib.a
-SUBDIRS =kernel drivers mm fs net ipc lib
+SUBDIRS =kernel drivers mm fs net ipc lib table
ifeq ($(CONFIG_ISDN),y)
DRIVERS := $(DRIVERS) drivers/isdn/isdn.a
diff -ur linux-2.0.32/arch/i386/kernel/entry.S linux-hacked/arch/i386/kernel/entry.S
--- linux-2.0.32/arch/i386/kernel/entry.S Tue Sep 16 23:42:45 1997
+++ linux-hacked/arch/i386/kernel/entry.S Thu Jun 11 21:37:20 1998
@@ -699,4 +699,6 @@
.long SYMBOL_NAME(sys_mremap)
.long 0,0
.long SYMBOL_NAME(sys_vm86)
- .space (NR_syscalls-166)*4
+ .long 0
+ .long SYMBOL_NAME(sys_table)
+ .space (NR_syscalls-168)*4
diff -ur linux-2.0.32/include/asm-i386/unistd.h linux-hacked/include/asm-i386/unistd.h
--- linux-2.0.32/include/asm-i386/unistd.h Fri Mar 22 07:34:02 1996
+++ linux-hacked/include/asm-i386/unistd.h Thu Jun 11 21:37:03 1998
@@ -169,6 +169,7 @@
#define __NR_sched_rr_get_interval 161
#define __NR_nanosleep 162
#define __NR_mremap 163
+#define __NR_table 168
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
#define _syscall0(type,name) \

423
kernel/main.c Normal file
View File

@@ -0,0 +1,423 @@
/*
* linux/table/table_impl.c
* Copyright (C) 1998 Martin Baulig
*/
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/kernel_stat.h>
#include <linux/tty.h>
#include <linux/user.h>
#include <linux/a.out.h>
#include <linux/string.h>
#include <linux/mman.h>
#include <linux/proc_fs.h>
#include <linux/ioport.h>
#include <linux/config.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/swap.h>
#include <asm/segment.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <linux/table.h>
#include "version.h"
#if defined(__i386__)
# define KSTK_EIP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1019])
# define KSTK_ESP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1022])
#elif defined(__alpha__)
/*
* See arch/alpha/kernel/ptrace.c for details.
*/
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
+ (long)&((struct pt_regs *)0)->reg)
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
# define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->tss.usp)
#elif defined(__sparc__)
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
+ (long)&((struct pt_regs *)0)->reg)
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
# define KSTK_ESP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(u_regs[UREG_FP])))
#endif
static struct task_struct *
get_task (pid_t pid)
{
struct task_struct ** p;
p = task;
while (++p < task+NR_TASKS) {
if (*p && (*p)->pid == pid)
return *p;
}
return NULL;
}
static inline void statm_pte_range(pmd_t * pmd, unsigned long address, unsigned long size,
int * pages, int * shared, int * dirty, int * total)
{
pte_t * pte;
unsigned long end;
if (pmd_none(*pmd))
return;
if (pmd_bad(*pmd)) {
printk("statm_pte_range: bad pmd (%08lx)\n", pmd_val(*pmd));
pmd_clear(pmd);
return;
}
pte = pte_offset(pmd, address);
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
pte_t page = *pte;
address += PAGE_SIZE;
pte++;
if (pte_none(page))
continue;
++*total;
if (!pte_present(page))
continue;
++*pages;
if (pte_dirty(page))
++*dirty;
if (pte_page(page) >= high_memory)
continue;
if (mem_map[MAP_NR(pte_page(page))].count > 1)
++*shared;
} while (address < end);
}
static inline void statm_pmd_range(pgd_t * pgd, unsigned long address, unsigned long size,
int * pages, int * shared, int * dirty, int * total)
{
pmd_t * pmd;
unsigned long end;
if (pgd_none(*pgd))
return;
if (pgd_bad(*pgd)) {
printk("statm_pmd_range: bad pgd (%08lx)\n", pgd_val(*pgd));
pgd_clear(pgd);
return;
}
pmd = pmd_offset(pgd, address);
address &= ~PGDIR_MASK;
end = address + size;
if (end > PGDIR_SIZE)
end = PGDIR_SIZE;
do {
statm_pte_range(pmd, address, end - address, pages, shared, dirty, total);
address = (address + PMD_SIZE) & PMD_MASK;
pmd++;
} while (address < end);
}
static void statm_pgd_range(pgd_t * pgd, unsigned long address, unsigned long end,
int * pages, int * shared, int * dirty, int * total)
{
while (address < end) {
statm_pmd_range(pgd, address, end - address, pages, shared, dirty, total);
address = (address + PGDIR_SIZE) & PGDIR_MASK;
pgd++;
}
}
static unsigned long
get_wchan (struct task_struct *p)
{
if (!p || p == current || p->state == TASK_RUNNING)
return 0;
#if defined(__i386__)
{
unsigned long ebp, eip;
unsigned long stack_page;
int count = 0;
stack_page = p->kernel_stack_page;
if (!stack_page)
return 0;
ebp = p->tss.ebp;
do {
if (ebp < stack_page || ebp >= 4092+stack_page)
return 0;
eip = *(unsigned long *) (ebp+4);
if (eip < (unsigned long) interruptible_sleep_on
|| eip >= (unsigned long) add_timer)
return eip;
ebp = *(unsigned long *) ebp;
} while (count++ < 16);
}
#elif defined(__alpha__)
/*
* This one depends on the frame size of schedule(). Do a
* "disass schedule" in gdb to find the frame size. Also, the
* code assumes that sleep_on() follows immediately after
* interruptible_sleep_on() and that add_timer() follows
* immediately after interruptible_sleep(). Ugly, isn't it?
* Maybe adding a wchan field to task_struct would be better,
* after all...
*/
{
unsigned long schedule_frame;
unsigned long pc;
pc = thread_saved_pc(&p->tss);
if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) {
schedule_frame = ((unsigned long *)p->tss.ksp)[6];
return ((unsigned long *)schedule_frame)[12];
}
return pc;
}
#endif
return 0;
}
asmlinkage int
sys_table (int type, union table *buf, const void *param)
{
union table tbl;
struct sysinfo i;
struct task_struct *tsk = NULL;
pid_t pid;
int err;
if (type == TABLE_VERSION)
return _TABLE_VERSION;
if (!buf)
return -EFAULT;
memset (&tbl, 0, sizeof (union table));
/* For TABLE_PROC_*, read pid and get task_struct */
switch (type) {
case TABLE_PROC_UID:
case TABLE_PROC_MEM:
case TABLE_PROC_SEGMENT:
case TABLE_PROC_TIME:
case TABLE_PROC_STATE:
case TABLE_PROC_SIGNAL:
case TABLE_PROC_KERNEL:
err = verify_area (VERIFY_READ, param, sizeof (pid_t));
if (err)
return err;
memcpy_fromfs (&pid, param, sizeof (pid_t));
tsk = get_task (pid);
if (tsk == NULL)
return -ESRCH;
break;
}
/* Main function dispatcher */
switch (type) {
case TABLE_CPU:
tbl.cpu.total = jiffies;
tbl.cpu.user = kstat.cpu_user;
tbl.cpu.nice = kstat.cpu_nice;
tbl.cpu.sys = kstat.cpu_system;
tbl.cpu.idle = tbl.cpu.total - (tbl.cpu.user + tbl.cpu.nice + tbl.cpu.sys);
tbl.cpu.frequency = HZ;
break;
case TABLE_MEM:
si_meminfo (&i);
tbl.mem.total = i.totalram;
tbl.mem.used = i.totalram - i.freeram;
tbl.mem.free = i.freeram;
tbl.mem.shared = i.sharedram;
tbl.mem.buffer = i.bufferram;
tbl.mem.cached = page_cache_size << PAGE_SHIFT;
break;
case TABLE_SWAP:
si_swapinfo (&i);
tbl.swap.total = i.totalswap;
tbl.swap.used = i.totalswap - i.freeswap;
tbl.swap.free = i.freeswap;
break;
case TABLE_LOADAVG:
tbl.loadavg.loadavg [0] = (double) avenrun [0] / (1 << FSHIFT);
tbl.loadavg.loadavg [1] = (double) avenrun [1] / (1 << FSHIFT);
tbl.loadavg.loadavg [2] = (double) avenrun [2] / (1 << FSHIFT);
tbl.loadavg.nr_running = nr_running;
tbl.loadavg.nr_tasks = nr_tasks;
tbl.loadavg.last_pid = last_pid;
break;
case TABLE_UPTIME:
tbl.uptime.uptime = jiffies;
tbl.uptime.idle = task[0]->utime + task[0]->stime;
break;
case TABLE_PROC_STATE:
tbl.proc_state.state = tsk->state;
tbl.proc_state.flags = tsk->flags;
memcpy (tbl.proc_state.comm, tsk->comm, sizeof (tbl.proc_state.comm));
break;
case TABLE_PROC_UID:
tbl.proc_uid.uid = tsk->uid;
tbl.proc_uid.euid = tsk->euid;
tbl.proc_uid.suid = tsk->suid;
tbl.proc_uid.fsuid = tsk->fsuid;
tbl.proc_uid.gid = tsk->gid;
tbl.proc_uid.egid = tsk->egid;
tbl.proc_uid.sgid = tsk->sgid;
tbl.proc_uid.fsgid = tsk->fsgid;
tbl.proc_uid.pid = tsk->pid;
tbl.proc_uid.pgrp = tsk->pgrp;
tbl.proc_uid.ppid = tsk->p_pptr->pid;
tbl.proc_uid.session = tsk->session;
tbl.proc_uid.tty = tsk->tty ? kdev_t_to_nr (tsk->tty->device) : 0;
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
tbl.proc_uid.priority = tsk->priority;
tbl.proc_uid.counter = tsk->counter;
tbl.proc_uid.def_priority = DEF_PRIORITY;
break;
case TABLE_PROC_SIGNAL:
tbl.proc_signal.signal = tsk->signal;
tbl.proc_signal.blocked = tsk->blocked;
if (tsk->sig) {
struct sigaction * action = tsk->sig->action;
unsigned long sig_ign = 0, sig_caught = 0;
unsigned long bit = 1;
int i;
for (i = 0; i < 32; i++) {
switch((unsigned long) action->sa_handler) {
case 0:
break;
case 1:
sig_ign |= bit;
break;
default:
sig_caught |= bit;
}
bit <<= 1;
action++;
}
tbl.proc_signal.ignored = sig_ign;
tbl.proc_signal.caught = sig_caught;
} else {
tbl.proc_signal.ignored = 0;
tbl.proc_signal.caught = 0;
}
break;
case TABLE_PROC_MEM:
if (tsk->mm && tsk->mm != &init_mm) {
tbl.proc_mem.context = tsk->mm->context;
tbl.proc_mem.start_code = tsk->mm->start_code;
tbl.proc_mem.end_code = tsk->mm->end_code;
tbl.proc_mem.start_data = tsk->mm-> start_data;
tbl.proc_mem.end_data = tsk->mm->end_data;
tbl.proc_mem.start_brk = tsk->mm->start_brk;
tbl.proc_mem.brk = tsk->mm->brk;
tbl.proc_mem.start_stack = tsk->mm->start_stack;
tbl.proc_mem.start_mmap = tsk->mm->start_mmap;
tbl.proc_mem.arg_start = tsk->mm->arg_start;
tbl.proc_mem.arg_end = tsk->mm->arg_end;
tbl.proc_mem.env_start = tsk->mm->env_start;
tbl.proc_mem.env_end = tsk->mm->env_end;
tbl.proc_mem.rss = tsk->mm->rss;
tbl.proc_mem.total_vm = tsk->mm->total_vm;
tbl.proc_mem.locked_vm = tsk->mm->locked_vm;
}
tbl.proc_mem.rlim = tsk->rlim ? tsk->rlim[RLIMIT_RSS].rlim_cur : 0;
break;
case TABLE_PROC_SEGMENT:
if (tsk->mm && tsk->mm != &init_mm) {
unsigned long vsize = 0;
int size = 0, resident = 0, share = 0;
int trs = 0, lrs = 0, drs = 0, dt = 0;
struct vm_area_struct * vma = tsk->mm->mmap;
while (vma) {
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
int pages = 0, shared = 0, dirty = 0, total = 0;
vsize += vma->vm_end - vma->vm_start;
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
&pages, &shared, &dirty, &total);
resident += pages;
share += shared;
dt += dirty;
size += total;
if (vma->vm_flags & VM_EXECUTABLE)
trs += pages; /* text */
else if (vma->vm_flags & VM_GROWSDOWN)
drs += pages; /* stack */
else if (vma->vm_end > 0x60000000)
lrs += pages; /* library */
else
drs += pages;
vma = vma->vm_next;
}
tbl.proc_segment.vsize = vsize;
tbl.proc_segment.size = size;
tbl.proc_segment.resident = resident;
tbl.proc_segment.shared = share;
tbl.proc_segment.trs = trs;
tbl.proc_segment.lrs = lrs;
tbl.proc_segment.dt = dt;
}
break;
case TABLE_PROC_TIME:
tbl.proc_time.utime = tsk->utime;
tbl.proc_time.stime = tsk->stime;
tbl.proc_time.cutime = tsk->cutime;
tbl.proc_time.cstime = tsk->cstime;
tbl.proc_time.start_time = tsk->start_time;
tbl.proc_time.timeout = tsk->timeout;
tbl.proc_time.policy = tsk->policy;
tbl.proc_time.rt_priority = tsk->rt_priority;
tbl.proc_time.it_real_value = tsk->it_real_value;
tbl.proc_time.it_prof_value = tsk->it_prof_value;
tbl.proc_time.it_virt_value = tsk->it_virt_value;
tbl.proc_time.it_real_incr = tsk->it_real_incr;
tbl.proc_time.it_prof_incr = tsk->it_prof_incr;
tbl.proc_time.it_virt_incr = tsk->it_virt_incr;
break;
case TABLE_PROC_KERNEL:
tbl.proc_kernel.min_flt = tsk->min_flt;
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
tbl.proc_kernel.maj_flt = tsk->maj_flt;
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
tbl.proc_kernel.kesp = tsk->kernel_stack_page ? KSTK_EIP(tsk) : 0;
tbl.proc_kernel.keip = tsk->kernel_stack_page ? KSTK_ESP(tsk) : 0;
tbl.proc_kernel.nswap = tsk->nswap;
tbl.proc_kernel.cnswap = tsk->cnswap;
tbl.proc_kernel.wchan = get_wchan (tsk);
break;
default:
return -EINVAL;
}
err = verify_area (VERIFY_WRITE, buf, sizeof (struct table));
if (err)
return err;
memcpy_tofs (buf, &tbl, sizeof (union table));
return 0;
}

154
kernel/table.h Normal file
View File

@@ -0,0 +1,154 @@
#ifndef _LINUX_TABLE_H
#define _LINUX_TABLE_H
#ifdef _KERNEL
#include <linux/types.h>
#endif
#define TABLE_VERSION 0
#define TABLE_CPU 1
#define TABLE_MEM 2
#define TABLE_SWAP 3
#define TABLE_LOADAVG 4
#define TABLE_UPTIME 5
#define TABLE_PROC_UID 6
#define TABLE_PROC_MEM 7
#define TABLE_PROC_SEGMENT 8
#define TABLE_PROC_TIME 9
#define TABLE_PROC_STATE 10
#define TABLE_PROC_SIGNAL 11
#define TABLE_PROC_KERNEL 12
/* CPU Usage (in jiffies = 1/100th seconds) */
struct table_cpu
{
unsigned long total; /* Total CPU Time */
unsigned long user; /* CPU Time in User Mode */
unsigned long nice; /* CPU Time in User Mode (nice) */
unsigned long sys; /* CPU Time in System Mode */
unsigned long idle; /* CPU Time in the Idle Task */
unsigned long frequency; /* Tick frequency */
};
/* Memory Usage (in bytes) */
struct table_mem
{
unsigned long total; /* Total physical memory */
unsigned long used; /* Used memory size */
unsigned long free; /* Free memory size */
unsigned long shared; /* Shared memory size */
unsigned long buffer; /* Size of buffers */
unsigned long cached; /* Size of cached memory */
};
/* Swap Space (in bytes) */
struct table_swap
{
unsigned long total; /* Total swap space */
unsigned long used; /* Used swap space */
unsigned long free; /* Free swap space */
};
/* Load average */
struct table_loadavg
{
double loadavg [3];
unsigned nr_running;
unsigned nr_tasks;
unsigned last_pid;
};
/* Uptime */
struct table_uptime
{
unsigned long uptime;
unsigned long idle;
};
/* Information about processes. */
struct table_proc_state
{
long state;
unsigned long flags;
char comm[16];
};
struct table_proc_uid
{
int uid, euid, suid, fsuid;
int gid, egid, sgid, fsgid;
int pid, pgrp, ppid;
int session;
unsigned int tty;
int tpgid;
long priority;
long counter;
long def_priority;
};
struct table_proc_mem
{
unsigned long context;
unsigned long start_code, end_code, start_data, end_data;
unsigned long start_brk, brk, start_stack, start_mmap;
unsigned long arg_start, arg_end, env_start, env_end;
unsigned long rss, rlim, total_vm, locked_vm;
};
struct table_proc_segment
{
unsigned long vsize;
int size, resident, shared;
int trs, lrs, drs, dt;
};
struct table_proc_time
{
long utime, stime, cutime, cstime, start_time;
unsigned long timeout, policy, rt_priority;
unsigned long it_real_value, it_prof_value, it_virt_value;
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
};
struct table_proc_signal
{
unsigned long signal;
unsigned long blocked; /* bitmap of masked signals */
unsigned long ignored; /* mask of ignored signals */
unsigned long caught; /* mask of caught signals */
};
struct table_proc_kernel
{
unsigned long keip, kesp, wchan;
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
unsigned long nswap, cnswap;
};
/* Union */
union table
{
struct table_cpu cpu;
struct table_mem mem;
struct table_swap swap;
struct table_loadavg loadavg;
struct table_uptime uptime;
struct table_proc_uid proc_uid;
struct table_proc_mem proc_mem;
struct table_proc_segment proc_segment;
struct table_proc_time proc_time;
struct table_proc_state proc_state;
struct table_proc_signal proc_signal;
struct table_proc_kernel proc_kernel;
};
#endif /* _LINUX_IPC_H */

85
kernel/test.c Normal file
View File

@@ -0,0 +1,85 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/unistd.h>
#include <linux/table.h>
#include <syscall.h>
static inline _syscall3 (int, table, int, type, union table *, tbl, const void *, param);
int
main (void)
{
union table tbl;
unsigned count;
int ret;
ret = table (TABLE_VERSION, NULL, NULL);
if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_VERSION, sys_errlist [errno]);
exit (-errno);
}
fprintf (stderr, "Table (%u) = %u\n", TABLE_VERSION, ret);
for (count = 0; count < 5; count++) {
ret = table (TABLE_CPU, &tbl, NULL);
if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_CPU, sys_errlist [errno]);
exit (-errno);
}
fprintf (stderr, "Table (%u) = %lu, %lu, %lu, %lu, %lu, %lu\n",
TABLE_CPU, tbl.cpu.total, tbl.cpu.user, tbl.cpu.nice,
tbl.cpu.sys, tbl.cpu.idle, tbl.cpu.frequency);
}
ret = table (TABLE_MEM, &tbl, NULL);
if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_MEM, sys_errlist [errno]);
exit (-errno);
}
fprintf (stderr, "Table (%u) = %lu, %lu, %lu, %lu, %lu, %lu\n",
TABLE_MEM, tbl.mem.total, tbl.mem.used, tbl.mem.free,
tbl.mem.shared, tbl.mem.buffer, tbl.mem.cached);
ret = table (TABLE_SWAP, &tbl, NULL);
if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_SWAP, sys_errlist [errno]);
exit (-errno);
}
fprintf (stderr, "Table (%u) = %lu, %lu, %lu\n",
TABLE_SWAP, tbl.swap.total, tbl.swap.used, tbl.swap.free);
ret = table (TABLE_LOADAVG, &tbl, NULL);
if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_LOADAVG, sys_errlist [errno]);
exit (-errno);
}
fprintf (stderr, "Table (%u) = (%lu, %lu, %lu) - %u, %u, %u\n",
TABLE_LOADAVG, tbl.loadavg.loadavg [0], tbl.loadavg.loadavg [1],
tbl.loadavg.loadavg [2], tbl.loadavg.nr_running,
tbl.loadavg.nr_tasks, tbl.loadavg.last_pid);
ret = table (TABLE_UPTIME, &tbl, NULL);
if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_UPTIME, sys_errlist [errno]);
exit (-errno);
}
fprintf (stderr, "Table (%u) = %lu, %lu\n",
TABLE_UPTIME, tbl.uptime.uptime, tbl.uptime.idle);
exit (0);
}

1
kernel/version.h Normal file
View File

@@ -0,0 +1 @@
#define _TABLE_VERSION 1

View File

@@ -32,3 +32,4 @@ sysinfo.lo
uptime.lo
write.lo
xmalloc.lo
lib.c

View File

@@ -8,10 +8,14 @@ CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\"
lib_LTLIBRARIES = libgtop.la
libgtop_la_SOURCES = init.c open.c close.c read.c read_data.c \
write.c command.c cpu.c mem.c swap.c uptime.c \
loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c
libgtop_la_SOURCES = init.c open.c close.c command.c read.c read_data.c write.c lib.c
BUILT_SOURCES = lib.c
lib.c: lib.awk $(top_builddir)/config.h $(top_builddir)/features.def
$(AWK) -f $(srcdir)/lib.awk < $(top_builddir)/features.def > lib-t
mv lib-t lib.c
EXTRA_DIST = lib.awk
CLEANFILES = lib.c

View File

@@ -24,7 +24,7 @@
/* Closes pipe to gtop server. */
void
glibtop_close (glibtop *server)
glibtop_close_r (glibtop *server)
{
kill (server->pid, SIGKILL);
close (server->input [0]);

View File

@@ -27,28 +27,28 @@
#include <glibtop/xmalloc.h>
void *
glibtop_call__r (glibtop *server, unsigned command, size_t send_size, void *send_buf,
glibtop_call_l (glibtop *server, unsigned command, size_t send_size, void *send_buf,
size_t recv_size, void *recv_buf)
{
glibtop_command *cmnd;
void *ptr;
glibtop_init__r (&server);
glibtop_init_r (&server, 0, 0);
cmnd = glibtop_calloc__r (server, 1, sizeof (glibtop_command));
cmnd = glibtop_calloc_r (server, 1, sizeof (glibtop_command));
memcpy (&cmnd->server, server, sizeof (glibtop));
cmnd->command = command;
cmnd->size = send_size;
glibtop_write__r (server, sizeof (glibtop_command), cmnd);
glibtop_write__r (server, send_size, send_buf);
glibtop_read__r (server, recv_size, recv_buf);
glibtop_write_l (server, sizeof (glibtop_command), cmnd);
glibtop_write_l (server, send_size, send_buf);
glibtop_read_l (server, recv_size, recv_buf);
ptr = glibtop_read_data__r (server);
ptr = glibtop_read_data_l (server);
glibtop_free__r (server, cmnd);
glibtop_free_r (server, cmnd);
return ptr;
}

620
lib/gnuclient.c Normal file
View File

@@ -0,0 +1,620 @@
/* -*-C-*-
Client code to allow local and remote editing of files by XEmacs.
Copyright (C) 1989 Free Software Foundation, Inc.
Copyright (C) 1995 Sun Microsystems, Inc.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of XEmacs.
XEmacs is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
XEmacs 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with XEmacs; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
Please mail bugs and suggestions to the author at the above address.
*/
/*
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
* GNUATTACH support added by Ben Wing <wing@xemacs.org>.
* Please see the note at the end of the README file for details.
*
* (If gnuserv came bundled with your emacs, the README file is probably
* ../etc/gnuserv.README relative to the directory containing this file)
*/
#if 0
/* Hand-munged RCS header */
static char rcsid [] = "!Header: gnuclient.c,v 2.2 95/12/12 01:39:21 wing nene !";
#endif
#include "gnuserv.h"
#include "getopt.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <signal.h>
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
!defined(INTERNET_DOMAIN_SOCKETS)
int
main (int argc, char *argv[])
{
fprintf (stderr, "Sorry, the Emacs server is only "
"supported on systems that have\n");
fprintf (stderr, "Unix Domain sockets, Internet Domain "
"sockets or System V IPC.\n");
exit (1);
} /* main */
#else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
static char cwd[MAXPATHLEN+2]; /* current working directory when calculated */
static char *cp = NULL; /* ptr into valid bit of cwd above */
static pid_t emacs_pid; /* Process id for emacs process */
void initialize_signals (void);
static void
tell_emacs_to_resume (int sig)
{
char buffer[GSERV_BUFSZ+1];
int s; /* socket / msqid to server */
int connect_type; /* CONN_UNIX, CONN_INTERNET, or
ONN_IPC */
/* Why is SYSV so retarded? */
/* We want emacs to realize that we are resuming */
signal(SIGCONT, tell_emacs_to_resume);
connect_type = make_connection (NULL, (u_short) 0, &s);
sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid());
send_string(s, buffer);
#ifdef SYSV_IPC
if (connect_type == (int) CONN_IPC)
disconnect_from_ipc_server (s, msgp, FALSE);
#else /* !SYSV_IPC */
if (connect_type != (int) CONN_IPC)
disconnect_from_server (s, FALSE);
#endif /* !SYSV_IPC */
}
static void
pass_signal_to_emacs (int sig)
{
if (kill (emacs_pid, sig) == -1)
{
fprintf (stderr, "gnuattach: Could not pass signal to emacs process\n");
exit (1);
}
initialize_signals ();
}
void
initialize_signals ()
{
/* Set up signal handler to pass relevant signals to emacs process.
We used to send SIGSEGV, SIGBUS, SIGPIPE, SIGILL and others to
Emacs, but I think it's better not to. I can see no reason why
Emacs should SIGSEGV whenever gnuclient SIGSEGV-s, etc. */
signal (SIGHUP, pass_signal_to_emacs);
signal (SIGQUIT, pass_signal_to_emacs);
signal (SIGINT, pass_signal_to_emacs);
#ifdef SIGWINCH
signal (SIGWINCH, pass_signal_to_emacs);
#endif
/* We want emacs to realize that we are resuming */
signal (SIGCONT, tell_emacs_to_resume);
}
/*
get_current_working_directory -- return the cwd.
*/
static char *
get_current_working_directory (void)
{
if (cp == NULL)
{ /* haven't calculated it yet */
#ifdef BSD
if (getwd (cwd) == 0)
#else /* !BSD */
if (getcwd (cwd,MAXPATHLEN) == NULL)
#endif /* !BSD */
{
perror (progname);
fprintf (stderr, "%s: unable to get current working directory\n",
progname);
exit (1);
} /* if */
/* on some systems, cwd can look like '@machine/' ... */
/* ignore everything before the first '/' */
for (cp = cwd; *cp && *cp != '/'; ++cp)
;
} /* if */
return cp;
} /* get_current_working_directory */
/*
filename_expand -- try to convert the given filename into a fully-qualified
pathname.
*/
static void
filename_expand (char *fullpath, char *filename)
/* fullpath - returned full pathname */
/* filename - filename to expand */
{
int len;
fullpath[0] = '\0';
if (filename[0] && filename[0] != '/')
{ /* relative filename */
strcat (fullpath, get_current_working_directory ());
len = strlen (fullpath);
if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
; /* yep */
else
strcat (fullpath, "/"); /* nope, append trailing slash */
} /* if */
strcat (fullpath,filename);
} /* filename_expand */
/* Encase the string in quotes, escape all the backslashes and quotes
in string. */
static char *
clean_string (CONST char *s)
{
int i = 0;
char *p, *res;
for (p = s; *p; p++, i++)
{
if (*p == '\\' || *p == '\"')
++i;
else if (*p == '\004')
i += 3;
}
p = res = (char *)malloc (i + 2 + 1);
*p++ = '\"';
for (; *s; p++, s++)
{
switch (*s)
{
case '\\':
*p++ = '\\';
*p = '\\';
break;
case '\"':
*p++ = '\\';
*p = '\"';
break;
case '\004':
*p++ = '\\';
*p++ = 'C';
*p++ = '-';
*p = 'd';
break;
default:
*p = *s;
}
}
*p++ = '\"';
*p = '\0';
return res;
}
#define GET_ARGUMENT(var, desc) do { \
if (*(p + 1)) (var) = p + 1; \
else \
{ \
if (!argv[++i]) \
{ \
fprintf (stderr, "%s: `%s' must be followed by an argument\n", \
progname, desc); \
exit (1); \
} \
(var) = argv[i]; \
} \
over = 1; \
} while (0)
/* A strdup immitation. */
static char *
my_strdup (CONST char *s)
{
char *new = malloc (strlen (s) + 1);
if (new)
strcpy (new, s);
return new;
}
int
main (int argc, char *argv[])
{
int starting_line = 1; /* line to start editing at */
char command[MAXPATHLEN+50]; /* emacs command buffer */
char fullpath[MAXPATHLEN+1]; /* full pathname to file */
char *eval_form = NULL; /* form to evaluate with `-eval' */
char *eval_function = NULL; /* function to evaluate with `-f' */
char *load_library = NULL; /* library to load */
int quick = 0; /* quick edit, don't wait for user to
finish */
int batch = 0; /* batch mode */
int view = 0; /* view only. */
int nofiles = 0;
int errflg = 0; /* option error */
int s; /* socket / msqid to server */
int connect_type; /* CONN_UNIX, CONN_INTERNET, or
* CONN_IPC */
int suppress_windows_system = 0;
char *display = NULL;
#ifdef INTERNET_DOMAIN_SOCKETS
char *hostarg = NULL; /* remote hostname */
char *remotearg;
char thishost[HOSTNAMSZ]; /* this hostname */
char remotepath[MAXPATHLEN+1]; /* remote pathname */
char *path;
int rflg = 0; /* pathname given on cmdline */
char *portarg;
u_short port = 0; /* port to server */
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef SYSV_IPC
struct msgbuf *msgp; /* message */
#endif /* SYSV_IPC */
char *tty = NULL;
char buffer[GSERV_BUFSZ + 1]; /* buffer to read pid */
char result[GSERV_BUFSZ + 1];
int i;
#ifdef INTERNET_DOMAIN_SOCKETS
memset (remotepath, 0, sizeof (remotepath));
#endif /* INTERNET_DOMAIN_SOCKETS */
progname = strrchr (argv[0], '/');
if (progname)
++progname;
else
progname = argv[0];
display = getenv ("DISPLAY");
if (!display)
suppress_windows_system = 1;
else
display = my_strdup (display);
for (i = 1; argv[i] && !errflg; i++)
{
if (*argv[i] != '-')
break;
else if (*argv[i] == '-'
&& (*(argv[i] + 1) == '\0'
|| (*(argv[i] + 1) == '-' && *(argv[i] + 2) == '\0')))
{
/* `-' or `--' */
++i;
break;
}
if (!strcmp (argv[i], "-batch") || !strcmp (argv[i], "--batch"))
batch = 1;
else if (!strcmp (argv[i], "-eval") || !strcmp (argv[i], "--eval"))
{
if (!argv[++i])
{
fprintf (stderr, "%s: `-eval' must be followed by an argument\n",
progname);
exit (1);
}
eval_form = argv[i];
}
else if (!strcmp (argv[i], "-display") || !strcmp (argv[i], "--display"))
{
suppress_windows_system = 0;
if (!argv[++i])
{
fprintf (stderr,
"%s: `-display' must be followed by an argument\n",
progname);
exit (1);
}
if (display)
free (display);
/* no need to strdup. */
display = argv[i];
}
else if (!strcmp (argv[i], "-nw"))
suppress_windows_system = 1;
else
{
/* Iterate over one-letter options. */
char *p;
int over = 0;
for (p = argv[i] + 1; *p && !over; p++)
{
switch (*p)
{
case 'q':
quick = 1;
break;
case 'v':
view = 1;
break;
case 'f':
GET_ARGUMENT (eval_function, "-f");
break;
case 'l':
GET_ARGUMENT (load_library, "-l");
break;
#ifdef INTERNET_DOMAIN_SOCKETS
case 'h':
GET_ARGUMENT (hostarg, "-h");
break;
case 'p':
GET_ARGUMENT (portarg, "-p");
port = atoi (portarg);
break;
case 'r':
GET_ARGUMENT (remotearg, "-r");
strcpy (remotepath, remotearg);
rflg = 1;
break;
#endif /* INTERNET_DOMAIN_SOCKETS */
default:
errflg = 1;
}
} /* for */
} /* else */
} /* for */
if (errflg)
{
fprintf (stderr,
#ifdef INTERNET_DOMAIN_SOCKETS
"usage: %s [-nw] [-display display] [-q] [-v] [-l library]\n"
" [-batch] [-f function] [-eval form]\n"
" [-h host] [-p port] [-r remote-path] [[+line] file] ...\n",
#else /* !INTERNET_DOMAIN_SOCKETS */
"usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval form] "
"[[+line] path] ...\n",
#endif /* !INTERNET_DOMAIN_SOCKETS */
progname);
exit (1);
}
if (batch && argv[i])
{
fprintf (stderr, "%s: Cannot specify `-batch' with file names\n",
progname);
exit (1);
}
if (suppress_windows_system && hostarg)
{
fprintf (stderr, "%s: Remote editing is available only on X\n",
progname);
exit (1);
}
*result = '\0';
if (eval_function || eval_form || load_library)
{
#if defined(INTERNET_DOMAIN_SOCKETS)
connect_type = make_connection (hostarg, port, &s);
#else
connect_type = make_connection (NULL, (u_short) 0, &s);
#endif
sprintf (command, "(gnuserv-eval%s '(progn ", quick ? "-quickly" : "");
send_string (s, command);
if (load_library)
{
sprintf (command, " (load-library %s)", clean_string (load_library));
send_string (s, command);
}
if (eval_form)
{
sprintf (command, " %s", eval_form);
send_string (s, command);
}
if (eval_function)
{
sprintf (command, " (%s)", eval_function);
send_string (s, command);
}
send_string (s, "))");
send_string (s, EOT_STR);
if (read_line (s, result) == 0)
{
fprintf (stderr, "%s: Could not read\n", progname);
exit (1);
}
} /* eval_function || eval_form || load_library */
else if (batch)
{
fprintf (stderr, "%s: `-batch' requires an evaluation\n",
progname);
exit (1);
}
if (!batch)
{
if (suppress_windows_system)
{
tty = ttyname (0);
if (!tty)
{
fprintf (stderr, "%s: Not connected to a tty", progname);
exit (1);
}
#if defined(INTERNET_DOMAIN_SOCKETS)
connect_type = make_connection (hostarg, port, &s);
#else
connect_type = make_connection (NULL, (u_short) 0, &s);
#endif
send_string (s, "(gnuserv-eval '(emacs-pid))");
send_string (s, EOT_STR);
if (read_line (s, buffer) == 0)
{
fprintf (stderr, "%s: Could not establish Emacs procces id\n",
progname);
exit (1);
}
/* Don't do disconnect_from_server becasue we have already read
data, and disconnect doesn't do anything else. */
#ifndef INTERNET_DOMAIN_SOCKETS
if (connect_type == (int) CONN_IPC)
disconnect_from_ipc_server (s, msgp, FALSE);
#endif /* !SYSV_IPC */
emacs_pid = (pid_t)atol(buffer);
initialize_signals();
} /* suppress_windows_system */
#if defined(INTERNET_DOMAIN_SOCKETS)
connect_type = make_connection (hostarg, port, &s);
#else
connect_type = make_connection (NULL, (u_short) 0, &s);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS
if (connect_type == (int) CONN_INTERNET)
{
char *ptr;
gethostname (thishost, HOSTNAMSZ);
if (!rflg)
{ /* attempt to generate a path
* to this machine */
if ((ptr = getenv ("GNU_NODE")) != NULL)
/* user specified a path */
strcpy (remotepath, ptr);
}
#if 0 /* This is really bogus... re-enable it if you must have it! */
#if defined (hp9000s300) || defined (hp9000s800)
else if (strcmp (thishost,hostarg))
{ /* try /net/thishost */
strcpy (remotepath, "/net/"); /* (this fails using internet
addresses) */
strcat (remotepath, thishost);
}
#endif
#endif
}
else
{ /* same machines, no need for path */
remotepath[0] = '\0'; /* default is the empty path */
}
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef SYSV_IPC
if ((msgp = (struct msgbuf *)
malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL)
{
fprintf (stderr, "%s: not enough memory for message buffer\n", progname);
exit (1);
} /* if */
msgp->mtext[0] = '\0'; /* ready for later strcats */
#endif /* SYSV_IPC */
if (suppress_windows_system)
{
char *term = getenv ("TERM");
if (!term)
{
fprintf (stderr, "%s: unknown terminal type\n", progname);
exit (1);
}
sprintf (command, "(gnuserv-edit-files '(tty %s %s %d) '(",
clean_string (tty), clean_string (term), (int)getpid ());
}
else /* !suppress_windows_system */
{
sprintf (command, "(gnuserv-edit-files '(x %s) '(",
clean_string (display));
} /* !suppress_windows_system */
send_string (s, command);
if (!argv[i])
nofiles = 1;
for (; argv[i]; i++)
{
if (i < argc - 1 && *argv[i] == '+')
starting_line = atoi (argv[i++]);
else
starting_line = 1;
/* If the last argument is +something, treat it as a file. */
if (i == argc)
{
starting_line = 1;
--i;
}
filename_expand (fullpath, argv[i]);
#ifdef INTERNET_DOMAIN_SOCKETS
path = malloc (strlen (remotepath) + strlen (fullpath) + 1);
sprintf (path, "%s%s", remotepath, fullpath);
#else
path = my_strdup (fullpath);
#endif
sprintf (command, "(%d . %s)", starting_line, clean_string (path));
send_string (s, command);
free (path);
} /* for */
sprintf (command, ")%s%s",
(quick || (nofiles && !suppress_windows_system)) ? " 'quick" : "",
view ? " 'view" : "");
send_string (s, command);
send_string (s, ")");
#ifdef SYSV_IPC
if (connect_type == (int) CONN_IPC)
disconnect_from_ipc_server (s, msgp, FALSE);
#else /* !SYSV_IPC */
if (connect_type != (int) CONN_IPC)
disconnect_from_server (s, FALSE);
#endif /* !SYSV_IPC */
} /* not batch */
if (batch && !quick)
printf ("%s\n", result);
return 0;
} /* main */
#endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */

View File

@@ -26,14 +26,16 @@ static glibtop _glibtop_global_server;
glibtop *glibtop_global_server = NULL;
glibtop *
glibtop_init__r (glibtop **server)
glibtop_init_r (glibtop **server, const unsigned long features,
const unsigned flags)
{
if (*server != NULL)
return *server;
if (glibtop_global_server == NULL) {
glibtop_global_server = &_glibtop_global_server;
glibtop_open (glibtop_global_server, "glibtop");
glibtop_open_l (glibtop_global_server, "glibtop",
features, flags);
}
return *server = glibtop_global_server;

52
lib/lib.awk Normal file
View File

@@ -0,0 +1,52 @@
BEGIN {
print "/* lib.c */";
print "/* This is a generated file. Please modify `lib.awk' */";
print "";
print "#include <glibtop.h>";
print "#include <glibtop/sysdeps.h>";
print "#include <glibtop/command.h>";
print "";
}
function output(feature) {
if (feature ~ /^proclist$/) {
print "unsigned *";
prefix = "return ";
} else {
prefix = "";
print "void";
}
if (feature ~ /^proc_/) {
param = ", pid_t pid";
} else {
param = "";
}
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf"param")";
print "{";
print "\tglibtop_init_r (&server, GLIBTOP_SYSDEPS_"toupper(feature)", 0);";
print "";
print "\tif (server->features & GLIBTOP_SYSDEPS_"toupper(feature)") {";
if (feature ~ /^proc_/) {
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", sizeof (pid_t),";
print "\t\t\t\t&pid, sizeof (glibtop_"feature"), buf);";
print "\t} else {";
print "\t\t"prefix"glibtop_get_"feature"_r (server, buf, pid);";
} else {
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", 0, NULL,";
print "\t\t\t sizeof (glibtop_"feature"), buf);";
print "\t} else {";
print "\t\t"prefix"glibtop_get_"feature"_r (server, buf);";
}
print "\t}";
print "}";
print "";
}
/^(\w+)/ { output($1) }

View File

@@ -19,42 +19,138 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/open.h>
#include <glibtop/sysdeps.h>
#include <glibtop/command.h>
#include <glibtop/xmalloc.h>
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
void
glibtop_open (glibtop *server, const char *program_name)
glibtop_open_l (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
char version [BUFSIZ], buffer [BUFSIZ];
char *server_command, *server_rsh, *temp;
char *server_host, *server_user;
glibtop_sysdeps sysdeps;
memset (server, 0, sizeof (glibtop));
server->name = program_name;
/* Is the user allowed to override the server ? */
if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) {
/* Try to get data from environment. */
temp = getenv ("LIBGTOP_SERVER") ?
getenv ("LIBGTOP_SERVER") : GTOP_SERVER;
server_command = glibtop_malloc_r (server, strlen (temp) + 1);
strcpy (server_command, temp);
temp = getenv ("LIBGTOP_RSH") ?
getenv ("LIBGTOP_RSH") : "rsh";
server_rsh = glibtop_malloc_r (server, strlen (temp) + 1);
strcpy (server_rsh, temp);
/* Extract host and user information. */
temp = strstr (server_command, ":");
if (temp) {
*temp = 0;
server_host = server_command;
server_command = temp+1;
temp = strstr (server_host, "@");
if (temp) {
*temp = 0;
server_user = server_host;
server_host = temp+1;
} else {
server_user = NULL;
}
} else {
server_host = NULL;
server_user = NULL;
}
/* Store everything in `server'. */
server->server_command = server_command;
server->server_host = server_host;
server->server_user = server_user;
server->server_rsh = server_rsh;
}
/* Get server features. */
if (server->server_host == NULL) {
server->features = glibtop_server_features;
if (server->features == 0)
return;
}
/* Fork and exec server. */
if (pipe (server->input) || pipe (server->output))
glibtop_error__r (server, _("cannot make a pipe: %s\n"), strerror (errno));
glibtop_error_r (server, _("cannot make a pipe: %s\n"),
strerror (errno));
server->pid = fork ();
if (server->pid < 0) {
glibtop_error__r (server, _("%s: fork failed: %s\n"), strerror (errno));
glibtop_error_r (server, _("%s: fork failed: %s\n"),
strerror (errno));
} else if (server->pid == 0) {
close (0); close (1); /* close (2); */
close (server->input [0]); close (server->output [1]);
dup2 (server->input [1], 1); /* dup2 (server->input [1], 2); */
dup2 (server->output [0], 0);
execl (GTOP_SERVER, NULL);
if (server_host) {
if (server_user) {
execl (server->server_rsh, "-l",
server->server_user, server->server_host,
server->server_command, NULL);
} else {
execl (server->server_rsh,
server->server_host, server_command, NULL);
}
} else {
execl (server->server_command, NULL);
}
_exit (2);
}
fprintf (stderr, "PID: %d\n", server->pid);
close (server->input [1]);
close (server->output [0]);
sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION);
glibtop_read__r (server, strlen (version), buffer);
glibtop_read_l (server, strlen (version), buffer);
if (memcmp (version, buffer, strlen (version)))
glibtop_error__r (server, _("server version is not %s"), VERSION);
glibtop_error_r (server, _("server version is not %s"), VERSION);
fprintf (stderr, "Calling GLITOP_CMND_SYSDEPS ...\n");
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
sizeof (glibtop_sysdeps), &sysdeps);
server->features = sysdeps.features;
fprintf (stderr, "Features: %lu\n", server->features);
}

View File

@@ -1,35 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/prockernel.h>
#include <glibtop/command.h>
/* Provides detailed information about a process. */
void
glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf,
pid_t pid)
{
glibtop_init__r (&server);
glibtop_call__r (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t),
&pid, sizeof (glibtop_proc_kernel), buf);
}

View File

@@ -1,32 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop/proclist.h>
#include <glibtop/command.h>
/* Fetch list of currently running processes. */
unsigned *
glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf)
{
glibtop_init__r (&server);
return glibtop_call__r (server, GLIBTOP_CMND_PROCLIST, 0, NULL, sizeof (glibtop_proclist), buf);
}

View File

@@ -1,35 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/procsegment.h>
#include <glibtop/command.h>
/* Provides detailed information about a process. */
void
glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
glibtop_init__r (&server);
glibtop_call__r (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t),
&pid, sizeof (glibtop_proc_segment), buf);
}

View File

@@ -24,18 +24,18 @@
/* Reads some data from server. */
void
glibtop_read__r (glibtop *server, size_t size, void *buf)
glibtop_read_l (glibtop *server, size_t size, void *buf)
{
size_t ssize;
glibtop_init__r (&server);
glibtop_init_r (&server, 0, 0);
if (read (server->input [0], &ssize, sizeof (size_t)) < 0)
glibtop_error__r (server, _("read size: %s"), strerror (errno));
glibtop_error_r (server, _("read size: %s"), strerror (errno));
if (size != ssize)
glibtop_error__r (server, _("got %d bytes but requested %d"), ssize, size);
glibtop_error_r (server, _("got %d bytes but requested %d"), ssize, size);
if (read (server->input [0], buf, size) < 0)
glibtop_error__r (server, _("read %d bytes: %s"), size, strerror (errno));
glibtop_error_r (server, _("read %d bytes: %s"), size, strerror (errno));
}

View File

@@ -25,24 +25,24 @@
/* Reads some data from server. */
void *
glibtop_read_data__r (glibtop *server)
glibtop_read_data_l (glibtop *server)
{
size_t size;
void *ptr;
glibtop_init__r (&server);
glibtop_init_r (&server, 0, 0);
if (read (server->input [0], &size, sizeof (size_t)) < 0)
glibtop_error__r (server, _("read data size: %s"), strerror (errno));
glibtop_error_r (server, _("read data size: %s"),
strerror (errno));
if (!size) return NULL;
fprintf (stderr, "Server has %d bytes of data.\n", size);
ptr = glibtop_malloc__r (server, size);
ptr = glibtop_malloc_r (server, size);
if (read (server->input [0], ptr, size) < 0)
glibtop_error__r (server, _("read data %d bytes: %s"), size, strerror (errno));
glibtop_error_r (server, _("read data %d bytes: %s"),
size, strerror (errno));
return ptr;
}

View File

@@ -24,15 +24,15 @@
/* Writes some data to server. */
void
glibtop_write__r (glibtop *server, size_t size, void *buf)
glibtop_write_l (glibtop *server, size_t size, void *buf)
{
glibtop_init__r (&server);
glibtop_init_r (&server, 0, 0);
if (write (server->output [1], &size, sizeof (size_t)) < 0)
glibtop_error__r (server, _("write size: %s"), strerror (errno));
glibtop_error_r (server, _("write size: %s"), strerror (errno));
if (!size) return;
if (write (server->output [1], buf, size) < 0)
glibtop_error__r (server, _("write %d bytes: %s"), size, strerror (errno));
glibtop_error_r (server, _("write %d bytes: %s"), size, strerror (errno));
}

81
libgtop.spec Normal file
View File

@@ -0,0 +1,81 @@
# Note that this is NOT a relocatable package
%define ver 0.01
%define rel SNAP
%define prefix /usr
Summary: libgtop library
Name: libgtop
Version: %ver
Release: %rel
Copyright: LGPL
Group: X11/Libraries
Source: ftp://ftp.gnome.org/pub/libgtop-%{ver}.tar.gz
BuildRoot: /tmp/libgtop-root
Packager: Michael Fulbright <msf@redhat.com>
URL: http://www.gnome.org
Prereq: /sbin/install-info
Docdir: %{prefix}/doc
%description
A library that fetches
information about the running system such as cpu and memory usage,
active processes etc. On Linux systems, these information are taken
directly from the /proc filesystem.
%changelog
* Tue Jun 2 1998 Michael Fulbright <msf@redhat.com>
- first version of the RPM
%prep
%setup
%build
# Needed for snapshot releases.
if [ ! -f configure ]; then
CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%prefix --disable-libgtop-examples
else
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix --disable-libgtop-examples
fi
if [ "$SMP" != "" ]; then
(make "MAKE=make -k -j $SMP"; exit 0)
make
else
make
fi
%install
rm -rf $RPM_BUILD_ROOT
make prefix=$RPM_BUILD_ROOT%{prefix} install
#
# msf - remove these as they are really supposed to come from gnome-libs
#
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.a
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.la
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.so.0
rm -f $RPM_BUILD_ROOT/%{prefix}/lib/libgnomesupport.so.0.0.0
rm -fr $RPM_BUILD_ROOT/%{prefix}/include/libgtop
%clean
#rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-, root, root)
%doc ANNOUNCE AUTHORS ChangeLog NEWS README README.LATEST copyright.txt doc
%{prefix}/bin/*
%{prefix}/lib/lib*.so.*
%{prefix}/lib/libgtopConf.sh
%{prefix}/lib/*a
%{prefix}/include/*

View File

@@ -2,4 +2,5 @@ Makefile
Makefile.in
POTFILES
cat-id-tbl.c
fr.gmo
libgtop.pot

View File

@@ -1,3 +1,7 @@
Sun, 31 May 1998 22:38:59 +0200 Vincent Renardias <vincent@waw.com>
* fr.po: new file - ChangeLog isn't empty anymore _(;
1998-05-21 Martin Baulig <martin@home-of-linux.org>
* ChangeLog: new file - currently empty

View File

@@ -1,18 +1,8 @@
lib/close.c
lib/command.c
lib/cpu.c
lib/mem.c
lib/open.c
lib/read.c
lib/swap.c
lib/write.c
lib/sysdeps.c
lib/uptime.c
lib/loadavg.c
lib/shm_limits.c
lib/msg_limits.c
lib/sem_limits.c
lib/proclist.c
lib/read_data.c
acconfig.h
glibtop.h

402
po/fr.po Normal file
View File

@@ -0,0 +1,402 @@
# libgtop fr.po
# Copyright (C) 1998 Free Software Foundation, Inc.
# Vincent Renardias <vincent@waw.com>, 1998.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: libgtop VERSION\n"
"POT-Creation-Date: 1998-05-31 22:31+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Vincent Renardias <vincent@waw.com>\n"
"Language-Team: Vincent Renardias <vincent@waw.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
#: lib/open.c:36
#, c-format
msgid "cannot make a pipe: %s\n"
msgstr ""
#: lib/open.c:41
#, c-format
msgid "%s: fork failed: %s\n"
msgstr ""
#: lib/open.c:59
#, c-format
msgid "server version is not %s"
msgstr ""
#: lib/read.c:34
#, c-format
msgid "read size: %s"
msgstr ""
#: lib/read.c:37
#, c-format
msgid "got %d bytes but requested %d"
msgstr ""
#: lib/read.c:40
#, c-format
msgid "read %d bytes: %s"
msgstr ""
#: lib/write.c:32
#, c-format
msgid "write size: %s"
msgstr ""
#: lib/write.c:37
#, c-format
msgid "write %d bytes: %s"
msgstr ""
#: lib/read_data.c:36
#, c-format
msgid "read data size: %s"
msgstr ""
#: lib/read_data.c:46
#, c-format
msgid "read data %d bytes: %s"
msgstr ""
#: sysdeps/common/xmalloc.c:32
#, c-format
msgid "malloc %d bytes: %s"
msgstr ""
#: sysdeps/common/xmalloc.c:44
#, c-format
msgid "calloc %d block (%d bytes each): %s"
msgstr ""
#: sysdeps/common/xmalloc.c:56
#, c-format
msgid "realloc %d bytes: %s"
msgstr ""
#: sysdeps/names/sysdeps.c:42 sysdeps/names/sysdeps.c:62
msgid "CPU Usage"
msgstr "Utilisation CPU"
#: sysdeps/names/sysdeps.c:43 sysdeps/names/sysdeps.c:63
msgid "Memory Usage"
msgstr "Utilisation M<>moire"
#: sysdeps/names/sysdeps.c:44 sysdeps/names/sysdeps.c:64
msgid "Swap Usage"
msgstr "Utilisation du Swap"
#: sysdeps/names/sysdeps.c:45 sysdeps/names/sysdeps.c:65
msgid "System Uptime"
msgstr ""
#: sysdeps/names/sysdeps.c:46 sysdeps/names/sysdeps.c:66
msgid "Load Averange"
msgstr "Charge moyenne"
#: sysdeps/names/sysdeps.c:47 sysdeps/names/sysdeps.c:67
msgid "Shared Memory Limits"
msgstr "Limites de la m<>moire partag<61>e"
#: sysdeps/names/sysdeps.c:48 sysdeps/names/sysdeps.c:68
msgid "Message Queue Limits"
msgstr "Limites de la queue de messages"
#: sysdeps/names/sysdeps.c:49 sysdeps/names/sysdeps.c:69
msgid "Semaphore Set Limits"
msgstr "Limites de l'ensemble de s<>maphores"
#: sysdeps/names/sysdeps.c:50 sysdeps/names/sysdeps.c:70
msgid "List of running Processes"
msgstr "Liste des taches en cours d'<27>x<EFBFBD>cution"
#: sysdeps/names/sysdeps.c:51 sysdeps/names/sysdeps.c:71
msgid "Process Status information"
msgstr ""
#: sysdeps/names/sysdeps.c:52 sysdeps/names/sysdeps.c:72
msgid "Process UID and TTY information"
msgstr ""
#: sysdeps/names/sysdeps.c:53 sysdeps/names/sysdeps.c:73
msgid "Process Memory information"
msgstr ""
#: sysdeps/names/sysdeps.c:54 sysdeps/names/sysdeps.c:74
msgid "Process Time information"
msgstr ""
#: sysdeps/names/sysdeps.c:55 sysdeps/names/sysdeps.c:75
msgid "Process Signal information"
msgstr ""
#: sysdeps/names/sysdeps.c:56 sysdeps/names/sysdeps.c:76
msgid "Process Kernel Data information"
msgstr ""
#: sysdeps/names/sysdeps.c:57 sysdeps/names/sysdeps.c:77
msgid "Process Segment information"
msgstr ""
#: sysdeps/names/cpu.c:37
msgid "Total CPU Time"
msgstr "Temps CPU Total"
#: sysdeps/names/cpu.c:38
msgid "CPU Time in User Mode"
msgstr "Temps CPU en mode utilisateur"
#: sysdeps/names/cpu.c:39
msgid "CPU Time in User Mode (nice)"
msgstr ""
#: sysdeps/names/cpu.c:40
msgid "CPU Time in System Mode"
msgstr "Temps CPU en mode syst<73>me"
#: sysdeps/names/cpu.c:41
msgid "CPU Time in the Idle Task"
msgstr "Temps CPU pour la tache inactive"
#: sysdeps/names/cpu.c:42
msgid "Tick Frequency"
msgstr ""
#: sysdeps/names/cpu.c:47
msgid "The number of jiffies (1/100ths of a second) since system boot"
msgstr "Nombre de jiffies (1/100e de seconde) depuis le boot du syst<73>me"
#: sysdeps/names/cpu.c:49
msgid ""
"The number of jiffies (1/100ths of a second) that the system spent in user "
"mode"
msgstr ""
#: sysdeps/names/cpu.c:51
msgid ""
"The number of jiffies (1/100ths of a second) that the system spent in user "
"mode with low priority (nice)"
msgstr ""
#: sysdeps/names/cpu.c:53
msgid ""
"The number of jiffies (1/100ths of a second) that the system spent in system "
"mode"
msgstr ""
#: sysdeps/names/cpu.c:55
msgid ""
"The number of jiffies (1/100ths of a second) that the system spend in the "
"idle task"
msgstr ""
#: sysdeps/names/cpu.c:57
msgid ""
"All of the above values are in jiffies (1/100ths of a second) unless "
"otherwise stated in this field (i.e. 'frequency != 100')"
msgstr ""
#: sysdeps/names/loadavg.c:36
msgid "Load Average"
msgstr "Charge Moyenne"
#: sysdeps/names/loadavg.c:41
msgid "Number of jobs running simultaneously averaged over 1, 5 and 15 minutes"
msgstr ""
#: sysdeps/names/mem.c:39
msgid "Total Memory"
msgstr "M<>moire Totale"
#: sysdeps/names/mem.c:40
msgid "Used Memory"
msgstr "M<>moire Utilis<69>e"
#: sysdeps/names/mem.c:41
msgid "Free Memory"
msgstr "M<>moire Libre"
#: sysdeps/names/mem.c:42
msgid "Shared Memory"
msgstr "M<>moire Partag<61>e"
#: sysdeps/names/mem.c:43
msgid "Buffers"
msgstr "Tampons"
#: sysdeps/names/mem.c:44
msgid "Cached"
msgstr ""
#: sysdeps/names/mem.c:45
msgid "User"
msgstr "Utilisateur"
#: sysdeps/names/mem.c:46
msgid "Locked"
msgstr "V<>rouill<6C>"
#: sysdeps/names/mem.c:51
msgid "Total physical memory in kB"
msgstr "M<>moire physique totalle en Ko"
#: sysdeps/names/mem.c:52
msgid "Used memory size in kB"
msgstr ""
#: sysdeps/names/mem.c:53
msgid "Free memory size in kB"
msgstr ""
#: sysdeps/names/mem.c:54
msgid "Shared memory size in kB"
msgstr ""
#: sysdeps/names/mem.c:55
msgid "Size of buffers kB"
msgstr ""
#: sysdeps/names/mem.c:56
msgid "Size of cached memory in kB"
msgstr ""
#: sysdeps/names/mem.c:57
msgid "Memory used from user processes in kB"
msgstr ""
#: sysdeps/names/mem.c:58
msgid "Memory in locked pages in kB"
msgstr ""
#: sysdeps/names/swap.c:36 sysdeps/names/swap.c:43
msgid "Total Swap Space"
msgstr ""
#: sysdeps/names/swap.c:37 sysdeps/names/swap.c:44
msgid "Used Swap Space"
msgstr ""
#: sysdeps/names/swap.c:38 sysdeps/names/swap.c:45
msgid "Free Swap Space"
msgstr ""
#: sysdeps/names/uptime.c:36
msgid "Uptime"
msgstr ""
#: sysdeps/names/uptime.c:37
msgid "Idletime"
msgstr ""
#: sysdeps/names/uptime.c:42
msgid "Time in seconds since system boot"
msgstr ""
#: sysdeps/names/uptime.c:43
msgid "Time in seconds the system spent in the idle task since system boot"
msgstr ""
#: sysdeps/names/shm_limits.c:37 sysdeps/names/shm_limits.c:46
msgid "Max segment size"
msgstr ""
#: sysdeps/names/shm_limits.c:38 sysdeps/names/shm_limits.c:47
msgid "Min segment size"
msgstr ""
#: sysdeps/names/shm_limits.c:39 sysdeps/names/shm_limits.c:48
msgid "Max number of segments"
msgstr ""
#: sysdeps/names/shm_limits.c:40 sysdeps/names/shm_limits.c:49
msgid "Max shared segments per process"
msgstr ""
#: sysdeps/names/shm_limits.c:41 sysdeps/names/shm_limits.c:50
msgid "Max total shared memory"
msgstr ""
#: sysdeps/names/msg_limits.c:37 sysdeps/names/msg_limits.c:48
msgid "Size in kilobytes of message pool"
msgstr ""
#: sysdeps/names/msg_limits.c:38 sysdeps/names/msg_limits.c:49
msgid "Number of entries in message map"
msgstr ""
#: sysdeps/names/msg_limits.c:39 sysdeps/names/msg_limits.c:50
msgid "Max size of message"
msgstr ""
#: sysdeps/names/msg_limits.c:40 sysdeps/names/msg_limits.c:51
msgid "Default max size of queue"
msgstr ""
#: sysdeps/names/msg_limits.c:41 sysdeps/names/msg_limits.c:52
msgid "Max queues system wide"
msgstr ""
#: sysdeps/names/msg_limits.c:42 sysdeps/names/msg_limits.c:53
msgid "Message segment size"
msgstr ""
#: sysdeps/names/msg_limits.c:43 sysdeps/names/msg_limits.c:54
msgid "Number of system message headers"
msgstr ""
#: sysdeps/names/sem_limits.c:39 sysdeps/names/sem_limits.c:53
msgid "Number of entries in semaphore map"
msgstr ""
#: sysdeps/names/sem_limits.c:40 sysdeps/names/sem_limits.c:54
msgid "Max number of arrays"
msgstr ""
#: sysdeps/names/sem_limits.c:41 sysdeps/names/sem_limits.c:55
msgid "Max semaphores system wide"
msgstr ""
#: sysdeps/names/sem_limits.c:42 sysdeps/names/sem_limits.c:56
msgid "Number of undo structures system wide"
msgstr ""
#: sysdeps/names/sem_limits.c:43 sysdeps/names/sem_limits.c:57
msgid "Max semaphores per array"
msgstr ""
#: sysdeps/names/sem_limits.c:44 sysdeps/names/sem_limits.c:58
msgid "Max ops per semop call"
msgstr ""
#: sysdeps/names/sem_limits.c:45 sysdeps/names/sem_limits.c:59
msgid "Max number of undo entries per process"
msgstr ""
#: sysdeps/names/sem_limits.c:46 sysdeps/names/sem_limits.c:60
msgid "sizeof struct sem_undo"
msgstr ""
#: sysdeps/names/sem_limits.c:47 sysdeps/names/sem_limits.c:61
msgid "Semaphore max value"
msgstr ""
#: sysdeps/names/sem_limits.c:48 sysdeps/names/sem_limits.c:62
msgid "Adjust on exit max value"
msgstr ""
#: sysdeps/names/proclist.c:36 sysdeps/names/proclist.c:43
msgid "Number of list elements"
msgstr ""
#: sysdeps/names/proclist.c:37 sysdeps/names/proclist.c:44
msgid "Total size of list"
msgstr "Taille totalle de la liste"
#: sysdeps/names/proclist.c:38 sysdeps/names/proclist.c:45
msgid "Size of a single list element"
msgstr ""

View File

@@ -1 +1 @@
SUBDIRS = server
SUBDIRS = server proxy

620
src/daemon/gnuclient.c Normal file
View File

@@ -0,0 +1,620 @@
/* -*-C-*-
Client code to allow local and remote editing of files by XEmacs.
Copyright (C) 1989 Free Software Foundation, Inc.
Copyright (C) 1995 Sun Microsystems, Inc.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of XEmacs.
XEmacs is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
XEmacs 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
along with XEmacs; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
Please mail bugs and suggestions to the author at the above address.
*/
/*
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
* GNUATTACH support added by Ben Wing <wing@xemacs.org>.
* Please see the note at the end of the README file for details.
*
* (If gnuserv came bundled with your emacs, the README file is probably
* ../etc/gnuserv.README relative to the directory containing this file)
*/
#if 0
/* Hand-munged RCS header */
static char rcsid [] = "!Header: gnuclient.c,v 2.2 95/12/12 01:39:21 wing nene !";
#endif
#include "gnuserv.h"
#include "getopt.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <signal.h>
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
!defined(INTERNET_DOMAIN_SOCKETS)
int
main (int argc, char *argv[])
{
fprintf (stderr, "Sorry, the Emacs server is only "
"supported on systems that have\n");
fprintf (stderr, "Unix Domain sockets, Internet Domain "
"sockets or System V IPC.\n");
exit (1);
} /* main */
#else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
static char cwd[MAXPATHLEN+2]; /* current working directory when calculated */
static char *cp = NULL; /* ptr into valid bit of cwd above */
static pid_t emacs_pid; /* Process id for emacs process */
void initialize_signals (void);
static void
tell_emacs_to_resume (int sig)
{
char buffer[GSERV_BUFSZ+1];
int s; /* socket / msqid to server */
int connect_type; /* CONN_UNIX, CONN_INTERNET, or
ONN_IPC */
/* Why is SYSV so retarded? */
/* We want emacs to realize that we are resuming */
signal(SIGCONT, tell_emacs_to_resume);
connect_type = make_connection (NULL, (u_short) 0, &s);
sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid());
send_string(s, buffer);
#ifdef SYSV_IPC
if (connect_type == (int) CONN_IPC)
disconnect_from_ipc_server (s, msgp, FALSE);
#else /* !SYSV_IPC */
if (connect_type != (int) CONN_IPC)
disconnect_from_server (s, FALSE);
#endif /* !SYSV_IPC */
}
static void
pass_signal_to_emacs (int sig)
{
if (kill (emacs_pid, sig) == -1)
{
fprintf (stderr, "gnuattach: Could not pass signal to emacs process\n");
exit (1);
}
initialize_signals ();
}
void
initialize_signals ()
{
/* Set up signal handler to pass relevant signals to emacs process.
We used to send SIGSEGV, SIGBUS, SIGPIPE, SIGILL and others to
Emacs, but I think it's better not to. I can see no reason why
Emacs should SIGSEGV whenever gnuclient SIGSEGV-s, etc. */
signal (SIGHUP, pass_signal_to_emacs);
signal (SIGQUIT, pass_signal_to_emacs);
signal (SIGINT, pass_signal_to_emacs);
#ifdef SIGWINCH
signal (SIGWINCH, pass_signal_to_emacs);
#endif
/* We want emacs to realize that we are resuming */
signal (SIGCONT, tell_emacs_to_resume);
}
/*
get_current_working_directory -- return the cwd.
*/
static char *
get_current_working_directory (void)
{
if (cp == NULL)
{ /* haven't calculated it yet */
#ifdef BSD
if (getwd (cwd) == 0)
#else /* !BSD */
if (getcwd (cwd,MAXPATHLEN) == NULL)
#endif /* !BSD */
{
perror (progname);
fprintf (stderr, "%s: unable to get current working directory\n",
progname);
exit (1);
} /* if */
/* on some systems, cwd can look like '@machine/' ... */
/* ignore everything before the first '/' */
for (cp = cwd; *cp && *cp != '/'; ++cp)
;
} /* if */
return cp;
} /* get_current_working_directory */
/*
filename_expand -- try to convert the given filename into a fully-qualified
pathname.
*/
static void
filename_expand (char *fullpath, char *filename)
/* fullpath - returned full pathname */
/* filename - filename to expand */
{
int len;
fullpath[0] = '\0';
if (filename[0] && filename[0] != '/')
{ /* relative filename */
strcat (fullpath, get_current_working_directory ());
len = strlen (fullpath);
if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
; /* yep */
else
strcat (fullpath, "/"); /* nope, append trailing slash */
} /* if */
strcat (fullpath,filename);
} /* filename_expand */
/* Encase the string in quotes, escape all the backslashes and quotes
in string. */
static char *
clean_string (const char *s)
{
int i = 0;
char *p, *res;
for (p = s; *p; p++, i++)
{
if (*p == '\\' || *p == '\"')
++i;
else if (*p == '\004')
i += 3;
}
p = res = (char *)malloc (i + 2 + 1);
*p++ = '\"';
for (; *s; p++, s++)
{
switch (*s)
{
case '\\':
*p++ = '\\';
*p = '\\';
break;
case '\"':
*p++ = '\\';
*p = '\"';
break;
case '\004':
*p++ = '\\';
*p++ = 'C';
*p++ = '-';
*p = 'd';
break;
default:
*p = *s;
}
}
*p++ = '\"';
*p = '\0';
return res;
}
#define GET_ARGUMENT(var, desc) do { \
if (*(p + 1)) (var) = p + 1; \
else \
{ \
if (!argv[++i]) \
{ \
fprintf (stderr, "%s: `%s' must be followed by an argument\n", \
progname, desc); \
exit (1); \
} \
(var) = argv[i]; \
} \
over = 1; \
} while (0)
/* A strdup immitation. */
static char *
my_strdup (const char *s)
{
char *new = malloc (strlen (s) + 1);
if (new)
strcpy (new, s);
return new;
}
int
main (int argc, char *argv[])
{
int starting_line = 1; /* line to start editing at */
char command[MAXPATHLEN+50]; /* emacs command buffer */
char fullpath[MAXPATHLEN+1]; /* full pathname to file */
char *eval_form = NULL; /* form to evaluate with `-eval' */
char *eval_function = NULL; /* function to evaluate with `-f' */
char *load_library = NULL; /* library to load */
int quick = 0; /* quick edit, don't wait for user to
finish */
int batch = 0; /* batch mode */
int view = 0; /* view only. */
int nofiles = 0;
int errflg = 0; /* option error */
int s; /* socket / msqid to server */
int connect_type; /* CONN_UNIX, CONN_INTERNET, or
* CONN_IPC */
int suppress_windows_system = 0;
char *display = NULL;
#ifdef INTERNET_DOMAIN_SOCKETS
char *hostarg = NULL; /* remote hostname */
char *remotearg;
char thishost[HOSTNAMSZ]; /* this hostname */
char remotepath[MAXPATHLEN+1]; /* remote pathname */
char *path;
int rflg = 0; /* pathname given on cmdline */
char *portarg;
u_short port = 0; /* port to server */
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef SYSV_IPC
struct msgbuf *msgp; /* message */
#endif /* SYSV_IPC */
char *tty = NULL;
char buffer[GSERV_BUFSZ + 1]; /* buffer to read pid */
char result[GSERV_BUFSZ + 1];
int i;
#ifdef INTERNET_DOMAIN_SOCKETS
memset (remotepath, 0, sizeof (remotepath));
#endif /* INTERNET_DOMAIN_SOCKETS */
progname = strrchr (argv[0], '/');
if (progname)
++progname;
else
progname = argv[0];
display = getenv ("DISPLAY");
if (!display)
suppress_windows_system = 1;
else
display = my_strdup (display);
for (i = 1; argv[i] && !errflg; i++)
{
if (*argv[i] != '-')
break;
else if (*argv[i] == '-'
&& (*(argv[i] + 1) == '\0'
|| (*(argv[i] + 1) == '-' && *(argv[i] + 2) == '\0')))
{
/* `-' or `--' */
++i;
break;
}
if (!strcmp (argv[i], "-batch") || !strcmp (argv[i], "--batch"))
batch = 1;
else if (!strcmp (argv[i], "-eval") || !strcmp (argv[i], "--eval"))
{
if (!argv[++i])
{
fprintf (stderr, "%s: `-eval' must be followed by an argument\n",
progname);
exit (1);
}
eval_form = argv[i];
}
else if (!strcmp (argv[i], "-display") || !strcmp (argv[i], "--display"))
{
suppress_windows_system = 0;
if (!argv[++i])
{
fprintf (stderr,
"%s: `-display' must be followed by an argument\n",
progname);
exit (1);
}
if (display)
free (display);
/* no need to strdup. */
display = argv[i];
}
else if (!strcmp (argv[i], "-nw"))
suppress_windows_system = 1;
else
{
/* Iterate over one-letter options. */
char *p;
int over = 0;
for (p = argv[i] + 1; *p && !over; p++)
{
switch (*p)
{
case 'q':
quick = 1;
break;
case 'v':
view = 1;
break;
case 'f':
GET_ARGUMENT (eval_function, "-f");
break;
case 'l':
GET_ARGUMENT (load_library, "-l");
break;
#ifdef INTERNET_DOMAIN_SOCKETS
case 'h':
GET_ARGUMENT (hostarg, "-h");
break;
case 'p':
GET_ARGUMENT (portarg, "-p");
port = atoi (portarg);
break;
case 'r':
GET_ARGUMENT (remotearg, "-r");
strcpy (remotepath, remotearg);
rflg = 1;
break;
#endif /* INTERNET_DOMAIN_SOCKETS */
default:
errflg = 1;
}
} /* for */
} /* else */
} /* for */
if (errflg)
{
fprintf (stderr,
#ifdef INTERNET_DOMAIN_SOCKETS
"usage: %s [-nw] [-display display] [-q] [-v] [-l library]\n"
" [-batch] [-f function] [-eval form]\n"
" [-h host] [-p port] [-r remote-path] [[+line] file] ...\n",
#else /* !INTERNET_DOMAIN_SOCKETS */
"usage: %s [-nw] [-q] [-v] [-l library] [-f function] [-eval form] "
"[[+line] path] ...\n",
#endif /* !INTERNET_DOMAIN_SOCKETS */
progname);
exit (1);
}
if (batch && argv[i])
{
fprintf (stderr, "%s: Cannot specify `-batch' with file names\n",
progname);
exit (1);
}
if (suppress_windows_system && hostarg)
{
fprintf (stderr, "%s: Remote editing is available only on X\n",
progname);
exit (1);
}
*result = '\0';
if (eval_function || eval_form || load_library)
{
#if defined(INTERNET_DOMAIN_SOCKETS)
connect_type = make_connection (hostarg, port, &s);
#else
connect_type = make_connection (NULL, (u_short) 0, &s);
#endif
sprintf (command, "(gnuserv-eval%s '(progn ", quick ? "-quickly" : "");
send_string (s, command);
if (load_library)
{
sprintf (command, " (load-library %s)", clean_string (load_library));
send_string (s, command);
}
if (eval_form)
{
sprintf (command, " %s", eval_form);
send_string (s, command);
}
if (eval_function)
{
sprintf (command, " (%s)", eval_function);
send_string (s, command);
}
send_string (s, "))");
send_string (s, EOT_STR);
if (read_line (s, result) == 0)
{
fprintf (stderr, "%s: Could not read\n", progname);
exit (1);
}
} /* eval_function || eval_form || load_library */
else if (batch)
{
fprintf (stderr, "%s: `-batch' requires an evaluation\n",
progname);
exit (1);
}
if (!batch)
{
if (suppress_windows_system)
{
tty = ttyname (0);
if (!tty)
{
fprintf (stderr, "%s: Not connected to a tty", progname);
exit (1);
}
#if defined(INTERNET_DOMAIN_SOCKETS)
connect_type = make_connection (hostarg, port, &s);
#else
connect_type = make_connection (NULL, (u_short) 0, &s);
#endif
send_string (s, "(gnuserv-eval '(emacs-pid))");
send_string (s, EOT_STR);
if (read_line (s, buffer) == 0)
{
fprintf (stderr, "%s: Could not establish Emacs procces id\n",
progname);
exit (1);
}
/* Don't do disconnect_from_server becasue we have already read
data, and disconnect doesn't do anything else. */
#ifndef INTERNET_DOMAIN_SOCKETS
if (connect_type == (int) CONN_IPC)
disconnect_from_ipc_server (s, msgp, FALSE);
#endif /* !SYSV_IPC */
emacs_pid = (pid_t)atol(buffer);
initialize_signals();
} /* suppress_windows_system */
#if defined(INTERNET_DOMAIN_SOCKETS)
connect_type = make_connection (hostarg, port, &s);
#else
connect_type = make_connection (NULL, (u_short) 0, &s);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS
if (connect_type == (int) CONN_INTERNET)
{
char *ptr;
gethostname (thishost, HOSTNAMSZ);
if (!rflg)
{ /* attempt to generate a path
* to this machine */
if ((ptr = getenv ("GNU_NODE")) != NULL)
/* user specified a path */
strcpy (remotepath, ptr);
}
#if 0 /* This is really bogus... re-enable it if you must have it! */
#if defined (hp9000s300) || defined (hp9000s800)
else if (strcmp (thishost,hostarg))
{ /* try /net/thishost */
strcpy (remotepath, "/net/"); /* (this fails using internet
addresses) */
strcat (remotepath, thishost);
}
#endif
#endif
}
else
{ /* same machines, no need for path */
remotepath[0] = '\0'; /* default is the empty path */
}
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef SYSV_IPC
if ((msgp = (struct msgbuf *)
malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL)
{
fprintf (stderr, "%s: not enough memory for message buffer\n", progname);
exit (1);
} /* if */
msgp->mtext[0] = '\0'; /* ready for later strcats */
#endif /* SYSV_IPC */
if (suppress_windows_system)
{
char *term = getenv ("TERM");
if (!term)
{
fprintf (stderr, "%s: unknown terminal type\n", progname);
exit (1);
}
sprintf (command, "(gnuserv-edit-files '(tty %s %s %d) '(",
clean_string (tty), clean_string (term), (int)getpid ());
}
else /* !suppress_windows_system */
{
sprintf (command, "(gnuserv-edit-files '(x %s) '(",
clean_string (display));
} /* !suppress_windows_system */
send_string (s, command);
if (!argv[i])
nofiles = 1;
for (; argv[i]; i++)
{
if (i < argc - 1 && *argv[i] == '+')
starting_line = atoi (argv[i++]);
else
starting_line = 1;
/* If the last argument is +something, treat it as a file. */
if (i == argc)
{
starting_line = 1;
--i;
}
filename_expand (fullpath, argv[i]);
#ifdef INTERNET_DOMAIN_SOCKETS
path = malloc (strlen (remotepath) + strlen (fullpath) + 1);
sprintf (path, "%s%s", remotepath, fullpath);
#else
path = my_strdup (fullpath);
#endif
sprintf (command, "(%d . %s)", starting_line, clean_string (path));
send_string (s, command);
free (path);
} /* for */
sprintf (command, ")%s%s",
(quick || (nofiles && !suppress_windows_system)) ? " 'quick" : "",
view ? " 'view" : "");
send_string (s, command);
send_string (s, ")");
#ifdef SYSV_IPC
if (connect_type == (int) CONN_IPC)
disconnect_from_ipc_server (s, msgp, FALSE);
#else /* !SYSV_IPC */
if (connect_type != (int) CONN_IPC)
disconnect_from_server (s, FALSE);
#endif /* !SYSV_IPC */
} /* not batch */
if (batch && !quick)
printf ("%s\n", result);
return 0;
} /* main */
#endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */

897
src/daemon/gnuserv.c Normal file
View File

@@ -0,0 +1,897 @@
/* -*-C-*-
Server code for handling requests from clients and forwarding them
on to the GNU Emacs process.
This file is part of GNU Emacs.
Copying is permitted under those conditions described by the GNU
General Public License.
Copyright (C) 1989 Free Software Foundation, Inc.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on 'etc/server.c'
from the 18.52 GNU Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
/* HISTORY
* 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
/*
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
* Please see the note at the end of the README file for details.
*
* (If gnuserv came bundled with your emacs, the README file is probably
* ../etc/gnuserv.README relative to the directory containing this file)
*/
#if 0
static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !";
#endif
#include "gnuserv.h"
#ifdef AIX
#include <sys/select.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \
!defined(INTERNET_DOMAIN_SOCKETS)
main ()
{
fprintf (stderr,"Sorry, the Emacs server is only supported on systems that have\n");
fprintf (stderr,"Unix Domain sockets, Internet Domain sockets or System V IPC\n");
exit (1);
} /* main */
#else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */
#ifdef SYSV_IPC
int ipc_qid = 0; /* ipc message queue id */
int ipc_wpid = 0; /* watchdog task pid */
/*
ipc_exit -- clean up the queue id and queue, then kill the watchdog task
if it exists. exit with the given status.
*/
void
ipc_exit (int stat)
{
msgctl (ipc_qid,IPC_RMID,0);
if (ipc_wpid != 0)
kill (ipc_wpid, SIGKILL);
exit (stat);
} /* ipc_exit */
/*
ipc_handle_signal -- catch the signal given and clean up.
*/
void
ipc_handle_signal(int sig)
{
ipc_exit (0);
} /* ipc_handle_signal */
/*
ipc_spawn_watchdog -- spawn a watchdog task to clean up the message queue should the
server process die.
*/
void
ipc_spawn_watchdog (void)
{
if ((ipc_wpid = fork ()) == 0)
{ /* child process */
int ppid = getppid (); /* parent's process id */
setpgrp(); /* gnu kills process group on exit */
while (1)
{
if (kill (ppid, 0) < 0) /* ppid is no longer valid, parent
may have died */
{
ipc_exit (0);
} /* if */
sleep(10); /* have another go later */
} /* while */
} /* if */
} /* ipc_spawn_watchdog */
/*
ipc_init -- initialize server, setting the global msqid that can be listened on.
*/
void
ipc_init (struct msgbuf **msgpp)
{
key_t key; /* messge key */
char buf[GSERV_BUFSZ]; /* pathname for key */
sprintf (buf,"/tmp/gsrv%d",(int)geteuid ());
creat (buf,0600);
key = ftok (buf,1);
if ((ipc_qid = msgget (key,0600|IPC_CREAT)) == -1)
{
perror (progname);
fprintf (stderr, "%s: unable to create msg queue\n", progname);
ipc_exit (1);
} /* if */
ipc_spawn_watchdog ();
signal (SIGTERM,ipc_handle_signal);
signal (SIGINT,ipc_handle_signal);
if ((*msgpp = (struct msgbuf *)
malloc (sizeof **msgpp + GSERV_BUFSZ)) == NULL)
{
fprintf (stderr,
"%s: unable to allocate space for message buffer\n", progname);
ipc_exit(1);
} /* if */
} /* ipc_init */
/*
handle_ipc_request -- accept a request from a client, pass the request on
to the GNU Emacs process, then wait for its reply and
pass that on to the client.
*/
void
handle_ipc_request (struct msgbuf *msgp)
{
struct msqid_ds msg_st; /* message status */
char buf[GSERV_BUFSZ];
int len; /* length of message / read */
int s, result_len; /* tag fields on the response from emacs */
int offset = 0;
int total = 1; /* # bytes that will actually be sent off */
if ((len = msgrcv (ipc_qid, msgp, GSERV_BUFSZ - 1, 1, 0)) < 0)
{
perror (progname);
fprintf (stderr, "%s: unable to receive\n", progname);
ipc_exit (1);
} /* if */
msgctl (ipc_qid, IPC_STAT, &msg_st);
strncpy (buf, msgp->mtext, len);
buf[len] = '\0'; /* terminate */
printf ("%d %s", ipc_qid, buf);
fflush (stdout);
/* now for the response from gnu */
msgp->mtext[0] = '\0';
#if 0
if ((len = read(0,buf,GSERV_BUFSZ-1)) < 0)
{
perror (progname);
fprintf (stderr, "%s: unable to read\n", progname);
ipc_exit (1);
} /* if */
sscanf (buf, "%d:%[^\n]\n", &junk, msgp->mtext);
#else
/* read in "n/m:" (n=client fd, m=message length) */
while (offset < (GSERV_BUFSZ-1) &&
((len = read (0, buf + offset, 1)) > 0) &&
buf[offset] != ':')
{
offset += len;
}
if (len < 0)
{
perror (progname);
fprintf (stderr, "%s: unable to read\n", progname);
exit(1);
}
/* parse the response from emacs, getting client fd & result length */
buf[offset] = '\0';
sscanf (buf, "%d/%d", &s, &result_len);
while (result_len > 0)
{
if ((len = read(0, buf, min2 (result_len, GSERV_BUFSZ - 1))) < 0)
{
perror (progname);
fprintf (stderr, "%s: unable to read\n", progname);
exit (1);
}
/* Send this string off, but only if we have enough space */
if (GSERV_BUFSZ > total)
{
if (total + len <= GSERV_BUFSZ)
buf[len] = 0;
else
buf[GSERV_BUFSZ - total] = 0;
send_string(s,buf);
total += strlen(buf);
}
result_len -= len;
}
/* eat the newline */
while ((len = read (0,buf,1)) == 0)
;
if (len < 0)
{
perror(progname);
fprintf (stderr,"%s: unable to read\n", progname);
exit (1);
}
if (buf[0] != '\n')
{
fprintf (stderr,"%s: garbage after result [%c]\n", progname, buf[0]);
exit (1);
}
#endif
/* Send a response back to the client. */
msgp->mtype = msg_st.msg_lspid;
if (msgsnd (ipc_qid,msgp,strlen(msgp->mtext)+1,0) < 0)
perror ("msgsend(gnuserv)");
} /* handle_ipc_request */
#endif /* SYSV_IPC */
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
echo_request -- read request from a given socket descriptor, and send the information
to stdout (the gnu process).
*/
static void
echo_request (int s)
{
char buf[GSERV_BUFSZ];
int len;
printf("%d ",s);
/* read until we get a newline or no characters */
while ((len = recv(s,buf,GSERV_BUFSZ-1,0)) > 0) {
buf[len] = '\0';
printf("%s",buf);
if (buf[len-1] == EOT_CHR) {
fflush(stdout);
break; /* end of message */
}
} /* while */
if (len < 0) {
perror(progname);
fprintf(stderr,"%s: unable to recv\n",progname);
exit(1);
} /* if */
} /* echo_request */
/*
handle_response -- accept a response from stdin (the gnu process) and pass the
information on to the relevant client.
*/
static void
handle_response (void)
{
char buf[GSERV_BUFSZ+1];
int offset=0;
int s;
int len;
int result_len;
/* read in "n/m:" (n=client fd, m=message length) */
while (offset < GSERV_BUFSZ &&
((len = read(0,buf+offset,1)) > 0) &&
buf[offset] != ':') {
offset += len;
}
if (len < 0) {
perror(progname);
fprintf(stderr,"%s: unable to read\n",progname);
exit(1);
}
/* parse the response from emacs, getting client fd & result length */
buf[offset] = '\0';
sscanf(buf,"%d/%d", &s, &result_len);
while (result_len > 0) {
if ((len = read(0,buf,min2(result_len,GSERV_BUFSZ))) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to read\n",progname);
exit(1);
}
buf[len] = '\0';
send_string(s,buf);
result_len -= len;
}
/* eat the newline */
while ((len = read(0,buf,1)) == 0)
;
if (len < 0)
{
perror(progname);
fprintf(stderr,"%s: unable to read\n",progname);
exit(1);
}
if (buf[0] != '\n')
{
fprintf(stderr,"%s: garbage after result\n",progname);
exit(1);
}
/* send the newline */
buf[1] = '\0';
send_string(s,buf);
close(s);
} /* handle_response */
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
#ifdef INTERNET_DOMAIN_SOCKETS
struct entry {
u_long host_addr;
struct entry *next;
};
struct entry *permitted_hosts[TABLE_SIZE];
#ifdef AUTH_MAGIC_COOKIE
# include <X11/X.h>
# include <X11/Xauth.h>
static Xauth *server_xauth = NULL;
#endif
static int
timed_read (int fd, char *buf, int max, int timeout, int one_line)
{
fd_set rmask;
struct timeval tv; /* = {timeout, 0}; */
char c = 0;
int nbytes = 0;
int r;
tv.tv_sec = timeout;
tv.tv_usec = 0;
FD_ZERO(&rmask);
FD_SET(fd, &rmask);
do
{
r = select(fd + 1, &rmask, NULL, NULL, &tv);
if (r > 0)
{
if (read (fd, &c, 1) == 1 )
{
*buf++ = c;
++nbytes;
}
else
{
printf ("read error on socket\004\n");
return -1;
}
}
else if (r == 0)
{
printf ("read timed out\004\n");
return -1;
}
else
{
printf ("error in select\004\n");
return -1;
}
} while ((nbytes < max) && !(one_line && (c == '\n')));
--buf;
if (one_line && *buf == '\n')
{
*buf = 0;
}
return nbytes;
}
/*
permitted -- return whether a given host is allowed to connect to the server.
*/
static int
permitted (u_long host_addr, int fd)
{
int key;
struct entry *entry;
char auth_protocol[128];
char buf[1024];
int auth_data_len;
if (fd > 0)
{
/* we are checking permission on a real connection */
/* Read auth protocol name */
if (timed_read(fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0)
return FALSE;
if (strcmp (auth_protocol, DEFAUTH_NAME) &&
strcmp (auth_protocol, MCOOKIE_NAME))
{
printf ("authentication protocol (%s) from client is invalid...\n",
auth_protocol);
printf ("... Was the client an old version of gnuclient/gnudoit?\004\n");
return FALSE;
}
if (!strcmp(auth_protocol, MCOOKIE_NAME))
{
/*
* doing magic cookie auth
*/
if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0)
return FALSE;
auth_data_len = atoi(buf);
if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len)
return FALSE;
#ifdef AUTH_MAGIC_COOKIE
if (server_xauth && server_xauth->data &&
!memcmp(buf, server_xauth->data, auth_data_len))
{
return TRUE;
}
#else
printf ("client tried Xauth, but server is not compiled with Xauth\n");
#endif
/*
* auth failed, but allow this to fall through to the GNU_SECURE
* protocol....
*/
printf ("Xauth authentication failed, trying GNU_SECURE auth...\004\n");
}
/* Other auth protocols go here, and should execute only if the
* auth_protocol name matches.
*/
}
/* Now, try the old GNU_SECURE stuff... */
/* First find the hash key */
key = HASH(host_addr) % TABLE_SIZE;
/* Now check the chain for that hash key */
for(entry=permitted_hosts[key]; entry != NULL; entry=entry->next)
if (host_addr == entry->host_addr)
return(TRUE);
return(FALSE);
} /* permitted */
/*
add_host -- add the given host to the list of permitted hosts, provided it isn't
already there.
*/
static void
add_host (u_long host_addr)
{
int key;
struct entry *new_entry;
if (!permitted(host_addr, -1))
{
if ((new_entry = (struct entry *) malloc(sizeof(struct entry))) == NULL) {
fprintf(stderr,"%s: unable to malloc space for permitted host entry\n",
progname);
exit(1);
} /* if */
new_entry->host_addr = host_addr;
key = HASH(host_addr) % TABLE_SIZE;
new_entry->next = permitted_hosts[key];
permitted_hosts[key] = new_entry;
} /* if */
} /* add_host */
/*
setup_table -- initialise the table of hosts allowed to contact the server,
by reading from the file specified by the GNU_SECURE
environment variable
Put in the local machine, and, if a security file is specifed,
add each host that is named in the file.
Return the number of hosts added.
*/
static int
setup_table (void)
{
FILE *host_file;
char *file_name;
char hostname[HOSTNAMSZ];
u_int host_addr;
int i, hosts=0;
/* Make sure every entry is null */
for (i=0; i<TABLE_SIZE; i++)
permitted_hosts[i] = NULL;
gethostname(hostname,HOSTNAMSZ);
if ((host_addr = internet_addr(hostname)) == -1)
{
fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP",
progname,hostname);
exit(1);
} /* if */
#ifdef AUTH_MAGIC_COOKIE
server_xauth = XauGetAuthByAddr (FamilyInternet,
sizeof(host_addr), (char *)&host_addr,
strlen(MCOOKIE_SCREEN), MCOOKIE_SCREEN,
strlen(MCOOKIE_X_NAME), MCOOKIE_X_NAME);
hosts++;
#endif /* AUTH_MAGIC_COOKIE */
#if 0 /* Don't even want to allow access from the local host by default */
add_host(host_addr); /* add local host */
#endif
if (((file_name = getenv("GNU_SECURE")) != NULL && /* security file */
(host_file = fopen(file_name,"r")) != NULL)) /* opened ok */
{
while ((fscanf(host_file,"%s",hostname) != EOF)) /* find a host */
if ((host_addr = internet_addr(hostname)) != -1)/* get its addr */
{
add_host(host_addr); /* add the addr */
hosts++;
}
fclose(host_file);
} /* if */
return hosts;
} /* setup_table */
/*
internet_init -- initialize server, returning an internet socket that can
be listened on.
*/
static int
internet_init (void)
{
int ls; /* socket descriptor */
struct servent *sp; /* pointer to service information */
struct sockaddr_in server; /* for local socket address */
char *ptr; /* ptr to return from getenv */
if (setup_table() == 0)
return -1;
/* clear out address structure */
memset((char *)&server,0,sizeof(struct sockaddr_in));
/* Set up address structure for the listen socket. */
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
/* Find the information for the gnu server
* in order to get the needed port number.
*/
if ((ptr=getenv("GNU_PORT")) != NULL)
server.sin_port = htons(atoi(ptr));
else if ((sp = getservbyname ("gnuserv", "tcp")) == NULL)
server.sin_port = htons(DEFAULT_PORT+getuid());
else
server.sin_port = sp->s_port;
/* Create the listen socket. */
if ((ls = socket (AF_INET,SOCK_STREAM, 0)) == -1)
{
perror(progname);
fprintf(stderr,"%s: unable to create socket\n",progname);
exit(1);
} /* if */
/* Bind the listen address to the socket. */
if (bind(ls,(struct sockaddr *) &server,sizeof(struct sockaddr_in)) == -1)
{
perror(progname);
fprintf(stderr,"%s: unable to bind socket\n",progname);
exit(1);
} /* if */
/* Initiate the listen on the socket so remote users
* can connect.
*/
if (listen(ls,20) == -1)
{
perror(progname);
fprintf(stderr,"%s: unable to listen\n",progname);
exit(1);
} /* if */
return(ls);
} /* internet_init */
/*
handle_internet_request -- accept a request from a client and send the information
to stdout (the gnu process).
*/
static void
handle_internet_request (int ls)
{
int s;
size_t addrlen = sizeof(struct sockaddr_in);
struct sockaddr_in peer; /* for peer socket address */
memset((char *)&peer,0,sizeof(struct sockaddr_in));
if ((s = accept(ls,(struct sockaddr *)&peer, (void *) &addrlen)) == -1)
{
perror(progname);
fprintf(stderr,"%s: unable to accept\n",progname);
exit(1);
} /* if */
/* Check that access is allowed - if not return crud to the client */
if (!permitted(peer.sin_addr.s_addr, s))
{
send_string(s,"gnudoit: Connection refused\ngnudoit: unable to connect to remote");
close(s);
printf("Refused connection from %s\004\n", inet_ntoa(peer.sin_addr));
return;
} /* if */
echo_request(s);
} /* handle_internet_request */
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef UNIX_DOMAIN_SOCKETS
/*
unix_init -- initialize server, returning an unix-domain socket that can
be listened on.
*/
static int
unix_init (void)
{
int ls; /* socket descriptor */
struct sockaddr_un server; /* unix socket address */
int bindlen;
if ((ls = socket(AF_UNIX,SOCK_STREAM, 0)) < 0)
{
perror(progname);
fprintf(stderr,"%s: unable to create socket\n",progname);
exit(1);
} /* if */
/* Set up address structure for the listen socket. */
#ifdef HIDE_UNIX_SOCKET
sprintf(server.sun_path,"/tmp/gsrvdir%d",(int)geteuid());
if (mkdir(server.sun_path, 0700) < 0)
{
/* assume it already exists, and try to set perms */
if (chmod(server.sun_path, 0700) < 0)
{
perror(progname);
fprintf(stderr,"%s: can't set permissions on %s\n",
progname, server.sun_path);
exit(1);
}
}
strcat(server.sun_path,"/gsrv");
unlink(server.sun_path); /* remove old file if it exists */
#else /* HIDE_UNIX_SOCKET */
sprintf(server.sun_path,"/tmp/gsrv%d",(int)geteuid());
unlink(server.sun_path); /* remove old file if it exists */
#endif /* HIDE_UNIX_SOCKET */
server.sun_family = AF_UNIX;
#ifdef HAVE_SOCKADDR_SUN_LEN
/* See W. R. Stevens "Advanced Programming in the Unix Environment"
p. 502 */
bindlen = (sizeof (server.sun_len) + sizeof (server.sun_family)
+ strlen (server.sun_path) + 1);
server.sun_len = bindlen;
#else
bindlen = strlen (server.sun_path) + sizeof (server.sun_family);
#endif
if (bind(ls,(struct sockaddr *)&server,bindlen) < 0)
{
perror(progname);
fprintf(stderr,"%s: unable to bind socket\n",progname);
exit(1);
} /* if */
chmod(server.sun_path,0700); /* only this user can send commands */
if (listen(ls,20) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to listen\n",progname);
exit(1);
} /* if */
/* #### there are also better ways of dealing with this when
sigvec() is present. */
#if defined (HAVE_SIGPROCMASK)
{
sigset_t _mask;
sigemptyset (&_mask);
sigaddset (&_mask, SIGPIPE);
sigprocmask (SIG_BLOCK, &_mask, NULL);
}
#else
signal(SIGPIPE,SIG_IGN); /* in case user kills client */
#endif
return(ls);
} /* unix_init */
/*
handle_unix_request -- accept a request from a client and send the information
to stdout (the gnu process).
*/
static void
handle_unix_request (int ls)
{
int s;
size_t len = sizeof(struct sockaddr_un);
struct sockaddr_un server; /* for unix socket address */
server.sun_family = AF_UNIX;
if ((s = accept(ls,(struct sockaddr *)&server, (void *)&len)) < 0)
{
perror(progname);
fprintf(stderr,"%s: unable to accept\n",progname);
} /* if */
echo_request(s);
} /* handle_unix_request */
#endif /* UNIX_DOMAIN_SOCKETS */
int
main(argc,argv)
int argc;
char *argv[];
{
int chan; /* temporary channel number */
#ifdef INTERNET_DOMAIN_SOCKETS
int ils = -1; /* internet domain listen socket */
#endif
#ifdef UNIX_DOMAIN_SOCKETS
int uls = -1; /* unix domain listen socket */
#endif
#ifdef SYSV_IPC
struct msgbuf *msgp; /* message buffer */
#endif /* SYSV_IPC */
progname = argv[0];
for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */
;
#ifdef SYSV_IPC
ipc_init(&msgp); /* get a msqid to listen on, and a message buffer */
#endif /* SYSV_IPC */
#ifdef INTERNET_DOMAIN_SOCKETS
ils = internet_init(); /* get a internet domain socket to listen on */
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef UNIX_DOMAIN_SOCKETS
uls = unix_init(); /* get a unix domain socket to listen on */
#endif /* UNIX_DOMAIN_SOCKETS */
while (1) {
#ifdef SYSV_IPC
handle_ipc_request(msgp);
#else /* NOT SYSV_IPC */
fd_set rmask;
FD_ZERO(&rmask);
FD_SET(fileno(stdin), &rmask);
if (uls >= 0)
FD_SET(uls, &rmask);
if (ils >= 0)
FD_SET(ils, &rmask);
if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask,
(fd_set *)NULL, (fd_set *)NULL, (struct timeval *)NULL) < 0)
{
perror(progname);
fprintf(stderr,"%s: unable to select\n",progname);
exit(1);
} /* if */
#ifdef UNIX_DOMAIN_SOCKETS
if (uls > 0 && FD_ISSET(uls, &rmask))
handle_unix_request(uls);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS
if (ils > 0 && FD_ISSET(ils, &rmask))
handle_internet_request(ils);
#endif /* INTERNET_DOMAIN_SOCKETS */
if (FD_ISSET(fileno(stdin), &rmask)) /* from stdin (gnu process) */
handle_response();
#endif /* NOT SYSV_IPC */
} /* while */
return 0;
} /* main */
#endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */

190
src/daemon/gnuserv.h Normal file
View File

@@ -0,0 +1,190 @@
/* -*-C-*-
Header file for the GNU Emacs server and client C code.
This file is part of GNU Emacs.
Copying is permitted under those conditions described by the GNU
General Public License.
Copyright (C) 1989 Free Software Foundation, Inc.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
/* HISTORY
* 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
/*
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
* Please see the note at the end of the README file for details.
*
* (If gnuserv came bundled with your emacs, the README file is probably
* ../etc/gnuserv.README relative to the directory containing this file)
*/
#if 0
static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup alpha !";
#endif
#define NO_SHORTNAMES
#define PATCHLEVEL 2
#define NO_SHORTNAMES
/* gnuserv should not be compiled using SOCKS */
#define DO_NOT_SOCKSIFY
#include <glibtop/global.h>
#undef read
#undef write
#undef open
#undef close
#undef signal
/* Define the communication method between server and clients:
* You can have either or both kinds of sockets, but you can't mix
* sockets with sysv ipc
*/
#define INTERNET_DOMAIN_SOCKETS
#define UNIX_DOMAIN_SOCKETS
/* #define SYSV_IPC */
/*
* Define additional authentication protocols to be used. These methods will
* be tried before falling back to the default gnuserv protocol (based on
* the GNU_SECURE environment variable). Currently, only MIT-MAGIC-COOKIE-1
* is also supported.
*
* Comment out the next line(s) if you don't want to enable the
* appropriate authentication protocol.
*/
#if defined (HAVE_XAUTH)
#define AUTH_MAGIC_COOKIE
#endif /* HAVE_XAUTH */
/*
* stuff related to supporting MIT-MAGIC-COOKIE-1
*/
#define MCOOKIE_SCREEN "999" /* screen # to use as the gnuserv cookie */
#define MCOOKIE_NAME "MAGIC-1" /* authentication protocol name */
#define MCOOKIE_X_NAME "MIT-MAGIC-COOKIE-1" /* as needed by X */
#define DEFAUTH_NAME "GNU-SECURE" /* name of default auth protocol */
#define AUTH_TIMEOUT 15 /* # seconds to wait for auth data */
#define AUTH_NAMESZ 15 /* max allows auth protocol name size */
/*
* Pick a default communication scheme, if none was specified.
*/
#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS)
#ifdef HAVE_SYSVIPC
#define SYSV_IPC /* SYSV systems use SYSV IPC by default */
#endif /* HAVE_SYSVIPC */
#ifdef BSD
#define UNIX_DOMAIN_SOCKETS /* BSD systems use Unix Domain sockets by default */
#endif /* BSD */
#endif /* No communication method pre-defined */
/*
* If you are using SYSV_IPC, you might want to make the buffer size bigger
* since it limits the size of requests and responses. Don't make it bigger
* than your system's max message size though (usually a couple of k) or else
* msgsend will start failing. For sockets, using the system BUFSIZ is usually
* what you want.
*/
# define GSERV_BUFSZ BUFSIZ
#ifdef SYSV_IPC
#include <sys/ipc.h>
#include <sys/msg.h>
#define send_string(s,str) \
if (strlen(msgp->mtext) + strlen(str) < GSERV_BUFSZ) \
strcat(msgp->mtext,str); \
else \
{ \
fprintf(stderr,"%s: not enough message buffer space\n",progname); \
exit(1); \
} \
#endif /* SYSV_IPC */
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
#include <sys/socket.h>
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
#ifdef INTERNET_DOMAIN_SOCKETS
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define TABLE_SIZE 101 /* The number of entries in the hash table */
#define HASH(host) host /* Rather simplistic hash function */
#define DEFAULT_PORT 21490 /* default port number to use is
* DEFAULT_PORT + uid */
#endif /* INTERNET_DOMAIN_SOCKETS */
#ifdef UNIX_DOMAIN_SOCKETS
#include <sys/un.h>
#define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */
#endif /* UNIX_DOMAIN_SOCKETS */
#define HOSTNAMSZ 255 /* max size of a hostname */
#define REPLYSIZ 300 /* max size of reply from server to client */
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE 1
extern char *optarg;
extern int optind;
extern char *progname;
/* The casts shut Sun's compiler up and are safe in the context these
are actually used. */
#define max2(x,y) (((int) (x) > (int) (y)) ? (x) : (y))
#define min2(x,y) (((int) (x) < (int) (y)) ? (x) : (y))
#ifndef _NFILE /* rough guess at maximum number of open files */
#define _NFILE 20
#endif
#define EOT_STR "\004"
#define EOT_CHR '\004'
/* connection types */
#define CONN_UNIX 0
#define CONN_INTERNET 1
#define CONN_IPC 2
/* function declarations */
int make_connection (char *hostarg, int portarg, int *s);
#ifdef SYSV_IPC
void disconnect_from_ipc_server();
#endif
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
void send_string (int s, const char *msg);
void disconnect_from_server (int s, int echo);
int read_line (int s, char *dest);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS
int internet_addr (char *host);
#endif

454
src/daemon/gnuslib.c Normal file
View File

@@ -0,0 +1,454 @@
/* -*-C-*-
Common library code for the GNU Emacs server and client.
This file is part of GNU Emacs.
Copying is permitted under those conditions described by the GNU
General Public License.
Copyright (C) 1989 Free Software Foundation, Inc.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
/* HISTORY
* 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
/*
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
* Please see the note at the end of the README file for details.
*
* (If gnuserv came bundled with your emacs, the README file is probably
* ../etc/gnuserv.README relative to the directory containing this file)
*/
#if 0
static char rcsid [] = "!Header: gnuslib.c,v 2.4 95/02/16 11:57:37 arup alpha !";
#endif
#include "gnuserv.h"
#include <errno.h>
#ifdef SYSV_IPC
static int connect_to_ipc_server (void);
#endif
#ifdef UNIX_DOMAIN_SOCKETS
static int connect_to_unix_server (void);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS
static int connect_to_internet_server (char *serverhost, u_short port);
#endif
/* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */
#ifdef HAVE_BROKEN_INET_ADDR
# define IN_ADDR struct in_addr
# define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1)
#else
# if (LONGBITS > 32)
# define IN_ADDR unsigned int
# else
# define IN_ADDR unsigned long
# endif
# define NUMERIC_ADDR_ERROR (numeric_addr == (IN_ADDR) -1)
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#include <arpa/inet.h>
char *progname = NULL;
int make_connection(hostarg, portarg, s)
char *hostarg;
int portarg;
int *s;
{
#ifdef INTERNET_DOMAIN_SOCKETS
char *ptr;
if (hostarg == NULL)
hostarg = getenv("GNU_HOST");
if (portarg == 0 && (ptr=getenv("GNU_PORT")) != NULL)
portarg = atoi(ptr);
#endif
if (hostarg != NULL) {
/* hostname was given explicitly, via cmd line arg or GNU_HOST,
* so obey it. */
#ifdef UNIX_DOMAIN_SOCKETS
if (!strcmp(hostarg, "unix")) {
*s = connect_to_unix_server();
return (int) CONN_UNIX;
}
#endif /* UNIX_DOMAIN_SOCKETS */
#ifdef INTERNET_DOMAIN_SOCKETS
*s = connect_to_internet_server(hostarg, portarg);
return (int) CONN_INTERNET;
#endif
#ifdef SYSV_IPC
return -1; /* hostarg should always be NULL for SYSV_IPC */
#endif
} else {
/* no hostname given. Use unix-domain/sysv-ipc, or
* internet-domain connection to local host if they're not available. */
#if defined(UNIX_DOMAIN_SOCKETS)
*s = connect_to_unix_server();
return (int) CONN_UNIX;
#elif defined(SYSV_IPC)
*s = connect_to_ipc_server();
return (int) CONN_IPC;
#elif defined(INTERNET_DOMAIN_SOCKETS)
{
char localhost[HOSTNAMSZ];
gethostname(localhost,HOSTNAMSZ); /* use this host by default */
*s = connect_to_internet_server(localhost, portarg);
return (int) CONN_INTERNET;
}
#endif /* IPC type */
}
}
#ifdef SYSV_IPC
/*
connect_to_ipc_server -- establish connection with server process via SYSV IPC
Returns msqid for server if successful.
*/
static int connect_to_ipc_server (void)
{
int s; /* connected msqid */
key_t key; /* message key */
char buf[GSERV_BUFSZ+1]; /* buffer for filename */
sprintf(buf,"/tmp/gsrv%d",(int)geteuid());
creat(buf,0600);
if ((key = ftok(buf,1)) == -1) {
perror(progname);
fprintf(stderr, "%s: unable to get ipc key from %s\n",
progname, buf);
exit(1);
}
if ((s = msgget(key,0600)) == -1) {
perror(progname);
fprintf(stderr,"%s: unable to access msg queue\n",progname);
exit(1);
}; /* if */
return(s);
} /* connect_to_ipc_server */
/*
disconnect_from_ipc_server -- inform the server that sending has finished,
and wait for its reply.
*/
void disconnect_from_ipc_server(s,msgp,echo)
int s;
struct msgbuf *msgp;
int echo;
{
int len; /* length of received message */
send_string(s,EOT_STR); /* EOT terminates this message */
msgp->mtype = 1;
if(msgsnd(s,msgp,strlen(msgp->mtext)+1,0) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to send message to server\n",progname);
exit(1);
}; /* if */
if((len = msgrcv(s,msgp,GSERV_BUFSZ,getpid(),0)) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to receive message from server\n",progname);
exit(1);
}; /* if */
if (echo) {
msgp->mtext[len] = '\0'; /* string terminate message */
fputs(msgp->mtext, stdout);
if (msgp->mtext[len-1] != '\n') putchar ('\n');
}; /* if */
} /* disconnect_from_ipc_server */
#endif /* SYSV_IPC */
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
send_string -- send string to socket.
*/
void send_string(s,msg)
int s;
const char *msg;
{
#if 0
if (send(s,msg,strlen(msg),0) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to send\n",progname);
exit(1);
}; /* if */
#else
int len, left=strlen(msg);
while (left > 0) {
if ((len=write(s,msg,min2(left,GSERV_BUFSZ))) < 0) {
/* XEmacs addition: robertl@arnet.com */
if (errno == EPIPE) {
return ;
}
perror(progname);
fprintf(stderr,"%s: unable to send\n",progname);
exit(1);
}; /* if */
left -= len;
msg += len;
}; /* while */
#endif
} /* send_string */
/*
read_line -- read a \n terminated line from a socket
*/
int read_line(int s, char *dest)
{
int length;
int offset=0;
char buffer[GSERV_BUFSZ+1];
while ((length=read(s,buffer+offset,1)>0) && buffer[offset]!='\n'
&& buffer[offset] != EOT_CHR) {
offset += length;
if (offset >= GSERV_BUFSZ)
break;
}
buffer[offset] = '\0';
strcpy(dest,buffer);
return 1;
} /* read_line */
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
#ifdef UNIX_DOMAIN_SOCKETS
/*
connect_to_unix_server -- establish connection with server process via a unix-
domain socket. Returns socket descriptor for server
if successful.
*/
static int connect_to_unix_server (void)
{
int s; /* connected socket descriptor */
struct sockaddr_un server; /* for unix connections */
if ((s = socket(AF_UNIX,SOCK_STREAM,0)) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to create socket\n",progname);
exit(1);
}; /* if */
server.sun_family = AF_UNIX;
#ifdef HIDE_UNIX_SOCKET
sprintf(server.sun_path,"/tmp/gsrvdir%d/gsrv",(int)geteuid());
#else /* HIDE_UNIX_SOCKET */
sprintf(server.sun_path,"/tmp/gsrv%d",(int)geteuid());
#endif /* HIDE_UNIX_SOCKET */
if (connect(s,(struct sockaddr *)&server,strlen(server.sun_path)+2) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to connect to local\n",progname);
exit(1);
}; /* if */
return(s);
} /* connect_to_unix_server */
#endif /* UNIX_DOMAIN_SOCKETS */
#ifdef INTERNET_DOMAIN_SOCKETS
/*
internet_addr -- return the internet addr of the hostname or
internet address passed. Return -1 on error.
*/
int internet_addr(host)
char *host;
{
struct hostent *hp; /* pointer to host info for remote host */
IN_ADDR numeric_addr; /* host address */
numeric_addr = inet_addr(host);
if (!NUMERIC_ADDR_ERROR)
return numeric_addr;
else if ((hp = gethostbyname(host)) != NULL)
return ((struct in_addr *)(hp->h_addr))->s_addr;
else
return -1;
} /* internet_addr */
#ifdef AUTH_MAGIC_COOKIE
# include <X11/X.h>
# include <X11/Xauth.h>
static Xauth *server_xauth = NULL;
#endif
/*
connect_to_internet_server -- establish connection with server process via
an internet domain socket. Returns socket
descriptor for server if successful.
*/
static int connect_to_internet_server (char *serverhost, u_short port)
{
int s; /* connected socket descriptor */
struct servent *sp; /* pointer to service information */
struct sockaddr_in peeraddr_in; /* for peer socket address */
char buf[512]; /* temporary buffer */
/* clear out address structures */
memset((char *)&peeraddr_in,0,sizeof(struct sockaddr_in));
/* Set up the peer address to which we will connect. */
peeraddr_in.sin_family = AF_INET;
/* look up the server host's internet address */
if ((peeraddr_in.sin_addr.s_addr = internet_addr(serverhost)) == -1) {
fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP\n",
progname,serverhost);
exit(1);
}; /* if */
if (port == 0) {
if ((sp = getservbyname ("gnuserv","tcp")) == NULL)
peeraddr_in.sin_port = htons(DEFAULT_PORT+getuid());
else
peeraddr_in.sin_port = sp->s_port;
} /* if */
else
peeraddr_in.sin_port = htons(port);
/* Create the socket. */
if ((s = socket (AF_INET,SOCK_STREAM, 0))== -1) {
perror(progname);
fprintf(stderr,"%s: unable to create socket\n",progname);
exit(1);
}; /* if */
/* Try to connect to the remote server at the address
* which was just built into peeraddr.
*/
if (connect(s, (struct sockaddr *)&peeraddr_in,
sizeof(struct sockaddr_in)) == -1) {
perror(progname);
fprintf(stderr, "%s: unable to connect to remote\n",progname);
exit(1);
}; /* if */
#ifdef AUTH_MAGIC_COOKIE
/* send credentials using MIT-MAGIC-COOKIE-1 protocol */
server_xauth =
XauGetAuthByAddr(FamilyInternet,
sizeof(peeraddr_in.sin_addr.s_addr),
(char *) &peeraddr_in.sin_addr.s_addr,
strlen(MCOOKIE_SCREEN), MCOOKIE_SCREEN,
strlen(MCOOKIE_X_NAME), MCOOKIE_X_NAME);
if (server_xauth && server_xauth->data) {
sprintf(buf, "%s\n%d\n", MCOOKIE_NAME, server_xauth->data_length);
write (s, buf, strlen(buf));
write (s, server_xauth->data, server_xauth->data_length);
return (s);
}
#endif /* AUTH_MAGIC_COOKIE */
sprintf (buf, "%s\n", DEFAUTH_NAME);
write (s, buf, strlen(buf));
return(s);
} /* connect_to_internet_server */
#endif /* INTERNET_DOMAIN_SOCKETS */
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
disconnect_from_server -- inform the server that sending has finished, and wait for
its reply.
*/
void disconnect_from_server(s,echo)
int s;
int echo;
{
#if 0
char buffer[REPLYSIZ+1];
#else
char buffer[GSERV_BUFSZ+1];
#endif
int add_newline = 1;
int length;
send_string(s,EOT_STR); /* make sure server gets string */
#if !defined (linux) && !defined (_SCO_DS)
/*
* shutdown is completely hozed under linux. If s is a unix domain socket,
* you'll get EOPNOTSUPP back from it. If s is an internet socket, you get
* a broken pipe when you try to read a bit later. The latter
* problem is fixed for linux versions >= 1.1.46, but the problem
* with unix sockets persists. Sigh.
*/
if (shutdown(s,1) == -1) {
perror(progname);
fprintf(stderr, "%s: unable to shutdown socket\n",progname);
exit(1);
}; /* if */
#endif
#if 0
while((length = recv(s,buffer,REPLYSIZ,0)) > 0) {
buffer[length] = '\0';
if (echo) fputs(buffer,stdout);
add_newline = (buffer[length-1] != '\n');
}; /* while */
#else
while ((length = read(s,buffer,GSERV_BUFSZ)) > 0 ||
(length == -1 && errno == EINTR)) {
if (length) {
buffer[length] = '\0';
if (echo) {
fputs(buffer,stdout);
add_newline = (buffer[length-1] != '\n');
}; /* if */
}; /* if */
}; /* while */
#endif
if (echo && add_newline) putchar('\n');
if(length < 0) {
perror(progname);
fprintf(stderr,"%s: unable to read the reply from the server\n",progname);
exit(1);
}; /* if */
} /* disconnect_from_server */
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */

5
src/proxy/.cvsignore Normal file
View File

@@ -0,0 +1,5 @@
.deps
.libs
Makefile
Makefile.in
gtop_proxy

16
src/proxy/Makefile.am Normal file
View File

@@ -0,0 +1,16 @@
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\"
bin_PROGRAMS = gtop_proxy
gtop_proxy_SOURCES = main.c output.c version.c
gtop_proxy_LDADD = $(top_builddir)/lib/libgtop.la \
$(top_builddir)/sysdeps/common/libgtop_common.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \
@INTLLIBS@ @LIBSUPPORT@
gtop_proxy_LDFLAGS = -static

234
src/proxy/main.c Normal file
View File

@@ -0,0 +1,234 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop/command.h>
#include <glibtop/version.h>
#include <glibtop/xmalloc.h>
#include <glibtop/union.h>
#include <glibtop/open.h>
#include <fcntl.h>
#include <locale.h>
#if defined(HAVE_GETDTABLESIZE)
#define GET_MAX_FDS() getdtablesize()
#else
/* Fallthrough case - please add other #elif cases above
for different OS's as necessary */
#define GET_MAX_FDS() 256
#endif
int
main(int argc, char *argv[])
{
pid_t pid;
int fd, max_fd, nread;
size_t size, dsize;
char parameter [BUFSIZ];
glibtop_union data;
glibtop_command cmnd;
glibtop_sysdeps sysdeps;
glibtop server;
void *ptr;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, GTOPLOCALEDIR);
textdomain (PACKAGE);
glibtop_version ();
glibtop_open_l (&server, argv [0], 0, GLIBTOP_OPEN_NO_OVERRIDE);
/* close all file descriptors except ones used by the pipes (0 and 1). */
max_fd = GET_MAX_FDS();
for(fd = 3 /* The first fd after the pipes */; fd < max_fd; fd++)
close(fd);
while(1) {
/* block on read from client */
/* fprintf (stderr, "waiting for input ...\n"); */
nread = read (0, &size, sizeof (size_t));
/* will return 0 if parent exits. */
if (nread == 0)
_exit(0);
if (nread != sizeof (size_t))
_exit(1);
if (size != sizeof (glibtop_command))
_exit(2);
nread = read (0, &cmnd, size);
/* will return 0 if parent exits. */
if (nread == 0)
_exit(0);
if (nread < 0)
_exit(1);
nread = read (0, &dsize, sizeof (size_t));
/* will return 0 if parent exits. */
if (nread == 0)
_exit(0);
if (nread < 0)
_exit(1);
if (dsize >= BUFSIZ)
_exit(3);
memset (parameter, 0, sizeof (parameter));
if (dsize) {
nread = read (0, parameter, dsize);
/* will return 0 if parent exits. */
if (nread == 0)
_exit(0);
if (nread < 0)
_exit(1);
}
switch (cmnd.command) {
case GLIBTOP_CMND_SYSDEPS:
sysdeps.features = GLIBTOP_SYSDEPS_ALL;
glibtop_output (sizeof (glibtop_sysdeps), &sysdeps);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_CPU:
glibtop_get_cpu_l (&server, &data.cpu);
glibtop_output (sizeof (glibtop_cpu), &data.cpu);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_MEM:
glibtop_get_mem_l (&server, &data.mem);
glibtop_output (sizeof (glibtop_mem), &data.mem);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_SWAP:
glibtop_get_swap_l (&server, &data.swap);
glibtop_output (sizeof (glibtop_swap), &data.swap);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_UPTIME:
glibtop_get_uptime_l (&server, &data.uptime);
glibtop_output (sizeof (glibtop_uptime), &data.uptime);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_LOADAVG:
glibtop_get_loadavg_l (&server, &data.loadavg);
glibtop_output (sizeof (glibtop_loadavg), &data.loadavg);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_SHM_LIMITS:
glibtop_get_shm_limits_l (&server, &data.shm_limits);
glibtop_output (sizeof (glibtop_shm_limits),
&data.shm_limits);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_MSG_LIMITS:
glibtop_get_msg_limits_l (&server, &data.msg_limits);
glibtop_output (sizeof (glibtop_msg_limits),
&data.msg_limits);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_SEM_LIMITS:
glibtop_get_sem_limits_l (&server, &data.sem_limits);
glibtop_output (sizeof (glibtop_sem_limits),
&data.sem_limits);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROCLIST:
ptr = glibtop_get_proclist_l (&server, &data.proclist);
glibtop_output (sizeof (glibtop_proclist),
&data.proclist);
glibtop_output (data.proclist.total, ptr);
glibtop_free_r (&server, ptr);
break;
case GLIBTOP_CMND_PROC_STATE:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_state_l
(&server, &data.proc_state, pid);
glibtop_output (sizeof (glibtop_proc_state),
&data.proc_state);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_UID:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_uid_l
(&server, &data.proc_uid, pid);
glibtop_output (sizeof (glibtop_proc_uid),
&data.proc_uid);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_MEM:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_mem_l
(&server, &data.proc_mem, pid);
glibtop_output (sizeof (glibtop_proc_mem),
&data.proc_mem);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_TIME:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_time_l
(&server, &data.proc_time, pid);
glibtop_output (sizeof (glibtop_proc_time),
&data.proc_time);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_SIGNAL:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_signal_l
(&server, &data.proc_signal, pid);
glibtop_output (sizeof (glibtop_proc_signal),
&data.proc_signal);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_KERNEL:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_kernel_l
(&server, &data.proc_kernel, pid);
glibtop_output (sizeof (glibtop_proc_kernel),
&data.proc_kernel);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_SEGMENT:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_segment_l
(&server, &data.proc_segment, pid);
glibtop_output (sizeof (glibtop_proc_segment),
&data.proc_segment);
glibtop_output (0, NULL);
break;
}
}
_exit(0);
}

View File

@@ -19,14 +19,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop/cpu.h>
#include <glibtop/command.h>
/* Provides information about cpu usage. */
#include <glibtop/output.h>
void
glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf)
glibtop_output (size_t size, const void *buf)
{
glibtop_init__r (&server);
glibtop_call__r (server, GLIBTOP_CMND_CPU, 0, NULL, sizeof (glibtop_cpu), buf);
if (write (1, &size, sizeof (size_t)) < 0)
_exit (2);
if (write (1, buf, size) < 0)
_exit (2);
}

View File

@@ -19,14 +19,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop/mem.h>
#include <glibtop/command.h>
/* Provides information about memory usage. */
#include <glibtop/version.h>
void
glibtop_get_mem__r (glibtop *server, glibtop_mem *buf)
glibtop_version (void)
{
glibtop_init__r (&server);
glibtop_call__r (server, GLIBTOP_CMND_MEM, 0, NULL, sizeof (glibtop_mem), buf);
char buffer [BUFSIZ];
sprintf (buffer, "%s server %s ready.\n", PACKAGE, VERSION);
glibtop_output (strlen (buffer), buffer);
}

View File

@@ -26,6 +26,7 @@
#include <glibtop/open.h>
#include <fcntl.h>
#include <locale.h>
#if defined(HAVE_GETDTABLESIZE)
#define GET_MAX_FDS() getdtablesize()
@@ -73,7 +74,7 @@ int main(int argc, char *argv[])
setreuid (uid, euid); setregid (gid, egid);
glibtop_open (&server, argv [0]);
glibtop_open_r (&server, argv [0], 0, 0);
if (setreuid (euid, uid)) _exit (1);
@@ -141,112 +142,146 @@ int main(int argc, char *argv[])
switch (cmnd.command) {
case GLIBTOP_CMND_SYSDEPS:
glibtop_get_sysdeps__r (&server, &sysdeps);
sysdeps.features = GLIBTOP_SYSDEPS_ALL;
glibtop_output (sizeof (glibtop_sysdeps), &sysdeps);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_CPU:
glibtop_get_cpu__r (&server, &data.cpu);
#if GLIBTOP_SUID_CPU
glibtop_get_cpu_p (&server, &data.cpu);
#endif
glibtop_output (sizeof (glibtop_cpu), &data.cpu);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_MEM:
glibtop_get_mem__r (&server, &data.mem);
#if GLIBTOP_SUID_MEM
glibtop_get_mem_p (&server, &data.mem);
#endif
glibtop_output (sizeof (glibtop_mem), &data.mem);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_SWAP:
glibtop_get_swap__r (&server, &data.swap);
#if GLIBTOP_SUID_SWAP
glibtop_get_swap_p (&server, &data.swap);
#endif
glibtop_output (sizeof (glibtop_swap), &data.swap);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_UPTIME:
glibtop_get_uptime__r (&server, &data.uptime);
#if GLIBTOP_SUID_UPTIME
glibtop_get_uptime_p (&server, &data.uptime);
#endif
glibtop_output (sizeof (glibtop_uptime), &data.uptime);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_LOADAVG:
glibtop_get_loadavg__r (&server, &data.loadavg);
#if GLIBTOP_SUID_LOADAVG
glibtop_get_loadavg_p (&server, &data.loadavg);
#endif
glibtop_output (sizeof (glibtop_loadavg), &data.loadavg);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_SHM_LIMITS:
glibtop_get_shm_limits__r (&server, &data.shm_limits);
#if GLIBTOP_SUID_SHM_LIMITS
glibtop_get_shm_limits_p (&server, &data.shm_limits);
#endif
glibtop_output (sizeof (glibtop_shm_limits),
&data.shm_limits);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_MSG_LIMITS:
glibtop_get_msg_limits__r (&server, &data.msg_limits);
#if GLIBTOP_SUID_MSG_LIMITS
glibtop_get_msg_limits_p (&server, &data.msg_limits);
#endif
glibtop_output (sizeof (glibtop_msg_limits),
&data.msg_limits);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_SEM_LIMITS:
glibtop_get_sem_limits__r (&server, &data.sem_limits);
#if GLIBTOP_SUID_SEM_LIMITS
glibtop_get_sem_limits_p (&server, &data.sem_limits);
#endif
glibtop_output (sizeof (glibtop_sem_limits),
&data.sem_limits);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROCLIST:
ptr = glibtop_get_proclist__r (&server, &data.proclist);
#if GLIBTOP_SUID_PROCLIST
ptr = glibtop_get_proclist_p (&server, &data.proclist);
#else
ptr = NULL;
#endif
glibtop_output (sizeof (glibtop_proclist),
&data.proclist);
glibtop_output (data.proclist.total, ptr);
glibtop_free__r (&server, ptr);
glibtop_free_r (&server, ptr);
break;
case GLIBTOP_CMND_PROC_STATE:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_state__r
#if GLIBTOP_SUID_PROC_STATE
glibtop_get_proc_state_p
(&server, &data.proc_state, pid);
#endif
glibtop_output (sizeof (glibtop_proc_state),
&data.proc_state);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_UID:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_uid__r
#if GLIBTOP_SUID_PROC_UID
glibtop_get_proc_uid_p
(&server, &data.proc_uid, pid);
#endif
glibtop_output (sizeof (glibtop_proc_uid),
&data.proc_uid);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_MEM:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_mem__r
#if GLIBTOP_SUID_PROC_MEM
glibtop_get_proc_mem_p
(&server, &data.proc_mem, pid);
#endif
glibtop_output (sizeof (glibtop_proc_mem),
&data.proc_mem);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_TIME:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_time__r
#if GLIBTOP_SUID_PROC_TIME
glibtop_get_proc_time_p
(&server, &data.proc_time, pid);
#endif
glibtop_output (sizeof (glibtop_proc_time),
&data.proc_time);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_SIGNAL:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_signal__r
#if GLIBTOP_SUID_PROC_SIGNAL
glibtop_get_proc_signal_p
(&server, &data.proc_signal, pid);
#endif
glibtop_output (sizeof (glibtop_proc_signal),
&data.proc_signal);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_KERNEL:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_kernel__r
#if GLIBTOP_SUID_PROC_KERNEL
glibtop_get_proc_kernel_p
(&server, &data.proc_kernel, pid);
#endif
glibtop_output (sizeof (glibtop_proc_kernel),
&data.proc_kernel);
glibtop_output (0, NULL);
break;
case GLIBTOP_CMND_PROC_SEGMENT:
memcpy (&pid, parameter, sizeof (pid_t));
glibtop_get_proc_segment__r
#if GLIBTOP_SUID_PROC_SEGMENT
glibtop_get_proc_segment_p
(&server, &data.proc_segment, pid);
#endif
glibtop_output (sizeof (glibtop_proc_segment),
&data.proc_segment);
glibtop_output (0, NULL);

View File

@@ -12,4 +12,4 @@ endif
SUBDIRS = @sysdeps_dir@ common $(names_SUBDIRS) $(guile_SUBDIRS)
DIST_SUBDIRS = common guile linux names osf1 stub sun4
DIST_SUBDIRS = common guile linux kernel names osf1 stub sun4

View File

@@ -24,7 +24,7 @@
/* Prints error message and exits. */
void
glibtop_error__r (glibtop *server, char *format, ...)
glibtop_error_r (glibtop *server, char *format, ...)
{
va_list ap;
@@ -37,3 +37,46 @@ glibtop_error__r (glibtop *server, char *format, ...)
va_end (ap);
exit (1);
}
void
glibtop_error_io_r (glibtop *server, char *format, ...)
{
va_list ap;
va_start (ap, format);
fprintf (stderr, "%s: ", server->name);
vfprintf (stderr, format, ap);
fprintf (stderr, ": %s\n", strerror (errno));
va_end (ap);
exit (1);
}
void
glibtop_warn_r (glibtop *server, char *format, ...)
{
va_list ap;
va_start (ap, format);
fprintf (stderr, "%s: ", server->name);
vfprintf (stderr, format, ap);
fprintf (stderr, "\n");
va_end (ap);
}
void
glibtop_warn_io_r (glibtop *server, char *format, ...)
{
va_list ap;
va_start (ap, format);
fprintf (stderr, "%s: ", server->name);
vfprintf (stderr, format, ap);
fprintf (stderr, ": %s\n", strerror (errno));
va_end (ap);
}

456
sysdeps/common/gnuslib.c Normal file
View File

@@ -0,0 +1,456 @@
/* -*-C-*-
Common library code for the GNU Emacs server and client.
This file is part of GNU Emacs.
Copying is permitted under those conditions described by the GNU
General Public License.
Copyright (C) 1989 Free Software Foundation, Inc.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
/* HISTORY
* 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
/*
* This file incorporates new features added by Bob Weiner <weiner@mot.com>,
* Darrell Kindred <dkindred@cmu.edu> and Arup Mukherjee <arup@cmu.edu>.
* Please see the note at the end of the README file for details.
*
* (If gnuserv came bundled with your emacs, the README file is probably
* ../etc/gnuserv.README relative to the directory containing this file)
*/
#if 0
static char rcsid [] = "!Header: gnuslib.c,v 2.4 95/02/16 11:57:37 arup alpha !";
#endif
#include "gnuserv.h"
#include <errno.h>
#ifdef SYSV_IPC
static int connect_to_ipc_server (void);
#endif
#ifdef UNIX_DOMAIN_SOCKETS
static int connect_to_unix_server (void);
#endif
#ifdef INTERNET_DOMAIN_SOCKETS
static int connect_to_internet_server (char *serverhost, u_short port);
#endif
/* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */
#ifdef HAVE_BROKEN_INET_ADDR
# define IN_ADDR struct in_addr
# define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1)
#else
# if (LONGBITS > 32)
# define IN_ADDR unsigned int
# else
# define IN_ADDR unsigned long
# endif
# define NUMERIC_ADDR_ERROR (numeric_addr == (IN_ADDR) -1)
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#include <arpa/inet.h>
char *progname = NULL;
int make_connection(hostarg, portarg, s)
char *hostarg;
int portarg;
int *s;
{
#ifdef INTERNET_DOMAIN_SOCKETS
char *ptr;
if (hostarg == NULL)
hostarg = getenv("GNU_HOST");
if (portarg == 0 && (ptr=getenv("GNU_PORT")) != NULL)
portarg = atoi(ptr);
#endif
if (hostarg != NULL) {
/* hostname was given explicitly, via cmd line arg or GNU_HOST,
* so obey it. */
#ifdef UNIX_DOMAIN_SOCKETS
if (!strcmp(hostarg, "unix")) {
*s = connect_to_unix_server();
return (int) CONN_UNIX;
}
#endif /* UNIX_DOMAIN_SOCKETS */
#ifdef INTERNET_DOMAIN_SOCKETS
*s = connect_to_internet_server(hostarg, portarg);
return (int) CONN_INTERNET;
#endif
#ifdef SYSV_IPC
return -1; /* hostarg should always be NULL for SYSV_IPC */
#endif
} else {
/* no hostname given. Use unix-domain/sysv-ipc, or
* internet-domain connection to local host if they're not available. */
#if defined(UNIX_DOMAIN_SOCKETS)
*s = connect_to_unix_server();
return (int) CONN_UNIX;
#elif defined(SYSV_IPC)
*s = connect_to_ipc_server();
return (int) CONN_IPC;
#elif defined(INTERNET_DOMAIN_SOCKETS)
{
char localhost[HOSTNAMSZ];
gethostname(localhost,HOSTNAMSZ); /* use this host by default */
*s = connect_to_internet_server(localhost, portarg);
return (int) CONN_INTERNET;
}
#endif /* IPC type */
}
}
#ifdef SYSV_IPC
/*
connect_to_ipc_server -- establish connection with server process via SYSV IPC
Returns msqid for server if successful.
*/
static int connect_to_ipc_server (void)
{
int s; /* connected msqid */
key_t key; /* message key */
char buf[GSERV_BUFSZ+1]; /* buffer for filename */
sprintf(buf,"/tmp/gsrv%d",(int)geteuid());
creat(buf,0600);
if ((key = ftok(buf,1)) == -1) {
perror(progname);
fprintf(stderr, "%s: unable to get ipc key from %s\n",
progname, buf);
exit(1);
}
if ((s = msgget(key,0600)) == -1) {
perror(progname);
fprintf(stderr,"%s: unable to access msg queue\n",progname);
exit(1);
}; /* if */
return(s);
} /* connect_to_ipc_server */
/*
disconnect_from_ipc_server -- inform the server that sending has finished,
and wait for its reply.
*/
void disconnect_from_ipc_server(s,msgp,echo)
int s;
struct msgbuf *msgp;
int echo;
{
int len; /* length of received message */
send_string(s,EOT_STR); /* EOT terminates this message */
msgp->mtype = 1;
if(msgsnd(s,msgp,strlen(msgp->mtext)+1,0) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to send message to server\n",progname);
exit(1);
}; /* if */
if((len = msgrcv(s,msgp,GSERV_BUFSZ,getpid(),0)) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to receive message from server\n",progname);
exit(1);
}; /* if */
if (echo) {
msgp->mtext[len] = '\0'; /* string terminate message */
fputs(msgp->mtext, stdout);
if (msgp->mtext[len-1] != '\n') putchar ('\n');
}; /* if */
} /* disconnect_from_ipc_server */
#endif /* SYSV_IPC */
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
send_string -- send string to socket.
*/
void send_string(s,msg)
int s;
const char *msg;
{
#if 0
if (send(s,msg,strlen(msg),0) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to send\n",progname);
exit(1);
}; /* if */
#else
int len, left=strlen(msg);
while (left > 0) {
if ((len=write(s,msg,min2(left,GSERV_BUFSZ))) < 0) {
/* XEmacs addition: robertl@arnet.com */
if (errno == EPIPE) {
return ;
}
perror(progname);
fprintf(stderr,"%s: unable to send\n",progname);
exit(1);
}; /* if */
left -= len;
msg += len;
}; /* while */
#endif
} /* send_string */
/*
read_line -- read a \n terminated line from a socket
*/
int read_line(int s, char *dest)
{
int length;
int offset=0;
char buffer[GSERV_BUFSZ+1];
while ((length=read(s,buffer+offset,1)>0) && buffer[offset]!='\n'
&& buffer[offset] != EOT_CHR) {
offset += length;
if (offset >= GSERV_BUFSZ)
break;
}
buffer[offset] = '\0';
strcpy(dest,buffer);
return 1;
} /* read_line */
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */
#ifdef UNIX_DOMAIN_SOCKETS
/*
connect_to_unix_server -- establish connection with server process via a unix-
domain socket. Returns socket descriptor for server
if successful.
*/
static int connect_to_unix_server (void)
{
int s; /* connected socket descriptor */
struct sockaddr_un server; /* for unix connections */
if ((s = socket(AF_UNIX,SOCK_STREAM,0)) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to create socket\n",progname);
exit(1);
}; /* if */
server.sun_family = AF_UNIX;
#ifdef HIDE_UNIX_SOCKET
sprintf(server.sun_path,"/tmp/gsrvdir%d/gsrv",(int)geteuid());
#else /* HIDE_UNIX_SOCKET */
sprintf(server.sun_path,"/tmp/gsrv%d",(int)geteuid());
#endif /* HIDE_UNIX_SOCKET */
if (connect(s,(struct sockaddr *)&server,strlen(server.sun_path)+2) < 0) {
perror(progname);
fprintf(stderr,"%s: unable to connect to local\n",progname);
exit(1);
}; /* if */
return(s);
} /* connect_to_unix_server */
#endif /* UNIX_DOMAIN_SOCKETS */
#ifdef INTERNET_DOMAIN_SOCKETS
/*
internet_addr -- return the internet addr of the hostname or
internet address passed. Return -1 on error.
*/
int internet_addr(host)
char *host;
{
struct hostent *hp; /* pointer to host info for remote host */
IN_ADDR numeric_addr; /* host address */
numeric_addr = inet_addr (host);
if (!NUMERIC_ADDR_ERROR)
return numeric_addr;
else if ((hp = gethostbyname (host)) != NULL)
return ((struct in_addr *)(hp->h_addr))->s_addr;
else {
glibtop_warn_io ("gethostbyname (%s)", host);
return -1;
}
} /* internet_addr */
#ifdef AUTH_MAGIC_COOKIE
# include <X11/X.h>
# include <X11/Xauth.h>
static Xauth *server_xauth = NULL;
#endif
/*
connect_to_internet_server -- establish connection with server process via
an internet domain socket. Returns socket
descriptor for server if successful.
*/
static int connect_to_internet_server (char *serverhost, u_short port)
{
int s; /* connected socket descriptor */
struct servent *sp; /* pointer to service information */
struct sockaddr_in peeraddr_in; /* for peer socket address */
char buf[512]; /* temporary buffer */
/* clear out address structures */
memset((char *)&peeraddr_in,0,sizeof(struct sockaddr_in));
/* Set up the peer address to which we will connect. */
peeraddr_in.sin_family = AF_INET;
/* look up the server host's internet address */
if ((peeraddr_in.sin_addr.s_addr = internet_addr(serverhost)) == -1) {
fprintf(stderr,"%s: unable to find %s in /etc/hosts or from YP\n",
progname,serverhost);
exit(1);
}; /* if */
if (port == 0) {
if ((sp = getservbyname ("gnuserv","tcp")) == NULL)
peeraddr_in.sin_port = htons(DEFAULT_PORT+getuid());
else
peeraddr_in.sin_port = sp->s_port;
} /* if */
else
peeraddr_in.sin_port = htons(port);
/* Create the socket. */
if ((s = socket (AF_INET,SOCK_STREAM, 0))== -1) {
perror(progname);
fprintf(stderr,"%s: unable to create socket\n",progname);
exit(1);
}; /* if */
/* Try to connect to the remote server at the address
* which was just built into peeraddr.
*/
if (connect(s, (struct sockaddr *)&peeraddr_in,
sizeof(struct sockaddr_in)) == -1) {
perror(progname);
fprintf(stderr, "%s: unable to connect to remote\n",progname);
exit(1);
}; /* if */
#ifdef AUTH_MAGIC_COOKIE
/* send credentials using MIT-MAGIC-COOKIE-1 protocol */
server_xauth =
XauGetAuthByAddr(FamilyInternet,
sizeof(peeraddr_in.sin_addr.s_addr),
(char *) &peeraddr_in.sin_addr.s_addr,
strlen(MCOOKIE_SCREEN), MCOOKIE_SCREEN,
strlen(MCOOKIE_X_NAME), MCOOKIE_X_NAME);
if (server_xauth && server_xauth->data) {
sprintf(buf, "%s\n%d\n", MCOOKIE_NAME, server_xauth->data_length);
write (s, buf, strlen(buf));
write (s, server_xauth->data, server_xauth->data_length);
return (s);
}
#endif /* AUTH_MAGIC_COOKIE */
sprintf (buf, "%s\n", DEFAUTH_NAME);
write (s, buf, strlen(buf));
return(s);
} /* connect_to_internet_server */
#endif /* INTERNET_DOMAIN_SOCKETS */
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
disconnect_from_server -- inform the server that sending has finished, and wait for
its reply.
*/
void disconnect_from_server(s,echo)
int s;
int echo;
{
#if 0
char buffer[REPLYSIZ+1];
#else
char buffer[GSERV_BUFSZ+1];
#endif
int add_newline = 1;
int length;
send_string(s,EOT_STR); /* make sure server gets string */
#if !defined (linux) && !defined (_SCO_DS)
/*
* shutdown is completely hozed under linux. If s is a unix domain socket,
* you'll get EOPNOTSUPP back from it. If s is an internet socket, you get
* a broken pipe when you try to read a bit later. The latter
* problem is fixed for linux versions >= 1.1.46, but the problem
* with unix sockets persists. Sigh.
*/
if (shutdown(s,1) == -1) {
perror(progname);
fprintf(stderr, "%s: unable to shutdown socket\n",progname);
exit(1);
}; /* if */
#endif
#if 0
while((length = recv(s,buffer,REPLYSIZ,0)) > 0) {
buffer[length] = '\0';
if (echo) fputs(buffer,stdout);
add_newline = (buffer[length-1] != '\n');
}; /* while */
#else
while ((length = read(s,buffer,GSERV_BUFSZ)) > 0 ||
(length == -1 && errno == EINTR)) {
if (length) {
buffer[length] = '\0';
if (echo) {
fputs(buffer,stdout);
add_newline = (buffer[length-1] != '\n');
}; /* if */
}; /* if */
}; /* while */
#endif
if (echo && add_newline) putchar('\n');
if(length < 0) {
perror(progname);
fprintf(stderr,"%s: unable to read the reply from the server\n",progname);
exit(1);
}; /* if */
} /* disconnect_from_server */
#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */

View File

@@ -21,60 +21,80 @@
#include <glibtop/union.h>
#include <glibtop/sysdeps.h>
const unsigned long glibtop_server_features =
GLIBTOP_SUID_CPU +
GLIBTOP_SUID_MEM +
GLIBTOP_SUID_SWAP +
GLIBTOP_SUID_UPTIME +
GLIBTOP_SUID_LOADAVG +
GLIBTOP_SUID_SHM_LIMITS +
GLIBTOP_SUID_MSG_LIMITS +
GLIBTOP_SUID_SEM_LIMITS +
GLIBTOP_SUID_PROCLIST +
GLIBTOP_SUID_PROC_STATE +
GLIBTOP_SUID_PROC_UID +
GLIBTOP_SUID_PROC_MEM +
GLIBTOP_SUID_PROC_TIME +
GLIBTOP_SUID_PROC_SIGNAL +
GLIBTOP_SUID_PROC_KERNEL +
GLIBTOP_SUID_PROC_SEGMENT;
/* Checks which features are implemented. */
void
glibtop_get_sysdeps__r (glibtop *server, glibtop_sysdeps *buf)
glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf)
{
glibtop_union data;
memset (buf, 0, sizeof (glibtop_sysdeps));
buf->features = glibtop_server_features;
/* Call all system dependent functions to check which values
* they return. */
glibtop_get_cpu__r (server, &data.cpu);
glibtop_get_cpu_r (server, &data.cpu);
buf->cpu = data.cpu.flags;
glibtop_get_mem__r (server, &data.mem);
glibtop_get_mem_r (server, &data.mem);
buf->mem = data.mem.flags;
glibtop_get_swap__r (server, &data.swap);
glibtop_get_swap_r (server, &data.swap);
buf->swap = data.swap.flags;
glibtop_get_uptime__r (server, &data.uptime);
glibtop_get_uptime_r (server, &data.uptime);
buf->uptime = data.uptime.flags;
glibtop_get_loadavg__r (server, &data.loadavg);
glibtop_get_loadavg_r (server, &data.loadavg);
buf->loadavg = data.loadavg.flags;
glibtop_get_shm_limits__r (server, &data.shm_limits);
glibtop_get_shm_limits_r (server, &data.shm_limits);
buf->shm_limits = data.shm_limits.flags;
glibtop_get_msg_limits__r (server, &data.msg_limits);
glibtop_get_msg_limits_r (server, &data.msg_limits);
buf->msg_limits = data.msg_limits.flags;
glibtop_get_sem_limits__r (server, &data.sem_limits);
glibtop_get_sem_limits_r (server, &data.sem_limits);
buf->sem_limits = data.sem_limits.flags;
glibtop_get_proclist__r (server, &data.proclist);
glibtop_get_proclist_r (server, &data.proclist);
buf->proclist = data.proclist.flags;
glibtop_get_proc_state__r (server, &data.proc_state, 0);
glibtop_get_proc_state_r (server, &data.proc_state, 0);
buf->proc_state = data.proc_state.flags;
glibtop_get_proc_uid__r (server, &data.proc_uid, 0);
glibtop_get_proc_uid_r (server, &data.proc_uid, 0);
buf->proc_uid = data.proc_uid.flags;
glibtop_get_proc_mem__r (server, &data.proc_mem, 0);
glibtop_get_proc_mem_r (server, &data.proc_mem, 0);
buf->proc_mem = data.proc_mem.flags;
glibtop_get_proc_time__r (server, &data.proc_time, 0);
glibtop_get_proc_time_r (server, &data.proc_time, 0);
buf->proc_time = data.proc_time.flags;
glibtop_get_proc_kernel__r (server, &data.proc_kernel, 0);
glibtop_get_proc_kernel_r (server, &data.proc_kernel, 0);
buf->proc_kernel = data.proc_kernel.flags;
glibtop_get_proc_segment__r (server, &data.proc_segment, 0);
glibtop_get_proc_segment_r (server, &data.proc_segment, 0);
buf->proc_segment = data.proc_segment.flags;
}

View File

@@ -24,43 +24,43 @@
/* Wrappers to malloc, calloc, realloc ... */
void *
glibtop_malloc__r (glibtop *server, size_t size)
glibtop_malloc_r (glibtop *server, size_t size)
{
void *buf = malloc (size);
if (!buf)
glibtop_error__r (server, _("malloc %d bytes: %s"),
glibtop_error_r (server, _("malloc %d bytes: %s"),
size, strerror (errno));
return buf;
}
void *
glibtop_calloc__r (glibtop *server, size_t nmemb, size_t size)
glibtop_calloc_r (glibtop *server, size_t nmemb, size_t size)
{
void *buf = calloc (nmemb, size);
if (!buf)
glibtop_error__r (server, _("calloc %d block (%d bytes each): %s"),
glibtop_error_r (server, _("calloc %d block (%d bytes each): %s"),
nmemb, size, strerror (errno));
return buf;
}
void *
glibtop_realloc__r (glibtop *server, void *ptr, size_t size)
glibtop_realloc_r (glibtop *server, void *ptr, size_t size)
{
void *buf = realloc (ptr, size);
if (!buf)
glibtop_error__r (server, _("realloc %d bytes: %s"),
glibtop_error_r (server, _("realloc %d bytes: %s"),
size, strerror (errno));
return buf;
}
void
glibtop_free__r (glibtop *server, void *ptr)
glibtop_free_r (glibtop *server, void *ptr)
{
if (ptr) free (ptr);
}

View File

@@ -23,3 +23,4 @@ so_locations
swap.lo
sysdeps.lo
uptime.lo
guile.c

View File

@@ -14,8 +14,14 @@ CFLAGS = -Wall -W @CFLAGS@
lib_LTLIBRARIES = libgtop_guile.la
libgtop_guile_la_SOURCES = boot.c sysdeps.c cpu.c mem.c swap.c uptime.c \
loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c
libgtop_guile_la_SOURCES = guile.c
BUILT_SOURCES = guile.c
guile.c: guile.awk $(top_builddir)/config.h $(top_builddir)/features.def
$(AWK) -f $(srcdir)/guile.awk < $(top_builddir)/features.def > gnc-t
mv gnc-t guile.c
EXTRA_DIST = guile.awk
CLEANFILES = guile.c

View File

@@ -1,66 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/sysdeps.h>
#include <guile/gh.h>
void
glibtop_boot_guile (void)
{
gh_new_procedure0_0
("glibtop-get-cpu", glibtop_guile_get_cpu);
gh_new_procedure0_0
("glibtop-get-mem", glibtop_guile_get_mem);
gh_new_procedure0_0
("glibtop-get-swap", glibtop_guile_get_swap);
gh_new_procedure0_0
("glibtop-get-uptime", glibtop_guile_get_uptime);
gh_new_procedure0_0
("glibtop-get-loadavg", glibtop_guile_get_loadavg);
gh_new_procedure0_0
("glibtop-get-shm_limits",glibtop_guile_get_shm_limits);
gh_new_procedure0_0
("glibtop-get-msg_limits", glibtop_guile_get_msg_limits);
gh_new_procedure0_0
("glibtop-get-sem_limits", glibtop_guile_get_sem_limits);
gh_new_procedure0_0
("glibtop-get-sysdeps", glibtop_guile_get_sysdeps);
gh_new_procedure0_0
("glibtop-get-proclist", glibtop_guile_get_proclist);
gh_new_procedure1_0
("glibtop-get-proc_state", glibtop_guile_get_proc_state);
gh_new_procedure1_0
("glibtop-get-proc_uid", glibtop_guile_get_proc_uid);
gh_new_procedure1_0
("glibtop-get-proc_mem", glibtop_guile_get_proc_mem);
gh_new_procedure1_0
("glibtop-get-proc_time", glibtop_guile_get_proc_time);
gh_new_procedure1_0
("glibtop-get-proc_signal", glibtop_guile_get_proc_signal);
gh_new_procedure1_0
("glibtop-get-proc_kernel", glibtop_guile_get_proc_kernel);
gh_new_procedure1_0
("glibtop-get-proc_segment", glibtop_guile_get_proc_segment);
}

87
sysdeps/guile/guile.awk Normal file
View File

@@ -0,0 +1,87 @@
BEGIN {
print "/* guile.c */";
print "/* This is a generated file. Please modify `guile.awk' */";
print "";
print "#include <glibtop.h>";
print "#include <glibtop/xmalloc.h>";
print "#include <glibtop/sysdeps.h>";
print "";
print "#include <guile/gh.h>";
print "";
convert["long"] = "gh_long2scm ";
convert["ulong"] = "gh_ulong2scm ";
convert["double"] = "gh_double2scm";
convert["str"] = "gh_str02scm ";
convert["char"] = "gh_char2scm ";
}
/^(\w+)/ {
features[$1] = $1;
if ($1 ~ /^proclist$/) {
output = "SCM\nglibtop_guile_get_proclist (void)\n{\n";
output = output"\tglibtop_proclist proclist;\n\tunsigned i, *ptr;\n";
output = output"\tSCM list;\n\n\tptr = glibtop_get_proclist (&proclist);\n\n";
output = output"\tlist = gh_list (gh_ulong2scm ("$1".flags),\n\t\t\t";
} else {
if ($1 ~ /^proc_/) {
output = "SCM\nglibtop_guile_get_"$1" (SCM pid)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1", (pid_t) gh_scm2long (pid));\n\n";
} else {
output = "SCM\nglibtop_guile_get_"$1" (void)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1");\n\n";
}
output = output"\treturn gh_list (gh_ulong2scm ("$1".flags),\n\t\t\t";
}
nr_elements = split ($2, elements, /:/);
for (element = 1; element <= nr_elements; element++) {
list = elements[element];
type = elements[element];
sub(/\(.*/, "", type);
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
count = split (list, fields, /,/);
for (field = 1; field <= count; field++) {
output = output""convert[type]" ("$1"."fields[field]"),\n\t\t\t";
}
}
output = output"SCM_UNDEFINED);";
print output;
if ($1 ~ /^proclist$/) {
print "";
print "\tif (ptr) {";
print "\t\tfor (i = 0; i < proclist.number; i++)";
print "\t\t\tlist = gh_append";
print "\t\t\t\t(gh_list (list,";
print "\t\t\t\t\t gh_list (gh_ulong2scm ((unsigned long) ptr [i])),";
print "\t\t\t\t\t SCM_UNDEFINED));";
print "\t}";
print "";
print "\tglibtop_free (ptr);";
print "";
print "\treturn list;";
}
print "}";
print "";
}
END {
print "void";
print "glibtop_boot_guile (void)";
print "{";
for (feature in features) {
if (feature ~ /^proc_/) {
print "\tgh_new_procedure1_0";
} else {
print "\tgh_new_procedure0_0";
}
print "\t\t(\"glibtop-get-"feature"\", glibtop_guile_get_"feature");";
}
print "}";
}

View File

@@ -1,38 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/loadavg.h>
#include <guile/gh.h>
SCM glibtop_guile_get_loadavg (void)
{
glibtop_loadavg loadavg;
glibtop_get_loadavg (&loadavg);
return gh_list (gh_ulong2scm (loadavg.flags),
gh_double2scm (loadavg.loadavg [0]),
gh_double2scm (loadavg.loadavg [1]),
gh_double2scm (loadavg.loadavg [2]),
SCM_UNDEFINED);
}

View File

@@ -1,42 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/msg_limits.h>
#include <guile/gh.h>
SCM glibtop_guile_get_msg_limits (void)
{
glibtop_msg_limits msg_limits;
glibtop_get_msg_limits (&msg_limits);
return gh_list (gh_ulong2scm (msg_limits.flags),
gh_ulong2scm (msg_limits.msgpool),
gh_ulong2scm (msg_limits.msgmap),
gh_ulong2scm (msg_limits.msgmax),
gh_ulong2scm (msg_limits.msgmnb),
gh_ulong2scm (msg_limits.msgmni),
gh_ulong2scm (msg_limits.msgssz),
gh_ulong2scm (msg_limits.msgtql),
SCM_UNDEFINED);
}

View File

@@ -24,3 +24,4 @@ so_locations
swap.lo
sysdeps.lo
uptime.lo
guile-names.c

View File

@@ -8,9 +8,15 @@ CFLAGS = -Wall -W @CFLAGS@
lib_LTLIBRARIES = libgtop_guile_names.la
libgtop_guile_names_la_SOURCES = boot.c sysdeps.c cpu.c mem.c swap.c uptime.c \
loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c
libgtop_guile_names_la_SOURCES = guile-names.c
BUILT_SOURCES = guile-names.c
guile-names.c: guile-names.awk $(top_builddir)/config.h $(top_builddir)/features.def
$(AWK) -f $(srcdir)/guile-names.awk < $(top_builddir)/features.def > gnc-t
mv gnc-t guile-names.c
EXTRA_DIST = guile-names.awk
CLEANFILES = guile-names.c

View File

@@ -1,174 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/sysdeps.h>
#include <guile/gh.h>
void
glibtop_boot_guile_names (void)
{
gh_new_procedure0_0
("glibtop-names-cpu", glibtop_guile_names_cpu);
gh_new_procedure0_0
("glibtop-names-mem", glibtop_guile_names_mem);
gh_new_procedure0_0
("glibtop-names-swap", glibtop_guile_names_swap);
gh_new_procedure0_0
("glibtop-names-uptime", glibtop_guile_names_uptime);
gh_new_procedure0_0
("glibtop-names-loadavg", glibtop_guile_names_loadavg);
gh_new_procedure0_0
("glibtop-names-shm_limits", glibtop_guile_names_shm_limits);
gh_new_procedure0_0
("glibtop-names-msg_limits", glibtop_guile_names_msg_limits);
gh_new_procedure0_0
("glibtop-names-sem_limits", glibtop_guile_names_sem_limits);
gh_new_procedure0_0
("glibtop-names-sysdeps", glibtop_guile_names_sysdeps);
gh_new_procedure0_0
("glibtop-names-proclist", glibtop_guile_names_proclist);
gh_new_procedure0_0
("glibtop-names-proc_state", glibtop_guile_names_proc_state);
gh_new_procedure0_0
("glibtop-names-proc_uid", glibtop_guile_names_proc_uid);
gh_new_procedure0_0
("glibtop-names-proc_mem", glibtop_guile_names_proc_mem);
gh_new_procedure0_0
("glibtop-names-proc_time", glibtop_guile_names_proc_time);
gh_new_procedure0_0
("glibtop-names-proc_signal", glibtop_guile_names_proc_signal);
gh_new_procedure0_0
("glibtop-names-proc_kernel", glibtop_guile_names_proc_kernel);
gh_new_procedure0_0
("glibtop-names-proc_segment", glibtop_guile_names_proc_segment);
gh_new_procedure0_0
("glibtop-types-cpu", glibtop_guile_types_cpu);
gh_new_procedure0_0
("glibtop-types-mem", glibtop_guile_types_mem);
gh_new_procedure0_0
("glibtop-types-swap", glibtop_guile_types_swap);
gh_new_procedure0_0
("glibtop-types-uptime", glibtop_guile_types_uptime);
gh_new_procedure0_0
("glibtop-types-loadavg", glibtop_guile_types_loadavg);
gh_new_procedure0_0
("glibtop-types-shm_limits", glibtop_guile_types_shm_limits);
gh_new_procedure0_0
("glibtop-types-msg_limits", glibtop_guile_types_msg_limits);
gh_new_procedure0_0
("glibtop-types-sem_limits", glibtop_guile_types_sem_limits);
gh_new_procedure0_0
("glibtop-types-sysdeps", glibtop_guile_types_sysdeps);
gh_new_procedure0_0
("glibtop-types-proclist", glibtop_guile_types_proclist);
gh_new_procedure0_0
("glibtop-types-proc_state", glibtop_guile_types_proc_state);
gh_new_procedure0_0
("glibtop-types-proc_uid", glibtop_guile_types_proc_uid);
gh_new_procedure0_0
("glibtop-types-proc_mem", glibtop_guile_types_proc_mem);
gh_new_procedure0_0
("glibtop-types-proc_time", glibtop_guile_types_proc_time);
gh_new_procedure0_0
("glibtop-types-proc_signal", glibtop_guile_types_proc_signal);
gh_new_procedure0_0
("glibtop-types-proc_kernel", glibtop_guile_types_proc_kernel);
gh_new_procedure0_0
("glibtop-types-proc_segment", glibtop_guile_types_proc_segment);
gh_new_procedure0_0
("glibtop-labels-cpu", glibtop_guile_labels_cpu);
gh_new_procedure0_0
("glibtop-labels-mem", glibtop_guile_labels_mem);
gh_new_procedure0_0
("glibtop-labels-swap", glibtop_guile_labels_swap);
gh_new_procedure0_0
("glibtop-labels-uptime", glibtop_guile_labels_uptime);
gh_new_procedure0_0
("glibtop-labels-loadavg", glibtop_guile_labels_loadavg);
gh_new_procedure0_0
("glibtop-labels-shm_limits", glibtop_guile_labels_shm_limits);
gh_new_procedure0_0
("glibtop-labels-msg_limits", glibtop_guile_labels_msg_limits);
gh_new_procedure0_0
("glibtop-labels-sem_limits", glibtop_guile_labels_sem_limits);
gh_new_procedure0_0
("glibtop-labels-sysdeps", glibtop_guile_labels_sysdeps);
gh_new_procedure0_0
("glibtop-labels-proclist", glibtop_guile_labels_proclist);
gh_new_procedure0_0
("glibtop-labels-proc_state", glibtop_guile_labels_proc_state);
gh_new_procedure0_0
("glibtop-labels-proc_uid", glibtop_guile_labels_proc_uid);
gh_new_procedure0_0
("glibtop-labels-proc_mem", glibtop_guile_labels_proc_mem);
gh_new_procedure0_0
("glibtop-labels-proc_time", glibtop_guile_labels_proc_time);
gh_new_procedure0_0
("glibtop-labels-proc_signal", glibtop_guile_labels_proc_signal);
gh_new_procedure0_0
("glibtop-labels-proc_kernel", glibtop_guile_labels_proc_kernel);
gh_new_procedure0_0
("glibtop-labels-proc_segment", glibtop_guile_labels_proc_segment);
gh_new_procedure0_0
("glibtop-descriptions-cpu", glibtop_guile_descriptions_cpu);
gh_new_procedure0_0
("glibtop-descriptions-mem", glibtop_guile_descriptions_mem);
gh_new_procedure0_0
("glibtop-descriptions-swap", glibtop_guile_descriptions_swap);
gh_new_procedure0_0
("glibtop-descriptions-uptime", glibtop_guile_descriptions_uptime);
gh_new_procedure0_0
("glibtop-descriptions-loadavg", glibtop_guile_descriptions_loadavg);
gh_new_procedure0_0
("glibtop-descriptions-shm_limits", glibtop_guile_descriptions_shm_limits);
gh_new_procedure0_0
("glibtop-descriptions-msg_limits", glibtop_guile_descriptions_msg_limits);
gh_new_procedure0_0
("glibtop-descriptions-sem_limits", glibtop_guile_descriptions_sem_limits);
gh_new_procedure0_0
("glibtop-descriptions-sysdeps", glibtop_guile_descriptions_sysdeps);
gh_new_procedure0_0
("glibtop-descriptions-proclist", glibtop_guile_descriptions_proclist);
gh_new_procedure0_0
("glibtop-descriptions-proc_state", glibtop_guile_descriptions_proc_state);
gh_new_procedure0_0
("glibtop-descriptions-proc_uid", glibtop_guile_descriptions_proc_uid);
gh_new_procedure0_0
("glibtop-descriptions-proc_mem", glibtop_guile_descriptions_proc_mem);
gh_new_procedure0_0
("glibtop-descriptions-proc_time", glibtop_guile_descriptions_proc_time);
gh_new_procedure0_0
("glibtop-descriptions-proc_signal", glibtop_guile_descriptions_proc_signal);
gh_new_procedure0_0
("glibtop-descriptions-proc_kernel", glibtop_guile_descriptions_proc_kernel);
gh_new_procedure0_0
("glibtop-descriptions-proc_segment", glibtop_guile_descriptions_proc_segment);
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/cpu.h>
#include <guile/gh.h>
SCM
glibtop_guile_names_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_cpu [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_cpu [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_cpu [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_cpu [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -0,0 +1,121 @@
BEGIN {
print "/* guile_names.c */";
print "/* This is a generated file. Please modify `guile-names.awk' */";
print "";
print "#include <glibtop.h>";
print "#include <glibtop/sysdeps.h>";
print "";
print "#include <guile/gh.h>";
print "";
}
function output(feature) {
print "SCM";
print "glibtop_guile_names_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_str02scm ((char *) glibtop_names_"feature" [i])),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
print "SCM";
print "glibtop_guile_types_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_ulong2scm (glibtop_types_"feature" [i])),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
print "SCM";
print "glibtop_guile_labels_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_str02scm (gettext";
print "\t\t\t\t\t\t\t(glibtop_labels_"feature" [i]))),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
print "SCM";
print "glibtop_guile_descriptions_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_str02scm (gettext";
print "\t\t\t\t\t\t\t(glibtop_descriptions_"feature" [i]))),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
}
/^(\w+)/ { features[$1] = $1 }
END {
for (feature in features) {
output(feature);
}
print "void";
print "glibtop_boot_guile_names (void)";
print "{";
for (feature in features) {
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-names-"feature"\", glibtop_guile_names_"feature");";
print "";
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-types-"feature"\", glibtop_guile_types_"feature");";
print "";
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-labels-"feature"\", glibtop_guile_labels_"feature");";
print "";
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-descriptions-"feature"\", glibtop_guile_descriptions_"feature");";
}
print "}";
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/loadavg.h>
#include <guile/gh.h>
SCM
glibtop_guile_names_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_loadavg [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_loadavg [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_loadavg [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_loadavg [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/mem.h>
#include <guile/gh.h>
SCM
glibtop_guile_names_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_mem [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_mem [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_mem [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_mem [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/msg_limits.h>
#include <guile/gh.h>
SCM
glibtop_guile_names_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_msg_limits [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_msg_limits [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_msg_limits [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_msg_limits [i])),
SCM_UNDEFINED));
return list;
}

Some files were not shown because too many files have changed in this diff Show More