From 33cdc01c1db3a1cafaeb63e50247072b82ef49ea Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 18:19:50 +0000 Subject: [PATCH 0001/2539] Initial revision --- .cvsignore | 24 + ANNOUNCE | 95 ++ AUTHORS | 1 + ChangeLog | 393 +++++++ Makefile.am | 41 + NEWS | 96 ++ README | 57 + README.LATEST | 8 + acconfig.h | 30 + acinclude.m4 | 960 +++++++++++++++++ autogen.sh | 17 + config.guess | 883 ++++++++++++++++ config.sub | 954 +++++++++++++++++ configure.in | 144 +++ copyright.txt | 21 + doc/.cvsignore | 15 + doc/Makefile | 6 + doc/catalog | 3 + doc/libgtop.dsl | 1627 +++++++++++++++++++++++++++++ doc/libgtop.sgml | 1332 +++++++++++++++++++++++ examples/.cvsignore | 13 + examples/Makefile.am | 66 ++ examples/first.c | 326 ++++++ examples/second.c | 140 +++ examples/third.c | 51 + examples/third.scm | 10 + glibtop.h | 72 ++ gtopConf.sh.in | 17 + guile/header.scm | 440 ++++++++ guile/make-header.scm | 195 ++++ include/glibtop/close.h | 33 + include/glibtop/command.h | 67 ++ include/glibtop/cpu.h | 88 ++ include/glibtop/error.h | 35 + include/glibtop/global.h | 93 ++ include/glibtop/loadavg.h | 78 ++ include/glibtop/mem.h | 90 ++ include/glibtop/msg_limits.h | 90 ++ include/glibtop/open.h | 33 + include/glibtop/output.h | 33 + include/glibtop/prockernel.h | 99 ++ include/glibtop/proclist.h | 82 ++ include/glibtop/procmem.h | 92 ++ include/glibtop/procsegment.h | 93 ++ include/glibtop/procsignal.h | 86 ++ include/glibtop/procstate.h | 93 ++ include/glibtop/proctime.h | 98 ++ include/glibtop/procuid.h | 102 ++ include/glibtop/read.h | 36 + include/glibtop/read_data.h | 36 + include/glibtop/sem_limits.h | 96 ++ include/glibtop/shm_limits.h | 86 ++ include/glibtop/swap.h | 82 ++ include/glibtop/sysdeps.h | 108 ++ include/glibtop/union.h | 69 ++ include/glibtop/uptime.h | 80 ++ include/glibtop/version.h | 31 + include/glibtop/write.h | 36 + include/glibtop/xmalloc.h | 42 + lib/.cvsignore | 34 + lib/Makefile.am | 15 + lib/close.c | 32 + lib/command.c | 54 + lib/cpu.c | 32 + lib/init.c | 40 + lib/loadavg.c | 33 + lib/mem.c | 32 + lib/msg_limits.c | 32 + lib/open.c | 60 ++ lib/prockernel.c | 35 + lib/proclist.c | 32 + lib/procmem.c | 35 + lib/procsegment.c | 35 + lib/procsignal.c | 35 + lib/procstate.c | 35 + lib/proctime.c | 35 + lib/procuid.c | 35 + lib/read.c | 41 + lib/read_data.c | 48 + lib/sem_limits.c | 32 + lib/shm_limits.c | 32 + lib/swap.c | 32 + lib/sysdeps.c | 32 + lib/uptime.c | 33 + lib/write.c | 38 + libgtop-mirror.sh | 47 + po/.cvsignore | 5 + po/POTFILES.in | 78 ++ po/stamp-cat-id | 1 + src/.cvsignore | 2 + src/Makefile.am | 1 + src/server/.cvsignore | 5 + src/server/Makefile.am | 14 + src/server/main.c | 258 +++++ src/server/output.c | 31 + src/server/version.c | 31 + stamp-h.in | 1 + sysdeps/.cvsignore | 2 + sysdeps/Makefile.am | 7 + sysdeps/common/.cvsignore | 12 + sysdeps/common/Makefile.am | 10 + sysdeps/common/error.c | 39 + sysdeps/common/sysdeps.c | 80 ++ sysdeps/common/xmalloc.c | 66 ++ sysdeps/guile/.cvsignore | 25 + sysdeps/guile/Makefile.am | 15 + sysdeps/guile/boot.c | 66 ++ sysdeps/guile/cpu.c | 41 + sysdeps/guile/loadavg.c | 38 + sysdeps/guile/mem.c | 42 + sysdeps/guile/msg_limits.c | 42 + sysdeps/guile/names/.cvsignore | 26 + sysdeps/guile/names/Makefile.am | 16 + sysdeps/guile/names/boot.c | 168 +++ sysdeps/guile/names/cpu.c | 95 ++ sysdeps/guile/names/loadavg.c | 95 ++ sysdeps/guile/names/mem.c | 95 ++ sysdeps/guile/names/msg_limits.c | 95 ++ sysdeps/guile/names/prockernel.c | 95 ++ sysdeps/guile/names/proclist.c | 96 ++ sysdeps/guile/names/procmem.c | 95 ++ sysdeps/guile/names/procsegment.c | 95 ++ sysdeps/guile/names/procsignal.c | 95 ++ sysdeps/guile/names/procstate.c | 95 ++ sysdeps/guile/names/proctime.c | 95 ++ sysdeps/guile/names/procuid.c | 95 ++ sysdeps/guile/names/sem_limits.c | 85 ++ sysdeps/guile/names/shm_limits.c | 85 ++ sysdeps/guile/names/swap.c | 84 ++ sysdeps/guile/names/sysdeps.c | 85 ++ sysdeps/guile/names/uptime.c | 84 ++ sysdeps/guile/prockernel.c | 44 + sysdeps/guile/proclist.c | 52 + sysdeps/guile/procmem.c | 42 + sysdeps/guile/procsegment.c | 43 + sysdeps/guile/procsignal.c | 40 + sysdeps/guile/procstate.c | 40 + sysdeps/guile/proctime.c | 43 + sysdeps/guile/procuid.c | 48 + sysdeps/guile/sem_limits.c | 45 + sysdeps/guile/shm_limits.c | 40 + sysdeps/guile/swap.c | 38 + sysdeps/guile/sysdeps.c | 51 + sysdeps/guile/uptime.c | 37 + sysdeps/linux/.cvsignore | 28 + sysdeps/linux/Makefile.am | 13 + sysdeps/linux/close.c | 28 + sysdeps/linux/cpu.c | 54 + sysdeps/linux/init.c | 40 + sysdeps/linux/libsysdeps.la | 19 + sysdeps/linux/loadavg.c | 48 + sysdeps/linux/mem.c | 53 + sysdeps/linux/msg_limits.c | 55 + sysdeps/linux/open.c | 61 ++ sysdeps/linux/procdata.c | 178 ++++ sysdeps/linux/prockernel.c | 82 ++ sysdeps/linux/proclist.c | 155 +++ sysdeps/linux/procmem.c | 96 ++ sysdeps/linux/procsegment.c | 99 ++ sysdeps/linux/procsignal.c | 78 ++ sysdeps/linux/procstate.c | 88 ++ sysdeps/linux/proctime.c | 79 ++ sysdeps/linux/procuid.c | 122 +++ sysdeps/linux/sem_limits.c | 61 ++ sysdeps/linux/shm_limits.c | 52 + sysdeps/linux/swap.c | 49 + sysdeps/linux/uptime.c | 47 + sysdeps/names/.cvsignore | 24 + sysdeps/names/Makefile.am | 16 + sysdeps/names/cpu.c | 60 ++ sysdeps/names/loadavg.c | 42 + sysdeps/names/mem.c | 57 + sysdeps/names/msg_limits.c | 55 + sysdeps/names/procdata.c | 53 + sysdeps/names/prockernel.c | 76 ++ sysdeps/names/proclist.c | 46 + sysdeps/names/procmem.c | 61 ++ sysdeps/names/procsegment.c | 51 + sysdeps/names/procsignal.c | 46 + sysdeps/names/procstate.c | 46 + sysdeps/names/proctime.c | 62 ++ sysdeps/names/procuid.c | 71 ++ sysdeps/names/sem_limits.c | 63 ++ sysdeps/names/shm_limits.c | 51 + sysdeps/names/swap.c | 46 + sysdeps/names/sysdeps.c | 78 ++ sysdeps/names/uptime.c | 44 + sysdeps/osf1/.cvsignore | 21 + sysdeps/osf1/Makefile.am | 15 + sysdeps/osf1/close.c | 28 + sysdeps/osf1/cpu.c | 59 ++ sysdeps/osf1/glibtop_machine.h | 48 + sysdeps/osf1/init.c | 40 + sysdeps/osf1/mem.c | 59 ++ sysdeps/osf1/msg_limits.c | 77 ++ sysdeps/osf1/open.c | 64 ++ sysdeps/osf1/procdata.c | 148 +++ sysdeps/osf1/prockernel.c | 32 + sysdeps/osf1/proclist.c | 155 +++ sysdeps/osf1/procmem.c | 32 + sysdeps/osf1/procsegment.c | 32 + sysdeps/osf1/procsignal.c | 32 + sysdeps/osf1/procstate.c | 32 + sysdeps/osf1/proctime.c | 32 + sysdeps/osf1/procuid.c | 32 + sysdeps/osf1/sem_limits.c | 100 ++ sysdeps/osf1/shm_limits.c | 79 ++ sysdeps/osf1/swap.c | 54 + sysdeps/stub/.cvsignore | 27 + sysdeps/stub/Makefile.am | 14 + sysdeps/stub/close.c | 28 + sysdeps/stub/cpu.c | 31 + sysdeps/stub/init.c | 40 + sysdeps/stub/libsysdeps.la | 19 + sysdeps/stub/mem.c | 31 + sysdeps/stub/msg_limits.c | 30 + sysdeps/stub/open.c | 31 + sysdeps/stub/prockernel.c | 32 + sysdeps/stub/proclist.c | 39 + sysdeps/stub/procmem.c | 32 + sysdeps/stub/procsegment.c | 32 + sysdeps/stub/procsignal.c | 32 + sysdeps/stub/procstate.c | 32 + sysdeps/stub/proctime.c | 32 + sysdeps/stub/procuid.c | 32 + sysdeps/stub/sem_limits.c | 30 + sysdeps/stub/shm_limits.c | 30 + sysdeps/stub/swap.c | 31 + sysdeps/sun4/.cvsignore | 19 + sysdeps/sun4/Makefile.am | 14 + sysdeps/sun4/close.c | 28 + sysdeps/sun4/cpu.c | 31 + sysdeps/sun4/init.c | 40 + sysdeps/sun4/libsysdeps.la | 19 + sysdeps/sun4/mem.c | 31 + sysdeps/sun4/msg_limits.c | 30 + sysdeps/sun4/open.c | 31 + sysdeps/sun4/procdata.c | 31 + sysdeps/sun4/prockernel.c | 32 + sysdeps/sun4/proclist.c | 39 + sysdeps/sun4/procmem.c | 32 + sysdeps/sun4/procsegment.c | 32 + sysdeps/sun4/procsignal.c | 32 + sysdeps/sun4/procstate.c | 32 + sysdeps/sun4/proctime.c | 32 + sysdeps/sun4/procuid.c | 32 + sysdeps/sun4/sem_limits.c | 30 + sysdeps/sun4/shm_limits.c | 30 + sysdeps/sun4/swap.c | 31 + 249 files changed, 19386 insertions(+) create mode 100644 .cvsignore create mode 100644 ANNOUNCE create mode 100644 AUTHORS create mode 100644 ChangeLog create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100644 README.LATEST create mode 100644 acconfig.h create mode 100644 acinclude.m4 create mode 100755 autogen.sh create mode 100755 config.guess create mode 100755 config.sub create mode 100644 configure.in create mode 100644 copyright.txt create mode 100644 doc/.cvsignore create mode 100644 doc/Makefile create mode 100644 doc/catalog create mode 100755 doc/libgtop.dsl create mode 100644 doc/libgtop.sgml create mode 100644 examples/.cvsignore create mode 100644 examples/Makefile.am create mode 100644 examples/first.c create mode 100644 examples/second.c create mode 100644 examples/third.c create mode 100644 examples/third.scm create mode 100644 glibtop.h create mode 100644 gtopConf.sh.in create mode 100644 guile/header.scm create mode 100644 guile/make-header.scm create mode 100644 include/glibtop/close.h create mode 100644 include/glibtop/command.h create mode 100644 include/glibtop/cpu.h create mode 100644 include/glibtop/error.h create mode 100644 include/glibtop/global.h create mode 100644 include/glibtop/loadavg.h create mode 100644 include/glibtop/mem.h create mode 100644 include/glibtop/msg_limits.h create mode 100644 include/glibtop/open.h create mode 100644 include/glibtop/output.h create mode 100644 include/glibtop/prockernel.h create mode 100644 include/glibtop/proclist.h create mode 100644 include/glibtop/procmem.h create mode 100644 include/glibtop/procsegment.h create mode 100644 include/glibtop/procsignal.h create mode 100644 include/glibtop/procstate.h create mode 100644 include/glibtop/proctime.h create mode 100644 include/glibtop/procuid.h create mode 100644 include/glibtop/read.h create mode 100644 include/glibtop/read_data.h create mode 100644 include/glibtop/sem_limits.h create mode 100644 include/glibtop/shm_limits.h create mode 100644 include/glibtop/swap.h create mode 100644 include/glibtop/sysdeps.h create mode 100644 include/glibtop/union.h create mode 100644 include/glibtop/uptime.h create mode 100644 include/glibtop/version.h create mode 100644 include/glibtop/write.h create mode 100644 include/glibtop/xmalloc.h create mode 100644 lib/.cvsignore create mode 100644 lib/Makefile.am create mode 100644 lib/close.c create mode 100644 lib/command.c create mode 100644 lib/cpu.c create mode 100644 lib/init.c create mode 100644 lib/loadavg.c create mode 100644 lib/mem.c create mode 100644 lib/msg_limits.c create mode 100644 lib/open.c create mode 100644 lib/prockernel.c create mode 100644 lib/proclist.c create mode 100644 lib/procmem.c create mode 100644 lib/procsegment.c create mode 100644 lib/procsignal.c create mode 100644 lib/procstate.c create mode 100644 lib/proctime.c create mode 100644 lib/procuid.c create mode 100644 lib/read.c create mode 100644 lib/read_data.c create mode 100644 lib/sem_limits.c create mode 100644 lib/shm_limits.c create mode 100644 lib/swap.c create mode 100644 lib/sysdeps.c create mode 100644 lib/uptime.c create mode 100644 lib/write.c create mode 100755 libgtop-mirror.sh create mode 100644 po/.cvsignore create mode 100644 po/POTFILES.in create mode 100644 po/stamp-cat-id create mode 100644 src/.cvsignore create mode 100644 src/Makefile.am create mode 100644 src/server/.cvsignore create mode 100644 src/server/Makefile.am create mode 100644 src/server/main.c create mode 100644 src/server/output.c create mode 100644 src/server/version.c create mode 100644 stamp-h.in create mode 100644 sysdeps/.cvsignore create mode 100644 sysdeps/Makefile.am create mode 100644 sysdeps/common/.cvsignore create mode 100644 sysdeps/common/Makefile.am create mode 100644 sysdeps/common/error.c create mode 100644 sysdeps/common/sysdeps.c create mode 100644 sysdeps/common/xmalloc.c create mode 100644 sysdeps/guile/.cvsignore create mode 100644 sysdeps/guile/Makefile.am create mode 100644 sysdeps/guile/boot.c create mode 100644 sysdeps/guile/cpu.c create mode 100644 sysdeps/guile/loadavg.c create mode 100644 sysdeps/guile/mem.c create mode 100644 sysdeps/guile/msg_limits.c create mode 100644 sysdeps/guile/names/.cvsignore create mode 100644 sysdeps/guile/names/Makefile.am create mode 100644 sysdeps/guile/names/boot.c create mode 100644 sysdeps/guile/names/cpu.c create mode 100644 sysdeps/guile/names/loadavg.c create mode 100644 sysdeps/guile/names/mem.c create mode 100644 sysdeps/guile/names/msg_limits.c create mode 100644 sysdeps/guile/names/prockernel.c create mode 100644 sysdeps/guile/names/proclist.c create mode 100644 sysdeps/guile/names/procmem.c create mode 100644 sysdeps/guile/names/procsegment.c create mode 100644 sysdeps/guile/names/procsignal.c create mode 100644 sysdeps/guile/names/procstate.c create mode 100644 sysdeps/guile/names/proctime.c create mode 100644 sysdeps/guile/names/procuid.c create mode 100644 sysdeps/guile/names/sem_limits.c create mode 100644 sysdeps/guile/names/shm_limits.c create mode 100644 sysdeps/guile/names/swap.c create mode 100644 sysdeps/guile/names/sysdeps.c create mode 100644 sysdeps/guile/names/uptime.c create mode 100644 sysdeps/guile/prockernel.c create mode 100644 sysdeps/guile/proclist.c create mode 100644 sysdeps/guile/procmem.c create mode 100644 sysdeps/guile/procsegment.c create mode 100644 sysdeps/guile/procsignal.c create mode 100644 sysdeps/guile/procstate.c create mode 100644 sysdeps/guile/proctime.c create mode 100644 sysdeps/guile/procuid.c create mode 100644 sysdeps/guile/sem_limits.c create mode 100644 sysdeps/guile/shm_limits.c create mode 100644 sysdeps/guile/swap.c create mode 100644 sysdeps/guile/sysdeps.c create mode 100644 sysdeps/guile/uptime.c create mode 100644 sysdeps/linux/.cvsignore create mode 100644 sysdeps/linux/Makefile.am create mode 100644 sysdeps/linux/close.c create mode 100644 sysdeps/linux/cpu.c create mode 100644 sysdeps/linux/init.c create mode 100644 sysdeps/linux/libsysdeps.la create mode 100644 sysdeps/linux/loadavg.c create mode 100644 sysdeps/linux/mem.c create mode 100644 sysdeps/linux/msg_limits.c create mode 100644 sysdeps/linux/open.c create mode 100644 sysdeps/linux/procdata.c create mode 100644 sysdeps/linux/prockernel.c create mode 100644 sysdeps/linux/proclist.c create mode 100644 sysdeps/linux/procmem.c create mode 100644 sysdeps/linux/procsegment.c create mode 100644 sysdeps/linux/procsignal.c create mode 100644 sysdeps/linux/procstate.c create mode 100644 sysdeps/linux/proctime.c create mode 100644 sysdeps/linux/procuid.c create mode 100644 sysdeps/linux/sem_limits.c create mode 100644 sysdeps/linux/shm_limits.c create mode 100644 sysdeps/linux/swap.c create mode 100644 sysdeps/linux/uptime.c create mode 100644 sysdeps/names/.cvsignore create mode 100644 sysdeps/names/Makefile.am create mode 100644 sysdeps/names/cpu.c create mode 100644 sysdeps/names/loadavg.c create mode 100644 sysdeps/names/mem.c create mode 100644 sysdeps/names/msg_limits.c create mode 100644 sysdeps/names/procdata.c create mode 100644 sysdeps/names/prockernel.c create mode 100644 sysdeps/names/proclist.c create mode 100644 sysdeps/names/procmem.c create mode 100644 sysdeps/names/procsegment.c create mode 100644 sysdeps/names/procsignal.c create mode 100644 sysdeps/names/procstate.c create mode 100644 sysdeps/names/proctime.c create mode 100644 sysdeps/names/procuid.c create mode 100644 sysdeps/names/sem_limits.c create mode 100644 sysdeps/names/shm_limits.c create mode 100644 sysdeps/names/swap.c create mode 100644 sysdeps/names/sysdeps.c create mode 100644 sysdeps/names/uptime.c create mode 100644 sysdeps/osf1/.cvsignore create mode 100644 sysdeps/osf1/Makefile.am create mode 100644 sysdeps/osf1/close.c create mode 100644 sysdeps/osf1/cpu.c create mode 100644 sysdeps/osf1/glibtop_machine.h create mode 100644 sysdeps/osf1/init.c create mode 100644 sysdeps/osf1/mem.c create mode 100644 sysdeps/osf1/msg_limits.c create mode 100644 sysdeps/osf1/open.c create mode 100644 sysdeps/osf1/procdata.c create mode 100644 sysdeps/osf1/prockernel.c create mode 100644 sysdeps/osf1/proclist.c create mode 100644 sysdeps/osf1/procmem.c create mode 100644 sysdeps/osf1/procsegment.c create mode 100644 sysdeps/osf1/procsignal.c create mode 100644 sysdeps/osf1/procstate.c create mode 100644 sysdeps/osf1/proctime.c create mode 100644 sysdeps/osf1/procuid.c create mode 100644 sysdeps/osf1/sem_limits.c create mode 100644 sysdeps/osf1/shm_limits.c create mode 100644 sysdeps/osf1/swap.c create mode 100644 sysdeps/stub/.cvsignore create mode 100644 sysdeps/stub/Makefile.am create mode 100644 sysdeps/stub/close.c create mode 100644 sysdeps/stub/cpu.c create mode 100644 sysdeps/stub/init.c create mode 100644 sysdeps/stub/libsysdeps.la create mode 100644 sysdeps/stub/mem.c create mode 100644 sysdeps/stub/msg_limits.c create mode 100644 sysdeps/stub/open.c create mode 100644 sysdeps/stub/prockernel.c create mode 100644 sysdeps/stub/proclist.c create mode 100644 sysdeps/stub/procmem.c create mode 100644 sysdeps/stub/procsegment.c create mode 100644 sysdeps/stub/procsignal.c create mode 100644 sysdeps/stub/procstate.c create mode 100644 sysdeps/stub/proctime.c create mode 100644 sysdeps/stub/procuid.c create mode 100644 sysdeps/stub/sem_limits.c create mode 100644 sysdeps/stub/shm_limits.c create mode 100644 sysdeps/stub/swap.c create mode 100644 sysdeps/sun4/.cvsignore create mode 100644 sysdeps/sun4/Makefile.am create mode 100644 sysdeps/sun4/close.c create mode 100644 sysdeps/sun4/cpu.c create mode 100644 sysdeps/sun4/init.c create mode 100644 sysdeps/sun4/libsysdeps.la create mode 100644 sysdeps/sun4/mem.c create mode 100644 sysdeps/sun4/msg_limits.c create mode 100644 sysdeps/sun4/open.c create mode 100644 sysdeps/sun4/procdata.c create mode 100644 sysdeps/sun4/prockernel.c create mode 100644 sysdeps/sun4/proclist.c create mode 100644 sysdeps/sun4/procmem.c create mode 100644 sysdeps/sun4/procsegment.c create mode 100644 sysdeps/sun4/procsignal.c create mode 100644 sysdeps/sun4/procstate.c create mode 100644 sysdeps/sun4/proctime.c create mode 100644 sysdeps/sun4/procuid.c create mode 100644 sysdeps/sun4/sem_limits.c create mode 100644 sysdeps/sun4/shm_limits.c create mode 100644 sysdeps/sun4/swap.c diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 00000000..de689a21 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,24 @@ +Makefile +Makefile.in +aclocal.m4 +alpha-dec-osf1 +autoh31167 +config.cache +config.h +config.h.in +config.log +config.status +configure +gtopConf.sh +i386-bsdi +i686-pc-linux-gnu +intl +libgtop-mirror.sh.swp +libtool +ltconfig +stamp-h +sun4 +sun4sol2 +ltmain.sh +macros +support diff --git a/ANNOUNCE b/ANNOUNCE new file mode 100644 index 00000000..2a54966d --- /dev/null +++ b/ANNOUNCE @@ -0,0 +1,95 @@ +Hi all, + +I just uploaded the first working draft alpha version 0.01 to my website: + + http://www.home-of-linux.org/gnome/libgtop/ + +Libgtop is 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. For other systems such as Solaris, where such programs need to be +suid root (or only setgid kmem/mem on some systems), it provides a suid/setgid server that +fetches those information and a client-side library that talks to this server. Main idea +was to have the same interface for all operating systems, thus all system dependent details +are hidden in the implementation of that server. + +Currently, it only works for Linux, documentation on how to port it to other systems is on +the way. I'm planning to keep this site an up-to-date mirror of my local machine (which is +connected to the internet over some expensive dialup connection, so I'll upload it about +once every day I made significant changes) so that you can always find the latest version +of the software here. + +I've written a simple guile interface for the library to show which information it can +already fetch. See examples/third for details. + +=========================================================================================== + +#include +#include +#include + +#include + +int +main (int argc, char *argv []) +{ + glibtop server; + glibtop_cpu cpu; + unsigned i, *ptr; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, GTOPLOCALEDIR); + textdomain (PACKAGE); + + glibtop_open (&server, argv [0]); + + glibtop_get_cpu (&server, &cpu); + + fprintf (stderr, "CPU: %lu, %lu, %lu, %lu, %lu\n", + cpu.total, cpu.user, cpu.nice, cpu.sys, cpu.idle); + + glibtop_close (&server); + + exit (0); +} + +=========================================================================================== + +The following scheme code is used in examples/third to show all information that is +currently available: + + (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) + +On my system, this yields: + +(3796245 348706 66 89999 3357474) +(31715328 31354880 360448 13385728 401408 7237632 17567744) +(133885952 42160128 91725824) +(37962.49 33574.74) +(0.01 0.02 0.0) +(33554432 1 128 128 4194304) +(2048 16384 4056 16384 128 16 16384) +(4096 128 4096 4096 32 32 32 20 32767 16383) +(31 127 7 3 1 31 127 1023 3) +(71 4 284 1 2 3 246 247 210 8 48 81 83 153 157 167 170 171 172 173 174 175 178 181 195 191 200 203 207 248 215 216 217 220 222 227 245 249 250 251 253 254 315 267 331 373 338 334 335 345 337 372 374 342 343 344 375 14445 13119 6438 14555 13118 13801 6439 17362 18411 18455 6521 6522 6523 23979 23980 7905 7906) + +=========================================================================================== + +Better documentation is on the way! There's still a little bit under the URL above. + +Enjoy it! + +Martin + + + + + diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..702002a3 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Martin Baulig (martin@home-of-linux.org) diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..83fedd85 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,393 @@ +1998-05-17 Martin Baulig + + * NEWS: added some stuff from 'README.LATEST'. + + * README.LATEST: incorporated content of this file + into 'NEWS'. + + * include/glibtop: added references to + 'glibtop_types_* []' and 'glibtop_guile_types_*'. + + * sysdeps/guile/names: added implementations of + 'glibtop_types_*' and 'glibtop_description_*'. + + * sysdeps/names: added 'glibtop_types_* []', + changed 'glibtop_descriptions_* []'. + +1998-05-11 Martin Baulig + + * sysdeps/linux: finished the remaining proc_* + functions. + + * sysdeps/guile: all guile functions now return + the 'flags' member as first element of the list. + + * include/glibtop/procstate.h (glibtop_proc_state): + added 'uid' and 'gid' members; the library tries hard + to set those values; it will never set the corresponding + 'flags' value unless the values are correct. + + * examples/first.c: added some nice features. + + * examples/second.c: new file - dumps out all + currently running processes. + +1998-05-11 Martin Baulig + + * sysdeps/linux/cpu.c: added 'frequency' member + to 'struct _glibtop_cpu'. + + * include/glibtop/cpu.h (glibtop_cpu): + added 'frequency' member + + * sysdeps/guile/names/procdata.c: splitted into + procstate.c, procuid.c, procmem.c, proctime.c, + procsignal.c, prockernel.c and procsegment.c + + * sysdeps/guile/procdata.c: splitted into + procstate.c, procuid.c, procmem.c, proctime.c, + procsignal.c, prockernel.c and procsegment.c + + * lib/procdata.c: splitted into + procstate.c, procuid.c, procmem.c, proctime.c, + procsignal.c, prockernel.c and procsegment.c + + * include/glibtop/procdata.h: splitted into + procstate.h, procuid.h, procmem.h, proctime.h, + procsignal.h, prockernel.h and procsegment.h + +1998-05-10 Martin Baulig + + * sysdeps/osf1: port to OSF1 has been made. + +1998-05-07 Martin Baulig + + * sysdeps/guile/sysdeps.c: changes to reflect the + new flags of procdata. + + * sysdeps/common/sysdeps.c: changes to reflect the + new flags of procdata. + + * sysdeps/linux/procdata.c: 'flags' member is now + 'unsigned long flags [2]'. When we give + glibtop_get_procdata () a pid of zero, only + the flags are returned. + + * sysdeps/linux: now using static constant instead + of #define for sysdeps. + + * include/glibtop/procdata.h: flags is now + 'unsigned long flags [2]'. + + * examples/first.c: output sysdeps + +1998-05-03 Martin Baulig + + * ltconfig.diff: ugly hack: when cross compiling, we assume + building shared libraries work. + +1998-05-02 Martin Baulig + + * sysdeps/stub/init.c: new file - initializes global server. + + * sysdeps/linux/init.c: new file - initializes global server. + + * lib/init.c: new file - initializes global server. + + * glibtop.h: global changes to the interfaces, all functions except + glibtop_open() and glibtop_close() that took a server argument have + now a '__r' suffix; the original name is now a macro that uses + glibtop_global_server. + +1998-04-12 Martin Baulig + + * sysdeps/linux/open.c: we set server->os_version_code here, + copied from gnome-utils/gtop/proc/version.c + + * sysdeps/linux/procdata.c: added implementation for this feature, + mainly copied from gnome-utils/gtop/proc/readproc.c + + * glibtop.h: added os_version_code member to struct _glibtop + + * src/server/Makefile.am: moved here from src + + * src/server/version.c: moved here from src + + * src/server/output.c: moved here from src + + * src/server/main.c: moved here from src + + * src/mico/server.cc: new file - simple mico client + + * src/mico/client.cc: new file - simple mico client + + * src/mico/proclist.idl: new file - simple mico interface + + * src/version.c: moved to src/server + + * src/output.c: moved to src/server + + * src/main.c: moved to src/server + +1998-04-11 Martin Baulig + + * doc/libgtop.sgml: added chapter on how to extend the library + + * sysdeps/names/procdata.c: new file - names for glibtop_procdata + + * sysdeps/linux/procdata.c: new file - copy from sysdeps/stub + + * sysdeps/stub/procdata.c: new file - stub for glibtop_procdata + + * sysdeps/guile/names/procdata.c: new file - guile names for glibtop_procdata + + * sysdeps/guile/procdata.c: new file - guile interface for glibtop_procdata + + * lib/procdata.c: new file - library function for glibtop_procdata + + * include/glibtop/procdata.h: new file - interface for glibtop_procdata - + get detailed information about a process + +1998-04-10 Martin Baulig + + * doc/libgtop.sgml: wrote some more documentation + + * NEWS: Added new directory sysdeps/guile/names. It is the guile interface + to the gtop_names library found in sysdeps/names. Changed + GLIBTOP_DESCRIPTIONS to GLIBTOP_NAMES and added GLIBTOP_GUILE_NAMES + to the header files. + + * sysdeps/guile/names/boot.c: new file - added also + cpu.c, mem.c, swap.c, uptime.c, loadavg.c, shm_limits.c, + msg_limits.c, sem_limits.c, proclist.c and sysdeps.c + to this directory. + + * sysdeps/guile/cpu.c: bugfixes + + * sysdeps/guile/proclist.c: bugfixes + + * sysdeps/names/sysdeps.c (glibtop_labels_sysdeps): more verbose now + + * examples/third.c: added gtop_guile_names library + + * doc/libgtop.sgml: documented guile interface + + * glibtop.h: changed GLIBTOP_DESCRIPTIONS to GLIBTOP_NAMES; + added GLIBTOP_GUILE_NAMES when we have the gtop_guile_names + library added in sysdeps/guile/names + +1998-04-09 Martin Baulig + + * NEWS: Added new directories guile and names to sysdeps. In names are + some string constants about the data stored in the structures. + guile is a guile interface for the library. It is used in + examples /third (which has been completely rewritten). + The header files define things from names when GLIBTOP_DESCRIPTIONS + if defined and/or from guile when HAVE_GUILE is defined. + + * sysdeps/names/cpu.c: new file, also added + cpu.c, mem.c, swap.c, uptime.c loadavg.c, shm_limits.c, + msg_limits.c, sem_limits.c, proclist.c and sysdeps.c to + this directory + + * sysdeps/guile/boot.c: new file, also added + cpu.c, mem.c, swap.c, uptime.c loadavg.c, shm_limits.c, + msg_limits.c, sem_limits.c, proclist.c and sysdeps.c to + this directory + + * sysdeps/common/sem_limits.c: moved to sysdeps/names + + * sysdeps/common/msg_limits.c: moved to sysdeps/names + + * sysdeps/common/sem_limits.c: moved to sysdeps/names + + * examples/third.c: completely rewritten - simple guile interpreter linked + with libgtop_guile + + * examples/second.c: removed + +1998-04-08 Martin Baulig + + * ANNOUNCE: new file + + * examples/third.scm: new file - sample guile file + + * examples/third.c: new file - guile wrapper for libgtop + + * examples/second.c: new file - simple guile test from guile-tut.info + + * README: new file + + * libgtop-mirror.sh: new file: mirror script for my web site + + * doc/dbtohtml.dsl: renamed to libgtop.dsl + +1998-04-06 Martin Baulig + + * lib/command.c: some changes in the interface + + * src/main.c: some changes in the interface, we can now return + some arbitrary data + + * lib/proclist.c: new file - library function for glibtop_proclist + + * sysdeps/linux/proclist.c: new file - implementation for glibtop_proclist + + * sysdeps/stub/proclist.c: new file - stub for glibtop_proclist + + * include/glibtop/proclist.h: new file - glibtop_proclist + + * include/glibtop/union.h: new file + + * lib/read_data.c: new file + + * include/glibtop/read_data.h: new file + + * sysdeps/common/xmalloc.c: new file - moved here from lib + + * sysdeps/common/error.c: new file - moved here from lib + + * lib/xmalloc.c: moved to sysdeps/common + + * lib/error.c: moved to sysdeps/common + +1998-04-05 Martin Baulig + + * lib/shm_limits.c: new file - library function for + glibtop_shm_limits + + * lib/msg_limits.c: new file - library function for + glibtop_msg_limits + + * lib/sem_limits.c: new file - library function for + glibtop_sem_limits + + * sysdeps/linux/shm_limits.c: new file - implementation for + glibtop_shm_limits + + * sysdeps/linux/msg_limits.c: new file - implementation for + glibtop_msg_limits + + * sysdeps/linux/sem_limits.c: new file - implementation for + glibtop_sem_limits + + * sysdeps/stub/shm_limits.c: new file - stub for + glibtop_shm_limits + + * sysdeps/stub/msg_limits.c: new file - stub for + glibtop_msg_limits + + * sysdeps/stub/sem_limits.c: new file - stub for + glibtop_sem_limits + + * sysdeps/common/shm_limits.c: new file - limit names + + * sysdeps/common/msg_limits.c: new file - limit names + + * sysdeps/common/sem_limits.c: new file - limit names + + * include/glibtop/shm_limits.h: new file - glibtop_shm_limits + + * include/glibtop/msg_limits.h: new file - glibtop_msg_limits + + * include/glibtop/sem_limits.h: new file - glibtop_sem_limits + + * sysdeps/common/sysdeps.c: moved here from sysdeps/stub + + * sysdeps/linux/sysdeps.c: moved to sysdeps/common + + * sysdeps/stub/sysdeps.c: moved to sysdeps/common + + * sysdeps/stub/ipc_limits.c: splitted info shm_limits.c, msg_limits.c + and sem_limits.c + + * sysdeps/linux/ipc_limits.c: splitted into shm_limits.c, msg_limits.c + and sem_limits.c + + * lib/ipc_limits.c: splitted into shm_limits.c, msg_limits.c + and sem_limits.c + + * include/ipc_limits.h: splitted into shm_limits.h, msg_limits.h + and sem_limits.s + + * lib/ipc_limits.c: new file - library function for + glibtop_ipc_limits + + * sysdeps/linux/ipc_limits.c: new file - implementation for + glibtop_ipc_limits + + * sysdeps/stub/ipc_limits.c: new file - stub for + glibtop_ipc_limits + + * include/glibtop/ipc_limits.h: new file - glibtop_ipc_limits - + sysv ipc limits + + * doc/libgtop.sgml: worked on documentation + + * lib/uptime.c: new file - library function for + glibtop_uptime + + * lib/loadavg.c: new file - library function for + glibtop_loadavg + + * lib/sysinfo.c: removed - splitted into + uptime.c and loadavg.c + + * sysdeps/linux/uptime.c: new file - implementation for + glibtop_uptime + + * sysdeps/linux/loadavg.c: new file - implementation for + glibtop_loadavg + + * sysdeps/linux/sysinfo.c: removed - splitted into + uptime.c and loadavg.c + + * sysdeps/stub/uptime.c: new file - stub for + glibtop_uptime + + * sysdeps/stub/loadavg.c: new file - stub for + glibtop_loadavg + + * sysdeps/stub/sysinfo.c: removed - splitted into + uptime.c and loadavg.c + + * src/main.c: added GLIBTOP_CMND_UPTIME and + GLIBTOP_CMND_LOADAVG implementation + + * include/glibtop/loadavg.h: new file - glibtop_loadavg + + * include/glibtop/uptime.h: new file - glibtop_uptime + + * include/glibtop/loadavg.h: removed - splitted into + uptime.h and loadavg.h + + * src/main.c: added GLIBTOP_CMND_SYSDEPS implementation + + * lib/sysdeps.c: new file - library function for glibtop_sysdeps + + * sysdeps/linux/sysdeps.c: new file - copied from sysdeps/stub + + * sysdeps/stub/sysdeps.c: new file - implementation for glibtop_sysinfo - + this is really the implementation and not just a stub + + * src/sysdeps.c: moved to sysdeps/stub - this file is now part + of the library + + * lib/sysinfo.c: new file - library function for glibtop_sysinfo + + * sysdeps/linux/sysinfo.c: new file - linux version for glibtop_sysinfo + + * sysdeps/stub/sysinfo.c: new file - stub for glibtop_sysinfo + + * include/glibtop/sysinfo.h: new file - provides uptime, idle time + and load averange. + + * po/libgtop.pot: removed file + + * sysdeps/linux/cpu.c: using long unsigned format + * sysdeps/linux/mem.c: using long usigned format + * sysdeps/linux/swap.c: using long unsigned format + * examples/first.c: using long unsigned format + + * initial version. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..cfc36ad3 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,41 @@ +## Process this file with automake to produce Makefile.in. + +built_SUBDIRS = sysdeps src lib examples + +SUBDIRS = po intl support macros $(built_SUBDIRS) + +include_HEADERS = + +EXTRA_DIST = gtopConf.sh.in + +release: + $(MAKE) dist distdir=$(PACKAGE)$(VERSION) + +## Put `exec' in the name because this should be installed by +## `install-exec', not `install-data'. +confexecdir=$(libdir) +confexec_DATA = $(top_builddir)/gtopConf.sh + +## to automatically rebuild aclocal.m4 if any of the macros in +## `macros/' change +@MAINT@include macros/macros.dep +@MAINT@macros/macros.dep: macros/Makefile.am +@MAINT@ cd macros && $(MAKE) macros.dep + +## We create gtopConf.sh here and not from configure because we want +## to get the paths expanded correctly. Macros like srcdir are given +## the value NONE in configure if the user doesn't specify them (this +## is an autoconf feature, not a bug). +gtopConf.sh: gtopConf.sh.in Makefile +## Use sed and then mv to avoid problems if the user interrupts. + sed -e 's,\@GTOP_LIBDIR\@,$(libdir),g' \ + -e 's,\@GTOP_INCLUDEDIR\@,$(includedir),g' \ + -e 's,\@GTOP_LIBS\@,$(GTOP_LIBS),g' \ + -e 's,\@GTOP_INCS\@,$(GTOP_INCS),g' \ + -e 's,\@GTOP_BINDIR\@,$(GTOP_BINDIR),g' \ + -e 's,\@GTOP_SERVER\@,$(GTOP_SERVER),g' \ + -e 's,\@GTOP_SYSDEPS_DIR\@,$(sysdeps_dir),g' \ + -e 's,\@GTOP_NEED_SERVER\@,$(need_server),g' \ + -e 's,\@GTOP_USE_MACHINE_H\@,$(use_glibtop_machine_h),g' \ + < $(srcdir)/gtopConf.sh.in > gtopConf.tmp \ + && mv gtopConf.tmp gtopConf.sh diff --git a/NEWS b/NEWS new file mode 100644 index 00000000..1a067145 --- /dev/null +++ b/NEWS @@ -0,0 +1,96 @@ +$Id$ + +May/17/1998 +=========== + +* we have now 'const char *glibtop_types_* []' consisting + of the C types of the corresponding files of '_glibtop_*'. + +* added guile function '(glibtop-types-*)' and '(glibtop-descriptions-*)'. + +May/10/1998 +=========== + +* Port to DEC OSF1 3.0 has been made: + + cpu (total, user, nice, sys, idle) + mem (total, used, free) + + loadavg (loadavg) + uptime (uptime) + + msg_limits (map, max, mnb, mni, tql) + sem_limits (mni, msl, opm, vmx, aem) + shm_limits (max, min, mni, seg) + + The following need the server to be SUID root: + + proclist (total, number, size) + procdata (cmd, state, uid, pid, ppid, pgrp, tty, k_flags, + session, tpgid, sigignore, sigcatch, signal, nice, + priority, resident, rss, vsize, utime, stime, + cutime, cstime, trs, drs) + +May/07/1998 +=========== + +* 'flags' member of sysdeps/linux/procdata.c is now + 'unsigned long flags [2]'. + +* When we give glibtop_get_procdata () a pid of zero, only + the flags are returned. + +* We now use static constants instead of #defines for sysdeps flags. + +May/03/1998 +=========== + +* VPATH-Build now working; sometimes it's necessary to copy + $(top_srcdir)/po/cat-id-tbl.c to $(top_builddir)/po. + +* The library has been tested on the following systems: + + - i686-pc-linux-gnu + - sparc-sun-sunos4.1.1 + - alpha-dec-osf1 (that's DEC OSF1 3.0 and 3.2) + +* Compilation has been tested on the following systems (I have no root + access there and cannot test the library because of this): + + - sparc-sun-solaris2 + - i386-bsdi + +* Does no longer require Gnome. + +* Guile-Parts are compiled only if guile can be found. + +* Some of the executables are statically linked to copy them more easily + between machines. + +May/02/1998 +=========== + + * Global changes to the interfaces, all functions except glibtop_open() + and glibtop_close() that took a server argument have now a '__r' suffix; + the original name is now a macro that uses glibtop_global_server. + +Apr/10/1998 +=========== +Added new directory sysdeps/guile/names. It is the guile interface +to the gtop_names library found in sysdeps/names. Changed +GLIBTOP_DESCRIPTIONS to GLIBTOP_NAMES and added GLIBTOP_GUILE_NAMES +to the header files. + +Apr/09/1998 +=========== +Added new directories guile and names to sysdeps. In names are +some string constants about the data stored in the structures. +guile is a guile interface for the library. It is used in +examples/third (which has been completely rewritten). +The header files define things from names when GLIBTOP_DESCRIPTIONS +if defined and/or from guile when HAVE_GUILE is defined. + +Apr/08/1998 +=========== + +Added guile wrapper for the library (see examples/third). diff --git a/README b/README new file mode 100644 index 00000000..5cfe7a3a --- /dev/null +++ b/README @@ -0,0 +1,57 @@ +Hi all, + +[PLEASE READ THE FILE ``README.LATEST'' FOR LATEST NEWS] + +this is the latest alpha version of libgtop, 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. For other systems such as Solaris, +where such programs need to be suid root (or only setgid kmem/mem on +some systems), it provides a suid/setgid server that fetches those +information and a client-side library that talks to this server. + +Main idea was to have the same interface for all operating systems, +thus all system dependent details are hidden in the implementation +of that server. + +Currently, it only works for Linux, documentation on how to port it +to other systems is on the way. I'm planning to keep this site an +up-to-date mirror of my local machine (which is connected to the +internet over some expensive dialup connection, so I'll upload it about +once every day I made significant changes) so that you can always find +the latest version of the software here. + +I've written a simple guile interface for the library to show which +information it can already fetch. See examples/third for details. + +Source Code: +=========== + + libgtop-current-cvs.cpio.gz is a cpio archive from the CVS repository + libgtop-current.cpio.gz contains the lates checked out sources + libgtop-stable.cpio.gz if present, it contains the last stable release + +Documentation: +============= + + libgtop.sgml is the SGML source of the (DocBook) documentation + +The next three files are only provided until they get too big to upload. + + libgtop.tex TEX file of the documentation + libgtop.dvi DVI file of the documentation + libgtop.ps Postscript file of the documentation + +HTML-Documentation: +================== + + libgtop.shtml Start here to browse the HTML documentation + +Other stuff: +=========== + + README, NEWS, ChangeLog copied from the sources + +Enjoy it! + +Martin (martin@home-of-linux.org - baulig@merkur.uni-trier.de) diff --git a/README.LATEST b/README.LATEST new file mode 100644 index 00000000..20129586 --- /dev/null +++ b/README.LATEST @@ -0,0 +1,8 @@ +$Id$ + +LATEST NEWS: +=========== + +Please look also in the file 'NEWS' for latest news. + +Martin diff --git a/acconfig.h b/acconfig.h new file mode 100644 index 00000000..16425574 --- /dev/null +++ b/acconfig.h @@ -0,0 +1,30 @@ +#undef ENABLE_NLS +#undef HAVE_CATGETS +#undef HAVE_GETTEXT +#undef HAVE_LC_MESSAGES +#undef HAVE_STPCPY +#undef HAVE_STRUCT_OSOCKADDR +#undef PACKAGE +#undef VERSION +#undef HAVE_LIBSM +#undef HAVE_LIBINTL_H +#undef HAVE_GTK_SIGNAL_HANDLER_PENDING + +/* Do not remove this comments and the empty lines; they are needed */ +#undef HAVE_PROGRAM_INVOCATION_SHORT_NAME + +/* to fix a bug in autoheader on DEC OSF1. */ +#undef HAVE_PROGRAM_INVOCATION_NAME + +#undef HAVE_LIBJPEG +#undef HAVE_LIBGIF +#undef HAVE_LIBTIFF +#undef HAVE_LIBZ +#undef HAVE_LIBPNG +#undef GNOME_ENABLE_DEBUG +#undef HAVE_GMP2_INCLUDE_DIR +#undef HAVE_GUILE +#undef ssize_t + +#undef HAVE_GLIBTOP_MACHINE_H + diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 00000000..d9148c37 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,960 @@ +dnl aclocal.m4 generated automatically by aclocal 1.2h + +dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +dnl This Makefile.in is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +AC_DEFUN([AC_LC_CANONICAL_HOST],[ + AC_REQUIRE([AC_CANONICAL_HOST]) + # The way shlib-versions is used to generate soversions.mk uses a + # fairly simplistic model for name recognition that can't distinguish + # i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os + # of `gnu*' here to be `gnu-gnu*' just so that shlib-versions can + # tell. This doesn't get used much beyond that, so it's fairly safe. + case "$host_os" in + linux*) + ;; + gnu*) + host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'` + ;; + esac +]) + + +AC_DEFUN([AC_LC_SYSDEPS],[ + AC_REQUIRE([AC_LC_CANONICAL_HOST]) + AC_MSG_CHECKING(for sysdeps directory) + AC_ARG_WITH(sysdeps, + [ --with-sysdeps=dir which sysdeps directory should be used [default=auto]], + [if test "x$withval" = "xyes" ; then + ac_cv_sysdeps_dir=yes + elif test "x$withval" = "xauto" ; then + ac_cv_sysdeps_dir=yes + else + ac_cv_sysdeps_dir=$withval + fi],[ac_cv_sysdeps_dir=yes]) + if test "x$ac_cv_sysdeps_dir" = "xyes" ; then + case "$host_os" in + linux*) + sysdeps_dir=linux + use_glibtop_machine_h=no + need_server=no + ;; + sunos4*) + sysdeps_dir=sun4 + use_glibtop_machine_h=no + need_server=yes + ;; + osf*) + sysdeps_dir=osf1 + use_glibtop_machine_h=yes + AC_DEFINE(HAVE_GLIBTOP_MACHINE_H) + need_server=yes + ;; + *) + sysdeps_dir=stub + use_glibtop_machine_h=no + need_server=no + ;; + esac + elif test "x$ac_cv_sysdeps_dir" = "xno" ; then + sysdeps_dir=stub + else + sysdeps_dir=stub + fi + test -d $srcdir/sysdeps/$sysdeps_dir || sysdeps_dir=stub + AC_MSG_RESULT($sysdeps_dir) + AC_SUBST(sysdeps_dir) + AC_SUBST(need_server) +]) + + +# 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>>, <<[^ ]>>, <<>>), <<>>, +<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<>; 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 +]) + +# +# 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 + +# 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 + #include + ],[ + 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. + /*) + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # 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 + 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 + 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) +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_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 &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 + 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) +]) + +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 ],[ + 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 ],[ + 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) +]) + +# Macro to add for using GNU gettext. +# Ulrich Drepper , 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 3 + +AC_DEFUN(AM_WITH_NLS, + [AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE(nls, + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT($USE_NLS) + AC_SUBST(USE_NLS) + + USE_INCLUDED_LIBINTL=no + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + AC_DEFINE(ENABLE_NLS) + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH(included-gettext, + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If gettext or catgets are available (in this order) we + dnl use this. Else we have to fall back to GNU NLS library. + dnl catgets is only used if permitted by option --with-catgets. + nls_cv_header_intl= + nls_cv_header_libgt= + CATOBJEXT=NONE + + AC_CHECK_HEADER(libintl.h, + [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc, + [AC_TRY_LINK([#include ], [return (int) gettext ("")], + gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)]) + + if test "$gt_cv_func_gettext_libc" != "yes"; then + AC_CHECK_LIB(intl, bindtextdomain, + [AC_CACHE_CHECK([for gettext in libintl], + gt_cv_func_gettext_libintl, + [AC_TRY_LINK([], [return (int) gettext ("")], + gt_cv_func_gettext_libintl=yes, + gt_cv_func_gettext_libintl=no)])]) + fi + + if test "$gt_cv_func_gettext_libc" = "yes" \ + || test "$gt_cv_func_gettext_libintl" = "yes"; then + AC_DEFINE(HAVE_GETTEXT) + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl + if test "$MSGFMT" != "no"; then + AC_CHECK_FUNCS(dcgettext) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; + return _nl_msg_cat_cntr], + [CATOBJEXT=.gmo + DATADIRNAME=share], + [CATOBJEXT=.mo + DATADIRNAME=lib]) + INSTOBJEXT=.mo + fi + fi + ]) + + if test "$CATOBJEXT" = "NONE"; then + AC_MSG_CHECKING([whether catgets can be used]) + AC_ARG_WITH(catgets, + [ --with-catgets use catgets functions if available], + nls_cv_use_catgets=$withval, nls_cv_use_catgets=no) + AC_MSG_RESULT($nls_cv_use_catgets) + + if test "$nls_cv_use_catgets" = "yes"; then + dnl No gettext in C library. Try catgets next. + AC_CHECK_LIB(i, main) + AC_CHECK_FUNC(catgets, + [AC_DEFINE(HAVE_CATGETS) + INTLOBJS="\$(CATOBJS)" + AC_PATH_PROG(GENCAT, gencat, no)dnl + if test "$GENCAT" != "no"; then + AC_PATH_PROG(GMSGFMT, gmsgfmt, no) + if test "$GMSGFMT" = "no"; then + AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no) + fi + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + USE_INCLUDED_LIBINTL=yes + CATOBJEXT=.cat + INSTOBJEXT=.cat + DATADIRNAME=lib + INTLDEPS='$(top_builddir)/intl/libintl.a' + INTLLIBS=$INTLDEPS + LIBS=`echo $LIBS | sed -e 's/-lintl//'` + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi]) + fi + fi + + if test "$CATOBJEXT" = "NONE"; then + dnl Neither gettext nor catgets in included in the C library. + dnl Fall back on GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + INTLOBJS="\$(GETTOBJS)" + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + AC_SUBST(MSGFMT) + USE_INCLUDED_LIBINTL=yes + CATOBJEXT=.gmo + INSTOBJEXT=.mo + DATADIRNAME=share + INTLDEPS='$(top_builddir)/intl/libintl.a' + INTLLIBS=$INTLDEPS + LIBS=`echo $LIBS | sed -e 's/-lintl//'` + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi + + dnl Test whether we really found GNU xgettext. + if test "$XGETTEXT" != ":"; then + dnl If it is no GNU xgettext we define it as : so that the + dnl Makefiles still can work. + if $XGETTEXT --omit-header /dev/null 2> /dev/null; then + : ; + else + AC_MSG_RESULT( + [found xgettext programs is not GNU xgettext; ignore it]) + XGETTEXT=":" + fi + fi + + # We need to process the po/ directory. + POSUB=po + else + DATADIRNAME=share + nls_cv_header_intl=intl/libintl.h + nls_cv_header_libgt=intl/libgettext.h + fi + + # If this is used in GNU gettext we have to set USE_NLS to `yes' + # because some of the sources are only built for this goal. + if test "$PACKAGE" = gettext; then + USE_NLS=yes + USE_INCLUDED_LIBINTL=yes + fi + + dnl These rules are solely for the distribution goal. While doing this + dnl we only have to keep exactly one list of the available catalogs + dnl in configure.in. + for lang in $ALL_LINGUAS; do + GMOFILES="$GMOFILES $lang.gmo" + POFILES="$POFILES $lang.po" + done + + dnl Make all variables we use known to autoconf. + AC_SUBST(USE_INCLUDED_LIBINTL) + AC_SUBST(CATALOGS) + AC_SUBST(CATOBJEXT) + AC_SUBST(DATADIRNAME) + AC_SUBST(GMOFILES) + AC_SUBST(INSTOBJEXT) + AC_SUBST(INTLDEPS) + AC_SUBST(INTLLIBS) + AC_SUBST(INTLOBJS) + AC_SUBST(POFILES) + AC_SUBST(POSUB) + ]) + +AC_DEFUN(AM_GNU_GETTEXT, + [AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_PROG_RANLIB])dnl + AC_REQUIRE([AC_ISC_POSIX])dnl + AC_REQUIRE([AC_HEADER_STDC])dnl + AC_REQUIRE([AC_C_CONST])dnl + AC_REQUIRE([AC_C_INLINE])dnl + AC_REQUIRE([AC_TYPE_OFF_T])dnl + AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([AC_FUNC_ALLOCA])dnl + AC_REQUIRE([AC_FUNC_MMAP])dnl + + AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \ +unistd.h values.h sys/param.h]) + AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \ +__argz_count __argz_stringify __argz_next]) + + if test "${ac_cv_func_stpcpy+set}" != "set"; then + AC_CHECK_FUNCS(stpcpy) + fi + if test "${ac_cv_func_stpcpy}" = "yes"; then + AC_DEFINE(HAVE_STPCPY) + fi + + AM_LC_MESSAGES + AM_WITH_NLS + + if test "x$CATOBJEXT" != "x"; then + if test "x$ALL_LINGUAS" = "x"; then + LINGUAS= + else + AC_MSG_CHECKING(for catalogs to be installed) + NEW_LINGUAS= + for lang in ${LINGUAS=$ALL_LINGUAS}; do + case "$ALL_LINGUAS" in + *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; + esac + done + LINGUAS=$NEW_LINGUAS + AC_MSG_RESULT($LINGUAS) + fi + + dnl Construct list of names of catalog files to be constructed. + if test -n "$LINGUAS"; then + for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done + fi + fi + + dnl The reference to in the installed file + dnl must be resolved because we cannot expect the users of this + dnl to define HAVE_LOCALE_H. + if test $ac_cv_header_locale_h = yes; then + INCLUDE_LOCALE_H="#include " + else + INCLUDE_LOCALE_H="\ +/* The system does not provide the header . Take care yourself. */" + fi + AC_SUBST(INCLUDE_LOCALE_H) + + dnl Determine which catalog format we have (if any is needed) + dnl For now we know about two different formats: + dnl Linux libc-5 and the normal X/Open format + test -d intl || mkdir intl + if test "$CATOBJEXT" = ".cat"; then + AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen) + + dnl Transform the SED scripts while copying because some dumb SEDs + dnl cannot handle comments. + sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed + fi + dnl po2tbl.sed is always needed. + sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ + $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed + + dnl In the intl/Makefile.in we have a special dependency which makes + dnl only sense for gettext. We comment this out for non-gettext + dnl packages. + if test "$PACKAGE" = "gettext"; then + GT_NO="#NO#" + GT_YES= + else + GT_NO= + GT_YES="#YES#" + fi + AC_SUBST(GT_NO) + AC_SUBST(GT_YES) + + dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly + dnl find the mkinstalldirs script in another subdir but ($top_srcdir). + dnl Try to locate is. + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + AC_SUBST(MKINSTALLDIRS) + + dnl *** For now the libtool support in intl/Makefile is not for real. + l= + AC_SUBST(l) + + dnl Generate list of files to be processed by xgettext which will + dnl be included in po/Makefile. + test -d po || mkdir po + if test "x$srcdir" != "x."; then + if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then + posrcprefix="$srcdir/" + else + posrcprefix="../$srcdir/" + fi + else + posrcprefix="../" + fi + rm -f po/POTFILES + 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 , 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 . +# Ulrich Drepper , 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 ], [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]) + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 00000000..13ee7e0c --- /dev/null +++ b/autogen.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +PKG_NAME="Gnome Top Library" + +(test -f $srcdir/configure.in \ + && test -f $srcdir/copyright.txt \ + && test -d $srcdir/sysdeps) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level gnome directory" + exit 1 +} + +. $srcdir/macros/autogen.sh diff --git a/config.guess b/config.guess new file mode 100755 index 00000000..413ed41c --- /dev/null +++ b/config.guess @@ -0,0 +1,883 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. +# +# This file 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 of the License, or +# (at your option) any later version. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# The master version of this file is at the FSF in /home/gd/gnu/lib. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:NetBSD:*:*) + echo m68k-cbm-netbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:NetBSD:*:*) + echo m68k-atari-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:NetBSD:*:*) + echo m68k-sun-netbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:NetBSD:*:*) + echo m68k-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >dummy.c + int main (argc, argv) int argc; char **argv; { + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + ${CC-cc} dummy.c -o dummy \ + && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[3478]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; + 9000/8?? ) HP_ARCH=hppa1.0 ;; + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo i386-pc-cygwin32 + exit 0 ;; + i*:MINGW*:*) + echo i386-pc-mingw32 + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin32 + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. + ld_help_string=`ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + LIBC="" + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + + objdump --private-headers dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >dummy.c < +main(argc, argv) + int argc; + char *argv[]; +{ +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + fi ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 +rm -f dummy.c dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/config.sub b/config.sub new file mode 100755 index 00000000..213a6d47 --- /dev/null +++ b/config.sub @@ -0,0 +1,954 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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 of the License, or +# (at your option) any later version. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 \ + | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ + | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ + | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ + | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ + | mipstx39 | mipstx39el \ + | sparc | sparclet | sparclite | sparc64 | v850) + basic_machine=$basic_machine-unknown + ;; + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[3456]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ + | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ + | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mipstx39-* | mipstx39el-* \ + | f301-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + os=-mvs + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[3456]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[3456]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[3456]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[3456]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + np1) + basic_machine=np1-gould + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5) + basic_machine=i586-intel + ;; + pentiumpro | p6) + basic_machine=i686-intel + ;; + pentium-* | p5-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + k5) + # We don't have specific support for AMD's K5 yet, so just call it a Pentium + basic_machine=i586-amd + ;; + nexen) + # We don't have specific support for Nexgen yet, so just call it a Pentium + basic_machine=i586-nexgen + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -xenix) + os=-xenix + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-ibm) + os=-aix + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -hpux*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/configure.in b/configure.in new file mode 100644 index 00000000..ac7287f1 --- /dev/null +++ b/configure.in @@ -0,0 +1,144 @@ +dnl +Mnl Configure script for the Gnome library +dnl + +AC_INIT(copyright.txt) +AM_CONFIG_HEADER(config.h) + +AM_INIT_AUTOMAKE(libgtop, 0.01) + +AM_MAINTAINER_MODE + +AM_ACLOCAL_INCLUDE(macros) + +AC_CANONICAL_HOST + +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) + +NM=`which $NM` +export CC CXX RANLIB LD AS AR NM + +AC_LC_SYSDEPS + +GNOME_CHECK_GUILE + +if test x$ac_cv_guile_found = xyes ; then + guile_examples='third third_static third_linux' + guile_subdirs='guile' +else + guile_examples= + guile_subdirs= +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 Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_TYPE_OFF_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_STRUCT_ST_RDEV +AC_HEADER_TIME +AC_STRUCT_TM +AC_TYPE_UID_T + +dnl For SunOS +AC_CHECK_TYPE(ssize_t, int) +AC_CHECK_HEADERS(memory.h) +AC_CHECK_HEADERS(string.h strings.h, break) +AC_REPLACE_FUNCS(strerror) +AC_CHECK_LIB(kvm, kvm_open) + +dnl For DEC OSF1 +AC_CHECK_LIB(mach, vm_statistics) + +dnl Checks for library functions. +AC_FUNC_ALLOCA +AC_FUNC_MMAP +AC_TYPE_SIGNAL +AC_FUNC_STRFTIME +AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv strdup strtoul uname) + +ALL_LINGUAS="" +AM_GNU_GETTEXT + +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(LDFLAGS) + +AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]],AC_DEFINE(GNOME_ENABLE_DEBUG),) + +LIBSUPPORT= +SUPPORTINCS= +if test "$need_libgtop_support" = yes; then + LIBSUPPORT='$(top_builddir)/support/libgtopsupport.la' + SUPPORTINCS='-I$(top_srcdir)/support' +fi + +dnl These definitions are expanded in make. +GTOP_LIBS='-L$(libdir) -lgtop_common -lgtop ' +GTOP_INCS='-I$(includedir) -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/include' +GTOP_BINDIR='$(bindir)' +GTOP_SERVER='$(bindir)/gtop_server' + +GTOP_INCS="$GTOP_INCS -I\$(top_srcdir)/intl -DGTOPLOCALEDIR=\\\"\$(datadir)/locale\\\"" + +if test "x$use_glibtop_machine_h" = "xyes" ; then + GTOP_INCS="$GTOP_INCS -I\$(top_srcdir)/sysdeps/\$(sysdeps_dir)" +fi + +if test "x$ac_cv_guile_found" = "xyes" ; then + GTOP_INCS="$GTOP_INCS $GUILE_INCS" + GTOP_LIBS="$GTOP_LIBS $GUILE_LIBS" +fi + +AC_SUBST(GTOP_LIBS) +AC_SUBST(GTOP_INCS) +AC_SUBST(GTOP_BINDIR) +AC_SUBST(GTOP_SERVER) + +AC_SUBST(LIBSUPPORT) +AC_SUBST(SUPPORTINCS) + +AC_OUTPUT([ +Makefile +po/Makefile.in +intl/Makefile +sysdeps/Makefile +sysdeps/common/Makefile +sysdeps/names/Makefile +sysdeps/guile/Makefile +sysdeps/guile/names/Makefile +sysdeps/stub/Makefile +sysdeps/sun4/Makefile +sysdeps/osf1/Makefile +sysdeps/linux/Makefile +src/Makefile +src/server/Makefile +lib/Makefile +examples/Makefile +support/Makefile +macros/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]) diff --git a/copyright.txt b/copyright.txt new file mode 100644 index 00000000..87356576 --- /dev/null +++ b/copyright.txt @@ -0,0 +1,21 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + diff --git a/doc/.cvsignore b/doc/.cvsignore new file mode 100644 index 00000000..9af57b1c --- /dev/null +++ b/doc/.cvsignore @@ -0,0 +1,15 @@ +*.shml +.timestamp +dbtohtml-1.shtml +dbtohtml-2.shtml +dbtohtml-3.shtml +dbtohtml.shtml +libgtop-1.shtml +libgtop-2.shtml +libgtop-3.shtml +libgtop-4.shtml +libgtop-5.shtml +libgtop-INDEX.shtml +libgtop.ced +libgtop.fot +libgtop.shtml diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 00000000..92f4f866 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,6 @@ +all: .timestamp + +.timestamp: libgtop.sgml + jade -D /usr/lib/sgml/jade_dsl -d libgtop.dsl -t sgml \ + -V %no-make-index% libgtop.sgml > /dev/null + touch .timestamp diff --git a/doc/catalog b/doc/catalog new file mode 100644 index 00000000..76a78096 --- /dev/null +++ b/doc/catalog @@ -0,0 +1,3 @@ +PUBLIC "-//James Clark//DTD DSSSL Flow Object Tree//EN" "fot.dtd" +PUBLIC "ISO/IEC 10179:1996//DTD DSSSL Architecture//EN" "dsssl.dtd" +PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" "style-sheet.dtd" diff --git a/doc/libgtop.dsl b/doc/libgtop.dsl new file mode 100755 index 00000000..5947abc6 --- /dev/null +++ b/doc/libgtop.dsl @@ -0,0 +1,1627 @@ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; dbtohtml.dsl - DSSSL style sheet for DocBook to HTML conversion (jadeware) +; +; Author : Mark Burton (markb@ordern.com) +; Created On : Fri Jun 13 18:21:14 1997 +; Last Modified By: Mark Burton +; Last Modified On: Thu Jul 10 21:58:53 1997 +; +; $Id$ +; +; Usage: +; +; jade -d dbtohtml.dsl -t sgml yourdoc.sgm +; +; Additional command line options: +; +; -V %no-split-output% sends all the output to one file +; -V %no-make-index% disables index creation +; -V %no-make-toc% disables TOC creation +; -V %no-shade-screen% disables grey background to SCREEN regions +; -V %show-comments% includes contents of COMMENT regions + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Contributors + +; Mark Eichin (eichin@cygnus.com) +; Jason Molenda (crash@cygnus.co.jp) +; Mark Galassi (rosalia@cygnus.com) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Parameterisation + +; This style sheet can easily be parameterised by the use of a driver. +; Here is a simple example that sets the output file basename and directory. +; If the driver is foo.dsl, use: jade -d foo.dsl -t sgml yourdoc.sgm + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; declare non-standard functions + +(declare-flow-object-class element + "UNREGISTERED::James Clark//Flow Object Class::element") +(declare-flow-object-class empty-element + "UNREGISTERED::James Clark//Flow Object Class::empty-element") +(declare-flow-object-class document-type + "UNREGISTERED::James Clark//Flow Object Class::document-type") +(declare-flow-object-class processing-instruction + "UNREGISTERED::James Clark//Flow Object Class::processing-instruction") +(declare-flow-object-class entity + "UNREGISTERED::James Clark//Flow Object Class::entity") +(declare-flow-object-class entity-ref + "UNREGISTERED::James Clark//Flow Object Class::entity-ref") +(declare-flow-object-class formatting-instruction + "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction") + +(declare-characteristic preserve-sdata? + "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #f) +;; +;; try setting this to true to see if ISO character entities get translated +;;(declare-characteristic preserve-sdata? +;; "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #t) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; variables + +(define %no-split-output% #f) +(define %no-make-toc% #f) +(define %no-make-index% #f) +(define %no-shade-screen% #f) +(define %show-comments% #f) +(define %shade-width% "100%") ; width or #f +(define %email-element% "TT") ; font changing element or #f + +(define %html-public-id% "-//W3C//DTD HTML 3.2 Final//EN") +(define %body-bgcolor% "white") +(define %output-directory% ".") +(define %output-basename% "libgtop") +(define %output-suffix% ".shtml") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; top-level sections + +(define (book-common) + (cond (%no-split-output% ; everything goes in one file + (make-file (string-append %output-basename% %output-suffix%) + (make sequence + (process-children) + (cond ((not %no-make-index%) + (make sequence + (make-fat-rule) + (make-index))) + (#t (empty-sosofo)))))) + (#t ; split output into separate files + (make sequence + (make-file (string-append %output-basename% %output-suffix%) + (make sequence + (process-first-descendant "TITLE") + (process-first-descendant "BOOKINFO"))) + (process-matching-children "PREFACE" + "CHAPTER" + "APPENDIX" + "BIBLIOGRAPHY" + "GLOSSARY" + "ARTHEADER") + (cond ((not %no-make-index%) + (make-file (string-append %output-basename% + "-INDEX" + %output-suffix%) + (make-index))) + (#t (empty-sosofo))))))) + +(element BOOK (book-common)) + +(define generator-version + "Generated from Docbook 3.0 DTD, dbtohtml.dsl version $Revision$") + +(define (make-file file-name content) + (make entity + system-id: (string-append %output-directory% "/" file-name) + (make sequence + (make document-type + name: "html" + public-id: %html-public-id%) + (make formatting-instruction data: "<") + (make formatting-instruction data: "!--") + (literal generator-version) + (make formatting-instruction data: "--> +") + (make element + gi: "html" + (make sequence + (make element + gi: "head" + (make sequence + (make empty-element gi: "link" + attributes: (list (list "rel" "stylesheet") + (list "type" "text/css") + (list "href" "/style/docbook.css"))) + (make empty-element gi: "meta" + attributes: (list (list "name" "generator") + (list "content" generator-version))) + (make empty-element gi: "meta" + attributes: (list (list "name" "ObjectType") + (list "content" "book"))) + (make element + gi: "title" + (with-mode extract-title-text + (process-first-descendant "title"))))) + (make element + gi: "body" + attributes: (list (list "bgcolor" %body-bgcolor%)) + (make sequence + (make-anchor) + content + (make-footer) + (make formatting-instruction data: "<") + (make formatting-instruction data: "!--#include virtual=\"/includes/docbook_footer\"") + (make formatting-instruction data: "-->")))))))) + +(define (make-footer) + (let ((copyright (select-elements (descendants (book-node)) + '("COPYRIGHT" "BOOKINFO")))) + (cond ((node-list-empty? copyright) (empty-sosofo)) + (#t (make sequence + (make-fat-rule) + (process-node-list copyright)))))) + +(define (node-list-last nl) + (node-list-ref nl (- (node-list-length nl) 1))) + +(define (make-nav-links parent-gi) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "A" + attributes: (list (list "href" (link-file-name (ancestor parent-gi)))) + (literal "Up")) + (literal " ") + (if (absolute-last-sibling?) + (empty-sosofo) + (make element + gi: "A" + attributes: (list (list "href" + (link-file-name (node-list-first + (follow (current-node)))))) + (literal "Forward"))) + (literal " ") + (if (absolute-first-sibling?) + (empty-sosofo) + (make element + gi: "A" + attributes: (list (list "href" + (link-file-name (node-list-last + (preced (current-node)))))) + (literal "Back"))) + (make empty-element + gi: "P"))) + +(define (make-pref-chap-app) + (cond (%no-split-output% + (make sequence + (make-anchor) + (make-fat-rule) + (process-children))) + (#t + (make-file (link-file-name (current-node)) + (make sequence + (make-nav-links "BOOK") + (process-children) + (make-nav-links "BOOK")))))) + +;;(element ARTICLE (process-children)) +(element ARTICLE (book-common)) + +(element PREFACE (make-pref-chap-app)) + +(element CHAPTER (make-pref-chap-app)) + +(element APPENDIX (make-pref-chap-app)) + +(element BEGINPAGE (make sequence + (make empty-element gi: "P") + (make empty-element gi: "HR"))) + +(element BIBLIOGRAPHY (make-pref-chap-app)) + +(element BOOKBIBLIO (process-children)) + +(element BIBLIODIV (process-children)) + +(element GLOSSARY (make-pref-chap-app)) + +; (element GLOSSDIV (make-pref-chap-app)) + +;;(element ARTHEADER (make-pref-chap-app)) +(element ARTHEADER + (make sequence + (cond ((not %no-make-toc%) + (make sequence + (make-fat-rule) + (make element + gi: "h2" + attributes: (list "align" "center") + (literal "Contents")) + (make element + gi: "ul" + attributes: (list "align" "center") + (with-mode make-toc-links + (process-node-list (book-node)))))) + (#t (empty-sosofo))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; sections + +(element SECT1 + (make sequence + (make-anchor) + (process-children))) + +(element SECT2 + (make sequence + (make-anchor) + (process-children))) + +(element SECT3 + (make sequence + (make-anchor) + (process-children))) + +(element SECT4 + (make sequence + (make-anchor) + (process-children))) + +(element SECT5 + (make sequence + (make-anchor) + (process-children))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; titles + +(mode extract-title-text + (element (TITLE) + (process-children))) + +(mode extract-title-text + (element (BRIDGEHEAD) + (process-children))) + +(element (BOOK TITLE) + (make element + gi: "h1" + attributes: (list "align" "center") + (process-children))) + +(element (ARTICLE TITLE) + (make element + gi: "h1" + attributes: (list "align" "center") + (process-children))) + +(element (CHAPTER TITLE) + (make sequence + (make element + gi: "h1" + (make sequence + (literal (chap-app-head-label "Chapter")) + (process-children-trim))))) + +(element (PREFACE TITLE) + (make element + gi: "h1" + (make sequence + (literal "Preface: ") + (process-children-trim)))) + +(element (APPENDIX TITLE) + (make element + gi: "H1" + (make sequence + (literal (chap-app-head-label "Appendix")) + (process-children-trim)))) + +(element (BIBLIOGRAPHY TITLE) + (make element gi: "H1" + (make sequence + (literal (chap-app-head-label "Bibliography")) + (process-children-trim)))) + +(element (BOOKBIBLIO TITLE) + (make element gi: "H2" + (make sequence +;;; (literal (chap-app-head-label "Bibliography")) + (process-children-trim)))) + +(element (BIBLIODIV TITLE) + (make element gi: "H2" + (make sequence + (process-children-trim)))) + +(element (GLOSSARY TITLE) + (make element gi: "H1" + (make sequence + (literal "Glossary") +; (process-children-trim) +))) + +(element (GLOSSDIV TITLE) + (make element gi: "H2" + (process-children-trim))) + +(element (ARTHEADER TITLE) + (make element gi: "H1" + (process-children-trim))) + +(element (ARTHEADER DATE) + (make element gi: "P")) + +(element (ARTHEADER SUBTITLE) + (make element + gi: "H2" + (make element + gi: "i" + (process-children-trim) + ))) + +(element (SECT1 TITLE) (make element gi: "H2")) + +(element (SECT2 TITLE) (make element gi: "H3")) + +(element (SECT3 TITLE) (make element gi: "H4")) + +(element (SECT4 TITLE) (make element gi: "H5")) + +(element (SECT5 TITLE) (make element gi: "H6")) + +(element (FORMALPARA TITLE) (make element gi: "H6")) + +(element BRIDGEHEAD (make element gi: "H4")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; font changers + +(element EMPHASIS + (make element gi: "EM")) + +(element TYPE + (make element gi: "STRONG" + (make element gi: "TT"))) + +(element TOKEN + (make element gi: "EM" + (make element gi: "STRONG" + (make element gi: "TT")))) + +(element REPLACEABLE (make element gi: "EM")) + +(element FIRSTTERM (make element gi: "EM")) + +(element APPLICATION (make element gi: "TT")) + +(element FILENAME (make element gi: "TT")) + +(element LITERAL (make element gi: "TT")) + +(element GUIMENU (make element gi: "TT")) +(element GUIMENUITEM (make element gi: "TT")) + +(element ENVAR (make element gi: "TT")) + +(element SUBSCRIPT (make element gi: "SUB")) + +(element SUPERSCRIPT (make element gi: "SUP")) + +(element CITATION (process-children)) +(element CITETITLE (make element gi: "I")) + +(element COMMAND (make element gi: "TT")) + +(element STRUCTFIELD (make element gi: "TT")) + +(element OPTION (make element gi: "TT")) + +(element USERINPUT (make element gi: "TT")) + +(element COMPUTEROUTPUT (make element gi: "TT")) + +(element PROMPT (make element gi: "TT")) + +(element PRODUCTNAME (make element gi: "I")) + +(element SGMLTAG (make element gi: "TT")) +(element CLASSNAME (make element gi: "TT")) +(element SYMBOL (make element gi: "TT")) +(element LITERALLAYOUT (make element gi: "PRE")) +(element PROGRAMLISTING (make element gi: "PRE")) + +(element FOREIGNPHRASE (make element gi: "I")) + +;; I think that title abbreviations don't really have a place in HTML. +;; The only place in which I can imagine them being useful is if the +;; HTML secret title (the one that goes in your bookmarks and stuff) +;; is derived from the DocBook title abbrev +;; +;; (element ABBREV (process-children-trim)) +(element ABBREV (empty-sosofo)) +(element TITLEABBREV (empty-sosofo)) + +(element EMAIL + (if %email-element% + (make element + gi: %email-element% + (process-children-trim)) + (process-children-trim))) + +(element QUOTE + (make sequence + (make entity-ref + name: "quot") + (process-children-trim) + (make entity-ref + name: "quot"))) + +(element ADDRESS + (make element + gi: "address" + (make element + gi: "em" + (process-children-trim)))) + +(element (ADDRESS CITY) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS COUNTRY) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS EMAIL) + (make sequence + (make empty-element + gi: "BR") + ;; Now throw some space between street address and the email + ;; address. Sadly, the only way I know how to do it in HTML is to + ;; throw in an empty paragraph tag. + (make empty-element + gi: "spacer" + attributes: '(("align" "vertical") ("size" "10"))) + (if %email-element% + (make element + gi: %email-element% + (process-children-trim)) + (process-children-trim)))) + +(element (ADDRESS FAX) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS OTHERADDR) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS POB) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS PHONE) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS POSTCODE) + (process-children-trim)) + +(element (ADDRESS STATE) + (process-children-trim)) + +(element (ADDRESS STREET) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; paragraph like things + +(element CAUTION (make-special-para)) + +(element IMPORTANT (make-special-para)) + +(element WARNING (make-special-para)) + +(element NOTE (make-special-para)) + +(element TIP (make-special-para)) + +(element EXAMPLE (make-special-para)) + +(element INFORMALEXAMPLE + (make element + gi: "BLOCKQUOTE")) + +(element COMMENT + (cond (%show-comments% + (make element + gi: "FONT" + attributes: '(("color" "red")) + (make-special-para))) + (#t (empty-sosofo)))) + +(element PARA + (make sequence + (make empty-element + gi: "P") + (with-mode footnote-ref + (process-children)) + (with-mode footnote-def + (process-matching-children "FOOTNOTE")))) + +(element BLOCKQUOTE (make element gi: "BLOCKQUOTE")) + +(element SCREEN + (let ((gubbins (make element + gi: "PRE" + (process-children)))) + (make sequence + (make empty-element + gi: "P") + (if %no-shade-screen% + gubbins + (make element + gi: "TABLE" + attributes: (append (list '("border" "0") + '("bgcolor" "#E0E0E0")) + (if %shade-width% + (list (list "width" %shade-width%)) + '())) + (make element + gi: "TR" + (make element + gi: "TD" + gubbins))))))) + +(element FORMALPARA (process-children)) + +(element PHRASE (maybe-bold-children)) + +(mode footnote-ref + (element FOOTNOTE + (make sequence + (literal "[") + (literal (format-number (element-number (current-node)) "1")) + (literal "]")))) + +(mode footnote-def + (element FOOTNOTE + (make element + gi: "BLOCKQUOTE" + (make sequence + (literal "[") + (literal (format-number (element-number (current-node)) "1")) + (literal "]") + (process-children))))) + +(element (CAUTION TITLE) + (make element + gi: "H5")) + +(element (IMPORTANT TITLE) + (make element + gi: "H5")) + +(element (WARNING TITLE) + (make element + gi: "H5")) + +(element (NOTE TITLE) + (make element + gi: "H5")) + +(element (TIP TITLE) + (make element + gi: "H5")) + +(element (EXAMPLE TITLE) + (make element + gi: "H5")) + +(element (BIBLIOENTRY TITLE) + (make element + gi: "H3")) + +(element (BIBLIOENTRY PAGENUMS) + (make sequence + (literal "Pages: ") + (make element gi: "I"))) + +(element (BIBLIOENTRY DATE) + (make sequence + (literal " Date: ") + (make element gi: "I"))) + +(element (BIBLIOENTRY VOLUMENUM) + (make sequence + (literal " Volume: ") + (make element gi: "I"))) + +(element (BIBLIOENTRY SERIESINFO) (process-children)) + +(element (BIBLIOENTRY SERIESINFO TITLE) + (make element gi: "H4")) + +(element (BIBLIOENTRY BIBLIOMISC) + (make sequence + (literal " other: ") + (process-children))) + +; the para inside does the work, here... +(element (BIBLIOENTRY ABSTRACT) (process-children)) + +;; an article'sabstract is centered text +(element ABSTRACT + (make sequence + (make empty-element gi: "HR") + (make element + gi: "H2" + (literal "Abstract")) + (make element + gi: "DIV" + attributes: (list (list "align" "left")) + (make element gi: "BLOCKQUOTE" + (process-children))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; lists + +(element ITEMIZEDLIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "UL"))) + +(element ORDEREDLIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "OL"))) + +(element PROCEDURE + (make sequence + (make empty-element + gi: "P") + (make element + gi: "OL"))) + +(element SIMPLELIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "UL"))) + +(element (ITEMIZEDLIST LISTITEM) + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element (ORDEREDLIST LISTITEM) + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element STEP + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element (SIMPLELIST MEMBER) + (make sequence + (make empty-element + gi: "LI") + (process-children))) + +(element VARIABLELIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "DL"))) + +(element VARLISTENTRY + (make sequence + (make empty-element + gi: "DT") + (process-children))) + +(element (VARLISTENTRY LISTITEM) + (make sequence + (make empty-element + gi: "DD") + (process-children) + (make empty-element + gi: "P"))) + +(element TERM (maybe-bold-children)) + +(element GLOSSDIV + (make sequence + (make empty-element + gi: "P") + (make element + gi: "DL"))) + +; (define (gloss-entry-name indexterm) +; (string-append "gloss." (format-number (element-number indexterm) "1"))) +(define (gloss-entry-name glossterm) + (string-append "gloss." (data glossterm))) + +(element GLOSSENTRY + (process-children)) + +(element (GLOSSENTRY GLOSSTERM) + (make sequence + (make empty-element + gi: "DT") + (make empty-element + gi: "A" + attributes: (list (list "name" (gloss-entry-name (current-node))))) + (process-children))) + + +(element (GLOSSENTRY GLOSSDEF) + (make sequence + (make empty-element + gi: "DD") + (process-children) + (make empty-element + gi: "P"))) + +(element (GLOSSENTRY GLOSSSEE) + (make sequence + (make empty-element + gi: "DD") + (literal "See ") + (make element + gi: "A" + attributes: (list (list "href" + (string-append "#" + (gloss-entry-name (current-node))) + ))) + (make empty-element + gi: "P"))) + +; (element GLOSSTERM (maybe-bold-children)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; index + +(define (index-entry-name indexterm) + (string-append "index." (format-number (element-number indexterm) "1"))) + +(element INDEXTERM + (make sequence + (make element + gi: "A" + attributes: (list (list "name" (index-entry-name (current-node)))) + (literal "")) + (empty-sosofo))) + +; DIY string-ci>? + +(define (string-ci>? s1 s2) + (let ((len1 (string-length s1)) + (len2 (string-length s2))) + (let loop ((i 0)) + (cond ((= i len1) #f) + ((= i len2) #t) + (#t (let ((c1 (index-char-val (string-ref s1 i))) + (c2 (index-char-val (string-ref s2 i)))) + (cond + ((= c1 c2) (loop (+ i 1))) + (#t (> c1 c2))))))))) + +(define (index-char-val ch) + (case ch + ((#\A #\a) 65) + ((#\B #\b) 66) + ((#\C #\c) 67) + ((#\D #\d) 68) + ((#\E #\e) 69) + ((#\F #\f) 70) + ((#\G #\g) 71) + ((#\H #\h) 72) + ((#\I #\i) 73) + ((#\J #\j) 74) + ((#\K #\k) 75) + ((#\L #\l) 76) + ((#\M #\m) 77) + ((#\N #\n) 78) + ((#\O #\o) 79) + ((#\P #\p) 80) + ((#\Q #\q) 81) + ((#\R #\r) 82) + ((#\S #\s) 83) + ((#\T #\t) 84) + ((#\U #\u) 85) + ((#\V #\v) 86) + ((#\W #\w) 87) + ((#\X #\x) 88) + ((#\Y #\y) 89) + ((#\Z #\z) 90) + + ((#\ ) 32) + + ((#\0) 48) + ((#\1) 49) + ((#\2) 50) + ((#\3) 51) + ((#\4) 52) + ((#\5) 53) + ((#\6) 54) + ((#\7) 55) + ((#\8) 56) + ((#\9) 57) + + ; laziness precludes me from filling this out further + (else 0))) + +(define (string->number-list s) + (let loop ((i (- (string-length s) 1)) + (l '())) + (if (< i 0) + l + (loop (- i 1) (cons (index-char-val (string-ref s i)) l))))) + +(define (number-list>? l1 l2) + (cond ((null? l1) #f) + ((null? l2) #t) + ((= (car l1) (car l2)) + (number-list>? (cdr l1) (cdr l2))) + (#t (> (car l1) (car l2))))) + +; return the string data for a given index entry + +(define (get-index-entry-data entry) + (let ((primary (select-elements (descendants entry) "PRIMARY")) + (secondary (select-elements (descendants entry) "SECONDARY"))) + (if (node-list-empty? secondary) + (data primary) + (string-append (data primary) " - " (data secondary))))) + +(define (make-index-entry entry) + (let ((text (get-index-entry-data entry))) + (cons text + (make sequence + (make empty-element + gi: "LI") + (make element + gi: "A" + attributes: (list (list "href" + (string-append (link-file-name + entry) + "#" + (index-entry-name + entry)))) + (literal text)))))) + +(define (build-index nl) + (let loop ((result '()) + (nl nl)) + (if (node-list-empty? nl) + result + (loop (cons (make-index-entry (node-list-first nl)) result) + (node-list-rest nl))))) + +(define (sort-index il) + (letrec ((list-head (lambda (l n) + (if (> n 0) + (cons (car l) (list-head (cdr l) (- n 1))) + '()))) + (merge (lambda (il1 il2) + (cond ((null? il1) il2) + ((null? il2) il1) + ((string-ci>? (car (car il1)) (car (car il2))) + (cons (car il2) (merge il1 (cdr il2)))) + (#t + (cons (car il1) (merge (cdr il1) il2))))))) + (let* ((ll (length il)) + (ldiv2 (quotient ll 2))) + (if (> 2 ll) + il + (merge (sort-index (list-head il ldiv2)) + (sort-index (list-tail il ldiv2))))))) + +(define (output-index il) + (let extract-and-append ((il il) + (result (empty-sosofo))) + (if (null? il) + result + (extract-and-append (cdr il) (sosofo-append result (cdr (car il))))))) + +(define (make-index) + (make sequence + (make element + gi: "A" + attributes: (list (list "name" "INDEXTOP")) + (literal "")) + (make element + gi: "H1" + (literal "Index")) + (make element + gi: "UL" + (output-index + (sort-index + (build-index (select-elements (descendants (current-node)) + "INDEXTERM"))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; links & cross-references + +(define (link-file-name target) + (cond (%no-split-output% "") + (#t + (string-append + %output-basename% + (cond ((equal? (gi target) "CHAPTER") + (string-append + "-" + (format-number (child-number target) "1"))) + ((ancestor-child-number "CHAPTER" target) + (string-append + "-" + (format-number (ancestor-child-number "CHAPTER" target) "1"))) + ((equal? (gi target) "APPENDIX") + (string-append + "-" + (format-number (child-number target) "A"))) + ((ancestor-child-number "APPENDIX" target) + (string-append + "-" + (format-number (ancestor-child-number "APPENDIX" target) "A"))) + (#t "")) + %output-suffix%)))) + +(element ANCHOR + (make-anchor)) + +(element LINK + (let* ((target (element-with-id (attribute-string "linkend") + (book-node))) + (target-file-name (link-file-name target)) + (endterm (attribute-string "endterm")) + (target-title-sosofo (if endterm + (with-mode extract-xref-text + (process-node-list + (element-with-id endterm + (book-node)))) + (process-children)))) + (make element + gi: "A" + attributes: (list + (list "href" + (string-append + target-file-name + "#" + (attribute-string "linkend")))) + target-title-sosofo))) +(element ULINK + (make element + gi: "A" + attributes: (list + (list "href" (attribute-string "url"))))) + +(element XREF + (let* ((target (element-with-id (attribute-string "LINKEND") + (book-node))) + (target-file-name (link-file-name target))) + (make element + gi: "A" + attributes: (list + (list "href" + (string-append target-file-name + "#" + (attribute-string "linkend")))) + (with-mode extract-xref-text + (process-node-list target))))) + +(mode extract-xref-text + (default + (let ((title-sosofo (with-mode extract-title-text + (process-first-descendant "TITLE")))) + (if (sosofo? title-sosofo) + title-sosofo + (literal (string-append "Reference to " (gi))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; figures + +(element FIGURE + (make sequence + (make empty-element + gi: "P") + (make-anchor) + (process-children) + (make empty-element + gi: "P"))) + +(element (FIGURE TITLE) + (make sequence + (make element + gi: "B") + (make empty-element + gi: "P"))) + +(element GRAPHIC + (let ((img + (make sequence + (make empty-element + gi: "P") + (make empty-element + gi: "IMG" + attributes: (list + (list "src" + (string-append (attribute-string "fileref") + ".gif"))))))) + (if (equal? + (attribute-string "align") + "CENTER") + (make element + gi: "CENTER" + img) + img))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; tables + +(element TABLE + (make sequence + (make empty-element + gi: "P") + (make element + gi: "TABLE" + attributes: (if (equal? + (attribute-string "frame") + "ALL") + '(("border" "2") ("cellpadding" "2")) + '())) + (make empty-element + gi: "P"))) + +(element (TABLE TITLE) + (make element + gi: "H4" + (make sequence + (literal "Table: ") + (process-children-trim)))) + +(element INFORMALTABLE + (make sequence + (make empty-element + gi: "P") + (make element + gi: "TABLE" + attributes: (if (equal? + (attribute-string "frame") + "ALL") + '(("border" "2") ("cellpadding" "2")) + '())) + (make empty-element + gi: "P"))) + +(element TGROUP (process-children)) + +(element THEAD (process-children)) + +(element (THEAD ROW) + (make sequence + (make empty-element + gi: "TR") + (process-children))) + +(element (THEAD ROW ENTRY) + (make sequence + (make empty-element + gi: "TD") + (make element + gi: "B" + (process-children)))) + +(element TBODY (process-children)) + +(element (TBODY ROW) + (make sequence + (make empty-element + gi: "TR") + (process-children))) + + +(element (TBODY ROW ENTRY) + (make sequence + (make empty-element + gi: "TD") + (process-children))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; book info + +(element BOOKINFO + (make sequence + (make element + gi: "CENTER" + (process-children)) + (cond ((not %no-make-toc%) + (make sequence + (make-fat-rule) + (make element + gi: "H2" + (literal "Contents")) + (make element + gi: "ul" + (with-mode make-toc-links + (process-node-list (book-node)))))) + (#t (empty-sosofo))))) + +(element (BOOKINFO DATE) + (make element gi: "P")) + +(element (BOOKINFO TITLE) + (make element gi: "H1")) + +(element (BOOKINFO SUBTITLE) + (make element + gi: "H2" + (make element + gi: "i" + (process-children-trim) + ))) + +(element AUTHORGROUP + (let ((reducer (lambda (sofar new) + (sosofo-append sofar (make element + gi: "H2" + (process-node-list new)))))) + (make sequence + (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") + reducer + (empty-sosofo))))) + +;; I make a new left-aligned DIV sandwiched between HRs for the author +;; blurb. +(element AUTHORBLURB + (make sequence + (make empty-element gi: "HR") + (make element + gi: "DIV" + attributes: '(("align" "left")) + (make element + gi: "h4" + attributes: '(("align" "left")) + (literal "Author blurb for ") + (make element + gi: "i" + (process-matching-children "TITLE") + (literal ":"))) + (process-matching-children "FORMALPARA" "PARA" "SIMPARA")) + (make empty-element gi: "HR"))) + +(element (AUTHORBLURB TITLE) + (make element gi: "B")) + +(element CORPNAME + (make element gi: "H2")) + +(element (BIBLIOENTRY AUTHORGROUP) + (let ((reducer (lambda (sofar new) + (sosofo-append sofar (make element + gi: "H3" + (process-node-list new)))))) + (make sequence + (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") + reducer + (empty-sosofo))))) + +(element COPYRIGHT + (make element + gi: "H4" + (make sequence + (make entity-ref + name: "copy") + (process-matching-children "HOLDER") + (process-matching-children "YEAR")))) + +(element HOLDER + (make sequence + (literal " ") + (process-children-trim))) + +(element YEAR + (make sequence + (literal " ") + (process-children-trim))) + +(element CORPAUTHOR + (process-children-trim)) + +(element AUTHOR + (process-children-trim)) + +(element EDITOR + (process-children-trim)) + +(element CONFGROUP + (process-children-trim)) + +(element CONFTITLE + (make sequence + (make empty-element + gi: "BR") + (make element gi: "I" (process-children)))) + +(element CONFDATES + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element HONORIFIC + (make sequence + (process-children-trim) + (literal " "))) + +(element FIRSTNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element OTHERNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element SURNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element LINEAGE + (make sequence + (process-children-trim) + (literal " "))) + +(element TRADEMARK (process-children)) + +(element PUBLISHERNAME (process-children)) + +(element BIBLIOENTRY (process-children)) + +(element ACRONYM (process-children)) + +(element RELEASEINFO + (make sequence + (make empty-element + gi: "BR") + (make element gi: "B"))) + +(element AFFILIATION + (make sequence + (make element + gi: "I"))) + +(element ORGNAME + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +;;(element ORGNAME +;; (process-children)) + +(element JOBTITLE + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element ORGDIV + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element PUBLISHER + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element ISBN + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element PUBDATE + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element REVHISTORY + (empty-sosofo)) + +(element LEGALNOTICE + (make sequence + (make element + gi: "H4" + attributes: '(("align" "left")) + (literal "Legal Notice: ")) + (make element + gi: "DIV" + attributes: '(("align" "left"))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Synopses for command line, API functions and so forth +;;(element FUNCSYNOPSIS +;; (process-children)) + +(element FUNCSYNOPSIS + (make sequence + (make empty-element gi: "P") ; go to a new line + ;; just in case there is some synopsisinfo, like #include directives + (process-matching-children "FUNCSYNOPSISINFO") + (make empty-element gi: "P") ; go to a new line + (process-matching-children "FUNCDEF") ; this gives the function name + (literal " (") + (process-matching-children "PARAMDEF") ; this gives the function arguments + (literal ")") + )) + +(element FUNCDEF + (make element gi: "TT")) + +(element FUNCTION + (make element gi: "B")) + +(element STRUCTNAME + (make element gi: "B")) + +(element FUNCSYNOPSISINFO + (make element + gi: "PRE")) + +(element PARAMDEF + (make element + gi: "TT")) + +(element PARAMETER + (make element + gi: "I")) + +(element FUNCPROTOTYPE + (make element + gi: "PRE")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; TOC + +(element LOF (empty-sosofo)) + +(element LOT (empty-sosofo)) + +(element TOC (empty-sosofo)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; DIY TOC + +(mode make-toc-links + (element (BOOK) + (sosofo-append + (process-children) + (cond ((not %no-make-index%) + (make sequence + (make empty-element + gi: "LI") + (make element + gi: "A" + attributes: (list (list "href" + (cond (%no-split-output% "#INDEXTOP") + (#t + (string-append %output-basename% + "-INDEX" + %output-suffix% + "#INDEXTOP"))))) + (literal "Index")))) + (#t (empty-sosofo))))) + (element (CHAPTER) + (make-chap-or-app-toc-links)) + (element (APPENDIX) + (make-chap-or-app-toc-links)) + (element (SECT1) + (make sequence + (make empty-element + gi: "LI") + (let ((title-text (with-mode extract-title-text + (process-first-descendant "TITLE")))) + (if (id) + (make element + gi: "A" + attributes: (list (list "href" (string-append (link-file-name (current-node)) + "#" + (id)))) + title-text) + title-text)))) + (default + (empty-sosofo))) + +(define (make-chap-or-app-toc-links) + (make sequence + (make empty-element + gi: "LI") + (let ((title-text + (make sequence + (literal (if (equal? (gi) "CHAPTER") + (string-append "Chapter " + (format-number + (element-number (current-node)) + "1") + " - ") + (string-append "Appendix " + (format-number + (element-number (current-node)) + "A") + " - "))) + (with-mode extract-title-text + (process-first-descendant "TITLE"))))) + (if (id) + (make element + gi: "A" + attributes: (list (list "href" (string-append (link-file-name (current-node)) + "#" + (id)))) + title-text) + title-text)) + (make element + gi: "UL" + (with-mode make-toc-links + (process-matching-children "SECT1"))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; make the unimplemented bits stand out + +(default + (make element + gi: "FONT" + attributes: '(("color" "red")) + (make sequence + (literal (string-append "<" (gi) ">")) + (process-children) + (literal (string-append ""))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; standard subroutines + +(define (node-list-reduce nl combine init) + (if (node-list-empty? nl) + init + (node-list-reduce (node-list-rest nl) + combine + (combine init (node-list-first nl))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; various homebrew subroutines + +(define (book-node) + (cond ((equal? (gi) "BOOK") (current-node)) + (#t (let ((book-root (ancestor "BOOK"))) + (if (node-list-empty? book-root) + (cond ((equal? (gi) "CHAPTER") (current-node)) + (#t (ancestor "CHAPTER"))) + book-root))))) + +(define (make-fat-rule) + (make sequence + (make empty-element gi: "P") + (make empty-element gi: "HR"))) + +(define (chap-app-head-label chap-or-app) + (let ((label + (attribute-string "label" (ancestor chap-or-app)))) + (string-append + chap-or-app + " " + (if label + (if (equal? label "auto") + (format-number + (element-number (ancestor chap-or-app)) + (if (equal? chap-or-app "Chapter") "1" "A")) + label) + (format-number + (element-number (ancestor chap-or-app)) + (if (equal? chap-or-app "Chapter") "1" "A"))) + ". "))) + +(define (make-anchor) + (if (id) + (make element + gi: "A" + attributes: (list (list "name" (id))) + (literal "")) + (empty-sosofo))) + +(define (make-special-para) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "B" + (literal (string-append (gi) ":"))) + (make element + gi: "BLOCKQUOTE" + (process-children)))) + +(define (maybe-bold-children) + (cond ((equal? (attribute-string "role") + "bold") + (make element + gi: "B" + (process-children-trim))) + (#t (process-children-trim)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; the end diff --git a/doc/libgtop.sgml b/doc/libgtop.sgml new file mode 100644 index 00000000..0b3eec6d --- /dev/null +++ b/doc/libgtop.sgml @@ -0,0 +1,1332 @@ + + + + + + GTop Library Project Documentation + + + Martin + Baulig + +
+ martin@home-of-linux.org +
+
+
+
+ + 1998 + Martin Baulig + + + + + This documentation 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 of the License, or (at your option) any later + version. + + + This library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307 USA + + + For more details see the file COPYING in the source + distribution of LibGTop. + + +
+ + + + + Introduction + + + About the GTop Library Project + + + On some systems like DEC OSF/1). + + + Of cause making a program that uses some toolkit like + Because of this, some kind of server is needed that reada some + commands from standard input and dumps the requested information + to standard output. When written in a secure manner, it can be + SUID root on systems where this is needed. + + + Any program such as + This is what the + Project Overview + + + The following steps have to be taken: + + + + + Interface Design + + + + First, it is necessary to collect all sorts of information + that can be returned from the library and design some C + structures to hold them. Also, there has to be some method + to find out which elements are supported by the operating + system and which are not. + + + These C structures and definitions are then put in some + header files which are shared between server and client. + The idea behind this is that if they both use the same + header files - and thus the same interface - programs can + be linked directly with the server library on systems where + this is supported (where the server does not need any + priviledges such as under + Server Implementation + + + + After the general interface is designed, the server part of + the library can be written. We will put both the server and + the client code in two distinct libraries. + + + Client Implementation + + + + As the next step, we can implement the client side library. + This library will open a pipe to the server, pass it the + request as input and parse its output. + + + Rewriting existing applications + + + + At this point, the library is ready for use. We can now + begin to rewrite existing applications to use it (or even + write some very new applications). + + + Porting + + + + As the very last step - once everything is running under + + During development, I'll start under DEC OSF/1 V3.0/3.2. + + + + + Feedback + + + Please feel free to contact the author, + Martin Baulig + if you have any comments. + + + Getting Started + + + Using the Guile Interface + + + In examples/third there is a simple guile + interpreter. + + + On Linux systems, you should use the third_linux + executable, this is statically linked with the system dependent library + and works without installing the server first. + + + Let's start with a simple example: + + + $ ./third + guile> (glibtop-get-cpu) + (1107488 39049 0 21981 1046458) + guile> (quit) + + + + Fine, this is our current CPU usage, but what do this five numbers + really mean? Well, of cause one can look a the C header file: + + + typedef struct _glibtop_cpu glibtop_cpu; + + struct _glibtop_cpu + { + unsigned long flags, + total, /* GLIBTOP_CPU_TOTAL */ + user, /* GLIBTOP_CPU_USER */ + nice, /* GLIBTOP_CPU_NICE */ + sys, /* GLIBTOP_CPU_SYS */ + idle; /* GLIBTOP_CPU_IDLE */ + }; + + + + But there's also some easier way: + + + $ ./third_linux + guile> (glibtop-get-cpu) + (1604151 105343 0 63334 1435474) + guile> (glibtop-names-cpu) + ("total" "user" "nice" "sys" "idle") + guile> (quit) + + + + This displays the field names of the C structure + glibtop_cpu. They are not translated into + native language so that one can use guile to generate some C code + that deals with this data. + + + If you want to use this names in an application program, you should + use the following: + + + $ ./third_linux + guile> (glibtop-get-cpu) + (1642347 106696 0 63810 1471841) + guile> (glibtop-labels-cpu) + ("total" "user" "nice" "sys" "idle") + guile> (quit) + + + + There's no difference? You're correct, while I'm writing this manual, + translations in other languaged have not yet been made and labels have + not been written. + + + Let's use another example where this is already working: + + + $ ./third_linux + guile> (glibtop-get-shm_limits) + (33554432 1 128 128 4194304) + guile> (glibtop-names-shm_limits) + ("shmmax" "shmmin" "shmmni" "shmseg" "shmall") + guile> (glibtop-labels-shm_limits) + ("Max segment size" "Min segment size" "Max number of segments" + "Max shared segments per process" "Max total shared memory") + guile> (quit) + + + + Great! But how can I know what features are currently implemented by the + library? Well, basically there are two ways. + + + First, you can use + + + $ ./third_linux + guile> (apropos "glibtop-get") + the-root-module: glibtop-get-cpu #<primitive-procedure glibtop-get-cpu> + the-root-module: glibtop-get-uptime #<primitive-procedure glibtop-get-uptime> + the-root-module: glibtop-get-sysdeps #<primitive-procedure glibtop-get-sysdeps> + the-root-module: glibtop-get-loadavg #<primitive-procedure glibtop-get-loadavg> + the-root-module: glibtop-get-swap #<primitive-procedure glibtop-get-swap> + the-root-module: glibtop-get-proclist #<primitive-procedure glibtop-get-proclist> + the-root-module: glibtop-get-sem_limits #<primitive-procedure glibtop-get-sem_limits> + the-root-module: glibtop-get-msg_limits #<primitive-procedure glibtop-get-msg_limits> + the-root-module: glibtop-get-shm_limits #<primitive-procedure glibtop-get-shm_limits> + the-root-module: glibtop-get-mem #<primitive-procedure glibtop-get-mem> + guile> (quit) + + + + This gives you a basic idea which functions are defined in the library. + But there's also a better way: + + + $ ./third_linux + guile> (glibtop-get-sysdeps) + (31 127 7 3 1 31 127 1023 3) + guile> (glibtop-names-sysdeps) + ("cpu" "mem" "swap" "uptime" "loadavg" "shm_limits" "msg_limits" "sem_limits" + "proclist") + guile> (glibtop-labels-sysdeps) + ("CPU Usage" "Memory Usage" "Swap Usage" "System Uptime" "Load Averange" + "Shared Memory Limits" "Message Queue Limits" "Semaphore Set Limits" + "List of running Processes") + guile> (quit) + + + + Back to the glibtop_get_cpu. Here is a nice example + on how you can convert the returned data to percents: + + + [FIXME: not yet written] + + + Using system dependent features + + + Some of the features of the library are only implemented on some systems. + For instance, in our last example: + + + guile> (glibtop-get-cpu) + (2091847 130894 17 70602 1890334) + + + + Well fine - some process is running with nice now on my system - but in + the last section, we always got zero in the nice + field. When some feature is not implemented on a particular system, it is + set to zero. So how can we find out whether a feature is not implemented on + the current system or whether it is really zero all the time? + + + This is what the flags member of the C structure + is for. Since theese flags never change during the lifetime of a process, + on can call glibtop_get_sysdeps to get a structure + glibtop_sysdeps containing the + flags members of all currently available features. + The contents of the structure remains constant during the lifetime of a + process. + + + In guile, on can use glibgtop-get-sysdeps, too: + + + guile> (glibtop-get-sysdeps) + (31 127 7 3 1 31 127 1023 3) + + + + We already know that the first member of this list corresponds to + glibtop_cpu. So this 31 + tells us which features of glibtop_cpu are + implemented on this systems. The binary representation of + 31 is 11111. If the lowest bit + of this constant is set, this means that the first list element is + implemented on the current system and so on. If, for instance, the + user member of glibtop_cpu + is not implemented, this constant will be 11101 + or 29 in decimal representation. + + +Using the library in a C program + + +Well, in C things are a little bit more complicated than in guile. +Let's start with a very simple example: + + +First steps + + +#include <glibtop/open.h> +#include <glibtop/close.h> + +#include <glibtop/cpu.h> + +int +main (int argc, char *argv []) +{ + glibtop server; + glibtop_cpu cpu; + + glibtop_open (&server, argv [0]); + + glibtop_get_cpu (&server, &cpu); + + fprintf (stderr, "CPU: %lu, %lu, %lu, %lu, %lu\n", + cpu.total, cpu.user, cpu.nice, cpu.sys, cpu.idle); + + glibtop_close (&server); +} + + + + +This will print out: + + +$ ./first_linux +CPU: 2262741, 136828, 17, 72569, 2053327 + + + +Make sure to open a connection to the server by a call to +glibtop_open before calling any other function +of the library and to close that connection upon termination by a call to +glibtop_close. Otherwise your program may either +not work correctly or simply dump core. + + +Using names and labels in C + + +To dump out the field names of glibtop_cpu: + + +Dump field names of <structname>glibtop_cpu</structname>: + +<programlisting> +#include <glibtop/open.h> +#include <glibtop/close.h> + +#include <glibtop/cpu.h> + +int +main (int argc, char *argv []) +{ + fprintf (stderr, "CPU Names: %s, %s, %s, %s, %s\n", + glibtop_names_cpu [GLIBTOP_CPU_TOTAL], + glibtop_names_cpu [GLIBTOP_CPU_USER], + glibtop_names_cpu [GLIBTOP_CPU_NICE], + glibtop_names_cpu [GLIBTOP_CPU_SYS], + glibtop_names_cpu [GLIBTOP_CPU_IDLE]); +} +</programlisting> +</example> + +<para> +Since this are constants, they also work without the server connection. + +<para> +To dump all members of <structname>glibtop_cpu</structname> no matter +how many there are: + +<example> +<title>Dump all members of <structname>glibtop_cpu</structname> no matter +how many + + +#include <glibtop/open.h> +#include <glibtop/close.h> + +#include <glibtop/cpu.h> + +int +main (int argc, char *argv []) +{ + int i; + + for (i = 0; i < GLIBTOP_MAX_CPU; i++) + fprintf (stderr,"#%d: %s\n", i, glibtop_names_cpu [i]); +} + + + + +Finaly, let's dump the internationalized labels: + + +Dump internationalized labels + + +#include <glibtop.h> +#include <glibtop/open.h> +#include <glibtop/close.h> + +#include <glibtop/cpu.h> + +int +main (int argc, char *argv []) +{ + int i; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, GTOPLOCALEDIR); + textdomain (PACKAGE); + + for (i = 0; i < GLIBTOP_MAX_CPU; i++) + fprintf (stderr,"#%d: %s\n", i, + gettext (glibtop_labels_cpu [i])); +} + + + + +Using system dependent features in C + + +In C, there are some constants defined in the header files: + + +#define GLIBTOP_CPU_TOTAL 0 +#define GLIBTOP_CPU_USER 1 +#define GLIBTOP_CPU_NICE 2 +#define GLIBTOP_CPU_SYS 3 +#define GLIBTOP_CPU_IDLE 4 + + + +The value used in the flags member to indicate +whether some feature is implemented on the current system is always +2 at the power of the corresponding constant. + + +For instance, if you want to print out the user +field of glibtop_cpu when it's implemented on the +current system, you can use: + + +Only print <structfield>user</structfield> member of +<structname>glibtop_cpu</structname> when it's implemented + + + +#include <glibtop/open.h> +#include <glibtop/close.h> + +#include <glibtop/cpu.h> + +int +main (int argc, char *argv []) +{ + glibtop server; + glibtop_cpu cpu; + + glibtop_open (&server, argv [0]); + + glibtop_get_cpu (&server, &cpu); + + fprintf (stderr, "CPU: %lu, ", cpu.total); + + /* FIXME: is this correct? */ + + if (cpu.flags & (1 << GLIBTOP_CPU_USER)) + fprintf (stderr, "%lu, ", cpu.user); + + fprintf (stderr, "%lu, %lu, %lu\n", cpu.nice, cpu.sys, cpu.idle); + + glibtop_close (&server); +} + + + + +Hacker's Guide + + +Extending the Library + + +This section will give you a step by step tutorial on how to extend the +library to add a new feature. It is not yet really complete. + + +The Header File + + +First, we'll start writing the C header file for our new feature we want +to add. Currently there is no support for getting information about a +particular process, so we'll add it here. + + +All header files are put into includes/glibtop and +are named after the feature they define. So we'll put everything into +procdata.h: + + +Start of <filename>procdata.h</filename> + +<programlisting> +#ifndef __GLIBTOP_PROCDATA_H__ +#define __GLIBTOP_PROCDATA_H__ + +#include <glibtop.h> +#include <glibtop/global.h> +</programlisting> +</example> + +<para> +This is how we start every header file. Make sure to include at lease +<filename>glibtop.h</filename> and <filename>glibtop/global.h</filename>. +They contain important declarations and include some other important +header files. + +<para> +Next, we look at the <filename>/proc</filename> filesystem of Linux to +find out which information can be fetched about a particular process: + +<screen> +<prompt>$</prompt> <userinput>cat /proc/self/stat</userinput> +14919 (cat) R 14886 14919 14886 1220 14919 1048576 24 0 63 0 0 1 0 0 15 0 -1 +0 1915281 835584 67 2147483647 134512640 134527808 3221222564 3221222372 +1074212972 0 0 2147483648 0 0 0 0 +</screen> + +<para> +Well, this is a rather complex example, but those are the most important +information we need about a process. I think it would be best to start +with the definition of the C structure +<structname>glibtop_procdata</structname> that will be used to store all +those information. We'll copy most from +<filename>gnome-utils/gtop/proc/readproc.h</filename>: + +<example> +<title>Definition of <structname>glibtop_procdata</structname> + +<programlisting> +typedef struct _glibtop_procdata glibtop_procdata; + +struct _glibtop_procdata +{ + unsigned long flags; + char cmd[40], /* basename of executable file in call to exec(2) */ + state; /* single-char code for process state (S=sleeping) */ + int uid, /* user id */ + pid, /* process id */ + ppid, /* pid of parent process */ + pgrp, /* process group id */ + session, /* session id */ + tty, /* full device number of controlling terminal */ + tpgid, /* terminal process group id */ + priority, /* kernel scheduling priority */ + nice, /* standard unix nice level of process */ + signal, /* mask of pending signals */ + blocked, /* mask of blocked signals */ + sigignore, /* mask of ignored signals */ + sigcatch; /* mask of caught signals */ + long start_time, /* start time of process -- seconds since 1-1-70 */ + utime, /* user-mode CPU time accumulated by process */ + stime, /* kernel-mode CPU time accumulated by process */ + cutime, /* cumulative utime of process and reaped children */ + cstime, /* cumulative stime of process and reaped children */ + /* the next 7 members come from /proc/#/statm */ + size, /* total # of pages of memory */ + resident, /* number of resident set (non-swapped) pages (4k) */ + share, /* number of pages of shared (mmap'd) memory */ + trs, /* text resident set size */ + lrs, /* shared-lib resident set size */ + drs, /* data resident set size */ + dt; /* dirty pages */ + unsigned long vsize, /* number of pages of virtual memory ... */ + rss, /* resident set size from /proc/#/stat */ + rss_rlim, /* resident set size ... ? */ + timeout, /* ? */ + it_real_value, /* ? */ + k_flags, /* kernel flags for the process */ + min_flt, /* number of minor page faults since process start */ + maj_flt, /* number of major page faults since process start */ + cmin_flt, /* cumulative min_flt of process and child processes */ + cmaj_flt, /* cumulative maj_flt of process and child processes */ + start_code, /* address of beginning of code segment */ + end_code, /* address of end of code segment */ + start_stack, /* address of the bottom of stack for the process */ + kstk_esp, /* kernel stack pointer */ + kstk_eip, /* kernel stack pointer */ + wchan; /* address of kernel wait channel proc is sleeping in */ +}; +</programlisting> +</example> + +<para> +For each field we now have to define an unique constant: + +<example> +<title>Constant definitions for <structname>glibtop_procdata</structname>: + + +#define GLIBTOP_PROCDATA_CMD 0 +#define GLIBTOP_PROCDATA_STATE 1 +#define GLIBTOP_PROCDATA_UID 2 +#define GLIBTOP_PROCDATA_PID 3 +#define GLIBTOP_PROCDATA_PPID 4 +#define GLIBTOP_PROCDATA_PGRP 5 +#define GLIBTOP_PROCDATA_SESSION 6 +#define GLIBTOP_PROCDATA_TTY 7 +#define GLIBTOP_PROCDATA_TPGID 8 +#define GLIBTOP_PROCDATA_PRIORITY 9 +#define GLIBTOP_PROCDATA_NICE 10 +#define GLIBTOP_PROCDATA_SIGNAL 11 +#define GLIBTOP_PROCDATA_BLOCKED 12 +#define GLIBTOP_PROCDATA_SIGIGNORE 13 +#define GLIBTOP_PROCDATA_SIGCATCH 14 +#define GLIBTOP_PROCDATA_START_TIME 15 +#define GLIBTOP_PROCDATA_UTIME 16 +#define GLIBTOP_PROCDATA_STIME 17 +#define GLIBTOP_PROCDATA_CUTIME 18 +#define GLIBTOP_PROCDATA_CSTIME 19 +#define GLIBTOP_PROCDATA_SIZE 20 +#define GLIBTOP_PROCDATA_RESIDENT 21 +#define GLIBTOP_PROCDATA_SHARE 22 +#define GLIBTOP_PROCDATA_TRS 23 +#define GLIBTOP_PROCDATA_LRS 24 +#define GLIBTOP_PROCDATA_DRS 25 +#define GLIBTOP_PROCDATA_DT 26 +#define GLIBTOP_PROCDATA_VSIZE 27 +#define GLIBTOP_PROCDATA_RSS 28 +#define GLIBTOP_PROCDATA_RSS_RLIM 29 +#define GLIBTOP_PROCDATA_TIMEOUT 30 +#define GLIBTOP_PROCDATA_IT_REAL_VALUE 31 +#define GLIBTOP_PROCDATA_K_FLAGS 32 +#define GLIBTOP_PROCDATA_MIN_FLT 33 +#define GLIBTOP_PROCDATA_MAJ_FLT 34 +#define GLIBTOP_PROCDATA_CMIN_FLT 35 +#define GLIBTOP_PROCDATA_CMAJ_FLT 36 +#define GLIBTOP_PROCDATA_START_CODE 37 +#define GLIBTOP_PROCDATA_END_CODE 38 +#define GLIBTOP_PROCDATA_START_STACK 39 +#define GLIBTOP_PROCDATA_KSTK_ESP 40 +#define GLIBTOP_PROCDATA_KSTK_EIP 41 +#define GLIBTOP_PROCDATA_WCHAN 42 + +#define GLIBTOP_MAX_PROCDATA 43 + + + + +Finally, we'll need some external definitions. They are discussed in detail +later. Basically, you can copy them from any other header file and just +change the names - in our example, we also have to add an additional +parameter to glibtop_get_procdata and +glibtop_guile_get_procdata: + + +External definitions + + +extern void glibtop_get_procdata (glibtop *, glibtop_procdata *, pid_t); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_procdata (SCM); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_procdata (void); +extern SCM glibtop_guile_labels_procdata (void); +extern SCM glibtop_guile_descriptions_procdata (void); + +#endif + +#ifdef GLIBTOP_NAMES + +/* You need to link with -lgtop_names to get this stuff here. */ + +extern const char *glibtop_names_procdata []; +extern const char *glibtop_labels_procdata []; +extern const char *glibtop_descriptions_procdata []; + +#endif + + + + +The Stub File + + +The stub file is used when the library has not yet been ported to the +system it is used on. It goes into sysdeps/stub +and sets the whole structure glibtop_procdata +to zero: + + +<filename>sysdeps/stub/procdata.c</filename> + + +/* Provides detailed information about a process. */ + +void +glibtop_get_procdata (glibtop *server, glibtop_procdata *buf, pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_procdata)); +} + + + + +We'll see later how to port this stub to a particular operating system. +At the moment it's enough to simply copy it to each of the other sysdeps +directories (except for common, +names and guile). + + +<filename>sysdeps/names</filename> + + +In sysdeps/names, we create the following file: + + +<filename>sysdeps/names/procdata.c</filename> + + +#include <glibtop/procdata.h> + +const char *glibtop_names_procdata [GLIBTOP_MAX_PROCDATA] = +{ "cmd", "state", "uid", "pid", "ppid", "pgrp", "session", + "tty", "tpgid", "priority", "nice", "signal", "blocked", + "sigignore", "sigcatch", "start_time", "utime", "stime", + "cutime", "cstime", "size", "resident", "share", "trs", + "lrs", "drs", "dt", "vsize", "rss", "rss_rlim", "timeout", + "it_real_value", "k_flags", "min_flt", "maj_flt", "cmin_flt", + "cmaj_flt", "start_code", "end_code", "start_stack", + "kstk_esp", "kstk_eip", "wchan" +}; + +const char *glibtop_labels_procdata [GLIBTOP_MAX_PROCDATA] = +{ N_("Cmd"), N_("Stat"), N_("UID"), N_("PID"), N_("PPID"), N_("PGRP"), + N_("Session"), N_("Tty"), N_("TPGID"), N_("Priority"), N_("Nice"), + N_("Signal"), N_("Blocked"), N_("SigIgnore"), N_("SigCatch"), + N_("Start_Time"), N_("UTime"), N_("STime"), N_("CUTime"), N_("CSTime"), + N_("Size"), N_("Resident"), N_("Share"), N_("TRS"), N_("LRS"), N_("DRS"), + N_("DT"), N_("VSize"), N_("RSS"), N_("RSS_RLim"), N_("Timeout"), + N_("It_Real_Value"), N_("Flags"), N_("Min_Flt"), N_("Maj_Flt"), + N_("CMin_Flt"), N_("Cmaj_Flt"), N_("Start_Code"), N_("End_Code"), + N_("Start_Stack"), N_("KSTK_ESP"), N_("KSTK_EIP"), N_("WChan") +}; + +const char *glibtop_descriptions_procdata [GLIBTOP_MAX_PROCDATA] = +{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL +}; + + + + +The Guile Interface + + +The next step is to create the guile interface. It goes into +sysdeps/guile: + + +<filename>sysdeps/guile/procdata.c</filename> + + +SCM +glibtop_guile_get_procdata (SCM pid) +{ + glibtop_procdata p; + + glibtop_get_procdata (&glibtop_global_server, &p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_str02scm (p.cmd), + gh_char2scm (p.state), + gh_long2scm (p.pid), + gh_long2scm (p.ppid), + gh_long2scm (p.pgrp), + gh_long2scm (p.session), + gh_long2scm (p.tty), + gh_long2scm (p.tpgid), + gh_long2scm (p.priority), + gh_long2scm (p.nice), + gh_long2scm (p.signal), + gh_long2scm (p.blocked), + gh_long2scm (p.sigignore), + gh_long2scm (p.sigcatch), + gh_long2scm (p.utime), + gh_long2scm (p.stime), + gh_long2scm (p.cutime), + gh_long2scm (p.cstime), + gh_long2scm (p.size), + gh_long2scm (p.resident), + gh_long2scm (p.share), + gh_long2scm (p.trs), + gh_long2scm (p.lrs), + gh_long2scm (p.drs), + gh_long2scm (p.dt), + gh_ulong2scm (p.vsize), + gh_ulong2scm (p.rss), + gh_ulong2scm (p.rss_rlim), + gh_ulong2scm (p.timeout), + gh_ulong2scm (p.it_real_value), + gh_ulong2scm (p.k_flags), + gh_ulong2scm (p.min_flt), + gh_ulong2scm (p.maj_flt), + gh_ulong2scm (p.cmin_flt), + gh_ulong2scm (p.cmaj_flt), + gh_ulong2scm (p.start_code), + gh_ulong2scm (p.end_code), + gh_ulong2scm (p.start_stack), + gh_ulong2scm (p.kstk_esp), + gh_ulong2scm (p.kstk_eip), + gh_ulong2scm (p.wchan), + SCM_UNDEFINED); +} + + + + +Guile Names and Labels + + +This is a little bit shorter again - all you have to do is copy one of +the other files and change the names: + + +<filename>sysdeps/guile/names/procdata.c</filename> + + +#include <glibtop.h> +#include <glibtop/procdata.h> + +#include <guile/gh.h> + +SCM +glibtop_guile_names_procdata (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROCDATA; i++) + list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_procdata [i]), SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_procdata (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROCDATA; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_procdata [i])), + SCM_UNDEFINED)); + + return list; +} + + + + +The Library File + + +The last one is the library file: + + +<filename>lib/procdata.c</filename> + + +#include <glibtop/procdata.h> +#include <glibtop/command.h> + +/* Provides detailed information about a process. */ + +void +glibtop_get_procdata (glibtop *server, glibtop_procdata *buf, pid_t pid) +{ + glibtop_call (server, GLIBTOP_CMND_PROCDATA, sizeof (pid_t), &pid, + sizeof (glibtop_procdata), buf); +} + + + + +Make sure to define GLIBTOP_CMND_PROCDATA in +command.h. The call to +glibtop_call is simple - we send +pid and its size and we get +buf which is of type +glibtop_procdata. + + +Sysdeps + + +Finally, we add an entry to sysdeps.h and +sysdeps.c: + + +<filename>includes/glibtop/sysdeps.h</filename> + + +#include <glibtop.h> +#include <glibtop/cpu.h> +#include <glibtop/mem.h> +#include <glibtop/swap.h> +#include <glibtop/uptime.h> +#include <glibtop/loadavg.h> +#include <glibtop/shm_limits.h> +#include <glibtop/msg_limits.h> +#include <glibtop/sem_limits.h> +#include <glibtop/proclist.h> +#include <glibtop/procdata.h> + +#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_PROCDATA 9 + +#define GLIBTOP_MAX_SYSDEPS 10 + +typedef struct _glibtop_sysdeps glibtop_sysdeps; + +struct _glibtop_sysdeps +{ + unsigned long flags, + cpu, /* glibtop_cpu */ + mem, /* glibtop_mem */ + swap, /* glibtop_swap */ + uptime, /* glibtop_uptime */ + loadavg, /* glibtop_loadavg */ + shm_limits, /* glibtop_shm_limits */ + msg_limits, /* glibtop_msg_limits */ + sem_limits, /* glibtop_sem_limits */ + proclist, /* glibtop_proclist */ + procdata; /* glibtop_procdata */ +}; + + + + +Just make sure to include procdata.h, to define +GLIBTOP_SYSDEPS_PROCDATA, to increase +GLIBTOP_MAX_SYSDEPS by one and to add to new element +procdata to +glibtop_sysdeps. + + +After that, add a procdata to +glibtop_union +(it's defined in union.h) and include +procdata.h in that file: + + +<filename>include/glibtop/union.h</filename> + + +#include <glibtop/cpu.h> +#include <glibtop/mem.h> +#include <glibtop/swap.h> +#include <glibtop/uptime.h> +#include <glibtop/loadavg.h> +#include <glibtop/shm_limits.h> +#include <glibtop/msg_limits.h> +#include <glibtop/sem_limits.h> +#include <glibtop/proclist.h> +#include <glibtop/procdata.h> + +typedef union _glibtop_union glibtop_union; + +union _glibtop_union +{ + glibtop_cpu cpu; + glibtop_mem mem; + glibtop_swap swap; + glibtop_uptime uptime; + glibtop_loadavg loadavg; + glibtop_shm_limits shm_limits; + glibtop_msg_limits msg_limits; + glibtop_sem_limits sem_limits; + glibtop_proclist proclist; + glibtop_procdata procdata; +}; + + + + +Now we can append the following to glibtop_get_sysdeps +in sysdeps/common/sysdeps.c: + +Add this at the end of +<function>glibtop_get_sysdeps</function> in +<filename>sysdeps/common/sysdeps.c</filename> + + + + glibtop_get_procdata (server, &data.procdata, 0); + buf->procdata = data.procdata.flags; + + + + +Also add the new name and label to sysdeps/names/sysdeps.c + + +Adding the new command to the server + + +We have to add the following switch case: + +Add this to <filename>src/main.c</filename>: + + + case GLIBTOP_CMND_PROCDATA: + if (sscanf (parameter, "%d", &pid) != 1) pid = 0; + glibtop_get_procdata (&server, &data.procdata, pid); + glibtop_output (sizeof (glibtop_procdata), &data.procdata); + glibtop_output (0, NULL); + break; + + + + +Compiling ... + + +Now it's time to add procdata.c to the +Makefile.am in each directory we added +this file and run a make. + + +Interface Description + + +General information + + +<structname>glibtop_cpu</structname> - CPU usage + + +typedef struct _glibtop_cpu glibtop_cpu; + +struct _glibtop_cpu +{ + unsigned long flags, + total, /* GLIBTOP_CPU_TOTAL */ + user, /* GLIBTOP_CPU_USER */ + nice, /* GLIBTOP_CPU_NICE */ + sys, /* GLIBTOP_CPU_SYS */ + idle; /* GLIBTOP_CPU_IDLE */ +}; + + + +<structname>glibtop_mem</structname> - Memory usage + + +typedef struct _glibtop_mem glibtop_mem; + +struct _glibtop_mem +{ + unsigned long flags, + total, /* GLIBTOP_MEM_TOTAL */ + used, /* GLIBTOP_MEM_USED */ + free, /* GLIBTOP_MEM_FREE */ + shared, /* GLIBTOP_MEM_SHARED */ + buffer, /* GLIBTOP_MEM_BUFFER */ + cached, /* GLIBTOP_MEM_CACHED */ + user; /* GLIBTOP_MEM_USER */ +}; + + + +<structname>glibtop_swap</structname> - Swap usage + + +typedef struct _glibtop_swap glibtop_swap; + +struct _glibtop_swap +{ + unsigned long flags, + total, /* GLIBTOP_SWAP_TOTAL */ + used, /* GLIBTOP_SWAP_USED */ + free; /* GLIBTOP_SWAP_FREE */ +}; + + + +<structname>glibtop_uptime</structname> - uptime and idletime + + +typedef struct _glibtop_uptime glibtop_uptime; + +struct _glibtop_uptime +{ + unsigned long flags; + double uptime, /* GLIBTOP_UPTIME_UPTIME */ + idletime; /* GLIBTOP_UPTIME_IDLETIME */ +}; + + + +<structname>glibtop_loadavg</structname> - load averange + + +typedef struct _glibtop_loadavg glibtop_loadavg; + +struct _glibtop_loadavg +{ + unsigned long flags; + double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */ +}; + + + +Function Descriptions + + +Opening and Closing + + +Before you can use the library, you have to open a connection to the server. + + +<function>glibtop_open()</function> - connect to server + + + +#include <glibtop.h> +#include <glibtop/open.h> +void glibtop_open +glibtop *server, const char *program_name + + + + +server + + + +some data about the server (input and output pipes etc.) are stored here. + + +program_name + + + +program name (used in error messages). + + + +<function>glibtop_close()</function> - close connection to server + + + +#include <glibtop.h> +#include <glibtop/close.h> +void glibtop_close +glibtop *server + + + + +server + + + +the server you connected to. + + + +<function>glibtop_get_sysdeps()</function> - which features are implemented? + + + +#include <glibtop.h> +#include <glibtop/sysdeps.h> +void glibtop_get_sysdeps +glibtop *server, glibtop_sysdeps *sysdeps + + + +General information + + +<function>glibtop_get_cpu()</function> - get CPU usage + + + +#include <glibtop.h> +#include <glibtop/cpu.h> +void glibtop_get_cpu +glibtop *server, glibtop_cpu *cpu_usage + + + +<function>glibtop_get_mem()</function> - get memory usage + + + +#include <glibtop.h> +#include <glibtop/mem.h> +void glibtop_get_mem +glibtop *server, glibtop_mem *memory_usage + + + +<function>glibtop_get_swap()</function> - get swap usage + + + +#include <glibtop.h> +#include <glibtop/swap.h> +void glibtop_get_swap +glibtop *server, glibtop_swap *swap_usage + + + +<function>glibtop_get_uptime()</function> - get uptime and idle time + + + +#include <glibtop.h> +#include <glibtop/uptime.h> +void glibtop_get_uptime +glibtop *server, glibtop_uptime *uptime + + + +<function>glibtop_get_loadavg()</function> - get load averange + + + +#include <glibtop.h> +#include <glibtop/loadavg.h> +void glibtop_get_loadavg +glibtop *server, glibtop_loadavg *loadavg + + +
diff --git a/examples/.cvsignore b/examples/.cvsignore new file mode 100644 index 00000000..d13bffe3 --- /dev/null +++ b/examples/.cvsignore @@ -0,0 +1,13 @@ +.deps +.libs +Makefile +Makefile.in +first +first_linux +first_static +second +third +third_linux +third_static +second_static +second_linux diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 00000000..6c50866d --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,66 @@ +## Process this file with automake to produce Makefile.in + +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +DEFS = @DEFS@ + +bin_PROGRAMS = first first_static first_linux \ + second second_static second_linux \ + @guile_examples@ + +EXTRA_PROGRAMS = third third_static third_linux + +first_SOURCES = first.c +first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ + $(top_builddir)/lib/libgtop.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 \ + @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 + +third_SOURCES = third.c +third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \ + $(top_builddir)/sysdeps/guile/names/libgtop_guile_names.la \ + $(top_builddir)/sysdeps/names/libgtop_names.la \ + $(top_builddir)/sysdeps/common/libgtop_common.la \ + $(top_builddir)/lib/libgtop.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 \ + $(top_builddir)/sysdeps/guile/names/libgtop_guile_names.la \ + $(top_builddir)/sysdeps/names/libgtop_names.la \ + $(top_builddir)/sysdeps/common/libgtop_common.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ + @GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@ +third_linux_LDFLAGS = -static diff --git a/examples/first.c b/examples/first.c new file mode 100644 index 00000000..218a3fc0 --- /dev/null +++ b/examples/first.c @@ -0,0 +1,326 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include +#include + +#include +#include + +int +main (int argc, char *argv []) +{ + glibtop_union data; + glibtop_sysdeps sysdeps; + unsigned i, *ptr; + pid_t pid, ppid; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, GTOPLOCALEDIR); + textdomain (PACKAGE); + + glibtop_init__r (&glibtop_global_server); + + 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); + + fprintf (stderr, "Memory (0x%08lx): %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); + + 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); + + fprintf (stderr, "Uptime (0x%08lx): %f, %f\n", data.uptime.flags, + data.uptime.uptime, data.uptime.idletime); + + 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); + + 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); + + fprintf (stderr, "Msg Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld, %ld, %ld\n", + data.msg_limits.flags, data.msg_limits.msgpool, + data.msg_limits.msgmap, data.msg_limits.msgmax, + data.msg_limits.msgmnb, data.msg_limits.msgmni, + data.msg_limits.msgssz, data.msg_limits.msgtql); + + glibtop_get_sem_limits (&data.sem_limits); + + fprintf (stderr, "Sem Limits (0x%08lx): " + "%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n", + data.sem_limits.flags, data.sem_limits.semmap, + data.sem_limits.semmni, data.sem_limits.semmns, + data.sem_limits.semmnu, data.sem_limits.semmsl, + data.sem_limits.semopm, data.sem_limits.semume, + data.sem_limits.semusz, data.sem_limits.semvmx, + data.sem_limits.semaem); + + fprintf (stderr, "\n"); + + glibtop_get_sysdeps (&sysdeps); + + fprintf (stderr, "Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " + "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", + sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap, + sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits, + sysdeps.msg_limits, sysdeps.sem_limits, + sysdeps.proclist, sysdeps.proc_state, + sysdeps.proc_uid, sysdeps.proc_mem, + sysdeps.proc_time, sysdeps.proc_signal, + sysdeps.proc_kernel, sysdeps.proc_segment); + + fprintf (stderr, "\n"); + + ptr = glibtop_get_proclist (&data.proclist); + + fprintf (stderr, "Proclist (0x%08lx): %ld, %ld, %ld\n", + data.proclist.flags, data.proclist.number, + data.proclist.size, data.proclist.total); + + if (ptr) { + fprintf (stderr, "\nProcess: "); + for (i = 0; i < data.proclist.number; i++) + fprintf (stderr, "%s%u", i ? ", " : "", ptr [i]); + fprintf (stderr, "\n"); + } + + glibtop_free (ptr); + + pid = getpid (); + ppid = getppid (); + + fprintf (stderr, "\n"); + + 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); + + fprintf (stderr, "Proc_Uid PID %5u (0x%08lx): " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + pid, data.proc_uid.flags, data.proc_uid.uid, + data.proc_uid.euid, data.proc_uid.gid, + data.proc_uid.egid, data.proc_uid.pid, + data.proc_uid.ppid, data.proc_uid.pgrp, + data.proc_uid.session, data.proc_uid.tty, + data.proc_uid.tpgid, data.proc_uid.priority, + data.proc_uid.nice); + + 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, + data.proc_mem.size, data.proc_mem.vsize, + 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); + + fprintf (stderr, "Proc_Time PID %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags, + data.proc_time.start_time, data.proc_time.utime, + data.proc_time.stime, data.proc_time.cutime, + data.proc_time.cstime, data.proc_time.timeout, + data.proc_time.it_real_value); + + 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); + + fprintf (stderr, "Proc_Kernel PID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", pid, + data.proc_kernel.flags, data.proc_kernel.k_flags, + data.proc_kernel.min_flt, data.proc_kernel.maj_flt, + data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, + data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, + data.proc_kernel.wchan); + + 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, + data.proc_segment.trs, data.proc_segment.lrs, + data.proc_segment.drs, data.proc_segment.dt, + data.proc_segment.start_code, data.proc_segment.end_code, + data.proc_segment.start_stack); + + fprintf (stderr, "\n"); + + 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); + + fprintf (stderr, "Proc_Uid PPID %5u (0x%08lx): " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + ppid, data.proc_uid.flags, data.proc_uid.uid, + data.proc_uid.euid, data.proc_uid.gid, + data.proc_uid.egid, data.proc_uid.pid, + data.proc_uid.ppid, data.proc_uid.pgrp, + data.proc_uid.session, data.proc_uid.tty, + data.proc_uid.tpgid, data.proc_uid.priority, + data.proc_uid.nice); + + 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, + data.proc_mem.size, data.proc_mem.vsize, + 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); + + fprintf (stderr, "Proc_Time PPID %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld %ld\n", ppid, data.proc_time.flags, + data.proc_time.start_time, data.proc_time.utime, + data.proc_time.stime, data.proc_time.cutime, + data.proc_time.cstime, data.proc_time.timeout, + data.proc_time.it_real_value); + + 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); + + fprintf (stderr, "Proc_Kernel PPID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", ppid, + data.proc_kernel.flags, data.proc_kernel.k_flags, + data.proc_kernel.min_flt, data.proc_kernel.maj_flt, + data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, + data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, + data.proc_kernel.wchan); + + 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, + data.proc_segment.trs, data.proc_segment.lrs, + data.proc_segment.drs, data.proc_segment.dt, + data.proc_segment.start_code, data.proc_segment.end_code, + data.proc_segment.start_stack); + + fprintf (stderr, "\n"); + + 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); + + fprintf (stderr, "Proc_Uid INIT %5u (0x%08lx): " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + 1, data.proc_uid.flags, data.proc_uid.uid, + data.proc_uid.euid, data.proc_uid.gid, + data.proc_uid.egid, data.proc_uid.pid, + data.proc_uid.ppid, data.proc_uid.pgrp, + data.proc_uid.session, data.proc_uid.tty, + data.proc_uid.tpgid, data.proc_uid.priority, + data.proc_uid.nice); + + 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, + data.proc_mem.size, data.proc_mem.vsize, + 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); + + fprintf (stderr, "Proc_Time INIT %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld %ld\n", 1, data.proc_time.flags, + data.proc_time.start_time, data.proc_time.utime, + data.proc_time.stime, data.proc_time.cutime, + data.proc_time.cstime, data.proc_time.timeout, + data.proc_time.it_real_value); + + 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); + + fprintf (stderr, "Proc_Kernel INIT %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", 1, + data.proc_kernel.flags, data.proc_kernel.k_flags, + data.proc_kernel.min_flt, data.proc_kernel.maj_flt, + data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, + data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, + data.proc_kernel.wchan); + + 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, + data.proc_segment.trs, data.proc_segment.lrs, + data.proc_segment.drs, data.proc_segment.dt, + data.proc_segment.start_code, data.proc_segment.end_code, + data.proc_segment.start_stack); + + exit (0); +} diff --git a/examples/second.c b/examples/second.c new file mode 100644 index 00000000..c3d1b0f5 --- /dev/null +++ b/examples/second.c @@ -0,0 +1,140 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include +#include + +#include +#include + +int +main (int argc, char *argv []) +{ + glibtop_union data; + glibtop_proclist proclist; + glibtop_sysdeps sysdeps; + unsigned *ptr, pid, i; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, GTOPLOCALEDIR); + textdomain (PACKAGE); + + glibtop_init__r (&glibtop_global_server); + + glibtop_get_sysdeps (&sysdeps); + + fprintf (stderr, "Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " + "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", + sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap, + sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits, + sysdeps.msg_limits, sysdeps.sem_limits, + sysdeps.proclist, sysdeps.proc_state, + sysdeps.proc_uid, sysdeps.proc_mem, + sysdeps.proc_time, sysdeps.proc_signal, + sysdeps.proc_kernel, sysdeps.proc_segment); + + fprintf (stderr, "\n"); + + ptr = glibtop_get_proclist (&proclist); + + fprintf (stderr, "Proclist (0x%08lx): %ld, %ld, %ld\n", + proclist.flags, proclist.number, proclist.size, + proclist.total); + + if (!ptr) exit (1); + + for (i = 0; i < proclist.number; i++) { + + pid = ptr [i]; + + fprintf (stderr, "\n"); + + 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); + + fprintf (stderr, "Proc_Uid PID %5u (0x%08lx): " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + pid, data.proc_uid.flags, data.proc_uid.uid, + data.proc_uid.euid, data.proc_uid.gid, + data.proc_uid.egid, data.proc_uid.pid, + data.proc_uid.ppid, data.proc_uid.pgrp, + data.proc_uid.session, data.proc_uid.tty, + data.proc_uid.tpgid, data.proc_uid.priority, + data.proc_uid.nice); + + 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, + data.proc_mem.size, data.proc_mem.vsize, + 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); + + fprintf (stderr, "Proc_Time PID %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags, + data.proc_time.start_time, data.proc_time.utime, + data.proc_time.stime, data.proc_time.cutime, + data.proc_time.cstime, data.proc_time.timeout, + data.proc_time.it_real_value); + + 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); + + fprintf (stderr, "Proc_Kernel PID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", pid, + data.proc_kernel.flags, data.proc_kernel.k_flags, + data.proc_kernel.min_flt, data.proc_kernel.maj_flt, + data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, + data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, + data.proc_kernel.wchan); + + 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, + data.proc_segment.trs, data.proc_segment.lrs, + data.proc_segment.drs, data.proc_segment.dt, + data.proc_segment.start_code, data.proc_segment.end_code, + data.proc_segment.start_stack); + + fprintf (stderr, "\n"); + } + + glibtop_free (ptr); + + exit (0); +} diff --git a/examples/third.c b/examples/third.c new file mode 100644 index 00000000..d4160425 --- /dev/null +++ b/examples/third.c @@ -0,0 +1,51 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include +#include + +#include +#include + +void main_prog(int argc, char *argv[]); + +int +main (int argc, char *argv[]) +{ + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, GTOPLOCALEDIR); + textdomain (PACKAGE); + + gh_enter (argc, argv, main_prog); + exit (0); +} + +void +main_prog (int argc, char *argv[]) +{ + glibtop_boot_guile (); + glibtop_boot_guile_names (); + + gh_repl (argc, argv); +} diff --git a/examples/third.scm b/examples/third.scm new file mode 100644 index 00000000..2de3e006 --- /dev/null +++ b/examples/third.scm @@ -0,0 +1,10 @@ +(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) diff --git a/glibtop.h b/glibtop.h new file mode 100644 index 00000000..01309bf8 --- /dev/null +++ b/glibtop.h @@ -0,0 +1,72 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_H__ +#define __GLIBTOP_H__ + +#include + +#ifdef HAVE_GLIBTOP_MACHINE_H +#include +#endif + +typedef struct _glibtop glibtop; + +struct _glibtop +{ + int fd; /* Server file descriptor */ +#ifdef HAVE_GLIBTOP_MACHINE_H + glibtop_machine machine; /* Machine dependent data */ +#endif + int input [2]; /* Pipe client <- server */ + 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 */ + pid_t pid; /* PID of the server */ +}; + +extern glibtop *glibtop_global_server; + +#define glibtop_init() glibtop_init__r(&glibtop_global_server); + +extern glibtop *glibtop_init__r __P((glibtop **)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern void glibtop_boot_guile __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern void glibtop_boot_guile_names __P((void)); + +#ifndef GLIBTOP_NAMES +#define GLIBTOP_NAMES +#endif + +#endif + +#endif diff --git a/gtopConf.sh.in b/gtopConf.sh.in new file mode 100644 index 00000000..a7044717 --- /dev/null +++ b/gtopConf.sh.in @@ -0,0 +1,17 @@ +# +# Configuration of the libgtop package +# + +GTOP_LIBDIR="@GTOP_LIBDIR@" +GTOP_INCLUDEDIR="@GTOP_INCLUDEDIR@" + +GTOP_LIBS="@GTOP_LIBS@" +GTOP_INCS="@GTOP_INCS@" + +GTOP_BINDIR="@GTOP_BINDIR@" +GTOP_SERVER="@GTOP_SERVER@" + +GTOP_SYSDEPS_DIR="@GTOP_SYSDEPS_DIR@" +GTOP_NEED_SERVER="@GTOP_NEED_SERVER@" +GTOP_USE_MACHINE_H="@GTOP_USE_MACHINE_H@" + diff --git a/guile/header.scm b/guile/header.scm new file mode 100644 index 00000000..d3fa5ece --- /dev/null +++ b/guile/header.scm @@ -0,0 +1,440 @@ +;; $Id$ + +(define cpu-type '(("name" . "cpu") + ("label" . "CPU Usage") + ("fields" . (list + (("name" . "total") + ("label" . "Total CPU Usage") + ("type" . "unsigned long")) + (("name" . "user") + ("type" . "unsigned long")) + (("name" . "nice") + ("type" . "unsigned long")) + (("name" . "sys") + ("type" . "unsigned long")) + (("name" . "idle") + ("type" . "unsigned long")) + (("name" . "name") + ("type" . "const char") + ("pointer" . #t)) + (("name" . "test")) + ) + ) + ) + ) + +(define main-function + (lambda (definition) + (letrec ((default-type "unsigned long") + (struct-label-comments #t) + (struct-name-comments #f) + (default-name-tabs-first 3) + (default-name-tabs 4) + (default-type-tabs 2) + (default-comment-tabs 5) + (default-definition-tabs 3) + (default-definition-value-tabs 2) + (default-max-line-length 60) + ;; set default values for unspecified fields + (check-field-definition + (lambda (fields) + (let ((newlist (list))) + (for-each + (lambda (field) + (if (not (assoc-ref field "type")) + (set! field (assoc-set! field "type" default-type))) + (if (assoc-ref field "label") + (set! field (assoc-set! field "has-label" #t)) + (begin + (set! field (assoc-set! field "label" (assoc-ref field "name"))) + (set! field (assoc-set! field "has-label" #f)) + ) + ) + (set! newlist (append newlist (list field))) + ) + (cdr fields)) + (set-cdr! fields newlist) + ) + ) + ) + ;; number fields sequentially + (make-field-numbers + (lambda (fields) + (let ((pos 0) (newlist (list))) + (for-each + (lambda (field) + (set! field (assoc-set! field "number" pos)) + (set! newlist (append newlist (list field))) + (set! pos (+ pos 1)) + ) + (cdr fields)) + (set-cdr! fields newlist) + (set! definition (assoc-set! definition "max-fields" pos)) + ) + ) + ) + ;; pad string with up to 'tabs' tabs + (tabify-string + (lambda (string tabs) + (let ((length (string-length string)) + (tlength (* tabs 8))) + (if (> tlength length) + (let* ((diff (- tlength length)) + (count (quotient (+ diff 7) 8))) + (string-append string + (make-string count #\tab)) + ) + (string-append string + #\space) + ) + ) + ) + ) + ;; pad string with spaces + (spacify-string + (lambda (string tabs) + (let ((length (string-length string)) + (tlength (* tabs 8))) + (if (> tlength length) + (string-append string + (make-string (- tlength length) #\space)) + (string-append string + #\space) + ) + ) + ) + ) + ;; creates comment string + (make-comment-string + (lambda (comment) + (if comment + (string "/* " + (spacify-string comment + default-comment-tabs) + " */") + (string) + ) + ) + ) + ;; create constant for entry (eg. GLIBTOP_CPU_TOTAL) + (entry-constant-name + (lambda (name) + (string-upcase! (string "GLIBTOP_" + (assoc-ref definition "name") + "_" + name + ) + ) + ) + ) + ;; create text that is displayed as comment along with entry + (entry-comment-text + (lambda (name label) + (if label + (if struct-label-comments label #f) + (if struct-name-comments (entry-constant-name name) #f) + ) + ) + ) + ;; starts struct definition + (make-struct-definition-head + (lambda () + (let* ((class (assoc-ref definition "name")) + ) + (string "struct _glibtop_" class "\n" + "{\n" + ) + ) + ) + ) + ;; terminates struct definition + (make-struct-definition-tail + (lambda () + (string "};\n\n") + ) + ) + ;; generate struct definition body + (make-struct-definition-body + (lambda (fields) + (letrec ((output (string)) + (is-first-entry #t) + (current-type #f) + (current-name #f) + (current-label #f) + (current-pointer #f) + ;; close entry (other = next entry is of other type) + (entry-end + (lambda (other) + (let ((old-first is-first-entry)) + (set! is-first-entry other) + (if current-type + (string (tabify-string (string (string (if current-pointer "*" "")) + current-name + (string (if other ";" ",")) + ) + (if old-first + default-name-tabs-first + default-name-tabs + ) + ) + (make-comment-string (entry-comment-text + current-name current-label)) + "\n") + (string) + ) + ) + ) + ) + ;; start new entry + (entry-start + (lambda (name type) + (if current-type + (if (equal? current-type type) + (string (entry-end #f) "\t\t") + (string (entry-end #t) "\t" + (tabify-string type default-type-tabs) + ) + ) + (string "\t" + (tabify-string type default-type-tabs) + ) + ) + ) + ) + ) + ;; main function + (for-each + (lambda (field) + (let ((name (assoc-ref field "name")) + (type (assoc-ref field "type")) + (pointer (assoc-ref field "pointer")) + (label (if (assoc-ref field "has-label") + (assoc-ref field "label") + #f) + ) + ) + (set! output (string-append output + (string (entry-start name type)) + ) + ) + ;; save current data + (set! current-type type) + (set! current-name name) + (set! current-label label) + (set! current-pointer pointer) + ) + ) + (cdr fields)) + ;; close last entry + (string-append output (entry-end #t)) + ) + ) + ) + ;; display complete struct definition + (make-struct-definition + (lambda (fields) + (string-append (make-struct-definition-head) + (make-struct-definition-body fields) + (make-struct-definition-tail) + ) + ) + ) + ;; make constant definition + (make-const-definition + (lambda (name value comment) + (let* ((nstring (string-upcase! (string "GLIBTOP_" name))) + (tabname (tabify-string nstring default-definition-tabs)) + (tabvalue (if comment + (tabify-string (string value) default-definition-value-tabs) + (string value)) + ) + (ctext (make-comment-string comment)) + (line (string "#define " tabname tabvalue ctext "\n")) + ) + line) + ) + ) + ;; creates constant definitions + (make-struct-constants + (lambda (fields) + (let ((class (assoc-ref definition "name")) + (output (string)) + ) + (for-each + (lambda (field) + (let* ((name (assoc-ref field "name")) + (number (assoc-ref field "number")) + (key (string class "_" name)) + (value (number->string number)) + (label (if (assoc-ref field "has-label") + (assoc-ref field "label") + #f) + ) + (line (make-const-definition key + value + (entry-comment-text name label) + ) + ) + ) + (set! output (string-append output line)) + ) + ) + (cdr fields)) + output) + ) + ) + ;; creates definition of maximum constant + (make-struct-max-constant + (lambda () + (let* ((class (assoc-ref definition "name")) + (max (assoc-ref definition "max-fields")) + ) + (make-const-definition (string "MAX_" class) + (number->string max) + #f) + ) + ) + ) + ;; adds new list element to string, inserting newline if necessary + (add-to-string + (lambda (output line element separator indent max-length) + (let* ((slen (string-length line)) + (elen (string-length element)) + (tlen (+ slen elen)) + (bsep (if separator + (string separator " ") + (string) + ) + ) + (nsep (string (if separator separator "") "\n")) + ) + (if (and (> slen 0) (> tlen max-length)) + (begin + (set! output (string-append output line nsep)) + (set! line (string indent element)) + ) + (set! line (string-append line bsep element)) + ) + (list output line) + ) + ) + ) + ;; create general list definition + (make-general-list-definition + (lambda (fields name symbol line-length make-element-string) + (letrec ((class (assoc-ref definition "name")) + (make-general-list-definition-head + (lambda () + (string "const char *" + "glibtop_" + symbol + "_" + class + " " + "[GLIBTOP_MAX_" + (string-upcase! (string class)) + "] = \n{ " + ) + ) + ) + (make-general-list-definition-tail + (lambda () + (string "\n};\n") + ) + ) + (make-general-list-definition-body + (lambda () + (let* ((first #t) (output (string)) (line (string))) + (for-each + (lambda (field) + (let* ((element (assoc-ref field name)) + (olist (add-to-string output line + (make-element-string element) + (if first #f ",") + " " + line-length)) + ) + (set! output (car olist)) + (set! line (car (cdr olist))) + (set! first #f) + ) + ) + (cdr fields)) + (set! output (string-append output line)) + output) + ) + ) + ) + ;; main function + (string-append (make-general-list-definition-head) + (make-general-list-definition-body) + (make-general-list-definition-tail) + ) + ) + ) + ) + ;; create name list definition + (make-name-list-definition + (lambda (fields) + (make-general-list-definition fields + "name" + "names" + default-max-line-length + (lambda (x) + (string #\" x #\") + ) + ) + ) + ) + ;; create label list definition + (make-label-list-definition + (lambda (fields) + (make-general-list-definition fields + "label" + "labels" + 0 + (lambda (x) + (string "gettext_noop (" #\" x #\" ")") + ) + ) + ) + ) + ;; create description list definition + (make-description-list-definition + (lambda (fields) + (make-general-list-definition fields + "description" + "descriptions" + default-max-line-length + (lambda (x) + (if x + (string "gettext_noop (" #\" x #\" ")") + (string "NULL") + ) + ) + ) + ) + ) + ) + ;; start of main function + (let ((fielddef (assoc-ref definition "fields"))) + (display fielddef) (newline) (newline) + (check-field-definition fielddef) + (make-field-numbers fielddef) + (display fielddef) (newline) (newline) + (display (make-struct-definition fielddef)) + (display (make-struct-constants fielddef)) (newline) + (display (make-struct-max-constant)) (newline) (newline) + (display (make-name-list-definition fielddef)) (newline) + (display (make-label-list-definition fielddef)) (newline) + (display (make-description-list-definition fielddef)) (newline) + ) + ) + ) + ) + +(begin + (main-function cpu-type) + (newline) + ) + diff --git a/guile/make-header.scm b/guile/make-header.scm new file mode 100644 index 00000000..ec51216b --- /dev/null +++ b/guile/make-header.scm @@ -0,0 +1,195 @@ +(define cpu-type '(("name" . "cpu") + ("label" . "CPU Usage") + ("fields" . (("unsigned long" ("total" "Total CPU Usage") + ("user") ("nice") ("sys") ("idle")) + ("const char" ("name")) + ) + ) + ) + ) + +;; computes constant for struct field (eg. GLIBTOP_CPU_TOTAL) + +(define field-name-constant + (lambda (name field) + (string "GLIBTOP_" + (string-upcase! (string name)) + "_" + (string-upcase! (string field))) + ) + ) + +;; computes structure name (eg. glibtop_cpu) + +(define make-struct-name + (lambda (type) + (string "glibtop_" (assoc-ref type "name")) + ) + ) + +(define tab-pad-string + (lambda (string tabs) + (string-append string (make-string (- (* tabs 8) (string-length string)) #\space)) + ) + ) + +(define make-field-list + (lambda (name type fields) + (let* ((output (string)) (pos 1)) + (map + (lambda (x) + (let* ((sep (if (= pos (length fields)) ";" ",")) + (start (if (= pos 1) + (string "\t" + (tab-pad-string (string type) 2)) + (string "\t\t")) + ) + (comment (string (if (= pos 1) "" "\t") "/* " + (tab-pad-string (field-name-constant name (car x)) 3) + " */")) + (field (tab-pad-string (string-append (string (car x)) sep) 2)) + ) + (set! pos (+ pos 1)) + (string-append start field comment "\n") + ) + ) + fields) + ) + ) + ) + +(define make-struct-body + (lambda (type) + (let* ((name (assoc-ref type "name")) + (data (assoc-ref type "fields")) + (output (string)) + ) + (for-each + (lambda (y) + (for-each + (lambda (z) + (set! output (string-append output z)) + ) + y) + ) + (map + (lambda (x) (make-field-list name (car x) (cdr x))) + data) + ) + output) + ) + ) + +(define make-struct + (lambda (type) + (let* ((name (assoc-ref type "name")) + (data (assoc-ref type "fields")) + (output (string-append + (tab-pad-string + (string "typedef struct _glibtop_" name) + 5) + (string "glibtop_" name ";\n\n" + "struct glibtop_" name "\n{\n\t" + "unsigned long\tflags;\n") + ) + ) + ) + (string-append output (make-struct-body type) "};\n") + ) + ) + ) + +(define make-field-name-list + (lambda (type) + (let* ((name (assoc-ref type "name")) + (data (assoc-ref type "fields")) + (return (list)) + ) + (map + (lambda (x) + (map + (lambda (y) (set! return (append return (list (car y))))) + (cdr x) + ) + ) + data) + return) + ) + ) + +(define make-field-constants + (lambda (type) + (let* ((name (assoc-ref type "name")) + (data (make-field-name-list type)) + (output (string + (tab-pad-string + (string "#define GLIBTOP_MAX_" + (string-upcase! (string name)) + ) 5) + (number->string (length data)) + "\n\n" + ) + ) + (pos 0) + ) + (for-each + (lambda (x) + (set! output (string-append output (string + (tab-pad-string + (string "#define GLIBTOP_" + (string-upcase! (string name)) + "_" + (string-upcase! (string x)) + ) 5) + (number->string pos) + "\n" + ) + ) + ) + (set! pos (+ pos 1)) + ) + data) + output) + ) + ) + +(define make-extern-defs + (lambda (type) + (let* ((name (assoc-ref type "name")) + ) + (string + (tab-pad-string (string "extern void glibtop_get_" name) 6) + "__P(glibtop *, glibtop_" name " *);\n\n" + "#ifdef HAVE_GUILE\n\n" + "/* You need to link with -lgtop_guile to get this stuff here. */\n\n" + (tab-pad-string (string "extern SCM glibtop_get_" name) 6) + "__P(void);\n\n" + "#endif /* HAVE_GUILE */\n\n" + "#ifdef GLIBTOP_GUILE_NAMES\n\n" + "/* You need to link with -lgtop_guile_names to get this stuff here. */\n\n" + (tab-pad-string (string "extern SCM glibtop_guile_names_" name) 6) + "__P(void);\n" + (tab-pad-string (string "extern SCM glibtop_guile_labels_" name) 6) + "__P(void);\n" + (tab-pad-string (string "extern SCM glibtop_guile_descriptions_" name) 6) + "__P(void);\n\n" + "#endif /* GLIBTOP_GUILE_NAMES */\n\n" + "#ifdef GLIBTOP_NAMES\n\n" + "/* You need to link with -lgtop_names to get this stuff here. */\n\n" + (tab-pad-string (string "extern const char *glibtop_names_" name) 6) + "[];\n" + (tab-pad-string (string "extern const char *glibtop_labels_" name) 6) + "[];\n" + (tab-pad-string (string "extern const char *glibtop_descriptions_" name) 6) + "[];\n\n" + "#endif /* GLIBTOP_NAMES */\n\n") + ) + ) + ) + +(begin + (display (make-field-constants cpu-type)) (newline) + (display (make-struct cpu-type)) (newline) + (display (make-extern-defs cpu-type)) (newline) + ) + diff --git a/include/glibtop/close.h b/include/glibtop/close.h new file mode 100644 index 00000000..d57ccd38 --- /dev/null +++ b/include/glibtop/close.h @@ -0,0 +1,33 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_CLOSE_H__ +#define __GLIBTOP_CLOSE_H__ + +#include + +__BEGIN_DECLS + +extern void glibtop_close __P((glibtop *)); + +__END_DECLS + +#endif diff --git a/include/glibtop/command.h b/include/glibtop/command.h new file mode 100644 index 00000000..2afcd582 --- /dev/null +++ b/include/glibtop/command.h @@ -0,0 +1,67 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_COMMAND_H__ +#define __GLIBTOP_COMMAND_H__ + +#include +#include + +__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 +#define GLIBTOP_CMND_UPTIME 5 +#define GLIBTOP_CMND_LOADAVG 6 +#define GLIBTOP_CMND_SHM_LIMITS 7 +#define GLIBTOP_CMND_MSG_LIMITS 8 +#define GLIBTOP_CMND_SEM_LIMITS 9 +#define GLIBTOP_CMND_PROCLIST 10 + +#define GLIBTOP_CMND_PROC_STATE 11 +#define GLIBTOP_CMND_PROC_UID 12 +#define GLIBTOP_CMND_PROC_MEM 13 +#define GLIBTOP_CMND_PROC_TIME 14 +#define GLIBTOP_CMND_PROC_SIGNAL 15 +#define GLIBTOP_CMND_PROC_KERNEL 16 +#define GLIBTOP_CMND_PROC_SEGMENT 17 + +#define GLIBTOP_MAX_CMND 18 + +typedef struct _glibtop_command glibtop_command; + +struct _glibtop_command +{ + glibtop server; + unsigned command; + size_t size; +}; + +#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 *)); + +__END_DECLS + +#endif diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h new file mode 100644 index 00000000..0d1b77ec --- /dev/null +++ b/include/glibtop/cpu.h @@ -0,0 +1,88 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_CPU_H__ +#define __GLIBTOP_CPU_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_CPU_TOTAL 0 +#define GLIBTOP_CPU_USER 1 +#define GLIBTOP_CPU_NICE 2 +#define GLIBTOP_CPU_SYS 3 +#define GLIBTOP_CPU_IDLE 4 +#define GLIBTOP_CPU_FREQUENCY 5 + +#define GLIBTOP_MAX_CPU 6 + +typedef struct _glibtop_cpu glibtop_cpu; + +struct _glibtop_cpu +{ + unsigned long flags, + total, /* GLIBTOP_CPU_TOTAL */ + user, /* GLIBTOP_CPU_USER */ + nice, /* GLIBTOP_CPU_NICE */ + sys, /* GLIBTOP_CPU_SYS */ + idle, /* GLIBTOP_CPU_IDLE */ + frequency; /* GLIBTOP_CPU_FREQUENCY */ +}; + +#define glibtop_get_cpu(cpu) glibtop_get_cpu__r(glibtop_global_server, cpu) + +extern void glibtop_get_cpu__r __P((glibtop *, glibtop_cpu *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_cpu __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_cpu __P((void)); +extern SCM glibtop_guile_types_cpu __P((void)); +extern SCM glibtop_guile_labels_cpu __P((void)); +extern SCM glibtop_guile_descriptions_cpu __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_cpu []; +extern const char *glibtop_descriptions_cpu []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/error.h b/include/glibtop/error.h new file mode 100644 index 00000000..94e14ba9 --- /dev/null +++ b/include/glibtop/error.h @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_ERROR_H__ +#define __GLIBTOP_ERROR_H__ + +#include + +__BEGIN_DECLS + +#define glibtop_error(p1, args...) glibtop_error__r(glibtop_global_server , p1 , ## args) + +extern void glibtop_error__r __P((glibtop *, char *, ...)); + +__END_DECLS + +#endif diff --git a/include/glibtop/global.h b/include/glibtop/global.h new file mode 100644 index 00000000..d1609f35 --- /dev/null +++ b/include/glibtop/global.h @@ -0,0 +1,93 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_GLOBAL_H__ +#define __GLIBTOP_GLOBAL_H__ + +#include + +/* __BEGIN_DECLS should be used at the beginning of your declarations, + so that C++ compilers don't mangle their names. Use __END_DECLS at + the end of C declarations. */ + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +/* __P is a macro used to wrap function prototypes, so that compilers + that don't understand ANSI C prototypes still work, and ANSI C + compilers can issue warnings about type mismatches. */ + +#undef __P +#if defined (__STDC__) || defined (_AIX) \ +|| (defined (__mips) && defined (_SYSTYPE_SVR4)) \ + || defined(WIN32) || defined(__cplusplus) +# define __P(protos) protos +#else +# define __P(protos) () +#endif + +#ifdef HAVE_GUILE +#include +#endif + +#if (defined HAVE_LIBINTL_H) || (defined HAVE_GETTEXT) +#include +#else +#include +#endif + +#include +#include + +#include +#include + +#ifdef HAVE_MEMORY_H +#include +#endif + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +#ifndef _ +#define _(String) gettext (String) +#define N_(String) (String) +#endif + +#ifndef HAVE_STRERROR +extern char *strerror __P((int)); +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h new file mode 100644 index 00000000..d33b589c --- /dev/null +++ b/include/glibtop/loadavg.h @@ -0,0 +1,78 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_LOADAVG_H__ +#define __GLIBTOP_LOADAVG_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_LOADAVG_LOADAVG 0 + +#define GLIBTOP_MAX_LOADAVG 1 + +typedef struct _glibtop_loadavg glibtop_loadavg; + +struct _glibtop_loadavg +{ + unsigned long flags; + double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */ +}; + +#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg__r(glibtop_global_server, loadavg) + +extern void glibtop_get_loadavg__r __P((glibtop *, glibtop_loadavg *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_loadavg __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_loadavg __P((void)); +extern SCM glibtop_guile_types_loadavg __P((void)); +extern SCM glibtop_guile_labels_loadavg __P((void)); +extern SCM glibtop_guile_descriptions_loadavg __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_loadavg []; +extern const char *glibtop_descriptions_loadavg []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h new file mode 100644 index 00000000..a2eaca95 --- /dev/null +++ b/include/glibtop/mem.h @@ -0,0 +1,90 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_MEM_H__ +#define __GLIBTOP_MEM_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_MEM_TOTAL 0 +#define GLIBTOP_MEM_USED 1 +#define GLIBTOP_MEM_FREE 2 +#define GLIBTOP_MEM_SHARED 3 +#define GLIBTOP_MEM_BUFFER 4 +#define GLIBTOP_MEM_CACHED 5 +#define GLIBTOP_MEM_USER 6 + +#define GLIBTOP_MAX_MEM 7 + +typedef struct _glibtop_mem glibtop_mem; + +struct _glibtop_mem +{ + unsigned long flags, + total, /* GLIBTOP_MEM_TOTAL */ + used, /* GLIBTOP_MEM_USED */ + free, /* GLIBTOP_MEM_FREE */ + shared, /* GLIBTOP_MEM_SHARED */ + buffer, /* GLIBTOP_MEM_BUFFER */ + cached, /* GLIBTOP_MEM_CACHED */ + user; /* GLIBTOP_MEM_USER */ +}; + +#define glibtop_get_mem(mem) glibtop_get_mem__r(glibtop_global_server, mem) + +extern void glibtop_get_mem__r __P((glibtop *, glibtop_mem *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_mem __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_mem __P((void)); +extern SCM glibtop_guile_types_mem __P((void)); +extern SCM glibtop_guile_labels_mem __P((void)); +extern SCM glibtop_guile_descriptions_mem __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_mem []; +extern const char *glibtop_descriptions_mem []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/msg_limits.h b/include/glibtop/msg_limits.h new file mode 100644 index 00000000..a45b8ba7 --- /dev/null +++ b/include/glibtop/msg_limits.h @@ -0,0 +1,90 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_MSG_LIMITS_H__ +#define __GLIBTOP_MSG_LIMITS_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_IPC_MSGPOOL 0 +#define GLIBTOP_IPC_MSGMAP 1 +#define GLIBTOP_IPC_MSGMAX 2 +#define GLIBTOP_IPC_MSGMNB 3 +#define GLIBTOP_IPC_MSGMNI 4 +#define GLIBTOP_IPC_MSGSSZ 5 +#define GLIBTOP_IPC_MSGTQL 6 + +#define GLIBTOP_MAX_MSG_LIMITS 7 + +typedef struct _glibtop_msg_limits glibtop_msg_limits; + +struct _glibtop_msg_limits +{ + unsigned long flags, + msgpool, /* GLIBTOP_IPC_MSGPOOL */ + msgmap, /* GLIBTOP_IPC_MSGMAP */ + msgmax, /* GLIBTOP_IPC_MSGMAX */ + msgmnb, /* GLIBTOP_IPC_MSGMNB */ + msgmni, /* GLIBTOP_IPC_MSGMNI */ + msgssz, /* GLIBTOP_IPC_MSGSSZ */ + msgtql; /* GLIBTOP_IPC_MSGTQL */ +}; + +#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits__r(glibtop_global_server, msg) + +extern void glibtop_get_msg_limits__r __P((glibtop *, glibtop_msg_limits *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_msg_limits __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_msg_limits __P((void)); +extern SCM glibtop_guile_types_msg_limits __P((void)); +extern SCM glibtop_guile_labels_msg_limits __P((void)); +extern SCM glibtop_guile_descriptions_msg_limits __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_msg_limits []; +extern const char *glibtop_descriptions_msg_limits []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/open.h b/include/glibtop/open.h new file mode 100644 index 00000000..8be5a9ae --- /dev/null +++ b/include/glibtop/open.h @@ -0,0 +1,33 @@ +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_OPEN_H__ +#define __GLIBTOP_OPEN_H__ + +#include +#include +#include + +__BEGIN_DECLS + +extern void glibtop_open __P((glibtop *, const char *)); + +__END_DECLS + +#endif diff --git a/include/glibtop/output.h b/include/glibtop/output.h new file mode 100644 index 00000000..293a967d --- /dev/null +++ b/include/glibtop/output.h @@ -0,0 +1,33 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_OUTPUT_H__ +#define __GLIBTOP_OUTPUT_H__ + +#include + +__BEGIN_DECLS + +extern void glibtop_output __P((size_t, const void *)); + +__END_DECLS + +#endif diff --git a/include/glibtop/prockernel.h b/include/glibtop/prockernel.h new file mode 100644 index 00000000..90a43b65 --- /dev/null +++ b/include/glibtop/prockernel.h @@ -0,0 +1,99 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCKERNEL_H__ +#define __GLIBTOP_PROCKERNEL_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_KERNEL_K_FLAGS 0 +#define GLIBTOP_PROC_KERNEL_MIN_FLT 1 +#define GLIBTOP_PROC_KERNEL_MAJ_FLT 2 +#define GLIBTOP_PROC_KERNEL_CMIN_FLT 3 +#define GLIBTOP_PROC_KERNEL_CMAJ_FLT 4 +#define GLIBTOP_PROC_KERNEL_KSTK_ESP 5 +#define GLIBTOP_PROC_KERNEL_KSTK_EIP 6 +#define GLIBTOP_PROC_KERNEL_WCHAN 7 + +#define GLIBTOP_MAX_PROC_KERNEL 8 + +typedef struct _glibtop_proc_kernel glibtop_proc_kernel; + +/* Kernel stuff */ + +struct _glibtop_proc_kernel +{ + unsigned long flags; + unsigned long k_flags, /* kernel flags for the process */ + min_flt, /* number of minor page faults since + * process start */ + maj_flt, /* number of major page faults since + * process start */ + cmin_flt, /* cumulative min_flt of process and + * child processes */ + cmaj_flt, /* cumulative maj_flt of process and + * child processes */ + kstk_esp, /* kernel stack pointer */ + kstk_eip, /* kernel stack pointer */ + wchan; /* address of kernel wait channel + * proc is sleeping in */ +}; + +#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel__r(glibtop_global_server, p1, p2) + +extern void glibtop_get_proc_kernel__r __P((glibtop *, glibtop_proc_kernel *, pid_t)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proc_kernel __P((SCM)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_types_proc_kernel __P((void)); +extern SCM glibtop_guile_names_proc_kernel __P((void)); +extern SCM glibtop_guile_labels_proc_kernel __P((void)); +extern SCM glibtop_guile_descriptions_proc_kernel __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proc_kernel []; +extern const char *glibtop_descriptions_proc_kernel []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h new file mode 100644 index 00000000..d163b828 --- /dev/null +++ b/include/glibtop/proclist.h @@ -0,0 +1,82 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCLIST_H__ +#define __GLIBTOP_PROCLIST_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROCLIST_NUMBER 0 +#define GLIBTOP_PROCLIST_TOTAL 1 +#define GLIBTOP_PROCLIST_SIZE 2 + +#define GLIBTOP_MAX_PROCLIST 3 + +typedef struct _glibtop_proclist glibtop_proclist; + +struct _glibtop_proclist +{ + unsigned long flags, + number, /* GLIBTOP_PROCLIST_NUMBER */ + total, /* GLIBTOP_PROCLIST_TOTAL */ + size; /* GLIBTOP_PROCLIST_SIZE */ +}; + +#define glibtop_get_proclist(proclist) glibtop_get_proclist__r(glibtop_global_server, proclist) + +extern unsigned *glibtop_get_proclist__r __P((glibtop *, glibtop_proclist *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proclist __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_proclist __P((void)); +extern SCM glibtop_guile_types_proclist __P((void)); +extern SCM glibtop_guile_labels_proclist __P((void)); +extern SCM glibtop_guile_descriptions_proclist __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proclist []; +extern const char *glibtop_descriptions_proclist []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/procmem.h b/include/glibtop/procmem.h new file mode 100644 index 00000000..bcca778a --- /dev/null +++ b/include/glibtop/procmem.h @@ -0,0 +1,92 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCMEM_H__ +#define __GLIBTOP_PROCMEM_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_MEM_SIZE 0 +#define GLIBTOP_PROC_MEM_VSIZE 1 +#define GLIBTOP_PROC_MEM_RESIDENT 2 +#define GLIBTOP_PROC_MEM_SHARE 3 +#define GLIBTOP_PROC_MEM_RSS 4 +#define GLIBTOP_PROC_MEM_RSS_RLIM 5 + +#define GLIBTOP_MAX_PROC_MEM 6 + +typedef struct _glibtop_proc_mem glibtop_proc_mem; + +/* Memory section */ + +struct _glibtop_proc_mem +{ + unsigned long flags; + long size, /* total # of pages of memory */ + vsize, /* number of pages of virtual memory ... */ + resident, /* number of resident set + * (non-swapped) pages (4k) */ + share, /* number of pages of shared (mmap'd) memory */ + rss, /* resident set size */ + rss_rlim; /* current limit (in bytes) of the rss + * 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) + +extern void glibtop_get_proc_mem__r __P((glibtop *, glibtop_proc_mem *, pid_t)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proc_mem __P((SCM)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_types_proc_mem __P((void)); +extern SCM glibtop_guile_names_proc_mem __P((void)); +extern SCM glibtop_guile_labels_proc_mem __P((void)); +extern SCM glibtop_guile_descriptions_proc_mem __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proc_mem []; +extern const char *glibtop_descriptions_proc_mem []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h new file mode 100644 index 00000000..b52f5bbf --- /dev/null +++ b/include/glibtop/procsegment.h @@ -0,0 +1,93 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCSEGMENT_H__ +#define __GLIBTOP_PROCSEGMENT_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_SEGMENT_TRS 0 +#define GLIBTOP_PROC_SEGMENT_LRS 1 +#define GLIBTOP_PROC_SEGMENT_DRS 2 +#define GLIBTOP_PROC_SEGMENT_DT 3 +#define GLIBTOP_PROC_SEGMENT_START_CODE 4 +#define GLIBTOP_PROC_SEGMENT_END_CODE 5 +#define GLIBTOP_PROC_SEGMENT_START_STACK 6 + +#define GLIBTOP_MAX_PROC_SEGMENT 7 + +typedef struct _glibtop_proc_segment glibtop_proc_segment; + +/* Segment stuff */ + +struct _glibtop_proc_segment +{ + unsigned long flags; + long trs, /* text resident set size */ + lrs, /* shared-lib resident set size */ + drs, /* data resident set size */ + dt; /* dirty pages */ + unsigned long start_code, + /* address of beginning of code segment */ + end_code, /* address of end of code 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) + +extern void glibtop_get_proc_segment__r __P((glibtop *, glibtop_proc_segment *, pid_t)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proc_segment __P((SCM)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_proc_segment __P((void)); +extern SCM glibtop_guile_types_proc_segment __P((void)); +extern SCM glibtop_guile_labels_proc_segment __P((void)); +extern SCM glibtop_guile_descriptions_proc_segment __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proc_segment []; +extern const char *glibtop_descriptions_proc_segment []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/procsignal.h b/include/glibtop/procsignal.h new file mode 100644 index 00000000..dda8a5bf --- /dev/null +++ b/include/glibtop/procsignal.h @@ -0,0 +1,86 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCSIGNAL_H__ +#define __GLIBTOP_PROCSIGNAL_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_SIGNAL_SIGNAL 0 +#define GLIBTOP_PROC_SIGNAL_BLOCKED 1 +#define GLIBTOP_PROC_SIGNAL_SIGIGNORE 2 +#define GLIBTOP_PROC_SIGNAL_SIGCATCH 3 + +#define GLIBTOP_MAX_PROC_SIGNAL 4 + +typedef struct _glibtop_proc_signal glibtop_proc_signal; + +/* Signals section */ + +struct _glibtop_proc_signal +{ + unsigned long flags; + int signal, /* mask of pending signals */ + blocked, /* mask of blocked signals */ + sigignore, /* mask of ignored signals */ + sigcatch; /* mask of caught signals */ +}; + +#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal__r(glibtop_global_server, p1, p2) + +extern void glibtop_get_proc_signal__r __P((glibtop *, glibtop_proc_signal *, pid_t)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proc_signal __P((SCM)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_proc_signal __P((void)); +extern SCM glibtop_guile_types_proc_signal __P((void)); +extern SCM glibtop_guile_labels_proc_signal __P((void)); +extern SCM glibtop_guile_descriptions_proc_signal __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proc_signal []; +extern const char *glibtop_descriptions_proc_signal []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h new file mode 100644 index 00000000..c03f20d0 --- /dev/null +++ b/include/glibtop/procstate.h @@ -0,0 +1,93 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCSTATE_H__ +#define __GLIBTOP_PROCSTATE_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_STATE_CMD 0 +#define GLIBTOP_PROC_STATE_STATE 1 +#define GLIBTOP_PROC_STATE_UID 2 +#define GLIBTOP_PROC_STATE_GID 3 + +#define GLIBTOP_MAX_PROC_STATE 4 + +typedef struct _glibtop_proc_state glibtop_proc_state; + +/* Name and status */ + +struct _glibtop_proc_state +{ + unsigned long flags; + char cmd[40], /* basename of executable file in + * call to exec(2) */ + state; /* single-char code for process state + * (S=sleeping) */ + /* NOTE: when porting the library, TRY HARD to implement the + * following two fields. */ + /* IMPORTANT NOTICE: For security reasons, it is extremely important + * only to set the flags value for those two + * fields if their values are corrent ! */ + int uid, /* UID of process */ + gid; /* GID of process */ +}; + +#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state__r(glibtop_global_server, p1, p2) + +extern void glibtop_get_proc_state__r __P((glibtop *, glibtop_proc_state *, pid_t)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proc_state __P((SCM)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_proc_state __P((void)); +extern SCM glibtop_guile_types_proc_state __P((void)); +extern SCM glibtop_guile_labels_proc_state __P((void)); +extern SCM glibtop_guile_descriptions_proc_state __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proc_state []; +extern const char *glibtop_descriptions_proc_state []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/proctime.h b/include/glibtop/proctime.h new file mode 100644 index 00000000..50d08c17 --- /dev/null +++ b/include/glibtop/proctime.h @@ -0,0 +1,98 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCTIME_H__ +#define __GLIBTOP_PROCTIME_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_TIME_START_TIME 0 +#define GLIBTOP_PROC_TIME_UTIME 1 +#define GLIBTOP_PROC_TIME_STIME 2 +#define GLIBTOP_PROC_TIME_CUTIME 3 +#define GLIBTOP_PROC_TIME_CSTIME 4 +#define GLIBTOP_PROC_TIME_TIMEOUT 5 +#define GLIBTOP_PROC_TIME_IT_REAL_VALUE 6 + +#define GLIBTOP_MAX_PROC_TIME 7 + +typedef struct _glibtop_proc_time glibtop_proc_time; + +/* Time section */ + +struct _glibtop_proc_time +{ + unsigned long flags; + long start_time, /* start time of process -- + * seconds since 1-1-70 */ + utime, /* user-mode CPU time accumulated by process */ + stime, /* kernel-mode CPU time accumulated by process */ + cutime, /* cumulative utime of process and + * reaped children */ + cstime, /* cumulative stime of process and + * reaped children */ + timeout, /* The time (in jiffies) of the process's + * next timeout */ + it_real_value; /* The time (in jiffies) before the + * next SIGALRM is sent to the process + * due to an interval timer. */ +}; + +#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time__r(glibtop_global_server, p1, p2) + +extern void glibtop_get_proc_time__r __P((glibtop *, glibtop_proc_time *, pid_t)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proc_time __P((SCM)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_proc_time __P((void)); +extern SCM glibtop_guile_types_proc_time __P((void)); +extern SCM glibtop_guile_labels_proc_time __P((void)); +extern SCM glibtop_guile_descriptions_proc_time __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proc_time []; +extern const char *glibtop_descriptions_proc_time []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h new file mode 100644 index 00000000..decb9c25 --- /dev/null +++ b/include/glibtop/procuid.h @@ -0,0 +1,102 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PROCUID_H__ +#define __GLIBTOP_PROCUID_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PROC_UID_UID 0 +#define GLIBTOP_PROC_UID_EUID 1 +#define GLIBTOP_PROC_UID_GID 2 +#define GLIBTOP_PROC_UID_EGID 3 +#define GLIBTOP_PROC_UID_PID 4 +#define GLIBTOP_PROC_UID_PPID 5 +#define GLIBTOP_PROC_UID_PGRP 6 +#define GLIBTOP_PROC_UID_SESSION 7 +#define GLIBTOP_PROC_UID_TTY 8 +#define GLIBTOP_PROC_UID_TPGID 9 +#define GLIBTOP_PROC_UID_PRIORITY 10 +#define GLIBTOP_PROC_UID_NICE 11 + +#define GLIBTOP_MAX_PROC_UID 12 + +typedef struct _glibtop_proc_uid glibtop_proc_uid; + +/* User, Group, Terminal and session */ + +struct _glibtop_proc_uid +{ + unsigned long flags; + int uid, /* user id */ + euid, /* effective user id */ + gid, /* group id */ + egid, /* effective group id */ + pid, /* process id */ + ppid, /* pid of parent process */ + pgrp, /* process group id */ + session, /* session id */ + tty, /* full device number of controlling terminal */ + tpgid, /* terminal process group id */ + priority, /* kernel scheduling priority */ + nice; /* standard unix nice level of process */ +}; + +#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid__r(glibtop_global_server, p1, p2) + +extern void glibtop_get_proc_uid__r __P((glibtop *, glibtop_proc_uid *, pid_t)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_proc_uid __P((SCM)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_proc_uid __P((void)); +extern SCM glibtop_guile_types_proc_uid __P((void)); +extern SCM glibtop_guile_labels_proc_uid __P((void)); +extern SCM glibtop_guile_descriptions_proc_uid __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_proc_uid []; +extern const char *glibtop_descriptions_proc_uid []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/read.h b/include/glibtop/read.h new file mode 100644 index 00000000..ef9a3ea0 --- /dev/null +++ b/include/glibtop/read.h @@ -0,0 +1,36 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_READ_H__ +#define __GLIBTOP_READ_H__ + +#include +#include + +__BEGIN_DECLS + +#define glibtop_read(p1, p2) glibtop_read(glibtop_global_server, p1, p2) + +extern void glibtop_read__r __P((glibtop *, size_t, void *)); + +__END_DECLS + +#endif diff --git a/include/glibtop/read_data.h b/include/glibtop/read_data.h new file mode 100644 index 00000000..f0c54294 --- /dev/null +++ b/include/glibtop/read_data.h @@ -0,0 +1,36 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_READ_DATA_H__ +#define __GLIBTOP_READ_DATA_H__ + +#include +#include + +__BEGIN_DECLS + +#define glibtop_read_data() glibtop_read_data__r(glibtop_global_server) + +extern void *glibtop_read_data__r __P((glibtop *)); + +__END_DECLS + +#endif diff --git a/include/glibtop/sem_limits.h b/include/glibtop/sem_limits.h new file mode 100644 index 00000000..283f0029 --- /dev/null +++ b/include/glibtop/sem_limits.h @@ -0,0 +1,96 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SEM_LIMITS_H__ +#define __GLIBTOP_SEM_LIMITS_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_IPC_SEMMAP 0 +#define GLIBTOP_IPC_SEMMNI 1 +#define GLIBTOP_IPC_SEMMNS 2 +#define GLIBTOP_IPC_SEMMNU 3 +#define GLIBTOP_IPC_SEMMSL 4 +#define GLIBTOP_IPC_SEMOPM 5 +#define GLIBTOP_IPC_SEMUME 6 +#define GLIBTOP_IPC_SEMUSZ 7 +#define GLIBTOP_IPC_SEMVMX 8 +#define GLIBTOP_IPC_SEMAEM 9 + +#define GLIBTOP_MAX_SEM_LIMITS 10 + +typedef struct _glibtop_sem_limits glibtop_sem_limits; + +struct _glibtop_sem_limits +{ + unsigned long flags, + semmap, /* GLIBTOP_IPC_SEMMAP */ + semmni, /* GLIBTOP_IPC_SEMMNI */ + semmns, /* GLIBTOP_IPC_SEMMNS */ + semmnu, /* GLIBTOP_IPC_SEMMNU */ + semmsl, /* GLIBTOP_IPC_SEMMSL */ + semopm, /* GLIBTOP_IPC_SEMOPM */ + semume, /* GLIBTOP_IPC_SEMUME */ + semusz, /* GLIBTOP_IPC_SEMUSZ */ + semvmx, /* GLIBTOP_IPC_SEMVMX */ + semaem; /* GLIBTOP_IPC_SEMAEM */ +}; + +#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits__r(glibtop_global_server, sem) + +extern void glibtop_get_sem_limits__r __P((glibtop *, glibtop_sem_limits *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_sem_limits __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_sem_limits __P((void)); +extern SCM glibtop_guile_types_sem_limits __P((void)); +extern SCM glibtop_guile_labels_sem_limits __P((void)); +extern SCM glibtop_guile_descriptions_sem_limits __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_sem_limits []; +extern const char *glibtop_descriptions_sem_limits []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/shm_limits.h b/include/glibtop/shm_limits.h new file mode 100644 index 00000000..db4a926d --- /dev/null +++ b/include/glibtop/shm_limits.h @@ -0,0 +1,86 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SHM_LIMITS_H__ +#define __GLIBTOP_SHM_LIMITS_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_IPC_SHMMAX 0 +#define GLIBTOP_IPC_SHMMIN 1 +#define GLIBTOP_IPC_SHMMNI 2 +#define GLIBTOP_IPC_SHMSEG 3 +#define GLIBTOP_IPC_SHMALL 4 + +#define GLIBTOP_MAX_SHM_LIMITS 5 + +typedef struct _glibtop_shm_limits glibtop_shm_limits; + +struct _glibtop_shm_limits +{ + unsigned long flags, + shmmax, /* GLIBTOP_IPC_SHMMAX */ + shmmin, /* GLIBTOP_IPC_SHMMIN */ + shmmni, /* GLIBTOP_IPC_SHMMNI */ + shmseg, /* GLIBTOP_IPC_SHMSEG */ + shmall; /* GLIBTOP_IPC_SHMALL */ +}; + +#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits__r(glibtop_global_server, shm) + +extern void glibtop_get_shm_limits__r __P((glibtop *, glibtop_shm_limits *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_shm_limits __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_shm_limits __P((void)); +extern SCM glibtop_guile_types_shm_limits __P((void)); +extern SCM glibtop_guile_labels_shm_limits __P((void)); +extern SCM glibtop_guile_descriptions_shm_limits __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_shm_limits []; +extern const char *glibtop_descriptions_shm_limits []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/swap.h b/include/glibtop/swap.h new file mode 100644 index 00000000..dd42ac30 --- /dev/null +++ b/include/glibtop/swap.h @@ -0,0 +1,82 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SWAP_H__ +#define __GLIBTOP_SWAP_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_SWAP_TOTAL 0 +#define GLIBTOP_SWAP_USED 1 +#define GLIBTOP_SWAP_FREE 2 + +#define GLIBTOP_MAX_SWAP 3 + +typedef struct _glibtop_swap glibtop_swap; + +struct _glibtop_swap +{ + unsigned long flags, + total, /* GLIBTOP_SWAP_TOTAL */ + used, /* GLIBTOP_SWAP_USED */ + free; /* GLIBTOP_SWAP_FREE */ +}; + +#define glibtop_get_swap(swap) glibtop_get_swap__r(glibtop_global_server, swap) + +extern void glibtop_get_swap__r __P((glibtop *, glibtop_swap *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_swap __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_swap __P((void)); +extern SCM glibtop_guile_types_swap __P((void)); +extern SCM glibtop_guile_labels_swap __P((void)); +extern SCM glibtop_guile_descriptions_swap __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_swap []; +extern const char *glibtop_descriptions_swap []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h new file mode 100644 index 00000000..b7eec5cb --- /dev/null +++ b/include/glibtop/sysdeps.h @@ -0,0 +1,108 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SYSDEPS_H__ +#define __GLIBTOP_SYSDEPS_H__ + +#include +#include + +__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_MAX_SYSDEPS 16 + +typedef struct _glibtop_sysdeps glibtop_sysdeps; + +struct _glibtop_sysdeps +{ + unsigned long flags, + cpu, /* glibtop_cpu */ + mem, /* glibtop_mem */ + swap, /* glibtop_swap */ + uptime, /* glibtop_uptime */ + loadavg, /* glibtop_loadavg */ + shm_limits, /* glibtop_shm_limits */ + msg_limits, /* glibtop_msg_limits */ + sem_limits, /* glibtop_sem_limits */ + proclist, /* glibtop_proclist */ + proc_state, /* glibtop_proc_state */ + proc_uid, /* glibtop_proc_uid */ + proc_mem, /* glibtop_proc_mem */ + proc_time, /* glibtop_proc_time */ + proc_signal, /* glibtop_proc_signal */ + proc_kernel, /* glibtop_proc_kernel */ + proc_segment; /* glibtop_proc_segment */ +}; + +#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps__r(glibtop_global_server,sysdeps) + +extern void glibtop_get_sysdeps__r __P((glibtop *, glibtop_sysdeps *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_sysdeps __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_sysdeps __P((void)); +extern SCM glibtop_guile_types_sysdeps __P((void)); +extern SCM glibtop_guile_labels_sysdeps __P((void)); +extern SCM glibtop_guile_descriptions_sysdeps __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_sysdeps []; +extern const char *glibtop_descriptions_sysdeps []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/union.h b/include/glibtop/union.h new file mode 100644 index 00000000..fb3b6aff --- /dev/null +++ b/include/glibtop/union.h @@ -0,0 +1,69 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_UNION_H__ +#define __GLIBTOP_UNION_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +typedef union _glibtop_union glibtop_union; + +union _glibtop_union +{ + glibtop_cpu cpu; + glibtop_mem mem; + glibtop_swap swap; + glibtop_uptime uptime; + glibtop_loadavg loadavg; + glibtop_shm_limits shm_limits; + glibtop_msg_limits msg_limits; + glibtop_sem_limits sem_limits; + glibtop_proclist proclist; + glibtop_proc_state proc_state; + glibtop_proc_uid proc_uid; + glibtop_proc_mem proc_mem; + glibtop_proc_time proc_time; + glibtop_proc_signal proc_signal; + glibtop_proc_kernel proc_kernel; + glibtop_proc_segment proc_segment; +}; + +__END_DECLS + +#endif diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h new file mode 100644 index 00000000..10815ecb --- /dev/null +++ b/include/glibtop/uptime.h @@ -0,0 +1,80 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_UPTIME_H__ +#define __GLIBTOP_UPTIME_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_UPTIME_UPTIME 0 +#define GLIBTOP_UPTIME_IDLETIME 1 + +#define GLIBTOP_MAX_UPTIME 2 + +typedef struct _glibtop_uptime glibtop_uptime; + +struct _glibtop_uptime +{ + unsigned long flags; + double uptime, /* GLIBTOP_UPTIME_UPTIME */ + idletime; /* GLIBTOP_UPTIME_IDLETIME */ +}; + +#define glibtop_get_uptime(uptime) glibtop_get_uptime__r(glibtop_global_server, uptime) + +extern void glibtop_get_uptime__r __P((glibtop *, glibtop_uptime *)); + +#ifdef HAVE_GUILE + +/* You need to link with -lgtop_guile to get this stuff here. */ + +extern SCM glibtop_guile_get_uptime __P((void)); + +#endif + +#ifdef GLIBTOP_GUILE_NAMES + +/* You need to link with -lgtop_guile_names to get this stuff here. */ + +extern SCM glibtop_guile_names_uptime __P((void)); +extern SCM glibtop_guile_types_uptime __P((void)); +extern SCM glibtop_guile_labels_uptime __P((void)); +extern SCM glibtop_guile_descriptions_uptime __P((void)); + +#endif + +#ifdef GLIBTOP_NAMES + +/* 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 char *glibtop_labels_uptime []; +extern const char *glibtop_descriptions_uptime []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/version.h b/include/glibtop/version.h new file mode 100644 index 00000000..5676b997 --- /dev/null +++ b/include/glibtop/version.h @@ -0,0 +1,31 @@ +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_VERSION_H__ +#define __GLIBTOP_VERSION_H__ + +#include + +__BEGIN_DECLS + +extern void glibtop_version __P((void)); + +__END_DECLS + +#endif diff --git a/include/glibtop/write.h b/include/glibtop/write.h new file mode 100644 index 00000000..e7acb1fc --- /dev/null +++ b/include/glibtop/write.h @@ -0,0 +1,36 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_WRITE_H__ +#define __GLIBTOP_WRITE_H__ + +#include +#include + +__BEGIN_DECLS + +#define glibtop_write(p1, p2) glibtop_write(glibtop_global_server, p1, p2) + +extern void glibtop_write__r __P((glibtop *, size_t, void *)); + +__END_DECLS + +#endif diff --git a/include/glibtop/xmalloc.h b/include/glibtop/xmalloc.h new file mode 100644 index 00000000..14a6709c --- /dev/null +++ b/include/glibtop/xmalloc.h @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_XMALLOC_H__ +#define __GLIBTOP_XMALLOC_H__ + +#include +#include + +__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) + +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 + +#endif diff --git a/lib/.cvsignore b/lib/.cvsignore new file mode 100644 index 00000000..221fbc2f --- /dev/null +++ b/lib/.cvsignore @@ -0,0 +1,34 @@ +.deps +.libs +Makefile +Makefile.in +close.lo +command.lo +cpu.lo +error.lo +init.lo +ipc_limits.lo +libgtop.la +loadavg.lo +mem.lo +msg_limits.lo +open.lo +procdata.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +read.lo +read_data.lo +sem_limits.lo +shm_limits.lo +so_locations +swap.lo +sysinfo.lo +uptime.lo +write.lo +xmalloc.lo diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 00000000..5477b586 --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1,15 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@GTOP_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 + diff --git a/lib/close.c b/lib/close.c new file mode 100644 index 00000000..8f85c512 --- /dev/null +++ b/lib/close.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Closes pipe to gtop server. */ + +void +glibtop_close (glibtop *server) +{ + kill (server->pid, SIGKILL); + close (server->input [0]); + close (server->output [1]); +} diff --git a/lib/command.c b/lib/command.c new file mode 100644 index 00000000..03df4375 --- /dev/null +++ b/lib/command.c @@ -0,0 +1,54 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include +#include + +void * +glibtop_call__r (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); + + 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); + + ptr = glibtop_read_data__r (server); + + glibtop_free__r (server, cmnd); + + return ptr; +} diff --git a/lib/cpu.c b/lib/cpu.c new file mode 100644 index 00000000..253f1114 --- /dev/null +++ b/lib/cpu.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about cpu usage. */ + +void +glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_CPU, 0, NULL, sizeof (glibtop_cpu), buf); +} diff --git a/lib/init.c b/lib/init.c new file mode 100644 index 00000000..f6a9a506 --- /dev/null +++ b/lib/init.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = NULL; + +glibtop * +glibtop_init__r (glibtop **server) +{ + if (*server != NULL) + return *server; + + if (glibtop_global_server == NULL) { + glibtop_global_server = &_glibtop_global_server; + glibtop_open (glibtop_global_server, "glibtop"); + } + + return *server = glibtop_global_server; +} diff --git a/lib/loadavg.c b/lib/loadavg.c new file mode 100644 index 00000000..8671bfe8 --- /dev/null +++ b/lib/loadavg.c @@ -0,0 +1,33 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Provides load averange. */ + +void +glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_LOADAVG, 0, NULL, sizeof (glibtop_loadavg), buf); +} diff --git a/lib/mem.c b/lib/mem.c new file mode 100644 index 00000000..ad760c4b --- /dev/null +++ b/lib/mem.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about memory usage. */ + +void +glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_MEM, 0, NULL, sizeof (glibtop_mem), buf); +} diff --git a/lib/msg_limits.c b/lib/msg_limits.c new file mode 100644 index 00000000..a8c6760a --- /dev/null +++ b/lib/msg_limits.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, sizeof (glibtop_msg_limits), buf); +} diff --git a/lib/open.c b/lib/open.c new file mode 100644 index 00000000..7b36a871 --- /dev/null +++ b/lib/open.c @@ -0,0 +1,60 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ + +void +glibtop_open (glibtop *server, const char *program_name) +{ + char version [BUFSIZ], buffer [BUFSIZ]; + + memset (server, 0, sizeof (glibtop)); + + server->name = program_name; + + if (pipe (server->input) || pipe (server->output)) + 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)); + } 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); + _exit (2); + } + + close (server->input [1]); + close (server->output [0]); + + sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION); + + glibtop_read__r (server, strlen (version), buffer); + + if (memcmp (version, buffer, strlen (version))) + glibtop_error__r (server, _("server version is not %s"), VERSION); +} diff --git a/lib/prockernel.c b/lib/prockernel.c new file mode 100644 index 00000000..9dd9fccb --- /dev/null +++ b/lib/prockernel.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* 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); +} diff --git a/lib/proclist.c b/lib/proclist.c new file mode 100644 index 00000000..deae7ce2 --- /dev/null +++ b/lib/proclist.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* 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); +} diff --git a/lib/procmem.c b/lib/procmem.c new file mode 100644 index 00000000..5f4e8991 --- /dev/null +++ b/lib/procmem.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, + pid_t pid) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), + &pid, sizeof (glibtop_proc_mem), buf); +} diff --git a/lib/procsegment.c b/lib/procsegment.c new file mode 100644 index 00000000..ee10a5d8 --- /dev/null +++ b/lib/procsegment.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* 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); +} diff --git a/lib/procsignal.c b/lib/procsignal.c new file mode 100644 index 00000000..d0ae5468 --- /dev/null +++ b/lib/procsignal.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, + pid_t pid) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), + &pid, sizeof (glibtop_proc_signal), buf); +} diff --git a/lib/procstate.c b/lib/procstate.c new file mode 100644 index 00000000..557bfd85 --- /dev/null +++ b/lib/procstate.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, + pid_t pid) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), + &pid, sizeof (glibtop_proc_state), buf); +} diff --git a/lib/proctime.c b/lib/proctime.c new file mode 100644 index 00000000..a6ab8c28 --- /dev/null +++ b/lib/proctime.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, + pid_t pid) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), + &pid, sizeof (glibtop_proc_time), buf); +} diff --git a/lib/procuid.c b/lib/procuid.c new file mode 100644 index 00000000..6c06ba19 --- /dev/null +++ b/lib/procuid.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, + pid_t pid) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), + &pid, sizeof (glibtop_proc_uid), buf); +} diff --git a/lib/read.c b/lib/read.c new file mode 100644 index 00000000..f05a617d --- /dev/null +++ b/lib/read.c @@ -0,0 +1,41 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Reads some data from server. */ + +void +glibtop_read__r (glibtop *server, size_t size, void *buf) +{ + size_t ssize; + + glibtop_init__r (&server); + + if (read (server->input [0], &ssize, sizeof (size_t)) < 0) + glibtop_error__r (server, _("read size: %s"), strerror (errno)); + + if (size != ssize) + 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)); +} diff --git a/lib/read_data.c b/lib/read_data.c new file mode 100644 index 00000000..e6012585 --- /dev/null +++ b/lib/read_data.c @@ -0,0 +1,48 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Reads some data from server. */ + +void * +glibtop_read_data__r (glibtop *server) +{ + size_t size; + void *ptr; + + glibtop_init__r (&server); + + if (read (server->input [0], &size, sizeof (size_t)) < 0) + 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); + + if (read (server->input [0], ptr, size) < 0) + glibtop_error__r (server, _("read data %d bytes: %s"), size, strerror (errno)); + + return ptr; +} diff --git a/lib/sem_limits.c b/lib/sem_limits.c new file mode 100644 index 00000000..2be994e9 --- /dev/null +++ b/lib/sem_limits.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, sizeof (glibtop_sem_limits), buf); +} diff --git a/lib/shm_limits.c b/lib/shm_limits.c new file mode 100644 index 00000000..24e3447d --- /dev/null +++ b/lib/shm_limits.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, sizeof (glibtop_shm_limits), buf); +} diff --git a/lib/swap.c b/lib/swap.c new file mode 100644 index 00000000..2a88bc30 --- /dev/null +++ b/lib/swap.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about swap usage. */ + +void +glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_SWAP, 0, NULL, sizeof (glibtop_swap), buf); +} diff --git a/lib/sysdeps.c b/lib/sysdeps.c new file mode 100644 index 00000000..94ed2ac2 --- /dev/null +++ b/lib/sysdeps.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Checks which features are implemented. */ + +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); +} diff --git a/lib/uptime.c b/lib/uptime.c new file mode 100644 index 00000000..9a316433 --- /dev/null +++ b/lib/uptime.c @@ -0,0 +1,33 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Provides uptime and idle time. */ + +void +glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +{ + glibtop_init__r (&server); + glibtop_call__r (server, GLIBTOP_CMND_UPTIME, 0, NULL, sizeof (glibtop_uptime), buf); +} diff --git a/lib/write.c b/lib/write.c new file mode 100644 index 00000000..93b7581a --- /dev/null +++ b/lib/write.c @@ -0,0 +1,38 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Writes some data to server. */ + +void +glibtop_write__r (glibtop *server, size_t size, void *buf) +{ + glibtop_init__r (&server); + + if (write (server->output [1], &size, sizeof (size_t)) < 0) + 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)); +} diff --git a/libgtop-mirror.sh b/libgtop-mirror.sh new file mode 100755 index 00000000..385ad0b1 --- /dev/null +++ b/libgtop-mirror.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +AUTODIR=/home/norwegen/auto +CVSROOT=/pub/master/home-of-linux +CVSHOST=cvs: +MODULE=libgtop + +rm -rf $AUTODIR || exit 1 +mkdir $AUTODIR || exit 1 +cd $AUTODIR || exit 1 + +echo "Making cpio archive out of $CVSROOT/$MODULE ..." + +find $CVSROOT/$MODULE | cpio -o --format=crc | gzip -9f > $MODULE-current-cvs.cpio.gz || exit 1 + +echo "Checking out $MODULE" + +cvs -d $CVSHOST$CVSROOT co $MODULE || exit 1 + +echo "Making cpio archive out of checked out sources ..." + +find $MODULE | cpio -o --format=crc | gzip -9f > $MODULE-current.cpio.gz || exit 1 + +for file in README LIESMICH NEWS ChangeLog ; do + if [ -s $MODULE/$file ] ; then + cp $MODULE/$file . || exit 1 + fi +done + +tar cvf - $MODULE | gzip -9f > $MODULE-current.tar.gz || exit 1 + +find $MODULE/doc -maxdepth 1 -type f -exec cp {} . \; + +# echo "Making documentation ..." +# jade -D /usr/lib/sgml/jade_dsl -d libgtop.dsl -t sgml -V %no-make-index% libgtop.sgml > /dev/null || exit 1 + +# echo "Making TeX documentation ..." +# jade -D /usr/lib/sgml/jade_dsl -D /usr/lib/sgml/stylesheets -d docbook.dsl -t tex libgtop.sgml || exit 1 +# jadetex libgtop.tex || exit 1 +# jadetex libgtop.tex || exit 1 +# dvips libgtop || exit 1 + +echo "Cleaning up ..." + +rm -rf $MODULE + +echo "Done." diff --git a/po/.cvsignore b/po/.cvsignore new file mode 100644 index 00000000..fdccedaf --- /dev/null +++ b/po/.cvsignore @@ -0,0 +1,5 @@ +Makefile +Makefile.in +POTFILES +cat-id-tbl.c +libgtop.pot diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 00000000..be5e228f --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,78 @@ +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 +include/glibtop/command.h +include/glibtop/close.h +include/glibtop/global.h +include/glibtop/cpu.h +include/glibtop/error.h +include/glibtop/shm_limits.h +include/glibtop/uptime.h +include/glibtop/output.h +include/glibtop/mem.h +include/glibtop/open.h +include/glibtop/sysdeps.h +include/glibtop/union.h +include/glibtop/read.h +include/glibtop/swap.h +include/glibtop/loadavg.h +include/glibtop/version.h +include/glibtop/write.h +include/glibtop/xmalloc.h +include/glibtop/msg_limits.h +include/glibtop/proclist.h +include/glibtop/sem_limits.h +include/glibtop/read_data.h +src/server/main.c +src/server/output.c +src/server/version.c +sysdeps/linux/close.c +sysdeps/linux/cpu.c +sysdeps/linux/mem.c +sysdeps/linux/open.c +sysdeps/linux/swap.c +sysdeps/linux/shm_limits.c +sysdeps/linux/msg_limits.c +sysdeps/linux/uptime.c +sysdeps/linux/loadavg.c +sysdeps/linux/sem_limits.c +sysdeps/linux/proclist.c +sysdeps/stub/proclist.c +sysdeps/stub/close.c +sysdeps/stub/cpu.c +sysdeps/stub/mem.c +sysdeps/stub/open.c +sysdeps/stub/swap.c +sysdeps/stub/loadavg.c +sysdeps/stub/uptime.c +sysdeps/stub/shm_limits.c +sysdeps/stub/msg_limits.c +sysdeps/stub/sem_limits.c +sysdeps/common/sysdeps.c +sysdeps/common/xmalloc.c +sysdeps/common/error.c +sysdeps/names/sysdeps.c +sysdeps/names/cpu.c +sysdeps/names/loadavg.c +sysdeps/names/mem.c +sysdeps/names/swap.c +sysdeps/names/uptime.c +sysdeps/names/shm_limits.c +sysdeps/names/msg_limits.c +sysdeps/names/sem_limits.c +sysdeps/names/proclist.c diff --git a/po/stamp-cat-id b/po/stamp-cat-id new file mode 100644 index 00000000..9788f702 --- /dev/null +++ b/po/stamp-cat-id @@ -0,0 +1 @@ +timestamp diff --git a/src/.cvsignore b/src/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/src/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 00000000..b0e22324 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = server diff --git a/src/server/.cvsignore b/src/server/.cvsignore new file mode 100644 index 00000000..2164d8f4 --- /dev/null +++ b/src/server/.cvsignore @@ -0,0 +1,5 @@ +.deps +.libs +Makefile +Makefile.in +gtop_server diff --git a/src/server/Makefile.am b/src/server/Makefile.am new file mode 100644 index 00000000..6fe258f4 --- /dev/null +++ b/src/server/Makefile.am @@ -0,0 +1,14 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +bin_PROGRAMS = gtop_server + +gtop_server_SOURCES = main.c output.c version.c +gtop_server_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ + @INTLLIBS@ @LIBSUPPORT@ +gtop_server_LDFLAGS = -static + diff --git a/src/server/main.c b/src/server/main.c new file mode 100644 index 00000000..93332f12 --- /dev/null +++ b/src/server/main.c @@ -0,0 +1,258 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include +#include +#include + +#include + +#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; + + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ + + int uid, euid, gid, egid; + + uid = getuid (); euid = geteuid (); + gid = getgid (); egid = getegid (); + + if (setreuid (euid, uid)) _exit (1); + + if (setregid (egid, gid)) _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + /* For security reasons, we temporarily drop our priviledges + * before doing the gettext stuff. */ + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, GTOPLOCALEDIR); + textdomain (PACKAGE); + + glibtop_version (); + + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ + + setreuid (uid, euid); setreuid (gid, egid); + + glibtop_open (&server, argv [0]); + + if (setreuid (euid, uid)) _exit (1); + + if (setregid (egid, gid)) _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + /* 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: + glibtop_get_sysdeps__r (&server, &sysdeps); + glibtop_output (sizeof (glibtop_sysdeps), &sysdeps); + glibtop_output (0, NULL); + break; + case GLIBTOP_CMND_CPU: + glibtop_get_cpu__r (&server, &data.cpu); + glibtop_output (sizeof (glibtop_cpu), &data.cpu); + glibtop_output (0, NULL); + break; + case GLIBTOP_CMND_MEM: + glibtop_get_mem__r (&server, &data.mem); + glibtop_output (sizeof (glibtop_mem), &data.mem); + glibtop_output (0, NULL); + break; + case GLIBTOP_CMND_SWAP: + glibtop_get_swap__r (&server, &data.swap); + glibtop_output (sizeof (glibtop_swap), &data.swap); + glibtop_output (0, NULL); + break; + case GLIBTOP_CMND_UPTIME: + glibtop_get_uptime__r (&server, &data.uptime); + glibtop_output (sizeof (glibtop_uptime), &data.uptime); + glibtop_output (0, NULL); + break; + case GLIBTOP_CMND_LOADAVG: + glibtop_get_loadavg__r (&server, &data.loadavg); + 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); + 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); + 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); + 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); + 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__r + (&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__r + (&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__r + (&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__r + (&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__r + (&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__r + (&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__r + (&server, &data.proc_segment, pid); + glibtop_output (sizeof (glibtop_proc_segment), + &data.proc_segment); + glibtop_output (0, NULL); + break; + + } + } + _exit(0); +} diff --git a/src/server/output.c b/src/server/output.c new file mode 100644 index 00000000..9fa98655 --- /dev/null +++ b/src/server/output.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +void +glibtop_output (size_t size, const void *buf) +{ + if (write (1, &size, sizeof (size_t)) < 0) + _exit (2); + if (write (1, buf, size) < 0) + _exit (2); +} diff --git a/src/server/version.c b/src/server/version.c new file mode 100644 index 00000000..3e21f55a --- /dev/null +++ b/src/server/version.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +void +glibtop_version (void) +{ + char buffer [BUFSIZ]; + + sprintf (buffer, "%s server %s ready.\n", PACKAGE, VERSION); + glibtop_output (strlen (buffer), buffer); +} diff --git a/stamp-h.in b/stamp-h.in new file mode 100644 index 00000000..9788f702 --- /dev/null +++ b/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/sysdeps/.cvsignore b/sysdeps/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/sysdeps/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/sysdeps/Makefile.am b/sysdeps/Makefile.am new file mode 100644 index 00000000..b80ead9c --- /dev/null +++ b/sysdeps/Makefile.am @@ -0,0 +1,7 @@ +if GUILE +guile_SUBDIRS = guile +else +guile_SUBDIRS = +endif + +SUBDIRS = @sysdeps_dir@ common names $(guile_SUBDIRS) diff --git a/sysdeps/common/.cvsignore b/sysdeps/common/.cvsignore new file mode 100644 index 00000000..501b8d5f --- /dev/null +++ b/sysdeps/common/.cvsignore @@ -0,0 +1,12 @@ +.deps +.libs +Makefile +Makefile.in +error.lo +libgtop_common.la +msg_limits.lo +sem_limits.lo +shm_limits.lo +sysdeps.lo +xmalloc.lo +so_locations diff --git a/sysdeps/common/Makefile.am b/sysdeps/common/Makefile.am new file mode 100644 index 00000000..3fd5e649 --- /dev/null +++ b/sysdeps/common/Makefile.am @@ -0,0 +1,10 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +lib_LTLIBRARIES = libgtop_common.la + +libgtop_common_la_SOURCES = sysdeps.c xmalloc.c error.c + diff --git a/sysdeps/common/error.c b/sysdeps/common/error.c new file mode 100644 index 00000000..6f1f1963 --- /dev/null +++ b/sysdeps/common/error.c @@ -0,0 +1,39 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Prints error message and exits. */ + +void +glibtop_error__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); + exit (1); +} diff --git a/sysdeps/common/sysdeps.c b/sysdeps/common/sysdeps.c new file mode 100644 index 00000000..1155bbc8 --- /dev/null +++ b/sysdeps/common/sysdeps.c @@ -0,0 +1,80 @@ +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +/* Checks which features are implemented. */ + +void +glibtop_get_sysdeps__r (glibtop *server, glibtop_sysdeps *buf) +{ + glibtop_union data; + + memset (buf, 0, sizeof (glibtop_sysdeps)); + + /* Call all system dependent functions to check which values + * they return. */ + + glibtop_get_cpu__r (server, &data.cpu); + buf->cpu = data.cpu.flags; + + glibtop_get_mem__r (server, &data.mem); + buf->mem = data.mem.flags; + + glibtop_get_swap__r (server, &data.swap); + buf->swap = data.swap.flags; + + glibtop_get_uptime__r (server, &data.uptime); + buf->uptime = data.uptime.flags; + + glibtop_get_loadavg__r (server, &data.loadavg); + buf->loadavg = data.loadavg.flags; + + 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); + buf->msg_limits = data.msg_limits.flags; + + glibtop_get_sem_limits__r (server, &data.sem_limits); + buf->sem_limits = data.sem_limits.flags; + + glibtop_get_proclist__r (server, &data.proclist); + buf->proclist = data.proclist.flags; + + 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); + buf->proc_uid = data.proc_uid.flags; + + 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); + buf->proc_time = data.proc_time.flags; + + 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); + buf->proc_segment = data.proc_segment.flags; +} diff --git a/sysdeps/common/xmalloc.c b/sysdeps/common/xmalloc.c new file mode 100644 index 00000000..66458a18 --- /dev/null +++ b/sysdeps/common/xmalloc.c @@ -0,0 +1,66 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Wrappers to malloc, calloc, realloc ... */ + +void * +glibtop_malloc__r (glibtop *server, size_t size) +{ + void *buf = malloc (size); + + if (!buf) + 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) +{ + void *buf = calloc (nmemb, size); + + if (!buf) + 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) +{ + void *buf = realloc (ptr, size); + + if (!buf) + glibtop_error__r (server, _("realloc %d bytes: %s"), + size, strerror (errno)); + + return buf; +} + +void +glibtop_free__r (glibtop *server, void *ptr) +{ + if (ptr) free (ptr); +} diff --git a/sysdeps/guile/.cvsignore b/sysdeps/guile/.cvsignore new file mode 100644 index 00000000..3956f7f4 --- /dev/null +++ b/sysdeps/guile/.cvsignore @@ -0,0 +1,25 @@ +.deps +.libs +Makefile +Makefile.in +boot.lo +cpu.lo +libgtop_guile.la +loadavg.lo +mem.lo +msg_limits.lo +procdata.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +sem_limits.lo +shm_limits.lo +so_locations +swap.lo +sysdeps.lo +uptime.lo diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am new file mode 100644 index 00000000..c0972cc3 --- /dev/null +++ b/sysdeps/guile/Makefile.am @@ -0,0 +1,15 @@ +SUBDIRS = names + +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +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 diff --git a/sysdeps/guile/boot.c b/sysdeps/guile/boot.c new file mode 100644 index 00000000..fbd86941 --- /dev/null +++ b/sysdeps/guile/boot.c @@ -0,0 +1,66 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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); + +} diff --git a/sysdeps/guile/cpu.c b/sysdeps/guile/cpu.c new file mode 100644 index 00000000..707b4af7 --- /dev/null +++ b/sysdeps/guile/cpu.c @@ -0,0 +1,41 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM glibtop_guile_get_cpu (void) +{ + glibtop_cpu cpu; + + glibtop_get_cpu (&cpu); + + return gh_list (gh_ulong2scm (cpu.flags), + gh_ulong2scm (cpu.total), + gh_ulong2scm (cpu.user), + gh_ulong2scm (cpu.nice), + gh_ulong2scm (cpu.sys), + gh_ulong2scm (cpu.idle), + gh_ulong2scm (cpu.frequency), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/loadavg.c b/sysdeps/guile/loadavg.c new file mode 100644 index 00000000..1ace95ff --- /dev/null +++ b/sysdeps/guile/loadavg.c @@ -0,0 +1,38 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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); +} diff --git a/sysdeps/guile/mem.c b/sysdeps/guile/mem.c new file mode 100644 index 00000000..4b489579 --- /dev/null +++ b/sysdeps/guile/mem.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM glibtop_guile_get_mem (void) +{ + glibtop_mem mem; + + glibtop_get_mem (&mem); + + return gh_list (gh_ulong2scm (mem.flags), + gh_ulong2scm (mem.total), + gh_ulong2scm (mem.used), + gh_ulong2scm (mem.free), + gh_ulong2scm (mem.shared), + gh_ulong2scm (mem.buffer), + gh_ulong2scm (mem.cached), + gh_ulong2scm (mem.user), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/msg_limits.c b/sysdeps/guile/msg_limits.c new file mode 100644 index 00000000..35e88593 --- /dev/null +++ b/sysdeps/guile/msg_limits.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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); +} diff --git a/sysdeps/guile/names/.cvsignore b/sysdeps/guile/names/.cvsignore new file mode 100644 index 00000000..e5baa455 --- /dev/null +++ b/sysdeps/guile/names/.cvsignore @@ -0,0 +1,26 @@ +.deps +.libs +Makefile +Makefile.in +boot.lo +cpu.lo +libgtop_guile.la +libgtop_guile_names.la +loadavg.lo +mem.lo +msg_limits.lo +procdata.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +sem_limits.lo +shm_limits.lo +so_locations +swap.lo +sysdeps.lo +uptime.lo diff --git a/sysdeps/guile/names/Makefile.am b/sysdeps/guile/names/Makefile.am new file mode 100644 index 00000000..440bb955 --- /dev/null +++ b/sysdeps/guile/names/Makefile.am @@ -0,0 +1,16 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +DEFS = -DGLIBTOP_GUILE_NAMES @DEFS@ + +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 + diff --git a/sysdeps/guile/names/boot.c b/sysdeps/guile/names/boot.c new file mode 100644 index 00000000..ec96ac22 --- /dev/null +++ b/sysdeps/guile/names/boot.c @@ -0,0 +1,168 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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_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_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_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); +} diff --git a/sysdeps/guile/names/cpu.c b/sysdeps/guile/names/cpu.c new file mode 100644 index 00000000..ac08cb56 --- /dev/null +++ b/sysdeps/guile/names/cpu.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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; +} diff --git a/sysdeps/guile/names/loadavg.c b/sysdeps/guile/names/loadavg.c new file mode 100644 index 00000000..fe4b589d --- /dev/null +++ b/sysdeps/guile/names/loadavg.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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; +} diff --git a/sysdeps/guile/names/mem.c b/sysdeps/guile/names/mem.c new file mode 100644 index 00000000..afc4e7a9 --- /dev/null +++ b/sysdeps/guile/names/mem.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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; +} diff --git a/sysdeps/guile/names/msg_limits.c b/sysdeps/guile/names/msg_limits.c new file mode 100644 index 00000000..f978eabc --- /dev/null +++ b/sysdeps/guile/names/msg_limits.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +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; +} diff --git a/sysdeps/guile/names/prockernel.c b/sysdeps/guile/names/prockernel.c new file mode 100644 index 00000000..0de1d334 --- /dev/null +++ b/sysdeps/guile/names/prockernel.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_proc_kernel (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proc_kernel [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proc_kernel (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_types_proc_kernel [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proc_kernel (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proc_kernel [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proc_kernel (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proc_kernel [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/proclist.c b/sysdeps/guile/names/proclist.c new file mode 100644 index 00000000..34240142 --- /dev/null +++ b/sysdeps/guile/names/proclist.c @@ -0,0 +1,96 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include + +SCM +glibtop_guile_names_proclist (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proclist [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proclist (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_labels_proclist [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proclist (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proclist [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proclist (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proclist [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/procmem.c b/sysdeps/guile/names/procmem.c new file mode 100644 index 00000000..58ad25dd --- /dev/null +++ b/sysdeps/guile/names/procmem.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_proc_mem (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proc_mem [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proc_mem (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_labels_proc_mem [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proc_mem (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proc_mem [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proc_mem (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proc_mem [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/procsegment.c b/sysdeps/guile/names/procsegment.c new file mode 100644 index 00000000..7ed42171 --- /dev/null +++ b/sysdeps/guile/names/procsegment.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_proc_segment (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proc_segment [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proc_segment (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_types_proc_segment [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proc_segment (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proc_segment [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proc_segment (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proc_segment [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/procsignal.c b/sysdeps/guile/names/procsignal.c new file mode 100644 index 00000000..97df5373 --- /dev/null +++ b/sysdeps/guile/names/procsignal.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_proc_signal (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proc_signal [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proc_signal (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_types_proc_signal [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proc_signal (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proc_signal [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proc_signal (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proc_signal [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/procstate.c b/sysdeps/guile/names/procstate.c new file mode 100644 index 00000000..7ba88645 --- /dev/null +++ b/sysdeps/guile/names/procstate.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_proc_state (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proc_state [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proc_state (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_types_proc_state [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proc_state (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proc_state [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proc_state (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proc_state [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/proctime.c b/sysdeps/guile/names/proctime.c new file mode 100644 index 00000000..b0ad5e60 --- /dev/null +++ b/sysdeps/guile/names/proctime.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_proc_time (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proc_time [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proc_time (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_types_proc_time [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proc_time (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proc_time [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proc_time (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proc_time [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/procuid.c b/sysdeps/guile/names/procuid.c new file mode 100644 index 00000000..0746f8a8 --- /dev/null +++ b/sysdeps/guile/names/procuid.c @@ -0,0 +1,95 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_proc_uid (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_names_proc_uid [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_proc_uid (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (glibtop_types_proc_uid [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_proc_uid (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_labels_proc_uid [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_proc_uid (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) + list = gh_append2 + (list, gh_list + (gh_str02scm (gettext + (glibtop_descriptions_proc_uid [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/sem_limits.c b/sysdeps/guile/names/sem_limits.c new file mode 100644 index 00000000..397ddebd --- /dev/null +++ b/sysdeps/guile/names/sem_limits.c @@ -0,0 +1,85 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_sem_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_sem_limits [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_sem_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_sem_limits [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_sem_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_sem_limits [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_sem_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_sem_limits [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/shm_limits.c b/sysdeps/guile/names/shm_limits.c new file mode 100644 index 00000000..32ea693b --- /dev/null +++ b/sysdeps/guile/names/shm_limits.c @@ -0,0 +1,85 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_shm_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_shm_limits [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_shm_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_shm_limits [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_shm_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_shm_limits [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_shm_limits (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_shm_limits [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/swap.c b/sysdeps/guile/names/swap.c new file mode 100644 index 00000000..e5d477d4 --- /dev/null +++ b/sysdeps/guile/names/swap.c @@ -0,0 +1,84 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_swap (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SWAP; i++) + list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_swap [i]), SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_swap (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SWAP; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_swap [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_swap (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SWAP; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_swap [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_swap (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SWAP; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_swap [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/sysdeps.c b/sysdeps/guile/names/sysdeps.c new file mode 100644 index 00000000..20e4c184 --- /dev/null +++ b/sysdeps/guile/names/sysdeps.c @@ -0,0 +1,85 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_sysdeps (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_sysdeps [i]), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_sysdeps (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_sysdeps [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_sysdeps (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_sysdeps [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_sysdeps (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_sysdeps [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/names/uptime.c b/sysdeps/guile/names/uptime.c new file mode 100644 index 00000000..6bf65203 --- /dev/null +++ b/sysdeps/guile/names/uptime.c @@ -0,0 +1,84 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_names_uptime (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) + list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_uptime [i]), SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_types_uptime (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_uptime [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_labels_uptime (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_uptime [i])), + SCM_UNDEFINED)); + + return list; +} + +SCM +glibtop_guile_descriptions_uptime (void) +{ + int i; + SCM list; + + list = gh_list (SCM_UNDEFINED); + + for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) + list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_uptime [i])), + SCM_UNDEFINED)); + + return list; +} diff --git a/sysdeps/guile/prockernel.c b/sysdeps/guile/prockernel.c new file mode 100644 index 00000000..6702467c --- /dev/null +++ b/sysdeps/guile/prockernel.c @@ -0,0 +1,44 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_get_proc_kernel (SCM pid) +{ + glibtop_proc_kernel p; + + glibtop_get_proc_kernel (&p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_ulong2scm (p.flags), + gh_ulong2scm (p.k_flags), + gh_ulong2scm (p.min_flt), + gh_ulong2scm (p.maj_flt), + gh_ulong2scm (p.cmin_flt), + gh_ulong2scm (p.cmaj_flt), + gh_ulong2scm (p.kstk_esp), + gh_ulong2scm (p.kstk_eip), + gh_ulong2scm (p.wchan), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/proclist.c b/sysdeps/guile/proclist.c new file mode 100644 index 00000000..50fa0b0c --- /dev/null +++ b/sysdeps/guile/proclist.c @@ -0,0 +1,52 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include + +SCM +glibtop_guile_get_proclist (void) +{ + glibtop_proclist proclist; + unsigned *ptr; + unsigned i; + SCM list; + + ptr = glibtop_get_proclist (&proclist); + + list = gh_list (gh_ulong2scm (proclist.flags), + gh_ulong2scm (proclist.number), + gh_ulong2scm (proclist.size), + gh_ulong2scm (proclist.total), + SCM_UNDEFINED); + + if (ptr) { + for (i = 0; i < proclist.number; i++) + list = gh_append2 (list, gh_list (gh_ulong2scm ((unsigned long) ptr [i]), SCM_UNDEFINED)); + } + + glibtop_free (ptr); + + return list; +} diff --git a/sysdeps/guile/procmem.c b/sysdeps/guile/procmem.c new file mode 100644 index 00000000..e1862c3b --- /dev/null +++ b/sysdeps/guile/procmem.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_get_proc_mem (SCM pid) +{ + glibtop_proc_mem p; + + glibtop_get_proc_mem (&p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_ulong2scm (p.flags), + gh_long2scm (p.size), + gh_long2scm (p.vsize), + gh_long2scm (p.resident), + gh_long2scm (p.share), + gh_long2scm (p.rss), + gh_long2scm (p.rss_rlim), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/procsegment.c b/sysdeps/guile/procsegment.c new file mode 100644 index 00000000..dbc49915 --- /dev/null +++ b/sysdeps/guile/procsegment.c @@ -0,0 +1,43 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_get_proc_segment (SCM pid) +{ + glibtop_proc_segment p; + + glibtop_get_proc_segment (&p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_ulong2scm (p.flags), + gh_long2scm (p.trs), + gh_long2scm (p.lrs), + gh_long2scm (p.drs), + gh_long2scm (p.dt), + gh_ulong2scm (p.start_code), + gh_ulong2scm (p.end_code), + gh_ulong2scm (p.start_stack), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/procsignal.c b/sysdeps/guile/procsignal.c new file mode 100644 index 00000000..9b580c5b --- /dev/null +++ b/sysdeps/guile/procsignal.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_get_proc_signal (SCM pid) +{ + glibtop_proc_signal p; + + glibtop_get_proc_signal (&p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_ulong2scm (p.flags), + gh_long2scm (p.signal), + gh_long2scm (p.blocked), + gh_long2scm (p.sigignore), + gh_long2scm (p.sigcatch), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/procstate.c b/sysdeps/guile/procstate.c new file mode 100644 index 00000000..1b51f2ed --- /dev/null +++ b/sysdeps/guile/procstate.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_get_proc_state (SCM pid) +{ + glibtop_proc_state p; + + glibtop_get_proc_state (&p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_ulong2scm (p.flags), + gh_str02scm (p.cmd), + gh_char2scm (p.state), + gh_ulong2scm (p.uid), + gh_ulong2scm (p.gid), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/proctime.c b/sysdeps/guile/proctime.c new file mode 100644 index 00000000..52a6bfcd --- /dev/null +++ b/sysdeps/guile/proctime.c @@ -0,0 +1,43 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_get_proc_time (SCM pid) +{ + glibtop_proc_time p; + + glibtop_get_proc_time (&p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_ulong2scm (p.flags), + gh_long2scm (p.start_time), + gh_long2scm (p.utime), + gh_long2scm (p.stime), + gh_long2scm (p.cutime), + gh_long2scm (p.cstime), + gh_long2scm (p.timeout), + gh_long2scm (p.it_real_value), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/procuid.c b/sysdeps/guile/procuid.c new file mode 100644 index 00000000..96c7033c --- /dev/null +++ b/sysdeps/guile/procuid.c @@ -0,0 +1,48 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM +glibtop_guile_get_proc_uid (SCM pid) +{ + glibtop_proc_uid p; + + glibtop_get_proc_uid (&p, (pid_t) gh_scm2long (pid)); + + return gh_list (gh_ulong2scm (p.flags), + gh_long2scm (p.uid), + gh_long2scm (p.euid), + gh_long2scm (p.gid), + gh_long2scm (p.egid), + gh_long2scm (p.pid), + gh_long2scm (p.ppid), + gh_long2scm (p.pgrp), + gh_long2scm (p.session), + gh_long2scm (p.tty), + gh_long2scm (p.tpgid), + gh_long2scm (p.priority), + gh_long2scm (p.nice), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/sem_limits.c b/sysdeps/guile/sem_limits.c new file mode 100644 index 00000000..ca2b10af --- /dev/null +++ b/sysdeps/guile/sem_limits.c @@ -0,0 +1,45 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM glibtop_guile_get_sem_limits (void) +{ + glibtop_sem_limits sem_limits; + + glibtop_get_sem_limits (&sem_limits); + + return gh_list (gh_ulong2scm (sem_limits.flags), + gh_ulong2scm (sem_limits.semmap), + gh_ulong2scm (sem_limits.semmni), + gh_ulong2scm (sem_limits.semmns), + gh_ulong2scm (sem_limits.semmnu), + gh_ulong2scm (sem_limits.semmsl), + gh_ulong2scm (sem_limits.semopm), + gh_ulong2scm (sem_limits.semume), + gh_ulong2scm (sem_limits.semusz), + gh_ulong2scm (sem_limits.semvmx), + gh_ulong2scm (sem_limits.semaem), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/shm_limits.c b/sysdeps/guile/shm_limits.c new file mode 100644 index 00000000..e0efd174 --- /dev/null +++ b/sysdeps/guile/shm_limits.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM glibtop_guile_get_shm_limits (void) +{ + glibtop_shm_limits shm_limits; + + glibtop_get_shm_limits (&shm_limits); + + return gh_list (gh_ulong2scm (shm_limits.flags), + gh_ulong2scm (shm_limits.shmmax), + gh_ulong2scm (shm_limits.shmmin), + gh_ulong2scm (shm_limits.shmmni), + gh_ulong2scm (shm_limits.shmseg), + gh_ulong2scm (shm_limits.shmall), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/swap.c b/sysdeps/guile/swap.c new file mode 100644 index 00000000..4ab39ab8 --- /dev/null +++ b/sysdeps/guile/swap.c @@ -0,0 +1,38 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM glibtop_guile_get_swap (void) +{ + glibtop_swap swap; + + glibtop_get_swap (&swap); + + return gh_list (gh_ulong2scm (swap.flags), + gh_ulong2scm (swap.total), + gh_ulong2scm (swap.used), + gh_ulong2scm (swap.free), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/sysdeps.c b/sysdeps/guile/sysdeps.c new file mode 100644 index 00000000..90a4b04d --- /dev/null +++ b/sysdeps/guile/sysdeps.c @@ -0,0 +1,51 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM glibtop_guile_get_sysdeps (void) +{ + glibtop_sysdeps sysdeps; + + glibtop_get_sysdeps (&sysdeps); + + return gh_list (gh_ulong2scm (sysdeps.flags), + gh_ulong2scm (sysdeps.cpu), + gh_ulong2scm (sysdeps.mem), + gh_ulong2scm (sysdeps.swap), + gh_ulong2scm (sysdeps.uptime), + gh_ulong2scm (sysdeps.loadavg), + gh_ulong2scm (sysdeps.shm_limits), + gh_ulong2scm (sysdeps.msg_limits), + gh_ulong2scm (sysdeps.sem_limits), + gh_ulong2scm (sysdeps.proclist), + gh_ulong2scm (sysdeps.proc_state), + gh_ulong2scm (sysdeps.proc_uid), + gh_ulong2scm (sysdeps.proc_mem), + gh_ulong2scm (sysdeps.proc_time), + gh_ulong2scm (sysdeps.proc_signal), + gh_ulong2scm (sysdeps.proc_kernel), + gh_ulong2scm (sysdeps.proc_segment), + SCM_UNDEFINED); +} diff --git a/sysdeps/guile/uptime.c b/sysdeps/guile/uptime.c new file mode 100644 index 00000000..2425c751 --- /dev/null +++ b/sysdeps/guile/uptime.c @@ -0,0 +1,37 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +SCM glibtop_guile_get_uptime (void) +{ + glibtop_uptime uptime; + + glibtop_get_uptime (&uptime); + + return gh_list (gh_ulong2scm (uptime.flags), + gh_double2scm (uptime.uptime), + gh_double2scm (uptime.idletime), + SCM_UNDEFINED); +} diff --git a/sysdeps/linux/.cvsignore b/sysdeps/linux/.cvsignore new file mode 100644 index 00000000..b851d091 --- /dev/null +++ b/sysdeps/linux/.cvsignore @@ -0,0 +1,28 @@ +.deps +.libs +Makefile +Makefile.in +close.lo +cpu.lo +init.lo +ipc_limits.lo +libgtop_sysdeps.la +loadavg.lo +mem.lo +msg_limits.lo +open.lo +procdata.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +sem_limits.lo +shm_limits.lo +swap.lo +sysdeps.lo +sysinfo.lo +uptime.lo diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am new file mode 100644 index 00000000..10a1d6f4 --- /dev/null +++ b/sysdeps/linux/Makefile.am @@ -0,0 +1,13 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +lib_LTLIBRARIES = libgtop_sysdeps.la + +libgtop_sysdeps_la_SOURCES = init.c open.c close.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 diff --git a/sysdeps/linux/close.c b/sysdeps/linux/close.c new file mode 100644 index 00000000..ff7ebea4 --- /dev/null +++ b/sysdeps/linux/close.c @@ -0,0 +1,28 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Closes pipe to gtop server. */ + +void +glibtop_close (glibtop *server) +{ } diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c new file mode 100644 index 00000000..224ab06b --- /dev/null +++ b/sysdeps/linux/cpu.c @@ -0,0 +1,54 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_cpu = +(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) + +(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) + +(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY); + +/* Provides information about cpu usage. */ + +void +glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +{ + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_cpu)); + + buf->flags = _glibtop_sysdeps_cpu; + + f = fopen ("/proc/stat", "r"); + if (!f) return; + + fscanf (f, "cpu %lu %lu %lu %lu\n", + &buf->user, &buf->nice, &buf->sys, &buf->idle); + + buf->total = buf->user + buf->nice + buf->sys + buf->idle; + + buf->frequency = 100; + + fclose (f); +} diff --git a/sysdeps/linux/init.c b/sysdeps/linux/init.c new file mode 100644 index 00000000..f6a9a506 --- /dev/null +++ b/sysdeps/linux/init.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = NULL; + +glibtop * +glibtop_init__r (glibtop **server) +{ + if (*server != NULL) + return *server; + + if (glibtop_global_server == NULL) { + glibtop_global_server = &_glibtop_global_server; + glibtop_open (glibtop_global_server, "glibtop"); + } + + return *server = glibtop_global_server; +} diff --git a/sysdeps/linux/libsysdeps.la b/sysdeps/linux/libsysdeps.la new file mode 100644 index 00000000..3f600ebb --- /dev/null +++ b/sysdeps/linux/libsysdeps.la @@ -0,0 +1,19 @@ +# libsysdeps.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.0h + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='libsysdeps.so.0.0.0 libsysdeps.so.0 libsysdeps.so' + +# The name of the static archive. +old_library='libsysdeps.a' + +# Version information for libsysdeps. +current=0 +age=0 +revision=0 + +# Directory that this library needs to be installed in: +libdir='/usr/local/lib' diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c new file mode 100644 index 00000000..8401247c --- /dev/null +++ b/sysdeps/linux/loadavg.c @@ -0,0 +1,48 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_loadavg = +(1 << GLIBTOP_LOADAVG_LOADAVG); + +/* Provides load load averange. */ + +void +glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +{ + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_loadavg)); + + buf->flags = _glibtop_sysdeps_loadavg; + + f = fopen ("/proc/loadavg", "r"); + if (!f) return; + + fscanf (f, "%lf %lf %lf\n", + &buf->loadavg [0], &buf->loadavg [1], &buf->loadavg [2]); + + fclose (f); +} diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c new file mode 100644 index 00000000..80d2ccc3 --- /dev/null +++ b/sysdeps/linux/mem.c @@ -0,0 +1,53 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_mem = +(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) + +(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) + +(1 << GLIBTOP_MEM_BUFFER) + (1 << GLIBTOP_MEM_CACHED) + +(1 << GLIBTOP_MEM_USER); + +/* Provides information about memory usage. */ + +void +glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +{ + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_mem)); + + buf->flags = _glibtop_sysdeps_mem; + + f = fopen ("/proc/meminfo", "r"); + if (!f) return; + + fscanf (f, "%*[^\n]\nMem: %lu %lu %lu %lu %lu %lu\n", + &buf->total, &buf->used, &buf->free, &buf->shared, &buf->buffer, &buf->cached); + + buf->user = buf->total - buf->free - buf->shared - buf->buffer; + + fclose (f); +} diff --git a/sysdeps/linux/msg_limits.c b/sysdeps/linux/msg_limits.c new file mode 100644 index 00000000..997551af --- /dev/null +++ b/sysdeps/linux/msg_limits.c @@ -0,0 +1,55 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include + +static const unsigned long _glibtop_sysdeps_msg_limits = +(1 << GLIBTOP_IPC_MSGPOOL) + (1 << GLIBTOP_IPC_MSGMAP) + +(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNB) + +(1 << GLIBTOP_IPC_MSGMNI) + (1 << GLIBTOP_IPC_MSGSSZ) + +(1 << GLIBTOP_IPC_MSGTQL); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +{ + struct msginfo msginfo; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_msg_limits)); + + buf->flags = _glibtop_sysdeps_msg_limits; + + msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo); + + buf->msgpool = msginfo.msgpool; + buf->msgmap = msginfo.msgmap; + buf->msgmax = msginfo.msgmax; + buf->msgmnb = msginfo.msgmnb; + buf->msgmni = msginfo.msgmni; + buf->msgssz = msginfo.msgssz; + buf->msgtql = msginfo.msgtql; +} diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c new file mode 100644 index 00000000..b2da083a --- /dev/null +++ b/sysdeps/linux/open.c @@ -0,0 +1,61 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* ===================================================== + * Linux kernel version information for procps utilities + * Copyright (c) 1996 Charles Blake + */ +#include + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +static int linux_version_code = 0; + +static void set_linux_version(void) { + static struct utsname uts; + int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */ + + if (linux_version_code) return; + if (uname(&uts) == -1) /* failure most likely implies impending death */ + exit(1); + if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3) + fprintf(stderr, /* *very* unlikely to happen by accident */ + "Non-standard uts for running kernel:\n" + "release %s=%d.%d.%d gives version code %d\n", + uts.release, x, y, z, LINUX_VERSION(x,y,z)); + linux_version_code = LINUX_VERSION(x, y, z); +} + +/* ======================================================= */ + +/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ + +void +glibtop_open (glibtop *server, const char *program_name) +{ + memset (server, 0, sizeof (glibtop)); + server->name = program_name; + + set_linux_version (); + server->os_version_code = (unsigned long) linux_version_code; +} diff --git a/sysdeps/linux/procdata.c b/sysdeps/linux/procdata.c new file mode 100644 index 00000000..3fc01fb3 --- /dev/null +++ b/sysdeps/linux/procdata.c @@ -0,0 +1,178 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +#define BIT_SHIFT(x) (1 << (x % 32)) + +static const unsigned long _glibtop_sysdeps_procdata_0 = +BIT_SHIFT(GLIBTOP_PROCDATA_CMD) + +BIT_SHIFT(GLIBTOP_PROCDATA_STATE) + +BIT_SHIFT(GLIBTOP_PROCDATA_UID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PPID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) + +BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) + +BIT_SHIFT(GLIBTOP_PROCDATA_TTY) + +BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) + +BIT_SHIFT(GLIBTOP_PROCDATA_NICE) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) + +BIT_SHIFT(GLIBTOP_PROCDATA_BLOCKED) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_STIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIZE) + +BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) + +BIT_SHIFT(GLIBTOP_PROCDATA_SHARE) + +BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_LRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_DRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_DT) + +BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE) + +BIT_SHIFT(GLIBTOP_PROCDATA_RSS) + +BIT_SHIFT(GLIBTOP_PROCDATA_RSS_RLIM) + +BIT_SHIFT(GLIBTOP_PROCDATA_TIMEOUT) + +BIT_SHIFT(GLIBTOP_PROCDATA_IT_REAL_VALUE); + +static const unsigned long _glibtop_sysdeps_procdata_1 = +BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) + +BIT_SHIFT(GLIBTOP_PROCDATA_MIN_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_MAJ_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_CMIN_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_CMAJ_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) + +BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK) + +BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_ESP) + +BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_EIP) + +BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN); + +/* Provides detailed information about a process. */ + +void +glibtop_get_procdata__r (glibtop *server, glibtop_procdata *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + struct stat statb; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_procdata)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags [0] = _glibtop_sysdeps_procdata_0; + buf->flags [1] = _glibtop_sysdeps_procdata_1; + return; + } + + + sprintf (input, "/proc/%d/stat", pid); + + if (stat (input, &statb)) return; + + buf->uid = statb.st_uid; + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + memset (buf->cmd, 0, sizeof (buf->cmd)); + sscanf (input, "%d (%39c", &buf->pid, buf->cmd); + sscanf(tmp + 2, /* skip space after ')' too */ + "%c %d %d %d %d %d %lu %lu %lu %lu %lu " + "%ld %ld %ld %ld %d %d %lu %lu %ld %lu " + "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu", + &buf->state, &buf->ppid, &buf->pgrp, &buf->session, + &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt, + &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, + &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, + &buf->priority, &buf->nice, &buf->timeout, + &buf->it_real_value, &buf->start_time, &buf->vsize, + &buf->rss, &buf->rss_rlim, &buf->start_code, + &buf->end_code, &buf->start_stack, &buf->kstk_esp, + &buf->kstk_eip, &buf->signal, &buf->blocked, + &buf->sigignore, &buf->sigcatch, &buf->wchan); + + if (buf->tty == 0) + /* the old notty val, update elsewhere bef. moving to 0 */ + buf->tty = -1; + + if (server->os_version_code < LINUX_VERSION(1,3,39)) { + /* map old meanings to new */ + buf->priority = 2*15 - buf->priority; + buf->nice = 15 - buf->nice; + } + if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) + /* when tty wasn't full devno */ + buf->tty = 4*0x100 + buf->tty; + + fclose (f); + + sprintf (input, "/proc/%d/statm", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + sscanf (input, "%ld %ld %ld %ld %ld %ld %ld", + &buf->size, &buf->resident, &buf->share, + &buf->trs, &buf->lrs, &buf->drs, &buf->dt); + + fclose (f); + + buf->flags [0] = _glibtop_sysdeps_procdata_0; + buf->flags [1] = _glibtop_sysdeps_procdata_1; +} diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c new file mode 100644 index 00000000..0bd13c3f --- /dev/null +++ b/sysdeps/linux/prockernel.c @@ -0,0 +1,82 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_proc_kernel = +(1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_MIN_FLT) + +(1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) + +(1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_KSTK_ESP) + +(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1 << GLIBTOP_PROC_KERNEL_WCHAN); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proc_kernel)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_kernel; + return; + } + + sprintf (input, "/proc/%d/stat", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + + sscanf(tmp + 2, /* skip space after ')' too */ + "%*c %*d %*d %*d %*d %*d %lu %lu %lu %lu %lu " + "%*d %*d %*d %*d %*d %*d %*u %*u %*d %*u " + "%*u %*u %*u %*u %*u %lu %lu %*d %*d %*d %*d %lu", + &buf->k_flags, &buf->min_flt, &buf->cmin_flt, + &buf->maj_flt, &buf->cmaj_flt, &buf->kstk_esp, + &buf->kstk_eip, &buf->wchan); + + fclose (f); + + buf->flags = _glibtop_sysdeps_proc_kernel; +} diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c new file mode 100644 index 00000000..39070689 --- /dev/null +++ b/sysdeps/linux/proclist.c @@ -0,0 +1,155 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proclist = +(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) + +(1 << GLIBTOP_PROCLIST_SIZE); + +#define BLOCK_COUNT 256 +#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned)) + +/* Fetch list of currently running processes. + * + * The interface of this function is a little bit different from the others: + * buf->flags is only set if the call succeeded, in this case pids_chain, + * a list of the pids of all currently running processes is returned, + * buf->number is the number of elements of this list and buf->size is + * the size of one single element (sizeof (unsigned)). The total size is + * stored in buf->total. + * + * The calling function has to free the memory to which a pointer is returned. + * + * On error, NULL is returned and buf->flags is zero. */ + +unsigned * +glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +{ + DIR *proc; + struct dirent *entry; + char buffer [BUFSIZ]; + unsigned count, total, pid; + unsigned pids [BLOCK_COUNT], *pids_chain = NULL; + unsigned pids_size = 0, pids_offset = 0, new_size; + struct stat statb; + int len, i, ok; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proclist)); + + proc = opendir ("/proc"); + if (!proc) return NULL; + + /* read every every entry in /proc */ + + for (count = total = 0, entry = readdir (proc); entry; entry = readdir (proc)) { + ok = 1; len = strlen (entry->d_name); + + /* does it consist entirely of digits? */ + + for (i = 0; i < len; i++) + if (!isdigit (entry->d_name [i])) ok = 0; + if (!ok) continue; + + /* convert it in a number */ + + if (sscanf (entry->d_name, "%u", &pid) != 1) continue; + + /* is it really a directory? */ + + sprintf (buffer, "/proc/%d", pid); + + if (stat (buffer, &statb)) continue; + + if (!S_ISDIR (statb.st_mode)) continue; + + /* Fine. Now we first try to store it in pids. If this buffer is + * full, we copy it to the pids_chain. */ + + if (count >= BLOCK_COUNT) { + /* The following call to glibtop_realloc will be equivalent to + * glibtop_malloc if pids_chain is NULL. We just calculate the + * new size and copy pids to the beginning of the newly allocated + * block. */ + + new_size = pids_size + BLOCK_SIZE; + + pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + + memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE); + + pids_size = new_size; + + pids_offset += BLOCK_COUNT; + + count = 0; + } + + /* pids is now big enough to hold at least one single pid. */ + + pids [count++] = pid; + + total++; + } + + closedir (proc); + + /* count is only zero if an error occured (one a running Linux system, we + * only have at least one single process). */ + + if (!count) return NULL; + + /* The following call to glibtop_realloc will be equivalent to + * glibtop_malloc if pids_chain is NULL. We just calculate the + * new size and copy pids to the beginning of the newly allocated + * block. */ + + new_size = pids_size + count * sizeof (unsigned); + + pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + + memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); + + pids_size = new_size; + + pids_offset += BLOCK_COUNT; + + /* Since everything is ok now, we can set buf->flags, fill in the remaining fields + and return pids_chain. */ + + buf->flags = _glibtop_sysdeps_proclist; + + buf->size = sizeof (unsigned); + buf->number = total; + + buf->total = total * sizeof (unsigned); + + return pids_chain; +} diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c new file mode 100644 index 00000000..09a2fe83 --- /dev/null +++ b/sysdeps/linux/procmem.c @@ -0,0 +1,96 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_proc_mem = +(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_VSIZE) + +(1 << GLIBTOP_PROC_MEM_RESIDENT) + (1 << GLIBTOP_PROC_MEM_SHARE) + +(1 << GLIBTOP_PROC_MEM_RSS) + (1 << GLIBTOP_PROC_MEM_RSS_RLIM); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proc_mem)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_mem; + return; + } + + sprintf (input, "/proc/%d/stat", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + sscanf(tmp + 2, /* skip space after ')' too */ + "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " + "%*d %*d %*d %*d %*d %*d %*u %*u %*d %lu " + "%lu %lu", &buf->vsize, &buf->rss, &buf->rss_rlim); + + fclose (f); + + sprintf (input, "/proc/%d/statm", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + sscanf (input, "%ld %ld %ld", + &buf->size, &buf->resident, &buf->share); + + fclose (f); + + buf->flags = _glibtop_sysdeps_proc_mem; +} diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c new file mode 100644 index 00000000..479d98e4 --- /dev/null +++ b/sysdeps/linux/procsegment.c @@ -0,0 +1,99 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_proc_segment = +(1 << GLIBTOP_PROC_SEGMENT_TRS) + (1 << GLIBTOP_PROC_SEGMENT_LRS) + +(1 << GLIBTOP_PROC_SEGMENT_DRS) + (1 << GLIBTOP_PROC_SEGMENT_DT) + +(1 << GLIBTOP_PROC_SEGMENT_START_CODE) + (1 << GLIBTOP_PROC_SEGMENT_END_CODE) + +(1 << GLIBTOP_PROC_SEGMENT_START_STACK); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) +{ + char input [BUFSIZ], *tmp; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proc_segment)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_segment; + return; + } + + sprintf (input, "/proc/%d/stat", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + sscanf(tmp + 2, /* skip space after ')' too */ + "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " + "%*d %*d %*d %*d %*d %*d %*u %*u %*d %*u " + "%*u %*u %lu %lu %lu", &buf->start_code, + &buf->end_code, &buf->start_stack); + + fclose (f); + + sprintf (input, "/proc/%d/statm", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + sscanf (input, "%*d %*d %*d %ld %ld %ld %ld", + &buf->trs, &buf->lrs, &buf->drs, &buf->dt); + + fclose (f); + + buf->flags = _glibtop_sysdeps_proc_segment; +} diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c new file mode 100644 index 00000000..9bf32b26 --- /dev/null +++ b/sysdeps/linux/procsignal.c @@ -0,0 +1,78 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_proc_signal = +(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 << GLIBTOP_PROC_SIGNAL_BLOCKED) + +(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 << GLIBTOP_PROC_SIGNAL_SIGCATCH); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proc_signal)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_signal; + return; + } + + sprintf (input, "/proc/%d/stat", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + sscanf(tmp + 2, /* skip space after ')' too */ + "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " + "%*d %*d %*d %*d %*d %*d %*u %*u %*d %*u " + "%*u %*u %*u %*u %*u %*u %*u %d %d %d %d", + &buf->signal, &buf->blocked, &buf->sigignore, + &buf->sigcatch); + + fclose (f); + + buf->flags = _glibtop_sysdeps_proc_signal; +} diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c new file mode 100644 index 00000000..76252ba9 --- /dev/null +++ b/sysdeps/linux/procstate.c @@ -0,0 +1,88 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +static const unsigned long _glibtop_sysdeps_proc_state = +(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE) + +(1 << GLIBTOP_PROC_STATE_UID) + (1 << GLIBTOP_PROC_STATE_GID); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + struct stat statb; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proc_state)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_state; + return; + } + + sprintf (input, "/proc/%d/stat", pid); + + /* IMPORTANT NOTICE: For security reasons it is extremely important + * that the 'uid' and 'gid' fields have correct + * values; NEVER set their flags values if this + * is not the case !!! */ + + if (stat (input, &statb)) return; + + /* For security reasons we use stat () that is more failsafe than sscanf (). */ + + buf->uid = statb.st_uid; + buf->gid = statb.st_gid; + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + memset (buf->cmd, 0, sizeof (buf->cmd)); + sscanf (input, "%d (%39c", &pid, buf->cmd); + sscanf(tmp + 2, "%c", &buf->state); /* skip space after ')' too */ + + buf->flags = _glibtop_sysdeps_proc_state; +} diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c new file mode 100644 index 00000000..7c5dbc21 --- /dev/null +++ b/sysdeps/linux/proctime.c @@ -0,0 +1,79 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_proc_time = +(1 << GLIBTOP_PROC_TIME_START_TIME) + (1 << GLIBTOP_PROC_TIME_UTIME) + +(1 << GLIBTOP_PROC_TIME_STIME) + (1 << GLIBTOP_PROC_TIME_CUTIME) + +(1 << GLIBTOP_PROC_TIME_CSTIME) + (1 << GLIBTOP_PROC_TIME_TIMEOUT) + +(1 << GLIBTOP_PROC_TIME_IT_REAL_VALUE); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proc_time)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_time; + return; + } + + sprintf (input, "/proc/%d/stat", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + sscanf(tmp + 2, /* skip space after ')' too */ + "%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u " + "%ld %ld %ld %ld %*d %*d %lu %lu %ld", + &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, + &buf->timeout, &buf->it_real_value, &buf->start_time); + + fclose (f); + + buf->flags = _glibtop_sysdeps_proc_time; +} diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c new file mode 100644 index 00000000..d2ebddc3 --- /dev/null +++ b/sysdeps/linux/procuid.c @@ -0,0 +1,122 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_proc_uid = +(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) + +(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) + +(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) + +(1 << GLIBTOP_PROC_UID_PGRP) + (1 << GLIBTOP_PROC_UID_SESSION) + +(1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID) + +(1 << GLIBTOP_PROC_UID_PRIORITY) + (1 << GLIBTOP_PROC_UID_NICE); + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + int nread; + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_proc_uid)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_uid; + return; + } + + sprintf (input, "/proc/%d/status", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* Search substring 'Pid:' */ + + tmp = strstr (input, "Pid:"); + + if (tmp == NULL) return; + + sscanf (tmp, "\nPid: %u\nPPid: %u\nUid: %u %u %*u %*u\n" + "Gid: %u %u %*u %*u\n", &buf->pid, &buf->ppid, + &buf->uid, &buf->euid, &buf->gid, &buf->egid); + + fclose (f); + + sprintf (input, "/proc/%d/stat", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + sscanf(tmp + 2, /* skip space after ')' too */ + "%*c %*d %d %d %d %d %*u %*u %*u %*u %*u " + "%*d %*d %*d %*d %d %d", + &buf->pgrp, &buf->session, &buf->tty, &buf->tpgid, + &buf->priority, &buf->nice); + + if (buf->tty == 0) + /* the old notty val, update elsewhere bef. moving to 0 */ + buf->tty = -1; + + if (server->os_version_code < LINUX_VERSION(1,3,39)) { + /* map old meanings to new */ + buf->priority = 2*15 - buf->priority; + buf->nice = 15 - buf->nice; + } + if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) + /* when tty wasn't full devno */ + buf->tty = 4*0x100 + buf->tty; + + fclose (f); + + buf->flags = _glibtop_sysdeps_proc_uid; +} diff --git a/sysdeps/linux/sem_limits.c b/sysdeps/linux/sem_limits.c new file mode 100644 index 00000000..05d00a2d --- /dev/null +++ b/sysdeps/linux/sem_limits.c @@ -0,0 +1,61 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include + +static unsigned long _glibtop_sysdeps_sem_limits = +(1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) + +(1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) + +(1 << GLIBTOP_IPC_SEMMSL) + (1 << GLIBTOP_IPC_SEMOPM) + +(1 << GLIBTOP_IPC_SEMUME) + (1 << GLIBTOP_IPC_SEMUSZ) + +(1 << GLIBTOP_IPC_SEMVMX) + (1 << GLIBTOP_IPC_SEMAEM); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +{ + struct seminfo seminfo; + union semun arg; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_sem_limits)); + + buf->flags = _glibtop_sysdeps_sem_limits; + + arg.array = (ushort *) &seminfo; + semctl (0, 0, IPC_INFO, arg); + + buf->semmap = seminfo.semmap; + buf->semmni = seminfo.semmni; + buf->semmns = seminfo.semmns; + buf->semmnu = seminfo.semmnu; + buf->semmsl = seminfo.semmsl; + buf->semopm = seminfo.semopm; + buf->semume = seminfo.semume; + buf->semusz = seminfo.semusz; + buf->semvmx = seminfo.semvmx; + buf->semaem = seminfo.semaem; +} diff --git a/sysdeps/linux/shm_limits.c b/sysdeps/linux/shm_limits.c new file mode 100644 index 00000000..07a78bc7 --- /dev/null +++ b/sysdeps/linux/shm_limits.c @@ -0,0 +1,52 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include + +static unsigned long _glibtop_sysdeps_shm_limits = +(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) + +(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG) + +(1 << GLIBTOP_IPC_SHMALL); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +{ + struct shminfo shminfo; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_shm_limits)); + + buf->flags = _glibtop_sysdeps_shm_limits; + + shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo); + + buf->shmmax = shminfo.shmmax; + buf->shmmin = shminfo.shmmin; + buf->shmmni = shminfo.shmmni; + buf->shmseg = shminfo.shmseg; + buf->shmall = shminfo.shmall; +} diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c new file mode 100644 index 00000000..90572687 --- /dev/null +++ b/sysdeps/linux/swap.c @@ -0,0 +1,49 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static unsigned long _glibtop_sysdeps_swap = +(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) + +(1 << GLIBTOP_SWAP_FREE); + +/* Provides information about swap usage. */ + +void +glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +{ + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_swap)); + + buf->flags = _glibtop_sysdeps_swap; + + f = fopen ("/proc/meminfo", "r"); + if (!f) return; + + fscanf (f, "%*[^\n]\n%*[^\n]\nSwap: %lu %lu %lu\n", + &buf->total, &buf->used, &buf->free); + + fclose (f); +} diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c new file mode 100644 index 00000000..4dabf7be --- /dev/null +++ b/sysdeps/linux/uptime.c @@ -0,0 +1,47 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static unsigned long _glibtop_sysdeps_uptime = +(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME); + +/* Provides uptime and idle time. */ + +void +glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +{ + FILE *f; + + glibtop_init__r (&server); + + memset (buf, 0, sizeof (glibtop_uptime)); + + buf->flags = _glibtop_sysdeps_uptime; + + f = fopen ("/proc/uptime", "r"); + if (!f) return; + + fscanf (f, "%lf %lf\n", &buf->uptime, &buf->idletime); + + fclose (f); +} diff --git a/sysdeps/names/.cvsignore b/sysdeps/names/.cvsignore new file mode 100644 index 00000000..1f6ac7d5 --- /dev/null +++ b/sysdeps/names/.cvsignore @@ -0,0 +1,24 @@ +.deps +.libs +Makefile +Makefile.in +cpu.lo +libgtop_names.la +loadavg.lo +mem.lo +msg_limits.lo +procdata.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +sem_limits.lo +shm_limits.lo +so_locations +swap.lo +sysdeps.lo +uptime.lo diff --git a/sysdeps/names/Makefile.am b/sysdeps/names/Makefile.am new file mode 100644 index 00000000..3cdc9dab --- /dev/null +++ b/sysdeps/names/Makefile.am @@ -0,0 +1,16 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +DEFS = -DGLIBTOP_NAMES @DEFS@ + +lib_LTLIBRARIES = libgtop_names.la + +libgtop_names_la_SOURCES = cpu.c mem.c swap.c uptime.c loadavg.c \ + shm_limits.c msg_limits.c sem_limits.c \ + proclist.c sysdeps.c procstate.c procuid.c \ + proctime.c procmem.c procsignal.c prockernel.c \ + procsegment.c + diff --git a/sysdeps/names/cpu.c b/sysdeps/names/cpu.c new file mode 100644 index 00000000..e33c9f95 --- /dev/null +++ b/sysdeps/names/cpu.c @@ -0,0 +1,60 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_cpu [GLIBTOP_MAX_CPU] = +{ + "total", "user", "nice", "sys", "idle", "frequency" +}; + +const char *glibtop_types_cpu [GLIBTOP_MAX_CPU] = +{ + "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_cpu [GLIBTOP_MAX_CPU] = +{ + N_("Total CPU Time"), + N_("CPU Time in User Mode"), + N_("CPU Time in User Mode (nice)"), + N_("CPU Time in System Mode"), + N_("CPU Time in the Idle Task"), + N_("Tick Frequency") +}; + +const char *glibtop_descriptions_cpu [GLIBTOP_MAX_CPU] = +{ + N_("The number of jiffies (1/100ths of a second) since " + "system boot"), + N_("The number of jiffies (1/100ths of a second) that " + "the system spent in user mode"), + N_("The number of jiffies (1/100ths of a second) that " + "the system spent in user mode with low priority (nice)"), + N_("The number of jiffies (1/100ths of a second) that " + "the system spent in system mode"), + N_("The number of jiffies (1/100ths of a second) that " + "the system spend in the idle task"), + N_("All of the above values are in jiffies (1/100ths of " + "a second) unless otherwise stated in this field " + "(i.e. 'frequency != 100')") +}; diff --git a/sysdeps/names/loadavg.c b/sysdeps/names/loadavg.c new file mode 100644 index 00000000..4e41e621 --- /dev/null +++ b/sysdeps/names/loadavg.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_loadavg [GLIBTOP_MAX_LOADAVG] = +{ + "loadavg" +}; + +const char *glibtop_types_loadavg [GLIBTOP_MAX_LOADAVG] = +{ + "double" +}; + +const char *glibtop_labels_loadavg [GLIBTOP_MAX_LOADAVG] = +{ + N_("Load Average") +}; + +const char *glibtop_descriptions_loadavg [GLIBTOP_MAX_LOADAVG] = +{ + N_("Number of jobs running simultaneously averaged over 1, 5 and 15 minutes") +}; diff --git a/sysdeps/names/mem.c b/sysdeps/names/mem.c new file mode 100644 index 00000000..258ea38e --- /dev/null +++ b/sysdeps/names/mem.c @@ -0,0 +1,57 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_mem [GLIBTOP_MAX_MEM] = +{ + "total", "used", "free", "shared", "buffer", + "cached", "user" +}; + +const char *glibtop_types_mem [GLIBTOP_MAX_MEM] = +{ + "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long", + "unsigned long" +}; + +const char *glibtop_labels_mem [GLIBTOP_MAX_MEM] = +{ + N_("Total Memory"), + N_("Used Memory"), + N_("Free Memory"), + N_("Shared Memory"), + N_("Buffers"), + N_("Cached"), + N_("User") +}; + +const char *glibtop_descriptions_mem [GLIBTOP_MAX_MEM] = +{ + N_("Total physical memory in kB"), + N_("Used memory size in kB"), + N_("Free memory size in kB"), + N_("Shared memory size in kB"), + N_("Size of buffers kB"), + N_("Size of cached memory in kB"), + N_("Memory used from user processes in kB") +}; diff --git a/sysdeps/names/msg_limits.c b/sysdeps/names/msg_limits.c new file mode 100644 index 00000000..46dbf7e8 --- /dev/null +++ b/sysdeps/names/msg_limits.c @@ -0,0 +1,55 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = +{ + "msgpool", "msgmap", "msgmax", "msgmnb", "msgmni", "msgssz", "msgtql" +}; + +const char *glibtop_types_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = +{ + "unsigned long", "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = +{ + N_("Size in kilobytes of message pool"), + N_("Number of entries in message map"), + N_("Max size of message"), + N_("Default max size of queue"), + N_("Max queues system wide"), + N_("Message segment size"), + N_("Number of system message headers") +}; + +const char *glibtop_descriptions_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = +{ + N_("Size in kilobytes of message pool"), + N_("Number of entries in message map"), + N_("Max size of message"), + N_("Default max size of queue"), + N_("Max queues system wide"), + N_("Message segment size"), + N_("Number of system message headers") +}; diff --git a/sysdeps/names/procdata.c b/sysdeps/names/procdata.c new file mode 100644 index 00000000..1729860c --- /dev/null +++ b/sysdeps/names/procdata.c @@ -0,0 +1,53 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_procdata [GLIBTOP_MAX_PROCDATA] = +{ "cmd", "state", "uid", "pid", "ppid", "pgrp", "session", + "tty", "tpgid", "priority", "nice", "signal", "blocked", + "sigignore", "sigcatch", "start_time", "utime", "stime", + "cutime", "cstime", "size", "resident", "share", "trs", + "lrs", "drs", "dt", "vsize", "rss", "rss_rlim", "timeout", + "it_real_value", "k_flags", "min_flt", "maj_flt", "cmin_flt", + "cmaj_flt", "start_code", "end_code", "start_stack", + "kstk_esp", "kstk_eip", "wchan" +}; + +const char *glibtop_labels_procdata [GLIBTOP_MAX_PROCDATA] = +{ N_("Cmd"), N_("Stat"), N_("UID"), N_("PID"), N_("PPID"), N_("PGRP"), + N_("Session"), N_("Tty"), N_("TPGID"), N_("Priority"), N_("Nice"), + N_("Signal"), N_("Blocked"), N_("SigIgnore"), N_("SigCatch"), + N_("Start_Time"), N_("UTime"), N_("STime"), N_("CUTime"), N_("CSTime"), + N_("Size"), N_("Resident"), N_("Share"), N_("TRS"), N_("LRS"), N_("DRS"), + N_("DT"), N_("VSize"), N_("RSS"), N_("RSS_RLim"), N_("Timeout"), + N_("It_Real_Value"), N_("Flags"), N_("Min_Flt"), N_("Maj_Flt"), + N_("CMin_Flt"), N_("Cmaj_Flt"), N_("Start_Code"), N_("End_Code"), + N_("Start_Stack"), N_("KSTK_ESP"), N_("KSTK_EIP"), N_("WChan") +}; + +const char *glibtop_descriptions_procdata [GLIBTOP_MAX_PROCDATA] = +{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL +}; diff --git a/sysdeps/names/prockernel.c b/sysdeps/names/prockernel.c new file mode 100644 index 00000000..20f4a87b --- /dev/null +++ b/sysdeps/names/prockernel.c @@ -0,0 +1,76 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +const char *glibtop_names_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = +{ + "k_flags", "min_flt", "maj_flt", "cmin_flt", "cmaj_flt", + "kstk_esp", "kstk_eip", "wchan" +}; + +const char *glibtop_types_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = +{ + "unsigned long", "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = +{ + N_("K_Flags"), N_("Min_Flt"), N_("Maj_Flt"), N_("CMin_Flt"), + N_("CMaj_Flt"), N_("KStk_ESP"), N_("KStk_EIP"), N_("WChan") +}; + +const char *glibtop_descriptions_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = +{ + /* K_Flags */ + N_("Kernel flags of the process.\n\n" + "On Linux, currently every flag has the math bit set, because " + "crt0.s checks for math emulation, so this is not included in " + "the output.\n\n" + "This is probably a bug, as not every process is a compiled C " + "program.\n\n" + "The math bit should be a decimal 4, and the traced bit is " + "decimal 10."), + /* Min_Flt */ + N_("The number of minor faults the process has made, those which " + "have not required loading a memory page from disk."), + /* Maj_Flt */ + N_("The number of major faults the process has made, those which " + "have required loading a memory page from disk."), + /* CMin_Flt */ + N_("The number of minor faults that the process and its children " + "have made."), + /* CMaj_Flt */ + N_("The number of major faults that the process and its children " + "have made."), + /* KStk_ESP */ + N_("The current value of esp (32-bit stack pointer), as found in " + "the kernel stack page for the process."), + /* KStk_EIP */ + N_("The current EIP (32-bit instruction pointer)."), + /* WChan */ + N_("This is the \"channel\" in which the process is waiting. This " + "is the address of a system call, and can be looked up in a " + "namelist if you need a textual name. (If you have an up-to-date " + "/etc/psdatabase, then try ps -l to see the WCHAN field in action)") +}; diff --git a/sysdeps/names/proclist.c b/sysdeps/names/proclist.c new file mode 100644 index 00000000..d5bf022d --- /dev/null +++ b/sysdeps/names/proclist.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_proclist [GLIBTOP_MAX_PROCLIST] = +{ + "number", "total", "size" +}; + +const char *glibtop_types_proclist [GLIBTOP_MAX_PROCLIST] = +{ + "unsigned long", "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_proclist [GLIBTOP_MAX_PROCLIST] = +{ + N_("Number of list elements"), + N_("Total size of list"), + N_("Size of a single list element") +}; + +const char *glibtop_descriptions_proclist [GLIBTOP_MAX_PROCLIST] = +{ + N_("Number of list elements"), + N_("Total size of list"), + N_("Size of a single list element") +}; diff --git a/sysdeps/names/procmem.c b/sysdeps/names/procmem.c new file mode 100644 index 00000000..920f1a8b --- /dev/null +++ b/sysdeps/names/procmem.c @@ -0,0 +1,61 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#define GLIBTOP_PROC_MEM_SIZE 0 +#define GLIBTOP_PROC_MEM_VSIZE 1 +#define GLIBTOP_PROC_MEM_RESIDENT 2 +#define GLIBTOP_PROC_MEM_SHARE 3 +#define GLIBTOP_PROC_MEM_RSS 4 +#define GLIBTOP_PROC_MEM_RSS_RLIM 5 + +const char *glibtop_names_proc_mem [GLIBTOP_MAX_PROC_MEM] = +{ + "size", "vsize", "resident", "share", "rss", "rss_rlim" +}; + +const char *glibtop_types_proc_mem [GLIBTOP_MAX_PROC_MEM] = +{ + "long", "long", "long", "long", "long", "long" +}; + +const char *glibtop_labels_proc_mem [GLIBTOP_MAX_PROC_MEM] = +{ + N_("Size"), N_("Virtual"), N_("Resident"), N_("Share"), + N_("Resident Set Size"), N_("Resident Set Size Limit") +}; + +const char *glibtop_descriptions_proc_mem [GLIBTOP_MAX_PROC_MEM] = +{ + N_("Total # of pages of memory"), + N_("Number of pages of virtual memory"), + N_("Number of residnet set (non-swapped) pages"), + N_("Number of pages of shared (mmap'd) memory"), + N_("Number of pages the process has in real memory, minus 3 " + "for administrative purposes. This is just the pages which " + "count towards text, data, or stack space. This does not " + "include pages which have not been demand-loaded in, or which " + "are swapped out."), + N_("Current limit in bytes on the rss of the process " + "(usually 2,147,483,647).") +}; diff --git a/sysdeps/names/procsegment.c b/sysdeps/names/procsegment.c new file mode 100644 index 00000000..85a89304 --- /dev/null +++ b/sysdeps/names/procsegment.c @@ -0,0 +1,51 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +const char *glibtop_names_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = +{ + "trs", "lrs", "drs", "dt", "start_code", "end_code", "start_stack" +}; + +const char *glibtop_types_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = +{ + "long", "long", "long", "long", "unsigned long", + "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = +{ + N_("TRS"), N_("LRS"), N_("DRS"), N_("DT"), N_("Start_Code"), + N_("End_Code"), N_("Start_Stack") +}; + +const char *glibtop_descriptions_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = +{ + N_("Text resident set size"), + N_("Shared-Lib resident set size"), + N_("Data resident set size"), + N_("Dirty pages"), + N_("Address of beginning of code segment"), + N_("Address of end of code segment"), + N_("Address of the bottom of stack segment") +}; diff --git a/sysdeps/names/procsignal.c b/sysdeps/names/procsignal.c new file mode 100644 index 00000000..a278e60b --- /dev/null +++ b/sysdeps/names/procsignal.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +const char *glibtop_names_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = +{ + "signal", "blocked", "sigignore", "sigcatch" +}; + +const char *glibtop_types_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = +{ + "int", "int", "int", "int" +}; + +const char *glibtop_labels_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = +{ + N_("Signal"), N_("Blocked"), N_("SigIgnore"), N_("SigCatch") +}; + +const char *glibtop_descriptions_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = +{ + N_("Mask of pending signals"), + N_("Mask of blocked signals"), + N_("Mask of ignored signals"), + N_("Mask of caught signals") +}; diff --git a/sysdeps/names/procstate.c b/sysdeps/names/procstate.c new file mode 100644 index 00000000..bdd85499 --- /dev/null +++ b/sysdeps/names/procstate.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +const char *glibtop_names_proc_state [GLIBTOP_MAX_PROC_STATE] = +{ + "cmd", "state", "uid", "gid" +}; + +const char *glibtop_types_proc_state [GLIBTOP_MAX_PROC_STATE] = +{ + "char *", "char", "int", "int" +}; + +const char *glibtop_labels_proc_state [GLIBTOP_MAX_PROC_STATE] = +{ + N_("Cmd"), N_("State"), N_("UID"), N_("GID") +}; + +const char *glibtop_descriptions_proc_state [GLIBTOP_MAX_PROC_STATE] = +{ + N_("Basename of executable file in call to exec()"), + N_("Single-Char code for process state (S=sleeping)"), + N_("UID of process"), + N_("GID of process") +}; diff --git a/sysdeps/names/proctime.c b/sysdeps/names/proctime.c new file mode 100644 index 00000000..f7990b50 --- /dev/null +++ b/sysdeps/names/proctime.c @@ -0,0 +1,62 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#define GLIBTOP_PROC_TIME_START_TIME 0 +#define GLIBTOP_PROC_TIME_UTIME 1 +#define GLIBTOP_PROC_TIME_STIME 2 +#define GLIBTOP_PROC_TIME_CUTIME 3 +#define GLIBTOP_PROC_TIME_CSTIME 4 +#define GLIBTOP_PROC_TIME_TIMEOUT 5 +#define GLIBTOP_PROC_TIME_IT_REAL_VALUE 6 + +const char *glibtop_names_proc_time [GLIBTOP_MAX_PROC_TIME] = +{ + "start_time", "utime", "stime", "cutime", "cstime", + "timeout", "it_real_value" +}; + +const char *glibtop_types_proc_time [GLIBTOP_MAX_PROC_TIME] = +{ + "long", "long", "long", "long", "long", "long", "long" +}; + +const char *glibtop_labels_proc_time [GLIBTOP_MAX_PROC_TIME] = +{ + N_("Start_Time"), N_("UTime"), N_("STime"), N_("CUTime"), + N_("CSTime"), N_("TimeOut"), N_("It_Real_Value") +}; + +const char *glibtop_descriptions_proc_time [GLIBTOP_MAX_PROC_TIME] = +{ + N_("Start time of process in seconds since the epoch"), + N_("user-mode CPU time accumulated by process"), + N_("kernel-mode CPU time accumulated by process"), + N_("cumulative utime of process and reaped children"), + N_("cumulative stime of process and reaped children"), + N_("The time (in jiffies) of the process's next timeout"), + N_("The time (in jiffies) before the next SIGALRM is sent " + "to the process due to an interval timer.") +}; + + diff --git a/sysdeps/names/procuid.c b/sysdeps/names/procuid.c new file mode 100644 index 00000000..8d50f8bc --- /dev/null +++ b/sysdeps/names/procuid.c @@ -0,0 +1,71 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#define GLIBTOP_PROC_UID_UID 0 +#define GLIBTOP_PROC_UID_EUID 1 +#define GLIBTOP_PROC_UID_GID 2 +#define GLIBTOP_PROC_UID_EGID 3 +#define GLIBTOP_PROC_UID_PID 4 +#define GLIBTOP_PROC_UID_PPID 5 +#define GLIBTOP_PROC_UID_PGRP 6 +#define GLIBTOP_PROC_UID_SESSION 7 +#define GLIBTOP_PROC_UID_TTY 8 +#define GLIBTOP_PROC_UID_TPGID 9 +#define GLIBTOP_PROC_UID_PRIORITY 10 +#define GLIBTOP_PROC_UID_NICE 11 + +const char *glibtop_names_proc_uid [GLIBTOP_MAX_PROC_UID] = +{ + "uid", "euid", "gid", "egid", "pid", "ppid", "pgrp", + "session", "tty", "tpgid", "priority", "nice" +}; + +const char *glibtop_types_proc_uid [GLIBTOP_MAX_PROC_UID] = +{ + "int", "int", "int", "int", "int", "int", "int", + "int", "int", "int", "int", "int" +}; + +const char *glibtop_labels_proc_uid [GLIBTOP_MAX_PROC_UID] = +{ + N_("Uid"), N_("EUid"), N_("Gid"), N_("EGid"), N_("Pid"), + N_("PPid"), N_("PGrp"), N_("Session"), N_("Tty"), + N_("TPGid"), N_("Priority"), N_("Nice") +}; + +const char *glibtop_descriptions_proc_uid [GLIBTOP_MAX_PROC_UID] = +{ + N_("User ID"), + N_("Effective User ID"), + N_("Group ID"), + N_("Effective Group ID"), + N_("Process ID"), + N_("PID of parent process"), + N_("Process group ID"), + N_("Session ID"), + N_("Full device number of controlling terminal"), + N_("Terminal process group ID"), + N_("Kernel scheduling priority"), + N_("Standard unix nice level of process") +}; diff --git a/sysdeps/names/sem_limits.c b/sysdeps/names/sem_limits.c new file mode 100644 index 00000000..a75d9192 --- /dev/null +++ b/sysdeps/names/sem_limits.c @@ -0,0 +1,63 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = +{ + "semmap", "semmni", "semmns", "semmnu", "semmsl", + "semopm", "semume", "semusz", "semvmx", "semaem" +}; + +const char *glibtop_types_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = +{ + "unsigned long", "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = +{ + N_("Number of entries in semaphore map"), + N_("Max number of arrays"), + N_("Max semaphores system wide"), + N_("Number of undo structures system wide"), + N_("Max semaphores per array"), + N_("Max ops per semop call"), + N_("Max number of undo entries per process"), + N_("sizeof struct sem_undo"), + N_("Semaphore max value"), + N_("Adjust on exit max value") +}; + +const char *glibtop_descriptions_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = +{ + N_("Number of entries in semaphore map"), + N_("Max number of arrays"), + N_("Max semaphores system wide"), + N_("Number of undo structures system wide"), + N_("Max semaphores per array"), + N_("Max ops per semop call"), + N_("Max number of undo entries per process"), + N_("sizeof struct sem_undo"), + N_("Semaphore max value"), + N_("Adjust on exit max value") +}; diff --git a/sysdeps/names/shm_limits.c b/sysdeps/names/shm_limits.c new file mode 100644 index 00000000..6786d2dc --- /dev/null +++ b/sysdeps/names/shm_limits.c @@ -0,0 +1,51 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = +{ + "shmmax", "shmmin", "shmmni", "shmseg", "shmall" +}; + +const char *glibtop_types_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = +{ + "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = +{ + N_("Max segment size"), + N_("Min segment size"), + N_("Max number of segments"), + N_("Max shared segments per process"), + N_("Max total shared memory") +}; + +const char *glibtop_descriptions_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = +{ + N_("Max segment size"), + N_("Min segment size"), + N_("Max number of segments"), + N_("Max shared segments per process"), + N_("Max total shared memory") +}; diff --git a/sysdeps/names/swap.c b/sysdeps/names/swap.c new file mode 100644 index 00000000..06c51513 --- /dev/null +++ b/sysdeps/names/swap.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_swap [GLIBTOP_MAX_SWAP] = +{ + "total", "used", "free" +}; + +const char *glibtop_types_swap [GLIBTOP_MAX_SWAP] = +{ + "unsigned long", "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_swap [GLIBTOP_MAX_SWAP] = +{ + N_("Total Swap Space"), + N_("Used Swap Space"), + N_("Free Swap Space") +}; + +const char *glibtop_descriptions_swap [GLIBTOP_MAX_SWAP] = +{ + N_("Total Swap Space"), + N_("Used Swap Space"), + N_("Free Swap Space") +}; diff --git a/sysdeps/names/sysdeps.c b/sysdeps/names/sysdeps.c new file mode 100644 index 00000000..3387efd0 --- /dev/null +++ b/sysdeps/names/sysdeps.c @@ -0,0 +1,78 @@ +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +const char *glibtop_names_sysdeps [GLIBTOP_MAX_SYSDEPS] = +{ + "cpu", "mem", "swap", "uptime", "loadavg", "shm_limits", + "msg_limits", "sem_limits", "proclist", "proc_state", + "proc_uid", "proc_mem", "proc_time", "proc_signal", + "proc_kernel", "proc_segment" +}; + +const char *glibtop_types_sysdeps [GLIBTOP_MAX_SYSDEPS] = +{ + "unsigned long", "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long", "unsigned long", + "unsigned long", "unsigned long", "unsigned long", "unsigned long" +}; + +const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] = +{ + N_("CPU Usage"), + N_("Memory Usage"), + N_("Swap Usage"), + N_("System Uptime"), + N_("Load Averange"), + N_("Shared Memory Limits"), + N_("Message Queue Limits"), + N_("Semaphore Set Limits"), + N_("List of running Processes"), + N_("Process Status information"), + N_("Process UID and TTY information"), + N_("Process Memory information"), + N_("Process Time information"), + N_("Process Signal information"), + N_("Process Kernel Data information"), + N_("Process Segment information") +}; + +const char *glibtop_descriptions_sysdeps [GLIBTOP_MAX_SYSDEPS] = +{ + N_("CPU Usage"), + N_("Memory Usage"), + N_("Swap Usage"), + N_("System Uptime"), + N_("Load Averange"), + N_("Shared Memory Limits"), + N_("Message Queue Limits"), + N_("Semaphore Set Limits"), + N_("List of running Processes"), + N_("Process Status information"), + N_("Process UID and TTY information"), + N_("Process Memory information"), + N_("Process Time information"), + N_("Process Signal information"), + N_("Process Kernel Data information"), + N_("Process Segment information") +}; diff --git a/sysdeps/names/uptime.c b/sysdeps/names/uptime.c new file mode 100644 index 00000000..6561c006 --- /dev/null +++ b/sysdeps/names/uptime.c @@ -0,0 +1,44 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +const char *glibtop_names_uptime [GLIBTOP_MAX_UPTIME] = +{ + "uptime", "idletime" +}; + +const char *glibtop_types_uptime [GLIBTOP_MAX_UPTIME] = +{ + "double", "double" +}; + +const char *glibtop_labels_uptime [GLIBTOP_MAX_UPTIME] = +{ + N_("Uptime"), + N_("Idletime") +}; + +const char *glibtop_descriptions_uptime [GLIBTOP_MAX_UPTIME] = +{ + N_("Time in seconds since system boot"), + N_("Time in seconds the system spent in the idle task since system boot") +}; diff --git a/sysdeps/osf1/.cvsignore b/sysdeps/osf1/.cvsignore new file mode 100644 index 00000000..33eef0e1 --- /dev/null +++ b/sysdeps/osf1/.cvsignore @@ -0,0 +1,21 @@ +.deps +.libs +Makefile +Makefile.in +close.lo +cpu.lo +libgtop_sysdeps.la +libsysdeps.la +loadavg.c +loadavg.lo +mem.lo +msg_limits.lo +open.lo +proclist.lo +sem_limits.lo +shm_limits.lo +swap.lo +sysdeps.lo +uptime.c +uptime.lo +so_locations diff --git a/sysdeps/osf1/Makefile.am b/sysdeps/osf1/Makefile.am new file mode 100644 index 00000000..30765601 --- /dev/null +++ b/sysdeps/osf1/Makefile.am @@ -0,0 +1,15 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +lib_LTLIBRARIES = libgtop_sysdeps.la + + +libgtop_sysdeps_la_SOURCES = init.c open.c close.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_sysdeps_la_LIBADD = -lmach diff --git a/sysdeps/osf1/close.c b/sysdeps/osf1/close.c new file mode 100644 index 00000000..ff7ebea4 --- /dev/null +++ b/sysdeps/osf1/close.c @@ -0,0 +1,28 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Closes pipe to gtop server. */ + +void +glibtop_close (glibtop *server) +{ } diff --git a/sysdeps/osf1/cpu.c b/sysdeps/osf1/cpu.c new file mode 100644 index 00000000..cf5245d6 --- /dev/null +++ b/sysdeps/osf1/cpu.c @@ -0,0 +1,59 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +static const unsigned long _glibtop_sysdeps_cpu = +(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) + +(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) + +(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY); + +/* Provides information about cpu usage. */ + +void +glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +{ + struct tbl_sysinfo sysinfo; + int ret; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_cpu)); + + ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1, + sizeof (struct tbl_sysinfo)); + + if (ret != 1) return; + + buf->flags = _glibtop_sysdeps_cpu; + + buf->user = sysinfo.si_user; + buf->nice = sysinfo.si_nice; + buf->sys = sysinfo.si_sys; + buf->idle = sysinfo.si_idle; + + buf->total = sysinfo.si_user + sysinfo.si_nice + + sysinfo.si_sys + sysinfo.si_idle; + + buf->frequency = sysinfo.si_hz; +} diff --git a/sysdeps/osf1/glibtop_machine.h b/sysdeps/osf1/glibtop_machine.h new file mode 100644 index 00000000..12c28c60 --- /dev/null +++ b/sysdeps/osf1/glibtop_machine.h @@ -0,0 +1,48 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_MACHINE_H__ +#define __GLIBTOP_MACHINE_H__ + +#include + +/* The following are defined in . */ + +#undef sys +#undef user +#undef idle + +__BEGIN_DECLS + +extern int table __P((int id, int index, char *addr, int nel, u_int lel)); + +typedef struct _glibtop_machine glibtop_machine; + +struct _glibtop_machine +{ + uid_t uid, euid; /* Real and effective user id */ + gid_t gid, egid; /* Real and effective group id */ + unsigned proctable_entries; /* Max entries in the proctable */ +}; + +__END_DECLS + +#endif diff --git a/sysdeps/osf1/init.c b/sysdeps/osf1/init.c new file mode 100644 index 00000000..f6a9a506 --- /dev/null +++ b/sysdeps/osf1/init.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = NULL; + +glibtop * +glibtop_init__r (glibtop **server) +{ + if (*server != NULL) + return *server; + + if (glibtop_global_server == NULL) { + glibtop_global_server = &_glibtop_global_server; + glibtop_open (glibtop_global_server, "glibtop"); + } + + return *server = glibtop_global_server; +} diff --git a/sysdeps/osf1/mem.c b/sysdeps/osf1/mem.c new file mode 100644 index 00000000..bd4d6306 --- /dev/null +++ b/sysdeps/osf1/mem.c @@ -0,0 +1,59 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_mem = +(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) + +(1 << GLIBTOP_MEM_FREE); + +/* Provides information about memory usage. */ + +void +glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +{ + vm_statistics_data_t vmstats; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_mem)); + + buf->flags = _glibtop_sysdeps_mem; + + (void) vm_statistics(task_self(), &vmstats); + + buf->free = vmstats.free_count * vmstats.pagesize; + buf->used = vmstats.active_count * vmstats.pagesize; + + /* [FIXME]: Is this correct? */ + + buf->total = (vmstats.active_count + vmstats.inactive_count + + vmstats.free_count + vmstats.wire_count) * + vmstats.pagesize; +} diff --git a/sysdeps/osf1/msg_limits.c b/sysdeps/osf1/msg_limits.c new file mode 100644 index 00000000..98993716 --- /dev/null +++ b/sysdeps/osf1/msg_limits.c @@ -0,0 +1,77 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +static const unsigned long _glibtop_sysdeps_msg_limits = +(1 << GLIBTOP_IPC_MSGMAP) + (1 << GLIBTOP_IPC_MSGMAX) + +(1 << GLIBTOP_IPC_MSGMNB) + (1 << GLIBTOP_IPC_MSGMNI) + +(1 << GLIBTOP_IPC_MSGTQL); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +{ + int ret, value; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_msg_limits)); + + ret = table (TBL_MSGINFO, MSGINFO_MAX, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_MSGMAX); + + buf->msgmax = value; + + ret = table (TBL_MSGINFO, MSGINFO_MNB, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_MSGMNB); + + buf->msgmnb = value; + + ret = table (TBL_MSGINFO, MSGINFO_MNI, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_MSGMNI); + + buf->msgmni = value; + + ret = table (TBL_MSGINFO, MSGINFO_TQL, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_MSGTQL); + + buf->msgtql = value; +} diff --git a/sysdeps/osf1/open.c b/sysdeps/osf1/open.c new file mode 100644 index 00000000..540e499b --- /dev/null +++ b/sysdeps/osf1/open.c @@ -0,0 +1,64 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include + +/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ + +/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + +void +glibtop_open (glibtop *server, const char *program_name) +{ + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ + + memset (server, 0, sizeof (glibtop)); + server->name = program_name; + + server->machine.uid = getuid (); + server->machine.euid = geteuid (); + server->machine.gid = getgid (); + server->machine.egid = getegid (); + + server->machine.proctable_entries = table (TBL_PROCINFO, 0, NULL, INT_MAX, 0); + + /* Drop priviledges; we only become root when necessary. + + setreuid (ruid, euid) - set real and effective user id; + setregid (rgid, egid) - set real and effective group id; + + */ + + if (setreuid (server->machine.euid, server->machine.uid)) + _exit (1); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + /* Our effective uid is now those of the user invoking the server, + so we do no longer have any priviledges. + */ +} diff --git a/sysdeps/osf1/procdata.c b/sysdeps/osf1/procdata.c new file mode 100644 index 00000000..4eb64d88 --- /dev/null +++ b/sysdeps/osf1/procdata.c @@ -0,0 +1,148 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include +#include +#include + +#include +#include +#include + +/* Provides detailed information about a process. */ + +#define BIT_SHIFT(x) (1 << (x % 32)) + +static const unsigned long _glibtop_sysdeps_procdata_0 = +BIT_SHIFT(GLIBTOP_PROCDATA_CMD) + +BIT_SHIFT(GLIBTOP_PROCDATA_STATE) + +BIT_SHIFT(GLIBTOP_PROCDATA_UID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PPID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) + +BIT_SHIFT(GLIBTOP_PROCDATA_TTY) + +BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) + +BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) + +BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) + +BIT_SHIFT(GLIBTOP_PROCDATA_NICE); + +static const unsigned long _glibtop_sysdeps_procdata_1 = 0; + +void +glibtop_get_procdata__r (glibtop *server, glibtop_procdata *buf, pid_t pid) +{ + struct tbl_procinfo procinfo; + task_basic_info_data_t taskinfo; + struct user u; + task_t thistask; + int ret, info_count; + + memset (buf, 0, sizeof (glibtop_procdata)); + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_procdata)); + + ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1, + sizeof (struct tbl_procinfo)); + + if (ret != 1) return; + + strcpy (buf->cmd, procinfo.pi_comm); + + buf->uid = procinfo.pi_uid; + buf->pid = procinfo.pi_pid; + buf->ppid = procinfo.pi_ppid; + buf->pgrp = procinfo.pi_pgrp; + buf->tty = procinfo.pi_ttyd; + buf->k_flags = procinfo.pi_flag; + buf->session = procinfo.pi_session; + buf->tpgid = procinfo.pi_tpgrp; + buf->sigignore = procinfo.pi_sigignore; + buf->sigcatch = procinfo.pi_sigcatch; + buf->signal = procinfo.pi_sig; + + buf->flags [0] += _glibtop_sysdeps_procdata_0; + + if (procinfo.pi_status != PI_ACTIVE) return; + + /* From that point on, we are only interested in active processes. */ + + buf->nice = getpriority (PRIO_PROCESS, pid); + + /* Get task structure. */ + + ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask); + + if (ret != KERN_SUCCESS) return; + + /* Get taskinfo about this task. */ + + info_count = TASK_BASIC_INFO_COUNT; + + ret = task_info (thistask, TASK_BASIC_INFO, (task_info_t) &taskinfo, &info_count); + + if (ret != KERN_SUCCESS) return; + + buf->priority = taskinfo.base_priority; + buf->resident = taskinfo.resident_size; + buf->rss = taskinfo.resident_size; + buf->vsize = taskinfo.virtual_size; + + buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) + + BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) + + BIT_SHIFT(GLIBTOP_PROCDATA_RSS) + + BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE); + + ret = table (TBL_UAREA, pid, (char *) &u, 1, + sizeof (struct user)); + + if (ret != 1) return; + + buf->start_code = (unsigned long) u.u_text_start; + buf->end_code = (unsigned long) u.u_data_start; + buf->start_stack = (unsigned long) u.u_stack_start; + + buf->trs = u.u_tsize; + buf->drs = u.u_dsize; + + buf->start_time = u.u_start.tv_sec; + + buf->utime = u.u_ru.ru_utime.tv_sec; + buf->stime = u.u_ru.ru_stime.tv_sec; + buf->cutime = u.u_cru.ru_utime.tv_sec; + buf->cstime = u.u_cru.ru_stime.tv_sec; + + buf->flags [0] += BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) + + BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_STIME) + + BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) + + BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + BIT_SHIFT(GLIBTOP_PROCDATA_DRS); + + buf->flags [1] += BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) + + BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) + + BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK); +} diff --git a/sysdeps/osf1/prockernel.c b/sysdeps/osf1/prockernel.c new file mode 100644 index 00000000..93f47bb1 --- /dev/null +++ b/sysdeps/osf1/prockernel.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_kernel)); +} diff --git a/sysdeps/osf1/proclist.c b/sysdeps/osf1/proclist.c new file mode 100644 index 00000000..7659a9df --- /dev/null +++ b/sysdeps/osf1/proclist.c @@ -0,0 +1,155 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proclist = +(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) + +(1 << GLIBTOP_PROCLIST_SIZE); + +/* How many elements are there per proctable entry? */ + +#define ELEMENTS_PER_ENTRY 8 + +/* We have a buffer for BLOCK_COUNT pids; when it's full, it is copied + * to a newly realloc()ed area. */ + +#define BLOCK_COUNT 256 +#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned)) + +/* Fetch list of currently running processes. + * + * The interface of this function is a little bit different from the others: + * buf->flags is only set if the call succeeded, in this case pids_chain, + * a list of the pids of all currently running processes is returned, + * buf->number is the number of elements of this list and buf->size is + * the size of one single element (sizeof (unsigned)). The total size is + * stored in buf->total. + * + * The calling function has to free the memory to which a pointer is returned. + * + * On error, NULL is returned and buf->flags is zero. */ + +/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + +unsigned * +glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +{ + unsigned count = 0, total = 0; + unsigned pids [BLOCK_COUNT], *pids_chain = NULL; + unsigned pids_size = 0, pids_offset = 0, new_size; + struct tbl_procinfo procinfo [8]; + int entry, max_elements, k; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_proclist)); + + for (entry = 0; entry < server->machine.proctable_entries; + entry += ELEMENTS_PER_ENTRY) + { + + /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + + setreuid (server->machine.uid, server->machine.euid); + + max_elements = table (TBL_PROCINFO, entry, (char *) &procinfo, + ELEMENTS_PER_ENTRY, sizeof (struct tbl_procinfo)); + + if (setreuid (server->machine.euid, server->machine.uid)) + _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + for (k = 0; k < max_elements; k++) + { + /* Does this entry contain a real process? */ + + if (procinfo [k].pi_status == 0) + continue; + + /* The following code is copied from the Linux implementation. + * It's safe since we are no longer root at this point here. */ + + /* Fine. Now we first try to store it in pids. If this buffer is + * full, we copy it to the pids_chain. */ + + if (count >= BLOCK_COUNT) { + /* The following call to glibtop_realloc will be equivalent to + * glibtop_malloc if pids_chain is NULL. We just calculate the + * new size and copy pids to the beginning of the newly allocated + * block. */ + + new_size = pids_size + BLOCK_SIZE; + + pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + + memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE); + + pids_size = new_size; + + pids_offset += BLOCK_COUNT; + + count = 0; + } + + /* pids is now big enough to hold at least one single pid. */ + + pids [count++] = procinfo [k].pi_pid; + + total++; + } + } + + /* count is only zero if an error occured (eg. the server is not suid root). */ + + if (!count) return NULL; + + /* The following call to glibtop_realloc will be equivalent to + * glibtop_malloc if pids_chain is NULL. We just calculate the + * new size and copy pids to the beginning of the newly allocated + * block. */ + + new_size = pids_size + count * sizeof (unsigned); + + pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + + memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); + + pids_size = new_size; + + pids_offset += BLOCK_COUNT; + + /* Since everything is ok now, we can set buf->flags, fill in the remaining fields + and return pids_chain. */ + + buf->flags = _glibtop_sysdeps_proclist; + + buf->size = sizeof (unsigned); + buf->number = total; + + buf->total = total * sizeof (unsigned); + + return pids_chain; +} diff --git a/sysdeps/osf1/procmem.c b/sysdeps/osf1/procmem.c new file mode 100644 index 00000000..889a4a20 --- /dev/null +++ b/sysdeps/osf1/procmem.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_mem)); +} diff --git a/sysdeps/osf1/procsegment.c b/sysdeps/osf1/procsegment.c new file mode 100644 index 00000000..c0ffeb17 --- /dev/null +++ b/sysdeps/osf1/procsegment.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_segment)); +} diff --git a/sysdeps/osf1/procsignal.c b/sysdeps/osf1/procsignal.c new file mode 100644 index 00000000..6c30ee66 --- /dev/null +++ b/sysdeps/osf1/procsignal.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_signal)); +} diff --git a/sysdeps/osf1/procstate.c b/sysdeps/osf1/procstate.c new file mode 100644 index 00000000..b8ad5cec --- /dev/null +++ b/sysdeps/osf1/procstate.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_state)); +} diff --git a/sysdeps/osf1/proctime.c b/sysdeps/osf1/proctime.c new file mode 100644 index 00000000..ec81d2a0 --- /dev/null +++ b/sysdeps/osf1/proctime.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_time)); +} diff --git a/sysdeps/osf1/procuid.c b/sysdeps/osf1/procuid.c new file mode 100644 index 00000000..7fbb85fa --- /dev/null +++ b/sysdeps/osf1/procuid.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_uid)); +} diff --git a/sysdeps/osf1/sem_limits.c b/sysdeps/osf1/sem_limits.c new file mode 100644 index 00000000..f3a133e0 --- /dev/null +++ b/sysdeps/osf1/sem_limits.c @@ -0,0 +1,100 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +static unsigned long _glibtop_sysdeps_sem_limits = +(1 << GLIBTOP_IPC_SEMMNI) + (1 << GLIBTOP_IPC_SEMMSL) + +(1 << GLIBTOP_IPC_SEMOPM) + (1 << GLIBTOP_IPC_SEMVMX) + +(1 << GLIBTOP_IPC_SEMAEM); + +/* Provides information about sysv sem limits. */ + +void +glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +{ + int ret, value; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_sem_limits)); + + ret = table (TBL_SEMINFO, SEMINFO_MNI, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SEMMNI); + + buf->semmni = value; + + + ret = table (TBL_SEMINFO, SEMINFO_MSL, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SEMMSL); + + buf->semmsl = value; + + + ret = table (TBL_SEMINFO, SEMINFO_OPM, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SEMOPM); + + buf->semopm = value; + + + ret = table (TBL_SEMINFO, SEMINFO_UME, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SEMUME); + + buf->semume = value; + + + ret = table (TBL_SEMINFO, SEMINFO_VMX, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SEMVMX); + + buf->semvmx = value; + + + ret = table (TBL_SEMINFO, SEMINFO_AEM, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SEMAEM); + + buf->semaem = value; +} diff --git a/sysdeps/osf1/shm_limits.c b/sysdeps/osf1/shm_limits.c new file mode 100644 index 00000000..9173177a --- /dev/null +++ b/sysdeps/osf1/shm_limits.c @@ -0,0 +1,79 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +static unsigned long _glibtop_sysdeps_shm_limits = +(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) + +(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +{ + int ret, value; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_shm_limits)); + + ret = table (TBL_SHMINFO, SHMINFO_MAX, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SHMMAX); + + buf->shmmax = value; + + + ret = table (TBL_SHMINFO, SHMINFO_MIN, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SHMMIN); + + buf->shmmin = value; + + + ret = table (TBL_SHMINFO, SHMINFO_MNI, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SHMMNI); + + buf->shmmni = value; + + + ret = table (TBL_SHMINFO, SHMINFO_SEG, (char *) &value, 1, + sizeof (value)); + + if (ret != 1) return; + + buf->flags += (1 << GLIBTOP_IPC_SHMSEG); + + buf->shmseg = value; +} diff --git a/sysdeps/osf1/swap.c b/sysdeps/osf1/swap.c new file mode 100644 index 00000000..c606fa50 --- /dev/null +++ b/sysdeps/osf1/swap.c @@ -0,0 +1,54 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +static unsigned long _glibtop_sysdeps_swap = +(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) + +(1 << GLIBTOP_SWAP_FREE); + +/* Provides information about swap usage. */ + +void +glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +{ + struct tbl_swapinfo swapinfo; + int i; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_swap)); + + i = 0; + + while (table (TBL_SWAPINFO, i, (char *) &swapinfo, 1, + sizeof (struct tbl_swapinfo)) > 0) { + buf->total += swapinfo.size * getpagesize (); + buf->free += swapinfo.free * getpagesize (); + i++; + } + + buf->flags = _glibtop_sysdeps_swap; + + buf->used = buf->total - buf->free; +} diff --git a/sysdeps/stub/.cvsignore b/sysdeps/stub/.cvsignore new file mode 100644 index 00000000..ac735171 --- /dev/null +++ b/sysdeps/stub/.cvsignore @@ -0,0 +1,27 @@ +.deps +.libs +Makefile +Makefile.in +close.lo +cpu.lo +init.lo +libgtop_sysdeps.la +loadavg.c +loadavg.lo +mem.lo +msg_limits.lo +open.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +sem_limits.lo +shm_limits.lo +swap.lo +sysdeps.lo +uptime.c +uptime.lo diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am new file mode 100644 index 00000000..a1aac013 --- /dev/null +++ b/sysdeps/stub/Makefile.am @@ -0,0 +1,14 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +lib_LTLIBRARIES = libgtop_sysdeps.la + +libgtop_sysdeps_la_SOURCES = init.c open.c close.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 + diff --git a/sysdeps/stub/close.c b/sysdeps/stub/close.c new file mode 100644 index 00000000..ff7ebea4 --- /dev/null +++ b/sysdeps/stub/close.c @@ -0,0 +1,28 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Closes pipe to gtop server. */ + +void +glibtop_close (glibtop *server) +{ } diff --git a/sysdeps/stub/cpu.c b/sysdeps/stub/cpu.c new file mode 100644 index 00000000..cda12977 --- /dev/null +++ b/sysdeps/stub/cpu.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about cpu usage. */ + +void +glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +{ + memset (buf, 0, sizeof (glibtop_cpu)); +} diff --git a/sysdeps/stub/init.c b/sysdeps/stub/init.c new file mode 100644 index 00000000..f6a9a506 --- /dev/null +++ b/sysdeps/stub/init.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = NULL; + +glibtop * +glibtop_init__r (glibtop **server) +{ + if (*server != NULL) + return *server; + + if (glibtop_global_server == NULL) { + glibtop_global_server = &_glibtop_global_server; + glibtop_open (glibtop_global_server, "glibtop"); + } + + return *server = glibtop_global_server; +} diff --git a/sysdeps/stub/libsysdeps.la b/sysdeps/stub/libsysdeps.la new file mode 100644 index 00000000..3f600ebb --- /dev/null +++ b/sysdeps/stub/libsysdeps.la @@ -0,0 +1,19 @@ +# libsysdeps.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.0h + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='libsysdeps.so.0.0.0 libsysdeps.so.0 libsysdeps.so' + +# The name of the static archive. +old_library='libsysdeps.a' + +# Version information for libsysdeps. +current=0 +age=0 +revision=0 + +# Directory that this library needs to be installed in: +libdir='/usr/local/lib' diff --git a/sysdeps/stub/mem.c b/sysdeps/stub/mem.c new file mode 100644 index 00000000..0410e2dd --- /dev/null +++ b/sysdeps/stub/mem.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about memory usage. */ + +void +glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +{ + memset (buf, 0, sizeof (glibtop_mem)); +} diff --git a/sysdeps/stub/msg_limits.c b/sysdeps/stub/msg_limits.c new file mode 100644 index 00000000..62819042 --- /dev/null +++ b/sysdeps/stub/msg_limits.c @@ -0,0 +1,30 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +{ + memset (buf, 0, sizeof (glibtop_msg_limits)); +} diff --git a/sysdeps/stub/open.c b/sysdeps/stub/open.c new file mode 100644 index 00000000..c2d58069 --- /dev/null +++ b/sysdeps/stub/open.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ + +void +glibtop_open (glibtop *server, const char *program_name) +{ + memset (server, 0, sizeof (glibtop)); + server->name = program_name; +} diff --git a/sysdeps/stub/prockernel.c b/sysdeps/stub/prockernel.c new file mode 100644 index 00000000..93f47bb1 --- /dev/null +++ b/sysdeps/stub/prockernel.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_kernel)); +} diff --git a/sysdeps/stub/proclist.c b/sysdeps/stub/proclist.c new file mode 100644 index 00000000..f3e0b993 --- /dev/null +++ b/sysdeps/stub/proclist.c @@ -0,0 +1,39 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#define GLIBTOP_PROCLIST_FLAGS 3 + +/* Fetch list of currently running processes. + * + * IMPORTANT NOTE: + * On error, this function MUST return NULL and set buf->flags to zero ! + * On success, it returnes a pointer to a list of buf->number elements + * each buf->size big. The total size is stored in buf->total. */ + +unsigned * +glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +{ + memset (buf, 0, sizeof (glibtop_proclist)); + return NULL; +} diff --git a/sysdeps/stub/procmem.c b/sysdeps/stub/procmem.c new file mode 100644 index 00000000..889a4a20 --- /dev/null +++ b/sysdeps/stub/procmem.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_mem)); +} diff --git a/sysdeps/stub/procsegment.c b/sysdeps/stub/procsegment.c new file mode 100644 index 00000000..c0ffeb17 --- /dev/null +++ b/sysdeps/stub/procsegment.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_segment)); +} diff --git a/sysdeps/stub/procsignal.c b/sysdeps/stub/procsignal.c new file mode 100644 index 00000000..6c30ee66 --- /dev/null +++ b/sysdeps/stub/procsignal.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_signal)); +} diff --git a/sysdeps/stub/procstate.c b/sysdeps/stub/procstate.c new file mode 100644 index 00000000..b8ad5cec --- /dev/null +++ b/sysdeps/stub/procstate.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_state)); +} diff --git a/sysdeps/stub/proctime.c b/sysdeps/stub/proctime.c new file mode 100644 index 00000000..ec81d2a0 --- /dev/null +++ b/sysdeps/stub/proctime.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_time)); +} diff --git a/sysdeps/stub/procuid.c b/sysdeps/stub/procuid.c new file mode 100644 index 00000000..7fbb85fa --- /dev/null +++ b/sysdeps/stub/procuid.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_uid)); +} diff --git a/sysdeps/stub/sem_limits.c b/sysdeps/stub/sem_limits.c new file mode 100644 index 00000000..3768408b --- /dev/null +++ b/sysdeps/stub/sem_limits.c @@ -0,0 +1,30 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Provides information about sysv sem limits. */ + +void +glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +{ + memset (buf, 0, sizeof (glibtop_sem_limits)); +} diff --git a/sysdeps/stub/shm_limits.c b/sysdeps/stub/shm_limits.c new file mode 100644 index 00000000..52e801ba --- /dev/null +++ b/sysdeps/stub/shm_limits.c @@ -0,0 +1,30 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +{ + memset (buf, 0, sizeof (glibtop_shm_limits)); +} diff --git a/sysdeps/stub/swap.c b/sysdeps/stub/swap.c new file mode 100644 index 00000000..8e0d046b --- /dev/null +++ b/sysdeps/stub/swap.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about swap usage. */ + +void +glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +{ + memset (buf, 0, sizeof (glibtop_swap)); +} diff --git a/sysdeps/sun4/.cvsignore b/sysdeps/sun4/.cvsignore new file mode 100644 index 00000000..d167e031 --- /dev/null +++ b/sysdeps/sun4/.cvsignore @@ -0,0 +1,19 @@ +.deps +.libs +Makefile +Makefile.in +close.lo +cpu.lo +libgtop_sysdeps.la +loadavg.c +loadavg.lo +mem.lo +msg_limits.lo +open.lo +proclist.lo +sem_limits.lo +shm_limits.lo +swap.lo +sysdeps.lo +uptime.c +uptime.lo diff --git a/sysdeps/sun4/Makefile.am b/sysdeps/sun4/Makefile.am new file mode 100644 index 00000000..60b581f1 --- /dev/null +++ b/sysdeps/sun4/Makefile.am @@ -0,0 +1,14 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @GTOP_INCS@ + +CFLAGS = -Wall -W @CFLAGS@ + +lib_LTLIBRARIES = libgtop_sysdeps.la + +libgtop_sysdeps_la_SOURCES = init.c open.c close.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_sysdeps_la_LIBADD = -lkvm diff --git a/sysdeps/sun4/close.c b/sysdeps/sun4/close.c new file mode 100644 index 00000000..ff7ebea4 --- /dev/null +++ b/sysdeps/sun4/close.c @@ -0,0 +1,28 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Closes pipe to gtop server. */ + +void +glibtop_close (glibtop *server) +{ } diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c new file mode 100644 index 00000000..cda12977 --- /dev/null +++ b/sysdeps/sun4/cpu.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about cpu usage. */ + +void +glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +{ + memset (buf, 0, sizeof (glibtop_cpu)); +} diff --git a/sysdeps/sun4/init.c b/sysdeps/sun4/init.c new file mode 100644 index 00000000..f6a9a506 --- /dev/null +++ b/sysdeps/sun4/init.c @@ -0,0 +1,40 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = NULL; + +glibtop * +glibtop_init__r (glibtop **server) +{ + if (*server != NULL) + return *server; + + if (glibtop_global_server == NULL) { + glibtop_global_server = &_glibtop_global_server; + glibtop_open (glibtop_global_server, "glibtop"); + } + + return *server = glibtop_global_server; +} diff --git a/sysdeps/sun4/libsysdeps.la b/sysdeps/sun4/libsysdeps.la new file mode 100644 index 00000000..3f600ebb --- /dev/null +++ b/sysdeps/sun4/libsysdeps.la @@ -0,0 +1,19 @@ +# libsysdeps.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.0h + +# The name that we can dlopen(3). +dlname='' + +# Names of this library. +library_names='libsysdeps.so.0.0.0 libsysdeps.so.0 libsysdeps.so' + +# The name of the static archive. +old_library='libsysdeps.a' + +# Version information for libsysdeps. +current=0 +age=0 +revision=0 + +# Directory that this library needs to be installed in: +libdir='/usr/local/lib' diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c new file mode 100644 index 00000000..0410e2dd --- /dev/null +++ b/sysdeps/sun4/mem.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about memory usage. */ + +void +glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +{ + memset (buf, 0, sizeof (glibtop_mem)); +} diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c new file mode 100644 index 00000000..62819042 --- /dev/null +++ b/sysdeps/sun4/msg_limits.c @@ -0,0 +1,30 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +{ + memset (buf, 0, sizeof (glibtop_msg_limits)); +} diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c new file mode 100644 index 00000000..c2d58069 --- /dev/null +++ b/sysdeps/sun4/open.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ + +void +glibtop_open (glibtop *server, const char *program_name) +{ + memset (server, 0, sizeof (glibtop)); + server->name = program_name; +} diff --git a/sysdeps/sun4/procdata.c b/sysdeps/sun4/procdata.c new file mode 100644 index 00000000..b542721d --- /dev/null +++ b/sysdeps/sun4/procdata.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_procdata__r (glibtop *server, glibtop_procdata *buf, pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_procdata)); +} diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c new file mode 100644 index 00000000..93f47bb1 --- /dev/null +++ b/sysdeps/sun4/prockernel.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_kernel)); +} diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c new file mode 100644 index 00000000..f3e0b993 --- /dev/null +++ b/sysdeps/sun4/proclist.c @@ -0,0 +1,39 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#define GLIBTOP_PROCLIST_FLAGS 3 + +/* Fetch list of currently running processes. + * + * IMPORTANT NOTE: + * On error, this function MUST return NULL and set buf->flags to zero ! + * On success, it returnes a pointer to a list of buf->number elements + * each buf->size big. The total size is stored in buf->total. */ + +unsigned * +glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +{ + memset (buf, 0, sizeof (glibtop_proclist)); + return NULL; +} diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c new file mode 100644 index 00000000..889a4a20 --- /dev/null +++ b/sysdeps/sun4/procmem.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_mem)); +} diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c new file mode 100644 index 00000000..c0ffeb17 --- /dev/null +++ b/sysdeps/sun4/procsegment.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_segment)); +} diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c new file mode 100644 index 00000000..6c30ee66 --- /dev/null +++ b/sysdeps/sun4/procsignal.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_signal)); +} diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c new file mode 100644 index 00000000..b8ad5cec --- /dev/null +++ b/sysdeps/sun4/procstate.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_state)); +} diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c new file mode 100644 index 00000000..ec81d2a0 --- /dev/null +++ b/sysdeps/sun4/proctime.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_time)); +} diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c new file mode 100644 index 00000000..7fbb85fa --- /dev/null +++ b/sysdeps/sun4/procuid.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, + pid_t pid) +{ + memset (buf, 0, sizeof (glibtop_proc_uid)); +} diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c new file mode 100644 index 00000000..3768408b --- /dev/null +++ b/sysdeps/sun4/sem_limits.c @@ -0,0 +1,30 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Provides information about sysv sem limits. */ + +void +glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +{ + memset (buf, 0, sizeof (glibtop_sem_limits)); +} diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c new file mode 100644 index 00000000..52e801ba --- /dev/null +++ b/sysdeps/sun4/shm_limits.c @@ -0,0 +1,30 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +{ + memset (buf, 0, sizeof (glibtop_shm_limits)); +} diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c new file mode 100644 index 00000000..8e0d046b --- /dev/null +++ b/sysdeps/sun4/swap.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides information about swap usage. */ + +void +glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +{ + memset (buf, 0, sizeof (glibtop_swap)); +} From d9489b28e7ab7ea8603d55da4ab85d391bf16318 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 18:19:50 +0000 Subject: [PATCH 0002/2539] Initial import of libgtop into the Gnome CVS repository. From d74eaeb6c80a4411634c2d1cc03a7a92fe50727d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 18:43:46 +0000 Subject: [PATCH 0003/2539] forgot this file all the time - stub for glibtop_uptime * sysdeps/stub/uptime.c: forgot this file all the time - stub for glibtop_uptime * sysdeps/stub/loadavg.c: forgot this file all the time - stub for glibtop_loadavg --- sysdeps/stub/.cvsignore | 2 -- sysdeps/stub/loadavg.c | 31 +++++++++++++++++++++++++++++++ sysdeps/stub/uptime.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 sysdeps/stub/loadavg.c create mode 100644 sysdeps/stub/uptime.c diff --git a/sysdeps/stub/.cvsignore b/sysdeps/stub/.cvsignore index ac735171..259351e1 100644 --- a/sysdeps/stub/.cvsignore +++ b/sysdeps/stub/.cvsignore @@ -6,7 +6,6 @@ close.lo cpu.lo init.lo libgtop_sysdeps.la -loadavg.c loadavg.lo mem.lo msg_limits.lo @@ -23,5 +22,4 @@ sem_limits.lo shm_limits.lo swap.lo sysdeps.lo -uptime.c uptime.lo diff --git a/sysdeps/stub/loadavg.c b/sysdeps/stub/loadavg.c new file mode 100644 index 00000000..de6605e0 --- /dev/null +++ b/sysdeps/stub/loadavg.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides load averange. */ + +void +glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +{ + memset (buf, 0, sizeof (glibtop_loadavg)); +} diff --git a/sysdeps/stub/uptime.c b/sysdeps/stub/uptime.c new file mode 100644 index 00000000..5b9ea63f --- /dev/null +++ b/sysdeps/stub/uptime.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides uptime and idle time. */ + +void +glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +{ + memset (buf, 0, sizeof (glibtop_uptime)); +} From ab9c7e593d6aa08959fd1b49aedeec4fa5d5264b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 18:44:13 +0000 Subject: [PATCH 0004/2539] new file * po/Makefile.in.in: new file --- po/Makefile.in.in | 247 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 po/Makefile.in.in diff --git a/po/Makefile.in.in b/po/Makefile.in.in new file mode 100644 index 00000000..c25fea49 --- /dev/null +++ b/po/Makefile.in.in @@ -0,0 +1,247 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper +# +# 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. + +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = /bin/sh +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datadir = $(prefix)/@DATADIRNAME@ +localedir = $(datadir)/locale +gnulocaledir = $(prefix)/share/locale +gettextsrcdir = $(prefix)/share/gettext/po +subdir = po + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@ + +CC = @CC@ +GENCAT = @GENCAT@ +GMSGFMT = PATH=../src:$$PATH @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = PATH=../src:$$PATH @XGETTEXT@ +MSGMERGE = PATH=../src:$$PATH msgmerge + +DEFS = @DEFS@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ + +INCLUDES = -I.. -I$(top_srcdir)/intl + +COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) + +SOURCES = cat-id-tbl.c +POFILES = @POFILES@ +GMOFILES = @GMOFILES@ +DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(PACKAGE).pot \ +stamp-cat-id $(POFILES) $(GMOFILES) $(SOURCES) + +POTFILES = \ + +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +INSTOBJEXT = @INSTOBJEXT@ + +.SUFFIXES: +.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat + +.c.o: + $(COMPILE) $< + +.po.pox: + $(MAKE) $(PACKAGE).pot + $(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox + +.po.mo: + $(MSGFMT) -o $@ $< + +.po.gmo: + file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \ + && rm -f $$file && $(GMSGFMT) -o $$file $< + +.po.cat: + sed -f ../intl/po2msg.sed < $< > $*.msg \ + && rm -f $@ && $(GENCAT) $@ $*.msg + + +all: all-@USE_NLS@ + +all-yes: cat-id-tbl.c $(CATALOGS) +all-no: + +$(srcdir)/$(PACKAGE).pot: $(POTFILES) + $(XGETTEXT) --default-domain=$(PACKAGE) --directory=$(top_srcdir) \ + --add-comments --keyword=_ --keyword=N_ \ + --files-from=$(srcdir)/POTFILES.in + rm -f $(srcdir)/$(PACKAGE).pot + mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot + +$(srcdir)/cat-id-tbl.c: stamp-cat-id; @: +$(srcdir)/stamp-cat-id: $(PACKAGE).pot + rm -f cat-id-tbl.tmp + sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \ + | sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp + if cmp -s cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; then \ + rm cat-id-tbl.tmp; \ + else \ + echo cat-id-tbl.c changed; \ + rm -f $(srcdir)/cat-id-tbl.c; \ + mv cat-id-tbl.tmp $(srcdir)/cat-id-tbl.c; \ + fi + cd $(srcdir) && rm -f stamp-cat-id && echo timestamp > stamp-cat-id + + +install: install-exec install-data +install-exec: +install-data: install-data-@USE_NLS@ +install-data-no: all +install-data-yes: all + if test -r $(MKINSTALLDIRS); then \ + $(MKINSTALLDIRS) $(datadir); \ + else \ + $(top_srcdir)/mkinstalldirs $(datadir); \ + fi + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + case "$$cat" in \ + *.gmo) destdir=$(gnulocaledir);; \ + *) destdir=$(localedir);; \ + esac; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + dir=$$destdir/$$lang/LC_MESSAGES; \ + if test -r $(MKINSTALLDIRS); then \ + $(MKINSTALLDIRS) $$dir; \ + else \ + $(top_srcdir)/mkinstalldirs $$dir; \ + fi; \ + if test -r $$cat; then \ + $(INSTALL_DATA) $$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \ + echo "installing $$cat as $$dir/$(PACKAGE)$(INSTOBJEXT)"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \ + echo "installing $(srcdir)/$$cat as" \ + "$$dir/$(PACKAGE)$(INSTOBJEXT)"; \ + fi; \ + if test -r $$cat.m; then \ + $(INSTALL_DATA) $$cat.m $$dir/$(PACKAGE)$(INSTOBJEXT).m; \ + echo "installing $$cat.m as $$dir/$(PACKAGE)$(INSTOBJEXT).m"; \ + else \ + if test -r $(srcdir)/$$cat.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$cat.m \ + $$dir/$(PACKAGE)$(INSTOBJEXT).m; \ + echo "installing $(srcdir)/$$cat as" \ + "$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \ + else \ + true; \ + fi; \ + fi; \ + done + if test "$(PACKAGE)" = "gettext"; then \ + if test -r $(MKINSTALLDIRS); then \ + $(MKINSTALLDIRS) $(gettextsrcdir); \ + else \ + $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \ + fi; \ + $(INSTALL_DATA) $(srcdir)/Makefile.in.in \ + $(gettextsrcdir)/Makefile.in.in; \ + else \ + : ; \ + fi + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \ + rm -f $(localedir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \ + rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT); \ + rm -f $(gnulocaledir)/$$lang/LC_MESSAGES/$(PACKAGE)$(INSTOBJEXT).m; \ + done + rm -f $(gettextsrcdir)/po-Makefile.in.in + +check: all + +cat-id-tbl.o: ../intl/libgettext.h + +dvi info tags TAGS ID: + +mostlyclean: + rm -f core core.* *.pox $(PACKAGE).po *.old.po cat-id-tbl.tmp + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f $(GMOFILES) + +distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: update-po $(DISTFILES) + dists="$(DISTFILES)"; \ + for file in $$dists; do \ + ln $(srcdir)/$$file $(distdir) 2> /dev/null \ + || cp -p $(srcdir)/$$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(PACKAGE).pot + PATH=`pwd`/../src:$$PATH; \ + cd $(srcdir); \ + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + mv $$lang.po $$lang.old.po; \ + echo "$$lang:"; \ + if $(MSGMERGE) $$lang.old.po $(PACKAGE).pot -o $$lang.po; then \ + rm -f $$lang.old.po; \ + else \ + echo "msgmerge for $$cat failed!"; \ + rm -f $$lang.po; \ + mv $$lang.old.po $$lang.po; \ + fi; \ + done + +POTFILES: POTFILES.in + ( if test 'x$(srcdir)' != 'x.'; then \ + posrcprefix='$(top_srcdir)/'; \ + else \ + posrcprefix="../"; \ + fi; \ + rm -f $@-t $@ \ + && (sed -e '/^#/d' -e '/^[ ]*$$/d' \ + -e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \ + | sed -e '$$s/\\$$//') > $@-t \ + && chmod a-w $@-t \ + && mv $@-t $@ ) + +Makefile: Makefile.in.in ../config.status POTFILES + cd .. \ + && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \ + $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: From bf7eb7af5e6f7201a920be5e07ed1ad9779fdb04 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 18:44:37 +0000 Subject: [PATCH 0005/2539] new file * ABOUT-NLS: new file --- ABOUT-NLS | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 ABOUT-NLS diff --git a/ABOUT-NLS b/ABOUT-NLS new file mode 100644 index 00000000..dacb8b18 --- /dev/null +++ b/ABOUT-NLS @@ -0,0 +1,225 @@ +Notes on the Free Translation Project +************************************* + + Free software is going international! The Free Translation Project +is a way to get maintainers of free software, translators, and users all +together, so that will gradually become able to speak many languages. +A few packages already provide translations for their messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do *not* +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work at translations should contact the appropriate team. + + When reporting bugs in the `intl/' directory or bugs which may be +related to internationalization, you should tell about the version of +`gettext' which is used. The information can be found in the +`intl/VERSION' file, in internationalized packages. + +One advise in advance +===================== + + If you want to exploit the full power of internationalization, you +should configure it using + + ./configure --with-included-gettext + +to force usage of internationalizing routines provided within this +package, despite the existence of internationalizing capabilities in the +operating system where this package is being installed. So far, only +the `gettext' implementation in the GNU C library version 2 provides as +many features (such as locale alias or message inheritance) as the +implementation here. It is also not possible to offer this additional +functionality on top of a `catgets' implementation. Future versions of +GNU `gettext' will very likely convey even more functionality. So it +might be a good idea to change to GNU `gettext' as soon as possible. + + So you need not provide this option if you are using GNU libc 2 or +you have installed a recent copy of the GNU gettext package with the +included `libintl'. + +INSTALL Matters +=============== + + Some packages are "localizable" when properly installed; the +programs they contain can be made to speak your own native language. +Most such packages use GNU `gettext'. Other packages have their own +ways to internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system provides +usable `catgets' (if using this is selected by the installer) or +`gettext' functions. If neither is available, the GNU `gettext' own +library will be used. This library is wholly contained within this +package, usually in the `intl/' subdirectory, so prior installation of +the GNU `gettext' package is *not* required. Installers may use +special options at configuration time for changing the default +behaviour. The commands: + + ./configure --with-included-gettext + ./configure --with-catgets + ./configure --disable-nls + +will respectively bypass any pre-existing `catgets' or `gettext' to use +the internationalizing routines provided within this package, enable +the use of the `catgets' functions (if found on the locale system), or +else, *totally* disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl.a' file and +will decide to use this. This might be not what is desirable. You +should use the more recent version of the GNU `gettext' library. I.e. +if the file `intl/VERSION' shows that the library which comes with this +package is more recent, you should use + + ./configure --with-included-gettext + +to prevent auto-detection. + + By default the configuration process will not test for the `catgets' +function and therefore they will not be used. The reasons are already +given above: the emulation on top of `catgets' cannot provide all the +extensions provided by the GNU `gettext' library. If you nevertheless +want to use the `catgets' functions use + + ./configure --with-catgets + +to enable the test for `catgets' (this causes no harm if `catgets' is +not available on your system). If you really select this option we +would like to hear about the reasons because we cannot think of any +good one ourself. + + Internationalized packages have usually many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +Using This Package +================== + + As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +ISO 639 `LL' two-letter code prior to using the programs in the +package. For example, let's suppose that you speak German. At the +shell prompt, merely execute `setenv LANG de' (in `csh'), +`export LANG; LANG=de' (in `sh') or `export LANG=de' (in `bash'). This +can be done from your `.login' or `.profile' file, once and for all. + + An operating system might already offer message localization for +many of its programs, while other programs have been installed locally +with the full capabilities of GNU `gettext'. Just using `gettext' +extended syntax for `LANG' would break proper localization of already +available operating system programs. In this case, users should set +both `LANGUAGE' and `LANG' variables in their environment, as programs +using GNU `gettext' give preference to `LANGUAGE'. For example, some +Swedish users would rather read translations in German than English for +when Swedish is not available. This is easily accomplished by setting +`LANGUAGE' to `sv:de' while leaving `LANG' to `sv'. + +Translating Teams +================= + + For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list, courtesy of Linux +International. You may reach your translation team at the address +`LL@li.org', replacing LL by the two-letter ISO 639 code for your +language. Language codes are *not* the same as the country codes given +in ISO 3166. The following translation teams exist, as of August 1997: + + Chinese `zh', Czech `cs', Danish `da', Dutch `nl', English `en', + Esperanto `eo', Finnish `fi', French `fr', German `de', Hungarian + `hu', Irish `ga', Italian `it', Indonesian `id', Japanese `ja', + Korean `ko', Latin `la', Norwegian `no', Persian `fa', Polish + `pl', Portuguese `pt', Russian `ru', Slovenian `sl', Spanish `es', + Swedish `sv', and Turkish `tr'. + +For example, you may reach the Chinese translation team by writing to +`zh@li.org'. + + If you'd like to volunteer to *work* at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is *not* the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request@li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +*actively* in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `translation@iro.umontreal.ca' to reach the +coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skill are praised more than +programming skill, here. + +Available Packages +================== + + Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of August +1997. The matrix shows, in regard of each package, for which languages +PO files have been submitted to translation coordination. + + Ready PO files cs da de en es fi fr it ja ko nl no pl pt sl sv + .-------------------------------------------------. + bash | [] [] [] | 3 + bison | [] [] [] | 3 + clisp | [] [] [] [] | 4 + cpio | [] [] [] [] [] | 5 + diffutils | [] [] [] [] [] | 5 + enscript | [] [] [] [] [] [] | 6 + fileutils | [] [] [] [] [] [] [] [] [] [] | 10 + findutils | [] [] [] [] [] [] [] [] | 8 + flex | [] [] [] [] | 4 + gcal | [] [] [] [] [] | 5 + gettext | [] [] [] [] [] [] [] [] [] [] | 11 + grep | [] [] [] [] [] [] [] [] [] | 9 + hello | [] [] [] [] [] [] [] [] [] [] | 10 + id-utils | [] [] [] | 3 + indent | [] [] [] [] | 4 + libc | [] [] [] [] [] [] [] | 7 + m4 | [] [] [] [] [] | 5 + make | [] [] [] [] [] [] | 6 + music | [] [] | 2 + ptx | [] [] [] [] [] [] [] [] | 8 + recode | [] [] [] [] [] [] [] [] [] | 9 + sh-utils | [] [] [] [] [] [] [] | 7 + sharutils | [] [] [] [] [] | 5 + tar | [] [] [] [] [] [] [] [] [] [] | 10 + texinfo | [] | 1 + textutils | [] [] [] [] [] [] [] [] [] | 9 + wdiff | [] [] [] [] [] [] [] [] | 8 + `-------------------------------------------------' + 16 languages cs da de en es fi fr it ja ko nl no pl pt sl sv + 27 packages 3 2 24 1 17 1 26 2 1 11 20 9 19 7 7 17 167 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If August 1997 seems to be old, you may fetch a more recent copy of +this `ABOUT-NLS' file on most GNU archive sites. + From f171a2a5cacdebe6f816a4a6ef79eea4e23cbc4f Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 18:47:09 +0000 Subject: [PATCH 0006/2539] Libgtop is now in the GNOME CVS Repository. * NEWS: Libgtop is now in the GNOME CVS Repository. --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 1a067145..b9be53b9 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ $Id$ +May/19/1998 +=========== + +* Libgtop is now in the GNOME CVS Repository. + May/17/1998 =========== From 258732b8a1bb20afe9e1d1a83339454148217c43 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 18:47:24 +0000 Subject: [PATCH 0007/2539] *** empty log message *** --- ChangeLog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 83fedd85..7e26b7cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +1998-05-19 Martin Baulig + + * sysdeps/stub/uptime.c: forgot this file all the + time - stub for glibtop_uptime + + * sysdeps/stub/loadavg.c: forgot this file all the + time - stub for glibtop_loadavg + + * NEWS: Libgtop is now in the GNOME CVS Repository. + + * po/Makefile.in.in: new file + + * ABOUT-NLS: new file + 1998-05-17 Martin Baulig * NEWS: added some stuff from 'README.LATEST'. From 92dc0c9a34e1e7de1525f047d767e28174a42fa3 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 23:02:39 +0000 Subject: [PATCH 0008/2539] forgot to checkin * sysdeps/osf1/uptime.c: forgot to checkin * sysdeps/osf1/loadavg.c: forgot to checkin --- sysdeps/osf1/.cvsignore | 2 -- sysdeps/osf1/loadavg.c | 63 +++++++++++++++++++++++++++++++++++++++++ sysdeps/osf1/uptime.c | 51 +++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 sysdeps/osf1/loadavg.c create mode 100644 sysdeps/osf1/uptime.c diff --git a/sysdeps/osf1/.cvsignore b/sysdeps/osf1/.cvsignore index 33eef0e1..af2b88a8 100644 --- a/sysdeps/osf1/.cvsignore +++ b/sysdeps/osf1/.cvsignore @@ -6,7 +6,6 @@ close.lo cpu.lo libgtop_sysdeps.la libsysdeps.la -loadavg.c loadavg.lo mem.lo msg_limits.lo @@ -16,6 +15,5 @@ sem_limits.lo shm_limits.lo swap.lo sysdeps.lo -uptime.c uptime.lo so_locations diff --git a/sysdeps/osf1/loadavg.c b/sysdeps/osf1/loadavg.c new file mode 100644 index 00000000..4759279c --- /dev/null +++ b/sysdeps/osf1/loadavg.c @@ -0,0 +1,63 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +static const unsigned long _glibtop_sysdeps_loadavg = +(1 << GLIBTOP_LOADAVG_LOADAVG); + +/* Provides load averange. */ + +void +glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +{ + struct tbl_loadavg loadavg; + int ret; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_loadavg)); + + ret = table (TBL_LOADAVG, 0, (char *) &loadavg, 1, + sizeof (struct tbl_loadavg)); + + if (ret != 1) return; + + buf->flags = _glibtop_sysdeps_loadavg; + + if (loadavg.tl_lscale == 0) { + buf->loadavg [0] = loadavg.tl_avenrun.d [0]; + buf->loadavg [1] = loadavg.tl_avenrun.d [1]; + buf->loadavg [2] = loadavg.tl_avenrun.d [2]; + } else { + buf->loadavg [0] = + (double) loadavg.tl_avenrun.l [0] / + (double) loadavg.tl_mach_factor [0]; + buf->loadavg [1] = + (double) loadavg.tl_avenrun.l [1] + / (double) loadavg.tl_mach_factor [1]; + buf->loadavg [2] = + (double) loadavg.tl_avenrun.l [2] / + (double) loadavg.tl_mach_factor [2]; + } +} diff --git a/sysdeps/osf1/uptime.c b/sysdeps/osf1/uptime.c new file mode 100644 index 00000000..f455ef30 --- /dev/null +++ b/sysdeps/osf1/uptime.c @@ -0,0 +1,51 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include + +static unsigned long _glibtop_sysdeps_uptime = +(1 << GLIBTOP_UPTIME_UPTIME); + +/* Provides uptime and idle time. */ + +void +glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +{ + struct tbl_sysinfo sysinfo; + int ret; + + glibtop_init (); + + memset (buf, 0, sizeof (glibtop_uptime)); + + ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1, + sizeof (struct tbl_sysinfo)); + + if (ret != 1) return; + + buf->uptime = (double) (time (NULL) - sysinfo.si_boottime); + + buf->flags = _glibtop_sysdeps_uptime; +} From 2ece5e5f8e63d570b5587ca4128ae8a531b6d754 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 23:03:48 +0000 Subject: [PATCH 0009/2539] forgot to checkin * sysdeps/sun4/uptime.c: forgot to checkin * sysdeps/sun4/loadavg.c: forgot to checkin --- sysdeps/sun4/.cvsignore | 2 -- sysdeps/sun4/loadavg.c | 31 +++++++++++++++++++++++++++++++ sysdeps/sun4/uptime.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 sysdeps/sun4/loadavg.c create mode 100644 sysdeps/sun4/uptime.c diff --git a/sysdeps/sun4/.cvsignore b/sysdeps/sun4/.cvsignore index d167e031..dd420e7f 100644 --- a/sysdeps/sun4/.cvsignore +++ b/sysdeps/sun4/.cvsignore @@ -5,7 +5,6 @@ Makefile.in close.lo cpu.lo libgtop_sysdeps.la -loadavg.c loadavg.lo mem.lo msg_limits.lo @@ -15,5 +14,4 @@ sem_limits.lo shm_limits.lo swap.lo sysdeps.lo -uptime.c uptime.lo diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c new file mode 100644 index 00000000..de6605e0 --- /dev/null +++ b/sysdeps/sun4/loadavg.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides load averange. */ + +void +glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +{ + memset (buf, 0, sizeof (glibtop_loadavg)); +} diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c new file mode 100644 index 00000000..5b9ea63f --- /dev/null +++ b/sysdeps/sun4/uptime.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +/* Provides uptime and idle time. */ + +void +glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +{ + memset (buf, 0, sizeof (glibtop_uptime)); +} From 56a0d6235862195ac7c557f5856ad1a99924f2a9 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 23:03:56 +0000 Subject: [PATCH 0010/2539] added implementation for DEC OSF/1. * sysdeps/osf1/procuid.c (glibtop_get_proc_uid__r): added implementation for DEC OSF/1. --- sysdeps/osf1/procuid.c | 89 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/sysdeps/osf1/procuid.c b/sysdeps/osf1/procuid.c index 7fbb85fa..8635e8d3 100644 --- a/sysdeps/osf1/procuid.c +++ b/sysdeps/osf1/procuid.c @@ -22,11 +22,100 @@ #include #include +#include +#include + +#include +#include +#include + /* Provides detailed information about a process. */ +static const unsigned long _glibtop_sysdeps_proc_uid = +(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) + +(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) + +(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) + +(1 << GLIBTOP_PROC_UID_PGRP) + (1 << GLIBTOP_PROC_UID_SESSION) + +(1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID); + void glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { + struct tbl_procinfo procinfo; + task_basic_info_data_t taskinfo; + int ret, info_count; + task_t thistask; + + glibtop_init (); + memset (buf, 0, sizeof (glibtop_proc_uid)); + + /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + + setreuid (server->machine.uid, server->machine.euid); + + ret = table (TBL_PROCINFO, pid, (char *) &procinfo, 1, + sizeof (struct tbl_procinfo)); + + if (setreuid (server->machine.euid, server->machine.uid)) + _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + if (ret != 1) return; + + buf->uid = procinfo.pi_ruid; + buf->euid = procinfo.pi_svuid; + buf->gid = procinfo.pi_rgid; + buf->egid = procinfo.pi_svgid; + + buf->pid = procinfo.pi_pid; + buf->ppid = procinfo.pi_ppid; + buf->pgrp = procinfo.pi_pgrp; + buf->tty = procinfo.pi_ttyd; + buf->session = procinfo.pi_session; + buf->tpgid = procinfo.pi_tpgrp; + + buf->flags = _glibtop_sysdeps_proc_uid; + + /* !!! THE FOLLOWING CODE RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + + setreuid (server->machine.uid, server->machine.euid); + + /* Get task structure. */ + + ret = task_by_unix_pid (task_self(), procinfo.pi_pid, &thistask); + + if (ret == KERN_SUCCESS) { + + /* Get taskinfo about this task. */ + + info_count = TASK_BASIC_INFO_COUNT; + + ret = task_info (thistask, TASK_BASIC_INFO, + (task_info_t) &taskinfo, &info_count); + + } + + if (setreuid (server->machine.euid, server->machine.uid)) + _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + if (ret != KERN_SUCCESS) return; + + buf->priority = taskinfo.base_priority; + + buf->flags += (1 << GLIBTOP_PROC_UID_PRIORITY); + + errno = 0; + + ret = getpriority (PRIO_PROCESS, pid); + + if ((ret == -1) && (errno != 0)) return; + + buf->nice = ret; + + buf->flags += (1 << GLIBTOP_PROC_UID_NICE); } From d863bc7130fec93d1789ac6f8ca4255caa1707b9 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 19 May 1998 23:51:03 +0000 Subject: [PATCH 0011/2539] *** empty log message *** --- ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7e26b7cf..4693e508 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +1998-05-20 Martin Baulig + + * sysdeps/osf1/procuid.c (glibtop_get_proc_uid__r): + added implementation for DEC OSF/1. + + * sysdeps/sun4/uptime.c: forgot to checkin + + * sysdeps/sun4/loadavg.c: forgot to checkin + + * sysdeps/osf1/uptime.c: forgot to checkin + + * sysdeps/osf1/loadavg.c: forgot to checkin + 1998-05-19 Martin Baulig * sysdeps/stub/uptime.c: forgot this file all the From e1cdfc78c13d2baea7ad24271891ec32441ca360 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Wed, 20 May 1998 18:50:10 +0000 Subject: [PATCH 0012/2539] added definition of 'GTOP_GUILE_LIBS' and 'GTOP_GUILE_INCS': * gtopConf.sh.in: added definition of 'GTOP_GUILE_LIBS' and 'GTOP_GUILE_INCS': 'GTOP_LIBS' and 'GTOP_INCS' now contains everything that is needed to link with libgtop. 'GTOP_GUILE_LIBS' and 'GTOP_GUILE_INCS' now contains everything that is needed to link with libgtop and its guile interface. When guile cannot be found on the system or building of the guile interface was disables, they are identical to 'GTOP_LIBS' and 'GTOP_INCS' [FIXME: Should I make them empty in this case?] --- gtopConf.sh.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtopConf.sh.in b/gtopConf.sh.in index a7044717..5776f348 100644 --- a/gtopConf.sh.in +++ b/gtopConf.sh.in @@ -8,6 +8,9 @@ GTOP_INCLUDEDIR="@GTOP_INCLUDEDIR@" GTOP_LIBS="@GTOP_LIBS@" GTOP_INCS="@GTOP_INCS@" +GTOP_GUILE_LIBS="@GTOP_GUILE_LIBS@" +GTOP_GUILE_INCS="@GTOP_GUILE_INCS@" + GTOP_BINDIR="@GTOP_BINDIR@" GTOP_SERVER="@GTOP_SERVER@" From 6d3b740a2c9eb906f8f6ba23479968074579892a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Wed, 20 May 1998 20:56:12 +0000 Subject: [PATCH 0013/2539] added '--enable-libgtop-server' (default=auto), '--enable-libgtop-names' * acinclude.m4 (AC_LC_SYSDEPS): added '--enable-libgtop-server' (default=auto), '--enable-libgtop-names' (default=yes) and '--enable-libgtop-guile' (default=yes); we now define 'GLIBTOP_NAMES' here. * acconfig.h: added 'GLIBTOP_NAMES' and 'GLIBTOP_GUILE_NAMES' --- Makefile.am | 2 ++ acconfig.h | 3 +++ acinclude.m4 | 48 ++++++++++++++++++++++++++++++++++++++++++++- configure.in | 55 +++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 98 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index cfc36ad3..3b9eaeb0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,6 +32,8 @@ gtopConf.sh: gtopConf.sh.in Makefile -e 's,\@GTOP_INCLUDEDIR\@,$(includedir),g' \ -e 's,\@GTOP_LIBS\@,$(GTOP_LIBS),g' \ -e 's,\@GTOP_INCS\@,$(GTOP_INCS),g' \ + -e 's,\@GTOP_GUILE_LIBS\@,$(GTOP_GUILE_LIBS),g' \ + -e 's,\@GTOP_GUILE_INCS\@,$(GTOP_GUILE_INCS),g' \ -e 's,\@GTOP_BINDIR\@,$(GTOP_BINDIR),g' \ -e 's,\@GTOP_SERVER\@,$(GTOP_SERVER),g' \ -e 's,\@GTOP_SYSDEPS_DIR\@,$(sysdeps_dir),g' \ diff --git a/acconfig.h b/acconfig.h index 16425574..82742b69 100644 --- a/acconfig.h +++ b/acconfig.h @@ -28,3 +28,6 @@ #undef HAVE_GLIBTOP_MACHINE_H +#undef GLIBTOP_NAMES +#undef GLIBTOP_GUILE_NAMES + diff --git a/acinclude.m4 b/acinclude.m4 index d9148c37..8abbb232 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -29,7 +29,9 @@ AC_DEFUN([AC_LC_CANONICAL_HOST],[ AC_DEFUN([AC_LC_SYSDEPS],[ AC_REQUIRE([AC_LC_CANONICAL_HOST]) + AC_MSG_CHECKING(for sysdeps directory) + AC_ARG_WITH(sysdeps, [ --with-sysdeps=dir which sysdeps directory should be used [default=auto]], [if test "x$withval" = "xyes" ; then @@ -39,6 +41,7 @@ AC_DEFUN([AC_LC_SYSDEPS],[ else ac_cv_sysdeps_dir=$withval fi],[ac_cv_sysdeps_dir=yes]) + if test "x$ac_cv_sysdeps_dir" = "xyes" ; then case "$host_os" in linux*) @@ -68,13 +71,56 @@ AC_DEFUN([AC_LC_SYSDEPS],[ else sysdeps_dir=stub fi + test -d $srcdir/sysdeps/$sysdeps_dir || sysdeps_dir=stub AC_MSG_RESULT($sysdeps_dir) + + AC_MSG_CHECKING(whether we need the server) + + AC_ARG_ENABLE(libgtop-server, + [ --enable-libgtop-server use gtop_server [default=auto]], + [if test "x$enableval" = "xyes" ; then + need_server=yes + elif test "x$enableval" = "xno" ; then + need_server=no + fi]) + + AC_MSG_RESULT($need_server) + + AC_MSG_CHECKING(whether building of 'names' subdirs is requested) + + AC_ARG_ENABLE(libgtop-names, + [ --enable-libgtop-names enable building of 'names' subdirs [default=yes]], + [if test "x$enableval" = "xyes" ; then + ac_cv_want_names=yes + else + ac_cv_want_names=$enableval + fi],[ac_cv_names_subdir=yes]) + + AC_MSG_RESULT($ac_cv_want_names) + + AC_MSG_CHECKING(whether building of the guile interface is requested) + + AC_ARG_ENABLE(libgtop-guile, + [ --enable-libgtop-guile enable building of guile interface [default=yes]], + [if test "x$enableval" = "xyes" ; then + ac_cv_want_guile=yes + else + ac_cv_want_guile=$enableval + fi],[ac_cv_want_guile=yes]) + + AC_MSG_RESULT($ac_cv_want_guile) + + if test x$ac_cv_want_names = xyes ; then + AC_DEFINE(GLIBTOP_NAMES) + fi + + AM_CONDITIONAL(GLIBTOP_NAMES, test x$ac_cv_want_names = xyes) + AC_SUBST(sysdeps_dir) AC_SUBST(need_server) ]) - # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN(AM_CONFIG_HEADER, diff --git a/configure.in b/configure.in index ac7287f1..d024f429 100644 --- a/configure.in +++ b/configure.in @@ -26,15 +26,23 @@ export CC CXX RANLIB LD AS AR NM AC_LC_SYSDEPS -GNOME_CHECK_GUILE - -if test x$ac_cv_guile_found = xyes ; then - guile_examples='third third_static third_linux' - guile_subdirs='guile' +if test x$ac_cv_want_guile = xyes ; then + GNOME_CHECK_GUILE + if test x$ac_cv_guile_found = xyes ; then + if test x$ac_cv_want_names = xyes ; then + AC_DEFINE(GLIBTOP_GUILE_NAMES) + fi + guile_examples='third third_static third_linux' + guile_subdirs='guile' + else + guile_examples= + guile_subdirs= + fi else guile_examples= guile_subdirs= fi + AC_SUBST(guile_examples) AC_SUBST(guile_subdirs) @@ -99,24 +107,53 @@ if test "$need_libgtop_support" = yes; then fi dnl These definitions are expanded in make. -GTOP_LIBS='-L$(libdir) -lgtop_common -lgtop ' +GTOP_LIBS='-L$(libdir)' GTOP_INCS='-I$(includedir) -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/include' +GTOP_GUILE_LIBS="$GTOP_LIBS" +GTOP_GUILE_INCS="$GTOP_INCS" GTOP_BINDIR='$(bindir)' GTOP_SERVER='$(bindir)/gtop_server' -GTOP_INCS="$GTOP_INCS -I\$(top_srcdir)/intl -DGTOPLOCALEDIR=\\\"\$(datadir)/locale\\\"" +if test "x$ac_cv_guile_found" = "xyes" ; then + GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_guile" +fi + +if test "x$ac_cv_want_names" = "xyes" ; then + if test "x$ac_cv_guile_found" = "xyes" ; then + GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_guile_names" + fi + GTOP_LIBS="$GTOP_LIBS -lgtop_names" + GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_names" +fi + +GTOP_LIBS="$GTOP_LIBS -lgtop_common" +GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_common" + +if test "x$need_server" = "xyes" ; then + GTOP_LIBS="$GTOP_LIBS -lgtop" + GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop" +else + GTOP_LIBS="$GTOP_LIBS -lgtop_sysdeps" + GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_sysdeps" +fi if test "x$use_glibtop_machine_h" = "xyes" ; then GTOP_INCS="$GTOP_INCS -I\$(top_srcdir)/sysdeps/\$(sysdeps_dir)" fi +GTOP_INCS="$GTOP_INCS -I\$(top_srcdir)/intl -DGTOPLOCALEDIR=\\\\\"\$(datadir)/locale\\\\\"" + +GTOP_GUILE_INCS="$GTOP_INCS" + if test "x$ac_cv_guile_found" = "xyes" ; then - GTOP_INCS="$GTOP_INCS $GUILE_INCS" - GTOP_LIBS="$GTOP_LIBS $GUILE_LIBS" + GTOP_GUILE_INCS="$GTOP_INCS $GUILE_INCS" + GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS $GUILE_LIBS" fi AC_SUBST(GTOP_LIBS) AC_SUBST(GTOP_INCS) +AC_SUBST(GTOP_GUILE_LIBS) +AC_SUBST(GTOP_GUILE_INCS) AC_SUBST(GTOP_BINDIR) AC_SUBST(GTOP_SERVER) From 8bd9f46d1a42d81161e0ee2a097cca1108439e40 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Wed, 20 May 1998 21:01:04 +0000 Subject: [PATCH 0014/2539] only build 'names' subdir when necessary. * sysdeps/Makefile.am: only build 'names' subdir when necessary. --- sysdeps/Makefile.am | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sysdeps/Makefile.am b/sysdeps/Makefile.am index b80ead9c..c5e77c3c 100644 --- a/sysdeps/Makefile.am +++ b/sysdeps/Makefile.am @@ -4,4 +4,10 @@ else guile_SUBDIRS = endif -SUBDIRS = @sysdeps_dir@ common names $(guile_SUBDIRS) +if GLIBTOP_NAMES +names_SUBDIRS = names +else +names_SUBDIRS = +endif + +SUBDIRS = @sysdeps_dir@ common $(names_SUBDIRS) $(guile_SUBDIRS) From a6f0f33112617268ec70bf9b915b508621547589 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Wed, 20 May 1998 21:01:41 +0000 Subject: [PATCH 0015/2539] only build 'names' subdir when necessary. * sysdeps/guile/Makefile.am: only build 'names' subdir when necessary. --- sysdeps/guile/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am index c0972cc3..8c2696bb 100644 --- a/sysdeps/guile/Makefile.am +++ b/sysdeps/guile/Makefile.am @@ -1,4 +1,6 @@ +if GLIBTOP_NAMES SUBDIRS = names +endif LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ From bb959df4b22ed342efb4d7a6d6745711afb595c0 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Wed, 20 May 1998 21:04:10 +0000 Subject: [PATCH 0016/2539] added required check for 'GLIBGTOP_GUILE_NAMES'. * examples/third.c: added required check for 'GLIBGTOP_GUILE_NAMES'. --- examples/Makefile.am | 11 +++++++---- examples/third.c | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 6c50866d..5200b328 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -44,10 +44,14 @@ second_linux_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.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 +endif + third_SOURCES = third.c third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \ - $(top_builddir)/sysdeps/guile/names/libgtop_guile_names.la \ - $(top_builddir)/sysdeps/names/libgtop_names.la \ + $(third_guile_names_LIBS) $(third_names_LIBS) \ $(top_builddir)/sysdeps/common/libgtop_common.la \ $(top_builddir)/lib/libgtop.la \ @GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@ @@ -58,8 +62,7 @@ third_static_LDFLAGS = -static third_linux_SOURCES = $(third_SOURCES) third_linux_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \ - $(top_builddir)/sysdeps/guile/names/libgtop_guile_names.la \ - $(top_builddir)/sysdeps/names/libgtop_names.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@ diff --git a/examples/third.c b/examples/third.c index d4160425..9d1ce168 100644 --- a/examples/third.c +++ b/examples/third.c @@ -45,7 +45,9 @@ void main_prog (int argc, char *argv[]) { glibtop_boot_guile (); +#ifdef GLIBTOP_GUILE_NAMES glibtop_boot_guile_names (); +#endif gh_repl (argc, argv); } From f39948ae54e7d441b24484d0195d6bf8d8dfc1e1 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Wed, 20 May 1998 23:14:55 +0000 Subject: [PATCH 0017/2539] added more detailed description of today's changes. * NEWS: added more detailed description of today's changes. --- ChangeLog | 34 ++++++++++++++++++++++++++++++++++ NEWS | 25 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4693e508..f0326d7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,39 @@ 1998-05-20 Martin Baulig + * NEWS: added more detailed description of + today's changes. + + * examples/third.c: added required check for + 'GLIBGTOP_GUILE_NAMES'. + + * sysdeps/Makefile.am: only build 'names' subdir + when necessary. + + * sysdeps/guile/Makefile.am: only build 'names' + subdir when necessary. + + * acinclude.m4 (AC_LC_SYSDEPS): added + '--enable-libgtop-server' (default=auto), + '--enable-libgtop-names' (default=yes) and + '--enable-libgtop-guile' (default=yes); we + now define 'GLIBTOP_NAMES' here. + + * acconfig.h: added 'GLIBTOP_NAMES' and + 'GLIBTOP_GUILE_NAMES' + + * gtopConf.sh.in: added definition of 'GTOP_GUILE_LIBS' + and 'GTOP_GUILE_INCS': + + 'GTOP_LIBS' and 'GTOP_INCS' now contains everything + that is needed to link with libgtop. + + 'GTOP_GUILE_LIBS' and 'GTOP_GUILE_INCS' now contains + everything that is needed to link with libgtop and its + guile interface. When guile cannot be found on the system + or building of the guile interface was disables, they are + identical to 'GTOP_LIBS' and 'GTOP_INCS' + [FIXME: Should I make them empty in this case?] + * sysdeps/osf1/procuid.c (glibtop_get_proc_uid__r): added implementation for DEC OSF/1. diff --git a/NEWS b/NEWS index b9be53b9..28f6bcdb 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,30 @@ $Id$ +May/20/1998 +=========== + +* 'gtopConf.sh' now defines 'GTOP_LIBS' and 'GTOP_INCS' in a manner + that they contain everything that is needed to link some program with + libgtop. It will use '-lgtop' only if the server is really needed and + '-lgtop_sysdeps' otherwise; + +* 'gtopConf.sh' additionally defines 'GTOP_GUILE_LIBS' and 'GTOP_GUILE_INCS' + containing everything that is needed to link some program both with + libgtop and its guile interface. They are identically to 'GTOP_LIBS' + and 'GTOP_INCS' if building the guile interface is disabled or guile + cannot be found on the system. + +* 'configure' takes additional arguments '--enable-libgtop-server' and + '--disable-libgtop-server' to use the server even when it's not needed + or to disable it's use where it's needed. + +* 'configure' takes an argument '--without-libgtop-guile' to disable + guile support. + +* 'configure takes an argument '--without-libgtop-names' to remove + '-lgtop_names' (and '-lgtop_guile_names' when we have guile) from + 'GTOP_LIBS'; in this case these libraries are not even built. + May/19/1998 =========== From dec10a822158adc6850c4d6b06ae7faf2ef5ffba Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 17:37:51 +0000 Subject: [PATCH 0018/2539] INCLUDES no longer uses @GTOP_INCS@ which now points to where the stuff gets installed and now longer to the build directories. Added '-D_GNU_SOURCE' to INCLUDES. --- examples/Makefile.am | 4 +++- lib/Makefile.am | 4 +++- src/server/Makefile.am | 4 +++- sysdeps/common/Makefile.am | 4 +++- sysdeps/guile/Makefile.am | 4 +++- sysdeps/guile/names/Makefile.am | 6 +++--- sysdeps/linux/Makefile.am | 4 +++- sysdeps/names/Makefile.am | 6 +++--- sysdeps/osf1/Makefile.am | 5 +++-- sysdeps/stub/Makefile.am | 4 +++- sysdeps/sun4/Makefile.am | 4 +++- 11 files changed, 33 insertions(+), 16 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 5200b328..88bbc5ae 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -2,7 +2,9 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ diff --git a/lib/Makefile.am b/lib/Makefile.am index 5477b586..4c115f50 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,8 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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=\""@GTOP_SERVER@"\" diff --git a/src/server/Makefile.am b/src/server/Makefile.am index 6fe258f4..3c2ad0e0 100644 --- a/src/server/Makefile.am +++ b/src/server/Makefile.am @@ -1,6 +1,8 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ diff --git a/sysdeps/common/Makefile.am b/sysdeps/common/Makefile.am index 3fd5e649..b7d1c017 100644 --- a/sysdeps/common/Makefile.am +++ b/sysdeps/common/Makefile.am @@ -1,6 +1,8 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am index 8c2696bb..62143a93 100644 --- a/sysdeps/guile/Makefile.am +++ b/sysdeps/guile/Makefile.am @@ -4,7 +4,9 @@ endif LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ diff --git a/sysdeps/guile/names/Makefile.am b/sysdeps/guile/names/Makefile.am index 440bb955..24387126 100644 --- a/sysdeps/guile/names/Makefile.am +++ b/sysdeps/guile/names/Makefile.am @@ -1,11 +1,11 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ -DEFS = -DGLIBTOP_GUILE_NAMES @DEFS@ - lib_LTLIBRARIES = libgtop_guile_names.la libgtop_guile_names_la_SOURCES = boot.c sysdeps.c cpu.c mem.c swap.c uptime.c \ diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index 10a1d6f4..0c17dbea 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -1,6 +1,8 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ diff --git a/sysdeps/names/Makefile.am b/sysdeps/names/Makefile.am index 3cdc9dab..96e43037 100644 --- a/sysdeps/names/Makefile.am +++ b/sysdeps/names/Makefile.am @@ -1,11 +1,11 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ -DEFS = -DGLIBTOP_NAMES @DEFS@ - lib_LTLIBRARIES = libgtop_names.la libgtop_names_la_SOURCES = cpu.c mem.c swap.c uptime.c loadavg.c \ diff --git a/sysdeps/osf1/Makefile.am b/sysdeps/osf1/Makefile.am index 30765601..7903bcab 100644 --- a/sysdeps/osf1/Makefile.am +++ b/sysdeps/osf1/Makefile.am @@ -1,12 +1,13 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ lib_LTLIBRARIES = libgtop_sysdeps.la - libgtop_sysdeps_la_SOURCES = init.c open.c close.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 \ diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am index a1aac013..9c188950 100644 --- a/sysdeps/stub/Makefile.am +++ b/sysdeps/stub/Makefile.am @@ -1,6 +1,8 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ diff --git a/sysdeps/sun4/Makefile.am b/sysdeps/sun4/Makefile.am index 60b581f1..65d5a793 100644 --- a/sysdeps/sun4/Makefile.am +++ b/sysdeps/sun4/Makefile.am @@ -1,6 +1,8 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @GTOP_INCS@ +INCLUDES = -I$(includedir) -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@ From 57a44598b92b5a4daf2058b44a69b6268f367648 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 17:41:28 +0000 Subject: [PATCH 0019/2539] added 'machine_incs' which is used in 'INCLUDES' in several * acinclude.m4 (AC_LC_SYSDEPS): added 'machine_incs' which is used in 'INCLUDES' in several 'Makefile.am's; fixed typo 'ac_cv_want_names'; added missing AC_SUBST of 'use_glibtop_machine_h'. --- acinclude.m4 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 8abbb232..601f9dd1 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -95,7 +95,7 @@ AC_DEFUN([AC_LC_SYSDEPS],[ ac_cv_want_names=yes else ac_cv_want_names=$enableval - fi],[ac_cv_names_subdir=yes]) + fi],[ac_cv_want_names=yes]) AC_MSG_RESULT($ac_cv_want_names) @@ -117,7 +117,13 @@ AC_DEFUN([AC_LC_SYSDEPS],[ AM_CONDITIONAL(GLIBTOP_NAMES, test x$ac_cv_want_names = xyes) + if test x$use_glibtop_machine_h = xyes ; then + machine_incs="-I\$(top_srcdir)/sysdeps/$sysdeps_dir" + fi + + AC_SUBST(machine_incs) AC_SUBST(sysdeps_dir) + AC_SUBST(use_glibtop_machine_h) AC_SUBST(need_server) ]) From a83ab971d0188f366440ac6042f90edfa218677f Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 17:43:24 +0000 Subject: [PATCH 0020/2539] 'GTOP_INCS' and 'GTOP_LIBS' now really point to the places where * configure.in: 'GTOP_INCS' and 'GTOP_LIBS' now really point to the places where everything gets installed and no longer to the build directory, so that they can be used in 'gtopConf.sh'. --- configure.in | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/configure.in b/configure.in index d024f429..7c672b16 100644 --- a/configure.in +++ b/configure.in @@ -108,7 +108,7 @@ fi dnl These definitions are expanded in make. GTOP_LIBS='-L$(libdir)' -GTOP_INCS='-I$(includedir) -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/include' +GTOP_INCS='-I$(includedir)' GTOP_GUILE_LIBS="$GTOP_LIBS" GTOP_GUILE_INCS="$GTOP_INCS" GTOP_BINDIR='$(bindir)' @@ -137,14 +137,6 @@ else GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_sysdeps" fi -if test "x$use_glibtop_machine_h" = "xyes" ; then - GTOP_INCS="$GTOP_INCS -I\$(top_srcdir)/sysdeps/\$(sysdeps_dir)" -fi - -GTOP_INCS="$GTOP_INCS -I\$(top_srcdir)/intl -DGTOPLOCALEDIR=\\\\\"\$(datadir)/locale\\\\\"" - -GTOP_GUILE_INCS="$GTOP_INCS" - if test "x$ac_cv_guile_found" = "xyes" ; then GTOP_GUILE_INCS="$GTOP_INCS $GUILE_INCS" GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS $GUILE_LIBS" From afb564b63dc154ae2216d8e9d74eacb245860759 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 17:46:54 +0000 Subject: [PATCH 0021/2539] new file - sets output filename and directory for 'gnome-hackers.sgml'. * doc/gnome-hackers.dsl: new file - sets output filename and directory for 'gnome-hackers.sgml'. * doc/libgtop.dsl: most stuff from this file has moved to 'dbtohtml.dsl', it now only overrides the output filename and directory. * doc/dbtohtml.dsl: new file - contains most that was formerly in 'libgtop.dsl'. --- doc/dbtohtml.dsl | 1627 +++++++++++++++++++++++++++++++++++++++++ doc/gnome-hackers.dsl | 12 + doc/libgtop.dsl | 1621 +--------------------------------------- 3 files changed, 1642 insertions(+), 1618 deletions(-) create mode 100644 doc/dbtohtml.dsl create mode 100644 doc/gnome-hackers.dsl diff --git a/doc/dbtohtml.dsl b/doc/dbtohtml.dsl new file mode 100644 index 00000000..5947abc6 --- /dev/null +++ b/doc/dbtohtml.dsl @@ -0,0 +1,1627 @@ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; dbtohtml.dsl - DSSSL style sheet for DocBook to HTML conversion (jadeware) +; +; Author : Mark Burton (markb@ordern.com) +; Created On : Fri Jun 13 18:21:14 1997 +; Last Modified By: Mark Burton +; Last Modified On: Thu Jul 10 21:58:53 1997 +; +; $Id$ +; +; Usage: +; +; jade -d dbtohtml.dsl -t sgml yourdoc.sgm +; +; Additional command line options: +; +; -V %no-split-output% sends all the output to one file +; -V %no-make-index% disables index creation +; -V %no-make-toc% disables TOC creation +; -V %no-shade-screen% disables grey background to SCREEN regions +; -V %show-comments% includes contents of COMMENT regions + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Contributors + +; Mark Eichin (eichin@cygnus.com) +; Jason Molenda (crash@cygnus.co.jp) +; Mark Galassi (rosalia@cygnus.com) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Parameterisation + +; This style sheet can easily be parameterised by the use of a driver. +; Here is a simple example that sets the output file basename and directory. +; If the driver is foo.dsl, use: jade -d foo.dsl -t sgml yourdoc.sgm + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; declare non-standard functions + +(declare-flow-object-class element + "UNREGISTERED::James Clark//Flow Object Class::element") +(declare-flow-object-class empty-element + "UNREGISTERED::James Clark//Flow Object Class::empty-element") +(declare-flow-object-class document-type + "UNREGISTERED::James Clark//Flow Object Class::document-type") +(declare-flow-object-class processing-instruction + "UNREGISTERED::James Clark//Flow Object Class::processing-instruction") +(declare-flow-object-class entity + "UNREGISTERED::James Clark//Flow Object Class::entity") +(declare-flow-object-class entity-ref + "UNREGISTERED::James Clark//Flow Object Class::entity-ref") +(declare-flow-object-class formatting-instruction + "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction") + +(declare-characteristic preserve-sdata? + "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #f) +;; +;; try setting this to true to see if ISO character entities get translated +;;(declare-characteristic preserve-sdata? +;; "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #t) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; variables + +(define %no-split-output% #f) +(define %no-make-toc% #f) +(define %no-make-index% #f) +(define %no-shade-screen% #f) +(define %show-comments% #f) +(define %shade-width% "100%") ; width or #f +(define %email-element% "TT") ; font changing element or #f + +(define %html-public-id% "-//W3C//DTD HTML 3.2 Final//EN") +(define %body-bgcolor% "white") +(define %output-directory% ".") +(define %output-basename% "libgtop") +(define %output-suffix% ".shtml") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; top-level sections + +(define (book-common) + (cond (%no-split-output% ; everything goes in one file + (make-file (string-append %output-basename% %output-suffix%) + (make sequence + (process-children) + (cond ((not %no-make-index%) + (make sequence + (make-fat-rule) + (make-index))) + (#t (empty-sosofo)))))) + (#t ; split output into separate files + (make sequence + (make-file (string-append %output-basename% %output-suffix%) + (make sequence + (process-first-descendant "TITLE") + (process-first-descendant "BOOKINFO"))) + (process-matching-children "PREFACE" + "CHAPTER" + "APPENDIX" + "BIBLIOGRAPHY" + "GLOSSARY" + "ARTHEADER") + (cond ((not %no-make-index%) + (make-file (string-append %output-basename% + "-INDEX" + %output-suffix%) + (make-index))) + (#t (empty-sosofo))))))) + +(element BOOK (book-common)) + +(define generator-version + "Generated from Docbook 3.0 DTD, dbtohtml.dsl version $Revision$") + +(define (make-file file-name content) + (make entity + system-id: (string-append %output-directory% "/" file-name) + (make sequence + (make document-type + name: "html" + public-id: %html-public-id%) + (make formatting-instruction data: "<") + (make formatting-instruction data: "!--") + (literal generator-version) + (make formatting-instruction data: "--> +") + (make element + gi: "html" + (make sequence + (make element + gi: "head" + (make sequence + (make empty-element gi: "link" + attributes: (list (list "rel" "stylesheet") + (list "type" "text/css") + (list "href" "/style/docbook.css"))) + (make empty-element gi: "meta" + attributes: (list (list "name" "generator") + (list "content" generator-version))) + (make empty-element gi: "meta" + attributes: (list (list "name" "ObjectType") + (list "content" "book"))) + (make element + gi: "title" + (with-mode extract-title-text + (process-first-descendant "title"))))) + (make element + gi: "body" + attributes: (list (list "bgcolor" %body-bgcolor%)) + (make sequence + (make-anchor) + content + (make-footer) + (make formatting-instruction data: "<") + (make formatting-instruction data: "!--#include virtual=\"/includes/docbook_footer\"") + (make formatting-instruction data: "-->")))))))) + +(define (make-footer) + (let ((copyright (select-elements (descendants (book-node)) + '("COPYRIGHT" "BOOKINFO")))) + (cond ((node-list-empty? copyright) (empty-sosofo)) + (#t (make sequence + (make-fat-rule) + (process-node-list copyright)))))) + +(define (node-list-last nl) + (node-list-ref nl (- (node-list-length nl) 1))) + +(define (make-nav-links parent-gi) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "A" + attributes: (list (list "href" (link-file-name (ancestor parent-gi)))) + (literal "Up")) + (literal " ") + (if (absolute-last-sibling?) + (empty-sosofo) + (make element + gi: "A" + attributes: (list (list "href" + (link-file-name (node-list-first + (follow (current-node)))))) + (literal "Forward"))) + (literal " ") + (if (absolute-first-sibling?) + (empty-sosofo) + (make element + gi: "A" + attributes: (list (list "href" + (link-file-name (node-list-last + (preced (current-node)))))) + (literal "Back"))) + (make empty-element + gi: "P"))) + +(define (make-pref-chap-app) + (cond (%no-split-output% + (make sequence + (make-anchor) + (make-fat-rule) + (process-children))) + (#t + (make-file (link-file-name (current-node)) + (make sequence + (make-nav-links "BOOK") + (process-children) + (make-nav-links "BOOK")))))) + +;;(element ARTICLE (process-children)) +(element ARTICLE (book-common)) + +(element PREFACE (make-pref-chap-app)) + +(element CHAPTER (make-pref-chap-app)) + +(element APPENDIX (make-pref-chap-app)) + +(element BEGINPAGE (make sequence + (make empty-element gi: "P") + (make empty-element gi: "HR"))) + +(element BIBLIOGRAPHY (make-pref-chap-app)) + +(element BOOKBIBLIO (process-children)) + +(element BIBLIODIV (process-children)) + +(element GLOSSARY (make-pref-chap-app)) + +; (element GLOSSDIV (make-pref-chap-app)) + +;;(element ARTHEADER (make-pref-chap-app)) +(element ARTHEADER + (make sequence + (cond ((not %no-make-toc%) + (make sequence + (make-fat-rule) + (make element + gi: "h2" + attributes: (list "align" "center") + (literal "Contents")) + (make element + gi: "ul" + attributes: (list "align" "center") + (with-mode make-toc-links + (process-node-list (book-node)))))) + (#t (empty-sosofo))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; sections + +(element SECT1 + (make sequence + (make-anchor) + (process-children))) + +(element SECT2 + (make sequence + (make-anchor) + (process-children))) + +(element SECT3 + (make sequence + (make-anchor) + (process-children))) + +(element SECT4 + (make sequence + (make-anchor) + (process-children))) + +(element SECT5 + (make sequence + (make-anchor) + (process-children))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; titles + +(mode extract-title-text + (element (TITLE) + (process-children))) + +(mode extract-title-text + (element (BRIDGEHEAD) + (process-children))) + +(element (BOOK TITLE) + (make element + gi: "h1" + attributes: (list "align" "center") + (process-children))) + +(element (ARTICLE TITLE) + (make element + gi: "h1" + attributes: (list "align" "center") + (process-children))) + +(element (CHAPTER TITLE) + (make sequence + (make element + gi: "h1" + (make sequence + (literal (chap-app-head-label "Chapter")) + (process-children-trim))))) + +(element (PREFACE TITLE) + (make element + gi: "h1" + (make sequence + (literal "Preface: ") + (process-children-trim)))) + +(element (APPENDIX TITLE) + (make element + gi: "H1" + (make sequence + (literal (chap-app-head-label "Appendix")) + (process-children-trim)))) + +(element (BIBLIOGRAPHY TITLE) + (make element gi: "H1" + (make sequence + (literal (chap-app-head-label "Bibliography")) + (process-children-trim)))) + +(element (BOOKBIBLIO TITLE) + (make element gi: "H2" + (make sequence +;;; (literal (chap-app-head-label "Bibliography")) + (process-children-trim)))) + +(element (BIBLIODIV TITLE) + (make element gi: "H2" + (make sequence + (process-children-trim)))) + +(element (GLOSSARY TITLE) + (make element gi: "H1" + (make sequence + (literal "Glossary") +; (process-children-trim) +))) + +(element (GLOSSDIV TITLE) + (make element gi: "H2" + (process-children-trim))) + +(element (ARTHEADER TITLE) + (make element gi: "H1" + (process-children-trim))) + +(element (ARTHEADER DATE) + (make element gi: "P")) + +(element (ARTHEADER SUBTITLE) + (make element + gi: "H2" + (make element + gi: "i" + (process-children-trim) + ))) + +(element (SECT1 TITLE) (make element gi: "H2")) + +(element (SECT2 TITLE) (make element gi: "H3")) + +(element (SECT3 TITLE) (make element gi: "H4")) + +(element (SECT4 TITLE) (make element gi: "H5")) + +(element (SECT5 TITLE) (make element gi: "H6")) + +(element (FORMALPARA TITLE) (make element gi: "H6")) + +(element BRIDGEHEAD (make element gi: "H4")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; font changers + +(element EMPHASIS + (make element gi: "EM")) + +(element TYPE + (make element gi: "STRONG" + (make element gi: "TT"))) + +(element TOKEN + (make element gi: "EM" + (make element gi: "STRONG" + (make element gi: "TT")))) + +(element REPLACEABLE (make element gi: "EM")) + +(element FIRSTTERM (make element gi: "EM")) + +(element APPLICATION (make element gi: "TT")) + +(element FILENAME (make element gi: "TT")) + +(element LITERAL (make element gi: "TT")) + +(element GUIMENU (make element gi: "TT")) +(element GUIMENUITEM (make element gi: "TT")) + +(element ENVAR (make element gi: "TT")) + +(element SUBSCRIPT (make element gi: "SUB")) + +(element SUPERSCRIPT (make element gi: "SUP")) + +(element CITATION (process-children)) +(element CITETITLE (make element gi: "I")) + +(element COMMAND (make element gi: "TT")) + +(element STRUCTFIELD (make element gi: "TT")) + +(element OPTION (make element gi: "TT")) + +(element USERINPUT (make element gi: "TT")) + +(element COMPUTEROUTPUT (make element gi: "TT")) + +(element PROMPT (make element gi: "TT")) + +(element PRODUCTNAME (make element gi: "I")) + +(element SGMLTAG (make element gi: "TT")) +(element CLASSNAME (make element gi: "TT")) +(element SYMBOL (make element gi: "TT")) +(element LITERALLAYOUT (make element gi: "PRE")) +(element PROGRAMLISTING (make element gi: "PRE")) + +(element FOREIGNPHRASE (make element gi: "I")) + +;; I think that title abbreviations don't really have a place in HTML. +;; The only place in which I can imagine them being useful is if the +;; HTML secret title (the one that goes in your bookmarks and stuff) +;; is derived from the DocBook title abbrev +;; +;; (element ABBREV (process-children-trim)) +(element ABBREV (empty-sosofo)) +(element TITLEABBREV (empty-sosofo)) + +(element EMAIL + (if %email-element% + (make element + gi: %email-element% + (process-children-trim)) + (process-children-trim))) + +(element QUOTE + (make sequence + (make entity-ref + name: "quot") + (process-children-trim) + (make entity-ref + name: "quot"))) + +(element ADDRESS + (make element + gi: "address" + (make element + gi: "em" + (process-children-trim)))) + +(element (ADDRESS CITY) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS COUNTRY) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS EMAIL) + (make sequence + (make empty-element + gi: "BR") + ;; Now throw some space between street address and the email + ;; address. Sadly, the only way I know how to do it in HTML is to + ;; throw in an empty paragraph tag. + (make empty-element + gi: "spacer" + attributes: '(("align" "vertical") ("size" "10"))) + (if %email-element% + (make element + gi: %email-element% + (process-children-trim)) + (process-children-trim)))) + +(element (ADDRESS FAX) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS OTHERADDR) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS POB) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS PHONE) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS POSTCODE) + (process-children-trim)) + +(element (ADDRESS STATE) + (process-children-trim)) + +(element (ADDRESS STREET) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; paragraph like things + +(element CAUTION (make-special-para)) + +(element IMPORTANT (make-special-para)) + +(element WARNING (make-special-para)) + +(element NOTE (make-special-para)) + +(element TIP (make-special-para)) + +(element EXAMPLE (make-special-para)) + +(element INFORMALEXAMPLE + (make element + gi: "BLOCKQUOTE")) + +(element COMMENT + (cond (%show-comments% + (make element + gi: "FONT" + attributes: '(("color" "red")) + (make-special-para))) + (#t (empty-sosofo)))) + +(element PARA + (make sequence + (make empty-element + gi: "P") + (with-mode footnote-ref + (process-children)) + (with-mode footnote-def + (process-matching-children "FOOTNOTE")))) + +(element BLOCKQUOTE (make element gi: "BLOCKQUOTE")) + +(element SCREEN + (let ((gubbins (make element + gi: "PRE" + (process-children)))) + (make sequence + (make empty-element + gi: "P") + (if %no-shade-screen% + gubbins + (make element + gi: "TABLE" + attributes: (append (list '("border" "0") + '("bgcolor" "#E0E0E0")) + (if %shade-width% + (list (list "width" %shade-width%)) + '())) + (make element + gi: "TR" + (make element + gi: "TD" + gubbins))))))) + +(element FORMALPARA (process-children)) + +(element PHRASE (maybe-bold-children)) + +(mode footnote-ref + (element FOOTNOTE + (make sequence + (literal "[") + (literal (format-number (element-number (current-node)) "1")) + (literal "]")))) + +(mode footnote-def + (element FOOTNOTE + (make element + gi: "BLOCKQUOTE" + (make sequence + (literal "[") + (literal (format-number (element-number (current-node)) "1")) + (literal "]") + (process-children))))) + +(element (CAUTION TITLE) + (make element + gi: "H5")) + +(element (IMPORTANT TITLE) + (make element + gi: "H5")) + +(element (WARNING TITLE) + (make element + gi: "H5")) + +(element (NOTE TITLE) + (make element + gi: "H5")) + +(element (TIP TITLE) + (make element + gi: "H5")) + +(element (EXAMPLE TITLE) + (make element + gi: "H5")) + +(element (BIBLIOENTRY TITLE) + (make element + gi: "H3")) + +(element (BIBLIOENTRY PAGENUMS) + (make sequence + (literal "Pages: ") + (make element gi: "I"))) + +(element (BIBLIOENTRY DATE) + (make sequence + (literal " Date: ") + (make element gi: "I"))) + +(element (BIBLIOENTRY VOLUMENUM) + (make sequence + (literal " Volume: ") + (make element gi: "I"))) + +(element (BIBLIOENTRY SERIESINFO) (process-children)) + +(element (BIBLIOENTRY SERIESINFO TITLE) + (make element gi: "H4")) + +(element (BIBLIOENTRY BIBLIOMISC) + (make sequence + (literal " other: ") + (process-children))) + +; the para inside does the work, here... +(element (BIBLIOENTRY ABSTRACT) (process-children)) + +;; an article'sabstract is centered text +(element ABSTRACT + (make sequence + (make empty-element gi: "HR") + (make element + gi: "H2" + (literal "Abstract")) + (make element + gi: "DIV" + attributes: (list (list "align" "left")) + (make element gi: "BLOCKQUOTE" + (process-children))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; lists + +(element ITEMIZEDLIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "UL"))) + +(element ORDEREDLIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "OL"))) + +(element PROCEDURE + (make sequence + (make empty-element + gi: "P") + (make element + gi: "OL"))) + +(element SIMPLELIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "UL"))) + +(element (ITEMIZEDLIST LISTITEM) + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element (ORDEREDLIST LISTITEM) + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element STEP + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element (SIMPLELIST MEMBER) + (make sequence + (make empty-element + gi: "LI") + (process-children))) + +(element VARIABLELIST + (make sequence + (make empty-element + gi: "P") + (make element + gi: "DL"))) + +(element VARLISTENTRY + (make sequence + (make empty-element + gi: "DT") + (process-children))) + +(element (VARLISTENTRY LISTITEM) + (make sequence + (make empty-element + gi: "DD") + (process-children) + (make empty-element + gi: "P"))) + +(element TERM (maybe-bold-children)) + +(element GLOSSDIV + (make sequence + (make empty-element + gi: "P") + (make element + gi: "DL"))) + +; (define (gloss-entry-name indexterm) +; (string-append "gloss." (format-number (element-number indexterm) "1"))) +(define (gloss-entry-name glossterm) + (string-append "gloss." (data glossterm))) + +(element GLOSSENTRY + (process-children)) + +(element (GLOSSENTRY GLOSSTERM) + (make sequence + (make empty-element + gi: "DT") + (make empty-element + gi: "A" + attributes: (list (list "name" (gloss-entry-name (current-node))))) + (process-children))) + + +(element (GLOSSENTRY GLOSSDEF) + (make sequence + (make empty-element + gi: "DD") + (process-children) + (make empty-element + gi: "P"))) + +(element (GLOSSENTRY GLOSSSEE) + (make sequence + (make empty-element + gi: "DD") + (literal "See ") + (make element + gi: "A" + attributes: (list (list "href" + (string-append "#" + (gloss-entry-name (current-node))) + ))) + (make empty-element + gi: "P"))) + +; (element GLOSSTERM (maybe-bold-children)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; index + +(define (index-entry-name indexterm) + (string-append "index." (format-number (element-number indexterm) "1"))) + +(element INDEXTERM + (make sequence + (make element + gi: "A" + attributes: (list (list "name" (index-entry-name (current-node)))) + (literal "")) + (empty-sosofo))) + +; DIY string-ci>? + +(define (string-ci>? s1 s2) + (let ((len1 (string-length s1)) + (len2 (string-length s2))) + (let loop ((i 0)) + (cond ((= i len1) #f) + ((= i len2) #t) + (#t (let ((c1 (index-char-val (string-ref s1 i))) + (c2 (index-char-val (string-ref s2 i)))) + (cond + ((= c1 c2) (loop (+ i 1))) + (#t (> c1 c2))))))))) + +(define (index-char-val ch) + (case ch + ((#\A #\a) 65) + ((#\B #\b) 66) + ((#\C #\c) 67) + ((#\D #\d) 68) + ((#\E #\e) 69) + ((#\F #\f) 70) + ((#\G #\g) 71) + ((#\H #\h) 72) + ((#\I #\i) 73) + ((#\J #\j) 74) + ((#\K #\k) 75) + ((#\L #\l) 76) + ((#\M #\m) 77) + ((#\N #\n) 78) + ((#\O #\o) 79) + ((#\P #\p) 80) + ((#\Q #\q) 81) + ((#\R #\r) 82) + ((#\S #\s) 83) + ((#\T #\t) 84) + ((#\U #\u) 85) + ((#\V #\v) 86) + ((#\W #\w) 87) + ((#\X #\x) 88) + ((#\Y #\y) 89) + ((#\Z #\z) 90) + + ((#\ ) 32) + + ((#\0) 48) + ((#\1) 49) + ((#\2) 50) + ((#\3) 51) + ((#\4) 52) + ((#\5) 53) + ((#\6) 54) + ((#\7) 55) + ((#\8) 56) + ((#\9) 57) + + ; laziness precludes me from filling this out further + (else 0))) + +(define (string->number-list s) + (let loop ((i (- (string-length s) 1)) + (l '())) + (if (< i 0) + l + (loop (- i 1) (cons (index-char-val (string-ref s i)) l))))) + +(define (number-list>? l1 l2) + (cond ((null? l1) #f) + ((null? l2) #t) + ((= (car l1) (car l2)) + (number-list>? (cdr l1) (cdr l2))) + (#t (> (car l1) (car l2))))) + +; return the string data for a given index entry + +(define (get-index-entry-data entry) + (let ((primary (select-elements (descendants entry) "PRIMARY")) + (secondary (select-elements (descendants entry) "SECONDARY"))) + (if (node-list-empty? secondary) + (data primary) + (string-append (data primary) " - " (data secondary))))) + +(define (make-index-entry entry) + (let ((text (get-index-entry-data entry))) + (cons text + (make sequence + (make empty-element + gi: "LI") + (make element + gi: "A" + attributes: (list (list "href" + (string-append (link-file-name + entry) + "#" + (index-entry-name + entry)))) + (literal text)))))) + +(define (build-index nl) + (let loop ((result '()) + (nl nl)) + (if (node-list-empty? nl) + result + (loop (cons (make-index-entry (node-list-first nl)) result) + (node-list-rest nl))))) + +(define (sort-index il) + (letrec ((list-head (lambda (l n) + (if (> n 0) + (cons (car l) (list-head (cdr l) (- n 1))) + '()))) + (merge (lambda (il1 il2) + (cond ((null? il1) il2) + ((null? il2) il1) + ((string-ci>? (car (car il1)) (car (car il2))) + (cons (car il2) (merge il1 (cdr il2)))) + (#t + (cons (car il1) (merge (cdr il1) il2))))))) + (let* ((ll (length il)) + (ldiv2 (quotient ll 2))) + (if (> 2 ll) + il + (merge (sort-index (list-head il ldiv2)) + (sort-index (list-tail il ldiv2))))))) + +(define (output-index il) + (let extract-and-append ((il il) + (result (empty-sosofo))) + (if (null? il) + result + (extract-and-append (cdr il) (sosofo-append result (cdr (car il))))))) + +(define (make-index) + (make sequence + (make element + gi: "A" + attributes: (list (list "name" "INDEXTOP")) + (literal "")) + (make element + gi: "H1" + (literal "Index")) + (make element + gi: "UL" + (output-index + (sort-index + (build-index (select-elements (descendants (current-node)) + "INDEXTERM"))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; links & cross-references + +(define (link-file-name target) + (cond (%no-split-output% "") + (#t + (string-append + %output-basename% + (cond ((equal? (gi target) "CHAPTER") + (string-append + "-" + (format-number (child-number target) "1"))) + ((ancestor-child-number "CHAPTER" target) + (string-append + "-" + (format-number (ancestor-child-number "CHAPTER" target) "1"))) + ((equal? (gi target) "APPENDIX") + (string-append + "-" + (format-number (child-number target) "A"))) + ((ancestor-child-number "APPENDIX" target) + (string-append + "-" + (format-number (ancestor-child-number "APPENDIX" target) "A"))) + (#t "")) + %output-suffix%)))) + +(element ANCHOR + (make-anchor)) + +(element LINK + (let* ((target (element-with-id (attribute-string "linkend") + (book-node))) + (target-file-name (link-file-name target)) + (endterm (attribute-string "endterm")) + (target-title-sosofo (if endterm + (with-mode extract-xref-text + (process-node-list + (element-with-id endterm + (book-node)))) + (process-children)))) + (make element + gi: "A" + attributes: (list + (list "href" + (string-append + target-file-name + "#" + (attribute-string "linkend")))) + target-title-sosofo))) +(element ULINK + (make element + gi: "A" + attributes: (list + (list "href" (attribute-string "url"))))) + +(element XREF + (let* ((target (element-with-id (attribute-string "LINKEND") + (book-node))) + (target-file-name (link-file-name target))) + (make element + gi: "A" + attributes: (list + (list "href" + (string-append target-file-name + "#" + (attribute-string "linkend")))) + (with-mode extract-xref-text + (process-node-list target))))) + +(mode extract-xref-text + (default + (let ((title-sosofo (with-mode extract-title-text + (process-first-descendant "TITLE")))) + (if (sosofo? title-sosofo) + title-sosofo + (literal (string-append "Reference to " (gi))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; figures + +(element FIGURE + (make sequence + (make empty-element + gi: "P") + (make-anchor) + (process-children) + (make empty-element + gi: "P"))) + +(element (FIGURE TITLE) + (make sequence + (make element + gi: "B") + (make empty-element + gi: "P"))) + +(element GRAPHIC + (let ((img + (make sequence + (make empty-element + gi: "P") + (make empty-element + gi: "IMG" + attributes: (list + (list "src" + (string-append (attribute-string "fileref") + ".gif"))))))) + (if (equal? + (attribute-string "align") + "CENTER") + (make element + gi: "CENTER" + img) + img))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; tables + +(element TABLE + (make sequence + (make empty-element + gi: "P") + (make element + gi: "TABLE" + attributes: (if (equal? + (attribute-string "frame") + "ALL") + '(("border" "2") ("cellpadding" "2")) + '())) + (make empty-element + gi: "P"))) + +(element (TABLE TITLE) + (make element + gi: "H4" + (make sequence + (literal "Table: ") + (process-children-trim)))) + +(element INFORMALTABLE + (make sequence + (make empty-element + gi: "P") + (make element + gi: "TABLE" + attributes: (if (equal? + (attribute-string "frame") + "ALL") + '(("border" "2") ("cellpadding" "2")) + '())) + (make empty-element + gi: "P"))) + +(element TGROUP (process-children)) + +(element THEAD (process-children)) + +(element (THEAD ROW) + (make sequence + (make empty-element + gi: "TR") + (process-children))) + +(element (THEAD ROW ENTRY) + (make sequence + (make empty-element + gi: "TD") + (make element + gi: "B" + (process-children)))) + +(element TBODY (process-children)) + +(element (TBODY ROW) + (make sequence + (make empty-element + gi: "TR") + (process-children))) + + +(element (TBODY ROW ENTRY) + (make sequence + (make empty-element + gi: "TD") + (process-children))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; book info + +(element BOOKINFO + (make sequence + (make element + gi: "CENTER" + (process-children)) + (cond ((not %no-make-toc%) + (make sequence + (make-fat-rule) + (make element + gi: "H2" + (literal "Contents")) + (make element + gi: "ul" + (with-mode make-toc-links + (process-node-list (book-node)))))) + (#t (empty-sosofo))))) + +(element (BOOKINFO DATE) + (make element gi: "P")) + +(element (BOOKINFO TITLE) + (make element gi: "H1")) + +(element (BOOKINFO SUBTITLE) + (make element + gi: "H2" + (make element + gi: "i" + (process-children-trim) + ))) + +(element AUTHORGROUP + (let ((reducer (lambda (sofar new) + (sosofo-append sofar (make element + gi: "H2" + (process-node-list new)))))) + (make sequence + (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") + reducer + (empty-sosofo))))) + +;; I make a new left-aligned DIV sandwiched between HRs for the author +;; blurb. +(element AUTHORBLURB + (make sequence + (make empty-element gi: "HR") + (make element + gi: "DIV" + attributes: '(("align" "left")) + (make element + gi: "h4" + attributes: '(("align" "left")) + (literal "Author blurb for ") + (make element + gi: "i" + (process-matching-children "TITLE") + (literal ":"))) + (process-matching-children "FORMALPARA" "PARA" "SIMPARA")) + (make empty-element gi: "HR"))) + +(element (AUTHORBLURB TITLE) + (make element gi: "B")) + +(element CORPNAME + (make element gi: "H2")) + +(element (BIBLIOENTRY AUTHORGROUP) + (let ((reducer (lambda (sofar new) + (sosofo-append sofar (make element + gi: "H3" + (process-node-list new)))))) + (make sequence + (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") + reducer + (empty-sosofo))))) + +(element COPYRIGHT + (make element + gi: "H4" + (make sequence + (make entity-ref + name: "copy") + (process-matching-children "HOLDER") + (process-matching-children "YEAR")))) + +(element HOLDER + (make sequence + (literal " ") + (process-children-trim))) + +(element YEAR + (make sequence + (literal " ") + (process-children-trim))) + +(element CORPAUTHOR + (process-children-trim)) + +(element AUTHOR + (process-children-trim)) + +(element EDITOR + (process-children-trim)) + +(element CONFGROUP + (process-children-trim)) + +(element CONFTITLE + (make sequence + (make empty-element + gi: "BR") + (make element gi: "I" (process-children)))) + +(element CONFDATES + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element HONORIFIC + (make sequence + (process-children-trim) + (literal " "))) + +(element FIRSTNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element OTHERNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element SURNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element LINEAGE + (make sequence + (process-children-trim) + (literal " "))) + +(element TRADEMARK (process-children)) + +(element PUBLISHERNAME (process-children)) + +(element BIBLIOENTRY (process-children)) + +(element ACRONYM (process-children)) + +(element RELEASEINFO + (make sequence + (make empty-element + gi: "BR") + (make element gi: "B"))) + +(element AFFILIATION + (make sequence + (make element + gi: "I"))) + +(element ORGNAME + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +;;(element ORGNAME +;; (process-children)) + +(element JOBTITLE + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element ORGDIV + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element PUBLISHER + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element ISBN + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element PUBDATE + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element REVHISTORY + (empty-sosofo)) + +(element LEGALNOTICE + (make sequence + (make element + gi: "H4" + attributes: '(("align" "left")) + (literal "Legal Notice: ")) + (make element + gi: "DIV" + attributes: '(("align" "left"))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Synopses for command line, API functions and so forth +;;(element FUNCSYNOPSIS +;; (process-children)) + +(element FUNCSYNOPSIS + (make sequence + (make empty-element gi: "P") ; go to a new line + ;; just in case there is some synopsisinfo, like #include directives + (process-matching-children "FUNCSYNOPSISINFO") + (make empty-element gi: "P") ; go to a new line + (process-matching-children "FUNCDEF") ; this gives the function name + (literal " (") + (process-matching-children "PARAMDEF") ; this gives the function arguments + (literal ")") + )) + +(element FUNCDEF + (make element gi: "TT")) + +(element FUNCTION + (make element gi: "B")) + +(element STRUCTNAME + (make element gi: "B")) + +(element FUNCSYNOPSISINFO + (make element + gi: "PRE")) + +(element PARAMDEF + (make element + gi: "TT")) + +(element PARAMETER + (make element + gi: "I")) + +(element FUNCPROTOTYPE + (make element + gi: "PRE")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; TOC + +(element LOF (empty-sosofo)) + +(element LOT (empty-sosofo)) + +(element TOC (empty-sosofo)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; DIY TOC + +(mode make-toc-links + (element (BOOK) + (sosofo-append + (process-children) + (cond ((not %no-make-index%) + (make sequence + (make empty-element + gi: "LI") + (make element + gi: "A" + attributes: (list (list "href" + (cond (%no-split-output% "#INDEXTOP") + (#t + (string-append %output-basename% + "-INDEX" + %output-suffix% + "#INDEXTOP"))))) + (literal "Index")))) + (#t (empty-sosofo))))) + (element (CHAPTER) + (make-chap-or-app-toc-links)) + (element (APPENDIX) + (make-chap-or-app-toc-links)) + (element (SECT1) + (make sequence + (make empty-element + gi: "LI") + (let ((title-text (with-mode extract-title-text + (process-first-descendant "TITLE")))) + (if (id) + (make element + gi: "A" + attributes: (list (list "href" (string-append (link-file-name (current-node)) + "#" + (id)))) + title-text) + title-text)))) + (default + (empty-sosofo))) + +(define (make-chap-or-app-toc-links) + (make sequence + (make empty-element + gi: "LI") + (let ((title-text + (make sequence + (literal (if (equal? (gi) "CHAPTER") + (string-append "Chapter " + (format-number + (element-number (current-node)) + "1") + " - ") + (string-append "Appendix " + (format-number + (element-number (current-node)) + "A") + " - "))) + (with-mode extract-title-text + (process-first-descendant "TITLE"))))) + (if (id) + (make element + gi: "A" + attributes: (list (list "href" (string-append (link-file-name (current-node)) + "#" + (id)))) + title-text) + title-text)) + (make element + gi: "UL" + (with-mode make-toc-links + (process-matching-children "SECT1"))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; make the unimplemented bits stand out + +(default + (make element + gi: "FONT" + attributes: '(("color" "red")) + (make sequence + (literal (string-append "<" (gi) ">")) + (process-children) + (literal (string-append ""))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; standard subroutines + +(define (node-list-reduce nl combine init) + (if (node-list-empty? nl) + init + (node-list-reduce (node-list-rest nl) + combine + (combine init (node-list-first nl))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; various homebrew subroutines + +(define (book-node) + (cond ((equal? (gi) "BOOK") (current-node)) + (#t (let ((book-root (ancestor "BOOK"))) + (if (node-list-empty? book-root) + (cond ((equal? (gi) "CHAPTER") (current-node)) + (#t (ancestor "CHAPTER"))) + book-root))))) + +(define (make-fat-rule) + (make sequence + (make empty-element gi: "P") + (make empty-element gi: "HR"))) + +(define (chap-app-head-label chap-or-app) + (let ((label + (attribute-string "label" (ancestor chap-or-app)))) + (string-append + chap-or-app + " " + (if label + (if (equal? label "auto") + (format-number + (element-number (ancestor chap-or-app)) + (if (equal? chap-or-app "Chapter") "1" "A")) + label) + (format-number + (element-number (ancestor chap-or-app)) + (if (equal? chap-or-app "Chapter") "1" "A"))) + ". "))) + +(define (make-anchor) + (if (id) + (make element + gi: "A" + attributes: (list (list "name" (id))) + (literal "")) + (empty-sosofo))) + +(define (make-special-para) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "B" + (literal (string-append (gi) ":"))) + (make element + gi: "BLOCKQUOTE" + (process-children)))) + +(define (maybe-bold-children) + (cond ((equal? (attribute-string "role") + "bold") + (make element + gi: "B" + (process-children-trim))) + (#t (process-children-trim)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; the end diff --git a/doc/gnome-hackers.dsl b/doc/gnome-hackers.dsl new file mode 100644 index 00000000..dfecdeed --- /dev/null +++ b/doc/gnome-hackers.dsl @@ -0,0 +1,12 @@ + +]> + + + +(define %output-basename% "gnome-hackers") +(define %output-directory% "gnome-hackers") + + + + diff --git a/doc/libgtop.dsl b/doc/libgtop.dsl index 5947abc6..00deca64 100755 --- a/doc/libgtop.dsl +++ b/doc/libgtop.dsl @@ -1,1627 +1,12 @@ - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; dbtohtml.dsl - DSSSL style sheet for DocBook to HTML conversion (jadeware) -; -; Author : Mark Burton (markb@ordern.com) -; Created On : Fri Jun 13 18:21:14 1997 -; Last Modified By: Mark Burton -; Last Modified On: Thu Jul 10 21:58:53 1997 -; -; $Id$ -; -; Usage: -; -; jade -d dbtohtml.dsl -t sgml yourdoc.sgm -; -; Additional command line options: -; -; -V %no-split-output% sends all the output to one file -; -V %no-make-index% disables index creation -; -V %no-make-toc% disables TOC creation -; -V %no-shade-screen% disables grey background to SCREEN regions -; -V %show-comments% includes contents of COMMENT regions - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Contributors - -; Mark Eichin (eichin@cygnus.com) -; Jason Molenda (crash@cygnus.co.jp) -; Mark Galassi (rosalia@cygnus.com) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Parameterisation - -; This style sheet can easily be parameterised by the use of a driver. -; Here is a simple example that sets the output file basename and directory. -; If the driver is foo.dsl, use: jade -d foo.dsl -t sgml yourdoc.sgm - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; declare non-standard functions - -(declare-flow-object-class element - "UNREGISTERED::James Clark//Flow Object Class::element") -(declare-flow-object-class empty-element - "UNREGISTERED::James Clark//Flow Object Class::empty-element") -(declare-flow-object-class document-type - "UNREGISTERED::James Clark//Flow Object Class::document-type") -(declare-flow-object-class processing-instruction - "UNREGISTERED::James Clark//Flow Object Class::processing-instruction") -(declare-flow-object-class entity - "UNREGISTERED::James Clark//Flow Object Class::entity") -(declare-flow-object-class entity-ref - "UNREGISTERED::James Clark//Flow Object Class::entity-ref") -(declare-flow-object-class formatting-instruction - "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction") - -(declare-characteristic preserve-sdata? - "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #f) -;; -;; try setting this to true to see if ISO character entities get translated -;;(declare-characteristic preserve-sdata? -;; "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #t) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; variables - -(define %no-split-output% #f) -(define %no-make-toc% #f) -(define %no-make-index% #f) -(define %no-shade-screen% #f) -(define %show-comments% #f) -(define %shade-width% "100%") ; width or #f -(define %email-element% "TT") ; font changing element or #f - -(define %html-public-id% "-//W3C//DTD HTML 3.2 Final//EN") -(define %body-bgcolor% "white") -(define %output-directory% ".") -(define %output-basename% "libgtop") -(define %output-suffix% ".shtml") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; top-level sections - -(define (book-common) - (cond (%no-split-output% ; everything goes in one file - (make-file (string-append %output-basename% %output-suffix%) - (make sequence - (process-children) - (cond ((not %no-make-index%) - (make sequence - (make-fat-rule) - (make-index))) - (#t (empty-sosofo)))))) - (#t ; split output into separate files - (make sequence - (make-file (string-append %output-basename% %output-suffix%) - (make sequence - (process-first-descendant "TITLE") - (process-first-descendant "BOOKINFO"))) - (process-matching-children "PREFACE" - "CHAPTER" - "APPENDIX" - "BIBLIOGRAPHY" - "GLOSSARY" - "ARTHEADER") - (cond ((not %no-make-index%) - (make-file (string-append %output-basename% - "-INDEX" - %output-suffix%) - (make-index))) - (#t (empty-sosofo))))))) - -(element BOOK (book-common)) - -(define generator-version - "Generated from Docbook 3.0 DTD, dbtohtml.dsl version $Revision$") - -(define (make-file file-name content) - (make entity - system-id: (string-append %output-directory% "/" file-name) - (make sequence - (make document-type - name: "html" - public-id: %html-public-id%) - (make formatting-instruction data: "<") - (make formatting-instruction data: "!--") - (literal generator-version) - (make formatting-instruction data: "--> -") - (make element - gi: "html" - (make sequence - (make element - gi: "head" - (make sequence - (make empty-element gi: "link" - attributes: (list (list "rel" "stylesheet") - (list "type" "text/css") - (list "href" "/style/docbook.css"))) - (make empty-element gi: "meta" - attributes: (list (list "name" "generator") - (list "content" generator-version))) - (make empty-element gi: "meta" - attributes: (list (list "name" "ObjectType") - (list "content" "book"))) - (make element - gi: "title" - (with-mode extract-title-text - (process-first-descendant "title"))))) - (make element - gi: "body" - attributes: (list (list "bgcolor" %body-bgcolor%)) - (make sequence - (make-anchor) - content - (make-footer) - (make formatting-instruction data: "<") - (make formatting-instruction data: "!--#include virtual=\"/includes/docbook_footer\"") - (make formatting-instruction data: "-->")))))))) - -(define (make-footer) - (let ((copyright (select-elements (descendants (book-node)) - '("COPYRIGHT" "BOOKINFO")))) - (cond ((node-list-empty? copyright) (empty-sosofo)) - (#t (make sequence - (make-fat-rule) - (process-node-list copyright)))))) - -(define (node-list-last nl) - (node-list-ref nl (- (node-list-length nl) 1))) - -(define (make-nav-links parent-gi) - (make sequence - (make empty-element - gi: "P") - (make element - gi: "A" - attributes: (list (list "href" (link-file-name (ancestor parent-gi)))) - (literal "Up")) - (literal " ") - (if (absolute-last-sibling?) - (empty-sosofo) - (make element - gi: "A" - attributes: (list (list "href" - (link-file-name (node-list-first - (follow (current-node)))))) - (literal "Forward"))) - (literal " ") - (if (absolute-first-sibling?) - (empty-sosofo) - (make element - gi: "A" - attributes: (list (list "href" - (link-file-name (node-list-last - (preced (current-node)))))) - (literal "Back"))) - (make empty-element - gi: "P"))) - -(define (make-pref-chap-app) - (cond (%no-split-output% - (make sequence - (make-anchor) - (make-fat-rule) - (process-children))) - (#t - (make-file (link-file-name (current-node)) - (make sequence - (make-nav-links "BOOK") - (process-children) - (make-nav-links "BOOK")))))) - -;;(element ARTICLE (process-children)) -(element ARTICLE (book-common)) - -(element PREFACE (make-pref-chap-app)) - -(element CHAPTER (make-pref-chap-app)) - -(element APPENDIX (make-pref-chap-app)) - -(element BEGINPAGE (make sequence - (make empty-element gi: "P") - (make empty-element gi: "HR"))) - -(element BIBLIOGRAPHY (make-pref-chap-app)) - -(element BOOKBIBLIO (process-children)) - -(element BIBLIODIV (process-children)) - -(element GLOSSARY (make-pref-chap-app)) - -; (element GLOSSDIV (make-pref-chap-app)) - -;;(element ARTHEADER (make-pref-chap-app)) -(element ARTHEADER - (make sequence - (cond ((not %no-make-toc%) - (make sequence - (make-fat-rule) - (make element - gi: "h2" - attributes: (list "align" "center") - (literal "Contents")) - (make element - gi: "ul" - attributes: (list "align" "center") - (with-mode make-toc-links - (process-node-list (book-node)))))) - (#t (empty-sosofo))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; sections - -(element SECT1 - (make sequence - (make-anchor) - (process-children))) - -(element SECT2 - (make sequence - (make-anchor) - (process-children))) - -(element SECT3 - (make sequence - (make-anchor) - (process-children))) - -(element SECT4 - (make sequence - (make-anchor) - (process-children))) - -(element SECT5 - (make sequence - (make-anchor) - (process-children))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; titles - -(mode extract-title-text - (element (TITLE) - (process-children))) - -(mode extract-title-text - (element (BRIDGEHEAD) - (process-children))) - -(element (BOOK TITLE) - (make element - gi: "h1" - attributes: (list "align" "center") - (process-children))) - -(element (ARTICLE TITLE) - (make element - gi: "h1" - attributes: (list "align" "center") - (process-children))) - -(element (CHAPTER TITLE) - (make sequence - (make element - gi: "h1" - (make sequence - (literal (chap-app-head-label "Chapter")) - (process-children-trim))))) - -(element (PREFACE TITLE) - (make element - gi: "h1" - (make sequence - (literal "Preface: ") - (process-children-trim)))) - -(element (APPENDIX TITLE) - (make element - gi: "H1" - (make sequence - (literal (chap-app-head-label "Appendix")) - (process-children-trim)))) - -(element (BIBLIOGRAPHY TITLE) - (make element gi: "H1" - (make sequence - (literal (chap-app-head-label "Bibliography")) - (process-children-trim)))) - -(element (BOOKBIBLIO TITLE) - (make element gi: "H2" - (make sequence -;;; (literal (chap-app-head-label "Bibliography")) - (process-children-trim)))) - -(element (BIBLIODIV TITLE) - (make element gi: "H2" - (make sequence - (process-children-trim)))) - -(element (GLOSSARY TITLE) - (make element gi: "H1" - (make sequence - (literal "Glossary") -; (process-children-trim) -))) - -(element (GLOSSDIV TITLE) - (make element gi: "H2" - (process-children-trim))) - -(element (ARTHEADER TITLE) - (make element gi: "H1" - (process-children-trim))) - -(element (ARTHEADER DATE) - (make element gi: "P")) - -(element (ARTHEADER SUBTITLE) - (make element - gi: "H2" - (make element - gi: "i" - (process-children-trim) - ))) - -(element (SECT1 TITLE) (make element gi: "H2")) - -(element (SECT2 TITLE) (make element gi: "H3")) - -(element (SECT3 TITLE) (make element gi: "H4")) - -(element (SECT4 TITLE) (make element gi: "H5")) - -(element (SECT5 TITLE) (make element gi: "H6")) - -(element (FORMALPARA TITLE) (make element gi: "H6")) - -(element BRIDGEHEAD (make element gi: "H4")) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; font changers - -(element EMPHASIS - (make element gi: "EM")) - -(element TYPE - (make element gi: "STRONG" - (make element gi: "TT"))) - -(element TOKEN - (make element gi: "EM" - (make element gi: "STRONG" - (make element gi: "TT")))) - -(element REPLACEABLE (make element gi: "EM")) - -(element FIRSTTERM (make element gi: "EM")) - -(element APPLICATION (make element gi: "TT")) - -(element FILENAME (make element gi: "TT")) - -(element LITERAL (make element gi: "TT")) - -(element GUIMENU (make element gi: "TT")) -(element GUIMENUITEM (make element gi: "TT")) - -(element ENVAR (make element gi: "TT")) - -(element SUBSCRIPT (make element gi: "SUB")) - -(element SUPERSCRIPT (make element gi: "SUP")) - -(element CITATION (process-children)) -(element CITETITLE (make element gi: "I")) - -(element COMMAND (make element gi: "TT")) - -(element STRUCTFIELD (make element gi: "TT")) - -(element OPTION (make element gi: "TT")) - -(element USERINPUT (make element gi: "TT")) - -(element COMPUTEROUTPUT (make element gi: "TT")) - -(element PROMPT (make element gi: "TT")) - -(element PRODUCTNAME (make element gi: "I")) - -(element SGMLTAG (make element gi: "TT")) -(element CLASSNAME (make element gi: "TT")) -(element SYMBOL (make element gi: "TT")) -(element LITERALLAYOUT (make element gi: "PRE")) -(element PROGRAMLISTING (make element gi: "PRE")) - -(element FOREIGNPHRASE (make element gi: "I")) - -;; I think that title abbreviations don't really have a place in HTML. -;; The only place in which I can imagine them being useful is if the -;; HTML secret title (the one that goes in your bookmarks and stuff) -;; is derived from the DocBook title abbrev -;; -;; (element ABBREV (process-children-trim)) -(element ABBREV (empty-sosofo)) -(element TITLEABBREV (empty-sosofo)) - -(element EMAIL - (if %email-element% - (make element - gi: %email-element% - (process-children-trim)) - (process-children-trim))) - -(element QUOTE - (make sequence - (make entity-ref - name: "quot") - (process-children-trim) - (make entity-ref - name: "quot"))) - -(element ADDRESS - (make element - gi: "address" - (make element - gi: "em" - (process-children-trim)))) - -(element (ADDRESS CITY) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS COUNTRY) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS EMAIL) - (make sequence - (make empty-element - gi: "BR") - ;; Now throw some space between street address and the email - ;; address. Sadly, the only way I know how to do it in HTML is to - ;; throw in an empty paragraph tag. - (make empty-element - gi: "spacer" - attributes: '(("align" "vertical") ("size" "10"))) - (if %email-element% - (make element - gi: %email-element% - (process-children-trim)) - (process-children-trim)))) - -(element (ADDRESS FAX) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS OTHERADDR) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS POB) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS PHONE) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS POSTCODE) - (process-children-trim)) - -(element (ADDRESS STATE) - (process-children-trim)) - -(element (ADDRESS STREET) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; paragraph like things - -(element CAUTION (make-special-para)) - -(element IMPORTANT (make-special-para)) - -(element WARNING (make-special-para)) - -(element NOTE (make-special-para)) - -(element TIP (make-special-para)) - -(element EXAMPLE (make-special-para)) - -(element INFORMALEXAMPLE - (make element - gi: "BLOCKQUOTE")) - -(element COMMENT - (cond (%show-comments% - (make element - gi: "FONT" - attributes: '(("color" "red")) - (make-special-para))) - (#t (empty-sosofo)))) - -(element PARA - (make sequence - (make empty-element - gi: "P") - (with-mode footnote-ref - (process-children)) - (with-mode footnote-def - (process-matching-children "FOOTNOTE")))) - -(element BLOCKQUOTE (make element gi: "BLOCKQUOTE")) - -(element SCREEN - (let ((gubbins (make element - gi: "PRE" - (process-children)))) - (make sequence - (make empty-element - gi: "P") - (if %no-shade-screen% - gubbins - (make element - gi: "TABLE" - attributes: (append (list '("border" "0") - '("bgcolor" "#E0E0E0")) - (if %shade-width% - (list (list "width" %shade-width%)) - '())) - (make element - gi: "TR" - (make element - gi: "TD" - gubbins))))))) - -(element FORMALPARA (process-children)) - -(element PHRASE (maybe-bold-children)) - -(mode footnote-ref - (element FOOTNOTE - (make sequence - (literal "[") - (literal (format-number (element-number (current-node)) "1")) - (literal "]")))) - -(mode footnote-def - (element FOOTNOTE - (make element - gi: "BLOCKQUOTE" - (make sequence - (literal "[") - (literal (format-number (element-number (current-node)) "1")) - (literal "]") - (process-children))))) - -(element (CAUTION TITLE) - (make element - gi: "H5")) - -(element (IMPORTANT TITLE) - (make element - gi: "H5")) - -(element (WARNING TITLE) - (make element - gi: "H5")) - -(element (NOTE TITLE) - (make element - gi: "H5")) - -(element (TIP TITLE) - (make element - gi: "H5")) - -(element (EXAMPLE TITLE) - (make element - gi: "H5")) - -(element (BIBLIOENTRY TITLE) - (make element - gi: "H3")) - -(element (BIBLIOENTRY PAGENUMS) - (make sequence - (literal "Pages: ") - (make element gi: "I"))) - -(element (BIBLIOENTRY DATE) - (make sequence - (literal " Date: ") - (make element gi: "I"))) - -(element (BIBLIOENTRY VOLUMENUM) - (make sequence - (literal " Volume: ") - (make element gi: "I"))) - -(element (BIBLIOENTRY SERIESINFO) (process-children)) - -(element (BIBLIOENTRY SERIESINFO TITLE) - (make element gi: "H4")) - -(element (BIBLIOENTRY BIBLIOMISC) - (make sequence - (literal " other: ") - (process-children))) - -; the para inside does the work, here... -(element (BIBLIOENTRY ABSTRACT) (process-children)) - -;; an article'sabstract is centered text -(element ABSTRACT - (make sequence - (make empty-element gi: "HR") - (make element - gi: "H2" - (literal "Abstract")) - (make element - gi: "DIV" - attributes: (list (list "align" "left")) - (make element gi: "BLOCKQUOTE" - (process-children))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; lists - -(element ITEMIZEDLIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "UL"))) - -(element ORDEREDLIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "OL"))) - -(element PROCEDURE - (make sequence - (make empty-element - gi: "P") - (make element - gi: "OL"))) - -(element SIMPLELIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "UL"))) - -(element (ITEMIZEDLIST LISTITEM) - (make sequence - (make empty-element - gi: "LI") - (process-children) - (make empty-element - gi: "P"))) - -(element (ORDEREDLIST LISTITEM) - (make sequence - (make empty-element - gi: "LI") - (process-children) - (make empty-element - gi: "P"))) - -(element STEP - (make sequence - (make empty-element - gi: "LI") - (process-children) - (make empty-element - gi: "P"))) - -(element (SIMPLELIST MEMBER) - (make sequence - (make empty-element - gi: "LI") - (process-children))) - -(element VARIABLELIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "DL"))) - -(element VARLISTENTRY - (make sequence - (make empty-element - gi: "DT") - (process-children))) - -(element (VARLISTENTRY LISTITEM) - (make sequence - (make empty-element - gi: "DD") - (process-children) - (make empty-element - gi: "P"))) - -(element TERM (maybe-bold-children)) - -(element GLOSSDIV - (make sequence - (make empty-element - gi: "P") - (make element - gi: "DL"))) - -; (define (gloss-entry-name indexterm) -; (string-append "gloss." (format-number (element-number indexterm) "1"))) -(define (gloss-entry-name glossterm) - (string-append "gloss." (data glossterm))) - -(element GLOSSENTRY - (process-children)) - -(element (GLOSSENTRY GLOSSTERM) - (make sequence - (make empty-element - gi: "DT") - (make empty-element - gi: "A" - attributes: (list (list "name" (gloss-entry-name (current-node))))) - (process-children))) - - -(element (GLOSSENTRY GLOSSDEF) - (make sequence - (make empty-element - gi: "DD") - (process-children) - (make empty-element - gi: "P"))) - -(element (GLOSSENTRY GLOSSSEE) - (make sequence - (make empty-element - gi: "DD") - (literal "See ") - (make element - gi: "A" - attributes: (list (list "href" - (string-append "#" - (gloss-entry-name (current-node))) - ))) - (make empty-element - gi: "P"))) - -; (element GLOSSTERM (maybe-bold-children)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; index - -(define (index-entry-name indexterm) - (string-append "index." (format-number (element-number indexterm) "1"))) - -(element INDEXTERM - (make sequence - (make element - gi: "A" - attributes: (list (list "name" (index-entry-name (current-node)))) - (literal "")) - (empty-sosofo))) - -; DIY string-ci>? - -(define (string-ci>? s1 s2) - (let ((len1 (string-length s1)) - (len2 (string-length s2))) - (let loop ((i 0)) - (cond ((= i len1) #f) - ((= i len2) #t) - (#t (let ((c1 (index-char-val (string-ref s1 i))) - (c2 (index-char-val (string-ref s2 i)))) - (cond - ((= c1 c2) (loop (+ i 1))) - (#t (> c1 c2))))))))) - -(define (index-char-val ch) - (case ch - ((#\A #\a) 65) - ((#\B #\b) 66) - ((#\C #\c) 67) - ((#\D #\d) 68) - ((#\E #\e) 69) - ((#\F #\f) 70) - ((#\G #\g) 71) - ((#\H #\h) 72) - ((#\I #\i) 73) - ((#\J #\j) 74) - ((#\K #\k) 75) - ((#\L #\l) 76) - ((#\M #\m) 77) - ((#\N #\n) 78) - ((#\O #\o) 79) - ((#\P #\p) 80) - ((#\Q #\q) 81) - ((#\R #\r) 82) - ((#\S #\s) 83) - ((#\T #\t) 84) - ((#\U #\u) 85) - ((#\V #\v) 86) - ((#\W #\w) 87) - ((#\X #\x) 88) - ((#\Y #\y) 89) - ((#\Z #\z) 90) - - ((#\ ) 32) - - ((#\0) 48) - ((#\1) 49) - ((#\2) 50) - ((#\3) 51) - ((#\4) 52) - ((#\5) 53) - ((#\6) 54) - ((#\7) 55) - ((#\8) 56) - ((#\9) 57) - - ; laziness precludes me from filling this out further - (else 0))) - -(define (string->number-list s) - (let loop ((i (- (string-length s) 1)) - (l '())) - (if (< i 0) - l - (loop (- i 1) (cons (index-char-val (string-ref s i)) l))))) - -(define (number-list>? l1 l2) - (cond ((null? l1) #f) - ((null? l2) #t) - ((= (car l1) (car l2)) - (number-list>? (cdr l1) (cdr l2))) - (#t (> (car l1) (car l2))))) - -; return the string data for a given index entry - -(define (get-index-entry-data entry) - (let ((primary (select-elements (descendants entry) "PRIMARY")) - (secondary (select-elements (descendants entry) "SECONDARY"))) - (if (node-list-empty? secondary) - (data primary) - (string-append (data primary) " - " (data secondary))))) - -(define (make-index-entry entry) - (let ((text (get-index-entry-data entry))) - (cons text - (make sequence - (make empty-element - gi: "LI") - (make element - gi: "A" - attributes: (list (list "href" - (string-append (link-file-name - entry) - "#" - (index-entry-name - entry)))) - (literal text)))))) - -(define (build-index nl) - (let loop ((result '()) - (nl nl)) - (if (node-list-empty? nl) - result - (loop (cons (make-index-entry (node-list-first nl)) result) - (node-list-rest nl))))) - -(define (sort-index il) - (letrec ((list-head (lambda (l n) - (if (> n 0) - (cons (car l) (list-head (cdr l) (- n 1))) - '()))) - (merge (lambda (il1 il2) - (cond ((null? il1) il2) - ((null? il2) il1) - ((string-ci>? (car (car il1)) (car (car il2))) - (cons (car il2) (merge il1 (cdr il2)))) - (#t - (cons (car il1) (merge (cdr il1) il2))))))) - (let* ((ll (length il)) - (ldiv2 (quotient ll 2))) - (if (> 2 ll) - il - (merge (sort-index (list-head il ldiv2)) - (sort-index (list-tail il ldiv2))))))) - -(define (output-index il) - (let extract-and-append ((il il) - (result (empty-sosofo))) - (if (null? il) - result - (extract-and-append (cdr il) (sosofo-append result (cdr (car il))))))) - -(define (make-index) - (make sequence - (make element - gi: "A" - attributes: (list (list "name" "INDEXTOP")) - (literal "")) - (make element - gi: "H1" - (literal "Index")) - (make element - gi: "UL" - (output-index - (sort-index - (build-index (select-elements (descendants (current-node)) - "INDEXTERM"))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; links & cross-references - -(define (link-file-name target) - (cond (%no-split-output% "") - (#t - (string-append - %output-basename% - (cond ((equal? (gi target) "CHAPTER") - (string-append - "-" - (format-number (child-number target) "1"))) - ((ancestor-child-number "CHAPTER" target) - (string-append - "-" - (format-number (ancestor-child-number "CHAPTER" target) "1"))) - ((equal? (gi target) "APPENDIX") - (string-append - "-" - (format-number (child-number target) "A"))) - ((ancestor-child-number "APPENDIX" target) - (string-append - "-" - (format-number (ancestor-child-number "APPENDIX" target) "A"))) - (#t "")) - %output-suffix%)))) - -(element ANCHOR - (make-anchor)) - -(element LINK - (let* ((target (element-with-id (attribute-string "linkend") - (book-node))) - (target-file-name (link-file-name target)) - (endterm (attribute-string "endterm")) - (target-title-sosofo (if endterm - (with-mode extract-xref-text - (process-node-list - (element-with-id endterm - (book-node)))) - (process-children)))) - (make element - gi: "A" - attributes: (list - (list "href" - (string-append - target-file-name - "#" - (attribute-string "linkend")))) - target-title-sosofo))) -(element ULINK - (make element - gi: "A" - attributes: (list - (list "href" (attribute-string "url"))))) - -(element XREF - (let* ((target (element-with-id (attribute-string "LINKEND") - (book-node))) - (target-file-name (link-file-name target))) - (make element - gi: "A" - attributes: (list - (list "href" - (string-append target-file-name - "#" - (attribute-string "linkend")))) - (with-mode extract-xref-text - (process-node-list target))))) - -(mode extract-xref-text - (default - (let ((title-sosofo (with-mode extract-title-text - (process-first-descendant "TITLE")))) - (if (sosofo? title-sosofo) - title-sosofo - (literal (string-append "Reference to " (gi))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; figures - -(element FIGURE - (make sequence - (make empty-element - gi: "P") - (make-anchor) - (process-children) - (make empty-element - gi: "P"))) - -(element (FIGURE TITLE) - (make sequence - (make element - gi: "B") - (make empty-element - gi: "P"))) - -(element GRAPHIC - (let ((img - (make sequence - (make empty-element - gi: "P") - (make empty-element - gi: "IMG" - attributes: (list - (list "src" - (string-append (attribute-string "fileref") - ".gif"))))))) - (if (equal? - (attribute-string "align") - "CENTER") - (make element - gi: "CENTER" - img) - img))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; tables - -(element TABLE - (make sequence - (make empty-element - gi: "P") - (make element - gi: "TABLE" - attributes: (if (equal? - (attribute-string "frame") - "ALL") - '(("border" "2") ("cellpadding" "2")) - '())) - (make empty-element - gi: "P"))) - -(element (TABLE TITLE) - (make element - gi: "H4" - (make sequence - (literal "Table: ") - (process-children-trim)))) - -(element INFORMALTABLE - (make sequence - (make empty-element - gi: "P") - (make element - gi: "TABLE" - attributes: (if (equal? - (attribute-string "frame") - "ALL") - '(("border" "2") ("cellpadding" "2")) - '())) - (make empty-element - gi: "P"))) - -(element TGROUP (process-children)) - -(element THEAD (process-children)) - -(element (THEAD ROW) - (make sequence - (make empty-element - gi: "TR") - (process-children))) - -(element (THEAD ROW ENTRY) - (make sequence - (make empty-element - gi: "TD") - (make element - gi: "B" - (process-children)))) - -(element TBODY (process-children)) - -(element (TBODY ROW) - (make sequence - (make empty-element - gi: "TR") - (process-children))) - - -(element (TBODY ROW ENTRY) - (make sequence - (make empty-element - gi: "TD") - (process-children))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; book info - -(element BOOKINFO - (make sequence - (make element - gi: "CENTER" - (process-children)) - (cond ((not %no-make-toc%) - (make sequence - (make-fat-rule) - (make element - gi: "H2" - (literal "Contents")) - (make element - gi: "ul" - (with-mode make-toc-links - (process-node-list (book-node)))))) - (#t (empty-sosofo))))) - -(element (BOOKINFO DATE) - (make element gi: "P")) - -(element (BOOKINFO TITLE) - (make element gi: "H1")) - -(element (BOOKINFO SUBTITLE) - (make element - gi: "H2" - (make element - gi: "i" - (process-children-trim) - ))) - -(element AUTHORGROUP - (let ((reducer (lambda (sofar new) - (sosofo-append sofar (make element - gi: "H2" - (process-node-list new)))))) - (make sequence - (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") - reducer - (empty-sosofo))))) - -;; I make a new left-aligned DIV sandwiched between HRs for the author -;; blurb. -(element AUTHORBLURB - (make sequence - (make empty-element gi: "HR") - (make element - gi: "DIV" - attributes: '(("align" "left")) - (make element - gi: "h4" - attributes: '(("align" "left")) - (literal "Author blurb for ") - (make element - gi: "i" - (process-matching-children "TITLE") - (literal ":"))) - (process-matching-children "FORMALPARA" "PARA" "SIMPARA")) - (make empty-element gi: "HR"))) - -(element (AUTHORBLURB TITLE) - (make element gi: "B")) - -(element CORPNAME - (make element gi: "H2")) - -(element (BIBLIOENTRY AUTHORGROUP) - (let ((reducer (lambda (sofar new) - (sosofo-append sofar (make element - gi: "H3" - (process-node-list new)))))) - (make sequence - (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") - reducer - (empty-sosofo))))) - -(element COPYRIGHT - (make element - gi: "H4" - (make sequence - (make entity-ref - name: "copy") - (process-matching-children "HOLDER") - (process-matching-children "YEAR")))) - -(element HOLDER - (make sequence - (literal " ") - (process-children-trim))) - -(element YEAR - (make sequence - (literal " ") - (process-children-trim))) - -(element CORPAUTHOR - (process-children-trim)) - -(element AUTHOR - (process-children-trim)) - -(element EDITOR - (process-children-trim)) - -(element CONFGROUP - (process-children-trim)) - -(element CONFTITLE - (make sequence - (make empty-element - gi: "BR") - (make element gi: "I" (process-children)))) - -(element CONFDATES - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element HONORIFIC - (make sequence - (process-children-trim) - (literal " "))) - -(element FIRSTNAME - (make sequence - (process-children-trim) - (literal " "))) - -(element OTHERNAME - (make sequence - (process-children-trim) - (literal " "))) - -(element SURNAME - (make sequence - (process-children-trim) - (literal " "))) - -(element LINEAGE - (make sequence - (process-children-trim) - (literal " "))) - -(element TRADEMARK (process-children)) - -(element PUBLISHERNAME (process-children)) - -(element BIBLIOENTRY (process-children)) - -(element ACRONYM (process-children)) - -(element RELEASEINFO - (make sequence - (make empty-element - gi: "BR") - (make element gi: "B"))) - -(element AFFILIATION - (make sequence - (make element - gi: "I"))) - -(element ORGNAME - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -;;(element ORGNAME -;; (process-children)) - -(element JOBTITLE - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element ORGDIV - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element PUBLISHER - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element ISBN - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element PUBDATE - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element REVHISTORY - (empty-sosofo)) - -(element LEGALNOTICE - (make sequence - (make element - gi: "H4" - attributes: '(("align" "left")) - (literal "Legal Notice: ")) - (make element - gi: "DIV" - attributes: '(("align" "left"))))) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Synopses for command line, API functions and so forth -;;(element FUNCSYNOPSIS -;; (process-children)) - -(element FUNCSYNOPSIS - (make sequence - (make empty-element gi: "P") ; go to a new line - ;; just in case there is some synopsisinfo, like #include directives - (process-matching-children "FUNCSYNOPSISINFO") - (make empty-element gi: "P") ; go to a new line - (process-matching-children "FUNCDEF") ; this gives the function name - (literal " (") - (process-matching-children "PARAMDEF") ; this gives the function arguments - (literal ")") - )) - -(element FUNCDEF - (make element gi: "TT")) - -(element FUNCTION - (make element gi: "B")) - -(element STRUCTNAME - (make element gi: "B")) - -(element FUNCSYNOPSISINFO - (make element - gi: "PRE")) - -(element PARAMDEF - (make element - gi: "TT")) - -(element PARAMETER - (make element - gi: "I")) - -(element FUNCPROTOTYPE - (make element - gi: "PRE")) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; TOC - -(element LOF (empty-sosofo)) - -(element LOT (empty-sosofo)) - -(element TOC (empty-sosofo)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; DIY TOC - -(mode make-toc-links - (element (BOOK) - (sosofo-append - (process-children) - (cond ((not %no-make-index%) - (make sequence - (make empty-element - gi: "LI") - (make element - gi: "A" - attributes: (list (list "href" - (cond (%no-split-output% "#INDEXTOP") - (#t - (string-append %output-basename% - "-INDEX" - %output-suffix% - "#INDEXTOP"))))) - (literal "Index")))) - (#t (empty-sosofo))))) - (element (CHAPTER) - (make-chap-or-app-toc-links)) - (element (APPENDIX) - (make-chap-or-app-toc-links)) - (element (SECT1) - (make sequence - (make empty-element - gi: "LI") - (let ((title-text (with-mode extract-title-text - (process-first-descendant "TITLE")))) - (if (id) - (make element - gi: "A" - attributes: (list (list "href" (string-append (link-file-name (current-node)) - "#" - (id)))) - title-text) - title-text)))) - (default - (empty-sosofo))) - -(define (make-chap-or-app-toc-links) - (make sequence - (make empty-element - gi: "LI") - (let ((title-text - (make sequence - (literal (if (equal? (gi) "CHAPTER") - (string-append "Chapter " - (format-number - (element-number (current-node)) - "1") - " - ") - (string-append "Appendix " - (format-number - (element-number (current-node)) - "A") - " - "))) - (with-mode extract-title-text - (process-first-descendant "TITLE"))))) - (if (id) - (make element - gi: "A" - attributes: (list (list "href" (string-append (link-file-name (current-node)) - "#" - (id)))) - title-text) - title-text)) - (make element - gi: "UL" - (with-mode make-toc-links - (process-matching-children "SECT1"))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; make the unimplemented bits stand out - -(default - (make element - gi: "FONT" - attributes: '(("color" "red")) - (make sequence - (literal (string-append "<" (gi) ">")) - (process-children) - (literal (string-append ""))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; standard subroutines - -(define (node-list-reduce nl combine init) - (if (node-list-empty? nl) - init - (node-list-reduce (node-list-rest nl) - combine - (combine init (node-list-first nl))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; various homebrew subroutines - -(define (book-node) - (cond ((equal? (gi) "BOOK") (current-node)) - (#t (let ((book-root (ancestor "BOOK"))) - (if (node-list-empty? book-root) - (cond ((equal? (gi) "CHAPTER") (current-node)) - (#t (ancestor "CHAPTER"))) - book-root))))) - -(define (make-fat-rule) - (make sequence - (make empty-element gi: "P") - (make empty-element gi: "HR"))) - -(define (chap-app-head-label chap-or-app) - (let ((label - (attribute-string "label" (ancestor chap-or-app)))) - (string-append - chap-or-app - " " - (if label - (if (equal? label "auto") - (format-number - (element-number (ancestor chap-or-app)) - (if (equal? chap-or-app "Chapter") "1" "A")) - label) - (format-number - (element-number (ancestor chap-or-app)) - (if (equal? chap-or-app "Chapter") "1" "A"))) - ". "))) - -(define (make-anchor) - (if (id) - (make element - gi: "A" - attributes: (list (list "name" (id))) - (literal "")) - (empty-sosofo))) - -(define (make-special-para) - (make sequence - (make empty-element - gi: "P") - (make element - gi: "B" - (literal (string-append (gi) ":"))) - (make element - gi: "BLOCKQUOTE" - (process-children)))) - -(define (maybe-bold-children) - (cond ((equal? (attribute-string "role") - "bold") - (make element - gi: "B" - (process-children-trim))) - (#t (process-children-trim)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; the end From 8425bb7c0407a4983f498567e7bae985e8f8ab40 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 17:48:03 +0000 Subject: [PATCH 0022/2539] new file - short intro on how to use libgtop in the gnome project; * doc/gnome-hackers.sgml: new file - short intro on how to use libgtop in the gnome project; especially 'configure' and 'gtopConf.sh'. --- doc/gnome-hackers.sgml | 271 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 doc/gnome-hackers.sgml diff --git a/doc/gnome-hackers.sgml b/doc/gnome-hackers.sgml new file mode 100644 index 00000000..2f679647 --- /dev/null +++ b/doc/gnome-hackers.sgml @@ -0,0 +1,271 @@ + + + +]> + + + Using LibGTop in the Gnome Project + + + Martin + Baulig + +
+ martin@home-of-linux.org +
+
+
+
+ + 1998 + Martin Baulig + + + + + + This documentation 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 of the License, or (at your option) any later + version. + + + This library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307 USA + + + For more details see the file COPYING in the source + distribution of LibGTop. + + + + + + + This is a short introduction in how to use + libgtop in the GNOME project. + It describes the additional options configure + takes and the information stored in the automatically generated + gtopConf.sh configuration script. + + + +
+ + + + + Configuration + + + The configure script of libgtop + takes some non-standard options to let you decide which parts of the library + should be build. + + + + + + Normally, configure decides whether or not using the + server is required. Depending upon this decision, it adds either + -lgtop (when it's needed) or + -lgtop_systems (when it's not needed) to + GTOP_LIBS and GTOP_GUILE_LIBS. + + + You can change this behaviour with the following options: + + + + + --enable-libgtop-server + + + + Use the server regardless whether or not it is required. + + + --disable-libgtop-server + + + + Do not use the server regardless wheter or not it is required. + + + + + + + Normally, the guile interface of libgtop is build + when guile can be found on the system. + + + + + --disable-libgtop-guile + + + + Disables building the guile interface even if you have + guile installed. + + + --enable-libgtop-guile + + + + Has no effect at all since you cannot build the guile interface without + having guile installed on your system. + + + + + + + If you do not need the names subdirs, you can disable + their building with the following option: + when guile can be found on the system. + + + + + --disable-libgtop-names + + + + Disables building of the names subdirs. + + + --enable-libgtop-names + + + + Is the default. + + + + + + + The <filename>gtopConf.sh</filename> script + + + After a successful build of libgtop, a + gtopConf.sh script is generated which will later + be used to decide how to link a program with libgtop. + + + It defines the following variables: + + + + + GTOP_LIBDIR + + + + Defaults to $(prefix)/lib. It is the directory + where the libgtop libraries get installed. + + + GTOP_INCLUDEDIR + + + + Defaults to $(prefix)/include. It is the directory + where the libgtop header files get installed. + + + GTOP_LIBS + + + + Contains everything that you need to add to the _LDADD + variable of automake to link a program with + libgtop. + + + GTOP_INCS + + + + Contains everything that you need to add to the _INCLUDES + variable of automake to compile a program that uses + libgtop. + + + GTOP_GUILE_INCS + + + + Contains everything that you need to add to the _INCLUDES + variable of automake to compile a program that uses both + libgtop and its guile interface. + + + GTOP_BINDIR + + + + Defaults to $(bindir). It is the directory where the + libgtop binaries get installed. + + + GTOP_SERVER + + + + Defaults to $(bindir)/gtop_server. It is the full pathname + where the server gets installed. + + + GTOP_SYSDEPS_DIR + + + + The sysdeps directory that is used on your system. + + + GTOP_NEED_SERVER + + + + Is either yes or no and tells you + whether using the server is needed or not. + + + GTOP_USE_MACHINE_H + + + + Is either yes or no and tells you + whether glibtop_machine_h should be included in + glibtop.h. + + The system dependent part of the library may provide an additional header + file, glibtop_machine_h. In this case, they define + a structure _glibtop_machine in this header file. + This structure represents the machine member of + _glibtop. + + + + + Sample <filename>gtopConf.sh</filename> + + >opConf.sh; + + + +
From 50e59e9a85df342d6551d8f86c44fa763db0c3a9 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 17:51:18 +0000 Subject: [PATCH 0023/2539] added note about 'doc/gnome-hackers.sgml'. * NEWS: added note about 'doc/gnome-hackers.sgml'. --- ChangeLog | 26 ++++++++++++++++++++++++++ NEWS | 7 +++++++ doc/.cvsignore | 4 ++++ doc/Makefile | 15 ++++++++++++--- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0326d7b..e696714e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +1998-05-21 Martin Baulig + + * doc/gnome-hackers.sgml: new file - short intro on how + to use libgtop in the gnome project; especially 'configure' + and 'gtopConf.sh'. + + * doc/gnome-hackers.dsl: new file - sets output filename + and directory for 'gnome-hackers.sgml'. + + * doc/libgtop.dsl: most stuff from this file has moved + to 'dbtohtml.dsl', it now only overrides the output + filename and directory. + + * doc/dbtohtml.dsl: new file - contains most that was + formerly in 'libgtop.dsl'. + + * configure.in: 'GTOP_INCS' and 'GTOP_LIBS' now really + point to the places where everything gets installed and + no longer to the build directory, so that they can be + used in 'gtopConf.sh'. + + * acinclude.m4 (AC_LC_SYSDEPS): added 'machine_incs' + which is used in 'INCLUDES' in several 'Makefile.am's; + fixed typo 'ac_cv_want_names'; added missing AC_SUBST + of 'use_glibtop_machine_h'. + 1998-05-20 Martin Baulig * NEWS: added more detailed description of diff --git a/NEWS b/NEWS index 28f6bcdb..3bb066b6 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,12 @@ $Id$ +May/21/1998 +=========== + +* doc/gnome-hackers.sgml: This is a short intro on how to use libgtop + in the GNOME project. It covers especially the use of its 'configure' + script and the automatically generated 'gtopConf.sh'. + May/20/1998 =========== diff --git a/doc/.cvsignore b/doc/.cvsignore index 9af57b1c..c0f3bd58 100644 --- a/doc/.cvsignore +++ b/doc/.cvsignore @@ -1,9 +1,13 @@ *.shml .timestamp +.timestamp2 dbtohtml-1.shtml dbtohtml-2.shtml dbtohtml-3.shtml dbtohtml.shtml +gnome-hackers +gnome-hackers.ced +libgtop libgtop-1.shtml libgtop-2.shtml libgtop-3.shtml diff --git a/doc/Makefile b/doc/Makefile index 92f4f866..fa30b74a 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,6 +1,15 @@ -all: .timestamp +all: .timestamp .timestamp2 .timestamp: libgtop.sgml + rm -rf libgtop + mkdir libgtop jade -D /usr/lib/sgml/jade_dsl -d libgtop.dsl -t sgml \ - -V %no-make-index% libgtop.sgml > /dev/null - touch .timestamp + -V %no-make-index% libgtop.sgml > /dev/null && \ + touch .timestamp + +.timestamp2: gnome-hackers.sgml + rm -rf gnome-hackers + mkdir gnome-hackers + jade -D /usr/lib/sgml/jade_dsl -d gnome-hackers.dsl -t sgml \ + -V %no-make-index% gnome-hackers.sgml > /dev/null && \ + touch .timestamp2 From 033f27430cc9176a11e558cc166ddba4586184e6 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:02:31 +0000 Subject: [PATCH 0024/2539] new file - currently empty * ChangeLog: new file - currently empty --- po/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 po/ChangeLog diff --git a/po/ChangeLog b/po/ChangeLog new file mode 100644 index 00000000..f61f2ec3 --- /dev/null +++ b/po/ChangeLog @@ -0,0 +1,4 @@ +1998-05-21 Martin Baulig + + * ChangeLog: new file - currently empty + From 5e70e5fa9f575bc42970e41731e84283f19dacc1 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:06:55 +0000 Subject: [PATCH 0025/2539] added 'DIST_SUBDIRS' * sysdeps/Makefile.am: added 'DIST_SUBDIRS' --- sysdeps/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysdeps/Makefile.am b/sysdeps/Makefile.am index c5e77c3c..5625c33f 100644 --- a/sysdeps/Makefile.am +++ b/sysdeps/Makefile.am @@ -11,3 +11,5 @@ names_SUBDIRS = endif SUBDIRS = @sysdeps_dir@ common $(names_SUBDIRS) $(guile_SUBDIRS) + +DIST_SUBDIRS = common guile linux names osf1 stub sun4 From 436bef3790022167b1f638a6c8740b3dd5489476 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:07:29 +0000 Subject: [PATCH 0026/2539] added 'DIST_SUBDIRS' * sysdeps/guile/Makefile.am: added 'DIST_SUBDIRS' --- sysdeps/guile/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am index 62143a93..125f7d8a 100644 --- a/sysdeps/guile/Makefile.am +++ b/sysdeps/guile/Makefile.am @@ -2,6 +2,8 @@ if GLIBTOP_NAMES SUBDIRS = names endif +DIST_SUBDIRS = names + LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ From eb42a9e0cc09c8473d7f8cff4f045899ab5ec98e Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:10:05 +0000 Subject: [PATCH 0027/2539] new file * include/Makefile.am: new file --- include/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 include/Makefile.am diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 00000000..4832afc3 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = glibtop + From d7e1c5d56a55584c73cd5dd3db8e6ef0a046b374 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:10:24 +0000 Subject: [PATCH 0028/2539] new file - header file now get properly installed and go into the * include/glibtop/Makefile.am: new file - header file now get properly installed and go into the distribution. --- include/glibtop/Makefile.am | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 include/glibtop/Makefile.am diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am new file mode 100644 index 00000000..1a5941fc --- /dev/null +++ b/include/glibtop/Makefile.am @@ -0,0 +1,8 @@ +glibtopdir = $(includedir)/glibtop + +glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \ + sem_limits.h uptime.h command.h mem.h proclist.h \ + proctime.h shm_limits.h version.h cpu.h msg_limits.h \ + procmem.h procuid.h swap.h write.h error.h open.h \ + procsegment.h read.h sysdeps.h xmalloc.h global.h \ + output.h procsignal.h read_data.h union.h From 066c74d11dcb29a131221295684f12ff3c822e67 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:18:29 +0000 Subject: [PATCH 0029/2539] added 'GTOP_GUILE_FOUND', 'GTOP_WANT_NAMES', 'GTOP_WANT_GUILE_NAMES' and * gtopConf.sh.in: added 'GTOP_GUILE_FOUND', 'GTOP_WANT_NAMES', 'GTOP_WANT_GUILE_NAMES' and 'GTOP_WANT_EXAMPLES'. --- gtopConf.sh.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gtopConf.sh.in b/gtopConf.sh.in index 5776f348..c5bab334 100644 --- a/gtopConf.sh.in +++ b/gtopConf.sh.in @@ -18,3 +18,8 @@ GTOP_SYSDEPS_DIR="@GTOP_SYSDEPS_DIR@" GTOP_NEED_SERVER="@GTOP_NEED_SERVER@" GTOP_USE_MACHINE_H="@GTOP_USE_MACHINE_H@" +GTOP_GUILE_FOUND="@GTOP_GUILE_FOUND@" + +GTOP_WANT_NAMES="@GTOP_WANT_NAMES@" +GTOP_WANT_GUILE_NAMES="@GTOP_WANT_GUILE_NAMES@" +GTOP_WANT_EXAMPLES="@GTOP_WANT_EXAMPLES@" From 15d96eb9a131792f22267d1a15d397d1d41ac038 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:25:21 +0000 Subject: [PATCH 0030/2539] define 'GLIBTOP_NAMES' when building libgtop and a new conditional * acinclude.m4 (AC_LC_SYSDEPS): define 'GLIBTOP_NAMES' when building libgtop and a new conditional 'GLIBTOP_NAMES'; added new parameter '--without-examples'; define 'GLIBTOP_EXAMPLES' and conditional 'GLIBTOP_EXAMPLES'. --- acinclude.m4 | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 601f9dd1..25cfa00a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -99,6 +99,12 @@ AC_DEFUN([AC_LC_SYSDEPS],[ AC_MSG_RESULT($ac_cv_want_names) + if test x$ac_cv_want_names = xyes ; then + AC_DEFINE(GLIBTOP_NAMES) + fi + + AM_CONDITIONAL(GLIBTOP_NAMES, test x$ac_cv_want_names = xyes) + AC_MSG_CHECKING(whether building of the guile interface is requested) AC_ARG_ENABLE(libgtop-guile, @@ -111,11 +117,23 @@ AC_DEFUN([AC_LC_SYSDEPS],[ AC_MSG_RESULT($ac_cv_want_guile) - if test x$ac_cv_want_names = xyes ; then - AC_DEFINE(GLIBTOP_NAMES) + AC_MSG_CHECKING(whether building of the examples is requested) + + AC_ARG_WITH(libgtop-examples, + [ --without-examples disable building of the examples], + [if test "x$withval" = "xyes" ; then + ac_cv_want_examples=yes + else + ac_cv_want_examples=$withval + fi],[ac_cv_want_examples=yes]) + + AC_MSG_RESULT($ac_cv_want_examples) + + if test x$ac_cv_want_examples = xyes ; then + AC_DEFINE(GLIBTOP_EXAMPLES) fi - AM_CONDITIONAL(GLIBTOP_NAMES, test x$ac_cv_want_names = xyes) + AM_CONDITIONAL(GLIBTOP_EXAMPLES, test x$ac_cv_want_examples = xyes) if test x$use_glibtop_machine_h = xyes ; then machine_incs="-I\$(top_srcdir)/sysdeps/$sysdeps_dir" From 0a5e9d5c244d015ea746083a9c46cb26d262c54c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:26:38 +0000 Subject: [PATCH 0031/2539] added 'GLIBTOP_EXAMPLES'. * acconfig.h: added 'GLIBTOP_EXAMPLES'. --- acconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acconfig.h b/acconfig.h index 82742b69..ac64e471 100644 --- a/acconfig.h +++ b/acconfig.h @@ -30,4 +30,4 @@ #undef GLIBTOP_NAMES #undef GLIBTOP_GUILE_NAMES - +#undef GLIBTOP_EXAMPLES From 604c7dc48e75d1db91068271f803f71702f2c54c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:29:23 +0000 Subject: [PATCH 0032/2539] added 'gtop_guile_found', 'gtop_want_names', 'gtop_want_guile_names' and * configure.in: added 'gtop_guile_found', 'gtop_want_names', 'gtop_want_guile_names' and 'gtop_want_examples' for use in 'gtopConf.sh.in'; added 'include' and 'include/glibtop' subdirs. --- configure.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/configure.in b/configure.in index 7c672b16..c81928b6 100644 --- a/configure.in +++ b/configure.in @@ -142,6 +142,24 @@ if test "x$ac_cv_guile_found" = "xyes" ; then GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS $GUILE_LIBS" fi +gtop_guile_found="$ac_cv_guile_found" + +gtop_want_names="$ac_cv_want_names" + +if test "x$ac_cv_guile_found" = "xyes" ; then + gtop_want_guile_names="$ac_cv_want_names" +else + gtop_want_guile_names="no" +fi + +gtop_want_examples="$ac_cv_want_examples" + +AC_SUBST(gtop_guile_found) + +AC_SUBST(gtop_want_names) +AC_SUBST(gtop_want_guile_names) +AC_SUBST(gtop_want_examples) + AC_SUBST(GTOP_LIBS) AC_SUBST(GTOP_INCS) AC_SUBST(GTOP_GUILE_LIBS) @@ -156,6 +174,8 @@ AC_OUTPUT([ Makefile po/Makefile.in intl/Makefile +include/Makefile +include/glibtop/Makefile sysdeps/Makefile sysdeps/common/Makefile sysdeps/names/Makefile From 998392ec0599aa425527fc82a5a0bb7a7f2e0715 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:31:04 +0000 Subject: [PATCH 0033/2539] conditionally building 'examples' subdir, added 'copyright.txt' to * Makefile.am: conditionally building 'examples' subdir, added 'copyright.txt' to EXTRA_DIST. --- Makefile.am | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3b9eaeb0..1921ecf7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,12 +1,18 @@ ## Process this file with automake to produce Makefile.in. -built_SUBDIRS = sysdeps src lib examples +if GLIBTOP_EXAMPLES +examples_SUBDIRS = examples +endif -SUBDIRS = po intl support macros $(built_SUBDIRS) +built_SUBDIRS = include sysdeps src lib -include_HEADERS = +SUBDIRS = po intl support macros $(built_SUBDIRS) $(examples_SUBDIRS) -EXTRA_DIST = gtopConf.sh.in +DIST_SUBDIRS = po intl support macros include sysdeps src lib examples + +include_HEADERS = glibtop.h + +EXTRA_DIST = copyright.txt gtopConf.sh.in release: $(MAKE) dist distdir=$(PACKAGE)$(VERSION) @@ -39,5 +45,9 @@ gtopConf.sh: gtopConf.sh.in Makefile -e 's,\@GTOP_SYSDEPS_DIR\@,$(sysdeps_dir),g' \ -e 's,\@GTOP_NEED_SERVER\@,$(need_server),g' \ -e 's,\@GTOP_USE_MACHINE_H\@,$(use_glibtop_machine_h),g' \ + -e 's,\@GTOP_GUILE_FOUND\@,$(gtop_guile_found),g' \ + -e 's,\@GTOP_WANT_NAMES\@,$(gtop_want_names),g' \ + -e 's,\@GTOP_WANT_GUILE_NAMES\@,$(gtop_want_guile_names),g' \ + -e 's,\@GTOP_WANT_EXAMPLES\@,$(gtop_want_examples),g' \ < $(srcdir)/gtopConf.sh.in > gtopConf.tmp \ && mv gtopConf.tmp gtopConf.sh From dc8811243344361497079b394a0ff5e36e62afce Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:34:06 +0000 Subject: [PATCH 0034/2539] added information about latest changes in 'acinclude.m4' and * doc/gnome-hackers.sgml: added information about latest changes in 'acinclude.m4' and 'gtopConf.sh.in'. --- doc/gnome-hackers.sgml | 51 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/doc/gnome-hackers.sgml b/doc/gnome-hackers.sgml index 2f679647..6edbf6fa 100644 --- a/doc/gnome-hackers.sgml +++ b/doc/gnome-hackers.sgml @@ -154,7 +154,23 @@ Is the default. - + + + + + To disable building of the examples, you can say: + + + + + --without-examples + + + + Disables building of the examples. + + + @@ -259,6 +275,39 @@ This structure represents the machine member of _glibtop. + + GTOP_GUILE_FOUND + + + + Is either yes or no and tells you + whether guile has been found on your system + (or if building the guile interface was disabled). + + + GTOP_WANT_NAMES + + + + Is either yes or no and tells you + whether the sysdeps/names subdirectory was build. + + + GTOP_WANT_GUILE_NAMES + + + + Is either yes or no and tells you + whether the sysdeps/guile/names subdirectory was build. + + + GTOP_WANT_EXAMPLES + + + + Is either yes or no and tells you + whether the examples were build. + From 10a7ef87b92cdec4848d6ee27b919b3ee9812e5b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 20:37:06 +0000 Subject: [PATCH 0035/2539] *** empty log message *** --- .cvsignore | 5 +++-- ChangeLog | 29 +++++++++++++++++++++++++++++ include/.cvsignore | 2 ++ include/glibtop/.cvsignore | 2 ++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 include/.cvsignore create mode 100644 include/glibtop/.cvsignore diff --git a/.cvsignore b/.cvsignore index de689a21..1e0ac471 100644 --- a/.cvsignore +++ b/.cvsignore @@ -13,12 +13,13 @@ gtopConf.sh i386-bsdi i686-pc-linux-gnu intl +libgtop-0.01.tar.gz libgtop-mirror.sh.swp libtool ltconfig +ltmain.sh +macros stamp-h sun4 sun4sol2 -ltmain.sh -macros support diff --git a/ChangeLog b/ChangeLog index e696714e..da136519 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,34 @@ 1998-05-21 Martin Baulig + * doc/gnome-hackers.sgml: added information about latest + changes in 'acinclude.m4' and 'gtopConf.sh.in'. + + * Makefile.am: conditionally building 'examples' subdir, + added 'copyright.txt' to EXTRA_DIST. + + * configure.in: added 'gtop_guile_found', 'gtop_want_names', + 'gtop_want_guile_names' and 'gtop_want_examples' for use in + 'gtopConf.sh.in'; added 'include' and 'include/glibtop' subdirs. + + * acconfig.h: added 'GLIBTOP_EXAMPLES'. + + * acinclude.m4 (AC_LC_SYSDEPS): define 'GLIBTOP_NAMES' when + building libgtop and a new conditional 'GLIBTOP_NAMES'; added + new parameter '--without-examples'; define 'GLIBTOP_EXAMPLES' + and conditional 'GLIBTOP_EXAMPLES'. + + * gtopConf.sh.in: added 'GTOP_GUILE_FOUND', 'GTOP_WANT_NAMES', + 'GTOP_WANT_GUILE_NAMES' and 'GTOP_WANT_EXAMPLES'. + + * include/glibtop/Makefile.am: new file - header file + now get properly installed and go into the distribution. + + * include/Makefile.am: new file + + * sysdeps/guile/Makefile.am: added 'DIST_SUBDIRS' + + * sysdeps/Makefile.am: added 'DIST_SUBDIRS' + * doc/gnome-hackers.sgml: new file - short intro on how to use libgtop in the gnome project; especially 'configure' and 'gtopConf.sh'. diff --git a/include/.cvsignore b/include/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/include/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/include/glibtop/.cvsignore b/include/glibtop/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/include/glibtop/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in From 6241c3c65f850bda6f34743b0ca712cd885ea6fa Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 23:20:07 +0000 Subject: [PATCH 0036/2539] renamed from 'gtopConf.sh.in'; we now define 'LIBGTOP_LIBDIR', * libgtopConf.sh.in: renamed from 'gtopConf.sh.in'; we now define 'LIBGTOP_LIBDIR', 'LIBGTOP_INCLUDEDIR', 'LIBGTOP_LIBS', 'LIBGTOP_INCS', 'LIBGTOP_GUILE_LIBS', 'LIBGTOP_GUILE_INCS', 'LIBGTOP_BINDIR', 'LIBGTOP_SERVER', 'libgtop_sysdeps_dir', 'libgtop_need_server', 'libgtop_use_machine_h', 'libgtop_guile_found', 'libgtop_want_names', 'libgtop_want_guile_names', 'libgtop_want_examples'. * gtopConf.sh.in: renamed to 'libgtopConf.sh.in'. --- gtopConf.sh.in | 25 ------------------------- libgtopConf.sh.in | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 gtopConf.sh.in create mode 100644 libgtopConf.sh.in diff --git a/gtopConf.sh.in b/gtopConf.sh.in deleted file mode 100644 index c5bab334..00000000 --- a/gtopConf.sh.in +++ /dev/null @@ -1,25 +0,0 @@ -# -# Configuration of the libgtop package -# - -GTOP_LIBDIR="@GTOP_LIBDIR@" -GTOP_INCLUDEDIR="@GTOP_INCLUDEDIR@" - -GTOP_LIBS="@GTOP_LIBS@" -GTOP_INCS="@GTOP_INCS@" - -GTOP_GUILE_LIBS="@GTOP_GUILE_LIBS@" -GTOP_GUILE_INCS="@GTOP_GUILE_INCS@" - -GTOP_BINDIR="@GTOP_BINDIR@" -GTOP_SERVER="@GTOP_SERVER@" - -GTOP_SYSDEPS_DIR="@GTOP_SYSDEPS_DIR@" -GTOP_NEED_SERVER="@GTOP_NEED_SERVER@" -GTOP_USE_MACHINE_H="@GTOP_USE_MACHINE_H@" - -GTOP_GUILE_FOUND="@GTOP_GUILE_FOUND@" - -GTOP_WANT_NAMES="@GTOP_WANT_NAMES@" -GTOP_WANT_GUILE_NAMES="@GTOP_WANT_GUILE_NAMES@" -GTOP_WANT_EXAMPLES="@GTOP_WANT_EXAMPLES@" diff --git a/libgtopConf.sh.in b/libgtopConf.sh.in new file mode 100644 index 00000000..9330fca7 --- /dev/null +++ b/libgtopConf.sh.in @@ -0,0 +1,25 @@ +# +# Configuration of the libgtop package +# + +LIBGTOP_LIBDIR="@LIBGTOP_LIBDIR@" +LIBGTOP_INCLUDEDIR="@LIBGTOP_INCLUDEDIR@" + +LIBGTOP_LIBS="@LIBGTOP_LIBS@" +LIBGTOP_INCS="@LIBGTOP_INCS@" + +LIBGTOP_GUILE_LIBS="@LIBGTOP_GUILE_LIBS@" +LIBGTOP_GUILE_INCS="@LIBGTOP_GUILE_INCS@" + +LIBGTOP_BINDIR="@LIBGTOP_BINDIR@" +LIBGTOP_SERVER="@LIBGTOP_SERVER@" + +libgtop_sysdeps_dir="@libgtop_sysdeps_dir@" +libgtop_need_server="@libgtop_need_server@" +libgtop_use_machine_h="@libgtop_use_machine_h@" + +libgtop_guile_found="@libgtop_guile_found@" + +libgtop_want_names="@libgtop_want_names@" +libgtop_want_guile_names="@libgtop_want_guile_names@" +libgtop_want_examples="@libgtop_want_examples@" From 7e13eec9f6b71b58e39f3eeda0a21694ca552bdd Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 23:21:25 +0000 Subject: [PATCH 0037/2539] rewrote that macro - moved some of the code to * acinclude.m4 (AC_LC_SYSDEPS): rewrote that macro - moved some of the code to 'macros/gnome-libgtop-sysdeps.m4'; renamed variables: look at the ChangeLog entry for the new 'libgtopConf.sh.in' for details. --- acinclude.m4 | 106 +++++++++++++++------------------------------------ 1 file changed, 31 insertions(+), 75 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 25cfa00a..85b32a5f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -29,120 +29,76 @@ AC_DEFUN([AC_LC_CANONICAL_HOST],[ AC_DEFUN([AC_LC_SYSDEPS],[ AC_REQUIRE([AC_LC_CANONICAL_HOST]) + AC_REQUIRE([GNOME_LIBGTOP_SYSDEPS]) - AC_MSG_CHECKING(for sysdeps directory) - - AC_ARG_WITH(sysdeps, - [ --with-sysdeps=dir which sysdeps directory should be used [default=auto]], - [if test "x$withval" = "xyes" ; then - ac_cv_sysdeps_dir=yes - elif test "x$withval" = "xauto" ; then - ac_cv_sysdeps_dir=yes - else - ac_cv_sysdeps_dir=$withval - fi],[ac_cv_sysdeps_dir=yes]) - - if test "x$ac_cv_sysdeps_dir" = "xyes" ; then - case "$host_os" in - linux*) - sysdeps_dir=linux - use_glibtop_machine_h=no - need_server=no - ;; - sunos4*) - sysdeps_dir=sun4 - use_glibtop_machine_h=no - need_server=yes - ;; - osf*) - sysdeps_dir=osf1 - use_glibtop_machine_h=yes - AC_DEFINE(HAVE_GLIBTOP_MACHINE_H) - need_server=yes - ;; - *) - sysdeps_dir=stub - use_glibtop_machine_h=no - need_server=no - ;; - esac - elif test "x$ac_cv_sysdeps_dir" = "xno" ; then - sysdeps_dir=stub - else - sysdeps_dir=stub - fi - - test -d $srcdir/sysdeps/$sysdeps_dir || sysdeps_dir=stub - AC_MSG_RESULT($sysdeps_dir) - - AC_MSG_CHECKING(whether we need the server) - + AC_MSG_CHECKING(whether we need the gtop_server) + AC_ARG_ENABLE(libgtop-server, [ --enable-libgtop-server use gtop_server [default=auto]], [if test "x$enableval" = "xyes" ; then - need_server=yes + libgtop_need_server=yes elif test "x$enableval" = "xno" ; then - need_server=no + libgtop_need_server=no fi]) - AC_MSG_RESULT($need_server) + AC_MSG_RESULT($libgtop_need_server) - AC_MSG_CHECKING(whether building of 'names' subdirs is requested) + AC_MSG_CHECKING(whether building of libgtop names is requested) AC_ARG_ENABLE(libgtop-names, [ --enable-libgtop-names enable building of 'names' subdirs [default=yes]], [if test "x$enableval" = "xyes" ; then - ac_cv_want_names=yes + libgtop_want_names=yes else - ac_cv_want_names=$enableval - fi],[ac_cv_want_names=yes]) + libgtop_want_names=$enableval + fi],[libgtop_want_names=yes]) - AC_MSG_RESULT($ac_cv_want_names) + AC_MSG_RESULT($libgtop_want_names) - if test x$ac_cv_want_names = xyes ; then + if test x$libgtop_want_names = xyes ; then AC_DEFINE(GLIBTOP_NAMES) fi - AM_CONDITIONAL(GLIBTOP_NAMES, test x$ac_cv_want_names = xyes) + AM_CONDITIONAL(GLIBTOP_NAMES, test x$libgtop_want_names = xyes) AC_MSG_CHECKING(whether building of the guile interface is requested) AC_ARG_ENABLE(libgtop-guile, - [ --enable-libgtop-guile enable building of guile interface [default=yes]], + [ --enable-libgtop-guile enable building of the guile interface [default=yes]], [if test "x$enableval" = "xyes" ; then - ac_cv_want_guile=yes + libgtop_want_guile=yes else - ac_cv_want_guile=$enableval - fi],[ac_cv_want_guile=yes]) + libgtop_want_guile=$enableval + fi],[libgtop_want_guile=yes]) - AC_MSG_RESULT($ac_cv_want_guile) + AC_MSG_RESULT($libgtop_want_guile) AC_MSG_CHECKING(whether building of the examples is requested) - AC_ARG_WITH(libgtop-examples, - [ --without-examples disable building of the examples], - [if test "x$withval" = "xyes" ; then - ac_cv_want_examples=yes + AC_ARG_ENABLE(libgtop-examples, + [ --disable-libgtop-examples disable building of the examples], + [if test "x$enableval" = "xyes" ; then + libgtop_want_examples=yes else - ac_cv_want_examples=$withval - fi],[ac_cv_want_examples=yes]) + libgtop_want_examples=$enableval + fi],[libgtop_want_examples=yes]) - AC_MSG_RESULT($ac_cv_want_examples) + AC_MSG_RESULT($libgtop_want_examples) - if test x$ac_cv_want_examples = xyes ; then + if test x$libgtop_want_examples = xyes ; then AC_DEFINE(GLIBTOP_EXAMPLES) fi - AM_CONDITIONAL(GLIBTOP_EXAMPLES, test x$ac_cv_want_examples = xyes) + AM_CONDITIONAL(GLIBTOP_EXAMPLES, test x$libgtop_want_examples = xyes) - if test x$use_glibtop_machine_h = xyes ; then + if test x$libgtop_use_machine_h = xyes ; then machine_incs="-I\$(top_srcdir)/sysdeps/$sysdeps_dir" fi AC_SUBST(machine_incs) - AC_SUBST(sysdeps_dir) - AC_SUBST(use_glibtop_machine_h) - AC_SUBST(need_server) + AC_SUBST(libgtop_want_names) + AC_SUBST(libgtop_want_guile) + AC_SUBST(libgtop_want_examples) ]) # Like AC_CONFIG_HEADER, but automatically create stamp file. From f0f9b51b47c3d7b85f5a30a82ce196d106acb70b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 23:22:59 +0000 Subject: [PATCH 0038/2539] added 'NEED_LIBGTOP'. * acconfig.h: added 'NEED_LIBGTOP'. --- acconfig.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/acconfig.h b/acconfig.h index ac64e471..f5f3f252 100644 --- a/acconfig.h +++ b/acconfig.h @@ -31,3 +31,5 @@ #undef GLIBTOP_NAMES #undef GLIBTOP_GUILE_NAMES #undef GLIBTOP_EXAMPLES + +#undef NEED_LIBGTOP From 37efa42ec685d0dc19b421d6d49bc5ac5714018a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 23:24:53 +0000 Subject: [PATCH 0039/2539] renamed variables for 'libgtopConf.sh.in'. * configure.in: renamed variables for 'libgtopConf.sh.in'. --- configure.in | 85 +++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/configure.in b/configure.in index c81928b6..87c1e4cd 100644 --- a/configure.in +++ b/configure.in @@ -107,65 +107,60 @@ if test "$need_libgtop_support" = yes; then fi dnl These definitions are expanded in make. -GTOP_LIBS='-L$(libdir)' -GTOP_INCS='-I$(includedir)' -GTOP_GUILE_LIBS="$GTOP_LIBS" -GTOP_GUILE_INCS="$GTOP_INCS" -GTOP_BINDIR='$(bindir)' -GTOP_SERVER='$(bindir)/gtop_server' +LIBGTOP_LIBS='-L$(libdir)' +LIBGTOP_INCS='-I$(includedir)' +LIBGTOP_GUILE_LIBS="$LIBGTOP_LIBS" +LIBGTOP_GUILE_INCS="$LIBGTOP_INCS" +LIBGTOP_BINDIR='$(bindir)' +LIBGTOP_SERVER='$(bindir)/gtop_server' -if test "x$ac_cv_guile_found" = "xyes" ; then - GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_guile" +sysdeps_dir="$libgtop_sysdeps_dir" +AC_SUBST(sysdeps_dir) + +if test x$ac_cv_guile_found = xyes ; then + LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_guile" + libgtop_guile_found=yes +else + libgtop_guile_found=no fi -if test "x$ac_cv_want_names" = "xyes" ; then - if test "x$ac_cv_guile_found" = "xyes" ; then - GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_guile_names" +AC_SUBST(libgtop_guile_found) + +if test x$libgtop_want_names = xyes ; then + if test x$ac_cv_guile_found = xyes ; then + LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_guile_names" + libgtop_want_guile_names=yes + else + libgtop_want_guile_names=no fi - GTOP_LIBS="$GTOP_LIBS -lgtop_names" - GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_names" + LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_names" + LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_names" fi -GTOP_LIBS="$GTOP_LIBS -lgtop_common" -GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_common" +AC_SUBST(libgtop_want_guile_names) + +LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common" +LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common" if test "x$need_server" = "xyes" ; then - GTOP_LIBS="$GTOP_LIBS -lgtop" - GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop" + LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop" + LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop" else - GTOP_LIBS="$GTOP_LIBS -lgtop_sysdeps" - GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS -lgtop_sysdeps" + LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_sysdeps" + LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_sysdeps" fi if test "x$ac_cv_guile_found" = "xyes" ; then - GTOP_GUILE_INCS="$GTOP_INCS $GUILE_INCS" - GTOP_GUILE_LIBS="$GTOP_GUILE_LIBS $GUILE_LIBS" + LIBGTOP_GUILE_INCS="$LIBGTOP_INCS $GUILE_INCS" + LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS $GUILE_LIBS" fi -gtop_guile_found="$ac_cv_guile_found" - -gtop_want_names="$ac_cv_want_names" - -if test "x$ac_cv_guile_found" = "xyes" ; then - gtop_want_guile_names="$ac_cv_want_names" -else - gtop_want_guile_names="no" -fi - -gtop_want_examples="$ac_cv_want_examples" - -AC_SUBST(gtop_guile_found) - -AC_SUBST(gtop_want_names) -AC_SUBST(gtop_want_guile_names) -AC_SUBST(gtop_want_examples) - -AC_SUBST(GTOP_LIBS) -AC_SUBST(GTOP_INCS) -AC_SUBST(GTOP_GUILE_LIBS) -AC_SUBST(GTOP_GUILE_INCS) -AC_SUBST(GTOP_BINDIR) -AC_SUBST(GTOP_SERVER) +AC_SUBST(LIBGTOP_LIBS) +AC_SUBST(LIBGTOP_INCS) +AC_SUBST(LIBGTOP_GUILE_LIBS) +AC_SUBST(LIBGTOP_GUILE_INCS) +AC_SUBST(LIBGTOP_BINDIR) +AC_SUBST(LIBGTOP_SERVER) AC_SUBST(LIBSUPPORT) AC_SUBST(SUPPORTINCS) From 1d47b76ea15c680395e8933680c8641dddf4f390 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 23:26:18 +0000 Subject: [PATCH 0040/2539] uses '@LIBGTOP_SERVER@' instead of '@GTOP_SERVER@'. * lib/Makefile.am: uses '@LIBGTOP_SERVER@' instead of '@GTOP_SERVER@'. --- lib/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index 4c115f50..e98f0f52 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -4,7 +4,7 @@ INCLUDES = -I$(includedir) -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=\""@GTOP_SERVER@"\" +CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\" lib_LTLIBRARIES = libgtop.la From 022369f08ad92e95519a9b41eb706740fc5b3da0 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 23:29:00 +0000 Subject: [PATCH 0041/2539] 'gtopConf.sh' has been renamed to 'libgtopConf.sh'; variables in this * Makefile.am: 'gtopConf.sh' has been renamed to 'libgtopConf.sh'; variables in this script have changed. --- Makefile.am | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1921ecf7..c08f2026 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ DIST_SUBDIRS = po intl support macros include sysdeps src lib examples include_HEADERS = glibtop.h -EXTRA_DIST = copyright.txt gtopConf.sh.in +EXTRA_DIST = copyright.txt libgtopConf.sh.in release: $(MAKE) dist distdir=$(PACKAGE)$(VERSION) @@ -20,7 +20,7 @@ release: ## Put `exec' in the name because this should be installed by ## `install-exec', not `install-data'. confexecdir=$(libdir) -confexec_DATA = $(top_builddir)/gtopConf.sh +confexec_DATA = $(top_builddir)/libgtopConf.sh ## to automatically rebuild aclocal.m4 if any of the macros in ## `macros/' change @@ -28,26 +28,26 @@ confexec_DATA = $(top_builddir)/gtopConf.sh @MAINT@macros/macros.dep: macros/Makefile.am @MAINT@ cd macros && $(MAKE) macros.dep -## We create gtopConf.sh here and not from configure because we want +## We create libgtopConf.sh here and not from configure because we want ## to get the paths expanded correctly. Macros like srcdir are given ## the value NONE in configure if the user doesn't specify them (this ## is an autoconf feature, not a bug). -gtopConf.sh: gtopConf.sh.in Makefile +libgtopConf.sh: libgtopConf.sh.in Makefile ## Use sed and then mv to avoid problems if the user interrupts. - sed -e 's,\@GTOP_LIBDIR\@,$(libdir),g' \ - -e 's,\@GTOP_INCLUDEDIR\@,$(includedir),g' \ - -e 's,\@GTOP_LIBS\@,$(GTOP_LIBS),g' \ - -e 's,\@GTOP_INCS\@,$(GTOP_INCS),g' \ - -e 's,\@GTOP_GUILE_LIBS\@,$(GTOP_GUILE_LIBS),g' \ - -e 's,\@GTOP_GUILE_INCS\@,$(GTOP_GUILE_INCS),g' \ - -e 's,\@GTOP_BINDIR\@,$(GTOP_BINDIR),g' \ - -e 's,\@GTOP_SERVER\@,$(GTOP_SERVER),g' \ - -e 's,\@GTOP_SYSDEPS_DIR\@,$(sysdeps_dir),g' \ - -e 's,\@GTOP_NEED_SERVER\@,$(need_server),g' \ - -e 's,\@GTOP_USE_MACHINE_H\@,$(use_glibtop_machine_h),g' \ - -e 's,\@GTOP_GUILE_FOUND\@,$(gtop_guile_found),g' \ - -e 's,\@GTOP_WANT_NAMES\@,$(gtop_want_names),g' \ - -e 's,\@GTOP_WANT_GUILE_NAMES\@,$(gtop_want_guile_names),g' \ - -e 's,\@GTOP_WANT_EXAMPLES\@,$(gtop_want_examples),g' \ - < $(srcdir)/gtopConf.sh.in > gtopConf.tmp \ - && mv gtopConf.tmp gtopConf.sh + sed -e 's,\@LIBGTOP_LIBDIR\@,$(libdir),g' \ + -e 's,\@LIBGTOP_INCLUDEDIR\@,$(includedir),g' \ + -e 's,\@LIBGTOP_LIBS\@,$(LIBGTOP_LIBS),g' \ + -e 's,\@LIBGTOP_INCS\@,$(LIBGTOP_INCS),g' \ + -e 's,\@LIBGTOP_GUILE_LIBS\@,$(LIBGTOP_GUILE_LIBS),g' \ + -e 's,\@LIBGTOP_GUILE_INCS\@,$(LIBGTOP_GUILE_INCS),g' \ + -e 's,\@LIBGTOP_BINDIR\@,$(LIBGTOP_BINDIR),g' \ + -e 's,\@LIBGTOP_SERVER\@,$(LIBGTOP_SERVER),g' \ + -e 's,\@libgtop_sysdeps_dir\@,$(libgtop_sysdeps_dir),g' \ + -e 's,\@libgtop_need_server\@,$(libgtop_need_server),g' \ + -e 's,\@libgtop_use_machine_h\@,$(libgtop_use_machine_h),g' \ + -e 's,\@libgtop_guile_found\@,$(libgtop_guile_found),g' \ + -e 's,\@libgtop_want_names\@,$(libgtop_want_names),g' \ + -e 's,\@libgtop_want_guile_names\@,$(libgtop_want_guile_names),g' \ + -e 's,\@libgtop_want_examples\@,$(libgtop_want_examples),g' \ + < $(srcdir)/libgtopConf.sh.in > libgtopConf.tmp \ + && mv libgtopConf.tmp libgtopConf.sh From bee25bc2182d1911820469bfb8d303b5028e6cbb Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 21 May 1998 23:30:35 +0000 Subject: [PATCH 0042/2539] *** empty log message *** --- ChangeLog | 26 ++++++++++ doc/gnome-hackers.sgml | 112 ++++++++++++++++++++++++++++++++--------- 2 files changed, 115 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index da136519..9b7f2972 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,31 @@ 1998-05-21 Martin Baulig + * Makefile.am: 'gtopConf.sh' has been renamed to + 'libgtopConf.sh'; variables in this script have changed. + + * lib/Makefile.am: uses '@LIBGTOP_SERVER@' instead of + '@GTOP_SERVER@'. + + * configure.in: renamed variables for 'libgtopConf.sh.in'. + + * acconfig.h: added 'NEED_LIBGTOP'. + + * libgtopConf.sh.in: renamed from 'gtopConf.sh.in'; + we now define 'LIBGTOP_LIBDIR', 'LIBGTOP_INCLUDEDIR', + 'LIBGTOP_LIBS', 'LIBGTOP_INCS', 'LIBGTOP_GUILE_LIBS', + 'LIBGTOP_GUILE_INCS', 'LIBGTOP_BINDIR', 'LIBGTOP_SERVER', + 'libgtop_sysdeps_dir', 'libgtop_need_server', + 'libgtop_use_machine_h', 'libgtop_guile_found', + 'libgtop_want_names', 'libgtop_want_guile_names', + 'libgtop_want_examples'. + + * gtopConf.sh.in: renamed to 'libgtopConf.sh.in'. + + * acinclude.m4 (AC_LC_SYSDEPS): rewrote that macro - + moved some of the code to 'macros/gnome-libgtop-sysdeps.m4'; + renamed variables: look at the ChangeLog entry for the + new 'libgtopConf.sh.in' for details. + * doc/gnome-hackers.sgml: added information about latest changes in 'acinclude.m4' and 'gtopConf.sh.in'. diff --git a/doc/gnome-hackers.sgml b/doc/gnome-hackers.sgml index 6edbf6fa..a6f16855 100644 --- a/doc/gnome-hackers.sgml +++ b/doc/gnome-hackers.sgml @@ -1,7 +1,7 @@ + ]> @@ -57,7 +57,7 @@ libgtop in the GNOME project. It describes the additional options configure takes and the information stored in the automatically generated - gtopConf.sh configuration script. + libgtopConf.sh configuration script. @@ -65,6 +65,70 @@ + + Autoconf macros + + + <filename>macros/gnome-libgtop-sysdeps.m4</filename> + + + This file defines GNOME_LIBGTOP_SYSDEPS which you can + use to check which sysdeps directory libgtop should + use and whether the gtop_server is needed. + + + It defines the following variables: + + + + + libgtop_sysdeps_dir + + + + The sysdeps dir libgtop uses. + + + libgtop_use_machine_h + + + + Some of the system dependent parts of libgtop + provide a structure _glibtop_machine defined in + a header file glibtop_machine.h they provide. This + structure gets inserted into the machine member + of _glibtop when config.h + defines HAVE_GLIBTOP_MACHINE_H. + + + This variable is either yes or no and + tells you whether this is the case. If it is true, this macro wil automatically + define HAVE_GLIBTOP_MACHINE_H. + + + libgtop_need_server + + + + Is either yes or no and tells you + whether the server is needed. If it is needed, it will automatically + define NEED_LIBGTOP. + + + This macro also provides a conditional NEED_LIBGTOP + which you can use in you Makefile.am. + + + + + <filename>macros/gnome-libgtop-check.m4</filename> + + + Checks whether libgtop can be found and includes everything + from its libgtopConf.sh configuration script. + + + Configuration @@ -81,7 +145,7 @@ server is required. Depending upon this decision, it adds either -lgtop (when it's needed) or -lgtop_systems (when it's not needed) to - GTOP_LIBS and GTOP_GUILE_LIBS. + LIBGTOP_LIBS and LIBGTOP_GUILE_LIBS. You can change this behaviour with the following options: @@ -135,7 +199,6 @@ If you do not need the names subdirs, you can disable their building with the following option: - when guile can be found on the system. @@ -155,6 +218,9 @@ + + If it is enables, GLIBTOP_NAMES will be defined. + @@ -173,12 +239,12 @@ - - The <filename>gtopConf.sh</filename> script + + The <filename>libgtopConf.sh</filename> script After a successful build of libgtop, a - gtopConf.sh script is generated which will later + libgtopConf.sh script is generated which will later be used to decide how to link a program with libgtop. @@ -187,7 +253,7 @@ - GTOP_LIBDIR + LIBGTOP_LIBDIR @@ -195,7 +261,7 @@ where the libgtop libraries get installed. - GTOP_INCLUDEDIR + LIBGTOP_INCLUDEDIR @@ -203,7 +269,7 @@ where the libgtop header files get installed. - GTOP_LIBS + LIBGTOP_LIBS @@ -212,7 +278,7 @@ libgtop. - GTOP_INCS + LIBGTOP_INCS @@ -221,7 +287,7 @@ libgtop. - GTOP_GUILE_INCS + LIBGTOP_GUILE_INCS @@ -230,7 +296,7 @@ libgtop and its guile interface. - GTOP_BINDIR + LIBGTOP_BINDIR @@ -238,7 +304,7 @@ libgtop binaries get installed. - GTOP_SERVER + LIBGTOP_SERVER @@ -246,14 +312,14 @@ where the server gets installed. - GTOP_SYSDEPS_DIR + libgtop_sysdeps_dir The sysdeps directory that is used on your system. - GTOP_NEED_SERVER + libgtop_need_server @@ -261,7 +327,7 @@ whether using the server is needed or not. - GTOP_USE_MACHINE_H + libgtop_use_machine_h @@ -276,7 +342,7 @@ _glibtop. - GTOP_GUILE_FOUND + libgtop_guile_found @@ -285,7 +351,7 @@ (or if building the guile interface was disabled). - GTOP_WANT_NAMES + libgtop_want_names @@ -293,7 +359,7 @@ whether the sysdeps/names subdirectory was build. - GTOP_WANT_GUILE_NAMES + libgtop_want_guile_names @@ -301,7 +367,7 @@ whether the sysdeps/guile/names subdirectory was build. - GTOP_WANT_EXAMPLES + libgtop_want_examples @@ -311,9 +377,9 @@ - Sample <filename>gtopConf.sh</filename> + Sample <filename>libgtopConf.sh</filename> - >opConf.sh; + &libgtopConf.sh; From 33f52f01b80b0a29ac57b025adb3b59240e8324b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 22 May 1998 00:42:47 +0000 Subject: [PATCH 0043/2539] *** empty log message *** --- .cvsignore | 1 + doc/gnome-hackers.sgml | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.cvsignore b/.cvsignore index 1e0ac471..abed9664 100644 --- a/.cvsignore +++ b/.cvsignore @@ -15,6 +15,7 @@ i686-pc-linux-gnu intl libgtop-0.01.tar.gz libgtop-mirror.sh.swp +libgtopConf.sh libtool ltconfig ltmain.sh diff --git a/doc/gnome-hackers.sgml b/doc/gnome-hackers.sgml index a6f16855..7f81e2d9 100644 --- a/doc/gnome-hackers.sgml +++ b/doc/gnome-hackers.sgml @@ -68,6 +68,20 @@ Autoconf macros + + <filename>macros/gnome-libgtop-check.m4</filename> + + + Contains all that you need to include libgtop in any Gnome application. It defines + GNOME_INIT_LIBGTOP which you can use in the same way like + GNOME_INIT to check whether libgtop is installed and to read + its libgtopConf.sh script. It automatically invokes + GNOME_LIBGTOP_SYSDEPS. + + + When libgtop can be found, it defines HAVE_LIBGTOP. There's + also an automake conditional HAVE_LIBGTOP which you can use. + <filename>macros/gnome-libgtop-sysdeps.m4</filename> @@ -120,13 +134,6 @@ - - <filename>macros/gnome-libgtop-check.m4</filename> - - - Checks whether libgtop can be found and includes everything - from its libgtopConf.sh configuration script. - From 26628a62149a950cc102a620d41cb43ddbe74038 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 22 May 1998 23:22:03 +0000 Subject: [PATCH 0044/2539] New file. Uses the guile interface of libgtop to create docbook * guile/make-docbook.scm: New file. Uses the guile interface of libgtop to create docbook documentation for all functions. --- guile/make-docbook.scm | 266 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 guile/make-docbook.scm diff --git a/guile/make-docbook.scm b/guile/make-docbook.scm new file mode 100644 index 00000000..b993db92 --- /dev/null +++ b/guile/make-docbook.scm @@ -0,0 +1,266 @@ +;; $Id$ + +(define sysdeps-list '()) + +(define make-sysdeps-list + (lambda () + (letrec ((names (glibtop-names-sysdeps)) + (labels (glibtop-labels-sysdeps)) + (descriptions (glibtop-descriptions-sysdeps)) + ) + (for-each (lambda (feature) + (let* ((label (car labels)) + (description (car descriptions)) + (list '()) + ) + (set! labels (cdr labels)) + (set! descriptions (cdr descriptions)) + (set! list (assoc-set! list 'name feature)) + (set! list (assoc-set! list 'label label)) + (set! list (assoc-set! list 'description description)) + (set! sysdeps-list (assoc-set! sysdeps-list feature list)) + ) + ) + names) + ) + ) + ) + +(define make-docbook + (lambda (feature) + (let* ((names (eval-string (string "(glibtop-names-" feature ")"))) + (types (eval-string (string "(glibtop-types-" feature ")"))) + (labels (eval-string (string "(glibtop-labels-" feature ")"))) + (sysdeps (assoc-ref sysdeps-list feature)) (retval "void") + (name (assoc-ref sysdeps 'name)) + (label (assoc-ref sysdeps 'label)) + (description (assoc-ref sysdeps 'description)) + (descriptions (eval-string (string "(glibtop-descriptions-" feature ")"))) + (decl-list '()) (field-list '()) + + (synopsis-start-string + (string "Automatically generated function synopsis:\n\n")) + + (section-string + (string "\n" + "<function>glibtop_get_" feature "()</function> - " + label "\n\n") + ) + + (description-string + (string "\nAutomatically generated description:\n\n" + "
\n\n" + description "\n" + "\n
\n\n") + ) + + (definition-start-string + (string "Automatically generated declaration of " + "_glibtop_" feature ":\n\n") + ) + + (funcsynopsisinfo-string + (string "\n" + "#include <glibtop.h>\n" + "#include <glibtop/" feature ".h>" + "") + ) + + (funcdef-string + (string "" retval " " + "glibtop_get_" feature "__r" + "\n") + ) + + (paramdef-string + (string "glibtop *server, " + "glibtop_" feature " *" feature "\n" + "") + ) + + (funcdef-noserver-string + (string "" retval " " + "glibtop_get_" feature "" + "\n") + ) + + (paramdef-noserver-string + (string "glibtop_" feature " *" + "" feature "\n" + "") + ) + + (field-name-constant + (lambda (name field) + (string "GLIBTOP_" + (string-upcase! (string name)) + "_" + (string-upcase! (string field))) + ) + ) + + (make-struct-name + (lambda (type) + (string "glibtop_" (assoc-ref type "name")) + ) + ) + + (tab-pad-string + (lambda (string tabs) + (let* ((slength (string-length string)) + (tlength (* tabs 8))) + (string-append string + (make-string + (if (> tlength slength) + (- tlength slength) + 1 + ) + #\space)) + ) + ) + ) + + (make-field-list + (lambda (name type fields) + (let* ((output (string)) (pos 1)) + (map + (lambda (x) + (let* ((sep (if (= pos (length fields)) ";" ",")) + (start (if (= pos 1) + (string "\t" + (tab-pad-string (string type) 2)) + (string "\t\t")) + ) + (comment (string (if (= pos 1) "" "\t") "/* " + (tab-pad-string + (field-name-constant name (car x)) 3) + " */")) + (field (tab-pad-string + (string-append (string (car x)) sep) 2)) + ) + (set! pos (+ pos 1)) + (string-append start field comment "\n") + ) + ) + fields) + ) + ) + ) + + (init-field-list + (lambda () + (let* ((old-type #f) + (type-list types) + (new-type #f) + (fields (list)) + ) + (for-each + (lambda (x) + (set! new-type (car type-list)) + (set! type-list (cdr type-list)) + (if (equal? old-type new-type) + (set-car! fields + (append (list new-type) + (cdr (car fields)) + (list (list x)) + ) + ) + (if (equal? old-type #f) + (set! fields (list (list new-type (list x)))) + (set! fields (append (list (list new-type (list x))) fields)) + ) + ) + (set! old-type new-type) + ) + names) + fields) + ) + ) + + (make-struct-body + (lambda (type) + (let* ((name (assoc-ref type "name")) + (data (assoc-ref type "fields")) + (output (string)) + ) + (for-each + (lambda (y) + (for-each + (lambda (z) + (set! output (string-append output z)) + ) + y) + ) + (map + (lambda (x) (make-field-list name (car x) (cdr x))) + data) + ) + output) + ) + ) + + (make-struct + (lambda (type) + (let* ((name (assoc-ref type "name")) + (data (assoc-ref type "fields")) + (output (string-append + (tab-pad-string + (string "typedef struct _glibtop_" name) + 5) + (string "glibtop_" name ";\n\n" + "struct glibtop_" name "\n{\n\t" + "unsigned long\tflags;\n") + ) + ) + ) + (string-append output (make-struct-body type) "};\n") + ) + ) + ) + ) + + (set! decl-list (assoc-set! decl-list "name" name)) + (set! decl-list (assoc-set! decl-list "label" label)) + (set! decl-list (assoc-set! decl-list "fields" (init-field-list))) + + (string-append section-string + description-string + synopsis-start-string + (string "
\n\n") + funcsynopsisinfo-string + funcdef-noserver-string + paramdef-noserver-string + (string "\n") + (string "\n") + funcdef-string + paramdef-string + (string "\n
\n") + definition-start-string + (string "
\n\n") + (make-struct decl-list) + (string "\n
\n") + ) + ) + ) + ) + +;; +;; <function>glibtop_get_cpu()</function> - get CPU usage +;; +;; +;; +;; #include <glibtop.h> +;; #include <glibtop/cpu.h> +;; void glibtop_get_cpu +;; glibtop *server, glibtop_cpu *cpu_usage +;; + + + +(begin + (make-sysdeps-list) + (for-each (lambda (x) + (display (make-docbook x)) + ) + (glibtop-names-sysdeps)) + ) From c67ba32006ad2350a1a44a1b29e006083793ae82 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 22 May 1998 23:24:06 +0000 Subject: [PATCH 0045/2539] Small bugfixes. --- sysdeps/guile/names/boot.c | 6 ++++++ sysdeps/guile/names/proclist.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sysdeps/guile/names/boot.c b/sysdeps/guile/names/boot.c index ec96ac22..01ceb255 100644 --- a/sysdeps/guile/names/boot.c +++ b/sysdeps/guile/names/boot.c @@ -90,6 +90,8 @@ glibtop_boot_guile_names (void) ("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 @@ -125,6 +127,8 @@ glibtop_boot_guile_names (void) ("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 @@ -159,6 +163,8 @@ glibtop_boot_guile_names (void) ("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 diff --git a/sysdeps/guile/names/proclist.c b/sysdeps/guile/names/proclist.c index 34240142..7269d085 100644 --- a/sysdeps/guile/names/proclist.c +++ b/sysdeps/guile/names/proclist.c @@ -53,7 +53,7 @@ glibtop_guile_types_proclist (void) for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) list = gh_append2 (list, gh_list - (gh_str02scm (glibtop_labels_proclist [i]), + (gh_str02scm (glibtop_types_proclist [i]), SCM_UNDEFINED)); return list; From 1e541ba56cc00bf2f806c7a50fd898151fdf28c0 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 22 May 1998 23:33:23 +0000 Subject: [PATCH 0046/2539] New files. This is a reference manual that gets automatically build from * doc/{libgtop-ref.sgml, libgtop-ref.dsl}: New files. This is a reference manual that gets automatically build from make-docbook.scm. --- doc/libgtop-ref.dsl | 12 +++++++++ doc/libgtop-ref.sgml | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 doc/libgtop-ref.dsl create mode 100644 doc/libgtop-ref.sgml diff --git a/doc/libgtop-ref.dsl b/doc/libgtop-ref.dsl new file mode 100644 index 00000000..78cd4cb8 --- /dev/null +++ b/doc/libgtop-ref.dsl @@ -0,0 +1,12 @@ + +]> + + + +(define %output-basename% "libgtop-ref") +(define %output-directory% "libgtop-ref") + + + + diff --git a/doc/libgtop-ref.sgml b/doc/libgtop-ref.sgml new file mode 100644 index 00000000..292d3a20 --- /dev/null +++ b/doc/libgtop-ref.sgml @@ -0,0 +1,60 @@ + + + +]> + + + LibGTop Reference Manual + + + Martin + Baulig + +
+ martin@home-of-linux.org +
+
+
+
+ + 1998 + Martin Baulig + + + + + This documentation 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 of the License, or (at your option) any later + version. + + + This library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, + MA 02111-1307 USA + + + For more details see the file COPYING in the source + distribution of LibGTop. + + +
+ + + + + Function Reference List + + &reference.sgml; + +
From cd9d6bbb3996130a0d77b73af48a21b33e44d512 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 22 May 1998 23:35:09 +0000 Subject: [PATCH 0047/2539] *** empty log message *** --- ChangeLog | 10 ++++++++++ doc/.cvsignore | 2 ++ doc/Makefile | 9 ++++++++- guile/.cvsignore | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 guile/.cvsignore diff --git a/ChangeLog b/ChangeLog index 9b7f2972..45e1fc53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1998-05-22 Martin Baulig + + * doc/{libgtop-ref.sgml, libgtop-ref.dsl}: New files. + This is a reference manual that gets automatically + build from make-docbook.scm. + + * guile/make-docbook.scm: New file. Uses the guile + interface of libgtop to create docbook documentation + for all functions. + 1998-05-21 Martin Baulig * Makefile.am: 'gtopConf.sh' has been renamed to diff --git a/doc/.cvsignore b/doc/.cvsignore index c0f3bd58..7ceb66f0 100644 --- a/doc/.cvsignore +++ b/doc/.cvsignore @@ -1,6 +1,7 @@ *.shml .timestamp .timestamp2 +.timestamp3 dbtohtml-1.shtml dbtohtml-2.shtml dbtohtml-3.shtml @@ -14,6 +15,7 @@ libgtop-3.shtml libgtop-4.shtml libgtop-5.shtml libgtop-INDEX.shtml +libgtop-ref libgtop.ced libgtop.fot libgtop.shtml diff --git a/doc/Makefile b/doc/Makefile index fa30b74a..f020f45a 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,4 +1,4 @@ -all: .timestamp .timestamp2 +all: .timestamp .timestamp2 .timestamp3 .timestamp: libgtop.sgml rm -rf libgtop @@ -13,3 +13,10 @@ all: .timestamp .timestamp2 jade -D /usr/lib/sgml/jade_dsl -d gnome-hackers.dsl -t sgml \ -V %no-make-index% gnome-hackers.sgml > /dev/null && \ touch .timestamp2 + +.timestamp3: libgtop-ref.sgml ../guile/reference.sgml + rm -rf libgtop-ref + mkdir libgtop-ref + jade -D /usr/lib/sgml/jade_dsl -d libgtop-ref.dsl -t sgml \ + -V %no-make-index% libgtop-ref.sgml > /dev/null && \ + touch .timestamp3 diff --git a/guile/.cvsignore b/guile/.cvsignore new file mode 100644 index 00000000..de3f8239 --- /dev/null +++ b/guile/.cvsignore @@ -0,0 +1 @@ +reference.sgml From 29ba1a484b859b825fa383a949f2f21d40abd20d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 22 May 1998 23:55:35 +0000 Subject: [PATCH 0048/2539] Fixed typo. --- configure.in | 4 ++-- sysdeps/guile/names/procmem.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 87c1e4cd..194e1aa5 100644 --- a/configure.in +++ b/configure.in @@ -26,10 +26,10 @@ export CC CXX RANLIB LD AS AR NM AC_LC_SYSDEPS -if test x$ac_cv_want_guile = xyes ; then +if test x$libgtop_want_guile = xyes ; then GNOME_CHECK_GUILE if test x$ac_cv_guile_found = xyes ; then - if test x$ac_cv_want_names = xyes ; then + if test x$libgtop_want_names = xyes ; then AC_DEFINE(GLIBTOP_GUILE_NAMES) fi guile_examples='third third_static third_linux' diff --git a/sysdeps/guile/names/procmem.c b/sysdeps/guile/names/procmem.c index 58ad25dd..4daf9967 100644 --- a/sysdeps/guile/names/procmem.c +++ b/sysdeps/guile/names/procmem.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_mem (void) for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) list = gh_append2 (list, gh_list - (gh_str02scm (glibtop_labels_proc_mem [i]), + (gh_str02scm (glibtop_types_proc_mem [i]), SCM_UNDEFINED)); return list; From 7cd525974aa0760824a420468a57a7abe2c364fe Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 22 May 1998 23:56:06 +0000 Subject: [PATCH 0049/2539] Added information about struct fields. --- guile/make-docbook.scm | 46 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/guile/make-docbook.scm b/guile/make-docbook.scm index b993db92..2c2d6eb7 100644 --- a/guile/make-docbook.scm +++ b/guile/make-docbook.scm @@ -53,12 +53,17 @@ description "\n" "\n\n\n") ) - + (definition-start-string (string "Automatically generated declaration of " "_glibtop_" feature ":\n\n") ) + (param-description-start-string + (string "Automatically generated descriptions of " + "_glibtop_" feature ":\n\n") + ) + (funcsynopsisinfo-string (string "\n" "#include <glibtop.h>\n" @@ -133,7 +138,7 @@ ) (comment (string (if (= pos 1) "" "\t") "/* " (tab-pad-string - (field-name-constant name (car x)) 3) + (field-name-constant name (car x)) 4) " */")) (field (tab-pad-string (string-append (string (car x)) sep) 2)) @@ -217,8 +222,39 @@ ) ) ) - ) + (make-param-description + (lambda () + (let* ((label-list labels) + (description-list descriptions) + (output (string)) + ) + (for-each + (lambda (name) + (let* ((label (car label-list)) + (description (car description-list)) + ) + (set! label-list (cdr label-list)) + (set! description-list (cdr description-list)) + (set! output + (string-append output + (string "\n" + "" + name + "\n\n" + "\n\n" + description "\n\n") + ) + ) + ) + ) + names) + output) + ) + ) + + ) + (set! decl-list (assoc-set! decl-list "name" name)) (set! decl-list (assoc-set! decl-list "label" label)) (set! decl-list (assoc-set! decl-list "fields" (init-field-list))) @@ -239,6 +275,10 @@ (string "
\n\n") (make-struct decl-list) (string "\n
\n") + param-description-start-string + "\n\n" + (make-param-description) + "\n\n" ) ) ) From 39be9f45bb4f492ad7fc21d075edb6dc150a57d7 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 13:46:31 +0000 Subject: [PATCH 0050/2539] added -D_IN_LIBGTOP * configure.in (CFLAGS): added -D_IN_LIBGTOP --- configure.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.in b/configure.in index 194e1aa5..3c2b8f20 100644 --- a/configure.in +++ b/configure.in @@ -93,6 +93,8 @@ AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv strdup strtoul uname) ALL_LINGUAS="" AM_GNU_GETTEXT +CFLAGS="$CFLAGS -D_IN_LIBGTOP" + AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) From 977a3695f67db6c6e85d73f0c6f0dfaf7dad6596 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 13:50:46 +0000 Subject: [PATCH 0051/2539] removed -I$(includedir). * */Makefile.am (INCLUDES): removed -I$(includedir). --- examples/Makefile.am | 2 +- lib/Makefile.am | 2 +- src/server/Makefile.am | 2 +- sysdeps/common/Makefile.am | 2 +- sysdeps/guile/Makefile.am | 2 +- sysdeps/guile/names/Makefile.am | 2 +- sysdeps/linux/Makefile.am | 2 +- sysdeps/names/Makefile.am | 2 +- sysdeps/osf1/Makefile.am | 2 +- sysdeps/stub/Makefile.am | 2 +- sysdeps/sun4/Makefile.am | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 88bbc5ae..54b126de 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -2,7 +2,7 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/lib/Makefile.am b/lib/Makefile.am index e98f0f52..31dda65f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/src/server/Makefile.am b/src/server/Makefile.am index 3c2ad0e0..5bab7942 100644 --- a/src/server/Makefile.am +++ b/src/server/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/common/Makefile.am b/sysdeps/common/Makefile.am index b7d1c017..d61567c7 100644 --- a/sysdeps/common/Makefile.am +++ b/sysdeps/common/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am index 125f7d8a..19bd1d1d 100644 --- a/sysdeps/guile/Makefile.am +++ b/sysdeps/guile/Makefile.am @@ -6,7 +6,7 @@ DIST_SUBDIRS = names LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/guile/names/Makefile.am b/sysdeps/guile/names/Makefile.am index 24387126..80f4fb88 100644 --- a/sysdeps/guile/names/Makefile.am +++ b/sysdeps/guile/names/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index 0c17dbea..7d161c51 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/names/Makefile.am b/sysdeps/names/Makefile.am index 96e43037..f650e158 100644 --- a/sysdeps/names/Makefile.am +++ b/sysdeps/names/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/osf1/Makefile.am b/sysdeps/osf1/Makefile.am index 7903bcab..35a64d0a 100644 --- a/sysdeps/osf1/Makefile.am +++ b/sysdeps/osf1/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am index 9c188950..2545ce47 100644 --- a/sysdeps/stub/Makefile.am +++ b/sysdeps/stub/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 diff --git a/sysdeps/sun4/Makefile.am b/sysdeps/sun4/Makefile.am index 65d5a793..cc5126d7 100644 --- a/sysdeps/sun4/Makefile.am +++ b/sysdeps/sun4/Makefile.am @@ -1,6 +1,6 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = -I$(includedir) -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \ +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 From e5ad7e782f335d3621017b7f5cdcdf5fd1cbc7bf Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 13:51:28 +0000 Subject: [PATCH 0052/2539] *** empty log message *** --- ChangeLog | 6 ++++++ doc/.cvsignore | 1 + doc/libgtop-ref.sgml | 17 ++++++++++++----- guile/make-docbook.scm | 11 ++++++++--- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 45e1fc53..8ae36717 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1998-05-23 Martin Baulig + + * configure.in (CFLAGS): added -D_IN_LIBGTOP + + * */Makefile.am (INCLUDES): removed -I$(includedir). + 1998-05-22 Martin Baulig * doc/{libgtop-ref.sgml, libgtop-ref.dsl}: New files. diff --git a/doc/.cvsignore b/doc/.cvsignore index 7ceb66f0..d91096a3 100644 --- a/doc/.cvsignore +++ b/doc/.cvsignore @@ -16,6 +16,7 @@ libgtop-4.shtml libgtop-5.shtml libgtop-INDEX.shtml libgtop-ref +libgtop-ref.ced libgtop.ced libgtop.fot libgtop.shtml diff --git a/doc/libgtop-ref.sgml b/doc/libgtop-ref.sgml index 292d3a20..93e645c2 100644 --- a/doc/libgtop-ref.sgml +++ b/doc/libgtop-ref.sgml @@ -17,6 +17,16 @@ + + + $Id$ + + + This reference manual is automatically generated from doc/make-docbook.scm. + It uses the guile interface of libgtop to get the names of all + features the library defines and a description of the structures. + + 1998 Martin Baulig @@ -49,12 +59,9 @@
- + - - - Function Reference List - + &reference.sgml;
diff --git a/guile/make-docbook.scm b/guile/make-docbook.scm index 2c2d6eb7..aae7542b 100644 --- a/guile/make-docbook.scm +++ b/guile/make-docbook.scm @@ -26,7 +26,7 @@ ) ) -(define make-docbook +(define make-function-reference (lambda (feature) (let* ((names (eval-string (string "(glibtop-names-" feature ")"))) (types (eval-string (string "(glibtop-types-" feature ")"))) @@ -37,7 +37,7 @@ (description (assoc-ref sysdeps 'description)) (descriptions (eval-string (string "(glibtop-descriptions-" feature ")"))) (decl-list '()) (field-list '()) - + (synopsis-start-string (string "Automatically generated function synopsis:\n\n")) @@ -299,8 +299,13 @@ (begin (make-sysdeps-list) + + (display (string "\n" + "Function Reference List\n\n") + ) + (for-each (lambda (x) - (display (make-docbook x)) + (display (make-function-reference x)) ) (glibtop-names-sysdeps)) ) From 40b6a23c639911b672a53d32bc924df4b8f3d871 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 16:08:27 +0000 Subject: [PATCH 0053/2539] Fixed 'need_gnome_support' typo. --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 3c2b8f20..b3264e50 100644 --- a/configure.in +++ b/configure.in @@ -103,8 +103,8 @@ AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=no]], LIBSUPPORT= SUPPORTINCS= -if test "$need_libgtop_support" = yes; then - LIBSUPPORT='$(top_builddir)/support/libgtopsupport.la' +if test "$need_gnome_support" = yes; then + LIBSUPPORT='$(top_builddir)/support/libgnomesupport.la' SUPPORTINCS='-I$(top_srcdir)/support' fi From 00176cd6e81f90bb055910c0be798de0ec8ea46b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 23:00:46 +0000 Subject: [PATCH 0054/2539] Added 'machine_incs' again. --- configure.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.in b/configure.in index b3264e50..5df8406d 100644 --- a/configure.in +++ b/configure.in @@ -157,6 +157,12 @@ if test "x$ac_cv_guile_found" = "xyes" ; then 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 + +AC_SUBST(machine_incs) + AC_SUBST(LIBGTOP_LIBS) AC_SUBST(LIBGTOP_INCS) AC_SUBST(LIBGTOP_GUILE_LIBS) From 37e161bcecf014c2035905d6c0b4f92c83c86895 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 23:03:59 +0000 Subject: [PATCH 0055/2539] New file. System dependend header file for SunOS. * sysdeps/sun4/glibtop_machine.h: New file. System dependend header file for SunOS. --- sysdeps/sun4/glibtop_machine.h | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 sysdeps/sun4/glibtop_machine.h diff --git a/sysdeps/sun4/glibtop_machine.h b/sysdeps/sun4/glibtop_machine.h new file mode 100644 index 00000000..3fbb0251 --- /dev/null +++ b/sysdeps/sun4/glibtop_machine.h @@ -0,0 +1,97 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_MACHINE_H__ +#define __GLIBTOP_MACHINE_H__ + +/* make sure param.h gets loaded with KERNEL defined to get PZERO & NZERO */ +#define KERNEL +#include +#undef KERNEL + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef solbourne +#include +#endif + +/* Older versions of SunOS don't have a typedef for pid_t. + Hopefully this will catch all those cases without causing other problems. + */ +#ifndef __sys_stdtypes_h +typedef int pid_t; +#endif + +/* definitions for indices in the nlist array */ +#define X_AVENRUN 0 +#define X_CCPU 1 +#define X_MPID 2 +#define X_NPROC 3 +#define X_PROC 4 +#define X_TOTAL 5 +#define X_CP_TIME 6 +#define X_PAGES 7 +#define X_EPAGES 8 + +#ifdef MULTIPROCESSOR +#define X_NCPU 9 +#define X_MP_TIME 10 +#endif + +__BEGIN_DECLS + +typedef struct _glibtop_machine glibtop_machine; + +struct _glibtop_machine +{ + uid_t uid, euid; /* Real and effective user id */ + gid_t gid, egid; /* Real and effective group id */ + int nlist_count; /* Number of symbols in the nlist */ + int ncpu; /* Number of CPUs we have */ + kvm_t *kd; +}; + +/* Those functions are used internally in libgtop */ + +#ifdef _IN_LIBGTOP + +extern struct nlist _glibtop_nlist[]; + +extern int _glibtop_check_nlist __P((void *, register struct nlist *)); + +extern int _glibtop_getkval __P((void *, unsigned long, int *, int, char *)); + +#endif + +__END_DECLS + +#endif From 109f8dc6080cfee3e1331c9ec09bb7f5c20bbdbf Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 23:05:08 +0000 Subject: [PATCH 0056/2539] Started porting. Getting CPU usage now working. Took a lot of code from * sysdeps/sun4/{open.c, cpu.c}: Started porting. Getting CPU usage now working. Took a lot of code from top-3.4. --- sysdeps/sun4/cpu.c | 68 ++++++++++++++++++++ sysdeps/sun4/open.c | 149 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c index cda12977..e5efea4d 100644 --- a/sysdeps/sun4/cpu.c +++ b/sysdeps/sun4/cpu.c @@ -22,10 +22,78 @@ #include #include +static const unsigned long _glibtop_sysdeps_cpu = +(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) + +(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) + +(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY); + /* Provides information about cpu usage. */ void glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) { + long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES]; + int i; + memset (buf, 0, sizeof (glibtop_cpu)); + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* get the cp_time array */ + + (void) _glibtop_getkval (server, _glibtop_nlist [X_CP_TIME].n_value, (int *) cp_time, + sizeof (cp_time), _glibtop_nlist [X_CP_TIME].n_name); + +#ifdef MULTIPROCESSOR + /* get the mp_time array as well */ + + if (server->machine.ncpu > 1) { + (void) _glibtop_getkval (server, _glibtop_nlist [X_MP_TIME].n_value, (int *) mp_time, + sizeof (mp_time), _glibtop_nlist [X_MP_TIME].n_name); + } +#endif + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + +#ifdef MULTIPROCESSOR + /* If we have multiple processors, we add the times for each of them and set + frequency to 100 times the number of the processors. */ + + /* [FIXME]: I had no machine with more than one processor to test this code !!! */ + + if (server->machine.ncpu > 1) { + for (i = 0; i < server->machine.ncpu; i++) { + buf->user += mp_time [i][CP_USER]; + buf->nice += mp_time [i][CP_NICE]; + buf->sys += mp_time [i][CP_SYS]; + buf->idle += mp_time [i][CP_IDLE]; + buf->frequency += 100; + } + } else { + buf->user = cp_time [CP_USER]; + buf->nice = cp_time [CP_NICE]; + buf->sys = cp_time [CP_SYS]; + buf->idle = cp_time [CP_IDLE]; + buf->frequency = 100; + } +#else + buf->user = cp_time [CP_USER]; + buf->nice = cp_time [CP_NICE]; + buf->sys = cp_time [CP_SYS]; + buf->idle = cp_time [CP_IDLE]; + buf->frequency = 100; +#endif + + /* Calculate total time. */ + + buf->total = buf->user + buf->nice + buf->sys + buf->idle; + + /* Now we can set the flags. */ + + buf->flags = _glibtop_sysdeps_cpu; } diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index c2d58069..94cc5a44 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -19,13 +19,162 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include +struct nlist _glibtop_nlist[] = { +#ifdef i386 + { "avenrun" }, /* 0 */ + { "ccpu" }, /* 1 */ + { "mpid" }, /* 2 */ + { "nproc" }, /* 3 */ + { "proc" }, /* 4 */ + { "total" }, /* 5 */ + { "cp_time" }, /* 6 */ + { "pages" }, /* 7 */ + { "epages" }, /* 8 */ +#else + { "_avenrun" }, /* 0 */ + { "_ccpu" }, /* 1 */ + { "_mpid" }, /* 2 */ + { "_nproc" }, /* 3 */ + { "_proc" }, /* 4 */ + { "_total" }, /* 5 */ + { "_cp_time" }, /* 6 */ + { "_pages" }, /* 7 */ + { "_epages" }, /* 8 */ +#ifdef MULTIPROCESSOR + { "_ncpu" }, + { "_mp_time" }, +#endif +#endif + { 0 } +}; + /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ +/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + void glibtop_open (glibtop *server, const char *program_name) { + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ + memset (server, 0, sizeof (glibtop)); server->name = program_name; + + server->machine.uid = getuid (); + server->machine.euid = geteuid (); + server->machine.gid = getgid (); + server->machine.egid = getegid (); + + /* initialize the kernel interface */ + + server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "libgtop"); + + if (server->machine.kd == NULL) + glibtop_error__r (server, "kvm_open: %s", strerror (errno)); + + /* get the list of symbols we want to access in the kernel */ + + server->machine.nlist_count = kvm_nlist (server->machine.kd, _glibtop_nlist); + + if (server->machine.nlist_count < 0) + glibtop_error__r (server, "nlist: %s", strerror (errno)); + +#ifdef MULTIPROCESSOR + /* were ncpu and xp_time not found in the nlist? */ + + if ((server->machine.nlist_count > 0) && (_glibtop_nlist[X_NCPU].n_type == 0) && + (_glibtop_nlist[X_MP_TIME].n_type == 0)) { + /* we were compiled on an MP system but we are not running on one */ + /* so we will pretend this didn't happen and set ncpu = 1 */ + server->machine.nlist_count -= 2; + server->machine.ncpu = 1; + } +#endif + +#ifdef solbourne + { + unsigned int status, type; + + /* Get the number of CPUs on this system. */ + syscall(SYS_getcpustatus, &status, &server->machine.ncpu, &type); + } +#endif + + /* Make sure all of the symbols were found. */ + + if ((server->machine.nlist_count > 0) && + (_glibtop_check_nlist (server, _glibtop_nlist) > 0)) + _exit (1); + + /* Drop priviledges. */ + + if (setreuid (server->machine.euid, server->machine.uid)) + _exit (1); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SUID ROOT PART !!! */ + + /* Our effective uid is now those of the user invoking the server, + so we do no longer have any priviledges. + */ + + /* NOTE: On SunOS, we do not need to be suid root, we just need to be sgid kmem. + * The server will only use setegid() to get back it's priviledges, so it + * will fail if it is suid root and not sgid kmem. + */ +} + +/* Used internally. Returns number of symbols that cannot be found in the nlist. */ + +int +_glibtop_check_nlist (void *server, register struct nlist *nlst) +{ + register int not_found; + + /* check to see if we got ALL the symbols we requested */ + /* this will write one line to stderr for every symbol not found */ + + not_found = 0; + + while (nlst->n_name != NULL) { + +#ifdef i386 + if (nlst->n_value == 0) { + glibtop_error__r (server, "kernel: no symbol named `%s'", nlst->n_name); + not_found++; + } +#else + if (nlst->n_type == 0) { + glibtop_error__r (server, "kernel: no symbol named `%s'", nlst->n_name); + not_found++; + } +#endif + + nlst++; + } + + return not_found; +} + +/* Used internally. Fetches value from kernel. */ + +int +_glibtop_getkval (void *void_server, unsigned long offset, int *ptr, int size, char *refstr) +{ + glibtop *server = (glibtop *) void_server; + + if (kvm_read (server->machine.kd, offset, ptr, size) != size) + { + if (*refstr == '!') return 0; + + glibtop_error__r (server, "kvm_read(%s): %s", + refstr, strerror (errno)); + } + + return 1; } From b281735ba71d36b334d769658742586c6e2c4088 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 23 May 1998 23:06:34 +0000 Subject: [PATCH 0057/2539] *** empty log message *** --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8ae36717..0eb85899 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 1998-05-23 Martin Baulig + * sysdeps/sun4/{open.c, cpu.c}: Started porting. + Getting CPU usage now working. Took a lot of code + from top-3.4. + + * sysdeps/sun4/glibtop_machine.h: New file. + System dependend header file for SunOS. + * configure.in (CFLAGS): added -D_IN_LIBGTOP * */Makefile.am (INCLUDES): removed -I$(includedir). From ff3aced01e1776ecb6e95f20e31b51d72aa3e057 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 24 May 1998 16:15:24 +0000 Subject: [PATCH 0058/2539] added `locked' member to this structure for SunOS. * include/glibtop/mem.h (_glibtop_mem): added `locked' member to this structure for SunOS. --- examples/first.c | 4 ++-- include/glibtop/mem.h | 6 ++++-- sysdeps/guile/mem.c | 1 + sysdeps/names/mem.c | 10 ++++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/first.c b/examples/first.c index 218a3fc0..edd7e0eb 100644 --- a/examples/first.c +++ b/examples/first.c @@ -49,10 +49,10 @@ main (int argc, char *argv []) glibtop_get_mem (&data.mem); - fprintf (stderr, "Memory (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", + 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.user, data.mem.locked); glibtop_get_swap (&data.swap); diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h index a2eaca95..220bebbc 100644 --- a/include/glibtop/mem.h +++ b/include/glibtop/mem.h @@ -34,8 +34,9 @@ __BEGIN_DECLS #define GLIBTOP_MEM_BUFFER 4 #define GLIBTOP_MEM_CACHED 5 #define GLIBTOP_MEM_USER 6 +#define GLIBTOP_MEM_LOCKED 7 -#define GLIBTOP_MAX_MEM 7 +#define GLIBTOP_MAX_MEM 8 typedef struct _glibtop_mem glibtop_mem; @@ -48,7 +49,8 @@ struct _glibtop_mem shared, /* GLIBTOP_MEM_SHARED */ buffer, /* GLIBTOP_MEM_BUFFER */ cached, /* GLIBTOP_MEM_CACHED */ - user; /* GLIBTOP_MEM_USER */ + user, /* GLIBTOP_MEM_USER */ + locked; /* GLIBTOP_MEM_LOCKED */ }; #define glibtop_get_mem(mem) glibtop_get_mem__r(glibtop_global_server, mem) diff --git a/sysdeps/guile/mem.c b/sysdeps/guile/mem.c index 4b489579..38618dc0 100644 --- a/sysdeps/guile/mem.c +++ b/sysdeps/guile/mem.c @@ -38,5 +38,6 @@ SCM glibtop_guile_get_mem (void) gh_ulong2scm (mem.buffer), gh_ulong2scm (mem.cached), gh_ulong2scm (mem.user), + gh_ulong2scm (mem.locked), SCM_UNDEFINED); } diff --git a/sysdeps/names/mem.c b/sysdeps/names/mem.c index 258ea38e..4914b04d 100644 --- a/sysdeps/names/mem.c +++ b/sysdeps/names/mem.c @@ -24,14 +24,14 @@ const char *glibtop_names_mem [GLIBTOP_MAX_MEM] = { "total", "used", "free", "shared", "buffer", - "cached", "user" + "cached", "user", "locked" }; const char *glibtop_types_mem [GLIBTOP_MAX_MEM] = { "unsigned long", "unsigned long", "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long" + "unsigned long", "unsigned long" }; const char *glibtop_labels_mem [GLIBTOP_MAX_MEM] = @@ -42,7 +42,8 @@ const char *glibtop_labels_mem [GLIBTOP_MAX_MEM] = N_("Shared Memory"), N_("Buffers"), N_("Cached"), - N_("User") + N_("User"), + N_("Locked"), }; const char *glibtop_descriptions_mem [GLIBTOP_MAX_MEM] = @@ -53,5 +54,6 @@ const char *glibtop_descriptions_mem [GLIBTOP_MAX_MEM] = N_("Shared memory size in kB"), N_("Size of buffers kB"), N_("Size of cached memory in kB"), - N_("Memory used from user processes in kB") + N_("Memory used from user processes in kB"), + N_("Memory in locked pages in kB") }; From 15caaaf34f82764466d6efcdbacc1ec0ba18d1cb Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 24 May 1998 16:16:59 +0000 Subject: [PATCH 0059/2539] added memory statistics. * sysdeps/sun4/{open.c, mem.c, glibtop_machine.h}: added memory statistics. --- ChangeLog | 8 +++++ sysdeps/sun4/glibtop_machine.h | 9 +++++- sysdeps/sun4/mem.c | 55 ++++++++++++++++++++++++++++++++++ sysdeps/sun4/open.c | 37 +++++++++++++++++++++++ 4 files changed, 108 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0eb85899..bb6195bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1998-05-24 Martin Baulig + + * sysdeps/sun4/{open.c, mem.c, glibtop_machine.h}: added + memory statistics. + + * include/glibtop/mem.h (_glibtop_mem): added `locked' + member to this structure for SunOS. + 1998-05-23 Martin Baulig * sysdeps/sun4/{open.c, cpu.c}: Started porting. diff --git a/sysdeps/sun4/glibtop_machine.h b/sysdeps/sun4/glibtop_machine.h index 3fbb0251..8fb3d133 100644 --- a/sysdeps/sun4/glibtop_machine.h +++ b/sysdeps/sun4/glibtop_machine.h @@ -44,6 +44,8 @@ #include #endif +__BEGIN_DECLS + /* Older versions of SunOS don't have a typedef for pid_t. Hopefully this will catch all those cases without causing other problems. */ @@ -67,7 +69,8 @@ typedef int pid_t; #define X_MP_TIME 10 #endif -__BEGIN_DECLS +/* Log base 2 of 1024 is 10 (2^10 == 1024) */ +#define LOG1024 10 typedef struct _glibtop_machine glibtop_machine; @@ -77,6 +80,10 @@ struct _glibtop_machine gid_t gid, egid; /* Real and effective group id */ int nlist_count; /* Number of symbols in the nlist */ int ncpu; /* Number of CPUs we have */ + unsigned long pages, epages; + struct page *physpage; + int bytesize, count; + int pageshift; /* log base 2 of the pagesize */ kvm_t *kd; }; diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c index 0410e2dd..d6a67788 100644 --- a/sysdeps/sun4/mem.c +++ b/sysdeps/sun4/mem.c @@ -22,10 +22,65 @@ #include #include +static const unsigned long _glibtop_sysdeps_mem = +(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) + +(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_LOCKED); + +/* define pagetok in terms of pageshift */ + +#define pagetok(size) ((size) << server->machine.pageshift) + /* Provides information about memory usage. */ void glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) { memset (buf, 0, sizeof (glibtop_mem)); + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* get the array of physpage descriptors */ + + (void) _glibtop_getkval (server, server->machine.pages, + (int *) server->machine.physpage, + server->machine.bytesize, + "array _page"); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SGID KMEM PART !!! */ + + + { /* sum memory statistics */ + register struct page *pp; + register int cnt; + register int inuse; + register int free; + register int locked; + + /* bop thru the array counting page types */ + + pp = server->machine.physpage; + inuse = free = locked = 0; + for (cnt = server->machine.count; --cnt >= 0; pp++) { + if (pp->p_free) + free++; + else if (pp->p_lock || pp->p_keepcnt > 0) + locked++; + else + inuse++; + } + + /* convert memory stats to Kbytes */ + + buf->total = pagetok (inuse + free); + buf->used = pagetok (inuse); + buf->free = pagetok (free); + buf->locked = pagetok (locked); + + buf->flags = _glibtop_sysdeps_mem; + } } diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index 94cc5a44..1944cdf7 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -21,6 +21,7 @@ #include #include +#include struct nlist _glibtop_nlist[] = { #ifdef i386 @@ -58,6 +59,8 @@ struct nlist _glibtop_nlist[] = { void glibtop_open (glibtop *server, const char *program_name) { + register int pagesize; + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ memset (server, 0, sizeof (glibtop)); @@ -108,7 +111,41 @@ glibtop_open (glibtop *server, const char *program_name) if ((server->machine.nlist_count > 0) && (_glibtop_check_nlist (server, _glibtop_nlist) > 0)) _exit (1); + + /* This are for the memory statistics. */ + (void) _glibtop_getkval (server, _glibtop_nlist[X_PAGES].n_value, + (int *)(&server->machine.pages), + sizeof (server->machine.pages), + _glibtop_nlist[X_PAGES].n_name); + + (void) _glibtop_getkval (server, _glibtop_nlist[X_EPAGES].n_value, + (int *)(&server->machine.epages), + sizeof (server->machine.epages), + _glibtop_nlist[X_EPAGES].n_name); + + server->machine.bytesize = server->machine.epages - + server->machine.pages; + server->machine.count = server->machine.bytesize / sizeof (struct page); + + server->machine.physpage = + (struct page *) glibtop_malloc__r (server, server->machine.bytesize); + + /* get the page size with "getpagesize" and calculate pageshift from it */ + + pagesize = getpagesize(); + + server->machine.pageshift = 0; + + while (pagesize > 1) { + server->machine.pageshift++; + pagesize >>= 1; + } + + /* we only need the amount of log(2)1024 for our conversion */ + + server->machine.pageshift -= LOG1024; + /* Drop priviledges. */ if (setreuid (server->machine.euid, server->machine.uid)) From dd0258acf96aaac1e1fc81f5010808b5664f868f Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 25 May 1998 17:13:16 +0000 Subject: [PATCH 0060/2539] Fixed `broken pipe' error when server is running SUID; accidentally uses * src/server/main.c: Fixed `broken pipe' error when server is running SUID; accidentally uses setreuid () instead of setregid (). --- src/server/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/main.c b/src/server/main.c index 93332f12..a3a12d7d 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - setreuid (uid, euid); setreuid (gid, egid); + setreuid (uid, euid); setregid (gid, egid); glibtop_open (&server, argv [0]); From 4e1e1ccb9f505ae01492acc18dc0554ee3910a1c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 28 May 1998 19:08:35 +0000 Subject: [PATCH 0061/2539] removed that file; it is no longer needed. * lib/sysdeps.c: removed that file; it is no longer needed. --- lib/sysdeps.c | 32 -------------------------------- po/POTFILES.in | 1 - 2 files changed, 33 deletions(-) delete mode 100644 lib/sysdeps.c diff --git a/lib/sysdeps.c b/lib/sysdeps.c deleted file mode 100644 index 94ed2ac2..00000000 --- a/lib/sysdeps.c +++ /dev/null @@ -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 , 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 -#include - -/* Checks which features are implemented. */ - -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); -} diff --git a/po/POTFILES.in b/po/POTFILES.in index be5e228f..bc2fe1e4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -6,7 +6,6 @@ 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 From 62dda3b78280719d39640db4972706bba8740695 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 28 May 1998 19:19:49 +0000 Subject: [PATCH 0062/2539] 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_' being either 'GLIBTOP_SYSDEPS_'+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. --- include/glibtop/command.h | 3 ++- include/glibtop/cpu.h | 13 ++++++++++++- include/glibtop/loadavg.h | 13 ++++++++++++- include/glibtop/mem.h | 13 ++++++++++++- include/glibtop/msg_limits.h | 13 ++++++++++++- include/glibtop/prockernel.h | 13 ++++++++++++- include/glibtop/proclist.h | 13 ++++++++++++- include/glibtop/procmem.h | 13 ++++++++++++- include/glibtop/procsegment.h | 13 ++++++++++++- include/glibtop/procsignal.h | 13 ++++++++++++- include/glibtop/procstate.h | 13 ++++++++++++- include/glibtop/proctime.h | 13 ++++++++++++- include/glibtop/procuid.h | 13 ++++++++++++- include/glibtop/read.h | 3 ++- include/glibtop/read_data.h | 3 ++- include/glibtop/sem_limits.h | 13 ++++++++++++- include/glibtop/shm_limits.h | 13 ++++++++++++- include/glibtop/swap.h | 13 ++++++++++++- include/glibtop/uptime.h | 13 ++++++++++++- include/glibtop/write.h | 3 ++- 20 files changed, 200 insertions(+), 20 deletions(-) diff --git a/include/glibtop/command.h b/include/glibtop/command.h index 2afcd582..c57d2373 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -60,7 +60,8 @@ struct _glibtop_command #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 diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h index 0d1b77ec..80b04348 100644 --- a/include/glibtop/cpu.h +++ b/include/glibtop/cpu.h @@ -51,7 +51,18 @@ struct _glibtop_cpu #define glibtop_get_cpu(cpu) glibtop_get_cpu__r(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__l +#else +#define glibtop_get_cpu__r glibtop_get_cpu__s +#endif + +#if GLIBTOP_SUID_CPU +extern void glibtop_get_cpu__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h index d33b589c..dd30d432 100644 --- a/include/glibtop/loadavg.h +++ b/include/glibtop/loadavg.h @@ -41,7 +41,18 @@ struct _glibtop_loadavg #define glibtop_get_loadavg(loadavg) glibtop_get_loadavg__r(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__l +#else +#define glibtop_get_loadavg__r glibtop_get_loadavg__s +#endif + +#if GLIBTOP_SUID_LOADAVG +extern void glibtop_get_loadavg__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h index 220bebbc..5b35344a 100644 --- a/include/glibtop/mem.h +++ b/include/glibtop/mem.h @@ -55,7 +55,18 @@ struct _glibtop_mem #define glibtop_get_mem(mem) glibtop_get_mem__r(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__l +#else +#define glibtop_get_mem__r glibtop_get_mem__s +#endif + +#if GLIBTOP_SUID_MEM +extern void glibtop_get_mem__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/msg_limits.h b/include/glibtop/msg_limits.h index a45b8ba7..9031f549 100644 --- a/include/glibtop/msg_limits.h +++ b/include/glibtop/msg_limits.h @@ -53,7 +53,18 @@ struct _glibtop_msg_limits #define glibtop_get_msg_limits(msg) glibtop_get_msg_limits__r(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__l +#else +#define glibtop_get_msg_limits__r glibtop_get_msg_limits__s +#endif + +#if GLIBTOP_SUID_MSG_LIMITS +extern void glibtop_get_msg_limits__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/prockernel.h b/include/glibtop/prockernel.h index 90a43b65..c214e0b2 100644 --- a/include/glibtop/prockernel.h +++ b/include/glibtop/prockernel.h @@ -62,7 +62,18 @@ struct _glibtop_proc_kernel #define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel__r(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__l +#else +#define glibtop_get_proc_kernel__r glibtop_get_proc_kernel__s +#endif + +#if GLIBTOP_SUID_PROC_KERNEL +extern void glibtop_get_proc_kernel__l __P((glibtop *, glibtop_proc_kernel *, pid_t)); +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 diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h index d163b828..a55dd055 100644 --- a/include/glibtop/proclist.h +++ b/include/glibtop/proclist.h @@ -45,7 +45,18 @@ struct _glibtop_proclist #define glibtop_get_proclist(proclist) glibtop_get_proclist__r(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__l +#else +#define glibtop_get_proclist__r glibtop_get_proclist__s +#endif + +#if GLIBTOP_SUID_PROCLIST +extern unsigned *glibtop_get_proclist__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/procmem.h b/include/glibtop/procmem.h index bcca778a..d841add8 100644 --- a/include/glibtop/procmem.h +++ b/include/glibtop/procmem.h @@ -55,7 +55,18 @@ struct _glibtop_proc_mem #define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem__r(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__l +#else +#define glibtop_get_proc_mem__r glibtop_get_proc_mem__s +#endif + +#if GLIBTOP_SUID_PROC_MEM +extern void glibtop_get_proc_mem__l __P((glibtop *, glibtop_proc_mem *, pid_t)); +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 diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h index b52f5bbf..7b8b4425 100644 --- a/include/glibtop/procsegment.h +++ b/include/glibtop/procsegment.h @@ -56,7 +56,18 @@ struct _glibtop_proc_segment #define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment__r(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__l +#else +#define glibtop_get_proc_segment__r glibtop_get_proc_segment__s +#endif + +#if GLIBTOP_SUID_PROC_SEGMENT +extern void glibtop_get_proc_segment__l __P((glibtop *, glibtop_proc_segment *, pid_t)); +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 diff --git a/include/glibtop/procsignal.h b/include/glibtop/procsignal.h index dda8a5bf..dc77a7e3 100644 --- a/include/glibtop/procsignal.h +++ b/include/glibtop/procsignal.h @@ -49,7 +49,18 @@ struct _glibtop_proc_signal #define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal__r(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__l +#else +#define glibtop_get_proc_signal__r glibtop_get_proc_signal__s +#endif + +#if GLIBTOP_SUID_PROC_SIGNAL +extern void glibtop_get_proc_signal__l __P((glibtop *, glibtop_proc_signal *, pid_t)); +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 diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h index c03f20d0..f5044eb9 100644 --- a/include/glibtop/procstate.h +++ b/include/glibtop/procstate.h @@ -56,7 +56,18 @@ struct _glibtop_proc_state #define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state__r(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__l +#else +#define glibtop_get_proc_state__r glibtop_get_proc_state__s +#endif + +#if GLIBTOP_SUID_PROC_STATE +extern void glibtop_get_proc_state__l __P((glibtop *, glibtop_proc_state *, pid_t)); +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 diff --git a/include/glibtop/proctime.h b/include/glibtop/proctime.h index 50d08c17..1d866767 100644 --- a/include/glibtop/proctime.h +++ b/include/glibtop/proctime.h @@ -61,7 +61,18 @@ struct _glibtop_proc_time #define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time__r(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__l +#else +#define glibtop_get_proc_time__r glibtop_get_proc_time__s +#endif + +#if GLIBTOP_SUID_PROC_TIME +extern void glibtop_get_proc_time__l __P((glibtop *, glibtop_proc_time *, pid_t)); +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 diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h index decb9c25..3d8682bc 100644 --- a/include/glibtop/procuid.h +++ b/include/glibtop/procuid.h @@ -65,7 +65,18 @@ struct _glibtop_proc_uid #define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid__r(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__l +#else +#define glibtop_get_proc_uid__r glibtop_get_proc_uid__s +#endif + +#if GLIBTOP_SUID_PROC_UID +extern void glibtop_get_proc_uid__l __P((glibtop *, glibtop_proc_uid *, pid_t)); +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 diff --git a/include/glibtop/read.h b/include/glibtop/read.h index ef9a3ea0..4286cce1 100644 --- a/include/glibtop/read.h +++ b/include/glibtop/read.h @@ -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 diff --git a/include/glibtop/read_data.h b/include/glibtop/read_data.h index f0c54294..61bda2b2 100644 --- a/include/glibtop/read_data.h +++ b/include/glibtop/read_data.h @@ -29,7 +29,8 @@ __BEGIN_DECLS #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 diff --git a/include/glibtop/sem_limits.h b/include/glibtop/sem_limits.h index 283f0029..f24460e2 100644 --- a/include/glibtop/sem_limits.h +++ b/include/glibtop/sem_limits.h @@ -59,7 +59,18 @@ struct _glibtop_sem_limits #define glibtop_get_sem_limits(sem) glibtop_get_sem_limits__r(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__l +#else +#define glibtop_get_sem_limits__r glibtop_get_sem_limits__s +#endif + +#if GLIBTOP_SUID_SEM_LIMITS +extern void glibtop_get_sem_limits__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/shm_limits.h b/include/glibtop/shm_limits.h index db4a926d..30fc3e4f 100644 --- a/include/glibtop/shm_limits.h +++ b/include/glibtop/shm_limits.h @@ -49,7 +49,18 @@ struct _glibtop_shm_limits #define glibtop_get_shm_limits(shm) glibtop_get_shm_limits__r(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__l +#else +#define glibtop_get_shm_limits__r glibtop_get_shm_limits__s +#endif + +#if GLIBTOP_SUID_SHM_LIMITS +extern void glibtop_get_shm_limits__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/swap.h b/include/glibtop/swap.h index dd42ac30..fb438413 100644 --- a/include/glibtop/swap.h +++ b/include/glibtop/swap.h @@ -45,7 +45,18 @@ struct _glibtop_swap #define glibtop_get_swap(swap) glibtop_get_swap__r(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__l +#else +#define glibtop_get_swap__r glibtop_get_swap__s +#endif + +#if GLIBTOP_SUID_SWAP +extern void glibtop_get_swap__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h index 10815ecb..50dfdb48 100644 --- a/include/glibtop/uptime.h +++ b/include/glibtop/uptime.h @@ -43,7 +43,18 @@ struct _glibtop_uptime #define glibtop_get_uptime(uptime) glibtop_get_uptime__r(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__l +#else +#define glibtop_get_uptime__r glibtop_get_uptime__s +#endif + +#if GLIBTOP_SUID_UPTIME +extern void glibtop_get_uptime__l __P((glibtop *, glibtop_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 diff --git a/include/glibtop/write.h b/include/glibtop/write.h index e7acb1fc..22a677b5 100644 --- a/include/glibtop/write.h +++ b/include/glibtop/write.h @@ -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 From 7dd0c2eac345fadf459420615edc62c382e0fd89 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 28 May 1998 19:22:48 +0000 Subject: [PATCH 0063/2539] 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_' has a positive value. --- lib/command.c | 10 +++++----- lib/cpu.c | 10 ++++++++-- lib/loadavg.c | 9 +++++++-- lib/mem.c | 9 +++++++-- lib/msg_limits.c | 9 +++++++-- lib/open.c | 2 +- lib/prockernel.c | 8 ++++++-- lib/proclist.c | 9 +++++++-- lib/procmem.c | 8 ++++++-- lib/procsegment.c | 8 ++++++-- lib/procsignal.c | 8 ++++++-- lib/procstate.c | 8 ++++++-- lib/proctime.c | 8 ++++++-- lib/procuid.c | 8 ++++++-- lib/read.c | 2 +- lib/read_data.c | 8 +++++--- lib/sem_limits.c | 9 +++++++-- lib/shm_limits.c | 9 +++++++-- lib/swap.c | 9 +++++++-- lib/uptime.c | 9 +++++++-- lib/write.c | 2 +- 21 files changed, 119 insertions(+), 43 deletions(-) diff --git a/lib/command.c b/lib/command.c index 03df4375..eb74183b 100644 --- a/lib/command.c +++ b/lib/command.c @@ -27,7 +27,7 @@ #include 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; @@ -42,11 +42,11 @@ glibtop_call__r (glibtop *server, unsigned command, size_t send_size, void *send 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); diff --git a/lib/cpu.c b/lib/cpu.c index 253f1114..04d3bb9d 100644 --- a/lib/cpu.c +++ b/lib/cpu.c @@ -19,14 +19,20 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include +#if GLIBTOP_SUID_CPU + /* Provides information about cpu usage. */ void -glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu__l (glibtop *server, glibtop_cpu *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_CPU, 0, NULL, sizeof (glibtop_cpu), buf); + glibtop_call__l (server, GLIBTOP_CMND_CPU, 0, NULL, + sizeof (glibtop_cpu), buf); } + +#endif diff --git a/lib/loadavg.c b/lib/loadavg.c index 8671bfe8..7d571218 100644 --- a/lib/loadavg.c +++ b/lib/loadavg.c @@ -23,11 +23,16 @@ #include #include +#if GLIBTOP_SUID_LOADAVG + /* Provides load averange. */ void -glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg__l (glibtop *server, glibtop_loadavg *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_LOADAVG, 0, NULL, sizeof (glibtop_loadavg), buf); + glibtop_call__l (server, GLIBTOP_CMND_LOADAVG, 0, NULL, + sizeof (glibtop_loadavg), buf); } + +#endif diff --git a/lib/mem.c b/lib/mem.c index ad760c4b..a5dd8a65 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -22,11 +22,16 @@ #include #include +#if GLIBTOP_SUID_MEM + /* Provides information about memory usage. */ void -glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +glibtop_get_mem__l (glibtop *server, glibtop_mem *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_MEM, 0, NULL, sizeof (glibtop_mem), buf); + glibtop_call__l (server, GLIBTOP_CMND_MEM, 0, NULL, + sizeof (glibtop_mem), buf); } + +#endif diff --git a/lib/msg_limits.c b/lib/msg_limits.c index a8c6760a..176a8a4f 100644 --- a/lib/msg_limits.c +++ b/lib/msg_limits.c @@ -22,11 +22,16 @@ #include #include +#if GLIBTOP_SUID_MSG_LIMITS + /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits__l (glibtop *server, glibtop_msg_limits *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, sizeof (glibtop_msg_limits), buf); + glibtop_call__l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, + sizeof (glibtop_msg_limits), buf); } + +#endif diff --git a/lib/open.c b/lib/open.c index 7b36a871..ed55b431 100644 --- a/lib/open.c +++ b/lib/open.c @@ -53,7 +53,7 @@ glibtop_open (glibtop *server, const char *program_name) 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); diff --git a/lib/prockernel.c b/lib/prockernel.c index 9dd9fccb..d93add72 100644 --- a/lib/prockernel.c +++ b/lib/prockernel.c @@ -23,13 +23,17 @@ #include #include +#if GLIBTOP_SUID_PROC_KERNEL + /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel__l (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t), + glibtop_call__l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t), &pid, sizeof (glibtop_proc_kernel), buf); } + +#endif diff --git a/lib/proclist.c b/lib/proclist.c index deae7ce2..3c541129 100644 --- a/lib/proclist.c +++ b/lib/proclist.c @@ -22,11 +22,16 @@ #include #include +#if GLIBTOP_SUID_PROCLIST + /* Fetch list of currently running processes. */ unsigned * -glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist__l (glibtop *server, glibtop_proclist *buf) { glibtop_init__r (&server); - return glibtop_call__r (server, GLIBTOP_CMND_PROCLIST, 0, NULL, sizeof (glibtop_proclist), buf); + return glibtop_call__l (server, GLIBTOP_CMND_PROCLIST, 0, NULL, + sizeof (glibtop_proclist), buf); } + +#endif diff --git a/lib/procmem.c b/lib/procmem.c index 5f4e8991..7dd06ba9 100644 --- a/lib/procmem.c +++ b/lib/procmem.c @@ -23,13 +23,17 @@ #include #include +#if GLIBTOP_SUID_PROC_MEM + /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem__l (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), + glibtop_call__l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), &pid, sizeof (glibtop_proc_mem), buf); } + +#endif diff --git a/lib/procsegment.c b/lib/procsegment.c index ee10a5d8..f144094a 100644 --- a/lib/procsegment.c +++ b/lib/procsegment.c @@ -23,13 +23,17 @@ #include #include +#if GLIBTOP_SUID_PROC_SEGMENT + /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment__l (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t), + glibtop_call__l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t), &pid, sizeof (glibtop_proc_segment), buf); } + +#endif diff --git a/lib/procsignal.c b/lib/procsignal.c index d0ae5468..d1ed2dd8 100644 --- a/lib/procsignal.c +++ b/lib/procsignal.c @@ -23,13 +23,17 @@ #include #include +#if GLIBTOP_SUID_PROC_SIGNAL + /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal__l (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), + glibtop_call__l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), &pid, sizeof (glibtop_proc_signal), buf); } + +#endif diff --git a/lib/procstate.c b/lib/procstate.c index 557bfd85..3c986c3e 100644 --- a/lib/procstate.c +++ b/lib/procstate.c @@ -23,13 +23,17 @@ #include #include +#if GLIBTOP_SUID_PROC_STATE + /* Provides detailed information about a process. */ void -glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state__l (glibtop *server, glibtop_proc_state *buf, pid_t pid) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), + glibtop_call__l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), &pid, sizeof (glibtop_proc_state), buf); } + +#endif diff --git a/lib/proctime.c b/lib/proctime.c index a6ab8c28..41413cbb 100644 --- a/lib/proctime.c +++ b/lib/proctime.c @@ -23,13 +23,17 @@ #include #include +#if GLIBTOP_SUID_PROC_TIME + /* Provides detailed information about a process. */ void -glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, +glibtop_get_proc_time__l (glibtop *server, glibtop_proc_time *buf, pid_t pid) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), + glibtop_call__l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), &pid, sizeof (glibtop_proc_time), buf); } + +#endif diff --git a/lib/procuid.c b/lib/procuid.c index 6c06ba19..93e6ada3 100644 --- a/lib/procuid.c +++ b/lib/procuid.c @@ -23,13 +23,17 @@ #include #include +#if GLIBTOP_SUID_PROC_UID + /* Provides detailed information about a process. */ void -glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, +glibtop_get_proc_uid__l (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), + glibtop_call__l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), &pid, sizeof (glibtop_proc_uid), buf); } + +#endif diff --git a/lib/read.c b/lib/read.c index f05a617d..c8ff2eec 100644 --- a/lib/read.c +++ b/lib/read.c @@ -24,7 +24,7 @@ /* 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; diff --git a/lib/read_data.c b/lib/read_data.c index e6012585..acfe0add 100644 --- a/lib/read_data.c +++ b/lib/read_data.c @@ -25,7 +25,7 @@ /* Reads some data from server. */ void * -glibtop_read_data__r (glibtop *server) +glibtop_read_data__l (glibtop *server) { size_t size; void *ptr; @@ -33,7 +33,8 @@ glibtop_read_data__r (glibtop *server) glibtop_init__r (&server); 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; @@ -42,7 +43,8 @@ glibtop_read_data__r (glibtop *server) 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; } diff --git a/lib/sem_limits.c b/lib/sem_limits.c index 2be994e9..2ce853a3 100644 --- a/lib/sem_limits.c +++ b/lib/sem_limits.c @@ -22,11 +22,16 @@ #include #include +#if GLIBTOP_SUID_SEM_LIMITS + /* Provides information about sysv ipc limits. */ void -glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits__l (glibtop *server, glibtop_sem_limits *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, sizeof (glibtop_sem_limits), buf); + glibtop_call__l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, + sizeof (glibtop_sem_limits), buf); } + +#endif diff --git a/lib/shm_limits.c b/lib/shm_limits.c index 24e3447d..9d3aee22 100644 --- a/lib/shm_limits.c +++ b/lib/shm_limits.c @@ -22,11 +22,16 @@ #include #include +#if GLIBTOP_SUID_SHM_LIMITS + /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits__l (glibtop *server, glibtop_shm_limits *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, sizeof (glibtop_shm_limits), buf); + glibtop_call__l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, + sizeof (glibtop_shm_limits), buf); } + +#endif diff --git a/lib/swap.c b/lib/swap.c index 2a88bc30..e4972869 100644 --- a/lib/swap.c +++ b/lib/swap.c @@ -22,11 +22,16 @@ #include #include +#if GLIBTOP_SUID_SWAP + /* Provides information about swap usage. */ void -glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +glibtop_get_swap__l (glibtop *server, glibtop_swap *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_SWAP, 0, NULL, sizeof (glibtop_swap), buf); + glibtop_call__l (server, GLIBTOP_CMND_SWAP, 0, NULL, + sizeof (glibtop_swap), buf); } + +#endif diff --git a/lib/uptime.c b/lib/uptime.c index 9a316433..597a50b8 100644 --- a/lib/uptime.c +++ b/lib/uptime.c @@ -23,11 +23,16 @@ #include #include +#if GLIBTOP_SUID_UPTIME + /* Provides uptime and idle time. */ void -glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime__l (glibtop *server, glibtop_uptime *buf) { glibtop_init__r (&server); - glibtop_call__r (server, GLIBTOP_CMND_UPTIME, 0, NULL, sizeof (glibtop_uptime), buf); + glibtop_call__l (server, GLIBTOP_CMND_UPTIME, 0, NULL, + sizeof (glibtop_uptime), buf); } + +#endif diff --git a/lib/write.c b/lib/write.c index 93b7581a..2d3984d0 100644 --- a/lib/write.c +++ b/lib/write.c @@ -24,7 +24,7 @@ /* 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); From 95b9d824ea1ebd717e1acabec6c0b8745a805cad Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 28 May 1998 19:24:24 +0000 Subject: [PATCH 0064/2539] renamed all functions implementing features to '__s'. * sysdeps/linux/*.c: renamed all functions implementing features to '__s'. --- sysdeps/linux/cpu.c | 2 +- sysdeps/linux/glibtop_server.h | 46 ++++++++++++++++++++++++++++++++++ sysdeps/linux/loadavg.c | 2 +- sysdeps/linux/mem.c | 2 +- sysdeps/linux/msg_limits.c | 2 +- sysdeps/linux/procdata.c | 2 +- sysdeps/linux/prockernel.c | 2 +- sysdeps/linux/proclist.c | 2 +- sysdeps/linux/procmem.c | 2 +- sysdeps/linux/procsegment.c | 2 +- sysdeps/linux/procsignal.c | 2 +- sysdeps/linux/procstate.c | 2 +- sysdeps/linux/proctime.c | 2 +- sysdeps/linux/procuid.c | 2 +- sysdeps/linux/sem_limits.c | 2 +- sysdeps/linux/shm_limits.c | 2 +- sysdeps/linux/swap.c | 2 +- sysdeps/linux/uptime.c | 2 +- 18 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 sysdeps/linux/glibtop_server.h diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index 224ab06b..9f009092 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -30,7 +30,7 @@ static const unsigned long _glibtop_sysdeps_cpu = /* Provides information about cpu usage. */ void -glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu__s (glibtop *server, glibtop_cpu *buf) { FILE *f; diff --git a/sysdeps/linux/glibtop_server.h b/sysdeps/linux/glibtop_server.h new file mode 100644 index 00000000..52b1b3c0 --- /dev/null +++ b/sysdeps/linux/glibtop_server.h @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SERVER_H__ +#define __GLIBTOP_SERVER_H__ + +__BEGIN_DECLS + +#define GLIBTOP_SUID_CPU 0 +#define GLIBTOP_SUID_MEM 0 +#define GLIBTOP_SUID_SWAP 0 +#define GLIBTOP_SUID_UPTIME 0 +#define GLIBTOP_SUID_LOADAVG 0 +#define GLIBTOP_SUID_SHM_LIMITS 0 +#define GLIBTOP_SUID_MSG_LIMITS 0 +#define GLIBTOP_SUID_SEM_LIMITS 0 +#define GLIBTOP_SUID_PROCLIST 0 +#define GLIBTOP_SUID_PROC_STATE 0 +#define GLIBTOP_SUID_PROC_UID 0 +#define GLIBTOP_SUID_PROC_MEM 0 +#define GLIBTOP_SUID_PROC_TIME 0 +#define GLIBTOP_SUID_PROC_SIGNAL 0 +#define GLIBTOP_SUID_PROC_KERNEL 0 +#define GLIBTOP_SUID_PROC_SEGMENT 0 + +__END_DECLS + +#endif diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c index 8401247c..2b759b0f 100644 --- a/sysdeps/linux/loadavg.c +++ b/sysdeps/linux/loadavg.c @@ -28,7 +28,7 @@ static const unsigned long _glibtop_sysdeps_loadavg = /* Provides load load averange. */ void -glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg__s (glibtop *server, glibtop_loadavg *buf) { FILE *f; diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index 80d2ccc3..22a8b192 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_mem = /* Provides information about memory usage. */ void -glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +glibtop_get_mem__s (glibtop *server, glibtop_mem *buf) { FILE *f; diff --git a/sysdeps/linux/msg_limits.c b/sysdeps/linux/msg_limits.c index 997551af..43b24407 100644 --- a/sysdeps/linux/msg_limits.c +++ b/sysdeps/linux/msg_limits.c @@ -33,7 +33,7 @@ static const unsigned long _glibtop_sysdeps_msg_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits__s (glibtop *server, glibtop_msg_limits *buf) { struct msginfo msginfo; diff --git a/sysdeps/linux/procdata.c b/sysdeps/linux/procdata.c index 3fc01fb3..1c9f9cf1 100644 --- a/sysdeps/linux/procdata.c +++ b/sysdeps/linux/procdata.c @@ -78,7 +78,7 @@ BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN); /* Provides detailed information about a process. */ void -glibtop_get_procdata__r (glibtop *server, glibtop_procdata *buf, pid_t pid) +glibtop_get_procdata__s (glibtop *server, glibtop_procdata *buf, pid_t pid) { char input [BUFSIZ], *tmp; struct stat statb; diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c index 0bd13c3f..5f6cba72 100644 --- a/sysdeps/linux/prockernel.c +++ b/sysdeps/linux/prockernel.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) +glibtop_get_proc_kernel__s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c index 39070689..93f79e34 100644 --- a/sysdeps/linux/proclist.c +++ b/sysdeps/linux/proclist.c @@ -49,7 +49,7 @@ static const unsigned long _glibtop_sysdeps_proclist = * On error, NULL is returned and buf->flags is zero. */ unsigned * -glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist__s (glibtop *server, glibtop_proclist *buf) { DIR *proc; struct dirent *entry; diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index 09a2fe83..727565e6 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -30,7 +30,7 @@ static const unsigned long _glibtop_sysdeps_proc_mem = /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, pid_t pid) +glibtop_get_proc_mem__s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index 479d98e4..70fd131d 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_segment = /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment__s (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { char input [BUFSIZ], *tmp; diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c index 9bf32b26..0e978eef 100644 --- a/sysdeps/linux/procsignal.c +++ b/sysdeps/linux/procsignal.c @@ -29,7 +29,7 @@ static const unsigned long _glibtop_sysdeps_proc_signal = /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, pid_t pid) +glibtop_get_proc_signal__s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index 76252ba9..5a423622 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_state = /* Provides detailed information about a process. */ void -glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, pid_t pid) +glibtop_get_proc_state__s (glibtop *server, glibtop_proc_state *buf, pid_t pid) { char input [BUFSIZ], *tmp; struct stat statb; diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index 7c5dbc21..01c8bf43 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_proc_time = /* Provides detailed information about a process. */ void -glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, pid_t pid) +glibtop_get_proc_time__s (glibtop *server, glibtop_proc_time *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c index d2ebddc3..f3d5b8f5 100644 --- a/sysdeps/linux/procuid.c +++ b/sysdeps/linux/procuid.c @@ -35,7 +35,7 @@ static const unsigned long _glibtop_sysdeps_proc_uid = /* Provides detailed information about a process. */ void -glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, pid_t pid) +glibtop_get_proc_uid__s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; diff --git a/sysdeps/linux/sem_limits.c b/sysdeps/linux/sem_limits.c index 05d00a2d..fda5c0e5 100644 --- a/sysdeps/linux/sem_limits.c +++ b/sysdeps/linux/sem_limits.c @@ -34,7 +34,7 @@ static unsigned long _glibtop_sysdeps_sem_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits__s (glibtop *server, glibtop_sem_limits *buf) { struct seminfo seminfo; union semun arg; diff --git a/sysdeps/linux/shm_limits.c b/sysdeps/linux/shm_limits.c index 07a78bc7..d3c3193a 100644 --- a/sysdeps/linux/shm_limits.c +++ b/sysdeps/linux/shm_limits.c @@ -32,7 +32,7 @@ static unsigned long _glibtop_sysdeps_shm_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits__s (glibtop *server, glibtop_shm_limits *buf) { struct shminfo shminfo; diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index 90572687..8fb5e41e 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -29,7 +29,7 @@ static unsigned long _glibtop_sysdeps_swap = /* Provides information about swap usage. */ void -glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +glibtop_get_swap__s (glibtop *server, glibtop_swap *buf) { FILE *f; diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c index 4dabf7be..69f5b6b5 100644 --- a/sysdeps/linux/uptime.c +++ b/sysdeps/linux/uptime.c @@ -28,7 +28,7 @@ static unsigned long _glibtop_sysdeps_uptime = /* Provides uptime and idle time. */ void -glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime__s (glibtop *server, glibtop_uptime *buf) { FILE *f; From 68162783dc0505841cf5d6793fa0ef462e18cb8e Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 28 May 1998 19:29:29 +0000 Subject: [PATCH 0065/2539] 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_' has a non-zero value. --- ChangeLog | 39 +++++++++++++++++++++++++++ configure.in | 6 ++--- examples/Makefile.am | 28 ++++--------------- glibtop.h | 2 ++ src/server/main.c | 64 +++++++++++++++++++++++++++++++++----------- 5 files changed, 96 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb6195bb..0a6517c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +1998-05-28 Martin Baulig + + * src/server/main.c: we now use the '__p' functions, + but only if the appropriate 'GLIBTOP_SUID_' + 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_' has a positive value. + + * 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_' + being either 'GLIBTOP_SYSDEPS_'+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 + + * src/server/main.c: Fixed `broken pipe' error when server + is running SUID; accidentally uses setreuid () instead of + setregid (). + 1998-05-24 Martin Baulig * sysdeps/sun4/{open.c, mem.c, glibtop_machine.h}: added diff --git a/configure.in b/configure.in index 5df8406d..838b8758 100644 --- a/configure.in +++ b/configure.in @@ -32,7 +32,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= @@ -157,9 +157,7 @@ if test "x$ac_cv_guile_found" = "xyes" ; then 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) diff --git a/examples/Makefile.am b/examples/Makefile.am index 54b126de..9984ca10 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -10,14 +10,14 @@ CFLAGS = -Wall -W @CFLAGS@ 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)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/lib/libgtop.la \ @INTLLIBS@ @LIBSUPPORT@ @@ -25,14 +25,9 @@ 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)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/lib/libgtop.la \ @INTLLIBS@ @LIBSUPPORT@ @@ -40,12 +35,6 @@ 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 @@ -55,17 +44,10 @@ 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)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/lib/libgtop.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 diff --git a/glibtop.h b/glibtop.h index 01309bf8..26bba2d5 100644 --- a/glibtop.h +++ b/glibtop.h @@ -24,6 +24,8 @@ #include +#include + #ifdef HAVE_GLIBTOP_MACHINE_H #include #endif diff --git a/src/server/main.c b/src/server/main.c index a3a12d7d..31b261d6 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -146,50 +146,68 @@ int main(int argc, char *argv[]) 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); +#endif glibtop_output (sizeof (glibtop_proclist), &data.proclist); glibtop_output (data.proclist.total, ptr); @@ -197,56 +215,70 @@ int main(int argc, char *argv[]) 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); From 6de9ad750b1f569338cb8444654a9f9f765f2f6b Mon Sep 17 00:00:00 2001 From: Vincent Renardias Date: Sun, 31 May 1998 20:54:43 +0000 Subject: [PATCH 0066/2539] Sun, 31 May 1998 22:52:48 +0200 [Vincent] * Yet more .FR translations. (and fixed a typo in gxsnmp ;) --- configure.in | 2 +- po/ChangeLog | 4 + po/fr.po | 402 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 po/fr.po diff --git a/configure.in b/configure.in index 838b8758..878b7f14 100644 --- a/configure.in +++ b/configure.in @@ -90,7 +90,7 @@ AC_TYPE_SIGNAL AC_FUNC_STRFTIME AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv strdup strtoul uname) -ALL_LINGUAS="" +ALL_LINGUAS="fr" AM_GNU_GETTEXT CFLAGS="$CFLAGS -D_IN_LIBGTOP" diff --git a/po/ChangeLog b/po/ChangeLog index f61f2ec3..308ade84 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +Sun, 31 May 1998 22:38:59 +0200 Vincent Renardias + + * fr.po: new file - ChangeLog isn't empty anymore _(; + 1998-05-21 Martin Baulig * ChangeLog: new file - currently empty diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 00000000..e226dd2c --- /dev/null +++ b/po/fr.po @@ -0,0 +1,402 @@ +# libgtop fr.po +# Copyright (C) 1998 Free Software Foundation, Inc. +# Vincent Renardias , 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 \n" +"Language-Team: Vincent Renardias \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 Mmoire" + +#: 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 mmoire partage" + +#: 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 smaphores" + +#: sysdeps/names/sysdeps.c:50 sysdeps/names/sysdeps.c:70 +msgid "List of running Processes" +msgstr "Liste des taches en cours d'xcution" + +#: 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 systme" + +#: 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 systme" + +#: 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 "Mmoire Totale" + +#: sysdeps/names/mem.c:40 +msgid "Used Memory" +msgstr "Mmoire Utilise" + +#: sysdeps/names/mem.c:41 +msgid "Free Memory" +msgstr "Mmoire Libre" + +#: sysdeps/names/mem.c:42 +msgid "Shared Memory" +msgstr "Mmoire Partage" + +#: 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 "Vrouill" + +#: sysdeps/names/mem.c:51 +msgid "Total physical memory in kB" +msgstr "Mmoire 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 "" From 67798e0d7d631f030db33147ef06d986bba1a5bb Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 1 Jun 1998 15:09:03 +0000 Subject: [PATCH 0067/2539] 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. --- lib/command.c | 2 +- lib/cpu.c | 15 ++++----- lib/init.c | 6 ++-- lib/loadavg.c | 15 ++++----- lib/mem.c | 15 ++++----- lib/msg_limits.c | 15 ++++----- lib/open.c | 78 +++++++++++++++++++++++++++++++++++++++++++++-- lib/prockernel.c | 17 ++++++----- lib/proclist.c | 15 ++++----- lib/procmem.c | 17 ++++++----- lib/procsegment.c | 17 ++++++----- lib/procsignal.c | 17 ++++++----- lib/procstate.c | 15 ++++----- lib/proctime.c | 17 ++++++----- lib/procuid.c | 15 ++++----- lib/read.c | 2 +- lib/read_data.c | 4 +-- lib/sem_limits.c | 15 ++++----- lib/shm_limits.c | 15 ++++----- lib/swap.c | 15 ++++----- lib/uptime.c | 15 ++++----- lib/write.c | 2 +- 22 files changed, 217 insertions(+), 127 deletions(-) diff --git a/lib/command.c b/lib/command.c index eb74183b..1bc67b05 100644 --- a/lib/command.c +++ b/lib/command.c @@ -33,7 +33,7 @@ glibtop_call__l (glibtop *server, unsigned command, size_t send_size, void *send glibtop_command *cmnd; void *ptr; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); cmnd = glibtop_calloc__r (server, 1, sizeof (glibtop_command)); diff --git a/lib/cpu.c b/lib/cpu.c index 04d3bb9d..94ffcdab 100644 --- a/lib/cpu.c +++ b/lib/cpu.c @@ -23,16 +23,17 @@ #include #include -#if GLIBTOP_SUID_CPU - /* Provides information about cpu usage. */ void glibtop_get_cpu__l (glibtop *server, glibtop_cpu *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_CPU, 0, NULL, - sizeof (glibtop_cpu), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_CPU, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_CPU) { + glibtop_call__l (server, GLIBTOP_CMND_CPU, 0, NULL, + sizeof (glibtop_cpu), buf); + } else { + glibtop_get_cpu__r (server, buf); + } +} diff --git a/lib/init.c b/lib/init.c index f6a9a506..a3cb49ef 100644 --- a/lib/init.c +++ b/lib/init.c @@ -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 (glibtop_global_server, "glibtop", + features, flags); } return *server = glibtop_global_server; diff --git a/lib/loadavg.c b/lib/loadavg.c index 7d571218..0704f1bc 100644 --- a/lib/loadavg.c +++ b/lib/loadavg.c @@ -23,16 +23,17 @@ #include #include -#if GLIBTOP_SUID_LOADAVG - /* Provides load averange. */ void glibtop_get_loadavg__l (glibtop *server, glibtop_loadavg *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_LOADAVG, 0, NULL, - sizeof (glibtop_loadavg), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_LOADAVG) { + glibtop_call__l (server, GLIBTOP_CMND_LOADAVG, 0, NULL, + sizeof (glibtop_loadavg), buf); + } else { + glibtop_get_loadavg__r (server, buf); + } +} diff --git a/lib/mem.c b/lib/mem.c index a5dd8a65..ea8f2c6b 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -22,16 +22,17 @@ #include #include -#if GLIBTOP_SUID_MEM - /* Provides information about memory usage. */ void glibtop_get_mem__l (glibtop *server, glibtop_mem *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_MEM, 0, NULL, - sizeof (glibtop_mem), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_MEM, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_MEM) { + glibtop_call__l (server, GLIBTOP_CMND_MEM, 0, NULL, + sizeof (glibtop_mem), buf); + } else { + glibtop_get_mem__r (server, buf); + } +} diff --git a/lib/msg_limits.c b/lib/msg_limits.c index 176a8a4f..9fc82c12 100644 --- a/lib/msg_limits.c +++ b/lib/msg_limits.c @@ -22,16 +22,17 @@ #include #include -#if GLIBTOP_SUID_MSG_LIMITS - /* Provides information about sysv ipc limits. */ void glibtop_get_msg_limits__l (glibtop *server, glibtop_msg_limits *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, - sizeof (glibtop_msg_limits), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_MSG_LIMITS) { + glibtop_call__l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, + sizeof (glibtop_msg_limits), buf); + } else { + glibtop_get_msg_limits__r (server, buf); + } +} diff --git a/lib/open.c b/lib/open.c index ed55b431..7dbe3131 100644 --- a/lib/open.c +++ b/lib/open.c @@ -19,19 +19,80 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include +#include /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open (glibtop *server, const char *program_name) +glibtop_open (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; memset (server, 0, sizeof (glibtop)); server->name = program_name; + /* 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) + glibtop_error__r (server, _("Remote server not yet supported by library\n")); + + server->features = glibtop_server_features; + + /* Fork and exec server. */ + if (pipe (server->input) || pipe (server->output)) glibtop_error__r (server, _("cannot make a pipe: %s\n"), strerror (errno)); @@ -44,7 +105,20 @@ glibtop_open (glibtop *server, const char *program_name) 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, "gtop_server", "-l", + server->server_user, server->server_host, + server->server_command, NULL); + } else { + execl (server->server_rsh, "gtop_server", + server->server_host, server_command, NULL); + } + } else { + execl (server->server_command, "gtop_server", NULL); + } + _exit (2); } diff --git a/lib/prockernel.c b/lib/prockernel.c index d93add72..0c66d230 100644 --- a/lib/prockernel.c +++ b/lib/prockernel.c @@ -23,17 +23,18 @@ #include #include -#if GLIBTOP_SUID_PROC_KERNEL - /* Provides detailed information about a process. */ void glibtop_get_proc_kernel__l (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) + pid_t pid) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t), - &pid, sizeof (glibtop_proc_kernel), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROC_KERNEL) { + glibtop_call__l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t), + &pid, sizeof (glibtop_proc_kernel), buf); + } else { + glibtop_get_proc_kernel__r (server, buf, pid); + } +} diff --git a/lib/proclist.c b/lib/proclist.c index 3c541129..0a40f825 100644 --- a/lib/proclist.c +++ b/lib/proclist.c @@ -22,16 +22,17 @@ #include #include -#if GLIBTOP_SUID_PROCLIST - /* Fetch list of currently running processes. */ unsigned * glibtop_get_proclist__l (glibtop *server, glibtop_proclist *buf) { - glibtop_init__r (&server); - return glibtop_call__l (server, GLIBTOP_CMND_PROCLIST, 0, NULL, - sizeof (glibtop_proclist), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROCLIST, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROCLIST) { + return glibtop_call__l (server, GLIBTOP_CMND_PROCLIST, 0, NULL, + sizeof (glibtop_proclist), buf); + } else { + return glibtop_get_proclist__r (server, buf); + } +} diff --git a/lib/procmem.c b/lib/procmem.c index 7dd06ba9..575c59a9 100644 --- a/lib/procmem.c +++ b/lib/procmem.c @@ -23,17 +23,18 @@ #include #include -#if GLIBTOP_SUID_PROC_MEM - /* Provides detailed information about a process. */ void glibtop_get_proc_mem__l (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) + pid_t pid) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), - &pid, sizeof (glibtop_proc_mem), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_MEM, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROC_MEM) { + glibtop_call__l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), + &pid, sizeof (glibtop_proc_mem), buf); + } else { + glibtop_get_proc_mem__r (server, buf, pid); + } +} diff --git a/lib/procsegment.c b/lib/procsegment.c index f144094a..a485dc30 100644 --- a/lib/procsegment.c +++ b/lib/procsegment.c @@ -23,17 +23,18 @@ #include #include -#if GLIBTOP_SUID_PROC_SEGMENT - /* Provides detailed information about a process. */ void glibtop_get_proc_segment__l (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) + pid_t pid) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t), - &pid, sizeof (glibtop_proc_segment), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROC_SEGMENT) { + glibtop_call__l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t), + &pid, sizeof (glibtop_proc_segment), buf); + } else { + glibtop_get_proc_segment__r (server, buf, pid); + } +} diff --git a/lib/procsignal.c b/lib/procsignal.c index d1ed2dd8..89c23ed3 100644 --- a/lib/procsignal.c +++ b/lib/procsignal.c @@ -23,17 +23,18 @@ #include #include -#if GLIBTOP_SUID_PROC_SIGNAL - /* Provides detailed information about a process. */ void glibtop_get_proc_signal__l (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) + pid_t pid) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), - &pid, sizeof (glibtop_proc_signal), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROC_SIGNAL) { + glibtop_call__l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), + &pid, sizeof (glibtop_proc_signal), buf); + } else { + glibtop_get_proc_signal__r (server, buf, pid); + } +} diff --git a/lib/procstate.c b/lib/procstate.c index 3c986c3e..a5625ac4 100644 --- a/lib/procstate.c +++ b/lib/procstate.c @@ -23,17 +23,18 @@ #include #include -#if GLIBTOP_SUID_PROC_STATE - /* Provides detailed information about a process. */ void glibtop_get_proc_state__l (glibtop *server, glibtop_proc_state *buf, pid_t pid) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), - &pid, sizeof (glibtop_proc_state), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROC_STATE) { + glibtop_call__l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), + &pid, sizeof (glibtop_proc_state), buf); + } else { + glibtop_get_proc_state__r (server, buf, pid); + } +} diff --git a/lib/proctime.c b/lib/proctime.c index 41413cbb..40c0e62c 100644 --- a/lib/proctime.c +++ b/lib/proctime.c @@ -23,17 +23,18 @@ #include #include -#if GLIBTOP_SUID_PROC_TIME - /* Provides detailed information about a process. */ void glibtop_get_proc_time__l (glibtop *server, glibtop_proc_time *buf, - pid_t pid) + pid_t pid) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), - &pid, sizeof (glibtop_proc_time), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROC_TIME) { + glibtop_call__l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), + &pid, sizeof (glibtop_proc_time), buf); + } else { + glibtop_get_proc_time__r (server, buf, pid); + } +} diff --git a/lib/procuid.c b/lib/procuid.c index 93e6ada3..563242a8 100644 --- a/lib/procuid.c +++ b/lib/procuid.c @@ -23,17 +23,18 @@ #include #include -#if GLIBTOP_SUID_PROC_UID - /* Provides detailed information about a process. */ void glibtop_get_proc_uid__l (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), - &pid, sizeof (glibtop_proc_uid), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_UID, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_PROC_UID) { + glibtop_call__l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), + &pid, sizeof (glibtop_proc_uid), buf); + } else { + glibtop_get_proc_uid__r (server, buf, pid); + } +} diff --git a/lib/read.c b/lib/read.c index c8ff2eec..d50b443e 100644 --- a/lib/read.c +++ b/lib/read.c @@ -28,7 +28,7 @@ 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)); diff --git a/lib/read_data.c b/lib/read_data.c index acfe0add..20e0b0e0 100644 --- a/lib/read_data.c +++ b/lib/read_data.c @@ -30,7 +30,7 @@ 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"), @@ -38,8 +38,6 @@ glibtop_read_data__l (glibtop *server) if (!size) return NULL; - fprintf (stderr, "Server has %d bytes of data.\n", size); - ptr = glibtop_malloc__r (server, size); if (read (server->input [0], ptr, size) < 0) diff --git a/lib/sem_limits.c b/lib/sem_limits.c index 2ce853a3..193b6f19 100644 --- a/lib/sem_limits.c +++ b/lib/sem_limits.c @@ -22,16 +22,17 @@ #include #include -#if GLIBTOP_SUID_SEM_LIMITS - /* Provides information about sysv ipc limits. */ void glibtop_get_sem_limits__l (glibtop *server, glibtop_sem_limits *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, - sizeof (glibtop_sem_limits), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_SEM_LIMITS) { + glibtop_call__l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, + sizeof (glibtop_sem_limits), buf); + } else { + glibtop_get_sem_limits__r (server, buf); + } +} diff --git a/lib/shm_limits.c b/lib/shm_limits.c index 9d3aee22..8b226400 100644 --- a/lib/shm_limits.c +++ b/lib/shm_limits.c @@ -22,16 +22,17 @@ #include #include -#if GLIBTOP_SUID_SHM_LIMITS - /* Provides information about sysv ipc limits. */ void glibtop_get_shm_limits__l (glibtop *server, glibtop_shm_limits *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, - sizeof (glibtop_shm_limits), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_SHM_LIMITS) { + glibtop_call__l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, + sizeof (glibtop_shm_limits), buf); + } else { + glibtop_get_shm_limits__r (server, buf); + } +} diff --git a/lib/swap.c b/lib/swap.c index e4972869..f6d7aeae 100644 --- a/lib/swap.c +++ b/lib/swap.c @@ -22,16 +22,17 @@ #include #include -#if GLIBTOP_SUID_SWAP - /* Provides information about swap usage. */ void glibtop_get_swap__l (glibtop *server, glibtop_swap *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_SWAP, 0, NULL, - sizeof (glibtop_swap), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_SWAP, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_SWAP) { + glibtop_call__l (server, GLIBTOP_CMND_SWAP, 0, NULL, + sizeof (glibtop_swap), buf); + } else { + glibtop_get_swap__r (server, buf); + } +} diff --git a/lib/uptime.c b/lib/uptime.c index 597a50b8..a6ce1195 100644 --- a/lib/uptime.c +++ b/lib/uptime.c @@ -23,16 +23,17 @@ #include #include -#if GLIBTOP_SUID_UPTIME - /* Provides uptime and idle time. */ void glibtop_get_uptime__l (glibtop *server, glibtop_uptime *buf) { - glibtop_init__r (&server); - glibtop_call__l (server, GLIBTOP_CMND_UPTIME, 0, NULL, - sizeof (glibtop_uptime), buf); -} + glibtop_init__r (&server, GLIBTOP_SYSDEPS_UPTIME, 0); -#endif + if (server->features & GLIBTOP_SYSDEPS_UPTIME) { + glibtop_call__l (server, GLIBTOP_CMND_UPTIME, 0, NULL, + sizeof (glibtop_uptime), buf); + } else { + glibtop_get_uptime__r (server, buf); + } +} diff --git a/lib/write.c b/lib/write.c index 2d3984d0..e7913ef0 100644 --- a/lib/write.c +++ b/lib/write.c @@ -26,7 +26,7 @@ void 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)); From b7be9a7141893692c456f6dd579effbc959d1d20 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 1 Jun 1998 15:14:50 +0000 Subject: [PATCH 0068/2539] added 'dummy' member so 'GLIBTOP_SYSDEPS_' now start with 1. * include/glibtop/sysdeps.h: added 'dummy' member so 'GLIBTOP_SYSDEPS_' now start with 1. * include/glibtop/*.h: we now #define 'glibtop_get_' as 'glibtop_get___l' and 'glibtop_get___r' either as the '__p' or the '__s' function. --- include/glibtop/command.h | 35 +++++++++++++++++----------------- include/glibtop/cpu.h | 7 ++++--- include/glibtop/loadavg.h | 7 ++++--- include/glibtop/mem.h | 7 ++++--- include/glibtop/msg_limits.h | 7 ++++--- include/glibtop/open.h | 4 +++- include/glibtop/prockernel.h | 7 ++++--- include/glibtop/proclist.h | 7 ++++--- include/glibtop/procmem.h | 7 ++++--- include/glibtop/procsegment.h | 7 ++++--- include/glibtop/procsignal.h | 7 ++++--- include/glibtop/procstate.h | 7 ++++--- include/glibtop/proctime.h | 7 ++++--- include/glibtop/procuid.h | 7 ++++--- include/glibtop/sem_limits.h | 7 ++++--- include/glibtop/shm_limits.h | 7 ++++--- include/glibtop/swap.h | 7 ++++--- include/glibtop/sysdeps.h | 36 ++++++++++++++++++----------------- include/glibtop/uptime.h | 7 ++++--- 19 files changed, 103 insertions(+), 84 deletions(-) diff --git a/include/glibtop/command.h b/include/glibtop/command.h index c57d2373..daf31227 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -28,26 +28,25 @@ __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 -#define GLIBTOP_CMND_UPTIME 5 -#define GLIBTOP_CMND_LOADAVG 6 -#define GLIBTOP_CMND_SHM_LIMITS 7 -#define GLIBTOP_CMND_MSG_LIMITS 8 -#define GLIBTOP_CMND_SEM_LIMITS 9 -#define GLIBTOP_CMND_PROCLIST 10 +#define GLIBTOP_CMND_CPU 1 +#define GLIBTOP_CMND_MEM 2 +#define GLIBTOP_CMND_SWAP 3 +#define GLIBTOP_CMND_UPTIME 4 +#define GLIBTOP_CMND_LOADAVG 5 +#define GLIBTOP_CMND_SHM_LIMITS 6 +#define GLIBTOP_CMND_MSG_LIMITS 7 +#define GLIBTOP_CMND_SEM_LIMITS 8 +#define GLIBTOP_CMND_PROCLIST 9 -#define GLIBTOP_CMND_PROC_STATE 11 -#define GLIBTOP_CMND_PROC_UID 12 -#define GLIBTOP_CMND_PROC_MEM 13 -#define GLIBTOP_CMND_PROC_TIME 14 -#define GLIBTOP_CMND_PROC_SIGNAL 15 -#define GLIBTOP_CMND_PROC_KERNEL 16 -#define GLIBTOP_CMND_PROC_SEGMENT 17 +#define GLIBTOP_CMND_PROC_STATE 10 +#define GLIBTOP_CMND_PROC_UID 11 +#define GLIBTOP_CMND_PROC_MEM 12 +#define GLIBTOP_CMND_PROC_TIME 13 +#define GLIBTOP_CMND_PROC_SIGNAL 14 +#define GLIBTOP_CMND_PROC_KERNEL 15 +#define GLIBTOP_CMND_PROC_SEGMENT 16 -#define GLIBTOP_MAX_CMND 18 +#define GLIBTOP_MAX_CMND 17 typedef struct _glibtop_command glibtop_command; diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h index 80b04348..323fbbaf 100644 --- a/include/glibtop/cpu.h +++ b/include/glibtop/cpu.h @@ -49,16 +49,17 @@ 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) #if GLIBTOP_SUID_CPU -#define glibtop_get_cpu__r glibtop_get_cpu__l +#define glibtop_get_cpu__r glibtop_get_cpu__p #else #define glibtop_get_cpu__r glibtop_get_cpu__s #endif -#if GLIBTOP_SUID_CPU 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 *)); diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h index dd30d432..eaf6588c 100644 --- a/include/glibtop/loadavg.h +++ b/include/glibtop/loadavg.h @@ -39,16 +39,17 @@ 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) #if GLIBTOP_SUID_LOADAVG -#define glibtop_get_loadavg__r glibtop_get_loadavg__l +#define glibtop_get_loadavg__r glibtop_get_loadavg__p #else #define glibtop_get_loadavg__r glibtop_get_loadavg__s #endif -#if GLIBTOP_SUID_LOADAVG 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 *)); diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h index 5b35344a..b36b626a 100644 --- a/include/glibtop/mem.h +++ b/include/glibtop/mem.h @@ -53,16 +53,17 @@ 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) #if GLIBTOP_SUID_MEM -#define glibtop_get_mem__r glibtop_get_mem__l +#define glibtop_get_mem__r glibtop_get_mem__p #else #define glibtop_get_mem__r glibtop_get_mem__s #endif -#if GLIBTOP_SUID_MEM 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 *)); diff --git a/include/glibtop/msg_limits.h b/include/glibtop/msg_limits.h index 9031f549..648f0905 100644 --- a/include/glibtop/msg_limits.h +++ b/include/glibtop/msg_limits.h @@ -51,16 +51,17 @@ 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) #if GLIBTOP_SUID_MSG_LIMITS -#define glibtop_get_msg_limits__r glibtop_get_msg_limits__l +#define glibtop_get_msg_limits__r glibtop_get_msg_limits__p #else #define glibtop_get_msg_limits__r glibtop_get_msg_limits__s #endif -#if GLIBTOP_SUID_MSG_LIMITS 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 *)); diff --git a/include/glibtop/open.h b/include/glibtop/open.h index 8be5a9ae..9a1dbe05 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -26,7 +26,9 @@ __BEGIN_DECLS -extern void glibtop_open __P((glibtop *, const char *)); +#define GLIBTOP_OPEN_IMMEDIATE 1 + +extern void glibtop_open __P((glibtop *, const char *, const unsigned long, const unsigned)); __END_DECLS diff --git a/include/glibtop/prockernel.h b/include/glibtop/prockernel.h index c214e0b2..3f035c31 100644 --- a/include/glibtop/prockernel.h +++ b/include/glibtop/prockernel.h @@ -60,16 +60,17 @@ 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) #if GLIBTOP_SUID_PROC_KERNEL -#define glibtop_get_proc_kernel__r glibtop_get_proc_kernel__l +#define glibtop_get_proc_kernel__r glibtop_get_proc_kernel__p #else #define glibtop_get_proc_kernel__r glibtop_get_proc_kernel__s #endif -#if GLIBTOP_SUID_PROC_KERNEL 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)); diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h index a55dd055..4d3dba24 100644 --- a/include/glibtop/proclist.h +++ b/include/glibtop/proclist.h @@ -43,16 +43,17 @@ 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) #if GLIBTOP_SUID_PROCLIST -#define glibtop_get_proclist__r glibtop_get_proclist__l +#define glibtop_get_proclist__r glibtop_get_proclist__p #else #define glibtop_get_proclist__r glibtop_get_proclist__s #endif -#if GLIBTOP_SUID_PROCLIST 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 *)); diff --git a/include/glibtop/procmem.h b/include/glibtop/procmem.h index d841add8..f8ae77b7 100644 --- a/include/glibtop/procmem.h +++ b/include/glibtop/procmem.h @@ -53,16 +53,17 @@ 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) #if GLIBTOP_SUID_PROC_MEM -#define glibtop_get_proc_mem__r glibtop_get_proc_mem__l +#define glibtop_get_proc_mem__r glibtop_get_proc_mem__p #else #define glibtop_get_proc_mem__r glibtop_get_proc_mem__s #endif -#if GLIBTOP_SUID_PROC_MEM 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)); diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h index 7b8b4425..574b60b3 100644 --- a/include/glibtop/procsegment.h +++ b/include/glibtop/procsegment.h @@ -54,16 +54,17 @@ 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) #if GLIBTOP_SUID_PROC_SEGMENT -#define glibtop_get_proc_segment__r glibtop_get_proc_segment__l +#define glibtop_get_proc_segment__r glibtop_get_proc_segment__p #else #define glibtop_get_proc_segment__r glibtop_get_proc_segment__s #endif -#if GLIBTOP_SUID_PROC_SEGMENT 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)); diff --git a/include/glibtop/procsignal.h b/include/glibtop/procsignal.h index dc77a7e3..c7257c9a 100644 --- a/include/glibtop/procsignal.h +++ b/include/glibtop/procsignal.h @@ -47,16 +47,17 @@ 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) #if GLIBTOP_SUID_PROC_SIGNAL -#define glibtop_get_proc_signal__r glibtop_get_proc_signal__l +#define glibtop_get_proc_signal__r glibtop_get_proc_signal__p #else #define glibtop_get_proc_signal__r glibtop_get_proc_signal__s #endif -#if GLIBTOP_SUID_PROC_SIGNAL 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)); diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h index f5044eb9..7217b6b2 100644 --- a/include/glibtop/procstate.h +++ b/include/glibtop/procstate.h @@ -54,16 +54,17 @@ 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) #if GLIBTOP_SUID_PROC_STATE -#define glibtop_get_proc_state__r glibtop_get_proc_state__l +#define glibtop_get_proc_state__r glibtop_get_proc_state__p #else #define glibtop_get_proc_state__r glibtop_get_proc_state__s #endif -#if GLIBTOP_SUID_PROC_STATE 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)); diff --git a/include/glibtop/proctime.h b/include/glibtop/proctime.h index 1d866767..245afc6e 100644 --- a/include/glibtop/proctime.h +++ b/include/glibtop/proctime.h @@ -59,16 +59,17 @@ 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) #if GLIBTOP_SUID_PROC_TIME -#define glibtop_get_proc_time__r glibtop_get_proc_time__l +#define glibtop_get_proc_time__r glibtop_get_proc_time__p #else #define glibtop_get_proc_time__r glibtop_get_proc_time__s #endif -#if GLIBTOP_SUID_PROC_TIME 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)); diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h index 3d8682bc..40de660e 100644 --- a/include/glibtop/procuid.h +++ b/include/glibtop/procuid.h @@ -63,16 +63,17 @@ 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) #if GLIBTOP_SUID_PROC_UID -#define glibtop_get_proc_uid__r glibtop_get_proc_uid__l +#define glibtop_get_proc_uid__r glibtop_get_proc_uid__p #else #define glibtop_get_proc_uid__r glibtop_get_proc_uid__s #endif -#if GLIBTOP_SUID_PROC_UID 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)); diff --git a/include/glibtop/sem_limits.h b/include/glibtop/sem_limits.h index f24460e2..8a591a68 100644 --- a/include/glibtop/sem_limits.h +++ b/include/glibtop/sem_limits.h @@ -57,16 +57,17 @@ 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) #if GLIBTOP_SUID_SEM_LIMITS -#define glibtop_get_sem_limits__r glibtop_get_sem_limits__l +#define glibtop_get_sem_limits__r glibtop_get_sem_limits__p #else #define glibtop_get_sem_limits__r glibtop_get_sem_limits__s #endif -#if GLIBTOP_SUID_SEM_LIMITS 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 *)); diff --git a/include/glibtop/shm_limits.h b/include/glibtop/shm_limits.h index 30fc3e4f..8d996e27 100644 --- a/include/glibtop/shm_limits.h +++ b/include/glibtop/shm_limits.h @@ -47,16 +47,17 @@ 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) #if GLIBTOP_SUID_SHM_LIMITS -#define glibtop_get_shm_limits__r glibtop_get_shm_limits__l +#define glibtop_get_shm_limits__r glibtop_get_shm_limits__p #else #define glibtop_get_shm_limits__r glibtop_get_shm_limits__s #endif -#if GLIBTOP_SUID_SHM_LIMITS 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 *)); diff --git a/include/glibtop/swap.h b/include/glibtop/swap.h index fb438413..4ee5564d 100644 --- a/include/glibtop/swap.h +++ b/include/glibtop/swap.h @@ -43,16 +43,17 @@ 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) #if GLIBTOP_SUID_SWAP -#define glibtop_get_swap__r glibtop_get_swap__l +#define glibtop_get_swap__r glibtop_get_swap__p #else #define glibtop_get_swap__r glibtop_get_swap__s #endif -#if GLIBTOP_SUID_SWAP 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 *)); diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index b7eec5cb..b8dd8f98 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -27,30 +27,32 @@ __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_DUMMY 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 typedef struct _glibtop_sysdeps glibtop_sysdeps; struct _glibtop_sysdeps { unsigned long flags, + dummy, /* dummy field */ cpu, /* glibtop_cpu */ mem, /* glibtop_mem */ swap, /* glibtop_swap */ diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h index 50dfdb48..aa3be951 100644 --- a/include/glibtop/uptime.h +++ b/include/glibtop/uptime.h @@ -41,16 +41,17 @@ 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) #if GLIBTOP_SUID_UPTIME -#define glibtop_get_uptime__r glibtop_get_uptime__l +#define glibtop_get_uptime__r glibtop_get_uptime__p #else #define glibtop_get_uptime__r glibtop_get_uptime__s #endif -#if GLIBTOP_SUID_UPTIME 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 *)); From 080dd0850bee995e57786406436e0b54db16b672 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 1 Jun 1998 15:15:56 +0000 Subject: [PATCH 0069/2539] now using 'glibtop_init' instead of 'glibtop_init__r'. * examples/{first.c, second.c}: now using 'glibtop_init' instead of 'glibtop_init__r'. --- examples/Makefile.am | 6 +++--- examples/first.c | 2 +- examples/second.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 9984ca10..34f06fa1 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -17,8 +17,8 @@ EXTRA_PROGRAMS = third third_static first_SOURCES = first.c first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ - $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/lib/libgtop.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ @INTLLIBS@ @LIBSUPPORT@ first_static_SOURCES = $(first_SOURCES) @@ -27,8 +27,8 @@ first_static_LDFLAGS = -static second_SOURCES = second.c second_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ - $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ $(top_builddir)/lib/libgtop.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ @INTLLIBS@ @LIBSUPPORT@ second_static_SOURCES = $(second_SOURCES) @@ -43,9 +43,9 @@ endif third_SOURCES = third.c third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.la \ $(third_guile_names_LIBS) $(third_names_LIBS) \ + $(top_builddir)/lib/libgtop.la \ $(top_builddir)/sysdeps/common/libgtop_common.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ - $(top_builddir)/lib/libgtop.la \ @GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@ third_static_SOURCES = $(third_SOURCES) diff --git a/examples/first.c b/examples/first.c index edd7e0eb..c4f32e6e 100644 --- a/examples/first.c +++ b/examples/first.c @@ -39,7 +39,7 @@ main (int argc, char *argv []) bindtextdomain (PACKAGE, GTOPLOCALEDIR); textdomain (PACKAGE); - glibtop_init__r (&glibtop_global_server); + glibtop_init (); glibtop_get_cpu (&data.cpu); diff --git a/examples/second.c b/examples/second.c index c3d1b0f5..9dbb73ce 100644 --- a/examples/second.c +++ b/examples/second.c @@ -39,7 +39,7 @@ main (int argc, char *argv []) bindtextdomain (PACKAGE, GTOPLOCALEDIR); textdomain (PACKAGE); - glibtop_init__r (&glibtop_global_server); + glibtop_init (); glibtop_get_sysdeps (&sysdeps); From 2546fa37eb76931f392a005825eb30f6fa80102e Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 1 Jun 1998 15:21:19 +0000 Subject: [PATCH 0070/2539] 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. --- sysdeps/linux/Makefile.am | 2 ++ sysdeps/linux/cpu.c | 2 +- sysdeps/linux/init.c | 6 ++++-- sysdeps/linux/loadavg.c | 2 +- sysdeps/linux/mem.c | 2 +- sysdeps/linux/msg_limits.c | 2 +- sysdeps/linux/open.c | 3 ++- sysdeps/linux/procdata.c | 2 +- sysdeps/linux/prockernel.c | 2 +- sysdeps/linux/proclist.c | 2 +- sysdeps/linux/procmem.c | 2 +- sysdeps/linux/procsegment.c | 2 +- sysdeps/linux/procsignal.c | 2 +- sysdeps/linux/procstate.c | 2 +- sysdeps/linux/proctime.c | 2 +- sysdeps/linux/procuid.c | 2 +- sysdeps/linux/sem_limits.c | 2 +- sysdeps/linux/shm_limits.c | 2 +- sysdeps/linux/swap.c | 2 +- sysdeps/linux/uptime.c | 2 +- 20 files changed, 25 insertions(+), 20 deletions(-) diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index 7d161c51..5c5cb132 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -13,3 +13,5 @@ libgtop_sysdeps_la_SOURCES = init.c open.c close.c cpu.c mem.c swap.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ procsegment.c + +include_HEADERS = glibtop_server.h diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index 9f009092..804d29e9 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -34,7 +34,7 @@ glibtop_get_cpu__s (glibtop *server, glibtop_cpu *buf) { FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_cpu)); diff --git a/sysdeps/linux/init.c b/sysdeps/linux/init.c index f6a9a506..a3cb49ef 100644 --- a/sysdeps/linux/init.c +++ b/sysdeps/linux/init.c @@ -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 (glibtop_global_server, "glibtop", + features, flags); } return *server = glibtop_global_server; diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c index 2b759b0f..d497a065 100644 --- a/sysdeps/linux/loadavg.c +++ b/sysdeps/linux/loadavg.c @@ -32,7 +32,7 @@ glibtop_get_loadavg__s (glibtop *server, glibtop_loadavg *buf) { FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_loadavg)); diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index 22a8b192..c7d78b1e 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -35,7 +35,7 @@ glibtop_get_mem__s (glibtop *server, glibtop_mem *buf) { FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_mem)); diff --git a/sysdeps/linux/msg_limits.c b/sysdeps/linux/msg_limits.c index 43b24407..6a1be74e 100644 --- a/sysdeps/linux/msg_limits.c +++ b/sysdeps/linux/msg_limits.c @@ -37,7 +37,7 @@ glibtop_get_msg_limits__s (glibtop *server, glibtop_msg_limits *buf) { struct msginfo msginfo; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_msg_limits)); diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index b2da083a..5645683a 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -51,7 +51,8 @@ static void set_linux_version(void) { /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open (glibtop *server, const char *program_name) +glibtop_open (glibtop *server, const char *program_name, + const unsigned long features, const unsigned flags) { memset (server, 0, sizeof (glibtop)); server->name = program_name; diff --git a/sysdeps/linux/procdata.c b/sysdeps/linux/procdata.c index 1c9f9cf1..5e2bd856 100644 --- a/sysdeps/linux/procdata.c +++ b/sysdeps/linux/procdata.c @@ -85,7 +85,7 @@ glibtop_get_procdata__s (glibtop *server, glibtop_procdata *buf, pid_t pid) int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_procdata)); diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c index 5f6cba72..dbd1dcb1 100644 --- a/sysdeps/linux/prockernel.c +++ b/sysdeps/linux/prockernel.c @@ -37,7 +37,7 @@ glibtop_get_proc_kernel__s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_kernel)); diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c index 93f79e34..e23ccbfe 100644 --- a/sysdeps/linux/proclist.c +++ b/sysdeps/linux/proclist.c @@ -60,7 +60,7 @@ glibtop_get_proclist__s (glibtop *server, glibtop_proclist *buf) struct stat statb; int len, i, ok; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proclist)); diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index 727565e6..fb5db2b1 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -36,7 +36,7 @@ glibtop_get_proc_mem__s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_mem)); diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index 70fd131d..1ed83167 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -38,7 +38,7 @@ glibtop_get_proc_segment__s (glibtop *server, glibtop_proc_segment *buf, int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_segment)); diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c index 0e978eef..09754f62 100644 --- a/sysdeps/linux/procsignal.c +++ b/sysdeps/linux/procsignal.c @@ -35,7 +35,7 @@ glibtop_get_proc_signal__s (glibtop *server, glibtop_proc_signal *buf, pid_t pid int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_signal)); diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index 5a423622..91af0b4c 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -38,7 +38,7 @@ glibtop_get_proc_state__s (glibtop *server, glibtop_proc_state *buf, pid_t pid) int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_state)); diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index 01c8bf43..9d63a8a2 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -37,7 +37,7 @@ glibtop_get_proc_time__s (glibtop *server, glibtop_proc_time *buf, pid_t pid) int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_time)); diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c index f3d5b8f5..3820f7fd 100644 --- a/sysdeps/linux/procuid.c +++ b/sysdeps/linux/procuid.c @@ -41,7 +41,7 @@ glibtop_get_proc_uid__s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) int nread; FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_uid)); diff --git a/sysdeps/linux/sem_limits.c b/sysdeps/linux/sem_limits.c index fda5c0e5..6b64c153 100644 --- a/sysdeps/linux/sem_limits.c +++ b/sysdeps/linux/sem_limits.c @@ -39,7 +39,7 @@ glibtop_get_sem_limits__s (glibtop *server, glibtop_sem_limits *buf) struct seminfo seminfo; union semun arg; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_sem_limits)); diff --git a/sysdeps/linux/shm_limits.c b/sysdeps/linux/shm_limits.c index d3c3193a..78f823c7 100644 --- a/sysdeps/linux/shm_limits.c +++ b/sysdeps/linux/shm_limits.c @@ -36,7 +36,7 @@ glibtop_get_shm_limits__s (glibtop *server, glibtop_shm_limits *buf) { struct shminfo shminfo; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_shm_limits)); diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index 8fb5e41e..1439e5d1 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -33,7 +33,7 @@ glibtop_get_swap__s (glibtop *server, glibtop_swap *buf) { FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_swap)); diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c index 69f5b6b5..8c3e3da0 100644 --- a/sysdeps/linux/uptime.c +++ b/sysdeps/linux/uptime.c @@ -32,7 +32,7 @@ glibtop_get_uptime__s (glibtop *server, glibtop_uptime *buf) { FILE *f; - glibtop_init__r (&server); + glibtop_init__r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_uptime)); From 344bdd330f6dba2c1a7fae5d13ce54c0895ee6f1 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 1 Jun 1998 15:22:00 +0000 Subject: [PATCH 0071/2539] 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. --- sysdeps/common/sysdeps.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sysdeps/common/sysdeps.c b/sysdeps/common/sysdeps.c index 1155bbc8..cbb961ab 100644 --- a/sysdeps/common/sysdeps.c +++ b/sysdeps/common/sysdeps.c @@ -21,6 +21,16 @@ #include #include +const unsigned long glibtop_server_features = +(1 << GLIBTOP_SUID_CPU) + (1 << GLIBTOP_SUID_MEM) + +(1 << GLIBTOP_SUID_SWAP) + (1 << GLIBTOP_SUID_UPTIME) + +(1 << GLIBTOP_SUID_LOADAVG) + (1 << GLIBTOP_SUID_SHM_LIMITS) + +(1 << GLIBTOP_SUID_MSG_LIMITS) + (1 << GLIBTOP_SUID_SEM_LIMITS) + +(1 << GLIBTOP_SUID_PROCLIST) + (1 << GLIBTOP_SUID_PROC_STATE) + +(1 << GLIBTOP_SUID_PROC_UID) + (1 << GLIBTOP_SUID_PROC_MEM) + +(1 << GLIBTOP_SUID_PROC_TIME) + (1 << GLIBTOP_SUID_PROC_SIGNAL) + +(1 << GLIBTOP_SUID_PROC_KERNEL) + (1 << GLIBTOP_SUID_PROC_SEGMENT); + /* Checks which features are implemented. */ void From 15e73d9b7d6615c806216042be8827ca6885c584 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 1 Jun 1998 15:25:11 +0000 Subject: [PATCH 0072/2539] *** empty log message *** --- glibtop.h | 11 +++++++++-- src/server/main.c | 9 +++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/glibtop.h b/glibtop.h index 26bba2d5..2d4756f0 100644 --- a/glibtop.h +++ b/glibtop.h @@ -42,14 +42,21 @@ 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); + +extern glibtop *glibtop_init__r __P((glibtop **, const unsigned long, const unsigned)); #ifdef HAVE_GUILE diff --git a/src/server/main.c b/src/server/main.c index 31b261d6..11b67326 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) setreuid (uid, euid); setregid (gid, egid); - glibtop_open (&server, argv [0]); + glibtop_open (&server, argv [0], 0, 0); if (setreuid (euid, uid)) _exit (1); @@ -140,11 +140,6 @@ int main(int argc, char *argv[]) } switch (cmnd.command) { - case GLIBTOP_CMND_SYSDEPS: - glibtop_get_sysdeps__r (&server, &sysdeps); - glibtop_output (sizeof (glibtop_sysdeps), &sysdeps); - glibtop_output (0, NULL); - break; case GLIBTOP_CMND_CPU: #if GLIBTOP_SUID_CPU glibtop_get_cpu__p (&server, &data.cpu); @@ -207,6 +202,8 @@ int main(int argc, char *argv[]) case GLIBTOP_CMND_PROCLIST: #if GLIBTOP_SUID_PROCLIST ptr = glibtop_get_proclist__p (&server, &data.proclist); +#else + ptr = NULL; #endif glibtop_output (sizeof (glibtop_proclist), &data.proclist); From b4a16ccd89ababdd42d9a25109d3b1136e040e36 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 1 Jun 1998 15:54:49 +0000 Subject: [PATCH 0073/2539] 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 --- ChangeLog | 34 ++++++++++++++++- NEWS | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0a6517c4..45b7148c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +1998-06-01 Martin Baulig + + * 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_' now start with 1. + + * include/glibtop/*.h: we now #define 'glibtop_get_' + as 'glibtop_get___l' and 'glibtop_get___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 * src/server/main.c: we now use the '__p' functions, @@ -17,7 +49,7 @@ to '__l'; we only emit code for those functions if the corresponding 'GLIBTOP_SUID_' has a positive value. - * sysdeps/linux/*.h: added some new function suffixes: + * 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. diff --git a/NEWS b/NEWS index 3bb066b6..f886566e 100644 --- a/NEWS +++ b/NEWS @@ -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_' + 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 + + * 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_' now start with 1. + + * include/glibtop/*.h: we now #define 'glibtop_get_' + as 'glibtop_get___l' and 'glibtop_get___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 + + * src/server/main.c: we now use the '__p' functions, + but only if the appropriate 'GLIBTOP_SUID_' + 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_' 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_' + being either 'GLIBTOP_SYSDEPS_'+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 =========== From beb68e2fc4061623d644ec23473cf4d3719b645a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 16:12:28 +0000 Subject: [PATCH 0074/2539] new command to get glibtop_server_features. * src/server/main.c (GLIBTOP_CMND_SYSDEPS): new command to get glibtop_server_features. --- src/server/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/server/main.c b/src/server/main.c index 11b67326..fd47da50 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -140,6 +140,11 @@ int main(int argc, char *argv[]) } 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: #if GLIBTOP_SUID_CPU glibtop_get_cpu__p (&server, &data.cpu); From cad4b8f2f553d650b5fe8a97692e9aa8075469ba Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 16:13:31 +0000 Subject: [PATCH 0075/2539] new directory - proxy server. * src/proxy/*: new directory - proxy server. --- src/proxy/.cvsignore | 5 + src/proxy/Makefile.am | 16 +++ src/proxy/main.c | 233 ++++++++++++++++++++++++++++++++++++++++++ src/proxy/output.c | 31 ++++++ src/proxy/version.c | 31 ++++++ 5 files changed, 316 insertions(+) create mode 100644 src/proxy/.cvsignore create mode 100644 src/proxy/Makefile.am create mode 100644 src/proxy/main.c create mode 100644 src/proxy/output.c create mode 100644 src/proxy/version.c diff --git a/src/proxy/.cvsignore b/src/proxy/.cvsignore new file mode 100644 index 00000000..0a35f089 --- /dev/null +++ b/src/proxy/.cvsignore @@ -0,0 +1,5 @@ +.deps +.libs +Makefile +Makefile.in +gtop_proxy diff --git a/src/proxy/Makefile.am b/src/proxy/Makefile.am new file mode 100644 index 00000000..66badb1a --- /dev/null +++ b/src/proxy/Makefile.am @@ -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 diff --git a/src/proxy/main.c b/src/proxy/main.c new file mode 100644 index 00000000..3671b962 --- /dev/null +++ b/src/proxy/main.c @@ -0,0 +1,233 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include +#include +#include + +#include + +#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 (&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); +} diff --git a/src/proxy/output.c b/src/proxy/output.c new file mode 100644 index 00000000..9fa98655 --- /dev/null +++ b/src/proxy/output.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +void +glibtop_output (size_t size, const void *buf) +{ + if (write (1, &size, sizeof (size_t)) < 0) + _exit (2); + if (write (1, buf, size) < 0) + _exit (2); +} diff --git a/src/proxy/version.c b/src/proxy/version.c new file mode 100644 index 00000000..3e21f55a --- /dev/null +++ b/src/proxy/version.c @@ -0,0 +1,31 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +void +glibtop_version (void) +{ + char buffer [BUFSIZ]; + + sprintf (buffer, "%s server %s ready.\n", PACKAGE, VERSION); + glibtop_output (strlen (buffer), buffer); +} From 6f179a314134e9db75853ce39ffe9a6741793c76 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 16:14:49 +0000 Subject: [PATCH 0076/2539] swapped lib and src directories. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c08f2026..94842009 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ 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) From 7f39d62371933fab64a352845379a1ad158d77b8 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 16:20:15 +0000 Subject: [PATCH 0077/2539] 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. --- configure.in | 1 + include/glibtop/command.h | 36 ++++++----- include/glibtop/open.h | 2 +- include/glibtop/sysdeps.h | 4 +- lib/open.c | 130 ++++++++++++++++++++++---------------- sysdeps/common/sysdeps.c | 28 +++++--- 6 files changed, 120 insertions(+), 81 deletions(-) diff --git a/configure.in b/configure.in index 878b7f14..ded551cc 100644 --- a/configure.in +++ b/configure.in @@ -188,6 +188,7 @@ sysdeps/osf1/Makefile sysdeps/linux/Makefile src/Makefile src/server/Makefile +src/proxy/Makefile lib/Makefile examples/Makefile support/Makefile diff --git a/include/glibtop/command.h b/include/glibtop/command.h index daf31227..ce83c618 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -28,25 +28,27 @@ __BEGIN_DECLS #define GLIBTOP_CMND_QUIT 0 -#define GLIBTOP_CMND_CPU 1 -#define GLIBTOP_CMND_MEM 2 -#define GLIBTOP_CMND_SWAP 3 -#define GLIBTOP_CMND_UPTIME 4 -#define GLIBTOP_CMND_LOADAVG 5 -#define GLIBTOP_CMND_SHM_LIMITS 6 -#define GLIBTOP_CMND_MSG_LIMITS 7 -#define GLIBTOP_CMND_SEM_LIMITS 8 -#define GLIBTOP_CMND_PROCLIST 9 +#define GLIBTOP_CMND_SYSDEPS 1 -#define GLIBTOP_CMND_PROC_STATE 10 -#define GLIBTOP_CMND_PROC_UID 11 -#define GLIBTOP_CMND_PROC_MEM 12 -#define GLIBTOP_CMND_PROC_TIME 13 -#define GLIBTOP_CMND_PROC_SIGNAL 14 -#define GLIBTOP_CMND_PROC_KERNEL 15 -#define GLIBTOP_CMND_PROC_SEGMENT 16 +#define GLIBTOP_CMND_CPU 2 +#define GLIBTOP_CMND_MEM 3 +#define GLIBTOP_CMND_SWAP 4 +#define GLIBTOP_CMND_UPTIME 5 +#define GLIBTOP_CMND_LOADAVG 6 +#define GLIBTOP_CMND_SHM_LIMITS 7 +#define GLIBTOP_CMND_MSG_LIMITS 8 +#define GLIBTOP_CMND_SEM_LIMITS 9 +#define GLIBTOP_CMND_PROCLIST 10 -#define GLIBTOP_MAX_CMND 17 +#define GLIBTOP_CMND_PROC_STATE 11 +#define GLIBTOP_CMND_PROC_UID 12 +#define GLIBTOP_CMND_PROC_MEM 13 +#define GLIBTOP_CMND_PROC_TIME 14 +#define GLIBTOP_CMND_PROC_SIGNAL 15 +#define GLIBTOP_CMND_PROC_KERNEL 16 +#define GLIBTOP_CMND_PROC_SEGMENT 17 + +#define GLIBTOP_MAX_CMND 18 typedef struct _glibtop_command glibtop_command; diff --git a/include/glibtop/open.h b/include/glibtop/open.h index 9a1dbe05..83674a55 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -26,7 +26,7 @@ __BEGIN_DECLS -#define GLIBTOP_OPEN_IMMEDIATE 1 +#define GLIBTOP_OPEN_NO_OVERRIDE 1 extern void glibtop_open __P((glibtop *, const char *, const unsigned long, const unsigned)); diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index b8dd8f98..8bbcba2b 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -47,12 +47,14 @@ __BEGIN_DECLS #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, - dummy, /* dummy field */ + features, /* server features */ cpu, /* glibtop_cpu */ mem, /* glibtop_mem */ swap, /* glibtop_swap */ diff --git a/lib/open.c b/lib/open.c index 7dbe3131..0bc6f9fd 100644 --- a/lib/open.c +++ b/lib/open.c @@ -21,6 +21,8 @@ #include #include +#include +#include #include /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ @@ -32,74 +34,83 @@ glibtop_open (glibtop *server, const char *program_name, 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; - /* Try to get data from environment. */ + /* Is the user allowed to override the server ? */ - temp = getenv ("LIBGTOP_SERVER") ? - getenv ("LIBGTOP_SERVER") : GTOP_SERVER; + if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) { - 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; + /* 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; } - - /* 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) - glibtop_error__r (server, _("Remote server not yet supported by library\n")); - - server->features = glibtop_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]); @@ -108,20 +119,22 @@ glibtop_open (glibtop *server, const char *program_name, if (server_host) { if (server_user) { - execl (server->server_rsh, "gtop_server", "-l", + execl (server->server_rsh, "-l", server->server_user, server->server_host, server->server_command, NULL); } else { - execl (server->server_rsh, "gtop_server", + execl (server->server_rsh, server->server_host, server_command, NULL); } } else { - execl (server->server_command, "gtop_server", NULL); + execl (server->server_command, NULL); } _exit (2); } + fprintf (stderr, "PID: %d\n", server->pid); + close (server->input [1]); close (server->output [0]); @@ -131,4 +144,13 @@ glibtop_open (glibtop *server, const char *program_name, if (memcmp (version, buffer, strlen (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); } diff --git a/sysdeps/common/sysdeps.c b/sysdeps/common/sysdeps.c index cbb961ab..883097e5 100644 --- a/sysdeps/common/sysdeps.c +++ b/sysdeps/common/sysdeps.c @@ -21,15 +21,25 @@ #include #include +#define BIT_MASK(feature) (feature ? (1 << feature) : feature) + const unsigned long glibtop_server_features = -(1 << GLIBTOP_SUID_CPU) + (1 << GLIBTOP_SUID_MEM) + -(1 << GLIBTOP_SUID_SWAP) + (1 << GLIBTOP_SUID_UPTIME) + -(1 << GLIBTOP_SUID_LOADAVG) + (1 << GLIBTOP_SUID_SHM_LIMITS) + -(1 << GLIBTOP_SUID_MSG_LIMITS) + (1 << GLIBTOP_SUID_SEM_LIMITS) + -(1 << GLIBTOP_SUID_PROCLIST) + (1 << GLIBTOP_SUID_PROC_STATE) + -(1 << GLIBTOP_SUID_PROC_UID) + (1 << GLIBTOP_SUID_PROC_MEM) + -(1 << GLIBTOP_SUID_PROC_TIME) + (1 << GLIBTOP_SUID_PROC_SIGNAL) + -(1 << GLIBTOP_SUID_PROC_KERNEL) + (1 << GLIBTOP_SUID_PROC_SEGMENT); +BIT_MASK(GLIBTOP_SUID_CPU) + +BIT_MASK(GLIBTOP_SUID_MEM) + +BIT_MASK(GLIBTOP_SUID_SWAP) + +BIT_MASK(GLIBTOP_SUID_UPTIME) + +BIT_MASK(GLIBTOP_SUID_LOADAVG) + +BIT_MASK(GLIBTOP_SUID_SHM_LIMITS) + +BIT_MASK(GLIBTOP_SUID_MSG_LIMITS) + +BIT_MASK(GLIBTOP_SUID_SEM_LIMITS) + +BIT_MASK(GLIBTOP_SUID_PROCLIST) + +BIT_MASK(GLIBTOP_SUID_PROC_STATE) + +BIT_MASK(GLIBTOP_SUID_PROC_UID) + +BIT_MASK(GLIBTOP_SUID_PROC_MEM) + +BIT_MASK(GLIBTOP_SUID_PROC_TIME) + +BIT_MASK(GLIBTOP_SUID_PROC_SIGNAL) + +BIT_MASK(GLIBTOP_SUID_PROC_KERNEL) + +BIT_MASK(GLIBTOP_SUID_PROC_SEGMENT); /* Checks which features are implemented. */ @@ -40,6 +50,8 @@ glibtop_get_sysdeps__r (glibtop *server, glibtop_sysdeps *buf) memset (buf, 0, sizeof (glibtop_sysdeps)); + buf->features = glibtop_server_features; + /* Call all system dependent functions to check which values * they return. */ From eb69a5547f10a32186e80f4e695a8d6e6c21156c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 16:26:07 +0000 Subject: [PATCH 0078/2539] *** empty log message *** --- ChangeLog | 17 +++++++++++++++++ po/.cvsignore | 1 + src/Makefile.am | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 45b7148c..6f3ad42c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +1998-06-02 Martin Baulig + + * 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 * NEWS: added more detailed description of today's and diff --git a/po/.cvsignore b/po/.cvsignore index fdccedaf..1d2726a8 100644 --- a/po/.cvsignore +++ b/po/.cvsignore @@ -2,4 +2,5 @@ Makefile Makefile.in POTFILES cat-id-tbl.c +fr.gmo libgtop.pot diff --git a/src/Makefile.am b/src/Makefile.am index b0e22324..25087860 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = server +SUBDIRS = server proxy From b96843a960dfb8528cff59baa7ee94bc47accb3d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 19:40:53 +0000 Subject: [PATCH 0079/2539] renamed to `glibtop_open__l'. * lib/open.c (glibtop_open): renamed to `glibtop_open__l'. --- lib/init.c | 4 ++-- lib/open.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/init.c b/lib/init.c index a3cb49ef..1fbc9952 100644 --- a/lib/init.c +++ b/lib/init.c @@ -34,8 +34,8 @@ glibtop_init__r (glibtop **server, const unsigned long features, if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; - glibtop_open (glibtop_global_server, "glibtop", - features, flags); + glibtop_open__l (glibtop_global_server, "glibtop", + features, flags); } return *server = glibtop_global_server; diff --git a/lib/open.c b/lib/open.c index 0bc6f9fd..5dca3717 100644 --- a/lib/open.c +++ b/lib/open.c @@ -28,8 +28,8 @@ /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) +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; From f233a1673fd7f3e25eb81cb0f40d235a8cd5422c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 19:41:29 +0000 Subject: [PATCH 0080/2539] renamed to `glibtop_open__r'. * sysdeps/linux/open.c (glibtop_open): renamed to `glibtop_open__r'. --- sysdeps/linux/init.c | 4 ++-- sysdeps/linux/open.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdeps/linux/init.c b/sysdeps/linux/init.c index a3cb49ef..e39cfd29 100644 --- a/sysdeps/linux/init.c +++ b/sysdeps/linux/init.c @@ -34,8 +34,8 @@ glibtop_init__r (glibtop **server, const unsigned long features, if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; - glibtop_open (glibtop_global_server, "glibtop", - features, flags); + glibtop_open__r (glibtop_global_server, "glibtop", + features, flags); } return *server = glibtop_global_server; diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index 5645683a..2c89a579 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -51,8 +51,8 @@ static void set_linux_version(void) { /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) +glibtop_open__r (glibtop *server, const char *program_name, + const unsigned long features, const unsigned flags) { memset (server, 0, sizeof (glibtop)); server->name = program_name; From e71eb0e75b0a3d0a6f0d76526758ba5023b213f4 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 19:42:53 +0000 Subject: [PATCH 0081/2539] *** empty log message *** --- ChangeLog | 5 +++++ include/glibtop/open.h | 4 +++- src/proxy/main.c | 2 +- src/server/main.c | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f3ad42c..eb830d8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 1998-06-02 Martin Baulig + * 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. diff --git a/include/glibtop/open.h b/include/glibtop/open.h index 83674a55..629c18e8 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -28,7 +28,9 @@ __BEGIN_DECLS #define GLIBTOP_OPEN_NO_OVERRIDE 1 -extern void glibtop_open __P((glibtop *, const char *, const unsigned long, const unsigned)); +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 diff --git a/src/proxy/main.c b/src/proxy/main.c index 3671b962..1eda5386 100644 --- a/src/proxy/main.c +++ b/src/proxy/main.c @@ -54,7 +54,7 @@ main(int argc, char *argv[]) glibtop_version (); - glibtop_open (&server, argv [0], 0, GLIBTOP_OPEN_NO_OVERRIDE); + 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(); diff --git a/src/server/main.c b/src/server/main.c index fd47da50..7dfc0c67 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) setreuid (uid, euid); setregid (gid, egid); - glibtop_open (&server, argv [0], 0, 0); + glibtop_open__r (&server, argv [0], 0, 0); if (setreuid (euid, uid)) _exit (1); From 3728e4c34e119370290977bd3c4dfd96524515cb Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 22:23:45 +0000 Subject: [PATCH 0082/2539] 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). --- sysdeps/sun4/cpu.c | 14 +++++++++----- sysdeps/sun4/init.c | 6 ++++-- sysdeps/sun4/loadavg.c | 4 +++- sysdeps/sun4/mem.c | 4 +++- sysdeps/sun4/msg_limits.c | 4 +++- sysdeps/sun4/open.c | 3 ++- sysdeps/sun4/procdata.c | 2 +- sysdeps/sun4/prockernel.c | 4 +++- sysdeps/sun4/proclist.c | 4 +++- sysdeps/sun4/procmem.c | 4 +++- sysdeps/sun4/procsegment.c | 4 +++- sysdeps/sun4/procsignal.c | 6 ++++-- sysdeps/sun4/procstate.c | 4 +++- sysdeps/sun4/proctime.c | 6 ++++-- sysdeps/sun4/procuid.c | 6 ++++-- sysdeps/sun4/sem_limits.c | 4 +++- sysdeps/sun4/shm_limits.c | 4 +++- sysdeps/sun4/swap.c | 4 +++- sysdeps/sun4/uptime.c | 4 +++- 19 files changed, 64 insertions(+), 27 deletions(-) diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c index e5efea4d..6ca965ae 100644 --- a/sysdeps/sun4/cpu.c +++ b/sysdeps/sun4/cpu.c @@ -30,11 +30,13 @@ static const unsigned long _glibtop_sysdeps_cpu = /* Provides information about cpu usage. */ void -glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu__p (glibtop *server, glibtop_cpu *buf) { long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES]; int i; + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_cpu)); /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ @@ -43,15 +45,17 @@ glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) /* get the cp_time array */ - (void) _glibtop_getkval (server, _glibtop_nlist [X_CP_TIME].n_value, (int *) cp_time, - sizeof (cp_time), _glibtop_nlist [X_CP_TIME].n_name); + (void) _glibtop_getkval (server, _glibtop_nlist [X_CP_TIME].n_value, + (int *) cp_time, sizeof (cp_time), + _glibtop_nlist [X_CP_TIME].n_name); #ifdef MULTIPROCESSOR /* get the mp_time array as well */ if (server->machine.ncpu > 1) { - (void) _glibtop_getkval (server, _glibtop_nlist [X_MP_TIME].n_value, (int *) mp_time, - sizeof (mp_time), _glibtop_nlist [X_MP_TIME].n_name); + (void) _glibtop_getkval (server, _glibtop_nlist [X_MP_TIME].n_value, + (int *) mp_time, sizeof (mp_time), + _glibtop_nlist [X_MP_TIME].n_name); } #endif diff --git a/sysdeps/sun4/init.c b/sysdeps/sun4/init.c index f6a9a506..e39cfd29 100644 --- a/sysdeps/sun4/init.c +++ b/sysdeps/sun4/init.c @@ -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__r (glibtop_global_server, "glibtop", + features, flags); } return *server = glibtop_global_server; diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c index de6605e0..07d4c0e9 100644 --- a/sysdeps/sun4/loadavg.c +++ b/sysdeps/sun4/loadavg.c @@ -25,7 +25,9 @@ /* Provides load averange. */ void -glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg__p (glibtop *server, glibtop_loadavg *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_loadavg)); } diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c index d6a67788..ab602e70 100644 --- a/sysdeps/sun4/mem.c +++ b/sysdeps/sun4/mem.c @@ -33,8 +33,10 @@ static const unsigned long _glibtop_sysdeps_mem = /* Provides information about memory usage. */ void -glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +glibtop_get_mem__p (glibtop *server, glibtop_mem *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_mem)); /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c index 62819042..eca74df9 100644 --- a/sysdeps/sun4/msg_limits.c +++ b/sysdeps/sun4/msg_limits.c @@ -24,7 +24,9 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits__p (glibtop *server, glibtop_msg_limits *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_msg_limits)); } diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index 1944cdf7..0193c00f 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -57,7 +57,8 @@ struct nlist _glibtop_nlist[] = { /* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ void -glibtop_open (glibtop *server, const char *program_name) +glibtop_open__r (glibtop *server, const char *program_name, + const unsigned long features, const unsigned flags) { register int pagesize; diff --git a/sysdeps/sun4/procdata.c b/sysdeps/sun4/procdata.c index b542721d..fa32152e 100644 --- a/sysdeps/sun4/procdata.c +++ b/sysdeps/sun4/procdata.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_procdata__r (glibtop *server, glibtop_procdata *buf, pid_t pid) +glibtop_get_procdata__p (glibtop *server, glibtop_procdata *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_procdata)); } diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c index 93f47bb1..ab13bb95 100644 --- a/sysdeps/sun4/prockernel.c +++ b/sysdeps/sun4/prockernel.c @@ -25,8 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel__p (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proc_kernel)); } diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c index f3e0b993..66778f57 100644 --- a/sysdeps/sun4/proclist.c +++ b/sysdeps/sun4/proclist.c @@ -32,8 +32,10 @@ * each buf->size big. The total size is stored in buf->total. */ unsigned * -glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist__p (glibtop *server, glibtop_proclist *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proclist)); return NULL; } diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c index 889a4a20..1e018270 100644 --- a/sysdeps/sun4/procmem.c +++ b/sysdeps/sun4/procmem.c @@ -25,8 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem__p (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proc_mem)); } diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c index c0ffeb17..5793d386 100644 --- a/sysdeps/sun4/procsegment.c +++ b/sysdeps/sun4/procsegment.c @@ -25,8 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment__p (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proc_segment)); } diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c index 6c30ee66..a3e905ae 100644 --- a/sysdeps/sun4/procsignal.c +++ b/sysdeps/sun4/procsignal.c @@ -25,8 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) +glibtop_get_proc_signal__p (glibtop *server, glibtop_proc_signal *buf, + pid_t pid) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proc_signal)); } diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c index b8ad5cec..a0ffb312 100644 --- a/sysdeps/sun4/procstate.c +++ b/sysdeps/sun4/procstate.c @@ -25,8 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state__p (glibtop *server, glibtop_proc_state *buf, pid_t pid) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proc_state)); } diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c index ec81d2a0..8bd4f728 100644 --- a/sysdeps/sun4/proctime.c +++ b/sysdeps/sun4/proctime.c @@ -25,8 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, - pid_t pid) +glibtop_get_proc_time__p (glibtop *server, glibtop_proc_time *buf, + pid_t pid) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proc_time)); } diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c index 7fbb85fa..a4c15f8f 100644 --- a/sysdeps/sun4/procuid.c +++ b/sysdeps/sun4/procuid.c @@ -25,8 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) +glibtop_get_proc_uid__p (glibtop *server, glibtop_proc_uid *buf, + pid_t pid) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_proc_uid)); } diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c index 3768408b..ef4df709 100644 --- a/sysdeps/sun4/sem_limits.c +++ b/sysdeps/sun4/sem_limits.c @@ -24,7 +24,9 @@ /* Provides information about sysv sem limits. */ void -glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits__p (glibtop *server, glibtop_sem_limits *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_sem_limits)); } diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c index 52e801ba..b51528b1 100644 --- a/sysdeps/sun4/shm_limits.c +++ b/sysdeps/sun4/shm_limits.c @@ -24,7 +24,9 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits__p (glibtop *server, glibtop_shm_limits *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_shm_limits)); } diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c index 8e0d046b..c1c3f2a8 100644 --- a/sysdeps/sun4/swap.c +++ b/sysdeps/sun4/swap.c @@ -25,7 +25,9 @@ /* Provides information about swap usage. */ void -glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +glibtop_get_swap__p (glibtop *server, glibtop_swap *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_swap)); } diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c index 5b9ea63f..58b87a8e 100644 --- a/sysdeps/sun4/uptime.c +++ b/sysdeps/sun4/uptime.c @@ -25,7 +25,9 @@ /* Provides uptime and idle time. */ void -glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime__p (glibtop *server, glibtop_uptime *buf) { + glibtop_init__r (&server, 0, 0); + memset (buf, 0, sizeof (glibtop_uptime)); } From 4aeb33b2b9c2e88539deec04c31c145150781c4b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 2 Jun 1998 22:48:32 +0000 Subject: [PATCH 0083/2539] Removed this file. * examples/third.scm: Removed this file. --- examples/third.scm | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 examples/third.scm diff --git a/examples/third.scm b/examples/third.scm deleted file mode 100644 index 2de3e006..00000000 --- a/examples/third.scm +++ /dev/null @@ -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) From 44f28a486b1f31284332dec90efbbd52cf466013 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 3 Jun 1998 04:30:15 +0000 Subject: [PATCH 0084/2539] #include 1998-06-02 Federico Mena Quintero * src/server/main.c: #include --- ChangeLog | 4 ++++ src/server/main.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index eb830d8f..149263dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +1998-06-02 Federico Mena Quintero + + * src/server/main.c: #include + 1998-06-02 Martin Baulig * lib/open.c (glibtop_open): renamed to `glibtop_open__l'. diff --git a/src/server/main.c b/src/server/main.c index 7dfc0c67..f9afd7c7 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -26,6 +26,7 @@ #include #include +#include #if defined(HAVE_GETDTABLESIZE) #define GET_MAX_FDS() getdtablesize() From 402c96e473ec4ef79898a91e70e7107d31e53272 Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Wed, 3 Jun 1998 04:33:37 +0000 Subject: [PATCH 0085/2539] #include for several files - Federico --- examples/first.c | 2 ++ examples/second.c | 2 ++ examples/third.c | 2 ++ src/proxy/main.c | 1 + 4 files changed, 7 insertions(+) diff --git a/examples/first.c b/examples/first.c index c4f32e6e..0f31308c 100644 --- a/examples/first.c +++ b/examples/first.c @@ -19,6 +19,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include #include #include diff --git a/examples/second.c b/examples/second.c index 9dbb73ce..423111ab 100644 --- a/examples/second.c +++ b/examples/second.c @@ -19,6 +19,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include #include #include diff --git a/examples/third.c b/examples/third.c index 9d1ce168..261ba8c3 100644 --- a/examples/third.c +++ b/examples/third.c @@ -19,6 +19,8 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include #include diff --git a/src/proxy/main.c b/src/proxy/main.c index 1eda5386..361d924b 100644 --- a/src/proxy/main.c +++ b/src/proxy/main.c @@ -26,6 +26,7 @@ #include #include +#include #if defined(HAVE_GETDTABLESIZE) #define GET_MAX_FDS() getdtablesize() From fbb3070abe54cb5882b6ffc2e041681227bd8e4e Mon Sep 17 00:00:00 2001 From: rhlabs Date: Thu, 4 Jun 1998 19:34:17 +0000 Subject: [PATCH 0086/2539] This file mysteriously disappeared from CVS, I'm putting it back. Dr Mike --- libgtop.spec | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 libgtop.spec diff --git a/libgtop.spec b/libgtop.spec new file mode 100644 index 00000000..e49638dd --- /dev/null +++ b/libgtop.spec @@ -0,0 +1,74 @@ +# 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 +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 + +- 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 + +%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 +%docdir doc +%{prefix}/bin/* +%{prefix}/lib/lib*.so.* +%{prefix}/share/* +%{prefix}/lib/libgtop/* +%{prefix}/lib/libgtopConf.sh +%{prefix}/lib/*a +%{prefix}/include/* From 0727d0911c28a6e83a2a74a3a2a68f0348b29dd7 Mon Sep 17 00:00:00 2001 From: rhlabs Date: Thu, 4 Jun 1998 20:13:51 +0000 Subject: [PATCH 0087/2539] Fixed file list Dr Mike --- libgtop.spec | 1 - 1 file changed, 1 deletion(-) diff --git a/libgtop.spec b/libgtop.spec index e49638dd..53f8abcb 100644 --- a/libgtop.spec +++ b/libgtop.spec @@ -67,7 +67,6 @@ make prefix=$RPM_BUILD_ROOT%{prefix} install %docdir doc %{prefix}/bin/* %{prefix}/lib/lib*.so.* -%{prefix}/share/* %{prefix}/lib/libgtop/* %{prefix}/lib/libgtopConf.sh %{prefix}/lib/*a From fb61de47a06b744102726868901458b356bfe7ca Mon Sep 17 00:00:00 2001 From: rhlabs Date: Thu, 4 Jun 1998 20:20:00 +0000 Subject: [PATCH 0088/2539] More file list fun Dr Mike --- libgtop.spec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libgtop.spec b/libgtop.spec index 53f8abcb..e3ec3abf 100644 --- a/libgtop.spec +++ b/libgtop.spec @@ -63,8 +63,7 @@ make prefix=$RPM_BUILD_ROOT%{prefix} install %files %defattr(-, root, root) -%doc ANNOUNCE AUTHORS ChangeLog NEWS README README.LATEST copyright.txt -%docdir doc +%doc ANNOUNCE AUTHORS ChangeLog NEWS README README.LATEST copyright.txt doc %{prefix}/bin/* %{prefix}/lib/lib*.so.* %{prefix}/lib/libgtop/* From d3f9cb80d7227eca4c9302d0e02ae7744bdb02fd Mon Sep 17 00:00:00 2001 From: rhlabs Date: Thu, 4 Jun 1998 20:55:18 +0000 Subject: [PATCH 0089/2539] 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 --- libgtop.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libgtop.spec b/libgtop.spec index e3ec3abf..ad9bc4c1 100644 --- a/libgtop.spec +++ b/libgtop.spec @@ -53,6 +53,16 @@ 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 @@ -66,7 +76,6 @@ make prefix=$RPM_BUILD_ROOT%{prefix} install %doc ANNOUNCE AUTHORS ChangeLog NEWS README README.LATEST copyright.txt doc %{prefix}/bin/* %{prefix}/lib/lib*.so.* -%{prefix}/lib/libgtop/* %{prefix}/lib/libgtopConf.sh %{prefix}/lib/*a %{prefix}/include/* From de5cf356c91d0a64e716670b38efcef7f442d05d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 6 Jun 1998 18:19:16 +0000 Subject: [PATCH 0090/2539] Added `#include '. 1998-06-06 Martin Baulig * glibtop.h: Added `#include '. * include/glibtop/types.h: New file - numeric constants for `glibtop_types_'. * sysdeps/names/*.c (glibtop_types_*): Using numeric constants from `types.h' instead of string constants. --- glibtop.h | 1 + include/glibtop/types.h | 36 ++++++++++++++++++++++++++++++++++++ sysdeps/names/cpu.c | 4 ++-- sysdeps/names/loadavg.c | 2 +- sysdeps/names/mem.c | 6 +++--- sysdeps/names/msg_limits.c | 5 +++-- sysdeps/names/prockernel.c | 5 +++-- sysdeps/names/proclist.c | 2 +- sysdeps/names/procmem.c | 3 ++- sysdeps/names/procsegment.c | 5 +++-- sysdeps/names/procsignal.c | 3 ++- sysdeps/names/procstate.c | 3 ++- sysdeps/names/proctime.c | 4 +++- sysdeps/names/procuid.c | 6 ++++-- sysdeps/names/sem_limits.c | 7 ++++--- sysdeps/names/shm_limits.c | 4 ++-- sysdeps/names/swap.c | 2 +- sysdeps/names/uptime.c | 2 +- 18 files changed, 74 insertions(+), 26 deletions(-) create mode 100644 include/glibtop/types.h diff --git a/glibtop.h b/glibtop.h index 2d4756f0..adfd95d6 100644 --- a/glibtop.h +++ b/glibtop.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef HAVE_GLIBTOP_MACHINE_H #include diff --git a/include/glibtop/types.h b/include/glibtop/types.h new file mode 100644 index 00000000..b622426f --- /dev/null +++ b/include/glibtop/types.h @@ -0,0 +1,36 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_TYPES_H__ +#define __GLIBTOP_TYPES_H__ + +__BEGIN_DECLS + +#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 diff --git a/sysdeps/names/cpu.c b/sysdeps/names/cpu.c index e33c9f95..8bf80d8d 100644 --- a/sysdeps/names/cpu.c +++ b/sysdeps/names/cpu.c @@ -28,8 +28,8 @@ const char *glibtop_names_cpu [GLIBTOP_MAX_CPU] = const char *glibtop_types_cpu [GLIBTOP_MAX_CPU] = { - "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_cpu [GLIBTOP_MAX_CPU] = diff --git a/sysdeps/names/loadavg.c b/sysdeps/names/loadavg.c index 4e41e621..351f3675 100644 --- a/sysdeps/names/loadavg.c +++ b/sysdeps/names/loadavg.c @@ -28,7 +28,7 @@ const char *glibtop_names_loadavg [GLIBTOP_MAX_LOADAVG] = const char *glibtop_types_loadavg [GLIBTOP_MAX_LOADAVG] = { - "double" + GLIBTOP_TYPE_DOUBLE }; const char *glibtop_labels_loadavg [GLIBTOP_MAX_LOADAVG] = diff --git a/sysdeps/names/mem.c b/sysdeps/names/mem.c index 4914b04d..534274ca 100644 --- a/sysdeps/names/mem.c +++ b/sysdeps/names/mem.c @@ -29,9 +29,9 @@ const char *glibtop_names_mem [GLIBTOP_MAX_MEM] = const char *glibtop_types_mem [GLIBTOP_MAX_MEM] = { - "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_mem [GLIBTOP_MAX_MEM] = diff --git a/sysdeps/names/msg_limits.c b/sysdeps/names/msg_limits.c index 46dbf7e8..a2a9ee1f 100644 --- a/sysdeps/names/msg_limits.c +++ b/sysdeps/names/msg_limits.c @@ -28,8 +28,9 @@ const char *glibtop_names_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = const char *glibtop_types_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = { - "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = diff --git a/sysdeps/names/prockernel.c b/sysdeps/names/prockernel.c index 20f4a87b..a9442100 100644 --- a/sysdeps/names/prockernel.c +++ b/sysdeps/names/prockernel.c @@ -30,8 +30,9 @@ const char *glibtop_names_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = const char *glibtop_types_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = { - "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = diff --git a/sysdeps/names/proclist.c b/sysdeps/names/proclist.c index d5bf022d..b1c8a360 100644 --- a/sysdeps/names/proclist.c +++ b/sysdeps/names/proclist.c @@ -28,7 +28,7 @@ const char *glibtop_names_proclist [GLIBTOP_MAX_PROCLIST] = const char *glibtop_types_proclist [GLIBTOP_MAX_PROCLIST] = { - "unsigned long", "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_proclist [GLIBTOP_MAX_PROCLIST] = diff --git a/sysdeps/names/procmem.c b/sysdeps/names/procmem.c index 920f1a8b..eeb5f46f 100644 --- a/sysdeps/names/procmem.c +++ b/sysdeps/names/procmem.c @@ -36,7 +36,8 @@ const char *glibtop_names_proc_mem [GLIBTOP_MAX_PROC_MEM] = const char *glibtop_types_proc_mem [GLIBTOP_MAX_PROC_MEM] = { - "long", "long", "long", "long", "long", "long" + GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, + GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG }; const char *glibtop_labels_proc_mem [GLIBTOP_MAX_PROC_MEM] = diff --git a/sysdeps/names/procsegment.c b/sysdeps/names/procsegment.c index 85a89304..fd81b9e3 100644 --- a/sysdeps/names/procsegment.c +++ b/sysdeps/names/procsegment.c @@ -29,8 +29,9 @@ const char *glibtop_names_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = const char *glibtop_types_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = { - "long", "long", "long", "long", "unsigned long", - "unsigned long", "unsigned long" + GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, + GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = diff --git a/sysdeps/names/procsignal.c b/sysdeps/names/procsignal.c index a278e60b..fe915a51 100644 --- a/sysdeps/names/procsignal.c +++ b/sysdeps/names/procsignal.c @@ -29,7 +29,8 @@ const char *glibtop_names_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = const char *glibtop_types_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = { - "int", "int", "int", "int" + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, + GLIBTOP_TYPE_INT }; const char *glibtop_labels_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = diff --git a/sysdeps/names/procstate.c b/sysdeps/names/procstate.c index bdd85499..d2a4511d 100644 --- a/sysdeps/names/procstate.c +++ b/sysdeps/names/procstate.c @@ -29,7 +29,8 @@ const char *glibtop_names_proc_state [GLIBTOP_MAX_PROC_STATE] = const char *glibtop_types_proc_state [GLIBTOP_MAX_PROC_STATE] = { - "char *", "char", "int", "int" + GLIBTOP_TYPE_STRING, GLIBTOP_TYPE_CHAR, + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT }; const char *glibtop_labels_proc_state [GLIBTOP_MAX_PROC_STATE] = diff --git a/sysdeps/names/proctime.c b/sysdeps/names/proctime.c index f7990b50..1010d6d7 100644 --- a/sysdeps/names/proctime.c +++ b/sysdeps/names/proctime.c @@ -38,7 +38,9 @@ const char *glibtop_names_proc_time [GLIBTOP_MAX_PROC_TIME] = const char *glibtop_types_proc_time [GLIBTOP_MAX_PROC_TIME] = { - "long", "long", "long", "long", "long", "long", "long" + GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, + GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, + GLIBTOP_TYPE_LONG }; const char *glibtop_labels_proc_time [GLIBTOP_MAX_PROC_TIME] = diff --git a/sysdeps/names/procuid.c b/sysdeps/names/procuid.c index 8d50f8bc..6f27d57f 100644 --- a/sysdeps/names/procuid.c +++ b/sysdeps/names/procuid.c @@ -43,8 +43,10 @@ const char *glibtop_names_proc_uid [GLIBTOP_MAX_PROC_UID] = const char *glibtop_types_proc_uid [GLIBTOP_MAX_PROC_UID] = { - "int", "int", "int", "int", "int", "int", "int", - "int", "int", "int", "int", "int" + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, + GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT }; const char *glibtop_labels_proc_uid [GLIBTOP_MAX_PROC_UID] = diff --git a/sysdeps/names/sem_limits.c b/sysdeps/names/sem_limits.c index a75d9192..86650fa4 100644 --- a/sysdeps/names/sem_limits.c +++ b/sysdeps/names/sem_limits.c @@ -29,9 +29,10 @@ const char *glibtop_names_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = const char *glibtop_types_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = { - "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = diff --git a/sysdeps/names/shm_limits.c b/sysdeps/names/shm_limits.c index 6786d2dc..1d0ce27d 100644 --- a/sysdeps/names/shm_limits.c +++ b/sysdeps/names/shm_limits.c @@ -28,8 +28,8 @@ const char *glibtop_names_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = const char *glibtop_types_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = { - "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = diff --git a/sysdeps/names/swap.c b/sysdeps/names/swap.c index 06c51513..2b617f70 100644 --- a/sysdeps/names/swap.c +++ b/sysdeps/names/swap.c @@ -28,7 +28,7 @@ const char *glibtop_names_swap [GLIBTOP_MAX_SWAP] = const char *glibtop_types_swap [GLIBTOP_MAX_SWAP] = { - "unsigned long", "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_swap [GLIBTOP_MAX_SWAP] = diff --git a/sysdeps/names/uptime.c b/sysdeps/names/uptime.c index 6561c006..8271d729 100644 --- a/sysdeps/names/uptime.c +++ b/sysdeps/names/uptime.c @@ -28,7 +28,7 @@ const char *glibtop_names_uptime [GLIBTOP_MAX_UPTIME] = const char *glibtop_types_uptime [GLIBTOP_MAX_UPTIME] = { - "double", "double" + GLIBTOP_TYPE_DOUBLE, GLIBTOP_TYPE_DOUBLE }; const char *glibtop_labels_uptime [GLIBTOP_MAX_UPTIME] = From f92d7f9ee7ec45dd6d26930c7898e22a437f4fd0 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 6 Jun 1998 18:41:08 +0000 Subject: [PATCH 0091/2539] Changed declaration. 1998-06-06 Martin Baulig * include/glibtop/*.h (glibtop_types_*): Changed declaration. --- include/glibtop/cpu.h | 2 +- include/glibtop/mem.h | 2 +- include/glibtop/msg_limits.h | 2 +- include/glibtop/prockernel.h | 2 +- include/glibtop/proclist.h | 2 +- include/glibtop/procmem.h | 2 +- include/glibtop/procsegment.h | 2 +- include/glibtop/procsignal.h | 2 +- include/glibtop/procstate.h | 2 +- include/glibtop/proctime.h | 2 +- include/glibtop/procuid.h | 2 +- include/glibtop/sem_limits.h | 2 +- include/glibtop/shm_limits.h | 2 +- include/glibtop/swap.h | 2 +- include/glibtop/uptime.h | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h index 323fbbaf..cf164833 100644 --- a/include/glibtop/cpu.h +++ b/include/glibtop/cpu.h @@ -89,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 []; diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h index b36b626a..9f90bb27 100644 --- a/include/glibtop/mem.h +++ b/include/glibtop/mem.h @@ -93,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 []; diff --git a/include/glibtop/msg_limits.h b/include/glibtop/msg_limits.h index 648f0905..6199265e 100644 --- a/include/glibtop/msg_limits.h +++ b/include/glibtop/msg_limits.h @@ -91,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 []; diff --git a/include/glibtop/prockernel.h b/include/glibtop/prockernel.h index 3f035c31..dbec0f0c 100644 --- a/include/glibtop/prockernel.h +++ b/include/glibtop/prockernel.h @@ -99,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 []; diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h index 4d3dba24..24026b6d 100644 --- a/include/glibtop/proclist.h +++ b/include/glibtop/proclist.h @@ -83,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 []; diff --git a/include/glibtop/procmem.h b/include/glibtop/procmem.h index f8ae77b7..9d787966 100644 --- a/include/glibtop/procmem.h +++ b/include/glibtop/procmem.h @@ -93,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 []; diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h index 574b60b3..76e419c7 100644 --- a/include/glibtop/procsegment.h +++ b/include/glibtop/procsegment.h @@ -93,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 []; diff --git a/include/glibtop/procsignal.h b/include/glibtop/procsignal.h index c7257c9a..f09b6047 100644 --- a/include/glibtop/procsignal.h +++ b/include/glibtop/procsignal.h @@ -87,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 []; diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h index 7217b6b2..d62c64e4 100644 --- a/include/glibtop/procstate.h +++ b/include/glibtop/procstate.h @@ -94,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 []; diff --git a/include/glibtop/proctime.h b/include/glibtop/proctime.h index 245afc6e..9bbe6597 100644 --- a/include/glibtop/proctime.h +++ b/include/glibtop/proctime.h @@ -99,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 []; diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h index 40de660e..12cbe5d7 100644 --- a/include/glibtop/procuid.h +++ b/include/glibtop/procuid.h @@ -103,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 []; diff --git a/include/glibtop/sem_limits.h b/include/glibtop/sem_limits.h index 8a591a68..50118802 100644 --- a/include/glibtop/sem_limits.h +++ b/include/glibtop/sem_limits.h @@ -97,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 []; diff --git a/include/glibtop/shm_limits.h b/include/glibtop/shm_limits.h index 8d996e27..df270868 100644 --- a/include/glibtop/shm_limits.h +++ b/include/glibtop/shm_limits.h @@ -87,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 []; diff --git a/include/glibtop/swap.h b/include/glibtop/swap.h index 4ee5564d..396f940a 100644 --- a/include/glibtop/swap.h +++ b/include/glibtop/swap.h @@ -83,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 []; diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h index aa3be951..99fe9290 100644 --- a/include/glibtop/uptime.h +++ b/include/glibtop/uptime.h @@ -81,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 []; From 222df2c7d6d99fbdda04ac52f2ef00a3d8c77b80 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 6 Jun 1998 18:42:14 +0000 Subject: [PATCH 0092/2539] Removed that file. 1998-06-06 Martin Baulig * sysdeps/names/procdata.c: Removed that file. * sysdeps/names/*.c: Fixed declaration of `glibtop_types_*'. --- sysdeps/names/cpu.c | 2 +- sysdeps/names/mem.c | 2 +- sysdeps/names/msg_limits.c | 2 +- sysdeps/names/procdata.c | 53 ------------------------------------- sysdeps/names/prockernel.c | 2 +- sysdeps/names/proclist.c | 2 +- sysdeps/names/procmem.c | 2 +- sysdeps/names/procsegment.c | 2 +- sysdeps/names/procsignal.c | 2 +- sysdeps/names/procstate.c | 2 +- sysdeps/names/proctime.c | 2 +- sysdeps/names/procuid.c | 2 +- sysdeps/names/sem_limits.c | 2 +- sysdeps/names/shm_limits.c | 2 +- sysdeps/names/swap.c | 2 +- sysdeps/names/uptime.c | 2 +- 16 files changed, 15 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/names/procdata.c diff --git a/sysdeps/names/cpu.c b/sysdeps/names/cpu.c index 8bf80d8d..385c8e59 100644 --- a/sysdeps/names/cpu.c +++ b/sysdeps/names/cpu.c @@ -26,7 +26,7 @@ const char *glibtop_names_cpu [GLIBTOP_MAX_CPU] = "total", "user", "nice", "sys", "idle", "frequency" }; -const char *glibtop_types_cpu [GLIBTOP_MAX_CPU] = +const unsigned glibtop_types_cpu [GLIBTOP_MAX_CPU] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG diff --git a/sysdeps/names/mem.c b/sysdeps/names/mem.c index 534274ca..cf912683 100644 --- a/sysdeps/names/mem.c +++ b/sysdeps/names/mem.c @@ -27,7 +27,7 @@ const char *glibtop_names_mem [GLIBTOP_MAX_MEM] = "cached", "user", "locked" }; -const char *glibtop_types_mem [GLIBTOP_MAX_MEM] = +const unsigned glibtop_types_mem [GLIBTOP_MAX_MEM] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, diff --git a/sysdeps/names/msg_limits.c b/sysdeps/names/msg_limits.c index a2a9ee1f..512bbd48 100644 --- a/sysdeps/names/msg_limits.c +++ b/sysdeps/names/msg_limits.c @@ -26,7 +26,7 @@ const char *glibtop_names_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = "msgpool", "msgmap", "msgmax", "msgmnb", "msgmni", "msgssz", "msgtql" }; -const char *glibtop_types_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = +const unsigned glibtop_types_msg_limits [GLIBTOP_MAX_MSG_LIMITS] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, diff --git a/sysdeps/names/procdata.c b/sysdeps/names/procdata.c deleted file mode 100644 index 1729860c..00000000 --- a/sysdeps/names/procdata.c +++ /dev/null @@ -1,53 +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 , 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 - -const char *glibtop_names_procdata [GLIBTOP_MAX_PROCDATA] = -{ "cmd", "state", "uid", "pid", "ppid", "pgrp", "session", - "tty", "tpgid", "priority", "nice", "signal", "blocked", - "sigignore", "sigcatch", "start_time", "utime", "stime", - "cutime", "cstime", "size", "resident", "share", "trs", - "lrs", "drs", "dt", "vsize", "rss", "rss_rlim", "timeout", - "it_real_value", "k_flags", "min_flt", "maj_flt", "cmin_flt", - "cmaj_flt", "start_code", "end_code", "start_stack", - "kstk_esp", "kstk_eip", "wchan" -}; - -const char *glibtop_labels_procdata [GLIBTOP_MAX_PROCDATA] = -{ N_("Cmd"), N_("Stat"), N_("UID"), N_("PID"), N_("PPID"), N_("PGRP"), - N_("Session"), N_("Tty"), N_("TPGID"), N_("Priority"), N_("Nice"), - N_("Signal"), N_("Blocked"), N_("SigIgnore"), N_("SigCatch"), - N_("Start_Time"), N_("UTime"), N_("STime"), N_("CUTime"), N_("CSTime"), - N_("Size"), N_("Resident"), N_("Share"), N_("TRS"), N_("LRS"), N_("DRS"), - N_("DT"), N_("VSize"), N_("RSS"), N_("RSS_RLim"), N_("Timeout"), - N_("It_Real_Value"), N_("Flags"), N_("Min_Flt"), N_("Maj_Flt"), - N_("CMin_Flt"), N_("Cmaj_Flt"), N_("Start_Code"), N_("End_Code"), - N_("Start_Stack"), N_("KSTK_ESP"), N_("KSTK_EIP"), N_("WChan") -}; - -const char *glibtop_descriptions_procdata [GLIBTOP_MAX_PROCDATA] = -{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL -}; diff --git a/sysdeps/names/prockernel.c b/sysdeps/names/prockernel.c index a9442100..e49f9b83 100644 --- a/sysdeps/names/prockernel.c +++ b/sysdeps/names/prockernel.c @@ -28,7 +28,7 @@ const char *glibtop_names_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = "kstk_esp", "kstk_eip", "wchan" }; -const char *glibtop_types_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = +const unsigned glibtop_types_proc_kernel [GLIBTOP_MAX_PROC_KERNEL] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, diff --git a/sysdeps/names/proclist.c b/sysdeps/names/proclist.c index b1c8a360..8358d13e 100644 --- a/sysdeps/names/proclist.c +++ b/sysdeps/names/proclist.c @@ -26,7 +26,7 @@ const char *glibtop_names_proclist [GLIBTOP_MAX_PROCLIST] = "number", "total", "size" }; -const char *glibtop_types_proclist [GLIBTOP_MAX_PROCLIST] = +const unsigned glibtop_types_proclist [GLIBTOP_MAX_PROCLIST] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; diff --git a/sysdeps/names/procmem.c b/sysdeps/names/procmem.c index eeb5f46f..41385465 100644 --- a/sysdeps/names/procmem.c +++ b/sysdeps/names/procmem.c @@ -34,7 +34,7 @@ const char *glibtop_names_proc_mem [GLIBTOP_MAX_PROC_MEM] = "size", "vsize", "resident", "share", "rss", "rss_rlim" }; -const char *glibtop_types_proc_mem [GLIBTOP_MAX_PROC_MEM] = +const unsigned glibtop_types_proc_mem [GLIBTOP_MAX_PROC_MEM] = { GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG diff --git a/sysdeps/names/procsegment.c b/sysdeps/names/procsegment.c index fd81b9e3..c0c84b66 100644 --- a/sysdeps/names/procsegment.c +++ b/sysdeps/names/procsegment.c @@ -27,7 +27,7 @@ const char *glibtop_names_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = "trs", "lrs", "drs", "dt", "start_code", "end_code", "start_stack" }; -const char *glibtop_types_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = +const unsigned glibtop_types_proc_segment [GLIBTOP_MAX_PROC_SEGMENT] = { GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, diff --git a/sysdeps/names/procsignal.c b/sysdeps/names/procsignal.c index fe915a51..9e7a96e0 100644 --- a/sysdeps/names/procsignal.c +++ b/sysdeps/names/procsignal.c @@ -27,7 +27,7 @@ const char *glibtop_names_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = "signal", "blocked", "sigignore", "sigcatch" }; -const char *glibtop_types_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = +const unsigned glibtop_types_proc_signal [GLIBTOP_MAX_PROC_SIGNAL] = { GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT diff --git a/sysdeps/names/procstate.c b/sysdeps/names/procstate.c index d2a4511d..81cce3e9 100644 --- a/sysdeps/names/procstate.c +++ b/sysdeps/names/procstate.c @@ -27,7 +27,7 @@ const char *glibtop_names_proc_state [GLIBTOP_MAX_PROC_STATE] = "cmd", "state", "uid", "gid" }; -const char *glibtop_types_proc_state [GLIBTOP_MAX_PROC_STATE] = +const unsigned glibtop_types_proc_state [GLIBTOP_MAX_PROC_STATE] = { GLIBTOP_TYPE_STRING, GLIBTOP_TYPE_CHAR, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT diff --git a/sysdeps/names/proctime.c b/sysdeps/names/proctime.c index 1010d6d7..125d674e 100644 --- a/sysdeps/names/proctime.c +++ b/sysdeps/names/proctime.c @@ -36,7 +36,7 @@ const char *glibtop_names_proc_time [GLIBTOP_MAX_PROC_TIME] = "timeout", "it_real_value" }; -const char *glibtop_types_proc_time [GLIBTOP_MAX_PROC_TIME] = +const unsigned glibtop_types_proc_time [GLIBTOP_MAX_PROC_TIME] = { GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, GLIBTOP_TYPE_LONG, diff --git a/sysdeps/names/procuid.c b/sysdeps/names/procuid.c index 6f27d57f..d457ae56 100644 --- a/sysdeps/names/procuid.c +++ b/sysdeps/names/procuid.c @@ -41,7 +41,7 @@ const char *glibtop_names_proc_uid [GLIBTOP_MAX_PROC_UID] = "session", "tty", "tpgid", "priority", "nice" }; -const char *glibtop_types_proc_uid [GLIBTOP_MAX_PROC_UID] = +const unsigned glibtop_types_proc_uid [GLIBTOP_MAX_PROC_UID] = { GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, GLIBTOP_TYPE_INT, diff --git a/sysdeps/names/sem_limits.c b/sysdeps/names/sem_limits.c index 86650fa4..62923ce0 100644 --- a/sysdeps/names/sem_limits.c +++ b/sysdeps/names/sem_limits.c @@ -27,7 +27,7 @@ const char *glibtop_names_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = "semopm", "semume", "semusz", "semvmx", "semaem" }; -const char *glibtop_types_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = +const unsigned glibtop_types_sem_limits [GLIBTOP_MAX_SEM_LIMITS] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, diff --git a/sysdeps/names/shm_limits.c b/sysdeps/names/shm_limits.c index 1d0ce27d..cbf8e058 100644 --- a/sysdeps/names/shm_limits.c +++ b/sysdeps/names/shm_limits.c @@ -26,7 +26,7 @@ const char *glibtop_names_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = "shmmax", "shmmin", "shmmni", "shmseg", "shmall" }; -const char *glibtop_types_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = +const unsigned glibtop_types_shm_limits [GLIBTOP_MAX_SHM_LIMITS] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG diff --git a/sysdeps/names/swap.c b/sysdeps/names/swap.c index 2b617f70..8e45f803 100644 --- a/sysdeps/names/swap.c +++ b/sysdeps/names/swap.c @@ -26,7 +26,7 @@ const char *glibtop_names_swap [GLIBTOP_MAX_SWAP] = "total", "used", "free" }; -const char *glibtop_types_swap [GLIBTOP_MAX_SWAP] = +const unsigned glibtop_types_swap [GLIBTOP_MAX_SWAP] = { GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; diff --git a/sysdeps/names/uptime.c b/sysdeps/names/uptime.c index 8271d729..7f7c3c91 100644 --- a/sysdeps/names/uptime.c +++ b/sysdeps/names/uptime.c @@ -26,7 +26,7 @@ const char *glibtop_names_uptime [GLIBTOP_MAX_UPTIME] = "uptime", "idletime" }; -const char *glibtop_types_uptime [GLIBTOP_MAX_UPTIME] = +const unsigned glibtop_types_uptime [GLIBTOP_MAX_UPTIME] = { GLIBTOP_TYPE_DOUBLE, GLIBTOP_TYPE_DOUBLE }; From 0a323e50804b1937467c9af851e334bbcec2b91e Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 6 Jun 1998 18:48:17 +0000 Subject: [PATCH 0093/2539] New file. 1998-06-06 Martin Baulig * 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/osf1/cpu.c | 2 +- sysdeps/osf1/glibtop_server.h | 46 +++++++++++++++++++++++++++++++++++ sysdeps/osf1/loadavg.c | 2 +- sysdeps/osf1/mem.c | 2 +- sysdeps/osf1/msg_limits.c | 2 +- sysdeps/osf1/sem_limits.c | 2 +- sysdeps/osf1/shm_limits.c | 2 +- sysdeps/osf1/swap.c | 2 +- sysdeps/osf1/uptime.c | 2 +- 9 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 sysdeps/osf1/glibtop_server.h diff --git a/sysdeps/osf1/cpu.c b/sysdeps/osf1/cpu.c index cf5245d6..0a6af83b 100644 --- a/sysdeps/osf1/cpu.c +++ b/sysdeps/osf1/cpu.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_cpu = /* Provides information about cpu usage. */ void -glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu__s (glibtop *server, glibtop_cpu *buf) { struct tbl_sysinfo sysinfo; int ret; diff --git a/sysdeps/osf1/glibtop_server.h b/sysdeps/osf1/glibtop_server.h new file mode 100644 index 00000000..4b1ee107 --- /dev/null +++ b/sysdeps/osf1/glibtop_server.h @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SERVER_H__ +#define __GLIBTOP_SERVER_H__ + +__BEGIN_DECLS + +#define GLIBTOP_SUID_CPU 0 +#define GLIBTOP_SUID_MEM 0 +#define GLIBTOP_SUID_SWAP 0 +#define GLIBTOP_SUID_UPTIME 0 +#define GLIBTOP_SUID_LOADAVG 0 +#define GLIBTOP_SUID_SHM_LIMITS 0 +#define GLIBTOP_SUID_MSG_LIMITS 0 +#define GLIBTOP_SUID_SEM_LIMITS 0 +#define GLIBTOP_SUID_PROCLIST (GLIBTOP_SYSDEPS_PROCLIST+1) +#define GLIBTOP_SUID_PROC_STATE (GLIBTOP_SYSDEPS_PROC_STATE+1) +#define GLIBTOP_SUID_PROC_UID (GLIBTOP_SYSDEPS_PROC_UID+1) +#define GLIBTOP_SUID_PROC_MEM (GLIBTOP_SYSDEPS_PROC_MEM+1) +#define GLIBTOP_SUID_PROC_TIME (GLIBTOP_SYSDEPS_PROC_TIME+1) +#define GLIBTOP_SUID_PROC_SIGNAL (GLIBTOP_SYSDEPS_PROC_SIGNAL+1) +#define GLIBTOP_SUID_PROC_KERNEL (GLIBTOP_SYSDEPS_PROC_KERNEL+1) +#define GLIBTOP_SUID_PROC_SEGMENT (GLIBTOP_SYSDEPS_PROC_SEGMENT+1) + +__END_DECLS + +#endif diff --git a/sysdeps/osf1/loadavg.c b/sysdeps/osf1/loadavg.c index 4759279c..d80126ba 100644 --- a/sysdeps/osf1/loadavg.c +++ b/sysdeps/osf1/loadavg.c @@ -29,7 +29,7 @@ static const unsigned long _glibtop_sysdeps_loadavg = /* Provides load averange. */ void -glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg__s (glibtop *server, glibtop_loadavg *buf) { struct tbl_loadavg loadavg; int ret; diff --git a/sysdeps/osf1/mem.c b/sysdeps/osf1/mem.c index bd4d6306..f3682802 100644 --- a/sysdeps/osf1/mem.c +++ b/sysdeps/osf1/mem.c @@ -36,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_mem = /* Provides information about memory usage. */ void -glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +glibtop_get_mem__s (glibtop *server, glibtop_mem *buf) { vm_statistics_data_t vmstats; diff --git a/sysdeps/osf1/msg_limits.c b/sysdeps/osf1/msg_limits.c index 98993716..3dbc558b 100644 --- a/sysdeps/osf1/msg_limits.c +++ b/sysdeps/osf1/msg_limits.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_msg_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits__s (glibtop *server, glibtop_msg_limits *buf) { int ret, value; diff --git a/sysdeps/osf1/sem_limits.c b/sysdeps/osf1/sem_limits.c index f3a133e0..b4bebd48 100644 --- a/sysdeps/osf1/sem_limits.c +++ b/sysdeps/osf1/sem_limits.c @@ -31,7 +31,7 @@ static unsigned long _glibtop_sysdeps_sem_limits = /* Provides information about sysv sem limits. */ void -glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits__s (glibtop *server, glibtop_sem_limits *buf) { int ret, value; diff --git a/sysdeps/osf1/shm_limits.c b/sysdeps/osf1/shm_limits.c index 9173177a..7f18869a 100644 --- a/sysdeps/osf1/shm_limits.c +++ b/sysdeps/osf1/shm_limits.c @@ -30,7 +30,7 @@ static unsigned long _glibtop_sysdeps_shm_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits__s (glibtop *server, glibtop_shm_limits *buf) { int ret, value; diff --git a/sysdeps/osf1/swap.c b/sysdeps/osf1/swap.c index c606fa50..a7b3f7cb 100644 --- a/sysdeps/osf1/swap.c +++ b/sysdeps/osf1/swap.c @@ -30,7 +30,7 @@ static unsigned long _glibtop_sysdeps_swap = /* Provides information about swap usage. */ void -glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +glibtop_get_swap__s (glibtop *server, glibtop_swap *buf) { struct tbl_swapinfo swapinfo; int i; diff --git a/sysdeps/osf1/uptime.c b/sysdeps/osf1/uptime.c index f455ef30..97776fbe 100644 --- a/sysdeps/osf1/uptime.c +++ b/sysdeps/osf1/uptime.c @@ -31,7 +31,7 @@ static unsigned long _glibtop_sysdeps_uptime = /* Provides uptime and idle time. */ void -glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime__s (glibtop *server, glibtop_uptime *buf) { struct tbl_sysinfo sysinfo; int ret; From 92ec7c6d333952284f49fe72db1dddd598f23693 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 6 Jun 1998 18:49:07 +0000 Subject: [PATCH 0094/2539] Forgot to checkin the ChangeLog on last three commits. --- ChangeLog | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 149263dc..b3afca51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +1998-06-06 Martin Baulig + + * 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 '. + + * include/glibtop/types.h: New file - numeric constants + for `glibtop_types_'. + + * sysdeps/names/*.c (glibtop_types_*): Using numeric + constants from `types.h' instead of string constants. + 1998-06-02 Federico Mena Quintero * src/server/main.c: #include From 85f31a170768f2345e697b42e9bde1bfae252dbb Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 6 Jun 1998 22:26:40 +0000 Subject: [PATCH 0095/2539] removed that directory. 1998-06-05 Martin Baulig * 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 * 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. --- ChangeLog | 27 ++ Makefile.am | 6 +- acinclude.m4 | 611 ++++----------------------------------- configure.in | 33 ++- include/glibtop/global.h | 2 + 5 files changed, 113 insertions(+), 566 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3afca51..c499dfc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,33 @@ * sysdeps/names/*.c (glibtop_types_*): Using numeric constants from `types.h' instead of string constants. +1998-06-05 Martin Baulig + + * 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 + + * 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 * src/server/main.c: #include diff --git a/Makefile.am b/Makefile.am index 94842009..8eccb23d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,13 +6,13 @@ endif built_SUBDIRS = include sysdeps lib src -SUBDIRS = po intl support macros $(built_SUBDIRS) $(examples_SUBDIRS) +SUBDIRS = po intl 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) diff --git a/acinclude.m4 b/acinclude.m4 index 85b32a5f..ba416daa 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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>>, <<[^ ]>>, <<>>), <<>>, -<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, -<>; 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 , 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 - #include - ],[ - 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 &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 . +# Ulrich Drepper , 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 ], [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 ],[ - 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 ],[ - 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 , 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 , 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 . -# Ulrich Drepper , 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 ], [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]) - diff --git a/configure.in b/configure.in index ded551cc..3357499b 100644 --- a/configure.in +++ b/configure.in @@ -24,6 +24,9 @@ AC_CHECK_TOOL(NM,nm) NM=`which $NM` export CC CXX RANLIB LD AS AR NM +dnl If you want to use libgtop without gnome, comment the following line out. +GNOME_INIT + AC_LC_SYSDEPS if test x$libgtop_want_guile = xyes ; then @@ -60,7 +63,8 @@ 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 @@ -101,12 +105,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,6 +169,7 @@ 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 @@ -168,9 +185,6 @@ AC_SUBST(LIBGTOP_GUILE_INCS) AC_SUBST(LIBGTOP_BINDIR) AC_SUBST(LIBGTOP_SERVER) -AC_SUBST(LIBSUPPORT) -AC_SUBST(SUPPORTINCS) - AC_OUTPUT([ Makefile po/Makefile.in @@ -191,5 +205,4 @@ src/server/Makefile src/proxy/Makefile lib/Makefile examples/Makefile -support/Makefile macros/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]) diff --git a/include/glibtop/global.h b/include/glibtop/global.h index d1609f35..9cbaed8b 100644 --- a/include/glibtop/global.h +++ b/include/glibtop/global.h @@ -55,11 +55,13 @@ #include #endif +#ifdef _IN_LIBGTOP #if (defined HAVE_LIBINTL_H) || (defined HAVE_GETTEXT) #include #else #include #endif +#endif #include #include From c84923132a0aaade80a48eb762b27d87640d3921 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 7 Jun 1998 13:57:45 +0000 Subject: [PATCH 0096/2539] Using single underscore instead of two underscores for function prefixes 1998-06-07 Martin Baulig * *.[ch]: Using single underscore instead of two underscores for function prefixes (regexp: ``s,__([rspl])\b,_$1,g'') to avoid ambiguity with mangled C++ names. --- ChangeLog | 6 ++++++ glibtop.h | 6 ++++-- include/glibtop/close.h | 2 +- include/glibtop/command.h | 6 +++--- include/glibtop/cpu.h | 12 ++++++------ include/glibtop/error.h | 4 ++-- include/glibtop/loadavg.h | 12 ++++++------ include/glibtop/mem.h | 12 ++++++------ include/glibtop/msg_limits.h | 12 ++++++------ include/glibtop/open.h | 4 ++-- include/glibtop/prockernel.h | 12 ++++++------ include/glibtop/proclist.h | 12 ++++++------ include/glibtop/procmem.h | 12 ++++++------ include/glibtop/procsegment.h | 12 ++++++------ include/glibtop/procsignal.h | 12 ++++++------ include/glibtop/procstate.h | 12 ++++++------ include/glibtop/proctime.h | 12 ++++++------ include/glibtop/procuid.h | 12 ++++++------ include/glibtop/read.h | 4 ++-- include/glibtop/read_data.h | 6 +++--- include/glibtop/sem_limits.h | 12 ++++++------ include/glibtop/shm_limits.h | 12 ++++++------ include/glibtop/swap.h | 12 ++++++------ include/glibtop/sysdeps.h | 4 ++-- include/glibtop/uptime.h | 12 ++++++------ include/glibtop/write.h | 4 ++-- include/glibtop/xmalloc.h | 16 ++++++++-------- lib/close.c | 2 +- lib/command.c | 16 ++++++++-------- lib/cpu.c | 8 ++++---- lib/init.c | 4 ++-- lib/loadavg.c | 8 ++++---- lib/mem.c | 8 ++++---- lib/msg_limits.c | 8 ++++---- lib/open.c | 16 ++++++++-------- lib/prockernel.c | 8 ++++---- lib/proclist.c | 8 ++++---- lib/procmem.c | 8 ++++---- lib/procsegment.c | 8 ++++---- lib/procsignal.c | 8 ++++---- lib/procstate.c | 8 ++++---- lib/proctime.c | 8 ++++---- lib/procuid.c | 8 ++++---- lib/read.c | 10 +++++----- lib/read_data.c | 10 +++++----- lib/sem_limits.c | 8 ++++---- lib/shm_limits.c | 8 ++++---- lib/swap.c | 8 ++++---- lib/uptime.c | 8 ++++---- lib/write.c | 8 ++++---- src/proxy/main.c | 36 +++++++++++++++++------------------ src/server/main.c | 36 +++++++++++++++++------------------ sysdeps/common/error.c | 2 +- sysdeps/common/sysdeps.c | 32 +++++++++++++++---------------- sysdeps/common/xmalloc.c | 14 +++++++------- sysdeps/linux/close.c | 2 +- sysdeps/linux/cpu.c | 4 ++-- sysdeps/linux/init.c | 6 ++++-- sysdeps/linux/loadavg.c | 4 ++-- sysdeps/linux/mem.c | 4 ++-- sysdeps/linux/msg_limits.c | 4 ++-- sysdeps/linux/open.c | 2 +- sysdeps/linux/procdata.c | 4 ++-- sysdeps/linux/prockernel.c | 4 ++-- sysdeps/linux/proclist.c | 8 ++++---- sysdeps/linux/procmem.c | 4 ++-- sysdeps/linux/procsegment.c | 4 ++-- sysdeps/linux/procsignal.c | 4 ++-- sysdeps/linux/procstate.c | 4 ++-- sysdeps/linux/proctime.c | 4 ++-- sysdeps/linux/procuid.c | 4 ++-- sysdeps/linux/sem_limits.c | 4 ++-- sysdeps/linux/shm_limits.c | 4 ++-- sysdeps/linux/swap.c | 4 ++-- sysdeps/linux/uptime.c | 4 ++-- sysdeps/osf1/cpu.c | 2 +- sysdeps/osf1/init.c | 2 +- sysdeps/osf1/loadavg.c | 2 +- sysdeps/osf1/mem.c | 2 +- sysdeps/osf1/msg_limits.c | 2 +- sysdeps/osf1/procdata.c | 2 +- sysdeps/osf1/prockernel.c | 2 +- sysdeps/osf1/proclist.c | 6 +++--- sysdeps/osf1/procmem.c | 2 +- sysdeps/osf1/procsegment.c | 2 +- sysdeps/osf1/procsignal.c | 2 +- sysdeps/osf1/procstate.c | 2 +- sysdeps/osf1/proctime.c | 2 +- sysdeps/osf1/procuid.c | 2 +- sysdeps/osf1/sem_limits.c | 2 +- sysdeps/osf1/shm_limits.c | 2 +- sysdeps/osf1/swap.c | 2 +- sysdeps/osf1/uptime.c | 2 +- sysdeps/stub/cpu.c | 2 +- sysdeps/stub/init.c | 2 +- sysdeps/stub/loadavg.c | 2 +- sysdeps/stub/mem.c | 2 +- sysdeps/stub/msg_limits.c | 2 +- sysdeps/stub/prockernel.c | 2 +- sysdeps/stub/proclist.c | 2 +- sysdeps/stub/procmem.c | 2 +- sysdeps/stub/procsegment.c | 2 +- sysdeps/stub/procsignal.c | 2 +- sysdeps/stub/procstate.c | 2 +- sysdeps/stub/proctime.c | 2 +- sysdeps/stub/procuid.c | 2 +- sysdeps/stub/sem_limits.c | 2 +- sysdeps/stub/shm_limits.c | 2 +- sysdeps/stub/swap.c | 2 +- sysdeps/stub/uptime.c | 2 +- sysdeps/sun4/cpu.c | 4 ++-- sysdeps/sun4/init.c | 4 ++-- sysdeps/sun4/loadavg.c | 4 ++-- sysdeps/sun4/mem.c | 4 ++-- sysdeps/sun4/msg_limits.c | 4 ++-- sysdeps/sun4/open.c | 14 +++++++------- sysdeps/sun4/procdata.c | 2 +- sysdeps/sun4/prockernel.c | 4 ++-- sysdeps/sun4/proclist.c | 4 ++-- sysdeps/sun4/procmem.c | 4 ++-- sysdeps/sun4/procsegment.c | 4 ++-- sysdeps/sun4/procsignal.c | 4 ++-- sysdeps/sun4/procstate.c | 4 ++-- sysdeps/sun4/proctime.c | 4 ++-- sysdeps/sun4/procuid.c | 4 ++-- sysdeps/sun4/sem_limits.c | 4 ++-- sysdeps/sun4/shm_limits.c | 4 ++-- sysdeps/sun4/swap.c | 4 ++-- sysdeps/sun4/uptime.c | 4 ++-- 129 files changed, 409 insertions(+), 399 deletions(-) diff --git a/ChangeLog b/ChangeLog index c499dfc8..3ee557f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1998-06-07 Martin Baulig + + * *.[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 * sysdeps/osf1/glibtop_server.h: New file. diff --git a/glibtop.h b/glibtop.h index adfd95d6..3f833081 100644 --- a/glibtop.h +++ b/glibtop.h @@ -55,9 +55,11 @@ extern glibtop *glibtop_global_server; extern const unsigned long glibtop_server_features; -#define glibtop_init() glibtop_init__r(&glibtop_global_server, 0, 0); +#define glibtop_init() glibtop_init_r(&glibtop_global_server, 0, 0); -extern glibtop *glibtop_init__r __P((glibtop **, const unsigned long, const unsigned)); +#define glibtop_close() glibtop_close_r(&glibtop_global_server); + +extern glibtop *glibtop_init_r __P((glibtop **, const unsigned long, const unsigned)); #ifdef HAVE_GUILE diff --git a/include/glibtop/close.h b/include/glibtop/close.h index d57ccd38..6241737a 100644 --- a/include/glibtop/close.h +++ b/include/glibtop/close.h @@ -26,7 +26,7 @@ __BEGIN_DECLS -extern void glibtop_close __P((glibtop *)); +extern void glibtop_close_r __P((glibtop *)); __END_DECLS diff --git a/include/glibtop/command.h b/include/glibtop/command.h index ce83c618..8314699f 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -59,10 +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__l __P((glibtop *, unsigned, size_t, void *, size_t, void *)); -extern void *glibtop_call__s __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 diff --git a/include/glibtop/cpu.h b/include/glibtop/cpu.h index cf164833..f4e96afc 100644 --- a/include/glibtop/cpu.h +++ b/include/glibtop/cpu.h @@ -49,20 +49,20 @@ struct _glibtop_cpu frequency; /* GLIBTOP_CPU_FREQUENCY */ }; -#define glibtop_get_cpu(cpu) glibtop_get_cpu__l(glibtop_global_server, cpu) +#define glibtop_get_cpu(cpu) glibtop_get_cpu_l(glibtop_global_server, cpu) #if GLIBTOP_SUID_CPU -#define glibtop_get_cpu__r glibtop_get_cpu__p +#define glibtop_get_cpu_r glibtop_get_cpu_p #else -#define glibtop_get_cpu__r glibtop_get_cpu__s +#define glibtop_get_cpu_r glibtop_get_cpu_s #endif -extern void glibtop_get_cpu__l __P((glibtop *, glibtop_cpu *)); +extern void glibtop_get_cpu_l __P((glibtop *, glibtop_cpu *)); #if GLIBTOP_SUID_CPU -extern void glibtop_get_cpu__p __P((glibtop *, glibtop_cpu *)); +extern void glibtop_get_cpu_p __P((glibtop *, glibtop_cpu *)); #else -extern void glibtop_get_cpu__s __P((glibtop *, glibtop_cpu *)); +extern void glibtop_get_cpu_s __P((glibtop *, glibtop_cpu *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/error.h b/include/glibtop/error.h index 94e14ba9..adb85828 100644 --- a/include/glibtop/error.h +++ b/include/glibtop/error.h @@ -26,9 +26,9 @@ __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) -extern void glibtop_error__r __P((glibtop *, char *, ...)); +extern void glibtop_error_r __P((glibtop *, char *, ...)); __END_DECLS diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h index eaf6588c..661e9032 100644 --- a/include/glibtop/loadavg.h +++ b/include/glibtop/loadavg.h @@ -39,20 +39,20 @@ struct _glibtop_loadavg double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */ }; -#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg__l(glibtop_global_server, loadavg) +#define glibtop_get_loadavg(loadavg) glibtop_get_loadavg_l(glibtop_global_server, loadavg) #if GLIBTOP_SUID_LOADAVG -#define glibtop_get_loadavg__r glibtop_get_loadavg__p +#define glibtop_get_loadavg_r glibtop_get_loadavg_p #else -#define glibtop_get_loadavg__r glibtop_get_loadavg__s +#define glibtop_get_loadavg_r glibtop_get_loadavg_s #endif -extern void glibtop_get_loadavg__l __P((glibtop *, glibtop_loadavg *)); +extern void glibtop_get_loadavg_l __P((glibtop *, glibtop_loadavg *)); #if GLIBTOP_SUID_LOADAVG -extern void glibtop_get_loadavg__p __P((glibtop *, glibtop_loadavg *)); +extern void glibtop_get_loadavg_p __P((glibtop *, glibtop_loadavg *)); #else -extern void glibtop_get_loadavg__s __P((glibtop *, glibtop_loadavg *)); +extern void glibtop_get_loadavg_s __P((glibtop *, glibtop_loadavg *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/mem.h b/include/glibtop/mem.h index 9f90bb27..5f490618 100644 --- a/include/glibtop/mem.h +++ b/include/glibtop/mem.h @@ -53,20 +53,20 @@ struct _glibtop_mem locked; /* GLIBTOP_MEM_LOCKED */ }; -#define glibtop_get_mem(mem) glibtop_get_mem__l(glibtop_global_server, mem) +#define glibtop_get_mem(mem) glibtop_get_mem_l(glibtop_global_server, mem) #if GLIBTOP_SUID_MEM -#define glibtop_get_mem__r glibtop_get_mem__p +#define glibtop_get_mem_r glibtop_get_mem_p #else -#define glibtop_get_mem__r glibtop_get_mem__s +#define glibtop_get_mem_r glibtop_get_mem_s #endif -extern void glibtop_get_mem__l __P((glibtop *, glibtop_mem *)); +extern void glibtop_get_mem_l __P((glibtop *, glibtop_mem *)); #if GLIBTOP_SUID_MEM -extern void glibtop_get_mem__p __P((glibtop *, glibtop_mem *)); +extern void glibtop_get_mem_p __P((glibtop *, glibtop_mem *)); #else -extern void glibtop_get_mem__s __P((glibtop *, glibtop_mem *)); +extern void glibtop_get_mem_s __P((glibtop *, glibtop_mem *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/msg_limits.h b/include/glibtop/msg_limits.h index 6199265e..c915b568 100644 --- a/include/glibtop/msg_limits.h +++ b/include/glibtop/msg_limits.h @@ -51,20 +51,20 @@ struct _glibtop_msg_limits msgtql; /* GLIBTOP_IPC_MSGTQL */ }; -#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits__l(glibtop_global_server, msg) +#define glibtop_get_msg_limits(msg) glibtop_get_msg_limits_l(glibtop_global_server, msg) #if GLIBTOP_SUID_MSG_LIMITS -#define glibtop_get_msg_limits__r glibtop_get_msg_limits__p +#define glibtop_get_msg_limits_r glibtop_get_msg_limits_p #else -#define glibtop_get_msg_limits__r glibtop_get_msg_limits__s +#define glibtop_get_msg_limits_r glibtop_get_msg_limits_s #endif -extern void glibtop_get_msg_limits__l __P((glibtop *, glibtop_msg_limits *)); +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 *)); +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 *)); +extern void glibtop_get_msg_limits_s __P((glibtop *, glibtop_msg_limits *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/open.h b/include/glibtop/open.h index 629c18e8..4e4e5408 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -28,9 +28,9 @@ __BEGIN_DECLS #define GLIBTOP_OPEN_NO_OVERRIDE 1 -extern void glibtop_open__l __P((glibtop *, const char *, const unsigned long, const unsigned)); +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)); +extern void glibtop_open_r __P((glibtop *, const char *, const unsigned long, const unsigned)); __END_DECLS diff --git a/include/glibtop/prockernel.h b/include/glibtop/prockernel.h index dbec0f0c..fed6fba6 100644 --- a/include/glibtop/prockernel.h +++ b/include/glibtop/prockernel.h @@ -60,20 +60,20 @@ struct _glibtop_proc_kernel * proc is sleeping in */ }; -#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel__l(glibtop_global_server, p1, p2) +#define glibtop_get_proc_kernel(p1, p2) glibtop_get_proc_kernel_l(glibtop_global_server, p1, p2) #if GLIBTOP_SUID_PROC_KERNEL -#define glibtop_get_proc_kernel__r glibtop_get_proc_kernel__p +#define glibtop_get_proc_kernel_r glibtop_get_proc_kernel_p #else -#define glibtop_get_proc_kernel__r glibtop_get_proc_kernel__s +#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)); +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)); +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)); +extern void glibtop_get_proc_kernel_s __P((glibtop *, glibtop_proc_kernel *, pid_t)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/proclist.h b/include/glibtop/proclist.h index 24026b6d..ebc6512c 100644 --- a/include/glibtop/proclist.h +++ b/include/glibtop/proclist.h @@ -43,20 +43,20 @@ struct _glibtop_proclist size; /* GLIBTOP_PROCLIST_SIZE */ }; -#define glibtop_get_proclist(proclist) glibtop_get_proclist__l(glibtop_global_server, proclist) +#define glibtop_get_proclist(proclist) glibtop_get_proclist_l(glibtop_global_server, proclist) #if GLIBTOP_SUID_PROCLIST -#define glibtop_get_proclist__r glibtop_get_proclist__p +#define glibtop_get_proclist_r glibtop_get_proclist_p #else -#define glibtop_get_proclist__r glibtop_get_proclist__s +#define glibtop_get_proclist_r glibtop_get_proclist_s #endif -extern unsigned *glibtop_get_proclist__l __P((glibtop *, glibtop_proclist *)); +extern unsigned *glibtop_get_proclist_l __P((glibtop *, glibtop_proclist *)); #if GLIBTOP_SUID_PROCLIST -extern unsigned *glibtop_get_proclist__p __P((glibtop *, glibtop_proclist *)); +extern unsigned *glibtop_get_proclist_p __P((glibtop *, glibtop_proclist *)); #else -extern unsigned *glibtop_get_proclist__s __P((glibtop *, glibtop_proclist *)); +extern unsigned *glibtop_get_proclist_s __P((glibtop *, glibtop_proclist *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/procmem.h b/include/glibtop/procmem.h index 9d787966..a2720169 100644 --- a/include/glibtop/procmem.h +++ b/include/glibtop/procmem.h @@ -53,20 +53,20 @@ struct _glibtop_proc_mem * of the process; usually 2,147,483,647 */ }; -#define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem__l(glibtop_global_server, p1, p2) +#define glibtop_get_proc_mem(p1, p2) glibtop_get_proc_mem_l(glibtop_global_server, p1, p2) #if GLIBTOP_SUID_PROC_MEM -#define glibtop_get_proc_mem__r glibtop_get_proc_mem__p +#define glibtop_get_proc_mem_r glibtop_get_proc_mem_p #else -#define glibtop_get_proc_mem__r glibtop_get_proc_mem__s +#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)); +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)); +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)); +extern void glibtop_get_proc_mem_s __P((glibtop *, glibtop_proc_mem *, pid_t)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/procsegment.h b/include/glibtop/procsegment.h index 76e419c7..54f59d81 100644 --- a/include/glibtop/procsegment.h +++ b/include/glibtop/procsegment.h @@ -54,20 +54,20 @@ struct _glibtop_proc_segment start_stack; /* address of the bottom of stack segment */ }; -#define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment__l(glibtop_global_server, p1, p2) +#define glibtop_get_proc_segment(p1, p2) glibtop_get_proc_segment_l(glibtop_global_server, p1, p2) #if GLIBTOP_SUID_PROC_SEGMENT -#define glibtop_get_proc_segment__r glibtop_get_proc_segment__p +#define glibtop_get_proc_segment_r glibtop_get_proc_segment_p #else -#define glibtop_get_proc_segment__r glibtop_get_proc_segment__s +#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)); +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)); +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)); +extern void glibtop_get_proc_segment_s __P((glibtop *, glibtop_proc_segment *, pid_t)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/procsignal.h b/include/glibtop/procsignal.h index f09b6047..e3690ea0 100644 --- a/include/glibtop/procsignal.h +++ b/include/glibtop/procsignal.h @@ -47,20 +47,20 @@ struct _glibtop_proc_signal sigcatch; /* mask of caught signals */ }; -#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal__l(glibtop_global_server, p1, p2) +#define glibtop_get_proc_signal(p1, p2) glibtop_get_proc_signal_l(glibtop_global_server, p1, p2) #if GLIBTOP_SUID_PROC_SIGNAL -#define glibtop_get_proc_signal__r glibtop_get_proc_signal__p +#define glibtop_get_proc_signal_r glibtop_get_proc_signal_p #else -#define glibtop_get_proc_signal__r glibtop_get_proc_signal__s +#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)); +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)); +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)); +extern void glibtop_get_proc_signal_s __P((glibtop *, glibtop_proc_signal *, pid_t)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/procstate.h b/include/glibtop/procstate.h index d62c64e4..416a2d94 100644 --- a/include/glibtop/procstate.h +++ b/include/glibtop/procstate.h @@ -54,20 +54,20 @@ struct _glibtop_proc_state gid; /* GID of process */ }; -#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state__l(glibtop_global_server, p1, p2) +#define glibtop_get_proc_state(p1, p2) glibtop_get_proc_state_l(glibtop_global_server, p1, p2) #if GLIBTOP_SUID_PROC_STATE -#define glibtop_get_proc_state__r glibtop_get_proc_state__p +#define glibtop_get_proc_state_r glibtop_get_proc_state_p #else -#define glibtop_get_proc_state__r glibtop_get_proc_state__s +#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)); +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)); +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)); +extern void glibtop_get_proc_state_s __P((glibtop *, glibtop_proc_state *, pid_t)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/proctime.h b/include/glibtop/proctime.h index 9bbe6597..40ae3aa5 100644 --- a/include/glibtop/proctime.h +++ b/include/glibtop/proctime.h @@ -59,20 +59,20 @@ struct _glibtop_proc_time * due to an interval timer. */ }; -#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time__l(glibtop_global_server, p1, p2) +#define glibtop_get_proc_time(p1, p2) glibtop_get_proc_time_l(glibtop_global_server, p1, p2) #if GLIBTOP_SUID_PROC_TIME -#define glibtop_get_proc_time__r glibtop_get_proc_time__p +#define glibtop_get_proc_time_r glibtop_get_proc_time_p #else -#define glibtop_get_proc_time__r glibtop_get_proc_time__s +#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)); +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)); +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)); +extern void glibtop_get_proc_time_s __P((glibtop *, glibtop_proc_time *, pid_t)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/procuid.h b/include/glibtop/procuid.h index 12cbe5d7..e478c2cb 100644 --- a/include/glibtop/procuid.h +++ b/include/glibtop/procuid.h @@ -63,20 +63,20 @@ struct _glibtop_proc_uid nice; /* standard unix nice level of process */ }; -#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid__l(glibtop_global_server, p1, p2) +#define glibtop_get_proc_uid(p1, p2) glibtop_get_proc_uid_l(glibtop_global_server, p1, p2) #if GLIBTOP_SUID_PROC_UID -#define glibtop_get_proc_uid__r glibtop_get_proc_uid__p +#define glibtop_get_proc_uid_r glibtop_get_proc_uid_p #else -#define glibtop_get_proc_uid__r glibtop_get_proc_uid__s +#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)); +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)); +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)); +extern void glibtop_get_proc_uid_s __P((glibtop *, glibtop_proc_uid *, pid_t)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/read.h b/include/glibtop/read.h index 4286cce1..bd0945d7 100644 --- a/include/glibtop/read.h +++ b/include/glibtop/read.h @@ -29,8 +29,8 @@ __BEGIN_DECLS #define glibtop_read(p1, p2) glibtop_read(glibtop_global_server, p1, p2) -extern void glibtop_read__l __P((glibtop *, size_t, void *)); -extern void glibtop_read__s __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 diff --git a/include/glibtop/read_data.h b/include/glibtop/read_data.h index 61bda2b2..8583a51b 100644 --- a/include/glibtop/read_data.h +++ b/include/glibtop/read_data.h @@ -27,10 +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__l __P((glibtop *)); -extern void *glibtop_read_data__s __P((glibtop *)); +extern void *glibtop_read_data_l __P((glibtop *)); +extern void *glibtop_read_data_s __P((glibtop *)); __END_DECLS diff --git a/include/glibtop/sem_limits.h b/include/glibtop/sem_limits.h index 50118802..19cefc95 100644 --- a/include/glibtop/sem_limits.h +++ b/include/glibtop/sem_limits.h @@ -57,20 +57,20 @@ struct _glibtop_sem_limits semaem; /* GLIBTOP_IPC_SEMAEM */ }; -#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits__l(glibtop_global_server, sem) +#define glibtop_get_sem_limits(sem) glibtop_get_sem_limits_l(glibtop_global_server, sem) #if GLIBTOP_SUID_SEM_LIMITS -#define glibtop_get_sem_limits__r glibtop_get_sem_limits__p +#define glibtop_get_sem_limits_r glibtop_get_sem_limits_p #else -#define glibtop_get_sem_limits__r glibtop_get_sem_limits__s +#define glibtop_get_sem_limits_r glibtop_get_sem_limits_s #endif -extern void glibtop_get_sem_limits__l __P((glibtop *, glibtop_sem_limits *)); +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 *)); +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 *)); +extern void glibtop_get_sem_limits_s __P((glibtop *, glibtop_sem_limits *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/shm_limits.h b/include/glibtop/shm_limits.h index df270868..e068bd47 100644 --- a/include/glibtop/shm_limits.h +++ b/include/glibtop/shm_limits.h @@ -47,20 +47,20 @@ struct _glibtop_shm_limits shmall; /* GLIBTOP_IPC_SHMALL */ }; -#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits__l(glibtop_global_server, shm) +#define glibtop_get_shm_limits(shm) glibtop_get_shm_limits_l(glibtop_global_server, shm) #if GLIBTOP_SUID_SHM_LIMITS -#define glibtop_get_shm_limits__r glibtop_get_shm_limits__p +#define glibtop_get_shm_limits_r glibtop_get_shm_limits_p #else -#define glibtop_get_shm_limits__r glibtop_get_shm_limits__s +#define glibtop_get_shm_limits_r glibtop_get_shm_limits_s #endif -extern void glibtop_get_shm_limits__l __P((glibtop *, glibtop_shm_limits *)); +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 *)); +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 *)); +extern void glibtop_get_shm_limits_s __P((glibtop *, glibtop_shm_limits *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/swap.h b/include/glibtop/swap.h index 396f940a..ce7ab57c 100644 --- a/include/glibtop/swap.h +++ b/include/glibtop/swap.h @@ -43,20 +43,20 @@ struct _glibtop_swap free; /* GLIBTOP_SWAP_FREE */ }; -#define glibtop_get_swap(swap) glibtop_get_swap__l(glibtop_global_server, swap) +#define glibtop_get_swap(swap) glibtop_get_swap_l(glibtop_global_server, swap) #if GLIBTOP_SUID_SWAP -#define glibtop_get_swap__r glibtop_get_swap__p +#define glibtop_get_swap_r glibtop_get_swap_p #else -#define glibtop_get_swap__r glibtop_get_swap__s +#define glibtop_get_swap_r glibtop_get_swap_s #endif -extern void glibtop_get_swap__l __P((glibtop *, glibtop_swap *)); +extern void glibtop_get_swap_l __P((glibtop *, glibtop_swap *)); #if GLIBTOP_SUID_SWAP -extern void glibtop_get_swap__p __P((glibtop *, glibtop_swap *)); +extern void glibtop_get_swap_p __P((glibtop *, glibtop_swap *)); #else -extern void glibtop_get_swap__s __P((glibtop *, glibtop_swap *)); +extern void glibtop_get_swap_s __P((glibtop *, glibtop_swap *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index 8bbcba2b..e2491008 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -73,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 diff --git a/include/glibtop/uptime.h b/include/glibtop/uptime.h index 99fe9290..39c8dea5 100644 --- a/include/glibtop/uptime.h +++ b/include/glibtop/uptime.h @@ -41,20 +41,20 @@ struct _glibtop_uptime idletime; /* GLIBTOP_UPTIME_IDLETIME */ }; -#define glibtop_get_uptime(uptime) glibtop_get_uptime__l(glibtop_global_server, uptime) +#define glibtop_get_uptime(uptime) glibtop_get_uptime_l(glibtop_global_server, uptime) #if GLIBTOP_SUID_UPTIME -#define glibtop_get_uptime__r glibtop_get_uptime__p +#define glibtop_get_uptime_r glibtop_get_uptime_p #else -#define glibtop_get_uptime__r glibtop_get_uptime__s +#define glibtop_get_uptime_r glibtop_get_uptime_s #endif -extern void glibtop_get_uptime__l __P((glibtop *, glibtop_uptime *)); +extern void glibtop_get_uptime_l __P((glibtop *, glibtop_uptime *)); #if GLIBTOP_SUID_UPTIME -extern void glibtop_get_uptime__p __P((glibtop *, glibtop_uptime *)); +extern void glibtop_get_uptime_p __P((glibtop *, glibtop_uptime *)); #else -extern void glibtop_get_uptime__s __P((glibtop *, glibtop_uptime *)); +extern void glibtop_get_uptime_s __P((glibtop *, glibtop_uptime *)); #endif #ifdef HAVE_GUILE diff --git a/include/glibtop/write.h b/include/glibtop/write.h index 22a677b5..065da135 100644 --- a/include/glibtop/write.h +++ b/include/glibtop/write.h @@ -29,8 +29,8 @@ __BEGIN_DECLS #define glibtop_write(p1, p2) glibtop_write(glibtop_global_server, p1, p2) -extern void glibtop_write__l __P((glibtop *, size_t, void *)); -extern void glibtop_write__s __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 diff --git a/include/glibtop/xmalloc.h b/include/glibtop/xmalloc.h index 14a6709c..5c2b5024 100644 --- a/include/glibtop/xmalloc.h +++ b/include/glibtop/xmalloc.h @@ -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 diff --git a/lib/close.c b/lib/close.c index 8f85c512..f4f0ba00 100644 --- a/lib/close.c +++ b/lib/close.c @@ -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]); diff --git a/lib/command.c b/lib/command.c index 1bc67b05..e8d2dc97 100644 --- a/lib/command.c +++ b/lib/command.c @@ -27,28 +27,28 @@ #include void * -glibtop_call__l (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, 0, 0); + 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__l (server, sizeof (glibtop_command), cmnd); - glibtop_write__l (server, send_size, send_buf); - glibtop_read__l (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__l (server); + ptr = glibtop_read_data_l (server); - glibtop_free__r (server, cmnd); + glibtop_free_r (server, cmnd); return ptr; } diff --git a/lib/cpu.c b/lib/cpu.c index 94ffcdab..6e20a19e 100644 --- a/lib/cpu.c +++ b/lib/cpu.c @@ -26,14 +26,14 @@ /* Provides information about cpu usage. */ void -glibtop_get_cpu__l (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_CPU, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_CPU, 0); if (server->features & GLIBTOP_SYSDEPS_CPU) { - glibtop_call__l (server, GLIBTOP_CMND_CPU, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_CPU, 0, NULL, sizeof (glibtop_cpu), buf); } else { - glibtop_get_cpu__r (server, buf); + glibtop_get_cpu_r (server, buf); } } diff --git a/lib/init.c b/lib/init.c index 1fbc9952..f0094020 100644 --- a/lib/init.c +++ b/lib/init.c @@ -26,7 +26,7 @@ static glibtop _glibtop_global_server; glibtop *glibtop_global_server = NULL; glibtop * -glibtop_init__r (glibtop **server, const unsigned long features, +glibtop_init_r (glibtop **server, const unsigned long features, const unsigned flags) { if (*server != NULL) @@ -34,7 +34,7 @@ glibtop_init__r (glibtop **server, const unsigned long features, if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; - glibtop_open__l (glibtop_global_server, "glibtop", + glibtop_open_l (glibtop_global_server, "glibtop", features, flags); } diff --git a/lib/loadavg.c b/lib/loadavg.c index 0704f1bc..3e503160 100644 --- a/lib/loadavg.c +++ b/lib/loadavg.c @@ -26,14 +26,14 @@ /* Provides load averange. */ void -glibtop_get_loadavg__l (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); if (server->features & GLIBTOP_SYSDEPS_LOADAVG) { - glibtop_call__l (server, GLIBTOP_CMND_LOADAVG, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_LOADAVG, 0, NULL, sizeof (glibtop_loadavg), buf); } else { - glibtop_get_loadavg__r (server, buf); + glibtop_get_loadavg_r (server, buf); } } diff --git a/lib/mem.c b/lib/mem.c index ea8f2c6b..34fe5ef1 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -25,14 +25,14 @@ /* Provides information about memory usage. */ void -glibtop_get_mem__l (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_l (glibtop *server, glibtop_mem *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_MEM, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_MEM, 0); if (server->features & GLIBTOP_SYSDEPS_MEM) { - glibtop_call__l (server, GLIBTOP_CMND_MEM, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_MEM, 0, NULL, sizeof (glibtop_mem), buf); } else { - glibtop_get_mem__r (server, buf); + glibtop_get_mem_r (server, buf); } } diff --git a/lib/msg_limits.c b/lib/msg_limits.c index 9fc82c12..16727049 100644 --- a/lib/msg_limits.c +++ b/lib/msg_limits.c @@ -25,14 +25,14 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__l (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits_l (glibtop *server, glibtop_msg_limits *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); if (server->features & GLIBTOP_SYSDEPS_MSG_LIMITS) { - glibtop_call__l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, sizeof (glibtop_msg_limits), buf); } else { - glibtop_get_msg_limits__r (server, buf); + glibtop_get_msg_limits_r (server, buf); } } diff --git a/lib/open.c b/lib/open.c index 5dca3717..d3501fa4 100644 --- a/lib/open.c +++ b/lib/open.c @@ -28,7 +28,7 @@ /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open__l (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]; @@ -49,14 +49,14 @@ glibtop_open__l (glibtop *server, const char *program_name, temp = getenv ("LIBGTOP_SERVER") ? getenv ("LIBGTOP_SERVER") : GTOP_SERVER; - server_command = glibtop_malloc__r (server, strlen (temp) + 1); + 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); + server_rsh = glibtop_malloc_r (server, strlen (temp) + 1); strcpy (server_rsh, temp); @@ -103,13 +103,13 @@ glibtop_open__l (glibtop *server, const char *program_name, /* Fork and exec server. */ if (pipe (server->input) || pipe (server->output)) - glibtop_error__r (server, _("cannot make a pipe: %s\n"), + 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"), + glibtop_error_r (server, _("%s: fork failed: %s\n"), strerror (errno)); } else if (server->pid == 0) { close (0); close (1); /* close (2); */ @@ -140,14 +140,14 @@ glibtop_open__l (glibtop *server, const char *program_name, sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION); - glibtop_read__l (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, + glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL, sizeof (glibtop_sysdeps), &sysdeps); server->features = sysdeps.features; diff --git a/lib/prockernel.c b/lib/prockernel.c index 0c66d230..56ff0159 100644 --- a/lib/prockernel.c +++ b/lib/prockernel.c @@ -26,15 +26,15 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__l (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); if (server->features & GLIBTOP_SYSDEPS_PROC_KERNEL) { - glibtop_call__l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t), + glibtop_call_l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t), &pid, sizeof (glibtop_proc_kernel), buf); } else { - glibtop_get_proc_kernel__r (server, buf, pid); + glibtop_get_proc_kernel_r (server, buf, pid); } } diff --git a/lib/proclist.c b/lib/proclist.c index 0a40f825..a82c016c 100644 --- a/lib/proclist.c +++ b/lib/proclist.c @@ -25,14 +25,14 @@ /* Fetch list of currently running processes. */ unsigned * -glibtop_get_proclist__l (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROCLIST, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROCLIST, 0); if (server->features & GLIBTOP_SYSDEPS_PROCLIST) { - return glibtop_call__l (server, GLIBTOP_CMND_PROCLIST, 0, NULL, + return glibtop_call_l (server, GLIBTOP_CMND_PROCLIST, 0, NULL, sizeof (glibtop_proclist), buf); } else { - return glibtop_get_proclist__r (server, buf); + return glibtop_get_proclist_r (server, buf); } } diff --git a/lib/procmem.c b/lib/procmem.c index 575c59a9..26e822ca 100644 --- a/lib/procmem.c +++ b/lib/procmem.c @@ -26,15 +26,15 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__l (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_MEM, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_MEM, 0); if (server->features & GLIBTOP_SYSDEPS_PROC_MEM) { - glibtop_call__l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), + glibtop_call_l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), &pid, sizeof (glibtop_proc_mem), buf); } else { - glibtop_get_proc_mem__r (server, buf, pid); + glibtop_get_proc_mem_r (server, buf, pid); } } diff --git a/lib/procsegment.c b/lib/procsegment.c index a485dc30..92ec5a2a 100644 --- a/lib/procsegment.c +++ b/lib/procsegment.c @@ -26,15 +26,15 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__l (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); if (server->features & GLIBTOP_SYSDEPS_PROC_SEGMENT) { - glibtop_call__l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t), + glibtop_call_l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t), &pid, sizeof (glibtop_proc_segment), buf); } else { - glibtop_get_proc_segment__r (server, buf, pid); + glibtop_get_proc_segment_r (server, buf, pid); } } diff --git a/lib/procsignal.c b/lib/procsignal.c index 89c23ed3..d51ce115 100644 --- a/lib/procsignal.c +++ b/lib/procsignal.c @@ -26,15 +26,15 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__l (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); if (server->features & GLIBTOP_SYSDEPS_PROC_SIGNAL) { - glibtop_call__l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), + glibtop_call_l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), &pid, sizeof (glibtop_proc_signal), buf); } else { - glibtop_get_proc_signal__r (server, buf, pid); + glibtop_get_proc_signal_r (server, buf, pid); } } diff --git a/lib/procstate.c b/lib/procstate.c index a5625ac4..d1167186 100644 --- a/lib/procstate.c +++ b/lib/procstate.c @@ -26,15 +26,15 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_state__l (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf, pid_t pid) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0); if (server->features & GLIBTOP_SYSDEPS_PROC_STATE) { - glibtop_call__l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), + glibtop_call_l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), &pid, sizeof (glibtop_proc_state), buf); } else { - glibtop_get_proc_state__r (server, buf, pid); + glibtop_get_proc_state_r (server, buf, pid); } } diff --git a/lib/proctime.c b/lib/proctime.c index 40c0e62c..ac116d00 100644 --- a/lib/proctime.c +++ b/lib/proctime.c @@ -26,15 +26,15 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_time__l (glibtop *server, glibtop_proc_time *buf, +glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf, pid_t pid) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0); if (server->features & GLIBTOP_SYSDEPS_PROC_TIME) { - glibtop_call__l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), + glibtop_call_l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), &pid, sizeof (glibtop_proc_time), buf); } else { - glibtop_get_proc_time__r (server, buf, pid); + glibtop_get_proc_time_r (server, buf, pid); } } diff --git a/lib/procuid.c b/lib/procuid.c index 563242a8..e65da97d 100644 --- a/lib/procuid.c +++ b/lib/procuid.c @@ -26,15 +26,15 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_uid__l (glibtop *server, glibtop_proc_uid *buf, +glibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_PROC_UID, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_UID, 0); if (server->features & GLIBTOP_SYSDEPS_PROC_UID) { - glibtop_call__l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), + glibtop_call_l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), &pid, sizeof (glibtop_proc_uid), buf); } else { - glibtop_get_proc_uid__r (server, buf, pid); + glibtop_get_proc_uid_r (server, buf, pid); } } diff --git a/lib/read.c b/lib/read.c index d50b443e..e8b2e623 100644 --- a/lib/read.c +++ b/lib/read.c @@ -24,18 +24,18 @@ /* Reads some data from server. */ void -glibtop_read__l (glibtop *server, size_t size, void *buf) +glibtop_read_l (glibtop *server, size_t size, void *buf) { size_t ssize; - glibtop_init__r (&server, 0, 0); + 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)); } diff --git a/lib/read_data.c b/lib/read_data.c index 20e0b0e0..d11b28d9 100644 --- a/lib/read_data.c +++ b/lib/read_data.c @@ -25,23 +25,23 @@ /* Reads some data from server. */ void * -glibtop_read_data__l (glibtop *server) +glibtop_read_data_l (glibtop *server) { size_t size; void *ptr; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); if (read (server->input [0], &size, sizeof (size_t)) < 0) - glibtop_error__r (server, _("read data size: %s"), + glibtop_error_r (server, _("read data size: %s"), strerror (errno)); if (!size) return NULL; - 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"), + glibtop_error_r (server, _("read data %d bytes: %s"), size, strerror (errno)); return ptr; diff --git a/lib/sem_limits.c b/lib/sem_limits.c index 193b6f19..ca332d2c 100644 --- a/lib/sem_limits.c +++ b/lib/sem_limits.c @@ -25,14 +25,14 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_sem_limits__l (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits_l (glibtop *server, glibtop_sem_limits *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); if (server->features & GLIBTOP_SYSDEPS_SEM_LIMITS) { - glibtop_call__l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, sizeof (glibtop_sem_limits), buf); } else { - glibtop_get_sem_limits__r (server, buf); + glibtop_get_sem_limits_r (server, buf); } } diff --git a/lib/shm_limits.c b/lib/shm_limits.c index 8b226400..d59efdfc 100644 --- a/lib/shm_limits.c +++ b/lib/shm_limits.c @@ -25,14 +25,14 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__l (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits_l (glibtop *server, glibtop_shm_limits *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); if (server->features & GLIBTOP_SYSDEPS_SHM_LIMITS) { - glibtop_call__l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, sizeof (glibtop_shm_limits), buf); } else { - glibtop_get_shm_limits__r (server, buf); + glibtop_get_shm_limits_r (server, buf); } } diff --git a/lib/swap.c b/lib/swap.c index f6d7aeae..8e5d33b7 100644 --- a/lib/swap.c +++ b/lib/swap.c @@ -25,14 +25,14 @@ /* Provides information about swap usage. */ void -glibtop_get_swap__l (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_l (glibtop *server, glibtop_swap *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_SWAP, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_SWAP, 0); if (server->features & GLIBTOP_SYSDEPS_SWAP) { - glibtop_call__l (server, GLIBTOP_CMND_SWAP, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_SWAP, 0, NULL, sizeof (glibtop_swap), buf); } else { - glibtop_get_swap__r (server, buf); + glibtop_get_swap_r (server, buf); } } diff --git a/lib/uptime.c b/lib/uptime.c index a6ce1195..1dcf8ae0 100644 --- a/lib/uptime.c +++ b/lib/uptime.c @@ -26,14 +26,14 @@ /* Provides uptime and idle time. */ void -glibtop_get_uptime__l (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf) { - glibtop_init__r (&server, GLIBTOP_SYSDEPS_UPTIME, 0); + glibtop_init_r (&server, GLIBTOP_SYSDEPS_UPTIME, 0); if (server->features & GLIBTOP_SYSDEPS_UPTIME) { - glibtop_call__l (server, GLIBTOP_CMND_UPTIME, 0, NULL, + glibtop_call_l (server, GLIBTOP_CMND_UPTIME, 0, NULL, sizeof (glibtop_uptime), buf); } else { - glibtop_get_uptime__r (server, buf); + glibtop_get_uptime_r (server, buf); } } diff --git a/lib/write.c b/lib/write.c index e7913ef0..ac03ecae 100644 --- a/lib/write.c +++ b/lib/write.c @@ -24,15 +24,15 @@ /* Writes some data to server. */ void -glibtop_write__l (glibtop *server, size_t size, void *buf) +glibtop_write_l (glibtop *server, size_t size, void *buf) { - glibtop_init__r (&server, 0, 0); + 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)); } diff --git a/src/proxy/main.c b/src/proxy/main.c index 361d924b..a71df0a2 100644 --- a/src/proxy/main.c +++ b/src/proxy/main.c @@ -55,7 +55,7 @@ main(int argc, char *argv[]) glibtop_version (); - glibtop_open__l (&server, argv [0], 0, GLIBTOP_OPEN_NO_OVERRIDE); + 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(); @@ -122,58 +122,58 @@ main(int argc, char *argv[]) glibtop_output (0, NULL); break; case GLIBTOP_CMND_CPU: - glibtop_get_cpu__l (&server, &data.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_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_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_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_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_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_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_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); + 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); + glibtop_free_r (&server, ptr); break; case GLIBTOP_CMND_PROC_STATE: memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_state__l + glibtop_get_proc_state_l (&server, &data.proc_state, pid); glibtop_output (sizeof (glibtop_proc_state), &data.proc_state); @@ -181,7 +181,7 @@ main(int argc, char *argv[]) break; case GLIBTOP_CMND_PROC_UID: memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_uid__l + glibtop_get_proc_uid_l (&server, &data.proc_uid, pid); glibtop_output (sizeof (glibtop_proc_uid), &data.proc_uid); @@ -189,7 +189,7 @@ main(int argc, char *argv[]) break; case GLIBTOP_CMND_PROC_MEM: memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_mem__l + glibtop_get_proc_mem_l (&server, &data.proc_mem, pid); glibtop_output (sizeof (glibtop_proc_mem), &data.proc_mem); @@ -197,7 +197,7 @@ main(int argc, char *argv[]) break; case GLIBTOP_CMND_PROC_TIME: memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_time__l + glibtop_get_proc_time_l (&server, &data.proc_time, pid); glibtop_output (sizeof (glibtop_proc_time), &data.proc_time); @@ -205,7 +205,7 @@ main(int argc, char *argv[]) break; case GLIBTOP_CMND_PROC_SIGNAL: memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_signal__l + glibtop_get_proc_signal_l (&server, &data.proc_signal, pid); glibtop_output (sizeof (glibtop_proc_signal), &data.proc_signal); @@ -213,7 +213,7 @@ main(int argc, char *argv[]) break; case GLIBTOP_CMND_PROC_KERNEL: memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_kernel__l + glibtop_get_proc_kernel_l (&server, &data.proc_kernel, pid); glibtop_output (sizeof (glibtop_proc_kernel), &data.proc_kernel); @@ -221,7 +221,7 @@ main(int argc, char *argv[]) break; case GLIBTOP_CMND_PROC_SEGMENT: memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_segment__l + glibtop_get_proc_segment_l (&server, &data.proc_segment, pid); glibtop_output (sizeof (glibtop_proc_segment), &data.proc_segment); diff --git a/src/server/main.c b/src/server/main.c index f9afd7c7..a248c862 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) setreuid (uid, euid); setregid (gid, egid); - glibtop_open__r (&server, argv [0], 0, 0); + glibtop_open_r (&server, argv [0], 0, 0); if (setreuid (euid, uid)) _exit (1); @@ -148,42 +148,42 @@ int main(int argc, char *argv[]) break; case GLIBTOP_CMND_CPU: #if GLIBTOP_SUID_CPU - glibtop_get_cpu__p (&server, &data.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: #if GLIBTOP_SUID_MEM - glibtop_get_mem__p (&server, &data.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: #if GLIBTOP_SUID_SWAP - glibtop_get_swap__p (&server, &data.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: #if GLIBTOP_SUID_UPTIME - glibtop_get_uptime__p (&server, &data.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: #if GLIBTOP_SUID_LOADAVG - glibtop_get_loadavg__p (&server, &data.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: #if GLIBTOP_SUID_SHM_LIMITS - glibtop_get_shm_limits__p (&server, &data.shm_limits); + glibtop_get_shm_limits_p (&server, &data.shm_limits); #endif glibtop_output (sizeof (glibtop_shm_limits), &data.shm_limits); @@ -191,7 +191,7 @@ int main(int argc, char *argv[]) break; case GLIBTOP_CMND_MSG_LIMITS: #if GLIBTOP_SUID_MSG_LIMITS - glibtop_get_msg_limits__p (&server, &data.msg_limits); + glibtop_get_msg_limits_p (&server, &data.msg_limits); #endif glibtop_output (sizeof (glibtop_msg_limits), &data.msg_limits); @@ -199,7 +199,7 @@ int main(int argc, char *argv[]) break; case GLIBTOP_CMND_SEM_LIMITS: #if GLIBTOP_SUID_SEM_LIMITS - glibtop_get_sem_limits__p (&server, &data.sem_limits); + glibtop_get_sem_limits_p (&server, &data.sem_limits); #endif glibtop_output (sizeof (glibtop_sem_limits), &data.sem_limits); @@ -207,19 +207,19 @@ int main(int argc, char *argv[]) break; case GLIBTOP_CMND_PROCLIST: #if GLIBTOP_SUID_PROCLIST - ptr = glibtop_get_proclist__p (&server, &data.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)); #if GLIBTOP_SUID_PROC_STATE - glibtop_get_proc_state__p + glibtop_get_proc_state_p (&server, &data.proc_state, pid); #endif glibtop_output (sizeof (glibtop_proc_state), @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) case GLIBTOP_CMND_PROC_UID: memcpy (&pid, parameter, sizeof (pid_t)); #if GLIBTOP_SUID_PROC_UID - glibtop_get_proc_uid__p + glibtop_get_proc_uid_p (&server, &data.proc_uid, pid); #endif glibtop_output (sizeof (glibtop_proc_uid), @@ -239,7 +239,7 @@ int main(int argc, char *argv[]) case GLIBTOP_CMND_PROC_MEM: memcpy (&pid, parameter, sizeof (pid_t)); #if GLIBTOP_SUID_PROC_MEM - glibtop_get_proc_mem__p + glibtop_get_proc_mem_p (&server, &data.proc_mem, pid); #endif glibtop_output (sizeof (glibtop_proc_mem), @@ -249,7 +249,7 @@ int main(int argc, char *argv[]) case GLIBTOP_CMND_PROC_TIME: memcpy (&pid, parameter, sizeof (pid_t)); #if GLIBTOP_SUID_PROC_TIME - glibtop_get_proc_time__p + glibtop_get_proc_time_p (&server, &data.proc_time, pid); #endif glibtop_output (sizeof (glibtop_proc_time), @@ -259,7 +259,7 @@ int main(int argc, char *argv[]) case GLIBTOP_CMND_PROC_SIGNAL: memcpy (&pid, parameter, sizeof (pid_t)); #if GLIBTOP_SUID_PROC_SIGNAL - glibtop_get_proc_signal__p + glibtop_get_proc_signal_p (&server, &data.proc_signal, pid); #endif glibtop_output (sizeof (glibtop_proc_signal), @@ -269,7 +269,7 @@ int main(int argc, char *argv[]) case GLIBTOP_CMND_PROC_KERNEL: memcpy (&pid, parameter, sizeof (pid_t)); #if GLIBTOP_SUID_PROC_KERNEL - glibtop_get_proc_kernel__p + glibtop_get_proc_kernel_p (&server, &data.proc_kernel, pid); #endif glibtop_output (sizeof (glibtop_proc_kernel), @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) case GLIBTOP_CMND_PROC_SEGMENT: memcpy (&pid, parameter, sizeof (pid_t)); #if GLIBTOP_SUID_PROC_SEGMENT - glibtop_get_proc_segment__p + glibtop_get_proc_segment_p (&server, &data.proc_segment, pid); #endif glibtop_output (sizeof (glibtop_proc_segment), diff --git a/sysdeps/common/error.c b/sysdeps/common/error.c index 6f1f1963..2424d11c 100644 --- a/sysdeps/common/error.c +++ b/sysdeps/common/error.c @@ -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; diff --git a/sysdeps/common/sysdeps.c b/sysdeps/common/sysdeps.c index 883097e5..93767226 100644 --- a/sysdeps/common/sysdeps.c +++ b/sysdeps/common/sysdeps.c @@ -44,7 +44,7 @@ BIT_MASK(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; @@ -55,48 +55,48 @@ glibtop_get_sysdeps__r (glibtop *server, glibtop_sysdeps *buf) /* 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; } diff --git a/sysdeps/common/xmalloc.c b/sysdeps/common/xmalloc.c index 66458a18..fec5b99f 100644 --- a/sysdeps/common/xmalloc.c +++ b/sysdeps/common/xmalloc.c @@ -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); } diff --git a/sysdeps/linux/close.c b/sysdeps/linux/close.c index ff7ebea4..02f2e5b3 100644 --- a/sysdeps/linux/close.c +++ b/sysdeps/linux/close.c @@ -24,5 +24,5 @@ /* Closes pipe to gtop server. */ void -glibtop_close (glibtop *server) +glibtop_close_l (glibtop *server) { } diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index 804d29e9..058f3586 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -30,11 +30,11 @@ static const unsigned long _glibtop_sysdeps_cpu = /* Provides information about cpu usage. */ void -glibtop_get_cpu__s (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) { FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_cpu)); diff --git a/sysdeps/linux/init.c b/sysdeps/linux/init.c index e39cfd29..f491070f 100644 --- a/sysdeps/linux/init.c +++ b/sysdeps/linux/init.c @@ -26,15 +26,17 @@ static glibtop _glibtop_global_server; glibtop *glibtop_global_server = NULL; glibtop * -glibtop_init__r (glibtop **server, const unsigned long features, +glibtop_init_r (glibtop **server, const unsigned long features, const unsigned flags) { if (*server != NULL) return *server; + fprintf (stderr, "DEBUG: %s (%d)\n", __FILE__, __LINE__); + if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; - glibtop_open__r (glibtop_global_server, "glibtop", + glibtop_open_r (glibtop_global_server, "glibtop", features, flags); } diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c index d497a065..fbfa310f 100644 --- a/sysdeps/linux/loadavg.c +++ b/sysdeps/linux/loadavg.c @@ -28,11 +28,11 @@ static const unsigned long _glibtop_sysdeps_loadavg = /* Provides load load averange. */ void -glibtop_get_loadavg__s (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) { FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_loadavg)); diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index c7d78b1e..937a6c81 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -31,11 +31,11 @@ static const unsigned long _glibtop_sysdeps_mem = /* Provides information about memory usage. */ void -glibtop_get_mem__s (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) { FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_mem)); diff --git a/sysdeps/linux/msg_limits.c b/sysdeps/linux/msg_limits.c index 6a1be74e..8b0e6fdc 100644 --- a/sysdeps/linux/msg_limits.c +++ b/sysdeps/linux/msg_limits.c @@ -33,11 +33,11 @@ static const unsigned long _glibtop_sysdeps_msg_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__s (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) { struct msginfo msginfo; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_msg_limits)); diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index 2c89a579..69f00051 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -51,7 +51,7 @@ static void set_linux_version(void) { /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open__r (glibtop *server, const char *program_name, +glibtop_open_r (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { memset (server, 0, sizeof (glibtop)); diff --git a/sysdeps/linux/procdata.c b/sysdeps/linux/procdata.c index 5e2bd856..9226b7e0 100644 --- a/sysdeps/linux/procdata.c +++ b/sysdeps/linux/procdata.c @@ -78,14 +78,14 @@ BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN); /* Provides detailed information about a process. */ void -glibtop_get_procdata__s (glibtop *server, glibtop_procdata *buf, pid_t pid) +glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid) { char input [BUFSIZ], *tmp; struct stat statb; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_procdata)); diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c index dbd1dcb1..13e56b62 100644 --- a/sysdeps/linux/prockernel.c +++ b/sysdeps/linux/prockernel.c @@ -31,13 +31,13 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) +glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_kernel)); diff --git a/sysdeps/linux/proclist.c b/sysdeps/linux/proclist.c index e23ccbfe..4581cadc 100644 --- a/sysdeps/linux/proclist.c +++ b/sysdeps/linux/proclist.c @@ -49,7 +49,7 @@ static const unsigned long _glibtop_sysdeps_proclist = * On error, NULL is returned and buf->flags is zero. */ unsigned * -glibtop_get_proclist__s (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf) { DIR *proc; struct dirent *entry; @@ -60,7 +60,7 @@ glibtop_get_proclist__s (glibtop *server, glibtop_proclist *buf) struct stat statb; int len, i, ok; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proclist)); @@ -101,7 +101,7 @@ glibtop_get_proclist__s (glibtop *server, glibtop_proclist *buf) new_size = pids_size + BLOCK_SIZE; - pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + pids_chain = glibtop_realloc_r (server, pids_chain, new_size); memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE); @@ -133,7 +133,7 @@ glibtop_get_proclist__s (glibtop *server, glibtop_proclist *buf) new_size = pids_size + count * sizeof (unsigned); - pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + pids_chain = glibtop_realloc_r (server, pids_chain, new_size); memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index fb5db2b1..22e0c128 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -30,13 +30,13 @@ static const unsigned long _glibtop_sysdeps_proc_mem = /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) +glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_mem)); diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index 1ed83167..d5ce5652 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -31,14 +31,14 @@ static const unsigned long _glibtop_sysdeps_proc_segment = /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__s (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_segment)); diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c index 09754f62..6cd51788 100644 --- a/sysdeps/linux/procsignal.c +++ b/sysdeps/linux/procsignal.c @@ -29,13 +29,13 @@ static const unsigned long _glibtop_sysdeps_proc_signal = /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) +glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_signal)); diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index 91af0b4c..48d83209 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -31,14 +31,14 @@ static const unsigned long _glibtop_sysdeps_proc_state = /* Provides detailed information about a process. */ void -glibtop_get_proc_state__s (glibtop *server, glibtop_proc_state *buf, pid_t pid) +glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) { char input [BUFSIZ], *tmp; struct stat statb; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_state)); diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index 9d63a8a2..7393215a 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -31,13 +31,13 @@ static const unsigned long _glibtop_sysdeps_proc_time = /* Provides detailed information about a process. */ void -glibtop_get_proc_time__s (glibtop *server, glibtop_proc_time *buf, pid_t pid) +glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_time)); diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c index 3820f7fd..783589a1 100644 --- a/sysdeps/linux/procuid.c +++ b/sysdeps/linux/procuid.c @@ -35,13 +35,13 @@ static const unsigned long _glibtop_sysdeps_proc_uid = /* Provides detailed information about a process. */ void -glibtop_get_proc_uid__s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) +glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { char input [BUFSIZ], *tmp; int nread; FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_uid)); diff --git a/sysdeps/linux/sem_limits.c b/sysdeps/linux/sem_limits.c index 6b64c153..88176f0b 100644 --- a/sysdeps/linux/sem_limits.c +++ b/sysdeps/linux/sem_limits.c @@ -34,12 +34,12 @@ static unsigned long _glibtop_sysdeps_sem_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_sem_limits__s (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) { struct seminfo seminfo; union semun arg; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_sem_limits)); diff --git a/sysdeps/linux/shm_limits.c b/sysdeps/linux/shm_limits.c index 78f823c7..2849b22d 100644 --- a/sysdeps/linux/shm_limits.c +++ b/sysdeps/linux/shm_limits.c @@ -32,11 +32,11 @@ static unsigned long _glibtop_sysdeps_shm_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__s (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) { struct shminfo shminfo; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_shm_limits)); diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index 1439e5d1..73ee5000 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -29,11 +29,11 @@ static unsigned long _glibtop_sysdeps_swap = /* Provides information about swap usage. */ void -glibtop_get_swap__s (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) { FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_swap)); diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c index 8c3e3da0..26dd355b 100644 --- a/sysdeps/linux/uptime.c +++ b/sysdeps/linux/uptime.c @@ -28,11 +28,11 @@ static unsigned long _glibtop_sysdeps_uptime = /* Provides uptime and idle time. */ void -glibtop_get_uptime__s (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) { FILE *f; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_uptime)); diff --git a/sysdeps/osf1/cpu.c b/sysdeps/osf1/cpu.c index 0a6af83b..9cf71117 100644 --- a/sysdeps/osf1/cpu.c +++ b/sysdeps/osf1/cpu.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_cpu = /* Provides information about cpu usage. */ void -glibtop_get_cpu__s (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) { struct tbl_sysinfo sysinfo; int ret; diff --git a/sysdeps/osf1/init.c b/sysdeps/osf1/init.c index f6a9a506..43f7469c 100644 --- a/sysdeps/osf1/init.c +++ b/sysdeps/osf1/init.c @@ -26,7 +26,7 @@ static glibtop _glibtop_global_server; glibtop *glibtop_global_server = NULL; glibtop * -glibtop_init__r (glibtop **server) +glibtop_init_r (glibtop **server) { if (*server != NULL) return *server; diff --git a/sysdeps/osf1/loadavg.c b/sysdeps/osf1/loadavg.c index d80126ba..c7d4dab0 100644 --- a/sysdeps/osf1/loadavg.c +++ b/sysdeps/osf1/loadavg.c @@ -29,7 +29,7 @@ static const unsigned long _glibtop_sysdeps_loadavg = /* Provides load averange. */ void -glibtop_get_loadavg__s (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) { struct tbl_loadavg loadavg; int ret; diff --git a/sysdeps/osf1/mem.c b/sysdeps/osf1/mem.c index f3682802..83045519 100644 --- a/sysdeps/osf1/mem.c +++ b/sysdeps/osf1/mem.c @@ -36,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_mem = /* Provides information about memory usage. */ void -glibtop_get_mem__s (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) { vm_statistics_data_t vmstats; diff --git a/sysdeps/osf1/msg_limits.c b/sysdeps/osf1/msg_limits.c index 3dbc558b..becadb49 100644 --- a/sysdeps/osf1/msg_limits.c +++ b/sysdeps/osf1/msg_limits.c @@ -31,7 +31,7 @@ static const unsigned long _glibtop_sysdeps_msg_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__s (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) { int ret, value; diff --git a/sysdeps/osf1/procdata.c b/sysdeps/osf1/procdata.c index 4eb64d88..782b48d3 100644 --- a/sysdeps/osf1/procdata.c +++ b/sysdeps/osf1/procdata.c @@ -53,7 +53,7 @@ BIT_SHIFT(GLIBTOP_PROCDATA_NICE); static const unsigned long _glibtop_sysdeps_procdata_1 = 0; void -glibtop_get_procdata__r (glibtop *server, glibtop_procdata *buf, pid_t pid) +glibtop_get_procdata_r (glibtop *server, glibtop_procdata *buf, pid_t pid) { struct tbl_procinfo procinfo; task_basic_info_data_t taskinfo; diff --git a/sysdeps/osf1/prockernel.c b/sysdeps/osf1/prockernel.c index 93f47bb1..bd04ca29 100644 --- a/sysdeps/osf1/prockernel.c +++ b/sysdeps/osf1/prockernel.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel_r (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_kernel)); diff --git a/sysdeps/osf1/proclist.c b/sysdeps/osf1/proclist.c index 7659a9df..d8b0e48d 100644 --- a/sysdeps/osf1/proclist.c +++ b/sysdeps/osf1/proclist.c @@ -54,7 +54,7 @@ static const unsigned long _glibtop_sysdeps_proclist = /* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ unsigned * -glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_r (glibtop *server, glibtop_proclist *buf) { unsigned count = 0, total = 0; unsigned pids [BLOCK_COUNT], *pids_chain = NULL; @@ -103,7 +103,7 @@ glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) new_size = pids_size + BLOCK_SIZE; - pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + pids_chain = glibtop_realloc_r (server, pids_chain, new_size); memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE); @@ -133,7 +133,7 @@ glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) new_size = pids_size + count * sizeof (unsigned); - pids_chain = glibtop_realloc__r (server, pids_chain, new_size); + pids_chain = glibtop_realloc_r (server, pids_chain, new_size); memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); diff --git a/sysdeps/osf1/procmem.c b/sysdeps/osf1/procmem.c index 889a4a20..bb1e4795 100644 --- a/sysdeps/osf1/procmem.c +++ b/sysdeps/osf1/procmem.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem_r (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_mem)); diff --git a/sysdeps/osf1/procsegment.c b/sysdeps/osf1/procsegment.c index c0ffeb17..21cd4814 100644 --- a/sysdeps/osf1/procsegment.c +++ b/sysdeps/osf1/procsegment.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment_r (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_segment)); diff --git a/sysdeps/osf1/procsignal.c b/sysdeps/osf1/procsignal.c index 6c30ee66..d4674f8f 100644 --- a/sysdeps/osf1/procsignal.c +++ b/sysdeps/osf1/procsignal.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal_r (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_signal)); diff --git a/sysdeps/osf1/procstate.c b/sysdeps/osf1/procstate.c index b8ad5cec..acf32c2e 100644 --- a/sysdeps/osf1/procstate.c +++ b/sysdeps/osf1/procstate.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state_r (glibtop *server, glibtop_proc_state *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_state)); diff --git a/sysdeps/osf1/proctime.c b/sysdeps/osf1/proctime.c index ec81d2a0..d2417173 100644 --- a/sysdeps/osf1/proctime.c +++ b/sysdeps/osf1/proctime.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, +glibtop_get_proc_time_r (glibtop *server, glibtop_proc_time *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_time)); diff --git a/sysdeps/osf1/procuid.c b/sysdeps/osf1/procuid.c index 8635e8d3..57b49d5f 100644 --- a/sysdeps/osf1/procuid.c +++ b/sysdeps/osf1/procuid.c @@ -39,7 +39,7 @@ static const unsigned long _glibtop_sysdeps_proc_uid = (1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID); void -glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, +glibtop_get_proc_uid_r (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { struct tbl_procinfo procinfo; diff --git a/sysdeps/osf1/sem_limits.c b/sysdeps/osf1/sem_limits.c index b4bebd48..820bb457 100644 --- a/sysdeps/osf1/sem_limits.c +++ b/sysdeps/osf1/sem_limits.c @@ -31,7 +31,7 @@ static unsigned long _glibtop_sysdeps_sem_limits = /* Provides information about sysv sem limits. */ void -glibtop_get_sem_limits__s (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) { int ret, value; diff --git a/sysdeps/osf1/shm_limits.c b/sysdeps/osf1/shm_limits.c index 7f18869a..990d2cb4 100644 --- a/sysdeps/osf1/shm_limits.c +++ b/sysdeps/osf1/shm_limits.c @@ -30,7 +30,7 @@ static unsigned long _glibtop_sysdeps_shm_limits = /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__s (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) { int ret, value; diff --git a/sysdeps/osf1/swap.c b/sysdeps/osf1/swap.c index a7b3f7cb..22143db1 100644 --- a/sysdeps/osf1/swap.c +++ b/sysdeps/osf1/swap.c @@ -30,7 +30,7 @@ static unsigned long _glibtop_sysdeps_swap = /* Provides information about swap usage. */ void -glibtop_get_swap__s (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) { struct tbl_swapinfo swapinfo; int i; diff --git a/sysdeps/osf1/uptime.c b/sysdeps/osf1/uptime.c index 97776fbe..ea64f8c4 100644 --- a/sysdeps/osf1/uptime.c +++ b/sysdeps/osf1/uptime.c @@ -31,7 +31,7 @@ static unsigned long _glibtop_sysdeps_uptime = /* Provides uptime and idle time. */ void -glibtop_get_uptime__s (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) { struct tbl_sysinfo sysinfo; int ret; diff --git a/sysdeps/stub/cpu.c b/sysdeps/stub/cpu.c index cda12977..a7d31ad6 100644 --- a/sysdeps/stub/cpu.c +++ b/sysdeps/stub/cpu.c @@ -25,7 +25,7 @@ /* Provides information about cpu usage. */ void -glibtop_get_cpu__r (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_r (glibtop *server, glibtop_cpu *buf) { memset (buf, 0, sizeof (glibtop_cpu)); } diff --git a/sysdeps/stub/init.c b/sysdeps/stub/init.c index f6a9a506..43f7469c 100644 --- a/sysdeps/stub/init.c +++ b/sysdeps/stub/init.c @@ -26,7 +26,7 @@ static glibtop _glibtop_global_server; glibtop *glibtop_global_server = NULL; glibtop * -glibtop_init__r (glibtop **server) +glibtop_init_r (glibtop **server) { if (*server != NULL) return *server; diff --git a/sysdeps/stub/loadavg.c b/sysdeps/stub/loadavg.c index de6605e0..06365338 100644 --- a/sysdeps/stub/loadavg.c +++ b/sysdeps/stub/loadavg.c @@ -25,7 +25,7 @@ /* Provides load averange. */ void -glibtop_get_loadavg__r (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_r (glibtop *server, glibtop_loadavg *buf) { memset (buf, 0, sizeof (glibtop_loadavg)); } diff --git a/sysdeps/stub/mem.c b/sysdeps/stub/mem.c index 0410e2dd..eb930453 100644 --- a/sysdeps/stub/mem.c +++ b/sysdeps/stub/mem.c @@ -25,7 +25,7 @@ /* Provides information about memory usage. */ void -glibtop_get_mem__r (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_r (glibtop *server, glibtop_mem *buf) { memset (buf, 0, sizeof (glibtop_mem)); } diff --git a/sysdeps/stub/msg_limits.c b/sysdeps/stub/msg_limits.c index 62819042..f554a09e 100644 --- a/sysdeps/stub/msg_limits.c +++ b/sysdeps/stub/msg_limits.c @@ -24,7 +24,7 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__r (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits_r (glibtop *server, glibtop_msg_limits *buf) { memset (buf, 0, sizeof (glibtop_msg_limits)); } diff --git a/sysdeps/stub/prockernel.c b/sysdeps/stub/prockernel.c index 93f47bb1..bd04ca29 100644 --- a/sysdeps/stub/prockernel.c +++ b/sysdeps/stub/prockernel.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__r (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel_r (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_kernel)); diff --git a/sysdeps/stub/proclist.c b/sysdeps/stub/proclist.c index f3e0b993..cd7cf2d1 100644 --- a/sysdeps/stub/proclist.c +++ b/sysdeps/stub/proclist.c @@ -32,7 +32,7 @@ * each buf->size big. The total size is stored in buf->total. */ unsigned * -glibtop_get_proclist__r (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_r (glibtop *server, glibtop_proclist *buf) { memset (buf, 0, sizeof (glibtop_proclist)); return NULL; diff --git a/sysdeps/stub/procmem.c b/sysdeps/stub/procmem.c index 889a4a20..bb1e4795 100644 --- a/sysdeps/stub/procmem.c +++ b/sysdeps/stub/procmem.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__r (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem_r (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_mem)); diff --git a/sysdeps/stub/procsegment.c b/sysdeps/stub/procsegment.c index c0ffeb17..21cd4814 100644 --- a/sysdeps/stub/procsegment.c +++ b/sysdeps/stub/procsegment.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__r (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment_r (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_segment)); diff --git a/sysdeps/stub/procsignal.c b/sysdeps/stub/procsignal.c index 6c30ee66..d4674f8f 100644 --- a/sysdeps/stub/procsignal.c +++ b/sysdeps/stub/procsignal.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__r (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal_r (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_signal)); diff --git a/sysdeps/stub/procstate.c b/sysdeps/stub/procstate.c index b8ad5cec..acf32c2e 100644 --- a/sysdeps/stub/procstate.c +++ b/sysdeps/stub/procstate.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_state__r (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state_r (glibtop *server, glibtop_proc_state *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_state)); diff --git a/sysdeps/stub/proctime.c b/sysdeps/stub/proctime.c index ec81d2a0..d2417173 100644 --- a/sysdeps/stub/proctime.c +++ b/sysdeps/stub/proctime.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_time__r (glibtop *server, glibtop_proc_time *buf, +glibtop_get_proc_time_r (glibtop *server, glibtop_proc_time *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_time)); diff --git a/sysdeps/stub/procuid.c b/sysdeps/stub/procuid.c index 7fbb85fa..e3a7e741 100644 --- a/sysdeps/stub/procuid.c +++ b/sysdeps/stub/procuid.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_uid__r (glibtop *server, glibtop_proc_uid *buf, +glibtop_get_proc_uid_r (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_uid)); diff --git a/sysdeps/stub/sem_limits.c b/sysdeps/stub/sem_limits.c index 3768408b..81676129 100644 --- a/sysdeps/stub/sem_limits.c +++ b/sysdeps/stub/sem_limits.c @@ -24,7 +24,7 @@ /* Provides information about sysv sem limits. */ void -glibtop_get_sem_limits__r (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits_r (glibtop *server, glibtop_sem_limits *buf) { memset (buf, 0, sizeof (glibtop_sem_limits)); } diff --git a/sysdeps/stub/shm_limits.c b/sysdeps/stub/shm_limits.c index 52e801ba..aa671129 100644 --- a/sysdeps/stub/shm_limits.c +++ b/sysdeps/stub/shm_limits.c @@ -24,7 +24,7 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__r (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits_r (glibtop *server, glibtop_shm_limits *buf) { memset (buf, 0, sizeof (glibtop_shm_limits)); } diff --git a/sysdeps/stub/swap.c b/sysdeps/stub/swap.c index 8e0d046b..c58f0e5b 100644 --- a/sysdeps/stub/swap.c +++ b/sysdeps/stub/swap.c @@ -25,7 +25,7 @@ /* Provides information about swap usage. */ void -glibtop_get_swap__r (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_r (glibtop *server, glibtop_swap *buf) { memset (buf, 0, sizeof (glibtop_swap)); } diff --git a/sysdeps/stub/uptime.c b/sysdeps/stub/uptime.c index 5b9ea63f..0b33cca4 100644 --- a/sysdeps/stub/uptime.c +++ b/sysdeps/stub/uptime.c @@ -25,7 +25,7 @@ /* Provides uptime and idle time. */ void -glibtop_get_uptime__r (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_r (glibtop *server, glibtop_uptime *buf) { memset (buf, 0, sizeof (glibtop_uptime)); } diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c index 6ca965ae..68cf0003 100644 --- a/sysdeps/sun4/cpu.c +++ b/sysdeps/sun4/cpu.c @@ -30,12 +30,12 @@ static const unsigned long _glibtop_sysdeps_cpu = /* Provides information about cpu usage. */ void -glibtop_get_cpu__p (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) { long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES]; int i; - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_cpu)); diff --git a/sysdeps/sun4/init.c b/sysdeps/sun4/init.c index e39cfd29..5613d1cb 100644 --- a/sysdeps/sun4/init.c +++ b/sysdeps/sun4/init.c @@ -26,7 +26,7 @@ static glibtop _glibtop_global_server; glibtop *glibtop_global_server = NULL; glibtop * -glibtop_init__r (glibtop **server, const unsigned long features, +glibtop_init_r (glibtop **server, const unsigned long features, const unsigned flags) { if (*server != NULL) @@ -34,7 +34,7 @@ glibtop_init__r (glibtop **server, const unsigned long features, if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; - glibtop_open__r (glibtop_global_server, "glibtop", + glibtop_open_r (glibtop_global_server, "glibtop", features, flags); } diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c index 07d4c0e9..0e553b4a 100644 --- a/sysdeps/sun4/loadavg.c +++ b/sysdeps/sun4/loadavg.c @@ -25,9 +25,9 @@ /* Provides load averange. */ void -glibtop_get_loadavg__p (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_loadavg)); } diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c index ab602e70..6f3b74c2 100644 --- a/sysdeps/sun4/mem.c +++ b/sysdeps/sun4/mem.c @@ -33,9 +33,9 @@ static const unsigned long _glibtop_sysdeps_mem = /* Provides information about memory usage. */ void -glibtop_get_mem__p (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_p (glibtop *server, glibtop_mem *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_mem)); diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c index eca74df9..5a8fff58 100644 --- a/sysdeps/sun4/msg_limits.c +++ b/sysdeps/sun4/msg_limits.c @@ -24,9 +24,9 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits__p (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_msg_limits)); } diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index 0193c00f..4e5cc6bd 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -57,7 +57,7 @@ struct nlist _glibtop_nlist[] = { /* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ void -glibtop_open__r (glibtop *server, const char *program_name, +glibtop_open_r (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { register int pagesize; @@ -77,14 +77,14 @@ glibtop_open__r (glibtop *server, const char *program_name, server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "libgtop"); if (server->machine.kd == NULL) - glibtop_error__r (server, "kvm_open: %s", strerror (errno)); + glibtop_error_r (server, "kvm_open: %s", strerror (errno)); /* get the list of symbols we want to access in the kernel */ server->machine.nlist_count = kvm_nlist (server->machine.kd, _glibtop_nlist); if (server->machine.nlist_count < 0) - glibtop_error__r (server, "nlist: %s", strerror (errno)); + glibtop_error_r (server, "nlist: %s", strerror (errno)); #ifdef MULTIPROCESSOR /* were ncpu and xp_time not found in the nlist? */ @@ -130,7 +130,7 @@ glibtop_open__r (glibtop *server, const char *program_name, server->machine.count = server->machine.bytesize / sizeof (struct page); server->machine.physpage = - (struct page *) glibtop_malloc__r (server, server->machine.bytesize); + (struct page *) glibtop_malloc_r (server, server->machine.bytesize); /* get the page size with "getpagesize" and calculate pageshift from it */ @@ -183,12 +183,12 @@ _glibtop_check_nlist (void *server, register struct nlist *nlst) #ifdef i386 if (nlst->n_value == 0) { - glibtop_error__r (server, "kernel: no symbol named `%s'", nlst->n_name); + glibtop_error_r (server, "kernel: no symbol named `%s'", nlst->n_name); not_found++; } #else if (nlst->n_type == 0) { - glibtop_error__r (server, "kernel: no symbol named `%s'", nlst->n_name); + glibtop_error_r (server, "kernel: no symbol named `%s'", nlst->n_name); not_found++; } #endif @@ -210,7 +210,7 @@ _glibtop_getkval (void *void_server, unsigned long offset, int *ptr, int size, c { if (*refstr == '!') return 0; - glibtop_error__r (server, "kvm_read(%s): %s", + glibtop_error_r (server, "kvm_read(%s): %s", refstr, strerror (errno)); } diff --git a/sysdeps/sun4/procdata.c b/sysdeps/sun4/procdata.c index fa32152e..d38d5b3e 100644 --- a/sysdeps/sun4/procdata.c +++ b/sysdeps/sun4/procdata.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_procdata__p (glibtop *server, glibtop_procdata *buf, pid_t pid) +glibtop_get_procdata_p (glibtop *server, glibtop_procdata *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_procdata)); } diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c index ab13bb95..f8596820 100644 --- a/sysdeps/sun4/prockernel.c +++ b/sysdeps/sun4/prockernel.c @@ -25,10 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel__p (glibtop *server, glibtop_proc_kernel *buf, +glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_kernel)); } diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c index 66778f57..0623dd23 100644 --- a/sysdeps/sun4/proclist.c +++ b/sysdeps/sun4/proclist.c @@ -32,9 +32,9 @@ * each buf->size big. The total size is stored in buf->total. */ unsigned * -glibtop_get_proclist__p (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proclist)); return NULL; diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c index 1e018270..c6971c8b 100644 --- a/sysdeps/sun4/procmem.c +++ b/sysdeps/sun4/procmem.c @@ -25,10 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_mem__p (glibtop *server, glibtop_proc_mem *buf, +glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_mem)); } diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c index 5793d386..d0d957c3 100644 --- a/sysdeps/sun4/procsegment.c +++ b/sysdeps/sun4/procsegment.c @@ -25,10 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_segment__p (glibtop *server, glibtop_proc_segment *buf, +glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_segment)); } diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c index a3e905ae..bee1dc5f 100644 --- a/sysdeps/sun4/procsignal.c +++ b/sysdeps/sun4/procsignal.c @@ -25,10 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_signal__p (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_signal)); } diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c index a0ffb312..ddc6d92c 100644 --- a/sysdeps/sun4/procstate.c +++ b/sysdeps/sun4/procstate.c @@ -25,10 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_state__p (glibtop *server, glibtop_proc_state *buf, +glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, pid_t pid) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_state)); } diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c index 8bd4f728..32b237db 100644 --- a/sysdeps/sun4/proctime.c +++ b/sysdeps/sun4/proctime.c @@ -25,10 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_time__p (glibtop *server, glibtop_proc_time *buf, +glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, pid_t pid) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_time)); } diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c index a4c15f8f..bf132521 100644 --- a/sysdeps/sun4/procuid.c +++ b/sysdeps/sun4/procuid.c @@ -25,10 +25,10 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_uid__p (glibtop *server, glibtop_proc_uid *buf, +glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_uid)); } diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c index ef4df709..1e7eaa0f 100644 --- a/sysdeps/sun4/sem_limits.c +++ b/sysdeps/sun4/sem_limits.c @@ -24,9 +24,9 @@ /* Provides information about sysv sem limits. */ void -glibtop_get_sem_limits__p (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_sem_limits)); } diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c index b51528b1..bb7facb7 100644 --- a/sysdeps/sun4/shm_limits.c +++ b/sysdeps/sun4/shm_limits.c @@ -24,9 +24,9 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits__p (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_shm_limits)); } diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c index c1c3f2a8..d6a402fc 100644 --- a/sysdeps/sun4/swap.c +++ b/sysdeps/sun4/swap.c @@ -25,9 +25,9 @@ /* Provides information about swap usage. */ void -glibtop_get_swap__p (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_swap)); } diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c index 58b87a8e..e1a6cc51 100644 --- a/sysdeps/sun4/uptime.c +++ b/sysdeps/sun4/uptime.c @@ -25,9 +25,9 @@ /* Provides uptime and idle time. */ void -glibtop_get_uptime__p (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) { - glibtop_init__r (&server, 0, 0); + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_uptime)); } From 9c9ad03d60e25892821169680ff4490a0bf48592 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 7 Jun 1998 20:38:02 +0000 Subject: [PATCH 0097/2539] New file. 1998-06-07 Martin Baulig * sysdeps/linux/glibtop_machine.h: New file. * sysdeps/linux/*.c: Performance optimizations. We now use `open' and `read' instead of `fopen' and `fscanf'. --- sysdeps/linux/cpu.c | 32 ++++++++++-- sysdeps/linux/glibtop_machine.h | 43 ++++++++++++++++ sysdeps/linux/loadavg.c | 32 ++++++++++-- sysdeps/linux/mem.c | 35 ++++++++++--- sysdeps/linux/prockernel.c | 53 +++++++++++++------- sysdeps/linux/procmem.c | 85 +++++++++++++++++++------------ sysdeps/linux/procsegment.c | 89 ++++++++++++++++++++------------- sysdeps/linux/procsignal.c | 53 +++++++++++++------- sysdeps/linux/procstate.c | 44 ++++++++++------ sysdeps/linux/proctime.c | 53 +++++++++++++------- sysdeps/linux/procuid.c | 83 ++++++++++++++++++------------ sysdeps/linux/swap.c | 32 ++++++++++-- sysdeps/linux/uptime.c | 21 ++++++-- 13 files changed, 456 insertions(+), 199 deletions(-) create mode 100644 sysdeps/linux/glibtop_machine.h diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index 058f3586..6dc68c6a 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_cpu = @@ -29,10 +30,13 @@ static const unsigned long _glibtop_sysdeps_cpu = /* Provides information about cpu usage. */ +#define FILENAME "/proc/stat" + void glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) { - FILE *f; + char buffer [BUFSIZ]; + int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -40,15 +44,33 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) buf->flags = _glibtop_sysdeps_cpu; - f = fopen ("/proc/stat", "r"); - if (!f) return; +#ifdef GLIBTOP_CACHE_OPEN + fd = server->machine.fd_stat; +#endif + if (fd == 0) { + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); + } else { + lseek (fd, 0, SEEK_SET); + } - fscanf (f, "cpu %lu %lu %lu %lu\n", + ret = read (fd, buffer, BUFSIZ); + if (ret == -1) + glibtop_error_r (server, "read (%s): %s", + FILENAME, strerror (errno)); + + sscanf (buffer, "cpu %lu %lu %lu %lu\n", &buf->user, &buf->nice, &buf->sys, &buf->idle); buf->total = buf->user + buf->nice + buf->sys + buf->idle; buf->frequency = 100; - fclose (f); +#ifdef GLIBTOP_CACHE_OPEN + server->machine.fd_stat = fd; +#else + close (fd); +#endif } diff --git a/sysdeps/linux/glibtop_machine.h b/sysdeps/linux/glibtop_machine.h new file mode 100644 index 00000000..600d562c --- /dev/null +++ b/sysdeps/linux/glibtop_machine.h @@ -0,0 +1,43 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_MACHINE_H__ +#define __GLIBTOP_MACHINE_H__ + +#include +#include + +__BEGIN_DECLS + +typedef struct _glibtop_machine glibtop_machine; + +struct _glibtop_machine +{ + pid_t last_pid; + int no_update; + int fd_stat, fd_meminfo, fd_loadavg; + char proc_stat [BUFSIZ], proc_statm [BUFSIZ]; + char proc_status [BUFSIZ]; +}; + +__END_DECLS + +#endif diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c index fbfa310f..96565610 100644 --- a/sysdeps/linux/loadavg.c +++ b/sysdeps/linux/loadavg.c @@ -20,17 +20,21 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_loadavg = (1 << GLIBTOP_LOADAVG_LOADAVG); +#define FILENAME "/proc/loadavg" + /* Provides load load averange. */ void glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) { - FILE *f; + char buffer [BUFSIZ]; + int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -38,11 +42,29 @@ glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) buf->flags = _glibtop_sysdeps_loadavg; - f = fopen ("/proc/loadavg", "r"); - if (!f) return; +#ifdef GLIBTOP_CACHE_OPEN + fd = server->machine.fd_loadavg; +#endif + if (fd == 0) { + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); + } else { + lseek (fd, 0, SEEK_SET); + } - fscanf (f, "%lf %lf %lf\n", + ret = read (fd, buffer, BUFSIZ); + if (ret == -1) + glibtop_error_r (server, "read (%s): %s", + FILENAME, strerror (errno)); + + sscanf (buffer, "%lf %lf %lf\n", &buf->loadavg [0], &buf->loadavg [1], &buf->loadavg [2]); - fclose (f); +#ifdef GLIBTOP_CACHE_OPEN + server->machine.fd_loadavg = fd; +#else + close (fd); +#endif } diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index 937a6c81..41b54323 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_mem = @@ -28,12 +29,15 @@ static const unsigned long _glibtop_sysdeps_mem = (1 << GLIBTOP_MEM_BUFFER) + (1 << GLIBTOP_MEM_CACHED) + (1 << GLIBTOP_MEM_USER); +#define FILENAME "/proc/meminfo" + /* Provides information about memory usage. */ void glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) { - FILE *f; + char buffer [BUFSIZ]; + int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -41,13 +45,32 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) buf->flags = _glibtop_sysdeps_mem; - f = fopen ("/proc/meminfo", "r"); - if (!f) return; +#ifdef GLIBTOP_CACHE_OPEN + fd = server->machine.fd_meminfo; +#endif + if (fd == 0) { + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); + } else { + lseek (fd, 0, SEEK_SET); + } - fscanf (f, "%*[^\n]\nMem: %lu %lu %lu %lu %lu %lu\n", - &buf->total, &buf->used, &buf->free, &buf->shared, &buf->buffer, &buf->cached); + ret = read (fd, buffer, BUFSIZ); + if (ret == -1) + glibtop_error_r (server, "read (%s): %s", + FILENAME, strerror (errno)); + + sscanf (buffer, "%*[^\n]\nMem: %lu %lu %lu %lu %lu %lu\n", + &buf->total, &buf->used, &buf->free, &buf->shared, + &buf->buffer, &buf->cached); buf->user = buf->total - buf->free - buf->shared - buf->buffer; - fclose (f); +#ifdef GLIBTOP_CACHE_OPEN + server->machine.fd_meminfo = fd; +#else + close (fd); +#endif } diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c index 13e56b62..e9fc8eb9 100644 --- a/sysdeps/linux/prockernel.c +++ b/sysdeps/linux/prockernel.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_proc_kernel = @@ -33,9 +34,8 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = void glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { - char input [BUFSIZ], *tmp; - int nread; - FILE *f; + char buffer [BUFSIZ], input [BUFSIZ], *tmp; + int fd = 0, nread; glibtop_init_r (&server, 0, 0); @@ -47,24 +47,41 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) return; } - sprintf (input, "/proc/%d/stat", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (pid != server->machine.last_pid) { + server->machine.last_pid = pid; + server->machine.no_update = 0; } - - input [nread] = 0; - + + if (!server->machine.no_update) { + server->machine.proc_status [0] = 0; + server->machine.proc_statm [0] = 0; + server->machine.proc_stat [0] = 0; + } + + if (server->machine.proc_stat [0]) { + strcpy (buffer, server->machine.proc_stat); + } else { + sprintf (input, "/proc/%d/stat", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); + + buffer [nread] = 0; + strcpy (server->machine.proc_stat, buffer); + close (fd); + } + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (input, ')'); + tmp = strrchr (buffer, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ @@ -75,8 +92,6 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) &buf->k_flags, &buf->min_flt, &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, &buf->kstk_esp, &buf->kstk_eip, &buf->wchan); - - fclose (f); buf->flags = _glibtop_sysdeps_proc_kernel; } diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index 22e0c128..fb03466e 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_proc_mem = @@ -32,9 +33,8 @@ static const unsigned long _glibtop_sysdeps_proc_mem = void glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { - char input [BUFSIZ], *tmp; - int nread; - FILE *f; + char buffer [BUFSIZ], input [BUFSIZ], *tmp; + int fd = 0, nread; glibtop_init_r (&server, 0, 0); @@ -46,24 +46,41 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) return; } - sprintf (input, "/proc/%d/stat", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (pid != server->machine.last_pid) { + server->machine.last_pid = pid; + server->machine.no_update = 0; + } + + if (!server->machine.no_update) { + server->machine.proc_status [0] = 0; + server->machine.proc_statm [0] = 0; + server->machine.proc_stat [0] = 0; + } + + if (server->machine.proc_stat [0]) { + strcpy (buffer, server->machine.proc_stat); + } else { + sprintf (input, "/proc/%d/stat", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); + + buffer [nread] = 0; + strcpy (server->machine.proc_stat, buffer); + close (fd); } - - input [nread] = 0; /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (input, ')'); + tmp = strrchr (buffer, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -71,26 +88,28 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) "%*d %*d %*d %*d %*d %*d %*u %*u %*d %lu " "%lu %lu", &buf->vsize, &buf->rss, &buf->rss_rlim); - fclose (f); + if (server->machine.proc_statm [0]) { + strcpy (buffer, server->machine.proc_statm); + } else { + sprintf (input, "/proc/%d/statm", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - sprintf (input, "/proc/%d/statm", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + buffer [nread] = 0; + strcpy (server->machine.proc_statm, buffer); + close (fd); } - - input [nread] = 0; - - sscanf (input, "%ld %ld %ld", + + sscanf (buffer, "%ld %ld %ld", &buf->size, &buf->resident, &buf->share); - fclose (f); - buf->flags = _glibtop_sysdeps_proc_mem; } diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index d5ce5652..1ecefa2a 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_proc_segment = @@ -32,11 +33,10 @@ static const unsigned long _glibtop_sysdeps_proc_segment = void glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) + pid_t pid) { - char input [BUFSIZ], *tmp; - int nread; - FILE *f; + char buffer [BUFSIZ], input [BUFSIZ], *tmp; + int fd = 0, nread; glibtop_init_r (&server, 0, 0); @@ -48,24 +48,41 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, return; } - sprintf (input, "/proc/%d/stat", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (pid != server->machine.last_pid) { + server->machine.last_pid = pid; + server->machine.no_update = 0; } - - input [nread] = 0; - + + if (!server->machine.no_update) { + server->machine.proc_status [0] = 0; + server->machine.proc_statm [0] = 0; + server->machine.proc_stat [0] = 0; + } + + if (server->machine.proc_stat [0]) { + strcpy (buffer, server->machine.proc_stat); + } else { + sprintf (input, "/proc/%d/stat", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); + + buffer [nread] = 0; + strcpy (server->machine.proc_stat, buffer); + close (fd); + } + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (input, ')'); + tmp = strrchr (buffer, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -74,26 +91,28 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, "%*u %*u %lu %lu %lu", &buf->start_code, &buf->end_code, &buf->start_stack); - fclose (f); - - sprintf (input, "/proc/%d/statm", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (server->machine.proc_statm [0]) { + strcpy (buffer, server->machine.proc_statm); + } else { + sprintf (input, "/proc/%d/statm", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); + + buffer [nread] = 0; + strcpy (server->machine.proc_statm, buffer); + close (fd); } - input [nread] = 0; - - sscanf (input, "%*d %*d %*d %ld %ld %ld %ld", + sscanf (buffer, "%*d %*d %*d %ld %ld %ld %ld", &buf->trs, &buf->lrs, &buf->drs, &buf->dt); - fclose (f); - buf->flags = _glibtop_sysdeps_proc_segment; } diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c index 6cd51788..7ae451a1 100644 --- a/sysdeps/linux/procsignal.c +++ b/sysdeps/linux/procsignal.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_proc_signal = @@ -31,9 +32,8 @@ static const unsigned long _glibtop_sysdeps_proc_signal = void glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { - char input [BUFSIZ], *tmp; - int nread; - FILE *f; + char buffer [BUFSIZ], input [BUFSIZ], *tmp; + int fd = 0, nread; glibtop_init_r (&server, 0, 0); @@ -45,24 +45,41 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) return; } - sprintf (input, "/proc/%d/stat", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (pid != server->machine.last_pid) { + server->machine.last_pid = pid; + server->machine.no_update = 0; } - - input [nread] = 0; - + + if (!server->machine.no_update) { + server->machine.proc_status [0] = 0; + server->machine.proc_statm [0] = 0; + server->machine.proc_stat [0] = 0; + } + + if (server->machine.proc_stat [0]) { + strcpy (buffer, server->machine.proc_stat); + } else { + sprintf (input, "/proc/%d/stat", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); + + buffer [nread] = 0; + strcpy (server->machine.proc_stat, buffer); + close (fd); + } + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (input, ')'); + tmp = strrchr (buffer, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -72,7 +89,5 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) &buf->signal, &buf->blocked, &buf->sigignore, &buf->sigcatch); - fclose (f); - buf->flags = _glibtop_sysdeps_proc_signal; } diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index 48d83209..4a504961 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include @@ -33,10 +34,9 @@ static const unsigned long _glibtop_sysdeps_proc_state = void glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) { - char input [BUFSIZ], *tmp; + char buffer [BUFSIZ], input [BUFSIZ], *tmp; struct stat statb; - int nread; - FILE *f; + int fd, nread; glibtop_init_r (&server, 0, 0); @@ -48,6 +48,12 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) return; } + server->machine.last_pid = pid; + server->machine.no_update = 0; + server->machine.proc_status [0] = 0; + server->machine.proc_statm [0] = 0; + server->machine.proc_stat [0] = 0; + sprintf (input, "/proc/%d/stat", pid); /* IMPORTANT NOTICE: For security reasons it is extremely important @@ -61,28 +67,34 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) buf->uid = statb.st_uid; buf->gid = statb.st_gid; + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; - } - - input [nread] = 0; + buffer [nread] = 0; + + server->machine.no_update = 1; + server->machine.last_pid = pid; + strcpy (server->machine.proc_stat, buffer); /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (input, ')'); + tmp = strrchr (buffer, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ memset (buf->cmd, 0, sizeof (buf->cmd)); - sscanf (input, "%d (%39c", &pid, buf->cmd); + sscanf (buffer, "%d (%39c", &pid, buf->cmd); sscanf(tmp + 2, "%c", &buf->state); /* skip space after ')' too */ + close (fd); + buf->flags = _glibtop_sysdeps_proc_state; } diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index 7393215a..949deb2a 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_proc_time = @@ -33,9 +34,8 @@ static const unsigned long _glibtop_sysdeps_proc_time = void glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) { - char input [BUFSIZ], *tmp; - int nread; - FILE *f; + char buffer [BUFSIZ], input [BUFSIZ], *tmp; + int fd = 0, nread; glibtop_init_r (&server, 0, 0); @@ -47,24 +47,41 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) return; } - sprintf (input, "/proc/%d/stat", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (pid != server->machine.last_pid) { + server->machine.last_pid = pid; + server->machine.no_update = 0; } - - input [nread] = 0; - + + if (!server->machine.no_update) { + server->machine.proc_status [0] = 0; + server->machine.proc_statm [0] = 0; + server->machine.proc_stat [0] = 0; + } + + if (server->machine.proc_stat [0]) { + strcpy (buffer, server->machine.proc_stat); + } else { + sprintf (input, "/proc/%d/stat", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); + + buffer [nread] = 0; + strcpy (server->machine.proc_stat, buffer); + close (fd); + } + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (input, ')'); + tmp = strrchr (buffer, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -73,7 +90,5 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, &buf->timeout, &buf->it_real_value, &buf->start_time); - fclose (f); - buf->flags = _glibtop_sysdeps_proc_time; } diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c index 783589a1..0c25bddd 100644 --- a/sysdeps/linux/procuid.c +++ b/sysdeps/linux/procuid.c @@ -20,6 +20,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static const unsigned long _glibtop_sysdeps_proc_uid = @@ -37,9 +38,8 @@ static const unsigned long _glibtop_sysdeps_proc_uid = void glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { - char input [BUFSIZ], *tmp; - int nread; - FILE *f; + char buffer [BUFSIZ], input [BUFSIZ], *tmp; + int fd = 0, nread; glibtop_init_r (&server, 0, 0); @@ -51,23 +51,40 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) return; } - sprintf (input, "/proc/%d/status", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (pid != server->machine.last_pid) { + server->machine.last_pid = pid; + server->machine.no_update = 0; } + + if (!server->machine.no_update) { + server->machine.proc_status [0] = 0; + server->machine.proc_statm [0] = 0; + server->machine.proc_stat [0] = 0; + } + + if (server->machine.proc_status [0]) { + strcpy (buffer, server->machine.proc_status); + } else { + sprintf (input, "/proc/%d/status", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - input [nread] = 0; + buffer [nread] = 0; + strcpy (server->machine.proc_status, buffer); + close (fd); + } /* Search substring 'Pid:' */ - tmp = strstr (input, "Pid:"); + tmp = strstr (buffer, "Pid:"); if (tmp == NULL) return; @@ -75,26 +92,30 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) "Gid: %u %u %*u %*u\n", &buf->pid, &buf->ppid, &buf->uid, &buf->euid, &buf->gid, &buf->egid); - fclose (f); - - sprintf (input, "/proc/%d/stat", pid); - - f = fopen (input, "r"); - if (!f) return; - - nread = fread (input, 1, BUFSIZ, f); - - if (nread < 0) { - fclose (f); - return; + if (server->machine.proc_stat [0]) { + strcpy (buffer, server->machine.proc_stat); + } else { + sprintf (input, "/proc/%d/stat", pid); + + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); + + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); + + buffer [nread] = 0; + strcpy (server->machine.proc_stat, buffer); + close (fd); } - input [nread] = 0; - /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (input, ')'); + tmp = strrchr (buffer, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -116,7 +137,5 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) /* when tty wasn't full devno */ buf->tty = 4*0x100 + buf->tty; - fclose (f); - buf->flags = _glibtop_sysdeps_proc_uid; } diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index 73ee5000..fd8b29f7 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -20,18 +20,22 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static unsigned long _glibtop_sysdeps_swap = (1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) + (1 << GLIBTOP_SWAP_FREE); +#define FILENAME "/proc/meminfo" + /* Provides information about swap usage. */ void glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) { - FILE *f; + char buffer [BUFSIZ]; + int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -39,11 +43,29 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) buf->flags = _glibtop_sysdeps_swap; - f = fopen ("/proc/meminfo", "r"); - if (!f) return; +#ifdef GLIBTOP_CACHE_OPEN + fd = server->machine.fd_meminfo; +#endif + if (fd == 0) { + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); + } else { + lseek (fd, 0, SEEK_SET); + } - fscanf (f, "%*[^\n]\n%*[^\n]\nSwap: %lu %lu %lu\n", + ret = read (fd, buffer, BUFSIZ); + if (ret == -1) + glibtop_error_r (server, "read (%s): %s", + FILENAME, strerror (errno)); + + sscanf (buffer, "%*[^\n]\n%*[^\n]\nSwap: %lu %lu %lu\n", &buf->total, &buf->used, &buf->free); - fclose (f); +#ifdef GLIBTOP_CACHE_OPEN + server->machine.fd_meminfo = fd; +#else + close (fd); +#endif } diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c index 26dd355b..17b263cb 100644 --- a/sysdeps/linux/uptime.c +++ b/sysdeps/linux/uptime.c @@ -20,17 +20,21 @@ Boston, MA 02111-1307, USA. */ #include +#include #include static unsigned long _glibtop_sysdeps_uptime = (1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME); +#define FILENAME "/proc/uptime" + /* Provides uptime and idle time. */ void glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) { - FILE *f; + int fd, ret; + char buffer [BUFSIZ]; glibtop_init_r (&server, 0, 0); @@ -38,10 +42,17 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) buf->flags = _glibtop_sysdeps_uptime; - f = fopen ("/proc/uptime", "r"); - if (!f) return; + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); - fscanf (f, "%lf %lf\n", &buf->uptime, &buf->idletime); + ret = read (fd, buffer, BUFSIZ); + if (ret == -1) + glibtop_error_r (server, "read (%s): %s", + FILENAME, strerror (errno)); - fclose (f); + sscanf (buffer, "%lf %lf\n", &buf->uptime, &buf->idletime); + + close (fd); } From 691cd81192c5a8d5c24011ad071fca0fdb302bff Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 7 Jun 1998 20:42:53 +0000 Subject: [PATCH 0098/2539] Bug fix. --- sysdeps/linux/procstate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index 4a504961..87656e1e 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -80,7 +80,6 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) buffer [nread] = 0; - server->machine.no_update = 1; server->machine.last_pid = pid; strcpy (server->machine.proc_stat, buffer); From 4cb95e1477b039e2227b6286d8fbb6fb8a61ad8d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 7 Jun 1998 20:46:05 +0000 Subject: [PATCH 0099/2539] New file. 1998-06-07 Martin Baulig * examples/ChangeLog: New file. --- ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3ee557f6..2d7d3739 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 1998-06-07 Martin Baulig + * 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. From 28324c38cc08f5b9b9c05160800298cba49022df Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 7 Jun 1998 20:46:21 +0000 Subject: [PATCH 0100/2539] Disable optimize. 1998-06-07 Martin Baulig * 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. --- examples/ChangeLog | 7 ++++ examples/Makefile.am | 2 +- examples/first.c | 97 ++++++++++++++++++++++++++++++-------------- 3 files changed, 75 insertions(+), 31 deletions(-) create mode 100644 examples/ChangeLog diff --git a/examples/ChangeLog b/examples/ChangeLog new file mode 100644 index 00000000..c4476e14 --- /dev/null +++ b/examples/ChangeLog @@ -0,0 +1,7 @@ +1998-06-07 Martin Baulig + + * 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. diff --git a/examples/Makefile.am b/examples/Makefile.am index 34f06fa1..2eb3efc2 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -6,7 +6,7 @@ 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@ diff --git a/examples/first.c b/examples/first.c index 0f31308c..741f7c7e 100644 --- a/examples/first.c +++ b/examples/first.c @@ -29,57 +29,70 @@ #include #include +#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 (); - 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, @@ -87,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", @@ -134,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", @@ -153,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, @@ -161,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, @@ -170,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, @@ -187,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, @@ -198,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", @@ -217,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, @@ -225,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, @@ -234,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, @@ -251,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, @@ -262,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", @@ -281,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, @@ -289,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, @@ -298,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, @@ -315,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, @@ -324,5 +359,7 @@ main (int argc, char *argv []) data.proc_segment.start_code, data.proc_segment.end_code, data.proc_segment.start_stack); + fcloseall (); + exit (0); } From be91463190323d9208bb64c682f8e3867dc81ff7 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 7 Jun 1998 21:14:30 +0000 Subject: [PATCH 0101/2539] More profiling stuff. --- sysdeps/linux/cpu.c | 10 +++++++--- sysdeps/linux/glibtop_machine.h | 13 +++++++++++++ sysdeps/linux/loadavg.c | 9 +++++---- sysdeps/linux/mem.c | 15 +++++++++++---- sysdeps/linux/swap.c | 11 ++++++++--- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index 6dc68c6a..202a8476 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -35,7 +35,7 @@ static const unsigned long _glibtop_sysdeps_cpu = void glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) { - char buffer [BUFSIZ]; + char buffer [BUFSIZ], *tmp; int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -61,8 +61,12 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) glibtop_error_r (server, "read (%s): %s", FILENAME, strerror (errno)); - sscanf (buffer, "cpu %lu %lu %lu %lu\n", - &buf->user, &buf->nice, &buf->sys, &buf->idle); + tmp = strchr (buffer, '\n'); + tmp = skip_token (tmp); /* "cpu" */ + buf->user = strtoul (tmp, &tmp, 10); + buf->nice = strtoul (tmp, &tmp, 10); + buf->sys = strtoul (tmp, &tmp, 10); + buf->idle = strtoul (tmp, &tmp, 10); buf->total = buf->user + buf->nice + buf->sys + buf->idle; diff --git a/sysdeps/linux/glibtop_machine.h b/sysdeps/linux/glibtop_machine.h index 600d562c..a1c789ed 100644 --- a/sysdeps/linux/glibtop_machine.h +++ b/sysdeps/linux/glibtop_machine.h @@ -24,9 +24,22 @@ #include #include +#include __BEGIN_DECLS +#if _IN_LIBGTOP + +static inline char * +skip_token(const char *p) +{ + while (isspace(*p)) p++; + while (*p && !isspace(*p)) p++; + return (char *)p; +} + +#endif + typedef struct _glibtop_machine glibtop_machine; struct _glibtop_machine diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c index 96565610..bb8b70e6 100644 --- a/sysdeps/linux/loadavg.c +++ b/sysdeps/linux/loadavg.c @@ -33,7 +33,7 @@ static const unsigned long _glibtop_sysdeps_loadavg = void glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) { - char buffer [BUFSIZ]; + char buffer [BUFSIZ], *tmp; int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -59,9 +59,10 @@ glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) glibtop_error_r (server, "read (%s): %s", FILENAME, strerror (errno)); - sscanf (buffer, "%lf %lf %lf\n", - &buf->loadavg [0], &buf->loadavg [1], &buf->loadavg [2]); - + buf->loadavg [0] = strtod (buffer, &tmp); + buf->loadavg [1] = strtod (tmp, &tmp); + buf->loadavg [2] = strtod (tmp, &tmp); + #ifdef GLIBTOP_CACHE_OPEN server->machine.fd_loadavg = fd; #else diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index 41b54323..b53db6e2 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -36,7 +36,7 @@ static const unsigned long _glibtop_sysdeps_mem = void glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) { - char buffer [BUFSIZ]; + char buffer [BUFSIZ], *tmp; int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -62,9 +62,16 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) glibtop_error_r (server, "read (%s): %s", FILENAME, strerror (errno)); - sscanf (buffer, "%*[^\n]\nMem: %lu %lu %lu %lu %lu %lu\n", - &buf->total, &buf->used, &buf->free, &buf->shared, - &buf->buffer, &buf->cached); + tmp = strchr (buffer, '\n'); + tmp = skip_token (tmp); /* "Mem:" */ + tmp = skip_token (tmp); /* total memory */ + + buf->total = strtoul (tmp, &tmp, 10); + buf->used = strtoul (tmp, &tmp, 10); + buf->free = strtoul (tmp, &tmp, 10); + buf->shared = strtoul (tmp, &tmp, 10); + buf->buffer = strtoul (tmp, &tmp, 10); + buf->cached = strtoul (tmp, &tmp, 10); buf->user = buf->total - buf->free - buf->shared - buf->buffer; diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index fd8b29f7..24d44c06 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -34,7 +34,7 @@ static unsigned long _glibtop_sysdeps_swap = void glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) { - char buffer [BUFSIZ]; + char buffer [BUFSIZ], *tmp; int fd = 0, ret; glibtop_init_r (&server, 0, 0); @@ -60,8 +60,13 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) glibtop_error_r (server, "read (%s): %s", FILENAME, strerror (errno)); - sscanf (buffer, "%*[^\n]\n%*[^\n]\nSwap: %lu %lu %lu\n", - &buf->total, &buf->used, &buf->free); + tmp = strchr (buffer, '\n'); + tmp = strchr (tmp+1, '\n'); + + tmp = skip_token (tmp); /* "Swap:" */ + buf->total = strtoul (tmp, &tmp, 10); + buf->used = strtoul (tmp, &tmp, 10); + buf->free = strtoul (tmp, &tmp, 10); #ifdef GLIBTOP_CACHE_OPEN server->machine.fd_meminfo = fd; From 33eefd46c711edcb26ef1a6e5d4a902ff7f79654 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 8 Jun 1998 00:25:47 +0000 Subject: [PATCH 0102/2539] Minor fixes for SunOS. --- examples/first.c | 2 -- sysdeps/common/sysdeps.c | 34 ++++++++++++++++------------------ sysdeps/sun4/close.c | 2 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/examples/first.c b/examples/first.c index 741f7c7e..d93e8f3b 100644 --- a/examples/first.c +++ b/examples/first.c @@ -359,7 +359,5 @@ main (int argc, char *argv []) data.proc_segment.start_code, data.proc_segment.end_code, data.proc_segment.start_stack); - fcloseall (); - exit (0); } diff --git a/sysdeps/common/sysdeps.c b/sysdeps/common/sysdeps.c index 93767226..61d653b4 100644 --- a/sysdeps/common/sysdeps.c +++ b/sysdeps/common/sysdeps.c @@ -21,25 +21,23 @@ #include #include -#define BIT_MASK(feature) (feature ? (1 << feature) : feature) - const unsigned long glibtop_server_features = -BIT_MASK(GLIBTOP_SUID_CPU) + -BIT_MASK(GLIBTOP_SUID_MEM) + -BIT_MASK(GLIBTOP_SUID_SWAP) + -BIT_MASK(GLIBTOP_SUID_UPTIME) + -BIT_MASK(GLIBTOP_SUID_LOADAVG) + -BIT_MASK(GLIBTOP_SUID_SHM_LIMITS) + -BIT_MASK(GLIBTOP_SUID_MSG_LIMITS) + -BIT_MASK(GLIBTOP_SUID_SEM_LIMITS) + -BIT_MASK(GLIBTOP_SUID_PROCLIST) + -BIT_MASK(GLIBTOP_SUID_PROC_STATE) + -BIT_MASK(GLIBTOP_SUID_PROC_UID) + -BIT_MASK(GLIBTOP_SUID_PROC_MEM) + -BIT_MASK(GLIBTOP_SUID_PROC_TIME) + -BIT_MASK(GLIBTOP_SUID_PROC_SIGNAL) + -BIT_MASK(GLIBTOP_SUID_PROC_KERNEL) + -BIT_MASK(GLIBTOP_SUID_PROC_SEGMENT); +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. */ diff --git a/sysdeps/sun4/close.c b/sysdeps/sun4/close.c index ff7ebea4..02f2e5b3 100644 --- a/sysdeps/sun4/close.c +++ b/sysdeps/sun4/close.c @@ -24,5 +24,5 @@ /* Closes pipe to gtop server. */ void -glibtop_close (glibtop *server) +glibtop_close_l (glibtop *server) { } From c9e7e3a862d613c6a5a7d66c1a58aed7c49b1aef Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 8 Jun 1998 00:40:51 +0000 Subject: [PATCH 0103/2539] Added again. 1998-06-08 Martin Baulig * 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'. --- ChangeLog | 10 ++++++++ Makefile.am | 2 +- configure.in | 64 ++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d7d3739..1bedcdfa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1998-06-08 Martin Baulig + + * 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 * examples/ChangeLog: New file. diff --git a/Makefile.am b/Makefile.am index 8eccb23d..57ae4886 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ endif built_SUBDIRS = include sysdeps lib src -SUBDIRS = po intl macros $(built_SUBDIRS) $(examples_SUBDIRS) +SUBDIRS = po intl support macros $(built_SUBDIRS) $(examples_SUBDIRS) DIST_SUBDIRS = po intl macros include sysdeps src lib examples diff --git a/configure.in b/configure.in index 3357499b..871374da 100644 --- a/configure.in +++ b/configure.in @@ -4,19 +4,28 @@ 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 +dnl This is necessary for cross-compiling for programs +dnl that need to run on the build host. + +AC_CHECK_PROG(build_CC, gcc, gcc) +if test -z "$build_CC" ; then + AC_CHECK_PROG(build_CC, cc, cc, , , /usr/ucb/cc) + test -z "$build_CC" && \ + AC_MSG_ERROR([no acceptable cc found in \$PATH]) +fi AC_CHECK_TOOL(CC,gcc) -AC_CHECK_TOOL(CXX,g++) + +AC_ISC_POSIX +AC_PROG_CC +AC_STDC_HEADERS +AC_ARG_PROGRAM + 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,8 +33,22 @@ 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 +GNOME_INIT_HOOK(gnome_found=yes) + +if test "x$gnome_found" != xyes; then + GNOME_SUPPORT_CHECKS +fi AC_LC_SYSDEPS @@ -49,18 +72,6 @@ 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 dnl You need to uncomment the following line if you want to use libgtop without Gnome. @@ -185,6 +196,18 @@ AC_SUBST(LIBGTOP_GUILE_INCS) AC_SUBST(LIBGTOP_BINDIR) AC_SUBST(LIBGTOP_SERVER) +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 po/Makefile.in @@ -205,4 +228,5 @@ src/server/Makefile src/proxy/Makefile lib/Makefile examples/Makefile +support/Makefile macros/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]) From 9ce768bc4ba3e2e576412b1b2e5486f76b87b18a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 8 Jun 1998 00:43:32 +0000 Subject: [PATCH 0104/2539] Forgot to checkin. --- sysdeps/sun4/glibtop_server.h | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sysdeps/sun4/glibtop_server.h diff --git a/sysdeps/sun4/glibtop_server.h b/sysdeps/sun4/glibtop_server.h new file mode 100644 index 00000000..4b37edfc --- /dev/null +++ b/sysdeps/sun4/glibtop_server.h @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SERVER_H__ +#define __GLIBTOP_SERVER_H__ + +__BEGIN_DECLS + +#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU) +#define GLIBTOP_SUID_MEM (1 << GLIBTOP_SYSDEPS_MEM) +#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP) +#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME) +#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG) +#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS) +#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS) +#define GLIBTOP_SUID_SEM_LIMITS (1 << GLIBTOP_SYSDEPS_SEM_LIMITS) +#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST) +#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE) +#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID) +#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM) +#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME) +#define GLIBTOP_SUID_PROC_SIGNAL (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL) +#define GLIBTOP_SUID_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL) +#define GLIBTOP_SUID_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT) + +__END_DECLS + +#endif From b2950457ce870a1153d9e5cef64c2b7778e13f46 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 8 Jun 1998 00:50:25 +0000 Subject: [PATCH 0105/2539] *** empty log message *** --- configure.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.in b/configure.in index 871374da..b79253c1 100644 --- a/configure.in +++ b/configure.in @@ -48,6 +48,9 @@ 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 From a3c345e79ee1579d54b7cb9396cb05c64633ebae Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 11 Jun 1998 22:42:11 +0000 Subject: [PATCH 0106/2539] Initial revision --- kernel/Makefile | 13 +++++++ kernel/main.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/table.h | 80 ++++++++++++++++++++++++++++++++++++++++++ kernel/test.c | 82 +++++++++++++++++++++++++++++++++++++++++++ kernel/version.h | 1 + 5 files changed, 266 insertions(+) create mode 100644 kernel/Makefile create mode 100644 kernel/main.c create mode 100644 kernel/table.h create mode 100644 kernel/test.c create mode 100644 kernel/version.h diff --git a/kernel/Makefile b/kernel/Makefile new file mode 100644 index 00000000..d24e3ba8 --- /dev/null +++ b/kernel/Makefile @@ -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 diff --git a/kernel/main.c b/kernel/main.c new file mode 100644 index 00000000..7f6381bb --- /dev/null +++ b/kernel/main.c @@ -0,0 +1,90 @@ +/* + * linux/table/table_impl.c + * Copyright (C) 1998 Martin Baulig + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "version.h" + +asmlinkage int +sys_table (int type, union table *buf) +{ + union table tbl; + struct sysinfo i; + int err; + + if (type == TABLE_VERSION) + return _TABLE_VERSION; + + if (!buf) + return -EFAULT; + + 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] = avenrun [0]; + tbl.loadavg.loadavg [1] = avenrun [1]; + tbl.loadavg.loadavg [2] = avenrun [2]; + 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; + 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; +} diff --git a/kernel/table.h b/kernel/table.h new file mode 100644 index 00000000..9515fdc9 --- /dev/null +++ b/kernel/table.h @@ -0,0 +1,80 @@ +#ifndef _LINUX_TABLE_H +#define _LINUX_TABLE_H +#include + +#define TABLE_VERSION 0 +#define TABLE_CPU 1 +#define TABLE_MEM 2 +#define TABLE_SWAP 3 +#define TABLE_LOADAVG 4 +#define TABLE_UPTIME 5 + +/* 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 +{ + unsigned long loadavg [3]; + unsigned nr_running; + unsigned nr_tasks; + unsigned last_pid; +}; + +/* Uptime */ + +struct table_uptime +{ + unsigned long uptime; + unsigned long idle; +}; + +/* Union */ + +union table +{ + struct table_cpu cpu; + struct table_mem mem; + struct table_swap swap; + struct table_loadavg loadavg; + struct table_uptime uptime; +}; + +#ifdef __KERNEL__ + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_IPC_H */ + + diff --git a/kernel/test.c b/kernel/test.c new file mode 100644 index 00000000..a6ba8dc7 --- /dev/null +++ b/kernel/test.c @@ -0,0 +1,82 @@ +#include +#include + +#include +#include +#include + +#include + +static inline _syscall2 (int, table, int, type, union table *, tbl); + +int +main (void) +{ + union table tbl; + int ret; + + ret = table (TABLE_VERSION, 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); + + ret = table (TABLE_CPU, &tbl); + + 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); + + 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); + + 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); + + 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); + + 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); +} diff --git a/kernel/version.h b/kernel/version.h new file mode 100644 index 00000000..d47411ee --- /dev/null +++ b/kernel/version.h @@ -0,0 +1 @@ +#define _TABLE_VERSION 1 From 2408a0731cceba18486cc64f36dd231d285e6fca Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 11 Jun 1998 22:42:11 +0000 Subject: [PATCH 0107/2539] Kernel stuff: We use a new system call `table ()' instead of the /proc filesystem to fetch data. From aff6786e71b3a6858f1ce1e7d6aaaa65b586e21d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 11 Jun 1998 23:03:07 +0000 Subject: [PATCH 0108/2539] Replaced call to `gh_append2 ()' with `gh_append ()'. 1998-06-12 Martin Baulig * sysdeps/guile/proclist.c: Replaced call to `gh_append2 ()' with `gh_append ()'. * sysdeps/guile/names/*.c: dito. --- ChangeLog | 7 +++++++ sysdeps/guile/names/cpu.c | 20 ++++++++++++-------- sysdeps/guile/names/loadavg.c | 20 ++++++++++++-------- sysdeps/guile/names/mem.c | 20 ++++++++++++-------- sysdeps/guile/names/msg_limits.c | 20 ++++++++++++-------- sysdeps/guile/names/prockernel.c | 20 ++++++++++++-------- sysdeps/guile/names/proclist.c | 20 ++++++++++++-------- sysdeps/guile/names/procmem.c | 20 ++++++++++++-------- sysdeps/guile/names/procsegment.c | 20 ++++++++++++-------- sysdeps/guile/names/procsignal.c | 20 ++++++++++++-------- sysdeps/guile/names/procstate.c | 20 ++++++++++++-------- sysdeps/guile/names/proctime.c | 20 ++++++++++++-------- sysdeps/guile/names/procuid.c | 20 ++++++++++++-------- sysdeps/guile/names/sem_limits.c | 24 ++++++++++++++++-------- sysdeps/guile/names/shm_limits.c | 24 ++++++++++++++++-------- sysdeps/guile/names/swap.c | 23 ++++++++++++++++------- sysdeps/guile/names/uptime.c | 23 ++++++++++++++++------- sysdeps/guile/proclist.c | 5 ++++- 18 files changed, 219 insertions(+), 127 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bedcdfa..8a0132e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1998-06-12 Martin Baulig + + * sysdeps/guile/proclist.c: Replaced call to + `gh_append2 ()' with `gh_append ()'. + + * sysdeps/guile/names/*.c: dito. + 1998-06-08 Martin Baulig * support: Added again. diff --git a/sysdeps/guile/names/cpu.c b/sysdeps/guile/names/cpu.c index ac08cb56..94cb4056 100644 --- a/sysdeps/guile/names/cpu.c +++ b/sysdeps/guile/names/cpu.c @@ -33,10 +33,11 @@ glibtop_guile_names_cpu (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_CPU; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_cpu [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_cpu (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_CPU; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_cpu [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_cpu (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_CPU; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_cpu [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_cpu (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_CPU; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_cpu [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/loadavg.c b/sysdeps/guile/names/loadavg.c index fe4b589d..c12254b4 100644 --- a/sysdeps/guile/names/loadavg.c +++ b/sysdeps/guile/names/loadavg.c @@ -33,10 +33,11 @@ glibtop_guile_names_loadavg (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_loadavg [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_loadavg (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_loadavg [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_loadavg (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_loadavg [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_loadavg (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_loadavg [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/mem.c b/sysdeps/guile/names/mem.c index afc4e7a9..fe2582e5 100644 --- a/sysdeps/guile/names/mem.c +++ b/sysdeps/guile/names/mem.c @@ -33,10 +33,11 @@ glibtop_guile_names_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_mem [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_mem [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_mem [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_mem [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/msg_limits.c b/sysdeps/guile/names/msg_limits.c index f978eabc..4e7afc4f 100644 --- a/sysdeps/guile/names/msg_limits.c +++ b/sysdeps/guile/names/msg_limits.c @@ -33,10 +33,11 @@ glibtop_guile_names_msg_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_msg_limits [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_msg_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_msg_limits [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_msg_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_msg_limits [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_msg_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_msg_limits [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/prockernel.c b/sysdeps/guile/names/prockernel.c index 0de1d334..31e7b13b 100644 --- a/sysdeps/guile/names/prockernel.c +++ b/sysdeps/guile/names/prockernel.c @@ -33,10 +33,11 @@ glibtop_guile_names_proc_kernel (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proc_kernel [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_proc_kernel (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_proc_kernel [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_proc_kernel (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_proc_kernel [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_proc_kernel (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proc_kernel [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/proclist.c b/sysdeps/guile/names/proclist.c index 7269d085..fb129e97 100644 --- a/sysdeps/guile/names/proclist.c +++ b/sysdeps/guile/names/proclist.c @@ -34,10 +34,11 @@ glibtop_guile_names_proclist (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proclist [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -51,10 +52,11 @@ glibtop_guile_types_proclist (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_proclist [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -68,11 +70,12 @@ glibtop_guile_labels_proclist (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_proclist [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -86,11 +89,12 @@ glibtop_guile_descriptions_proclist (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proclist [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/procmem.c b/sysdeps/guile/names/procmem.c index 4daf9967..58101900 100644 --- a/sysdeps/guile/names/procmem.c +++ b/sysdeps/guile/names/procmem.c @@ -33,10 +33,11 @@ glibtop_guile_names_proc_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proc_mem [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_proc_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_proc_mem [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_proc_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_proc_mem [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_proc_mem (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proc_mem [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/procsegment.c b/sysdeps/guile/names/procsegment.c index 7ed42171..5ab51c56 100644 --- a/sysdeps/guile/names/procsegment.c +++ b/sysdeps/guile/names/procsegment.c @@ -33,10 +33,11 @@ glibtop_guile_names_proc_segment (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proc_segment [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_proc_segment (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_proc_segment [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_proc_segment (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_proc_segment [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_proc_segment (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proc_segment [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/procsignal.c b/sysdeps/guile/names/procsignal.c index 97df5373..f614992d 100644 --- a/sysdeps/guile/names/procsignal.c +++ b/sysdeps/guile/names/procsignal.c @@ -33,10 +33,11 @@ glibtop_guile_names_proc_signal (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proc_signal [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_proc_signal (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_proc_signal [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_proc_signal (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_proc_signal [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_proc_signal (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proc_signal [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/procstate.c b/sysdeps/guile/names/procstate.c index 7ba88645..9b1a1e16 100644 --- a/sysdeps/guile/names/procstate.c +++ b/sysdeps/guile/names/procstate.c @@ -33,10 +33,11 @@ glibtop_guile_names_proc_state (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proc_state [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_proc_state (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_proc_state [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_proc_state (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_proc_state [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_proc_state (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proc_state [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/proctime.c b/sysdeps/guile/names/proctime.c index b0ad5e60..fb0d194c 100644 --- a/sysdeps/guile/names/proctime.c +++ b/sysdeps/guile/names/proctime.c @@ -33,10 +33,11 @@ glibtop_guile_names_proc_time (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proc_time [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_proc_time (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append2 + list = gh_appen (list, gh_list (gh_str02scm (glibtop_types_proc_time [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_proc_time (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append2 + list = gh_appen (list, gh_list (gh_str02scm (gettext (glibtop_labels_proc_time [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_proc_time (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append2 + list = gh_appen (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proc_time [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/procuid.c b/sysdeps/guile/names/procuid.c index 0746f8a8..32170788 100644 --- a/sysdeps/guile/names/procuid.c +++ b/sysdeps/guile/names/procuid.c @@ -33,10 +33,11 @@ glibtop_guile_names_proc_uid (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_names_proc_uid [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -50,10 +51,11 @@ glibtop_guile_types_proc_uid (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (glibtop_types_proc_uid [i]), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -67,11 +69,12 @@ glibtop_guile_labels_proc_uid (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_labels_proc_uid [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -85,11 +88,12 @@ glibtop_guile_descriptions_proc_uid (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append2 + list = gh_append (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_proc_uid [i])), - SCM_UNDEFINED)); + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/sem_limits.c b/sysdeps/guile/names/sem_limits.c index 397ddebd..46bdeb94 100644 --- a/sysdeps/guile/names/sem_limits.c +++ b/sysdeps/guile/names/sem_limits.c @@ -33,8 +33,10 @@ glibtop_guile_names_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_sem_limits [i]), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (glibtop_names_sem_limits [i]), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -48,8 +50,10 @@ glibtop_guile_types_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_sem_limits [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_types_sem_limits [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -63,8 +67,10 @@ glibtop_guile_labels_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_sem_limits [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_labels_sem_limits [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -78,8 +84,10 @@ glibtop_guile_descriptions_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_sem_limits [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_descriptions_sem_limits [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/shm_limits.c b/sysdeps/guile/names/shm_limits.c index 32ea693b..6987ad5d 100644 --- a/sysdeps/guile/names/shm_limits.c +++ b/sysdeps/guile/names/shm_limits.c @@ -33,8 +33,10 @@ glibtop_guile_names_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_shm_limits [i]), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (glibtop_names_shm_limits [i]), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -48,8 +50,10 @@ glibtop_guile_types_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_shm_limits [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_types_shm_limits [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -63,8 +67,10 @@ glibtop_guile_labels_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_shm_limits [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_labels_shm_limits [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -78,8 +84,10 @@ glibtop_guile_descriptions_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_shm_limits [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_descriptions_shm_limits [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/swap.c b/sysdeps/guile/names/swap.c index e5d477d4..7e04d533 100644 --- a/sysdeps/guile/names/swap.c +++ b/sysdeps/guile/names/swap.c @@ -33,7 +33,10 @@ glibtop_guile_names_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_swap [i]), SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (glibtop_names_swap [i]), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -47,8 +50,10 @@ glibtop_guile_types_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_swap [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_types_swap [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -62,8 +67,10 @@ glibtop_guile_labels_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_swap [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_labels_swap [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -77,8 +84,10 @@ glibtop_guile_descriptions_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_swap [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_descriptions_swap [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/names/uptime.c b/sysdeps/guile/names/uptime.c index 6bf65203..a5d6a2bf 100644 --- a/sysdeps/guile/names/uptime.c +++ b/sysdeps/guile/names/uptime.c @@ -33,7 +33,10 @@ glibtop_guile_names_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_uptime [i]), SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (glibtop_names_uptime [i]), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -47,8 +50,10 @@ glibtop_guile_types_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_uptime [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_types_uptime [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -62,8 +67,10 @@ glibtop_guile_labels_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_uptime [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_labels_uptime [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } @@ -77,8 +84,10 @@ glibtop_guile_descriptions_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_uptime [i])), - SCM_UNDEFINED)); + list = gh_append (list, gh_list + (gh_str02scm (gettext (glibtop_descriptions_uptime [i])), + SCM_UNDEFINED), + SCM_UNDEFINED); return list; } diff --git a/sysdeps/guile/proclist.c b/sysdeps/guile/proclist.c index 50fa0b0c..6eea127b 100644 --- a/sysdeps/guile/proclist.c +++ b/sysdeps/guile/proclist.c @@ -43,7 +43,10 @@ glibtop_guile_get_proclist (void) if (ptr) { for (i = 0; i < proclist.number; i++) - list = gh_append2 (list, gh_list (gh_ulong2scm ((unsigned long) ptr [i]), SCM_UNDEFINED)); + list = gh_append (list, + gh_list (gh_ulong2scm ((unsigned long) ptr [i]), + SCM_UNDEFINED), + SCM_UNDEFINED); } glibtop_free (ptr); From 5e3d6bdf1870f9c7bc50226b52adf1f26fc85be8 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 11 Jun 1998 23:56:06 +0000 Subject: [PATCH 0109/2539] Merged bug fixes from stable branch. --- sysdeps/guile/names/cpu.c | 32 ++++++++++++-------------- sysdeps/guile/names/loadavg.c | 32 ++++++++++++-------------- sysdeps/guile/names/mem.c | 32 ++++++++++++-------------- sysdeps/guile/names/msg_limits.c | 32 ++++++++++++-------------- sysdeps/guile/names/prockernel.c | 32 ++++++++++++-------------- sysdeps/guile/names/proclist.c | 34 ++++++++++++--------------- sysdeps/guile/names/procmem.c | 32 ++++++++++++-------------- sysdeps/guile/names/procsegment.c | 32 ++++++++++++-------------- sysdeps/guile/names/procsignal.c | 32 ++++++++++++-------------- sysdeps/guile/names/procstate.c | 32 ++++++++++++-------------- sysdeps/guile/names/proctime.c | 38 ++++++++++++++----------------- sysdeps/guile/names/procuid.c | 32 ++++++++++++-------------- sysdeps/guile/names/sem_limits.c | 28 ++++++++++------------- sysdeps/guile/names/shm_limits.c | 28 ++++++++++------------- sysdeps/guile/names/swap.c | 28 ++++++++++------------- sysdeps/guile/names/sysdeps.c | 22 ++++++++++-------- sysdeps/guile/names/uptime.c | 28 ++++++++++------------- sysdeps/guile/proclist.c | 8 +++---- 18 files changed, 237 insertions(+), 297 deletions(-) diff --git a/sysdeps/guile/names/cpu.c b/sysdeps/guile/names/cpu.c index 94cb4056..e7b533b6 100644 --- a/sysdeps/guile/names/cpu.c +++ b/sysdeps/guile/names/cpu.c @@ -34,10 +34,9 @@ glibtop_guile_names_cpu (void) for (i = 0; i < GLIBTOP_MAX_CPU; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_cpu [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_cpu [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_cpu (void) for (i = 0; i < GLIBTOP_MAX_CPU; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_cpu [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_cpu [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_cpu (void) for (i = 0; i < GLIBTOP_MAX_CPU; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_cpu [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_cpu [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_cpu (void) for (i = 0; i < GLIBTOP_MAX_CPU; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_cpu [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_cpu [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/loadavg.c b/sysdeps/guile/names/loadavg.c index c12254b4..e82c8e9b 100644 --- a/sysdeps/guile/names/loadavg.c +++ b/sysdeps/guile/names/loadavg.c @@ -34,10 +34,9 @@ glibtop_guile_names_loadavg (void) for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_loadavg [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_loadavg [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_loadavg (void) for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_loadavg [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_loadavg [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_loadavg (void) for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_loadavg [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_loadavg [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_loadavg (void) for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_loadavg [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_loadavg [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/mem.c b/sysdeps/guile/names/mem.c index fe2582e5..53662e1e 100644 --- a/sysdeps/guile/names/mem.c +++ b/sysdeps/guile/names/mem.c @@ -34,10 +34,9 @@ glibtop_guile_names_mem (void) for (i = 0; i < GLIBTOP_MAX_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_mem [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_mem [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_mem (void) for (i = 0; i < GLIBTOP_MAX_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_mem [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_mem [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_mem (void) for (i = 0; i < GLIBTOP_MAX_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_mem [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_mem [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_mem (void) for (i = 0; i < GLIBTOP_MAX_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_mem [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_mem [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/msg_limits.c b/sysdeps/guile/names/msg_limits.c index 4e7afc4f..60b23ee7 100644 --- a/sysdeps/guile/names/msg_limits.c +++ b/sysdeps/guile/names/msg_limits.c @@ -34,10 +34,9 @@ glibtop_guile_names_msg_limits (void) for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_msg_limits [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_msg_limits [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_msg_limits (void) for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_msg_limits [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_msg_limits [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_msg_limits (void) for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_msg_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_msg_limits [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_msg_limits (void) for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_msg_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_msg_limits [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/prockernel.c b/sysdeps/guile/names/prockernel.c index 31e7b13b..436e6d23 100644 --- a/sysdeps/guile/names/prockernel.c +++ b/sysdeps/guile/names/prockernel.c @@ -34,10 +34,9 @@ glibtop_guile_names_proc_kernel (void) for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proc_kernel [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proc_kernel [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_proc_kernel (void) for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_proc_kernel [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proc_kernel [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_proc_kernel (void) for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proc_kernel [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proc_kernel [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_proc_kernel (void) for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proc_kernel [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proc_kernel [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/proclist.c b/sysdeps/guile/names/proclist.c index fb129e97..764483b3 100644 --- a/sysdeps/guile/names/proclist.c +++ b/sysdeps/guile/names/proclist.c @@ -35,10 +35,9 @@ glibtop_guile_names_proclist (void) for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proclist [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proclist [i])), + SCM_UNDEFINED)); return list; } @@ -53,11 +52,10 @@ glibtop_guile_types_proclist (void) for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_proclist [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); - + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proclist [i])), + SCM_UNDEFINED)); + return list; } @@ -71,11 +69,10 @@ glibtop_guile_labels_proclist (void) for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proclist [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proclist [i]))), + SCM_UNDEFINED)); return list; } @@ -90,11 +87,10 @@ glibtop_guile_descriptions_proclist (void) for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proclist [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proclist [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/procmem.c b/sysdeps/guile/names/procmem.c index 58101900..cbd58a19 100644 --- a/sysdeps/guile/names/procmem.c +++ b/sysdeps/guile/names/procmem.c @@ -34,10 +34,9 @@ glibtop_guile_names_proc_mem (void) for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proc_mem [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proc_mem [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_proc_mem (void) for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_proc_mem [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proc_mem [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_proc_mem (void) for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proc_mem [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proc_mem [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_proc_mem (void) for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proc_mem [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proc_mem [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/procsegment.c b/sysdeps/guile/names/procsegment.c index 5ab51c56..a872bcd1 100644 --- a/sysdeps/guile/names/procsegment.c +++ b/sysdeps/guile/names/procsegment.c @@ -34,10 +34,9 @@ glibtop_guile_names_proc_segment (void) for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proc_segment [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proc_segment [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_proc_segment (void) for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_proc_segment [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proc_segment [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_proc_segment (void) for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proc_segment [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proc_segment [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_proc_segment (void) for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proc_segment [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proc_segment [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/procsignal.c b/sysdeps/guile/names/procsignal.c index f614992d..18c16271 100644 --- a/sysdeps/guile/names/procsignal.c +++ b/sysdeps/guile/names/procsignal.c @@ -34,10 +34,9 @@ glibtop_guile_names_proc_signal (void) for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proc_signal [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proc_signal [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_proc_signal (void) for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_proc_signal [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proc_signal [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_proc_signal (void) for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proc_signal [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proc_signal [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_proc_signal (void) for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proc_signal [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proc_signal [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/procstate.c b/sysdeps/guile/names/procstate.c index 9b1a1e16..ca10c102 100644 --- a/sysdeps/guile/names/procstate.c +++ b/sysdeps/guile/names/procstate.c @@ -34,10 +34,9 @@ glibtop_guile_names_proc_state (void) for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proc_state [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proc_state [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_proc_state (void) for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_proc_state [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proc_state [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_proc_state (void) for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proc_state [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proc_state [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_proc_state (void) for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proc_state [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proc_state [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/proctime.c b/sysdeps/guile/names/proctime.c index fb0d194c..4797d4ab 100644 --- a/sysdeps/guile/names/proctime.c +++ b/sysdeps/guile/names/proctime.c @@ -34,10 +34,9 @@ glibtop_guile_names_proc_time (void) for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proc_time [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proc_time [i])), + SCM_UNDEFINED)); return list; } @@ -51,11 +50,10 @@ glibtop_guile_types_proc_time (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_appen - (list, gh_list - (gh_str02scm (glibtop_types_proc_time [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proc_time [i])), + SCM_UNDEFINED)); return list; } @@ -69,12 +67,11 @@ glibtop_guile_labels_proc_time (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_appen - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proc_time [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proc_time [i]))), + SCM_UNDEFINED)); return list; } @@ -88,12 +85,11 @@ glibtop_guile_descriptions_proc_time (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_appen - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proc_time [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proc_time [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/procuid.c b/sysdeps/guile/names/procuid.c index 32170788..96022765 100644 --- a/sysdeps/guile/names/procuid.c +++ b/sysdeps/guile/names/procuid.c @@ -34,10 +34,9 @@ glibtop_guile_names_proc_uid (void) for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_names_proc_uid [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_names_proc_uid [i])), + SCM_UNDEFINED)); return list; } @@ -52,10 +51,9 @@ glibtop_guile_types_proc_uid (void) for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) list = gh_append - (list, gh_list - (gh_str02scm (glibtop_types_proc_uid [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (glibtop_types_proc_uid [i])), + SCM_UNDEFINED)); return list; } @@ -70,11 +68,10 @@ glibtop_guile_labels_proc_uid (void) for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_labels_proc_uid [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_labels_proc_uid [i]))), + SCM_UNDEFINED)); return list; } @@ -89,11 +86,10 @@ glibtop_guile_descriptions_proc_uid (void) for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) list = gh_append - (list, gh_list - (gh_str02scm (gettext - (glibtop_descriptions_proc_uid [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + (gh_list (list, + gh_list (gh_str02scm (gettext + (glibtop_descriptions_proc_uid [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/sem_limits.c b/sysdeps/guile/names/sem_limits.c index 46bdeb94..23b7a252 100644 --- a/sysdeps/guile/names/sem_limits.c +++ b/sysdeps/guile/names/sem_limits.c @@ -33,10 +33,9 @@ glibtop_guile_names_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (glibtop_names_sem_limits [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (glibtop_names_sem_limits [i])), + SCM_UNDEFINED)); return list; } @@ -50,10 +49,9 @@ glibtop_guile_types_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_types_sem_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_types_sem_limits [i]))), + SCM_UNDEFINED)); return list; } @@ -67,10 +65,9 @@ glibtop_guile_labels_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_labels_sem_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_labels_sem_limits [i]))), + SCM_UNDEFINED)); return list; } @@ -84,10 +81,9 @@ glibtop_guile_descriptions_sem_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_descriptions_sem_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_descriptions_sem_limits [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/shm_limits.c b/sysdeps/guile/names/shm_limits.c index 6987ad5d..c81a1b42 100644 --- a/sysdeps/guile/names/shm_limits.c +++ b/sysdeps/guile/names/shm_limits.c @@ -33,10 +33,9 @@ glibtop_guile_names_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (glibtop_names_shm_limits [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (glibtop_names_shm_limits [i])), + SCM_UNDEFINED)); return list; } @@ -50,10 +49,9 @@ glibtop_guile_types_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_types_shm_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_types_shm_limits [i]))), + SCM_UNDEFINED)); return list; } @@ -67,10 +65,9 @@ glibtop_guile_labels_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_labels_shm_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_labels_shm_limits [i]))), + SCM_UNDEFINED)); return list; } @@ -84,10 +81,9 @@ glibtop_guile_descriptions_shm_limits (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_descriptions_shm_limits [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_descriptions_shm_limits [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/swap.c b/sysdeps/guile/names/swap.c index 7e04d533..21195a8f 100644 --- a/sysdeps/guile/names/swap.c +++ b/sysdeps/guile/names/swap.c @@ -33,10 +33,9 @@ glibtop_guile_names_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (list, gh_list - (gh_str02scm (glibtop_names_swap [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (glibtop_names_swap [i])), + SCM_UNDEFINED)); return list; } @@ -50,10 +49,9 @@ glibtop_guile_types_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_types_swap [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_types_swap [i]))), + SCM_UNDEFINED)); return list; } @@ -67,10 +65,9 @@ glibtop_guile_labels_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_labels_swap [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_labels_swap [i]))), + SCM_UNDEFINED)); return list; } @@ -84,10 +81,9 @@ glibtop_guile_descriptions_swap (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_descriptions_swap [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_descriptions_swap [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/sysdeps.c b/sysdeps/guile/names/sysdeps.c index 20e4c184..390be91f 100644 --- a/sysdeps/guile/names/sysdeps.c +++ b/sysdeps/guile/names/sysdeps.c @@ -33,9 +33,10 @@ glibtop_guile_names_sysdeps (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_sysdeps [i]), - SCM_UNDEFINED)); - + list = gh_append (gh_list (list, + gh_list (gh_str02scm (glibtop_names_sysdeps [i])), + SCM_UNDEFINED)); + return list; } @@ -48,8 +49,9 @@ glibtop_guile_types_sysdeps (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_sysdeps [i])), - SCM_UNDEFINED)); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_types_sysdeps [i]))), + SCM_UNDEFINED)); return list; } @@ -63,8 +65,9 @@ glibtop_guile_labels_sysdeps (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_sysdeps [i])), - SCM_UNDEFINED)); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_labels_sysdeps [i]))), + SCM_UNDEFINED)); return list; } @@ -78,8 +81,9 @@ glibtop_guile_descriptions_sysdeps (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_sysdeps [i])), - SCM_UNDEFINED)); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_descriptions_sysdeps [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/names/uptime.c b/sysdeps/guile/names/uptime.c index a5d6a2bf..3776363b 100644 --- a/sysdeps/guile/names/uptime.c +++ b/sysdeps/guile/names/uptime.c @@ -33,10 +33,9 @@ glibtop_guile_names_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (list, gh_list - (gh_str02scm (glibtop_names_uptime [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (glibtop_names_uptime [i])), + SCM_UNDEFINED)); return list; } @@ -50,10 +49,9 @@ glibtop_guile_types_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_types_uptime [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_types_uptime [i]))), + SCM_UNDEFINED)); return list; } @@ -67,10 +65,9 @@ glibtop_guile_labels_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_labels_uptime [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_labels_uptime [i]))), + SCM_UNDEFINED)); return list; } @@ -84,10 +81,9 @@ glibtop_guile_descriptions_uptime (void) list = gh_list (SCM_UNDEFINED); for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (list, gh_list - (gh_str02scm (gettext (glibtop_descriptions_uptime [i])), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append (gh_list (list, + gh_list (gh_str02scm (gettext (glibtop_descriptions_uptime [i]))), + SCM_UNDEFINED)); return list; } diff --git a/sysdeps/guile/proclist.c b/sysdeps/guile/proclist.c index 6eea127b..7491805f 100644 --- a/sysdeps/guile/proclist.c +++ b/sysdeps/guile/proclist.c @@ -43,10 +43,10 @@ glibtop_guile_get_proclist (void) if (ptr) { for (i = 0; i < proclist.number; i++) - list = gh_append (list, - gh_list (gh_ulong2scm ((unsigned long) ptr [i]), - SCM_UNDEFINED), - SCM_UNDEFINED); + list = gh_append + (gh_list (list, + gh_list (gh_ulong2scm ((unsigned long) ptr [i])), + SCM_UNDEFINED)); } glibtop_free (ptr); From cf8068049fb964efd61316d2c8af97eee8c4cf98 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 12 Jun 1998 00:40:17 +0000 Subject: [PATCH 0110/2539] Forgot to change declaration on Jun 6. 1998-06-12 Martin Baulig * 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'. --- ChangeLog | 11 +++++++++++ include/glibtop/sysdeps.h | 4 ++-- sysdeps/guile/names/cpu.c | 2 +- sysdeps/guile/names/loadavg.c | 2 +- sysdeps/guile/names/mem.c | 2 +- sysdeps/guile/names/msg_limits.c | 2 +- sysdeps/guile/names/prockernel.c | 2 +- sysdeps/guile/names/proclist.c | 2 +- sysdeps/guile/names/procmem.c | 2 +- sysdeps/guile/names/procsegment.c | 2 +- sysdeps/guile/names/procsignal.c | 2 +- sysdeps/guile/names/procstate.c | 2 +- sysdeps/guile/names/proctime.c | 2 +- sysdeps/guile/names/procuid.c | 2 +- sysdeps/guile/names/sem_limits.c | 2 +- sysdeps/guile/names/shm_limits.c | 2 +- sysdeps/guile/names/swap.c | 2 +- sysdeps/guile/names/sysdeps.c | 2 +- sysdeps/guile/names/uptime.c | 2 +- sysdeps/names/sysdeps.c | 22 +++++++++++++--------- 20 files changed, 43 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a0132e7..0128056d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 1998-06-12 Martin Baulig + * 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 ()'. diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index e2491008..8436a81c 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -27,7 +27,7 @@ __BEGIN_DECLS -#define GLIBTOP_SYSDEPS_DUMMY 0 +#define GLIBTOP_SYSDEPS_FEATURES 0 #define GLIBTOP_SYSDEPS_CPU 1 #define GLIBTOP_SYSDEPS_MEM 2 #define GLIBTOP_SYSDEPS_SWAP 3 @@ -101,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 []; diff --git a/sysdeps/guile/names/cpu.c b/sysdeps/guile/names/cpu.c index e7b533b6..eed68f17 100644 --- a/sysdeps/guile/names/cpu.c +++ b/sysdeps/guile/names/cpu.c @@ -52,7 +52,7 @@ glibtop_guile_types_cpu (void) for (i = 0; i < GLIBTOP_MAX_CPU; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_cpu [i])), + gh_list (gh_ulong2scm (glibtop_types_cpu [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/loadavg.c b/sysdeps/guile/names/loadavg.c index e82c8e9b..c6e37127 100644 --- a/sysdeps/guile/names/loadavg.c +++ b/sysdeps/guile/names/loadavg.c @@ -52,7 +52,7 @@ glibtop_guile_types_loadavg (void) for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_loadavg [i])), + gh_list (gh_ulong2scm (glibtop_types_loadavg [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/mem.c b/sysdeps/guile/names/mem.c index 53662e1e..06160766 100644 --- a/sysdeps/guile/names/mem.c +++ b/sysdeps/guile/names/mem.c @@ -52,7 +52,7 @@ glibtop_guile_types_mem (void) for (i = 0; i < GLIBTOP_MAX_MEM; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_mem [i])), + gh_list (gh_ulong2scm (glibtop_types_mem [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/msg_limits.c b/sysdeps/guile/names/msg_limits.c index 60b23ee7..9225c9af 100644 --- a/sysdeps/guile/names/msg_limits.c +++ b/sysdeps/guile/names/msg_limits.c @@ -52,7 +52,7 @@ glibtop_guile_types_msg_limits (void) for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_msg_limits [i])), + gh_list (gh_ulong2scm (glibtop_types_msg_limits [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/prockernel.c b/sysdeps/guile/names/prockernel.c index 436e6d23..1fbd0e95 100644 --- a/sysdeps/guile/names/prockernel.c +++ b/sysdeps/guile/names/prockernel.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_kernel (void) for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proc_kernel [i])), + gh_list (gh_ulong2scm (glibtop_types_proc_kernel [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/proclist.c b/sysdeps/guile/names/proclist.c index 764483b3..2dc568cc 100644 --- a/sysdeps/guile/names/proclist.c +++ b/sysdeps/guile/names/proclist.c @@ -53,7 +53,7 @@ glibtop_guile_types_proclist (void) for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proclist [i])), + gh_list (gh_ulong2scm (glibtop_types_proclist [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/procmem.c b/sysdeps/guile/names/procmem.c index cbd58a19..a114a530 100644 --- a/sysdeps/guile/names/procmem.c +++ b/sysdeps/guile/names/procmem.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_mem (void) for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proc_mem [i])), + gh_list (gh_ulong2scm (glibtop_types_proc_mem [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/procsegment.c b/sysdeps/guile/names/procsegment.c index a872bcd1..926ae65f 100644 --- a/sysdeps/guile/names/procsegment.c +++ b/sysdeps/guile/names/procsegment.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_segment (void) for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proc_segment [i])), + gh_list (gh_ulong2scm (glibtop_types_proc_segment [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/procsignal.c b/sysdeps/guile/names/procsignal.c index 18c16271..e3c8da87 100644 --- a/sysdeps/guile/names/procsignal.c +++ b/sysdeps/guile/names/procsignal.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_signal (void) for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proc_signal [i])), + gh_list (gh_ulong2scm (glibtop_types_proc_signal [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/procstate.c b/sysdeps/guile/names/procstate.c index ca10c102..8575fc69 100644 --- a/sysdeps/guile/names/procstate.c +++ b/sysdeps/guile/names/procstate.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_state (void) for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proc_state [i])), + gh_list (gh_ulong2scm (glibtop_types_proc_state [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/proctime.c b/sysdeps/guile/names/proctime.c index 4797d4ab..67cbd924 100644 --- a/sysdeps/guile/names/proctime.c +++ b/sysdeps/guile/names/proctime.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_time (void) for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proc_time [i])), + gh_list (gh_ulong2scm (glibtop_types_proc_time [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/procuid.c b/sysdeps/guile/names/procuid.c index 96022765..b47eb226 100644 --- a/sysdeps/guile/names/procuid.c +++ b/sysdeps/guile/names/procuid.c @@ -52,7 +52,7 @@ glibtop_guile_types_proc_uid (void) for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_types_proc_uid [i])), + gh_list (gh_ulong2scm (glibtop_types_proc_uid [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/sem_limits.c b/sysdeps/guile/names/sem_limits.c index 23b7a252..6c88555c 100644 --- a/sysdeps/guile/names/sem_limits.c +++ b/sysdeps/guile/names/sem_limits.c @@ -50,7 +50,7 @@ glibtop_guile_types_sem_limits (void) for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_types_sem_limits [i]))), + gh_list (gh_ulong2scm (glibtop_types_sem_limits [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/shm_limits.c b/sysdeps/guile/names/shm_limits.c index c81a1b42..50c7c0d8 100644 --- a/sysdeps/guile/names/shm_limits.c +++ b/sysdeps/guile/names/shm_limits.c @@ -50,7 +50,7 @@ glibtop_guile_types_shm_limits (void) for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_types_shm_limits [i]))), + gh_list (gh_ulong2scm (glibtop_types_shm_limits [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/swap.c b/sysdeps/guile/names/swap.c index 21195a8f..720d6371 100644 --- a/sysdeps/guile/names/swap.c +++ b/sysdeps/guile/names/swap.c @@ -50,7 +50,7 @@ glibtop_guile_types_swap (void) for (i = 0; i < GLIBTOP_MAX_SWAP; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_types_swap [i]))), + gh_list (gh_ulong2scm (glibtop_types_swap [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/sysdeps.c b/sysdeps/guile/names/sysdeps.c index 390be91f..d9ed5af5 100644 --- a/sysdeps/guile/names/sysdeps.c +++ b/sysdeps/guile/names/sysdeps.c @@ -50,7 +50,7 @@ glibtop_guile_types_sysdeps (void) for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_types_sysdeps [i]))), + gh_list (gh_ulong2scm (glibtop_types_sysdeps [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/guile/names/uptime.c b/sysdeps/guile/names/uptime.c index 3776363b..eb708aff 100644 --- a/sysdeps/guile/names/uptime.c +++ b/sysdeps/guile/names/uptime.c @@ -50,7 +50,7 @@ glibtop_guile_types_uptime (void) for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_types_uptime [i]))), + gh_list (gh_ulong2scm (glibtop_types_uptime [i])), SCM_UNDEFINED)); return list; diff --git a/sysdeps/names/sysdeps.c b/sysdeps/names/sysdeps.c index 3387efd0..cfd672b3 100644 --- a/sysdeps/names/sysdeps.c +++ b/sysdeps/names/sysdeps.c @@ -23,22 +23,25 @@ const char *glibtop_names_sysdeps [GLIBTOP_MAX_SYSDEPS] = { - "cpu", "mem", "swap", "uptime", "loadavg", "shm_limits", - "msg_limits", "sem_limits", "proclist", "proc_state", - "proc_uid", "proc_mem", "proc_time", "proc_signal", - "proc_kernel", "proc_segment" + "features", "cpu", "mem", "swap", "uptime", "loadavg", + "shm_limits", "msg_limits", "sem_limits", "proclist", + "proc_state", "proc_uid", "proc_mem", "proc_time", + "proc_signal", "proc_kernel", "proc_segment" }; -const char *glibtop_types_sysdeps [GLIBTOP_MAX_SYSDEPS] = +const unsigned glibtop_types_sysdeps [GLIBTOP_MAX_SYSDEPS] = { - "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long", "unsigned long", - "unsigned long", "unsigned long", "unsigned long", "unsigned long" + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG }; const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] = { + N_("Server Features"), N_("CPU Usage"), N_("Memory Usage"), N_("Swap Usage"), @@ -59,6 +62,7 @@ const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] = const char *glibtop_descriptions_sysdeps [GLIBTOP_MAX_SYSDEPS] = { + N_("Server Features"), N_("CPU Usage"), N_("Memory Usage"), N_("Swap Usage"), From eedc64096ccd136baf17bd2b9f340a8b60fe1ace Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 12 Jun 1998 00:41:00 +0000 Subject: [PATCH 0111/2539] New file. 1998-06-12 Martin Baulig * test.scm: New file. --- examples/ChangeLog | 4 +++ examples/test.scm | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 examples/test.scm diff --git a/examples/ChangeLog b/examples/ChangeLog index c4476e14..e7d19aac 100644 --- a/examples/ChangeLog +++ b/examples/ChangeLog @@ -1,3 +1,7 @@ +1998-06-12 Martin Baulig + + * test.scm: New file. + 1998-06-07 Martin Baulig * Makefile.am (CFLAGS): Disable optimize. diff --git a/examples/test.scm b/examples/test.scm new file mode 100644 index 00000000..893893f5 --- /dev/null +++ b/examples/test.scm @@ -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) From c60d1d54496f33ef3dee91a4dfc229c6cf70f0f5 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 13 Jun 1998 21:20:48 +0000 Subject: [PATCH 0112/2539] The code in this directory fetches all information directly from the 1998-06-13 Martin Baulig The code in this directory fetches all information directly from the kernel. It uses the new table () system call from the `kernel' directory. --- sysdeps/kernel/.cvsignore | 28 +++++ sysdeps/kernel/ChangeLog | 5 + sysdeps/kernel/Makefile.am | 17 +++ sysdeps/kernel/close.c | 28 +++++ sysdeps/kernel/cpu.c | 55 ++++++++++ sysdeps/kernel/glibtop_server.h | 46 +++++++++ sysdeps/kernel/init.c | 44 ++++++++ sysdeps/kernel/kernel.h | 38 +++++++ sysdeps/kernel/loadavg.c | 57 ++++++++++ sysdeps/kernel/mem.c | 58 +++++++++++ sysdeps/kernel/msg_limits.c | 55 ++++++++++ sysdeps/kernel/open.c | 62 +++++++++++ sysdeps/kernel/procdata.c | 178 ++++++++++++++++++++++++++++++++ sysdeps/kernel/prockernel.c | 63 +++++++++++ sysdeps/kernel/proclist.c | 155 +++++++++++++++++++++++++++ sysdeps/kernel/procmem.c | 65 ++++++++++++ sysdeps/kernel/procsegment.c | 68 ++++++++++++ sysdeps/kernel/procsignal.c | 59 +++++++++++ sysdeps/kernel/procstate.c | 65 ++++++++++++ sysdeps/kernel/proctime.c | 61 +++++++++++ sysdeps/kernel/procuid.c | 100 ++++++++++++++++++ sysdeps/kernel/sem_limits.c | 61 +++++++++++ sysdeps/kernel/shm_limits.c | 52 ++++++++++ sysdeps/kernel/swap.c | 51 +++++++++ sysdeps/kernel/uptime.c | 54 ++++++++++ 25 files changed, 1525 insertions(+) create mode 100644 sysdeps/kernel/.cvsignore create mode 100644 sysdeps/kernel/ChangeLog create mode 100644 sysdeps/kernel/Makefile.am create mode 100644 sysdeps/kernel/close.c create mode 100644 sysdeps/kernel/cpu.c create mode 100644 sysdeps/kernel/glibtop_server.h create mode 100644 sysdeps/kernel/init.c create mode 100644 sysdeps/kernel/kernel.h create mode 100644 sysdeps/kernel/loadavg.c create mode 100644 sysdeps/kernel/mem.c create mode 100644 sysdeps/kernel/msg_limits.c create mode 100644 sysdeps/kernel/open.c create mode 100644 sysdeps/kernel/procdata.c create mode 100644 sysdeps/kernel/prockernel.c create mode 100644 sysdeps/kernel/proclist.c create mode 100644 sysdeps/kernel/procmem.c create mode 100644 sysdeps/kernel/procsegment.c create mode 100644 sysdeps/kernel/procsignal.c create mode 100644 sysdeps/kernel/procstate.c create mode 100644 sysdeps/kernel/proctime.c create mode 100644 sysdeps/kernel/procuid.c create mode 100644 sysdeps/kernel/sem_limits.c create mode 100644 sysdeps/kernel/shm_limits.c create mode 100644 sysdeps/kernel/swap.c create mode 100644 sysdeps/kernel/uptime.c diff --git a/sysdeps/kernel/.cvsignore b/sysdeps/kernel/.cvsignore new file mode 100644 index 00000000..b851d091 --- /dev/null +++ b/sysdeps/kernel/.cvsignore @@ -0,0 +1,28 @@ +.deps +.libs +Makefile +Makefile.in +close.lo +cpu.lo +init.lo +ipc_limits.lo +libgtop_sysdeps.la +loadavg.lo +mem.lo +msg_limits.lo +open.lo +procdata.lo +prockernel.lo +proclist.lo +procmem.lo +procsegment.lo +procsignal.lo +procstate.lo +proctime.lo +procuid.lo +sem_limits.lo +shm_limits.lo +swap.lo +sysdeps.lo +sysinfo.lo +uptime.lo diff --git a/sysdeps/kernel/ChangeLog b/sysdeps/kernel/ChangeLog new file mode 100644 index 00000000..51a5a6e8 --- /dev/null +++ b/sysdeps/kernel/ChangeLog @@ -0,0 +1,5 @@ +1998-06-13 Martin Baulig + + The code in this directory fetches all information + directly from the kernel. It uses the new table () + system call from the `kernel' directory. diff --git a/sysdeps/kernel/Makefile.am b/sysdeps/kernel/Makefile.am new file mode 100644 index 00000000..5c5cb132 --- /dev/null +++ b/sysdeps/kernel/Makefile.am @@ -0,0 +1,17 @@ +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@ + +lib_LTLIBRARIES = libgtop_sysdeps.la + +libgtop_sysdeps_la_SOURCES = init.c open.c close.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 + +include_HEADERS = glibtop_server.h diff --git a/sysdeps/kernel/close.c b/sysdeps/kernel/close.c new file mode 100644 index 00000000..02f2e5b3 --- /dev/null +++ b/sysdeps/kernel/close.c @@ -0,0 +1,28 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* Closes pipe to gtop server. */ + +void +glibtop_close_l (glibtop *server) +{ } diff --git a/sysdeps/kernel/cpu.c b/sysdeps/kernel/cpu.c new file mode 100644 index 00000000..10f55d44 --- /dev/null +++ b/sysdeps/kernel/cpu.c @@ -0,0 +1,55 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_cpu = +(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) + +(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) + +(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY); + +/* Provides information about cpu usage. */ + +void +glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_cpu)); + + if (table (TABLE_CPU, &tbl, NULL)) + glibtop_error_r (server, "table(TABLE_CPU): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_cpu; + + buf->total = tbl.cpu.total; + buf->user = tbl.cpu.user; + buf->nice = tbl.cpu.nice; + buf->sys = tbl.cpu.sys; + buf->idle = tbl.cpu.idle; + buf->frequency = tbl.cpu.frequency; +} diff --git a/sysdeps/kernel/glibtop_server.h b/sysdeps/kernel/glibtop_server.h new file mode 100644 index 00000000..52b1b3c0 --- /dev/null +++ b/sysdeps/kernel/glibtop_server.h @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SERVER_H__ +#define __GLIBTOP_SERVER_H__ + +__BEGIN_DECLS + +#define GLIBTOP_SUID_CPU 0 +#define GLIBTOP_SUID_MEM 0 +#define GLIBTOP_SUID_SWAP 0 +#define GLIBTOP_SUID_UPTIME 0 +#define GLIBTOP_SUID_LOADAVG 0 +#define GLIBTOP_SUID_SHM_LIMITS 0 +#define GLIBTOP_SUID_MSG_LIMITS 0 +#define GLIBTOP_SUID_SEM_LIMITS 0 +#define GLIBTOP_SUID_PROCLIST 0 +#define GLIBTOP_SUID_PROC_STATE 0 +#define GLIBTOP_SUID_PROC_UID 0 +#define GLIBTOP_SUID_PROC_MEM 0 +#define GLIBTOP_SUID_PROC_TIME 0 +#define GLIBTOP_SUID_PROC_SIGNAL 0 +#define GLIBTOP_SUID_PROC_KERNEL 0 +#define GLIBTOP_SUID_PROC_SEGMENT 0 + +__END_DECLS + +#endif diff --git a/sysdeps/kernel/init.c b/sysdeps/kernel/init.c new file mode 100644 index 00000000..f491070f --- /dev/null +++ b/sysdeps/kernel/init.c @@ -0,0 +1,44 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = NULL; + +glibtop * +glibtop_init_r (glibtop **server, const unsigned long features, + const unsigned flags) +{ + if (*server != NULL) + return *server; + + fprintf (stderr, "DEBUG: %s (%d)\n", __FILE__, __LINE__); + + if (glibtop_global_server == NULL) { + glibtop_global_server = &_glibtop_global_server; + glibtop_open_r (glibtop_global_server, "glibtop", + features, flags); + } + + return *server = glibtop_global_server; +} diff --git a/sysdeps/kernel/kernel.h b/sysdeps/kernel/kernel.h new file mode 100644 index 00000000..e7380d64 --- /dev/null +++ b/sysdeps/kernel/kernel.h @@ -0,0 +1,38 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_KERNEL_KERNEL_H__ +#define __GLIBTOP_KERNEL_KERNEL_H__ + +#include +#include + +#include + +#include + +__BEGIN_DECLS + +extern int table (int, union table *, const void *); + +__END_DECLS + +#endif diff --git a/sysdeps/kernel/loadavg.c b/sysdeps/kernel/loadavg.c new file mode 100644 index 00000000..e2dbe8ba --- /dev/null +++ b/sysdeps/kernel/loadavg.c @@ -0,0 +1,57 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_loadavg = +(1 << GLIBTOP_LOADAVG_LOADAVG); + +/* Provides load load averange. */ + +void +glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_loadavg)); + + if (table (TABLE_LOADAVG, &tbl, NULL)) + glibtop_error_r (server, "table(TABLE_LOADAVG): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_loadavg; + +#if 0 + 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); +#endif + + buf->loadavg [0] = tbl.loadavg.loadavg [0]; + buf->loadavg [1] = tbl.loadavg.loadavg [1]; + buf->loadavg [2] = tbl.loadavg.loadavg [2]; +} diff --git a/sysdeps/kernel/mem.c b/sysdeps/kernel/mem.c new file mode 100644 index 00000000..2c4104e5 --- /dev/null +++ b/sysdeps/kernel/mem.c @@ -0,0 +1,58 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_mem = +(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) + +(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) + +(1 << GLIBTOP_MEM_BUFFER) + (1 << GLIBTOP_MEM_CACHED) + +(1 << GLIBTOP_MEM_USER); + +/* Provides information about memory usage. */ + +void +glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_mem)); + + if (table (TABLE_MEM, &tbl, NULL)) + glibtop_error_r (server, "table(TABLE_MEM): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_mem; + + buf->total = tbl.mem.total; + buf->used = tbl.mem.used; + buf->free = tbl.mem.free; + buf->shared = tbl.mem.shared; + buf->buffer = tbl.mem.buffer; + buf->cached = tbl.mem.cached; + + buf->user = buf->total - buf->free - buf->shared - buf->buffer; +} diff --git a/sysdeps/kernel/msg_limits.c b/sysdeps/kernel/msg_limits.c new file mode 100644 index 00000000..8b0e6fdc --- /dev/null +++ b/sysdeps/kernel/msg_limits.c @@ -0,0 +1,55 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include + +static const unsigned long _glibtop_sysdeps_msg_limits = +(1 << GLIBTOP_IPC_MSGPOOL) + (1 << GLIBTOP_IPC_MSGMAP) + +(1 << GLIBTOP_IPC_MSGMAX) + (1 << GLIBTOP_IPC_MSGMNB) + +(1 << GLIBTOP_IPC_MSGMNI) + (1 << GLIBTOP_IPC_MSGSSZ) + +(1 << GLIBTOP_IPC_MSGTQL); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) +{ + struct msginfo msginfo; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_msg_limits)); + + buf->flags = _glibtop_sysdeps_msg_limits; + + msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo); + + buf->msgpool = msginfo.msgpool; + buf->msgmap = msginfo.msgmap; + buf->msgmax = msginfo.msgmax; + buf->msgmnb = msginfo.msgmnb; + buf->msgmni = msginfo.msgmni; + buf->msgssz = msginfo.msgssz; + buf->msgtql = msginfo.msgtql; +} diff --git a/sysdeps/kernel/open.c b/sysdeps/kernel/open.c new file mode 100644 index 00000000..69f00051 --- /dev/null +++ b/sysdeps/kernel/open.c @@ -0,0 +1,62 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +/* ===================================================== + * Linux kernel version information for procps utilities + * Copyright (c) 1996 Charles Blake + */ +#include + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +static int linux_version_code = 0; + +static void set_linux_version(void) { + static struct utsname uts; + int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */ + + if (linux_version_code) return; + if (uname(&uts) == -1) /* failure most likely implies impending death */ + exit(1); + if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3) + fprintf(stderr, /* *very* unlikely to happen by accident */ + "Non-standard uts for running kernel:\n" + "release %s=%d.%d.%d gives version code %d\n", + uts.release, x, y, z, LINUX_VERSION(x,y,z)); + linux_version_code = LINUX_VERSION(x, y, z); +} + +/* ======================================================= */ + +/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ + +void +glibtop_open_r (glibtop *server, const char *program_name, + const unsigned long features, const unsigned flags) +{ + memset (server, 0, sizeof (glibtop)); + server->name = program_name; + + set_linux_version (); + server->os_version_code = (unsigned long) linux_version_code; +} diff --git a/sysdeps/kernel/procdata.c b/sysdeps/kernel/procdata.c new file mode 100644 index 00000000..9226b7e0 --- /dev/null +++ b/sysdeps/kernel/procdata.c @@ -0,0 +1,178 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +#define BIT_SHIFT(x) (1 << (x % 32)) + +static const unsigned long _glibtop_sysdeps_procdata_0 = +BIT_SHIFT(GLIBTOP_PROCDATA_CMD) + +BIT_SHIFT(GLIBTOP_PROCDATA_STATE) + +BIT_SHIFT(GLIBTOP_PROCDATA_UID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PPID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) + +BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) + +BIT_SHIFT(GLIBTOP_PROCDATA_TTY) + +BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) + +BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) + +BIT_SHIFT(GLIBTOP_PROCDATA_NICE) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) + +BIT_SHIFT(GLIBTOP_PROCDATA_BLOCKED) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_STIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) + +BIT_SHIFT(GLIBTOP_PROCDATA_SIZE) + +BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) + +BIT_SHIFT(GLIBTOP_PROCDATA_SHARE) + +BIT_SHIFT(GLIBTOP_PROCDATA_TRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_LRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_DRS) + +BIT_SHIFT(GLIBTOP_PROCDATA_DT) + +BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE) + +BIT_SHIFT(GLIBTOP_PROCDATA_RSS) + +BIT_SHIFT(GLIBTOP_PROCDATA_RSS_RLIM) + +BIT_SHIFT(GLIBTOP_PROCDATA_TIMEOUT) + +BIT_SHIFT(GLIBTOP_PROCDATA_IT_REAL_VALUE); + +static const unsigned long _glibtop_sysdeps_procdata_1 = +BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) + +BIT_SHIFT(GLIBTOP_PROCDATA_MIN_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_MAJ_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_CMIN_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_CMAJ_FLT) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) + +BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) + +BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK) + +BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_ESP) + +BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_EIP) + +BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN); + +/* Provides detailed information about a process. */ + +void +glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid) +{ + char input [BUFSIZ], *tmp; + struct stat statb; + int nread; + FILE *f; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_procdata)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags [0] = _glibtop_sysdeps_procdata_0; + buf->flags [1] = _glibtop_sysdeps_procdata_1; + return; + } + + + sprintf (input, "/proc/%d/stat", pid); + + if (stat (input, &statb)) return; + + buf->uid = statb.st_uid; + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + /* This is from guile-utils/gtop/proc/readproc.c */ + + /* split into "PID (cmd" and "" */ + tmp = strrchr (input, ')'); + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + memset (buf->cmd, 0, sizeof (buf->cmd)); + sscanf (input, "%d (%39c", &buf->pid, buf->cmd); + sscanf(tmp + 2, /* skip space after ')' too */ + "%c %d %d %d %d %d %lu %lu %lu %lu %lu " + "%ld %ld %ld %ld %d %d %lu %lu %ld %lu " + "%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu", + &buf->state, &buf->ppid, &buf->pgrp, &buf->session, + &buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt, + &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, + &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, + &buf->priority, &buf->nice, &buf->timeout, + &buf->it_real_value, &buf->start_time, &buf->vsize, + &buf->rss, &buf->rss_rlim, &buf->start_code, + &buf->end_code, &buf->start_stack, &buf->kstk_esp, + &buf->kstk_eip, &buf->signal, &buf->blocked, + &buf->sigignore, &buf->sigcatch, &buf->wchan); + + if (buf->tty == 0) + /* the old notty val, update elsewhere bef. moving to 0 */ + buf->tty = -1; + + if (server->os_version_code < LINUX_VERSION(1,3,39)) { + /* map old meanings to new */ + buf->priority = 2*15 - buf->priority; + buf->nice = 15 - buf->nice; + } + if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) + /* when tty wasn't full devno */ + buf->tty = 4*0x100 + buf->tty; + + fclose (f); + + sprintf (input, "/proc/%d/statm", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + sscanf (input, "%ld %ld %ld %ld %ld %ld %ld", + &buf->size, &buf->resident, &buf->share, + &buf->trs, &buf->lrs, &buf->drs, &buf->dt); + + fclose (f); + + buf->flags [0] = _glibtop_sysdeps_procdata_0; + buf->flags [1] = _glibtop_sysdeps_procdata_1; +} diff --git a/sysdeps/kernel/prockernel.c b/sysdeps/kernel/prockernel.c new file mode 100644 index 00000000..f405f5a9 --- /dev/null +++ b/sysdeps/kernel/prockernel.c @@ -0,0 +1,63 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_proc_kernel = +(1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_MIN_FLT) + +(1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) + +(1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_KSTK_ESP) + +(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1 << GLIBTOP_PROC_KERNEL_WCHAN); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proc_kernel)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_kernel; + return; + } + + if (table (TABLE_PROC_KERNEL, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_KERNEL): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_proc_kernel; + + buf->min_flt = tbl.proc_kernel.min_flt; + buf->cmin_flt = tbl.proc_kernel.cmin_flt; + buf->maj_flt = tbl.proc_kernel.maj_flt; + buf->cmaj_flt = tbl.proc_kernel.cmaj_flt; + buf->kstk_esp = tbl.proc_kernel.kesp; + buf->kstk_eip = tbl.proc_kernel.keip; + buf->wchan = tbl.proc_kernel.wchan; +} diff --git a/sysdeps/kernel/proclist.c b/sysdeps/kernel/proclist.c new file mode 100644 index 00000000..4581cadc --- /dev/null +++ b/sysdeps/kernel/proclist.c @@ -0,0 +1,155 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_proclist = +(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) + +(1 << GLIBTOP_PROCLIST_SIZE); + +#define BLOCK_COUNT 256 +#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned)) + +/* Fetch list of currently running processes. + * + * The interface of this function is a little bit different from the others: + * buf->flags is only set if the call succeeded, in this case pids_chain, + * a list of the pids of all currently running processes is returned, + * buf->number is the number of elements of this list and buf->size is + * the size of one single element (sizeof (unsigned)). The total size is + * stored in buf->total. + * + * The calling function has to free the memory to which a pointer is returned. + * + * On error, NULL is returned and buf->flags is zero. */ + +unsigned * +glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf) +{ + DIR *proc; + struct dirent *entry; + char buffer [BUFSIZ]; + unsigned count, total, pid; + unsigned pids [BLOCK_COUNT], *pids_chain = NULL; + unsigned pids_size = 0, pids_offset = 0, new_size; + struct stat statb; + int len, i, ok; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proclist)); + + proc = opendir ("/proc"); + if (!proc) return NULL; + + /* read every every entry in /proc */ + + for (count = total = 0, entry = readdir (proc); entry; entry = readdir (proc)) { + ok = 1; len = strlen (entry->d_name); + + /* does it consist entirely of digits? */ + + for (i = 0; i < len; i++) + if (!isdigit (entry->d_name [i])) ok = 0; + if (!ok) continue; + + /* convert it in a number */ + + if (sscanf (entry->d_name, "%u", &pid) != 1) continue; + + /* is it really a directory? */ + + sprintf (buffer, "/proc/%d", pid); + + if (stat (buffer, &statb)) continue; + + if (!S_ISDIR (statb.st_mode)) continue; + + /* Fine. Now we first try to store it in pids. If this buffer is + * full, we copy it to the pids_chain. */ + + if (count >= BLOCK_COUNT) { + /* The following call to glibtop_realloc will be equivalent to + * glibtop_malloc if pids_chain is NULL. We just calculate the + * new size and copy pids to the beginning of the newly allocated + * block. */ + + new_size = pids_size + BLOCK_SIZE; + + pids_chain = glibtop_realloc_r (server, pids_chain, new_size); + + memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE); + + pids_size = new_size; + + pids_offset += BLOCK_COUNT; + + count = 0; + } + + /* pids is now big enough to hold at least one single pid. */ + + pids [count++] = pid; + + total++; + } + + closedir (proc); + + /* count is only zero if an error occured (one a running Linux system, we + * only have at least one single process). */ + + if (!count) return NULL; + + /* The following call to glibtop_realloc will be equivalent to + * glibtop_malloc if pids_chain is NULL. We just calculate the + * new size and copy pids to the beginning of the newly allocated + * block. */ + + new_size = pids_size + count * sizeof (unsigned); + + pids_chain = glibtop_realloc_r (server, pids_chain, new_size); + + memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned)); + + pids_size = new_size; + + pids_offset += BLOCK_COUNT; + + /* Since everything is ok now, we can set buf->flags, fill in the remaining fields + and return pids_chain. */ + + buf->flags = _glibtop_sysdeps_proclist; + + buf->size = sizeof (unsigned); + buf->number = total; + + buf->total = total * sizeof (unsigned); + + return pids_chain; +} diff --git a/sysdeps/kernel/procmem.c b/sysdeps/kernel/procmem.c new file mode 100644 index 00000000..5e7c6bb7 --- /dev/null +++ b/sysdeps/kernel/procmem.c @@ -0,0 +1,65 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_proc_mem = +(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_VSIZE) + +(1 << GLIBTOP_PROC_MEM_RESIDENT) + (1 << GLIBTOP_PROC_MEM_SHARE) + +(1 << GLIBTOP_PROC_MEM_RSS) + (1 << GLIBTOP_PROC_MEM_RSS_RLIM); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proc_mem)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_mem; + return; + } + + if (table (TABLE_PROC_MEM, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_MEM): %s\n", strerror (errno)); + + buf->rss = tbl.proc_mem.rss; + buf->rss_rlim = tbl.proc_mem.rlim; + + if (table (TABLE_PROC_SEGMENT, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_SEGMENT): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_proc_mem; + + buf->vsize = tbl.proc_segment.vsize; + buf->size = tbl.proc_segment.size; + buf->resident = tbl.proc_segment.resident; + buf->share = tbl.proc_segment.shared; +} diff --git a/sysdeps/kernel/procsegment.c b/sysdeps/kernel/procsegment.c new file mode 100644 index 00000000..d13fcd94 --- /dev/null +++ b/sysdeps/kernel/procsegment.c @@ -0,0 +1,68 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_proc_segment = +(1 << GLIBTOP_PROC_SEGMENT_TRS) + (1 << GLIBTOP_PROC_SEGMENT_LRS) + +(1 << GLIBTOP_PROC_SEGMENT_DRS) + (1 << GLIBTOP_PROC_SEGMENT_DT) + +(1 << GLIBTOP_PROC_SEGMENT_START_CODE) + (1 << GLIBTOP_PROC_SEGMENT_END_CODE) + +(1 << GLIBTOP_PROC_SEGMENT_START_STACK); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proc_segment)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_segment; + return; + } + + if (table (TABLE_PROC_MEM, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_MEM): %s\n", strerror (errno)); + + buf->start_code = tbl.proc_mem.start_code; + buf->end_code = tbl.proc_mem.end_code; + buf->start_stack = tbl.proc_mem.start_stack; + + if (table (TABLE_PROC_SEGMENT, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_SEGMENT): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_proc_segment; + + buf->trs = tbl.proc_segment.trs; + buf->lrs = tbl.proc_segment.lrs; + buf->drs = tbl.proc_segment.drs; + buf->dt = tbl.proc_segment.dt; +} diff --git a/sysdeps/kernel/procsignal.c b/sysdeps/kernel/procsignal.c new file mode 100644 index 00000000..38795315 --- /dev/null +++ b/sysdeps/kernel/procsignal.c @@ -0,0 +1,59 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_proc_signal = +(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 << GLIBTOP_PROC_SIGNAL_BLOCKED) + +(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 << GLIBTOP_PROC_SIGNAL_SIGCATCH); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proc_signal)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_signal; + return; + } + + if (table (TABLE_PROC_SIGNAL, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_SIGNAL): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_proc_signal; + + buf->signal = tbl.proc_signal.signal; + buf->blocked = tbl.proc_signal.blocked; + buf->sigignore = tbl.proc_signal.ignored; + buf->sigcatch = tbl.proc_signal.caught; + +} diff --git a/sysdeps/kernel/procstate.c b/sysdeps/kernel/procstate.c new file mode 100644 index 00000000..a8a7e153 --- /dev/null +++ b/sysdeps/kernel/procstate.c @@ -0,0 +1,65 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_proc_state = +(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE); + +/* Provides detailed information about a process. */ + +#define NR_STATES 7 + +void +glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) +{ + union table tbl; + static const char states [NR_STATES] = { 'R', 'S', 'D', 'Z', 'T', 'W', '.' }; + unsigned state; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proc_state)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_state; + return; + } + + if (table (TABLE_PROC_STATE, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_STATE): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_proc_state; + + memcpy (buf->cmd, tbl.proc_state.comm, sizeof (tbl.proc_state.comm)); + + state = (unsigned) tbl.proc_state.state; + + if (state >= NR_STATES) + state = NR_STATES; + + buf->state = states [state]; +} diff --git a/sysdeps/kernel/proctime.c b/sysdeps/kernel/proctime.c new file mode 100644 index 00000000..6b5945a2 --- /dev/null +++ b/sysdeps/kernel/proctime.c @@ -0,0 +1,61 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_proc_time = +(1 << GLIBTOP_PROC_TIME_UTIME) + (1 << GLIBTOP_PROC_TIME_CUTIME) + +(1 << GLIBTOP_PROC_TIME_STIME) + (1 << GLIBTOP_PROC_TIME_CSTIME) + +(1 << GLIBTOP_PROC_TIME_TIMEOUT) + (1 << GLIBTOP_PROC_TIME_IT_REAL_VALUE) + +(1 << GLIBTOP_PROC_TIME_START_TIME); + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proc_time)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_time; + return; + } + + if (table (TABLE_PROC_TIME, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_TIME): %s\n", strerror (errno)); + + buf->utime = tbl.proc_time.utime; + buf->stime = tbl.proc_time.stime; + buf->cutime = tbl.proc_time.cutime; + buf->cstime = tbl.proc_time.cstime; + buf->timeout = tbl.proc_time.timeout; + buf->it_real_value = tbl.proc_time.it_real_value; + buf->start_time = tbl.proc_time.start_time; +} diff --git a/sysdeps/kernel/procuid.c b/sysdeps/kernel/procuid.c new file mode 100644 index 00000000..3200c07d --- /dev/null +++ b/sysdeps/kernel/procuid.c @@ -0,0 +1,100 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static const unsigned long _glibtop_sysdeps_proc_uid = +(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) + +(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) + +(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) + +(1 << GLIBTOP_PROC_UID_PGRP) + (1 << GLIBTOP_PROC_UID_SESSION) + +(1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID) + +(1 << GLIBTOP_PROC_UID_PRIORITY) + (1 << GLIBTOP_PROC_UID_NICE); + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) +{ + union table tbl; + long def_priority, priority, nice; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_proc_uid)); + + if (pid == 0) { + /* Client is only interested in the flags. */ + buf->flags = _glibtop_sysdeps_proc_uid; + return; + } + + if (table (TABLE_PROC_UID, &tbl, &pid)) + glibtop_error_r (server, "table(TABLE_PROC_UID): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_proc_uid; + + buf->uid = tbl.proc_uid.uid; + buf->euid = tbl.proc_uid.euid; + buf->gid = tbl.proc_uid.gid; + buf->egid = tbl.proc_uid.egid; + + buf->pid = tbl.proc_uid.pid; + buf->ppid = tbl.proc_uid.ppid; + buf->pgrp = tbl.proc_uid.pgrp; + buf->session = tbl.proc_uid.session; + buf->tty = tbl.proc_uid.tty; + buf->tpgid = tbl.proc_uid.tpgid; + + /* scale priority and nice values from timeslices to -20..20 */ + /* to make it look like a "normal" unix priority/nice value */ + + def_priority = tbl.proc_uid.def_priority; + + priority = tbl.proc_uid.counter; + priority = 20 - (priority * 10 + def_priority / 2) / def_priority; + nice = tbl.proc_uid.priority; + nice = 20 - (nice * 20 + def_priority / 2) / def_priority; + + buf->priority = (int) priority; + buf->nice = (int) nice; + + if (buf->tty == 0) + /* the old notty val, update elsewhere bef. moving to 0 */ + buf->tty = -1; + + if (server->os_version_code < LINUX_VERSION(1,3,39)) { + /* map old meanings to new */ + buf->priority = 2*15 - buf->priority; + buf->nice = 15 - buf->nice; + } + if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1) + /* when tty wasn't full devno */ + buf->tty = 4*0x100 + buf->tty; + + buf->flags = _glibtop_sysdeps_proc_uid; +} diff --git a/sysdeps/kernel/sem_limits.c b/sysdeps/kernel/sem_limits.c new file mode 100644 index 00000000..88176f0b --- /dev/null +++ b/sysdeps/kernel/sem_limits.c @@ -0,0 +1,61 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include + +static unsigned long _glibtop_sysdeps_sem_limits = +(1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) + +(1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) + +(1 << GLIBTOP_IPC_SEMMSL) + (1 << GLIBTOP_IPC_SEMOPM) + +(1 << GLIBTOP_IPC_SEMUME) + (1 << GLIBTOP_IPC_SEMUSZ) + +(1 << GLIBTOP_IPC_SEMVMX) + (1 << GLIBTOP_IPC_SEMAEM); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) +{ + struct seminfo seminfo; + union semun arg; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_sem_limits)); + + buf->flags = _glibtop_sysdeps_sem_limits; + + arg.array = (ushort *) &seminfo; + semctl (0, 0, IPC_INFO, arg); + + buf->semmap = seminfo.semmap; + buf->semmni = seminfo.semmni; + buf->semmns = seminfo.semmns; + buf->semmnu = seminfo.semmnu; + buf->semmsl = seminfo.semmsl; + buf->semopm = seminfo.semopm; + buf->semume = seminfo.semume; + buf->semusz = seminfo.semusz; + buf->semvmx = seminfo.semvmx; + buf->semaem = seminfo.semaem; +} diff --git a/sysdeps/kernel/shm_limits.c b/sysdeps/kernel/shm_limits.c new file mode 100644 index 00000000..2849b22d --- /dev/null +++ b/sysdeps/kernel/shm_limits.c @@ -0,0 +1,52 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include + +static unsigned long _glibtop_sysdeps_shm_limits = +(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) + +(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG) + +(1 << GLIBTOP_IPC_SHMALL); + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) +{ + struct shminfo shminfo; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_shm_limits)); + + buf->flags = _glibtop_sysdeps_shm_limits; + + shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo); + + buf->shmmax = shminfo.shmmax; + buf->shmmin = shminfo.shmmin; + buf->shmmni = shminfo.shmmni; + buf->shmseg = shminfo.shmseg; + buf->shmall = shminfo.shmall; +} diff --git a/sysdeps/kernel/swap.c b/sysdeps/kernel/swap.c new file mode 100644 index 00000000..5e3f62f8 --- /dev/null +++ b/sysdeps/kernel/swap.c @@ -0,0 +1,51 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static unsigned long _glibtop_sysdeps_swap = +(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) + +(1 << GLIBTOP_SWAP_FREE); + +/* Provides information about swap usage. */ + +void +glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_swap)); + + if (table (TABLE_SWAP, &tbl, NULL)) + glibtop_error_r (server, "table(TABLE_SWAP): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_swap; + + buf->total = tbl.swap.total; + buf->used = tbl.swap.used; + buf->free = tbl.swap.free; +} diff --git a/sysdeps/kernel/uptime.c b/sysdeps/kernel/uptime.c new file mode 100644 index 00000000..63fdc859 --- /dev/null +++ b/sysdeps/kernel/uptime.c @@ -0,0 +1,54 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include +#include + +#include "kernel.h" + +static unsigned long _glibtop_sysdeps_uptime = +(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME); + +/* Provides uptime and idle time. */ + +void +glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) +{ + union table tbl; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_uptime)); + + if (table (TABLE_UPTIME, &tbl, NULL)) + glibtop_error_r (server, "table(TABLE_UPTIME): %s\n", strerror (errno)); + + buf->flags = _glibtop_sysdeps_uptime; + +#if 0 + fprintf (stderr, "Table (%u) = %lu, %lu\n", + TABLE_UPTIME, tbl.uptime.uptime, tbl.uptime.idle); +#endif + + buf->uptime = (double) tbl.uptime.uptime / HZ; + buf->idletime = (double) tbl.uptime.idle / HZ; +} From 9661c4becc48e0f30450a4e6fc2b14ad6a86955a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 13 Jun 1998 21:26:49 +0000 Subject: [PATCH 0113/2539] New directory. Contains some kernel code to implement a new system call 1998-06-13 Martin Baulig * 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. --- ChangeLog | 14 ++++++++++++++ configure.in | 14 ++------------ examples/first.c | 8 ++++++++ sysdeps/Makefile.am | 2 +- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0128056d..31c702e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +1998-06-13 Martin Baulig + + * 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 * include/glibtop/sysdeps.h (glibtop_types_sysdeps): diff --git a/configure.in b/configure.in index b79253c1..e64f7da0 100644 --- a/configure.in +++ b/configure.in @@ -8,23 +8,12 @@ AC_CANONICAL_SYSTEM AM_ACLOCAL_INCLUDE(macros) -dnl This is necessary for cross-compiling for programs -dnl that need to run on the build host. - -AC_CHECK_PROG(build_CC, gcc, gcc) -if test -z "$build_CC" ; then - AC_CHECK_PROG(build_CC, cc, cc, , , /usr/ucb/cc) - test -z "$build_CC" && \ - AC_MSG_ERROR([no acceptable cc found in \$PATH]) -fi - -AC_CHECK_TOOL(CC,gcc) - AC_ISC_POSIX AC_PROG_CC AC_STDC_HEADERS AC_ARG_PROGRAM +AC_CHECK_TOOL(CC,gcc) AC_CHECK_TOOL(RANLIB,ranlib) AC_CHECK_TOOL(AS,as) AC_CHECK_TOOL(AR,ar) @@ -226,6 +215,7 @@ sysdeps/stub/Makefile sysdeps/sun4/Makefile sysdeps/osf1/Makefile sysdeps/linux/Makefile +sysdeps/kernel/Makefile src/Makefile src/server/Makefile src/proxy/Makefile diff --git a/examples/first.c b/examples/first.c index d93e8f3b..2853eb2a 100644 --- a/examples/first.c +++ b/examples/first.c @@ -33,6 +33,14 @@ #define PROFILE_COUNT 1 #endif +#include +#include +#include + +#include + +_syscall3 (int, table, int, type, union table *, tbl, const void *, param); + int main (int argc, char *argv []) { diff --git a/sysdeps/Makefile.am b/sysdeps/Makefile.am index 5625c33f..d12f6d78 100644 --- a/sysdeps/Makefile.am +++ b/sysdeps/Makefile.am @@ -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 From 6fd3c113ec11a47acf0d7c6bf11c48c418d5760e Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 13 Jun 1998 22:53:55 +0000 Subject: [PATCH 0114/2539] List of features for `guile-names.awk'. 1998-06-13 Martin Baulig * 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. --- ChangeLog | 7 ++ features.def | 17 +++ include/glibtop/loadavg.h | 2 +- sysdeps/guile/names/Makefile.am | 14 ++- sysdeps/guile/names/boot.c | 174 ---------------------------- sysdeps/guile/names/cpu.c | 95 --------------- sysdeps/guile/names/guile-names.awk | 121 +++++++++++++++++++ sysdeps/guile/names/loadavg.c | 95 --------------- sysdeps/guile/names/mem.c | 95 --------------- sysdeps/guile/names/msg_limits.c | 95 --------------- sysdeps/guile/names/prockernel.c | 95 --------------- sysdeps/guile/names/proclist.c | 96 --------------- sysdeps/guile/names/procmem.c | 95 --------------- sysdeps/guile/names/procsegment.c | 95 --------------- sysdeps/guile/names/procsignal.c | 95 --------------- sysdeps/guile/names/procstate.c | 95 --------------- sysdeps/guile/names/proctime.c | 95 --------------- sysdeps/guile/names/procuid.c | 95 --------------- sysdeps/guile/names/sem_limits.c | 89 -------------- sysdeps/guile/names/shm_limits.c | 89 -------------- sysdeps/guile/names/swap.c | 89 -------------- sysdeps/guile/names/sysdeps.c | 89 -------------- sysdeps/guile/names/uptime.c | 89 -------------- sysdeps/names/loadavg.c | 2 +- 24 files changed, 156 insertions(+), 1767 deletions(-) create mode 100644 features.def delete mode 100644 sysdeps/guile/names/boot.c delete mode 100644 sysdeps/guile/names/cpu.c create mode 100644 sysdeps/guile/names/guile-names.awk delete mode 100644 sysdeps/guile/names/loadavg.c delete mode 100644 sysdeps/guile/names/mem.c delete mode 100644 sysdeps/guile/names/msg_limits.c delete mode 100644 sysdeps/guile/names/prockernel.c delete mode 100644 sysdeps/guile/names/proclist.c delete mode 100644 sysdeps/guile/names/procmem.c delete mode 100644 sysdeps/guile/names/procsegment.c delete mode 100644 sysdeps/guile/names/procsignal.c delete mode 100644 sysdeps/guile/names/procstate.c delete mode 100644 sysdeps/guile/names/proctime.c delete mode 100644 sysdeps/guile/names/procuid.c delete mode 100644 sysdeps/guile/names/sem_limits.c delete mode 100644 sysdeps/guile/names/shm_limits.c delete mode 100644 sysdeps/guile/names/swap.c delete mode 100644 sysdeps/guile/names/sysdeps.c delete mode 100644 sysdeps/guile/names/uptime.c diff --git a/ChangeLog b/ChangeLog index 31c702e6..d1c63f8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 1998-06-13 Martin Baulig + * 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. diff --git a/features.def b/features.def new file mode 100644 index 00000000..dc17abb0 --- /dev/null +++ b/features.def @@ -0,0 +1,17 @@ +cpu +mem +swap +uptime +loadavg +shm_limits +msg_limits +sem_limits +proclist +proc_state +proc_uid +proc_mem +proc_time +proc_signal +proc_kernel +proc_segment +sysdeps diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h index 661e9032..cadbb423 100644 --- a/include/glibtop/loadavg.h +++ b/include/glibtop/loadavg.h @@ -79,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 unsigned glibtop_types_loadavg []; extern const char *glibtop_labels_loadavg []; extern const char *glibtop_descriptions_loadavg []; diff --git a/sysdeps/guile/names/Makefile.am b/sysdeps/guile/names/Makefile.am index 80f4fb88..07c4bba4 100644 --- a/sysdeps/guile/names/Makefile.am +++ b/sysdeps/guile/names/Makefile.am @@ -8,9 +8,13 @@ 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 diff --git a/sysdeps/guile/names/boot.c b/sysdeps/guile/names/boot.c deleted file mode 100644 index 01ceb255..00000000 --- a/sysdeps/guile/names/boot.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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); -} diff --git a/sysdeps/guile/names/cpu.c b/sysdeps/guile/names/cpu.c deleted file mode 100644 index eed68f17..00000000 --- a/sysdeps/guile/names/cpu.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_ulong2scm (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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_cpu [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/guile-names.awk b/sysdeps/guile/names/guile-names.awk new file mode 100644 index 00000000..54ecb6e8 --- /dev/null +++ b/sysdeps/guile/names/guile-names.awk @@ -0,0 +1,121 @@ +BEGIN { + print "/* guile_names.c */"; + print "/* This is a generated file. Please modify `guile-names.awk' */"; + print ""; + + print "#include "; + print "#include "; + print ""; + print "#include "; + + print ""; + +} + +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 "}"; +} + diff --git a/sysdeps/guile/names/loadavg.c b/sysdeps/guile/names/loadavg.c deleted file mode 100644 index c6e37127..00000000 --- a/sysdeps/guile/names/loadavg.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_ulong2scm (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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_loadavg [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/mem.c b/sysdeps/guile/names/mem.c deleted file mode 100644 index 06160766..00000000 --- a/sysdeps/guile/names/mem.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_ulong2scm (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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_mem [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/msg_limits.c b/sysdeps/guile/names/msg_limits.c deleted file mode 100644 index 9225c9af..00000000 --- a/sysdeps/guile/names/msg_limits.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_ulong2scm (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_append - (gh_list (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_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_msg_limits [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/prockernel.c b/sysdeps/guile/names/prockernel.c deleted file mode 100644 index 1fbd0e95..00000000 --- a/sysdeps/guile/names/prockernel.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_names_proc_kernel (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proc_kernel [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proc_kernel (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proc_kernel [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proc_kernel (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proc_kernel [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proc_kernel (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proc_kernel [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/proclist.c b/sysdeps/guile/names/proclist.c deleted file mode 100644 index 2dc568cc..00000000 --- a/sysdeps/guile/names/proclist.c +++ /dev/null @@ -1,96 +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 , 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 -#include -#include - -#include - -SCM -glibtop_guile_names_proclist (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proclist [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proclist (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proclist [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proclist (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proclist [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proclist (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proclist [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/procmem.c b/sysdeps/guile/names/procmem.c deleted file mode 100644 index a114a530..00000000 --- a/sysdeps/guile/names/procmem.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_names_proc_mem (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proc_mem [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proc_mem (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proc_mem [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proc_mem (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proc_mem [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proc_mem (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proc_mem [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/procsegment.c b/sysdeps/guile/names/procsegment.c deleted file mode 100644 index 926ae65f..00000000 --- a/sysdeps/guile/names/procsegment.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_names_proc_segment (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proc_segment [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proc_segment (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proc_segment [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proc_segment (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proc_segment [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proc_segment (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proc_segment [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/procsignal.c b/sysdeps/guile/names/procsignal.c deleted file mode 100644 index e3c8da87..00000000 --- a/sysdeps/guile/names/procsignal.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_names_proc_signal (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proc_signal [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proc_signal (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proc_signal [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proc_signal (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proc_signal [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proc_signal (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proc_signal [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/procstate.c b/sysdeps/guile/names/procstate.c deleted file mode 100644 index 8575fc69..00000000 --- a/sysdeps/guile/names/procstate.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_names_proc_state (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proc_state [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proc_state (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proc_state [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proc_state (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proc_state [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proc_state (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proc_state [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/proctime.c b/sysdeps/guile/names/proctime.c deleted file mode 100644 index 67cbd924..00000000 --- a/sysdeps/guile/names/proctime.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_names_proc_time (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proc_time [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proc_time (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proc_time [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proc_time (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proc_time [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proc_time (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proc_time [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/procuid.c b/sysdeps/guile/names/procuid.c deleted file mode 100644 index b47eb226..00000000 --- a/sysdeps/guile/names/procuid.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_names_proc_uid (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (glibtop_names_proc_uid [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_proc_uid (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_proc_uid [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_proc_uid (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_labels_proc_uid [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_proc_uid (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++) - list = gh_append - (gh_list (list, - gh_list (gh_str02scm (gettext - (glibtop_descriptions_proc_uid [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/sem_limits.c b/sysdeps/guile/names/sem_limits.c deleted file mode 100644 index 6c88555c..00000000 --- a/sysdeps/guile/names/sem_limits.c +++ /dev/null @@ -1,89 +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 , 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 -#include - -#include - -SCM -glibtop_guile_names_sem_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_names_sem_limits [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_sem_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_sem_limits [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_sem_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_labels_sem_limits [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_sem_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_descriptions_sem_limits [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/shm_limits.c b/sysdeps/guile/names/shm_limits.c deleted file mode 100644 index 50c7c0d8..00000000 --- a/sysdeps/guile/names/shm_limits.c +++ /dev/null @@ -1,89 +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 , 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 -#include - -#include - -SCM -glibtop_guile_names_shm_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_names_shm_limits [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_shm_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_shm_limits [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_shm_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_labels_shm_limits [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_shm_limits (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_descriptions_shm_limits [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/swap.c b/sysdeps/guile/names/swap.c deleted file mode 100644 index 720d6371..00000000 --- a/sysdeps/guile/names/swap.c +++ /dev/null @@ -1,89 +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 , 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 -#include - -#include - -SCM -glibtop_guile_names_swap (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_names_swap [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_swap (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_swap [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_swap (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_labels_swap [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_swap (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SWAP; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_descriptions_swap [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/sysdeps.c b/sysdeps/guile/names/sysdeps.c deleted file mode 100644 index d9ed5af5..00000000 --- a/sysdeps/guile/names/sysdeps.c +++ /dev/null @@ -1,89 +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 , 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 -#include - -#include - -SCM -glibtop_guile_names_sysdeps (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_names_sysdeps [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_sysdeps (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_sysdeps [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_sysdeps (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_labels_sysdeps [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_sysdeps (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_descriptions_sysdeps [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/guile/names/uptime.c b/sysdeps/guile/names/uptime.c deleted file mode 100644 index eb708aff..00000000 --- a/sysdeps/guile/names/uptime.c +++ /dev/null @@ -1,89 +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 , 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 -#include - -#include - -SCM -glibtop_guile_names_uptime (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (glibtop_names_uptime [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_types_uptime (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (gh_list (list, - gh_list (gh_ulong2scm (glibtop_types_uptime [i])), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_uptime (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_labels_uptime [i]))), - SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_descriptions_uptime (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_UPTIME; i++) - list = gh_append (gh_list (list, - gh_list (gh_str02scm (gettext (glibtop_descriptions_uptime [i]))), - SCM_UNDEFINED)); - - return list; -} diff --git a/sysdeps/names/loadavg.c b/sysdeps/names/loadavg.c index 351f3675..fc6ce7c2 100644 --- a/sysdeps/names/loadavg.c +++ b/sysdeps/names/loadavg.c @@ -26,7 +26,7 @@ const char *glibtop_names_loadavg [GLIBTOP_MAX_LOADAVG] = "loadavg" }; -const char *glibtop_types_loadavg [GLIBTOP_MAX_LOADAVG] = +const unsigned glibtop_types_loadavg [GLIBTOP_MAX_LOADAVG] = { GLIBTOP_TYPE_DOUBLE }; From 13148c632fb5a4cb52e6135d4d295cf94baf878f Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 00:57:03 +0000 Subject: [PATCH 0115/2539] New file. Creates `gulie.c' depending upon `features.def'. 1998-06-14 Martin Baulig * sysdeps/guile/guile.awk: New file. Creates `gulie.c' depending upon `features.def'. * sysdeps/guile/*.c: Removed. --- ChangeLog | 7 +++ features.def | 33 ++++++----- sysdeps/guile/Makefile.am | 12 ++++ sysdeps/guile/boot.c | 66 ---------------------- sysdeps/guile/cpu.c | 41 -------------- sysdeps/guile/guile.awk | 87 +++++++++++++++++++++++++++++ sysdeps/guile/loadavg.c | 38 ------------- sysdeps/guile/mem.c | 43 -------------- sysdeps/guile/msg_limits.c | 42 -------------- sysdeps/guile/names/Makefile.am | 2 + sysdeps/guile/names/guile-names.awk | 28 +++++----- sysdeps/guile/prockernel.c | 44 --------------- sysdeps/guile/proclist.c | 55 ------------------ sysdeps/guile/procmem.c | 42 -------------- sysdeps/guile/procsegment.c | 43 -------------- sysdeps/guile/procsignal.c | 40 ------------- sysdeps/guile/procstate.c | 40 ------------- sysdeps/guile/proctime.c | 43 -------------- sysdeps/guile/procuid.c | 48 ---------------- sysdeps/guile/sem_limits.c | 45 --------------- sysdeps/guile/shm_limits.c | 40 ------------- sysdeps/guile/swap.c | 38 ------------- sysdeps/guile/sysdeps.c | 51 ----------------- sysdeps/guile/uptime.c | 37 ------------ 24 files changed, 138 insertions(+), 827 deletions(-) delete mode 100644 sysdeps/guile/boot.c delete mode 100644 sysdeps/guile/cpu.c create mode 100644 sysdeps/guile/guile.awk delete mode 100644 sysdeps/guile/loadavg.c delete mode 100644 sysdeps/guile/mem.c delete mode 100644 sysdeps/guile/msg_limits.c delete mode 100644 sysdeps/guile/prockernel.c delete mode 100644 sysdeps/guile/proclist.c delete mode 100644 sysdeps/guile/procmem.c delete mode 100644 sysdeps/guile/procsegment.c delete mode 100644 sysdeps/guile/procsignal.c delete mode 100644 sysdeps/guile/procstate.c delete mode 100644 sysdeps/guile/proctime.c delete mode 100644 sysdeps/guile/procuid.c delete mode 100644 sysdeps/guile/sem_limits.c delete mode 100644 sysdeps/guile/shm_limits.c delete mode 100644 sysdeps/guile/swap.c delete mode 100644 sysdeps/guile/sysdeps.c delete mode 100644 sysdeps/guile/uptime.c diff --git a/ChangeLog b/ChangeLog index d1c63f8c..af366a67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1998-06-14 Martin Baulig + + * sysdeps/guile/guile.awk: New file. + Creates `gulie.c' depending upon `features.def'. + + * sysdeps/guile/*.c: Removed. + 1998-06-13 Martin Baulig * features.def: List of features for `guile-names.awk'. diff --git a/features.def b/features.def index dc17abb0..d4de80a1 100644 --- a/features.def +++ b/features.def @@ -1,17 +1,16 @@ -cpu -mem -swap -uptime -loadavg -shm_limits -msg_limits -sem_limits -proclist -proc_state -proc_uid -proc_mem -proc_time -proc_signal -proc_kernel -proc_segment -sysdeps +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) diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am index 19bd1d1d..50372156 100644 --- a/sysdeps/guile/Makefile.am +++ b/sysdeps/guile/Makefile.am @@ -19,3 +19,15 @@ libgtop_guile_la_SOURCES = boot.c sysdeps.c cpu.c mem.c swap.c uptime.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 diff --git a/sysdeps/guile/boot.c b/sysdeps/guile/boot.c deleted file mode 100644 index fbd86941..00000000 --- a/sysdeps/guile/boot.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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); - -} diff --git a/sysdeps/guile/cpu.c b/sysdeps/guile/cpu.c deleted file mode 100644 index 707b4af7..00000000 --- a/sysdeps/guile/cpu.c +++ /dev/null @@ -1,41 +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 , 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 -#include - -#include - -SCM glibtop_guile_get_cpu (void) -{ - glibtop_cpu cpu; - - glibtop_get_cpu (&cpu); - - return gh_list (gh_ulong2scm (cpu.flags), - gh_ulong2scm (cpu.total), - gh_ulong2scm (cpu.user), - gh_ulong2scm (cpu.nice), - gh_ulong2scm (cpu.sys), - gh_ulong2scm (cpu.idle), - gh_ulong2scm (cpu.frequency), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/guile.awk b/sysdeps/guile/guile.awk new file mode 100644 index 00000000..25d293f0 --- /dev/null +++ b/sysdeps/guile/guile.awk @@ -0,0 +1,87 @@ +BEGIN { + print "/* guile.c */"; + print "/* This is a generated file. Please modify `guile.awk' */"; + print ""; + + print "#include "; + print "#include "; + print "#include "; + print ""; + print "#include "; + + 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 "}"; +} + diff --git a/sysdeps/guile/loadavg.c b/sysdeps/guile/loadavg.c deleted file mode 100644 index 1ace95ff..00000000 --- a/sysdeps/guile/loadavg.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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); -} diff --git a/sysdeps/guile/mem.c b/sysdeps/guile/mem.c deleted file mode 100644 index 38618dc0..00000000 --- a/sysdeps/guile/mem.c +++ /dev/null @@ -1,43 +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 , 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 -#include - -#include - -SCM glibtop_guile_get_mem (void) -{ - glibtop_mem mem; - - glibtop_get_mem (&mem); - - return gh_list (gh_ulong2scm (mem.flags), - gh_ulong2scm (mem.total), - gh_ulong2scm (mem.used), - gh_ulong2scm (mem.free), - gh_ulong2scm (mem.shared), - gh_ulong2scm (mem.buffer), - gh_ulong2scm (mem.cached), - gh_ulong2scm (mem.user), - gh_ulong2scm (mem.locked), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/msg_limits.c b/sysdeps/guile/msg_limits.c deleted file mode 100644 index 35e88593..00000000 --- a/sysdeps/guile/msg_limits.c +++ /dev/null @@ -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 , 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 -#include - -#include - -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); -} diff --git a/sysdeps/guile/names/Makefile.am b/sysdeps/guile/names/Makefile.am index 07c4bba4..cd86bc57 100644 --- a/sysdeps/guile/names/Makefile.am +++ b/sysdeps/guile/names/Makefile.am @@ -18,3 +18,5 @@ guile-names.c: guile-names.awk $(top_builddir)/config.h $(top_builddir)/features EXTRA_DIST = guile-names.awk +CLEANFILES = guile-names.c + diff --git a/sysdeps/guile/names/guile-names.awk b/sysdeps/guile/names/guile-names.awk index 54ecb6e8..11693343 100644 --- a/sysdeps/guile/names/guile-names.awk +++ b/sysdeps/guile/names/guile-names.awk @@ -12,19 +12,19 @@ BEGIN { } -output ($feature) { +function output(feature) { print "SCM"; - print "glibtop_guile_names_"$feature" (void)"; + 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 "\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 gh_list (gh_str02scm ((char *) glibtop_names_"feature" [i])),"; print "\t\t\t\t SCM_UNDEFINED));"; print ""; print "\treturn list;"; @@ -33,17 +33,17 @@ output ($feature) { print ""; print "SCM"; - print "glibtop_guile_types_"$feature" (void)"; + 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 "\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 gh_list (gh_ulong2scm (glibtop_types_"feature" [i])),"; print "\t\t\t\t SCM_UNDEFINED));"; print ""; print "\treturn list;"; @@ -52,18 +52,18 @@ output ($feature) { print ""; print "SCM"; - print "glibtop_guile_labels_"$feature" (void)"; + 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 "\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\t\t\t(glibtop_labels_"feature" [i]))),"; print "\t\t\t\t SCM_UNDEFINED));"; print ""; print "\treturn list;"; @@ -72,18 +72,18 @@ output ($feature) { print ""; print "SCM"; - print "glibtop_guile_descriptions_"$feature" (void)"; + 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 "\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\t\t\t(glibtop_descriptions_"feature" [i]))),"; print "\t\t\t\t SCM_UNDEFINED));"; print ""; print "\treturn list;"; @@ -96,7 +96,7 @@ output ($feature) { END { for (feature in features) { - output (feature); + output(feature); } print "void"; diff --git a/sysdeps/guile/prockernel.c b/sysdeps/guile/prockernel.c deleted file mode 100644 index 6702467c..00000000 --- a/sysdeps/guile/prockernel.c +++ /dev/null @@ -1,44 +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 , 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 -#include - -#include - -SCM -glibtop_guile_get_proc_kernel (SCM pid) -{ - glibtop_proc_kernel p; - - glibtop_get_proc_kernel (&p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_ulong2scm (p.flags), - gh_ulong2scm (p.k_flags), - gh_ulong2scm (p.min_flt), - gh_ulong2scm (p.maj_flt), - gh_ulong2scm (p.cmin_flt), - gh_ulong2scm (p.cmaj_flt), - gh_ulong2scm (p.kstk_esp), - gh_ulong2scm (p.kstk_eip), - gh_ulong2scm (p.wchan), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/proclist.c b/sysdeps/guile/proclist.c deleted file mode 100644 index 7491805f..00000000 --- a/sysdeps/guile/proclist.c +++ /dev/null @@ -1,55 +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 , 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 -#include -#include - -#include - -SCM -glibtop_guile_get_proclist (void) -{ - glibtop_proclist proclist; - unsigned *ptr; - unsigned i; - SCM list; - - ptr = glibtop_get_proclist (&proclist); - - list = gh_list (gh_ulong2scm (proclist.flags), - gh_ulong2scm (proclist.number), - gh_ulong2scm (proclist.size), - gh_ulong2scm (proclist.total), - SCM_UNDEFINED); - - if (ptr) { - for (i = 0; i < proclist.number; i++) - list = gh_append - (gh_list (list, - gh_list (gh_ulong2scm ((unsigned long) ptr [i])), - SCM_UNDEFINED)); - } - - glibtop_free (ptr); - - return list; -} diff --git a/sysdeps/guile/procmem.c b/sysdeps/guile/procmem.c deleted file mode 100644 index e1862c3b..00000000 --- a/sysdeps/guile/procmem.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM -glibtop_guile_get_proc_mem (SCM pid) -{ - glibtop_proc_mem p; - - glibtop_get_proc_mem (&p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_ulong2scm (p.flags), - gh_long2scm (p.size), - gh_long2scm (p.vsize), - gh_long2scm (p.resident), - gh_long2scm (p.share), - gh_long2scm (p.rss), - gh_long2scm (p.rss_rlim), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/procsegment.c b/sysdeps/guile/procsegment.c deleted file mode 100644 index dbc49915..00000000 --- a/sysdeps/guile/procsegment.c +++ /dev/null @@ -1,43 +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 , 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 -#include - -#include - -SCM -glibtop_guile_get_proc_segment (SCM pid) -{ - glibtop_proc_segment p; - - glibtop_get_proc_segment (&p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_ulong2scm (p.flags), - gh_long2scm (p.trs), - gh_long2scm (p.lrs), - gh_long2scm (p.drs), - gh_long2scm (p.dt), - gh_ulong2scm (p.start_code), - gh_ulong2scm (p.end_code), - gh_ulong2scm (p.start_stack), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/procsignal.c b/sysdeps/guile/procsignal.c deleted file mode 100644 index 9b580c5b..00000000 --- a/sysdeps/guile/procsignal.c +++ /dev/null @@ -1,40 +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 , 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 -#include - -#include - -SCM -glibtop_guile_get_proc_signal (SCM pid) -{ - glibtop_proc_signal p; - - glibtop_get_proc_signal (&p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_ulong2scm (p.flags), - gh_long2scm (p.signal), - gh_long2scm (p.blocked), - gh_long2scm (p.sigignore), - gh_long2scm (p.sigcatch), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/procstate.c b/sysdeps/guile/procstate.c deleted file mode 100644 index 1b51f2ed..00000000 --- a/sysdeps/guile/procstate.c +++ /dev/null @@ -1,40 +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 , 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 -#include - -#include - -SCM -glibtop_guile_get_proc_state (SCM pid) -{ - glibtop_proc_state p; - - glibtop_get_proc_state (&p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_ulong2scm (p.flags), - gh_str02scm (p.cmd), - gh_char2scm (p.state), - gh_ulong2scm (p.uid), - gh_ulong2scm (p.gid), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/proctime.c b/sysdeps/guile/proctime.c deleted file mode 100644 index 52a6bfcd..00000000 --- a/sysdeps/guile/proctime.c +++ /dev/null @@ -1,43 +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 , 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 -#include - -#include - -SCM -glibtop_guile_get_proc_time (SCM pid) -{ - glibtop_proc_time p; - - glibtop_get_proc_time (&p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_ulong2scm (p.flags), - gh_long2scm (p.start_time), - gh_long2scm (p.utime), - gh_long2scm (p.stime), - gh_long2scm (p.cutime), - gh_long2scm (p.cstime), - gh_long2scm (p.timeout), - gh_long2scm (p.it_real_value), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/procuid.c b/sysdeps/guile/procuid.c deleted file mode 100644 index 96c7033c..00000000 --- a/sysdeps/guile/procuid.c +++ /dev/null @@ -1,48 +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 , 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 -#include - -#include - -SCM -glibtop_guile_get_proc_uid (SCM pid) -{ - glibtop_proc_uid p; - - glibtop_get_proc_uid (&p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_ulong2scm (p.flags), - gh_long2scm (p.uid), - gh_long2scm (p.euid), - gh_long2scm (p.gid), - gh_long2scm (p.egid), - gh_long2scm (p.pid), - gh_long2scm (p.ppid), - gh_long2scm (p.pgrp), - gh_long2scm (p.session), - gh_long2scm (p.tty), - gh_long2scm (p.tpgid), - gh_long2scm (p.priority), - gh_long2scm (p.nice), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/sem_limits.c b/sysdeps/guile/sem_limits.c deleted file mode 100644 index ca2b10af..00000000 --- a/sysdeps/guile/sem_limits.c +++ /dev/null @@ -1,45 +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 , 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 -#include - -#include - -SCM glibtop_guile_get_sem_limits (void) -{ - glibtop_sem_limits sem_limits; - - glibtop_get_sem_limits (&sem_limits); - - return gh_list (gh_ulong2scm (sem_limits.flags), - gh_ulong2scm (sem_limits.semmap), - gh_ulong2scm (sem_limits.semmni), - gh_ulong2scm (sem_limits.semmns), - gh_ulong2scm (sem_limits.semmnu), - gh_ulong2scm (sem_limits.semmsl), - gh_ulong2scm (sem_limits.semopm), - gh_ulong2scm (sem_limits.semume), - gh_ulong2scm (sem_limits.semusz), - gh_ulong2scm (sem_limits.semvmx), - gh_ulong2scm (sem_limits.semaem), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/shm_limits.c b/sysdeps/guile/shm_limits.c deleted file mode 100644 index e0efd174..00000000 --- a/sysdeps/guile/shm_limits.c +++ /dev/null @@ -1,40 +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 , 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 -#include - -#include - -SCM glibtop_guile_get_shm_limits (void) -{ - glibtop_shm_limits shm_limits; - - glibtop_get_shm_limits (&shm_limits); - - return gh_list (gh_ulong2scm (shm_limits.flags), - gh_ulong2scm (shm_limits.shmmax), - gh_ulong2scm (shm_limits.shmmin), - gh_ulong2scm (shm_limits.shmmni), - gh_ulong2scm (shm_limits.shmseg), - gh_ulong2scm (shm_limits.shmall), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/swap.c b/sysdeps/guile/swap.c deleted file mode 100644 index 4ab39ab8..00000000 --- a/sysdeps/guile/swap.c +++ /dev/null @@ -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 , 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 -#include - -#include - -SCM glibtop_guile_get_swap (void) -{ - glibtop_swap swap; - - glibtop_get_swap (&swap); - - return gh_list (gh_ulong2scm (swap.flags), - gh_ulong2scm (swap.total), - gh_ulong2scm (swap.used), - gh_ulong2scm (swap.free), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/sysdeps.c b/sysdeps/guile/sysdeps.c deleted file mode 100644 index 90a4b04d..00000000 --- a/sysdeps/guile/sysdeps.c +++ /dev/null @@ -1,51 +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 , 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 -#include - -#include - -SCM glibtop_guile_get_sysdeps (void) -{ - glibtop_sysdeps sysdeps; - - glibtop_get_sysdeps (&sysdeps); - - return gh_list (gh_ulong2scm (sysdeps.flags), - gh_ulong2scm (sysdeps.cpu), - gh_ulong2scm (sysdeps.mem), - gh_ulong2scm (sysdeps.swap), - gh_ulong2scm (sysdeps.uptime), - gh_ulong2scm (sysdeps.loadavg), - gh_ulong2scm (sysdeps.shm_limits), - gh_ulong2scm (sysdeps.msg_limits), - gh_ulong2scm (sysdeps.sem_limits), - gh_ulong2scm (sysdeps.proclist), - gh_ulong2scm (sysdeps.proc_state), - gh_ulong2scm (sysdeps.proc_uid), - gh_ulong2scm (sysdeps.proc_mem), - gh_ulong2scm (sysdeps.proc_time), - gh_ulong2scm (sysdeps.proc_signal), - gh_ulong2scm (sysdeps.proc_kernel), - gh_ulong2scm (sysdeps.proc_segment), - SCM_UNDEFINED); -} diff --git a/sysdeps/guile/uptime.c b/sysdeps/guile/uptime.c deleted file mode 100644 index 2425c751..00000000 --- a/sysdeps/guile/uptime.c +++ /dev/null @@ -1,37 +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 , 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 -#include - -#include - -SCM glibtop_guile_get_uptime (void) -{ - glibtop_uptime uptime; - - glibtop_get_uptime (&uptime); - - return gh_list (gh_ulong2scm (uptime.flags), - gh_double2scm (uptime.uptime), - gh_double2scm (uptime.idletime), - SCM_UNDEFINED); -} From 44dcb69c4104cc738711d3aa2b779b71d0e7515d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 01:01:24 +0000 Subject: [PATCH 0116/2539] Added missing `const'. --- include/glibtop/loadavg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/glibtop/loadavg.h b/include/glibtop/loadavg.h index cadbb423..b5f267d0 100644 --- a/include/glibtop/loadavg.h +++ b/include/glibtop/loadavg.h @@ -79,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 unsigned glibtop_types_loadavg []; +extern const unsigned glibtop_types_loadavg []; extern const char *glibtop_labels_loadavg []; extern const char *glibtop_descriptions_loadavg []; From 6130f0a4f99ecbf5e8a28f46581c1742641a155f Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 02:13:50 +0000 Subject: [PATCH 0117/2539] New file. Creates `lib.c' depending upon `features.def'. 1998-06-14 Martin Baulig * lib/lib.awk: New file. Creates `lib.c' depending upon `features.def'. * lib/.c: Removed. --- lib/Makefile.am | 16 +++++++++------ lib/cpu.c | 39 ----------------------------------- lib/lib.awk | 52 +++++++++++++++++++++++++++++++++++++++++++++++ lib/loadavg.c | 39 ----------------------------------- lib/mem.c | 38 ---------------------------------- lib/msg_limits.c | 38 ---------------------------------- lib/prockernel.c | 40 ------------------------------------ lib/proclist.c | 38 ---------------------------------- lib/procmem.c | 40 ------------------------------------ lib/procsegment.c | 40 ------------------------------------ lib/procsignal.c | 40 ------------------------------------ lib/procstate.c | 40 ------------------------------------ lib/proctime.c | 40 ------------------------------------ lib/procuid.c | 40 ------------------------------------ lib/sem_limits.c | 38 ---------------------------------- lib/shm_limits.c | 38 ---------------------------------- lib/swap.c | 38 ---------------------------------- lib/uptime.c | 39 ----------------------------------- 18 files changed, 62 insertions(+), 631 deletions(-) delete mode 100644 lib/cpu.c create mode 100644 lib/lib.awk delete mode 100644 lib/loadavg.c delete mode 100644 lib/mem.c delete mode 100644 lib/msg_limits.c delete mode 100644 lib/prockernel.c delete mode 100644 lib/proclist.c delete mode 100644 lib/procmem.c delete mode 100644 lib/procsegment.c delete mode 100644 lib/procsignal.c delete mode 100644 lib/procstate.c delete mode 100644 lib/proctime.c delete mode 100644 lib/procuid.c delete mode 100644 lib/sem_limits.c delete mode 100644 lib/shm_limits.c delete mode 100644 lib/swap.c delete mode 100644 lib/uptime.c diff --git a/lib/Makefile.am b/lib/Makefile.am index 31dda65f..51560e63 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/cpu.c b/lib/cpu.c deleted file mode 100644 index 6e20a19e..00000000 --- a/lib/cpu.c +++ /dev/null @@ -1,39 +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 , 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 -#include -#include - -/* Provides information about cpu usage. */ - -void -glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_CPU, 0); - - if (server->features & GLIBTOP_SYSDEPS_CPU) { - glibtop_call_l (server, GLIBTOP_CMND_CPU, 0, NULL, - sizeof (glibtop_cpu), buf); - } else { - glibtop_get_cpu_r (server, buf); - } -} diff --git a/lib/lib.awk b/lib/lib.awk new file mode 100644 index 00000000..fc901bcd --- /dev/null +++ b/lib/lib.awk @@ -0,0 +1,52 @@ +BEGIN { + print "/* lib.c */"; + print "/* This is a generated file. Please modify `lib.awk' */"; + print ""; + + print "#include "; + print "#include "; + print "#include "; + + 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) } + + diff --git a/lib/loadavg.c b/lib/loadavg.c deleted file mode 100644 index 3e503160..00000000 --- a/lib/loadavg.c +++ /dev/null @@ -1,39 +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 , 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 -#include -#include - -/* Provides load averange. */ - -void -glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); - - if (server->features & GLIBTOP_SYSDEPS_LOADAVG) { - glibtop_call_l (server, GLIBTOP_CMND_LOADAVG, 0, NULL, - sizeof (glibtop_loadavg), buf); - } else { - glibtop_get_loadavg_r (server, buf); - } -} diff --git a/lib/mem.c b/lib/mem.c deleted file mode 100644 index 34fe5ef1..00000000 --- a/lib/mem.c +++ /dev/null @@ -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 , 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 -#include - -/* Provides information about memory usage. */ - -void -glibtop_get_mem_l (glibtop *server, glibtop_mem *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_MEM, 0); - - if (server->features & GLIBTOP_SYSDEPS_MEM) { - glibtop_call_l (server, GLIBTOP_CMND_MEM, 0, NULL, - sizeof (glibtop_mem), buf); - } else { - glibtop_get_mem_r (server, buf); - } -} diff --git a/lib/msg_limits.c b/lib/msg_limits.c deleted file mode 100644 index 16727049..00000000 --- a/lib/msg_limits.c +++ /dev/null @@ -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 , 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 -#include - -/* Provides information about sysv ipc limits. */ - -void -glibtop_get_msg_limits_l (glibtop *server, glibtop_msg_limits *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); - - if (server->features & GLIBTOP_SYSDEPS_MSG_LIMITS) { - glibtop_call_l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL, - sizeof (glibtop_msg_limits), buf); - } else { - glibtop_get_msg_limits_r (server, buf); - } -} diff --git a/lib/prockernel.c b/lib/prockernel.c deleted file mode 100644 index 56ff0159..00000000 --- a/lib/prockernel.c +++ /dev/null @@ -1,40 +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 , 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 -#include -#include - -/* Provides detailed information about a process. */ - -void -glibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROC_KERNEL) { - glibtop_call_l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t), - &pid, sizeof (glibtop_proc_kernel), buf); - } else { - glibtop_get_proc_kernel_r (server, buf, pid); - } -} diff --git a/lib/proclist.c b/lib/proclist.c deleted file mode 100644 index a82c016c..00000000 --- a/lib/proclist.c +++ /dev/null @@ -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 , 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 -#include - -/* Fetch list of currently running processes. */ - -unsigned * -glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROCLIST, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROCLIST) { - return glibtop_call_l (server, GLIBTOP_CMND_PROCLIST, 0, NULL, - sizeof (glibtop_proclist), buf); - } else { - return glibtop_get_proclist_r (server, buf); - } -} diff --git a/lib/procmem.c b/lib/procmem.c deleted file mode 100644 index 26e822ca..00000000 --- a/lib/procmem.c +++ /dev/null @@ -1,40 +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 , 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 -#include -#include - -/* Provides detailed information about a process. */ - -void -glibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_MEM, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROC_MEM) { - glibtop_call_l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t), - &pid, sizeof (glibtop_proc_mem), buf); - } else { - glibtop_get_proc_mem_r (server, buf, pid); - } -} diff --git a/lib/procsegment.c b/lib/procsegment.c deleted file mode 100644 index 92ec5a2a..00000000 --- a/lib/procsegment.c +++ /dev/null @@ -1,40 +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 , 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 -#include -#include - -/* Provides detailed information about a process. */ - -void -glibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROC_SEGMENT) { - glibtop_call_l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t), - &pid, sizeof (glibtop_proc_segment), buf); - } else { - glibtop_get_proc_segment_r (server, buf, pid); - } -} diff --git a/lib/procsignal.c b/lib/procsignal.c deleted file mode 100644 index d51ce115..00000000 --- a/lib/procsignal.c +++ /dev/null @@ -1,40 +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 , 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 -#include -#include - -/* Provides detailed information about a process. */ - -void -glibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROC_SIGNAL) { - glibtop_call_l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t), - &pid, sizeof (glibtop_proc_signal), buf); - } else { - glibtop_get_proc_signal_r (server, buf, pid); - } -} diff --git a/lib/procstate.c b/lib/procstate.c deleted file mode 100644 index d1167186..00000000 --- a/lib/procstate.c +++ /dev/null @@ -1,40 +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 , 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 -#include -#include - -/* Provides detailed information about a process. */ - -void -glibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf, - pid_t pid) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROC_STATE) { - glibtop_call_l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), - &pid, sizeof (glibtop_proc_state), buf); - } else { - glibtop_get_proc_state_r (server, buf, pid); - } -} diff --git a/lib/proctime.c b/lib/proctime.c deleted file mode 100644 index ac116d00..00000000 --- a/lib/proctime.c +++ /dev/null @@ -1,40 +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 , 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 -#include -#include - -/* Provides detailed information about a process. */ - -void -glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf, - pid_t pid) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROC_TIME) { - glibtop_call_l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t), - &pid, sizeof (glibtop_proc_time), buf); - } else { - glibtop_get_proc_time_r (server, buf, pid); - } -} diff --git a/lib/procuid.c b/lib/procuid.c deleted file mode 100644 index e65da97d..00000000 --- a/lib/procuid.c +++ /dev/null @@ -1,40 +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 , 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 -#include -#include - -/* Provides detailed information about a process. */ - -void -glibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_UID, 0); - - if (server->features & GLIBTOP_SYSDEPS_PROC_UID) { - glibtop_call_l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t), - &pid, sizeof (glibtop_proc_uid), buf); - } else { - glibtop_get_proc_uid_r (server, buf, pid); - } -} diff --git a/lib/sem_limits.c b/lib/sem_limits.c deleted file mode 100644 index ca332d2c..00000000 --- a/lib/sem_limits.c +++ /dev/null @@ -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 , 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 -#include - -/* Provides information about sysv ipc limits. */ - -void -glibtop_get_sem_limits_l (glibtop *server, glibtop_sem_limits *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); - - if (server->features & GLIBTOP_SYSDEPS_SEM_LIMITS) { - glibtop_call_l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL, - sizeof (glibtop_sem_limits), buf); - } else { - glibtop_get_sem_limits_r (server, buf); - } -} diff --git a/lib/shm_limits.c b/lib/shm_limits.c deleted file mode 100644 index d59efdfc..00000000 --- a/lib/shm_limits.c +++ /dev/null @@ -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 , 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 -#include - -/* Provides information about sysv ipc limits. */ - -void -glibtop_get_shm_limits_l (glibtop *server, glibtop_shm_limits *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); - - if (server->features & GLIBTOP_SYSDEPS_SHM_LIMITS) { - glibtop_call_l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL, - sizeof (glibtop_shm_limits), buf); - } else { - glibtop_get_shm_limits_r (server, buf); - } -} diff --git a/lib/swap.c b/lib/swap.c deleted file mode 100644 index 8e5d33b7..00000000 --- a/lib/swap.c +++ /dev/null @@ -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 , 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 -#include - -/* Provides information about swap usage. */ - -void -glibtop_get_swap_l (glibtop *server, glibtop_swap *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_SWAP, 0); - - if (server->features & GLIBTOP_SYSDEPS_SWAP) { - glibtop_call_l (server, GLIBTOP_CMND_SWAP, 0, NULL, - sizeof (glibtop_swap), buf); - } else { - glibtop_get_swap_r (server, buf); - } -} diff --git a/lib/uptime.c b/lib/uptime.c deleted file mode 100644 index 1dcf8ae0..00000000 --- a/lib/uptime.c +++ /dev/null @@ -1,39 +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 , 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 -#include -#include - -/* Provides uptime and idle time. */ - -void -glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf) -{ - glibtop_init_r (&server, GLIBTOP_SYSDEPS_UPTIME, 0); - - if (server->features & GLIBTOP_SYSDEPS_UPTIME) { - glibtop_call_l (server, GLIBTOP_CMND_UPTIME, 0, NULL, - sizeof (glibtop_uptime), buf); - } else { - glibtop_get_uptime_r (server, buf); - } -} From 6ea7e47194997023cb579d6e9216b32e228e2fe0 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 02:23:25 +0000 Subject: [PATCH 0118/2539] New tag. 1998-06-14 Martin Baulig * acconfig.h (HAVE_LINUX_TABLE): New tag. --- ChangeLog | 9 ++++++++- acconfig.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index af366a67..2b9adf39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,14 @@ 1998-06-14 Martin Baulig + * acconfig.h (HAVE_LINUX_TABLE): New tag. + + * lib/lib.awk: New file. + Creates `lib.c' depending upon `features.def'. + + * lib/.c: Removed. + * sysdeps/guile/guile.awk: New file. - Creates `gulie.c' depending upon `features.def'. + Creates `guile.c' depending upon `features.def'. * sysdeps/guile/*.c: Removed. diff --git a/acconfig.h b/acconfig.h index f5f3f252..1a9da99c 100644 --- a/acconfig.h +++ b/acconfig.h @@ -33,3 +33,5 @@ #undef GLIBTOP_EXAMPLES #undef NEED_LIBGTOP + +#undef HAVE_LINUX_TABLE From 7ffc53f45e5604440f6d763f07162a1854031700 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 02:26:32 +0000 Subject: [PATCH 0119/2539] *** empty log message *** --- examples/first.c | 2 ++ examples/second.c | 10 ++++++++++ examples/third.c | 10 ++++++++++ lib/.cvsignore | 1 + src/proxy/main.c | 10 ++++++++++ sysdeps/guile/.cvsignore | 1 + sysdeps/guile/Makefile.am | 6 ------ sysdeps/guile/names/.cvsignore | 1 + 8 files changed, 35 insertions(+), 6 deletions(-) diff --git a/examples/first.c b/examples/first.c index 2853eb2a..d65657e3 100644 --- a/examples/first.c +++ b/examples/first.c @@ -33,6 +33,7 @@ #define PROFILE_COUNT 1 #endif +#ifdef HAVE_LINUX_TABLE #include #include #include @@ -40,6 +41,7 @@ #include _syscall3 (int, table, int, type, union table *, tbl, const void *, param); +#endif int main (int argc, char *argv []) diff --git a/examples/second.c b/examples/second.c index 423111ab..4ebffe1f 100644 --- a/examples/second.c +++ b/examples/second.c @@ -29,6 +29,16 @@ #include #include +#ifdef HAVE_LINUX_TABLE +#include +#include +#include + +#include + +_syscall3 (int, table, int, type, union table *, tbl, const void *, param); +#endif + int main (int argc, char *argv []) { diff --git a/examples/third.c b/examples/third.c index 261ba8c3..f5d41c0d 100644 --- a/examples/third.c +++ b/examples/third.c @@ -32,6 +32,16 @@ void main_prog(int argc, char *argv[]); +#ifdef HAVE_LINUX_TABLE +#include +#include +#include + +#include + +_syscall3 (int, table, int, type, union table *, tbl, const void *, param); +#endif + int main (int argc, char *argv[]) { diff --git a/lib/.cvsignore b/lib/.cvsignore index 221fbc2f..27fc4990 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -32,3 +32,4 @@ sysinfo.lo uptime.lo write.lo xmalloc.lo +lib.c diff --git a/src/proxy/main.c b/src/proxy/main.c index a71df0a2..dd7cd58d 100644 --- a/src/proxy/main.c +++ b/src/proxy/main.c @@ -36,6 +36,16 @@ #define GET_MAX_FDS() 256 #endif +#ifdef HAVE_LINUX_TABLE +#include +#include +#include + +#include + +_syscall3 (int, table, int, type, union table *, tbl, const void *, param); +#endif + int main(int argc, char *argv[]) { diff --git a/sysdeps/guile/.cvsignore b/sysdeps/guile/.cvsignore index 3956f7f4..80292200 100644 --- a/sysdeps/guile/.cvsignore +++ b/sysdeps/guile/.cvsignore @@ -23,3 +23,4 @@ so_locations swap.lo sysdeps.lo uptime.lo +guile.c diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am index 50372156..ed83e8e0 100644 --- a/sysdeps/guile/Makefile.am +++ b/sysdeps/guile/Makefile.am @@ -14,12 +14,6 @@ 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 diff --git a/sysdeps/guile/names/.cvsignore b/sysdeps/guile/names/.cvsignore index e5baa455..da876484 100644 --- a/sysdeps/guile/names/.cvsignore +++ b/sysdeps/guile/names/.cvsignore @@ -24,3 +24,4 @@ so_locations swap.lo sysdeps.lo uptime.lo +guile-names.c From c75b77affc2ad1853ad9cb9a34b7fac94d9e9385 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 02:30:25 +0000 Subject: [PATCH 0120/2539] Removed deleted files. --- po/POTFILES.in | 9 --------- 1 file changed, 9 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index bc2fe1e4..b0b5df47 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,17 +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/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 From 23cccaf87f2a7d9cd9067de14285ee63b9826370 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 12:18:39 +0000 Subject: [PATCH 0121/2539] Removed declararion of table () function again. --- examples/first.c | 10 ---------- examples/second.c | 10 ---------- examples/third.c | 10 ---------- src/proxy/main.c | 10 ---------- 4 files changed, 40 deletions(-) diff --git a/examples/first.c b/examples/first.c index d65657e3..d93e8f3b 100644 --- a/examples/first.c +++ b/examples/first.c @@ -33,16 +33,6 @@ #define PROFILE_COUNT 1 #endif -#ifdef HAVE_LINUX_TABLE -#include -#include -#include - -#include - -_syscall3 (int, table, int, type, union table *, tbl, const void *, param); -#endif - int main (int argc, char *argv []) { diff --git a/examples/second.c b/examples/second.c index 4ebffe1f..423111ab 100644 --- a/examples/second.c +++ b/examples/second.c @@ -29,16 +29,6 @@ #include #include -#ifdef HAVE_LINUX_TABLE -#include -#include -#include - -#include - -_syscall3 (int, table, int, type, union table *, tbl, const void *, param); -#endif - int main (int argc, char *argv []) { diff --git a/examples/third.c b/examples/third.c index f5d41c0d..261ba8c3 100644 --- a/examples/third.c +++ b/examples/third.c @@ -32,16 +32,6 @@ void main_prog(int argc, char *argv[]); -#ifdef HAVE_LINUX_TABLE -#include -#include -#include - -#include - -_syscall3 (int, table, int, type, union table *, tbl, const void *, param); -#endif - int main (int argc, char *argv[]) { diff --git a/src/proxy/main.c b/src/proxy/main.c index dd7cd58d..a71df0a2 100644 --- a/src/proxy/main.c +++ b/src/proxy/main.c @@ -36,16 +36,6 @@ #define GET_MAX_FDS() 256 #endif -#ifdef HAVE_LINUX_TABLE -#include -#include -#include - -#include - -_syscall3 (int, table, int, type, union table *, tbl, const void *, param); -#endif - int main(int argc, char *argv[]) { From 8f43551d687d72539802f5dabcf4a366da40b080 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 12:19:18 +0000 Subject: [PATCH 0122/2539] New file - declaration of the table () function via _syscall3 (); due to a 1998-06-14 Martin Baulig * 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. --- sysdeps/kernel/ChangeLog | 6 ++++++ sysdeps/kernel/Makefile.am | 8 +++++++- sysdeps/kernel/kernel.s | 42 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 sysdeps/kernel/kernel.s diff --git a/sysdeps/kernel/ChangeLog b/sysdeps/kernel/ChangeLog index 51a5a6e8..75705a78 100644 --- a/sysdeps/kernel/ChangeLog +++ b/sysdeps/kernel/ChangeLog @@ -1,3 +1,9 @@ +1998-06-14 Martin Baulig + + * 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-13 Martin Baulig The code in this directory fetches all information diff --git a/sysdeps/kernel/Makefile.am b/sysdeps/kernel/Makefile.am index 5c5cb132..d4e24965 100644 --- a/sysdeps/kernel/Makefile.am +++ b/sysdeps/kernel/Makefile.am @@ -8,10 +8,16 @@ CFLAGS = -Wall -W @CFLAGS@ lib_LTLIBRARIES = libgtop_sysdeps.la -libgtop_sysdeps_la_SOURCES = init.c open.c close.c cpu.c mem.c swap.c \ +libgtop_sysdeps_la_SOURCES = init.c open.c close.c kernel.s 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 include_HEADERS = glibtop_server.h + +kernel.o kernel.lo: kernel.s + rm -f kernel.o kernel.lo + $(AS) -o kernel.o kernel.s + cp kernel.o kernel.lo + diff --git a/sysdeps/kernel/kernel.s b/sysdeps/kernel/kernel.s new file mode 100644 index 00000000..5f5383c8 --- /dev/null +++ b/sysdeps/kernel/kernel.s @@ -0,0 +1,42 @@ + .file "test.c" + .version "01.01" +/ GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release). +/ options passed: -O2 -Wall -W +/ options enabled: -fdefer-pop -fcse-follow-jumps -fcse-skip-blocks +/ -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole +/ -fforce-mem -ffunction-cse -finline -fkeep-static-consts -fcaller-saves +/ -fpcc-struct-return -frerun-cse-after-loop -frerun-loop-opt +/ -fschedule-insns2 -fcommon -fverbose-asm -fgnu-linker -fregmove +/ -falias-check -fargument-alias -m80387 -mhard-float -mno-soft-float +/ -mieee-fp -mfp-ret-in-387 -mschedule-prologue -mcpu=pentiumpro +/ -march=pentium + +gcc2_compiled.: +.text + .align 4 +.globl table + .type table,@function +table: + pushl %ebp + movl %esp,%ebp + movl $168,%eax + pushl %ebx + movl 8(%ebp),%ebx + movl 12(%ebp),%ecx + movl 16(%ebp),%edx +#APP + int $0x80 +#NO_APP + testl %eax,%eax + jge .L3 + negl %eax + movl %eax,errno + movl $-1,%eax +.L3: + movl -4(%ebp),%ebx + movl %ebp,%esp + popl %ebp + ret +.Lfe1: + .size table,.Lfe1-table + .ident "GCC: (GNU) egcs-2.90.29 980515 (egcs-1.0.3 release)" From b56c327cccaa7fbb3d5cc83d3a334c95a5de5806 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 12:29:52 +0000 Subject: [PATCH 0123/2539] This new system call now provides all information required for libgtop. --- kernel/main.c | 341 ++++++++++++++++++++++++++++++++++++++++++++++++- kernel/table.h | 98 ++++++++++++-- kernel/test.c | 31 +++-- 3 files changed, 440 insertions(+), 30 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 7f6381bb..08a184d6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -28,11 +28,168 @@ #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) +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) @@ -41,6 +198,31 @@ sys_table (int type, union table *buf) 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; @@ -66,9 +248,9 @@ sys_table (int type, union table *buf) tbl.swap.free = i.freeswap; break; case TABLE_LOADAVG: - tbl.loadavg.loadavg [0] = avenrun [0]; - tbl.loadavg.loadavg [1] = avenrun [1]; - tbl.loadavg.loadavg [2] = avenrun [2]; + 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; @@ -77,6 +259,157 @@ sys_table (int type, union table *buf) 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; } diff --git a/kernel/table.h b/kernel/table.h index 9515fdc9..801b410b 100644 --- a/kernel/table.h +++ b/kernel/table.h @@ -1,13 +1,23 @@ #ifndef _LINUX_TABLE_H #define _LINUX_TABLE_H -#include -#define TABLE_VERSION 0 -#define TABLE_CPU 1 -#define TABLE_MEM 2 -#define TABLE_SWAP 3 -#define TABLE_LOADAVG 4 -#define TABLE_UPTIME 5 +#ifdef _KERNEL +#include +#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) */ @@ -46,7 +56,7 @@ struct table_swap struct table_loadavg { - unsigned long loadavg [3]; + double loadavg [3]; unsigned nr_running; unsigned nr_tasks; unsigned last_pid; @@ -60,6 +70,67 @@ struct table_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 @@ -69,12 +140,15 @@ union table 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; }; -#ifdef __KERNEL__ - -#endif /* __KERNEL__ */ - #endif /* _LINUX_IPC_H */ diff --git a/kernel/test.c b/kernel/test.c index a6ba8dc7..f4ed092c 100644 --- a/kernel/test.c +++ b/kernel/test.c @@ -7,15 +7,16 @@ #include -static inline _syscall2 (int, table, int, type, union table *, tbl); +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); + ret = table (TABLE_VERSION, NULL, NULL); if (ret == -1) { fprintf (stderr, "table(%u): %s\n", TABLE_VERSION, sys_errlist [errno]); @@ -24,18 +25,20 @@ main (void) fprintf (stderr, "Table (%u) = %u\n", TABLE_VERSION, ret); - ret = table (TABLE_CPU, &tbl); + 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); + 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); } - 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); + ret = table (TABLE_MEM, &tbl, NULL); if (ret == -1) { fprintf (stderr, "table(%u): %s\n", TABLE_MEM, sys_errlist [errno]); @@ -46,7 +49,7 @@ main (void) 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); + ret = table (TABLE_SWAP, &tbl, NULL); if (ret == -1) { fprintf (stderr, "table(%u): %s\n", TABLE_SWAP, sys_errlist [errno]); @@ -56,7 +59,7 @@ main (void) fprintf (stderr, "Table (%u) = %lu, %lu, %lu\n", TABLE_SWAP, tbl.swap.total, tbl.swap.used, tbl.swap.free); - ret = table (TABLE_LOADAVG, &tbl); + ret = table (TABLE_LOADAVG, &tbl, NULL); if (ret == -1) { fprintf (stderr, "table(%u): %s\n", TABLE_LOADAVG, sys_errlist [errno]); @@ -68,7 +71,7 @@ main (void) tbl.loadavg.loadavg [2], tbl.loadavg.nr_running, tbl.loadavg.nr_tasks, tbl.loadavg.last_pid); - ret = table (TABLE_UPTIME, &tbl); + ret = table (TABLE_UPTIME, &tbl, NULL); if (ret == -1) { fprintf (stderr, "table(%u): %s\n", TABLE_UPTIME, sys_errlist [errno]); From 794a8efaeddca3085c6f9807189aa8c1d212c3bd Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 12:40:59 +0000 Subject: [PATCH 0124/2539] Added README. 1998-06-14 Martin Baulig * README: Added README. * kernel.patch: Patch for the Linux kernel to add the new system call. --- kernel/ChangeLog | 6 ++++++ kernel/README | 21 +++++++++++++++++++ kernel/kernel.patch | 49 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 kernel/ChangeLog create mode 100644 kernel/README create mode 100644 kernel/kernel.patch diff --git a/kernel/ChangeLog b/kernel/ChangeLog new file mode 100644 index 00000000..dfde45e2 --- /dev/null +++ b/kernel/ChangeLog @@ -0,0 +1,6 @@ +1998-06-14 Martin Baulig + + * README: Added README. + + * kernel.patch: Patch for the Linux kernel to add the + new system call. diff --git a/kernel/README b/kernel/README new file mode 100644 index 00000000..88d26bec --- /dev/null +++ b/kernel/README @@ -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 diff --git a/kernel/kernel.patch b/kernel/kernel.patch new file mode 100644 index 00000000..0ac00716 --- /dev/null +++ b/kernel/kernel.patch @@ -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) \ From 215ab9f17b90cf96654e82fc8340911a43180c9c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 14:09:34 +0000 Subject: [PATCH 0125/2539] Initial revision --- src/daemon/gnuclient.c | 620 ++++++++++++++++++++++++++++ src/daemon/gnuserv.c | 913 +++++++++++++++++++++++++++++++++++++++++ src/daemon/gnuserv.h | 220 ++++++++++ 3 files changed, 1753 insertions(+) create mode 100644 src/daemon/gnuclient.c create mode 100644 src/daemon/gnuserv.c create mode 100644 src/daemon/gnuserv.h diff --git a/src/daemon/gnuclient.c b/src/daemon/gnuclient.c new file mode 100644 index 00000000..41137abd --- /dev/null +++ b/src/daemon/gnuclient.c @@ -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 , + * Darrell Kindred and Arup Mukherjee . + * GNUATTACH support added by Ben Wing . + * 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 +#include +#include + +#ifdef HAVE_STRING_H +#include +#endif /* HAVE_STRING_H */ + +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ + +#include + +#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 */ diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c new file mode 100644 index 00000000..8665ce40 --- /dev/null +++ b/src/daemon/gnuserv.c @@ -0,0 +1,913 @@ +/* -*-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 , + * Darrell Kindred and Arup Mukherjee . + * 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 USE_LITOUT +#ifdef linux +#include +#else +#include +#endif +#endif + +#ifdef AIX +#include +#endif + +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ + +#ifdef HAVE_STRING_H +#include +#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 +# include + +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; is_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 USE_LITOUT + { + /* this is to allow ^D to pass to emacs */ + int d = LLITOUT; + (void) ioctl(fileno(stdout), TIOCLBIS, &d); + } +#endif + +#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 */ diff --git a/src/daemon/gnuserv.h b/src/daemon/gnuserv.h new file mode 100644 index 00000000..31fab4d0 --- /dev/null +++ b/src/daemon/gnuserv.h @@ -0,0 +1,220 @@ +/* -*-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 , + * Darrell Kindred and Arup Mukherjee . + * 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 <../src/config.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 */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +/* + * 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 +#include + +#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 +#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ + +#ifdef INTERNET_DOMAIN_SOCKETS +#include +#include +#include +#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 +#define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */ +#endif /* UNIX_DOMAIN_SOCKETS */ + +/* On some platforms, we need to do the equivalent of "stty litout" to get + * characters like ^D to pass through to emacs. This problem has only + * been observed under emacs18; fsf19 and lemacs are probably okay without it. + */ +#ifndef DONT_USE_LITOUT +#if !defined(HAVE_TERMIO) && !defined(HAVE_TERMIOS) && !defined(VMS) +#if !defined(MSDOS) && !defined(BSD4_1) +#define USE_LITOUT +#endif +#endif +#endif + + +#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 From 03c5a235ef8dd5101c7689d0901018c46dbf13fb Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 14:09:34 +0000 Subject: [PATCH 0126/2539] Importing gnuserv and gnuclient from XEmacs 20.3. From f87722233a457dadd5f3ad3247a03153596490dc Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 14:39:34 +0000 Subject: [PATCH 0127/2539] Initial revision --- src/daemon/gnuslib.c | 454 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 454 insertions(+) create mode 100644 src/daemon/gnuslib.c diff --git a/src/daemon/gnuslib.c b/src/daemon/gnuslib.c new file mode 100644 index 00000000..29a9971c --- /dev/null +++ b/src/daemon/gnuslib.c @@ -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 , + * Darrell Kindred and Arup Mukherjee . + * 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 + +#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 +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ +#ifdef HAVE_STRING_H +#include +#endif /* HAVE_STRING_H */ + +#include + +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 +# include + +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 */ From 026e93121e818a7c9a4b9acb9ce280d0ebcf3752 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 14:39:34 +0000 Subject: [PATCH 0128/2539] Forgot to import this file. From bde0d742822cabda424c1a7e48ea083cba505dcf Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 14:44:53 +0000 Subject: [PATCH 0129/2539] including correct headers; (HAVE_UNISTD_H): Added conditional. Added 1998-06-14 Martin Baulig * include/glibtop/global.h (TIME_WITH_SYS_TIME): including correct headers; (HAVE_UNISTD_H): Added conditional. Added `#include ' and `#include '. --- include/glibtop/global.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/glibtop/global.h b/include/glibtop/global.h index 9cbaed8b..1ad60784 100644 --- a/include/glibtop/global.h +++ b/include/glibtop/global.h @@ -51,6 +51,17 @@ # define __P(protos) () #endif +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + #ifdef HAVE_GUILE #include #endif @@ -67,7 +78,10 @@ #include #include + +#ifdef HAVE_UNISTD_H #include +#endif #ifdef HAVE_MEMORY_H #include @@ -75,7 +89,9 @@ #include #include +#include #include +#include #include #include From 8f14d30d11a31ab77fd07d2ce620d49e2ccbad75 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 14:45:57 +0000 Subject: [PATCH 0130/2539] Compiles and links correctly. --- src/daemon/gnuclient.c | 4 ++-- src/daemon/gnuserv.c | 16 ---------------- src/daemon/gnuserv.h | 34 ++-------------------------------- src/daemon/gnuslib.c | 2 +- 4 files changed, 5 insertions(+), 51 deletions(-) diff --git a/src/daemon/gnuclient.c b/src/daemon/gnuclient.c index 41137abd..9048bd16 100644 --- a/src/daemon/gnuclient.c +++ b/src/daemon/gnuclient.c @@ -198,7 +198,7 @@ filename_expand (char *fullpath, char *filename) /* Encase the string in quotes, escape all the backslashes and quotes in string. */ static char * -clean_string (CONST char *s) +clean_string (const char *s) { int i = 0; char *p, *res; @@ -256,7 +256,7 @@ clean_string (CONST char *s) /* A strdup immitation. */ static char * -my_strdup (CONST char *s) +my_strdup (const char *s) { char *new = malloc (strlen (s) + 1); if (new) diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index 8665ce40..b1bcc97c 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -35,14 +35,6 @@ static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !" #include "gnuserv.h" -#ifdef USE_LITOUT -#ifdef linux -#include -#else -#include -#endif -#endif - #ifdef AIX #include #endif @@ -852,14 +844,6 @@ main(argc,argv) for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */ ; -#ifdef USE_LITOUT - { - /* this is to allow ^D to pass to emacs */ - int d = LLITOUT; - (void) ioctl(fileno(stdout), TIOCLBIS, &d); - } -#endif - #ifdef SYSV_IPC ipc_init(&msgp); /* get a msqid to listen on, and a message buffer */ #endif /* SYSV_IPC */ diff --git a/src/daemon/gnuserv.h b/src/daemon/gnuserv.h index 31fab4d0..b370f297 100644 --- a/src/daemon/gnuserv.h +++ b/src/daemon/gnuserv.h @@ -41,7 +41,7 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #define NO_SHORTNAMES /* gnuserv should not be compiled using SOCKS */ #define DO_NOT_SOCKSIFY -#include <../src/config.h> +#include #undef read #undef write #undef open @@ -102,23 +102,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #endif /* No communication method pre-defined */ -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_SYS_TIME_H -#include -#endif - /* * 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 @@ -164,19 +147,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */ #endif /* UNIX_DOMAIN_SOCKETS */ -/* On some platforms, we need to do the equivalent of "stty litout" to get - * characters like ^D to pass through to emacs. This problem has only - * been observed under emacs18; fsf19 and lemacs are probably okay without it. - */ -#ifndef DONT_USE_LITOUT -#if !defined(HAVE_TERMIO) && !defined(HAVE_TERMIOS) && !defined(VMS) -#if !defined(MSDOS) && !defined(BSD4_1) -#define USE_LITOUT -#endif -#endif -#endif - - #define HOSTNAMSZ 255 /* max size of a hostname */ #define REPLYSIZ 300 /* max size of reply from server to client */ #undef FALSE @@ -211,7 +181,7 @@ int make_connection (char *hostarg, int portarg, int *s); void disconnect_from_ipc_server(); #endif #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS) -void send_string (int s, CONST char *msg); +void send_string (int s, const char *msg); void disconnect_from_server (int s, int echo); int read_line (int s, char *dest); #endif diff --git a/src/daemon/gnuslib.c b/src/daemon/gnuslib.c index 29a9971c..ca052f38 100644 --- a/src/daemon/gnuslib.c +++ b/src/daemon/gnuslib.c @@ -196,7 +196,7 @@ void disconnect_from_ipc_server(s,msgp,echo) */ void send_string(s,msg) int s; - CONST char *msg; + const char *msg; { #if 0 if (send(s,msg,strlen(msg),0) < 0) { From 58707dac42579bf31aeb6ae05d0243bfaad86ccf Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 16:47:09 +0000 Subject: [PATCH 0131/2539] New function - same as `glibtop_error_r', but doesn't call `exit'. 1998-06-14 Martin Baulig * 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/error.h | 8 ++++++++ sysdeps/common/error.c | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/glibtop/error.h b/include/glibtop/error.h index adb85828..915554c9 100644 --- a/include/glibtop/error.h +++ b/include/glibtop/error.h @@ -27,8 +27,16 @@ __BEGIN_DECLS #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) + +#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 diff --git a/sysdeps/common/error.c b/sysdeps/common/error.c index 2424d11c..55e9e265 100644 --- a/sysdeps/common/error.c +++ b/sysdeps/common/error.c @@ -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); +} From 0acb49721611dfbf95181f2521b410ea9c1c5d3c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 16:48:06 +0000 Subject: [PATCH 0132/2539] New tag. 1998-06-14 Martin Baulig * acconfig.h (HAVE_XAUTH): New tag. * configure.in: Added check for `HAVE_XAUTH'. --- ChangeLog | 13 +++++++++++++ acconfig.h | 2 ++ configure.in | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2b9adf39..54ccf0af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 1998-06-14 Martin Baulig + * 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 ' and `#include '. + * acconfig.h (HAVE_LINUX_TABLE): New tag. * lib/lib.awk: New file. diff --git a/acconfig.h b/acconfig.h index 1a9da99c..17419302 100644 --- a/acconfig.h +++ b/acconfig.h @@ -35,3 +35,5 @@ #undef NEED_LIBGTOP #undef HAVE_LINUX_TABLE + +#undef HAVE_XAUTH diff --git a/configure.in b/configure.in index e64f7da0..ec1eaa5d 100644 --- a/configure.in +++ b/configure.in @@ -13,6 +13,8 @@ AC_PROG_CC AC_STDC_HEADERS AC_ARG_PROGRAM +AC_PROG_AWK + AC_CHECK_TOOL(CC,gcc) AC_CHECK_TOOL(RANLIB,ranlib) AC_CHECK_TOOL(AS,as) @@ -100,6 +102,30 @@ AC_CHECK_FUNCS(getcwd gettimeofday getwd putenv strdup strtoul uname) 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) @@ -219,6 +245,7 @@ sysdeps/kernel/Makefile src/Makefile src/server/Makefile src/proxy/Makefile +src/daemon/Makefile lib/Makefile examples/Makefile support/Makefile From c1cc35ac1754d3c44be90988ac4b26c84cd8e9dd Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 16:50:30 +0000 Subject: [PATCH 0133/2539] Initial revision --- sysdeps/common/gnuslib.c | 454 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 454 insertions(+) create mode 100644 sysdeps/common/gnuslib.c diff --git a/sysdeps/common/gnuslib.c b/sysdeps/common/gnuslib.c new file mode 100644 index 00000000..29a9971c --- /dev/null +++ b/sysdeps/common/gnuslib.c @@ -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 , + * Darrell Kindred and Arup Mukherjee . + * 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 + +#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 +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ +#ifdef HAVE_STRING_H +#include +#endif /* HAVE_STRING_H */ + +#include + +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 +# include + +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 */ From e166f54328b2d09d5579ffc48dd7cc32496c7d1e Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 16:50:30 +0000 Subject: [PATCH 0134/2539] Importing from xemacs-20.3 From 35943ea8fc28773734246d002419ebfaf37af5e2 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 16:54:23 +0000 Subject: [PATCH 0135/2539] Committing changes I made in 'src/daemon'. --- sysdeps/common/gnuslib.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sysdeps/common/gnuslib.c b/sysdeps/common/gnuslib.c index 29a9971c..f4ef268a 100644 --- a/sysdeps/common/gnuslib.c +++ b/sysdeps/common/gnuslib.c @@ -196,7 +196,7 @@ void disconnect_from_ipc_server(s,msgp,echo) */ void send_string(s,msg) int s; - CONST char *msg; + const char *msg; { #if 0 if (send(s,msg,strlen(msg),0) < 0) { @@ -290,13 +290,15 @@ int internet_addr(host) struct hostent *hp; /* pointer to host info for remote host */ IN_ADDR numeric_addr; /* host address */ - numeric_addr = inet_addr(host); + numeric_addr = inet_addr (host); if (!NUMERIC_ADDR_ERROR) return numeric_addr; - else if ((hp = gethostbyname(host)) != NULL) + else if ((hp = gethostbyname (host)) != NULL) return ((struct in_addr *)(hp->h_addr))->s_addr; - else + else { + glibtop_warn_io ("gethostbyname (%s)", host); return -1; + } } /* internet_addr */ From 75605116d0934c9b5ed4d8ef2478d91980eeddc9 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 17:02:44 +0000 Subject: [PATCH 0136/2539] Initial revision --- include/glibtop/gnuserv.h | 220 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 include/glibtop/gnuserv.h diff --git a/include/glibtop/gnuserv.h b/include/glibtop/gnuserv.h new file mode 100644 index 00000000..31fab4d0 --- /dev/null +++ b/include/glibtop/gnuserv.h @@ -0,0 +1,220 @@ +/* -*-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 , + * Darrell Kindred and Arup Mukherjee . + * 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 <../src/config.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 */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +/* + * 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 +#include + +#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 +#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ + +#ifdef INTERNET_DOMAIN_SOCKETS +#include +#include +#include +#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 +#define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */ +#endif /* UNIX_DOMAIN_SOCKETS */ + +/* On some platforms, we need to do the equivalent of "stty litout" to get + * characters like ^D to pass through to emacs. This problem has only + * been observed under emacs18; fsf19 and lemacs are probably okay without it. + */ +#ifndef DONT_USE_LITOUT +#if !defined(HAVE_TERMIO) && !defined(HAVE_TERMIOS) && !defined(VMS) +#if !defined(MSDOS) && !defined(BSD4_1) +#define USE_LITOUT +#endif +#endif +#endif + + +#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 From 5fef6560bf100a0de3dac1ffe2e0c3b326da5ecf Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 17:02:44 +0000 Subject: [PATCH 0137/2539] Importing from xemacs-20.3 From d7770a12c6483e2d2251417745d3e56f353cf456 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 17:03:32 +0000 Subject: [PATCH 0138/2539] Committing changes from `src/daemon'. --- include/glibtop/gnuserv.h | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/include/glibtop/gnuserv.h b/include/glibtop/gnuserv.h index 31fab4d0..330b015a 100644 --- a/include/glibtop/gnuserv.h +++ b/include/glibtop/gnuserv.h @@ -41,7 +41,8 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #define NO_SHORTNAMES /* gnuserv should not be compiled using SOCKS */ #define DO_NOT_SOCKSIFY -#include <../src/config.h> +#include +#include #undef read #undef write #undef open @@ -102,23 +103,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #endif /* No communication method pre-defined */ -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_SYS_TIME_H -#include -#endif - /* * 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 @@ -164,19 +148,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #define HIDE_UNIX_SOCKET /* put the unix socket in a protected dir */ #endif /* UNIX_DOMAIN_SOCKETS */ -/* On some platforms, we need to do the equivalent of "stty litout" to get - * characters like ^D to pass through to emacs. This problem has only - * been observed under emacs18; fsf19 and lemacs are probably okay without it. - */ -#ifndef DONT_USE_LITOUT -#if !defined(HAVE_TERMIO) && !defined(HAVE_TERMIOS) && !defined(VMS) -#if !defined(MSDOS) && !defined(BSD4_1) -#define USE_LITOUT -#endif -#endif -#endif - - #define HOSTNAMSZ 255 /* max size of a hostname */ #define REPLYSIZ 300 /* max size of reply from server to client */ #undef FALSE @@ -211,7 +182,7 @@ int make_connection (char *hostarg, int portarg, int *s); void disconnect_from_ipc_server(); #endif #if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS) -void send_string (int s, CONST char *msg); +void send_string (int s, const char *msg); void disconnect_from_server (int s, int echo); int read_line (int s, char *dest); #endif From 1b7d7976b124f34e5f9ae3c70c1e59309e33a7f4 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 17:04:10 +0000 Subject: [PATCH 0139/2539] Initial revision --- lib/gnuclient.c | 620 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 620 insertions(+) create mode 100644 lib/gnuclient.c diff --git a/lib/gnuclient.c b/lib/gnuclient.c new file mode 100644 index 00000000..41137abd --- /dev/null +++ b/lib/gnuclient.c @@ -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 , + * Darrell Kindred and Arup Mukherjee . + * GNUATTACH support added by Ben Wing . + * 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 +#include +#include + +#ifdef HAVE_STRING_H +#include +#endif /* HAVE_STRING_H */ + +#ifdef HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ + +#include + +#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 */ From d334a77447096476093d4c2c817b3498cc221a69 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 17:04:10 +0000 Subject: [PATCH 0140/2539] Importing from xemacs-20.3 From 63c475d4009fa898865391f112704d67717d6a22 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 17:04:57 +0000 Subject: [PATCH 0141/2539] Committing changes from `src/daemon' --- lib/gnuclient.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gnuclient.c b/lib/gnuclient.c index 41137abd..9048bd16 100644 --- a/lib/gnuclient.c +++ b/lib/gnuclient.c @@ -198,7 +198,7 @@ filename_expand (char *fullpath, char *filename) /* Encase the string in quotes, escape all the backslashes and quotes in string. */ static char * -clean_string (CONST char *s) +clean_string (const char *s) { int i = 0; char *p, *res; @@ -256,7 +256,7 @@ clean_string (CONST char *s) /* A strdup immitation. */ static char * -my_strdup (CONST char *s) +my_strdup (const char *s) { char *new = malloc (strlen (s) + 1); if (new) From 7d0d3db11c0733214070e765417b20ff06e491a3 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 17:05:37 +0000 Subject: [PATCH 0142/2539] Removed again. --- src/daemon/gnuclient.c | 620 ----------------------------------------- src/daemon/gnuserv.h | 190 ------------- src/daemon/gnuslib.c | 454 ------------------------------ 3 files changed, 1264 deletions(-) delete mode 100644 src/daemon/gnuclient.c delete mode 100644 src/daemon/gnuserv.h delete mode 100644 src/daemon/gnuslib.c diff --git a/src/daemon/gnuclient.c b/src/daemon/gnuclient.c deleted file mode 100644 index 9048bd16..00000000 --- a/src/daemon/gnuclient.c +++ /dev/null @@ -1,620 +0,0 @@ -/* -*-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 , - * Darrell Kindred and Arup Mukherjee . - * GNUATTACH support added by Ben Wing . - * 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 -#include -#include - -#ifdef HAVE_STRING_H -#include -#endif /* HAVE_STRING_H */ - -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ - -#include - -#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 */ diff --git a/src/daemon/gnuserv.h b/src/daemon/gnuserv.h deleted file mode 100644 index b370f297..00000000 --- a/src/daemon/gnuserv.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -*-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 , - * Darrell Kindred and Arup Mukherjee . - * 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 -#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 -#include - -#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 -#endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ - -#ifdef INTERNET_DOMAIN_SOCKETS -#include -#include -#include -#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 -#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 diff --git a/src/daemon/gnuslib.c b/src/daemon/gnuslib.c deleted file mode 100644 index ca052f38..00000000 --- a/src/daemon/gnuslib.c +++ /dev/null @@ -1,454 +0,0 @@ -/* -*-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 , - * Darrell Kindred and Arup Mukherjee . - * 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 - -#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 -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#ifdef HAVE_STRING_H -#include -#endif /* HAVE_STRING_H */ - -#include - -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 -# include - -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 */ From 28dfff575276a82e252d90af7220ca4b71e8375c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 19:04:44 +0000 Subject: [PATCH 0143/2539] New file. Imported from xemacs 20.3. 1998-06-14 Martin Baulig * include/glibtop/gnuserv.h: New file. Imported from xemacs 20.3. * sysdeps/common/gnuslib.c: New file. Imported from xemacs 20.3 * lib/gnuclient.c: New file. Imported from xemacs 20.3 * sysdeps/daemon/gnuserv.c: New file. Imported from xemacs 20.3 * sysdeps/daemon: New directory. * configure.in (LIBGTOP_LIBS, LIBGTOP_GUILE_LIBS): Added `$X_LIBS -lXau' when we have xauth. --- ChangeLog | 13 + configure.in | 10 +- examples/Makefile.am | 6 +- include/glibtop/gnuserv.h | 24 +- lib/Makefile.am | 6 + lib/gnuclient.c | 617 ++++--------------------------------- src/Makefile.am | 2 +- src/daemon/gnuserv.c | 269 ++++++---------- sysdeps/common/Makefile.am | 3 +- sysdeps/common/gnuslib.c | 147 ++++----- 10 files changed, 253 insertions(+), 844 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54ccf0af..103e882a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 1998-06-14 Martin Baulig + * include/glibtop/gnuserv.h: New file. Imported from xemacs 20.3. + + * sysdeps/common/gnuslib.c: New file. Imported from xemacs 20.3 + + * lib/gnuclient.c: New file. Imported from xemacs 20.3 + + * sysdeps/daemon/gnuserv.c: New file. Imported from xemacs 20.3 + + * sysdeps/daemon: New directory. + + * configure.in (LIBGTOP_LIBS, LIBGTOP_GUILE_LIBS): Added + `$X_LIBS -lXau' when we have xauth. + * acconfig.h (HAVE_XAUTH): New tag. * configure.in: Added check for `HAVE_XAUTH'. diff --git a/configure.in b/configure.in index ec1eaa5d..95793460 100644 --- a/configure.in +++ b/configure.in @@ -6,6 +6,8 @@ AC_INIT(copyright.txt) AM_CONFIG_HEADER(config.h) AC_CANONICAL_SYSTEM +AM_INIT_AUTOMAKE(libgtop, 0.01) + AM_ACLOCAL_INCLUDE(macros) AC_ISC_POSIX @@ -32,8 +34,6 @@ 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) @@ -121,7 +121,7 @@ test -z "$with_xauth" && { AC_CHECK_LIB(Xau, XauGetAuthByAddr,[:],with_xauth=no, 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) + XE_SPACE(libs_xauth, $X_LIBS -lXau) fi AC_SUBST(libs_xauth) @@ -186,8 +186,8 @@ fi AC_SUBST(libgtop_want_guile_names) -LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common" -LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common" +LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common $ibs_xauth" +LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common $libs_xauth" if test "x$need_server" = "xyes" ; then LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop" diff --git a/examples/Makefile.am b/examples/Makefile.am index 2eb3efc2..a79cf4ce 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -19,7 +19,7 @@ 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@ + @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ first_static_SOURCES = $(first_SOURCES) first_static_LDADD = $(first_LDADD) @@ -29,7 +29,7 @@ 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@ + @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ second_static_SOURCES = $(second_SOURCES) second_static_LDADD = $(second_LDADD) @@ -46,7 +46,7 @@ third_LDADD = $(top_builddir)/sysdeps/guile/libgtop_guile.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@ + @GUILE_LIBS@ @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ third_static_SOURCES = $(third_SOURCES) third_static_LDADD = $(third_LDADD) diff --git a/include/glibtop/gnuserv.h b/include/glibtop/gnuserv.h index 330b015a..082637e4 100644 --- a/include/glibtop/gnuserv.h +++ b/include/glibtop/gnuserv.h @@ -56,8 +56,8 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #define INTERNET_DOMAIN_SOCKETS -#define UNIX_DOMAIN_SOCKETS -/* #define SYSV_IPC */ +// #define UNIX_DOMAIN_SOCKETS +// #define SYSV_IPC /* * Define additional authentication protocols to be used. These methods will @@ -77,7 +77,7 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a * stuff related to supporting MIT-MAGIC-COOKIE-1 */ -#define MCOOKIE_SCREEN "999" /* screen # to use as the gnuserv cookie */ +#define MCOOKIE_SCREEN "42980" /* 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 */ @@ -155,9 +155,8 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #undef TRUE #define TRUE 1 -extern char *optarg; -extern int optind; -extern char *progname; +// extern char *optarg; +// extern int optind; /* The casts shut Sun's compiler up and are safe in the context these are actually used. */ @@ -177,15 +176,18 @@ extern char *progname; #define CONN_IPC 2 /* function declarations */ -int make_connection (char *hostarg, int portarg, int *s); +extern int glibtop_make_connection __P((const char *, int, int *)); + #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); +// 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); +extern long glibtop_internet_addr __P((const char *)); #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index 51560e63..9e32e2e8 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -19,3 +19,9 @@ lib.c: lib.awk $(top_builddir)/config.h $(top_builddir)/features.def EXTRA_DIST = lib.awk CLEANFILES = lib.c + +bin_PROGRAMS = gnuclient +gnuclient_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ + @INTLLIBS@ @LIBSUPPORT@ @X_LIBS@ -lXau +gnuclient_LDFLAGS = -static diff --git a/lib/gnuclient.c b/lib/gnuclient.c index 9048bd16..e23fa8c9 100644 --- a/lib/gnuclient.c +++ b/lib/gnuclient.c @@ -42,579 +42,88 @@ Boston, MA 02111-1307, USA. 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 -#include -#include -#include +#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) +#else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */ -#ifdef HAVE_STRING_H -#include -#endif /* HAVE_STRING_H */ - -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ - -#include - -#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 */ + * CONN_IPC */ +#ifdef INTERNET_DOMAIN_SOCKETS + char *hostarg = NULL; /* remote hostname */ + char thishost[HOSTNAMSZ]; /* this hostname */ + char remotepath[MAXPATHLEN+1]; /* remote pathname */ + int rflg = 0; /* pathname given on cmdline */ + u_short port = 0; /* port to server */ +#endif /* INTERNET_DOMAIN_SOCKETS */ +#ifdef SYSV_IPC + struct msgbuf *msgp; /* message */ +#endif /* SYSV_IPC */ - /* Why is SYSV so retarded? */ - /* We want emacs to realize that we are resuming */ - signal(SIGCONT, tell_emacs_to_resume); + glibtop_init (); - connect_type = make_connection (NULL, (u_short) 0, &s); +#ifdef INTERNET_DOMAIN_SOCKETS + memset (remotepath, 0, sizeof (remotepath)); +#endif /* INTERNET_DOMAIN_SOCKETS */ - sprintf(buffer,"(gnuserv-eval '(resume-pid-console %d))", (int)getpid()); - send_string(s, buffer); +#if defined(INTERNET_DOMAIN_SOCKETS) + connect_type = glibtop_make_connection (hostarg, port, &s); +#else + connect_type = glibtop_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 ("LIBGTOP_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) + glibtop_error_io ("not enough memory for message buffer"); + + msgp->mtext[0] = '\0'; /* ready for later strcats */ +#endif /* SYSV_IPC */ + + raise (SIGSTOP); #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); + ; // 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 */ diff --git a/src/Makefile.am b/src/Makefile.am index 25087860..6c285f4f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = server proxy +SUBDIRS = server proxy daemon diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index b1bcc97c..9077b023 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -33,27 +33,13 @@ static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; #endif -#include "gnuserv.h" +#include #ifdef AIX #include #endif -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ - -#ifdef HAVE_STRING_H -#include -#endif /* HAVE_STRING_H */ - -#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && \ - !defined(INTERNET_DOMAIN_SOCKETS) +#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"); @@ -79,7 +65,7 @@ ipc_exit (int stat) if (ipc_wpid != 0) kill (ipc_wpid, SIGKILL); - + exit (stat); } /* ipc_exit */ @@ -104,9 +90,9 @@ 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 @@ -114,11 +100,11 @@ ipc_spawn_watchdog (void) { ipc_exit (0); } /* if */ - + sleep(10); /* have another go later */ } /* while */ } /* if */ - + } /* ipc_spawn_watchdog */ @@ -131,16 +117,12 @@ ipc_init (struct msgbuf **msgpp) key_t key; /* messge key */ char buf[GSERV_BUFSZ]; /* pathname for key */ - sprintf (buf,"/tmp/gsrv%d",(int)geteuid ()); + sprintf (buf,"/tmp/lgtd%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 */ + glibtop_error_io ("unable to create msg queue"); ipc_spawn_watchdog (); @@ -150,8 +132,7 @@ ipc_init (struct msgbuf **msgpp) if ((*msgpp = (struct msgbuf *) malloc (sizeof **msgpp + GSERV_BUFSZ)) == NULL) { - fprintf (stderr, - "%s: unable to allocate space for message buffer\n", progname); + glibtop_warn_io ("unable to allocate space for message buffer"); ipc_exit(1); } /* if */ } /* ipc_init */ @@ -174,8 +155,7 @@ handle_ipc_request (struct msgbuf *msgp) if ((len = msgrcv (ipc_qid, msgp, GSERV_BUFSZ - 1, 1, 0)) < 0) { - perror (progname); - fprintf (stderr, "%s: unable to receive\n", progname); + glibtop_warn_io ("msgrcv"); ipc_exit (1); } /* if */ @@ -192,8 +172,7 @@ handle_ipc_request (struct msgbuf *msgp) #if 0 if ((len = read(0,buf,GSERV_BUFSZ-1)) < 0) { - perror (progname); - fprintf (stderr, "%s: unable to read\n", progname); + glibtop_warn_io ("read"); ipc_exit (1); } /* if */ @@ -210,11 +189,7 @@ handle_ipc_request (struct msgbuf *msgp) } if (len < 0) - { - perror (progname); - fprintf (stderr, "%s: unable to read\n", progname); - exit(1); - } + glibtop_error_io ("read"); /* parse the response from emacs, getting client fd & result length */ buf[offset] = '\0'; @@ -223,11 +198,7 @@ handle_ipc_request (struct msgbuf *msgp) 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); - } + glibtop_error_io ("read"); /* Send this string off, but only if we have enough space */ @@ -249,23 +220,17 @@ handle_ipc_request (struct msgbuf *msgp) while ((len = read (0,buf,1)) == 0) ; if (len < 0) - { - perror(progname); - fprintf (stderr,"%s: unable to read\n", progname); - exit (1); - } + glibtop_error_io ("read"); + if (buf[0] != '\n') - { - fprintf (stderr,"%s: garbage after result [%c]\n", progname, buf[0]); - exit (1); - } + glibtop_error ("garbage after result [%c]", buf[0]); #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)"); + glibtop_warn_io ("msgsend(gnuserv)"); } /* handle_ipc_request */ #endif /* SYSV_IPC */ @@ -296,11 +261,8 @@ echo_request (int s) } /* while */ - if (len < 0) { - perror(progname); - fprintf(stderr,"%s: unable to recv\n",progname); - exit(1); - } /* if */ + if (len < 0) + glibtop_error_io ("recv"); } /* echo_request */ @@ -312,6 +274,7 @@ echo_request (int s) static void handle_response (void) { +#if 0 char buf[GSERV_BUFSZ+1]; int offset=0; int s; @@ -325,22 +288,17 @@ handle_response (void) offset += len; } - if (len < 0) { - perror(progname); - fprintf(stderr,"%s: unable to read\n",progname); - exit(1); - } + if (len < 0) + glibtop_error_io ("read"); /* 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); - } + if ((len = read(0,buf,min2(result_len,GSERV_BUFSZ))) < 0) + glibtop_error_io ("read"); + buf[len] = '\0'; send_string(s,buf); result_len -= len; @@ -350,20 +308,18 @@ handle_response (void) while ((len = read(0,buf,1)) == 0) ; if (len < 0) - { - perror(progname); - fprintf(stderr,"%s: unable to read\n",progname); - exit(1); - } + glibtop_error_io ("read"); + if (buf[0] != '\n') - { - fprintf(stderr,"%s: garbage after result\n",progname); - exit(1); - } + glibtop_error ("garbage after result"); + /* send the newline */ buf[1] = '\0'; send_string(s,buf); close(s); +#else + glibtop_error ("handle_response (): Function not implemented"); +#endif } /* handle_response */ #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ @@ -412,18 +368,18 @@ timed_read (int fd, char *buf, int max, int timeout, int one_line) } else { - printf ("read error on socket\004\n"); + glibtop_warn_io ("read error on socket"); return -1; } } else if (r == 0) { - printf ("read timed out\004\n"); + glibtop_warn ("read timed out"); return -1; } else { - printf ("error in select\004\n"); + glibtop_warn_io ("error in select"); return -1; } } while ((nbytes < max) && !(one_line && (c == '\n'))); @@ -464,10 +420,8 @@ permitted (u_long host_addr, int fd) 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"); - + glibtop_warn ("Authentication protocol from client is invalid", auth_protocol); + return FALSE; } @@ -493,7 +447,7 @@ permitted (u_long host_addr, int fd) return TRUE; } #else - printf ("client tried Xauth, but server is not compiled with Xauth\n"); + glibtop_warn ("client tried Xauth, but server is not compiled with Xauth"); #endif /* @@ -501,8 +455,8 @@ permitted (u_long host_addr, int fd) * protocol.... */ - printf ("Xauth authentication failed, trying GNU_SECURE auth...\004\n"); - + glibtop_warn ("Xauth authentication failed, trying GNU_SECURE auth..."); + } /* Other auth protocols go here, and should execute only if the @@ -518,7 +472,7 @@ permitted (u_long host_addr, int fd) key = HASH(host_addr) % TABLE_SIZE; /* Now check the chain for that hash key */ - for(entry=permitted_hosts[key]; entry != NULL; entry=entry->next) + for(entry = permitted_hosts[key]; entry != NULL; entry=entry->next) if (host_addr == entry->host_addr) return(TRUE); @@ -537,13 +491,10 @@ add_host (u_long host_addr) int key; struct entry *new_entry; - if (!permitted(host_addr, -1)) + 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 */ + if ((new_entry = (struct entry *) malloc(sizeof(struct entry))) == NULL) + glibtop_error_io ("unable to malloc space for permitted host entry"); new_entry->host_addr = host_addr; key = HASH(host_addr) % TABLE_SIZE; @@ -572,17 +523,13 @@ setup_table (void) int i, hosts=0; /* Make sure every entry is null */ - for (i=0; is_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 */ + glibtop_error_io ("unable to create socket"); /* 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 */ + glibtop_error_io ("bind"); /* 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 */ + glibtop_error_io ("listen"); return(ls); @@ -692,19 +628,13 @@ handle_internet_request (int ls) 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 */ - + glibtop_error_io ("accept"); + /* 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)); + glibtop_warn ("Refused connection from %s", inet_ntoa (peer.sin_addr)); return; } /* if */ @@ -726,31 +656,22 @@ unix_init (void) 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 */ + if ((ls = socket (AF_UNIX,SOCK_STREAM, 0)) < 0) + glibtop_error_io ("unable to create socket"); /* 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) + sprintf (server.sun_path, "/tmp/lgtddir%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); - } + if (chmod (server.sun_path, 0700) < 0) + glibtop_error_io ("Can't set permissions on %s", server.sun_path); } - strcat(server.sun_path,"/gsrv"); + strcat(server.sun_path, "/lgtd"); unlink(server.sun_path); /* remove old file if it exists */ #else /* HIDE_UNIX_SOCKET */ - sprintf(server.sun_path,"/tmp/gsrv%d",(int)geteuid()); + sprintf(server.sun_path, "/tmp/lgtd%d", (int)geteuid()); unlink(server.sun_path); /* remove old file if it exists */ #endif /* HIDE_UNIX_SOCKET */ @@ -765,20 +686,13 @@ unix_init (void) 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 */ + if (bind (ls, (struct sockaddr *)&server, bindlen) < 0) + glibtop_error_io ("bind"); 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 */ + if (listen(ls,20) < 0) + glibtop_error_io ("listen"); /* #### there are also better ways of dealing with this when sigvec() is present. */ @@ -790,10 +704,10 @@ unix_init (void) sigprocmask (SIG_BLOCK, &_mask, NULL); } #else - signal(SIGPIPE,SIG_IGN); /* in case user kills client */ + signal (SIGPIPE, SIG_IGN); /* in case user kills client */ #endif - return(ls); + return (ls); } /* unix_init */ @@ -811,11 +725,8 @@ handle_unix_request (int ls) 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 */ + if ((s = accept (ls, (struct sockaddr *)&server, (void *)&len)) < 0) + glibtop_error_io ("accept"); echo_request(s); @@ -829,17 +740,13 @@ main(argc,argv) 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]; + glibtop_init (); for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */ ; @@ -870,11 +777,7 @@ main(argc,argv) 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 */ + glibtop_error_io ("select"); #ifdef UNIX_DOMAIN_SOCKETS if (uls > 0 && FD_ISSET(uls, &rmask)) diff --git a/sysdeps/common/Makefile.am b/sysdeps/common/Makefile.am index d61567c7..763a1316 100644 --- a/sysdeps/common/Makefile.am +++ b/sysdeps/common/Makefile.am @@ -8,5 +8,4 @@ CFLAGS = -Wall -W @CFLAGS@ lib_LTLIBRARIES = libgtop_common.la -libgtop_common_la_SOURCES = sysdeps.c xmalloc.c error.c - +libgtop_common_la_SOURCES = sysdeps.c xmalloc.c error.c gnuslib.c diff --git a/sysdeps/common/gnuslib.c b/sysdeps/common/gnuslib.c index f4ef268a..dad417a8 100644 --- a/sysdeps/common/gnuslib.c +++ b/sysdeps/common/gnuslib.c @@ -33,8 +33,9 @@ static char rcsid [] = "!Header: gnuslib.c,v 2.4 95/02/16 11:57:37 arup alpha !"; #endif -#include "gnuserv.h" -#include +#include + +#include #ifdef SYSV_IPC static int connect_to_ipc_server (void); @@ -43,7 +44,7 @@ static int connect_to_ipc_server (void); static int connect_to_unix_server (void); #endif #ifdef INTERNET_DOMAIN_SOCKETS -static int connect_to_internet_server (char *serverhost, u_short port); +static int connect_to_internet_server (const char *serverhost, u_short port); #endif /* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */ @@ -59,45 +60,33 @@ static int connect_to_internet_server (char *serverhost, u_short port); # define NUMERIC_ADDR_ERROR (numeric_addr == (IN_ADDR) -1) #endif -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#ifdef HAVE_STRING_H -#include -#endif /* HAVE_STRING_H */ - #include -char *progname = NULL; - -int make_connection(hostarg, portarg, s) - char *hostarg; +int +glibtop_make_connection (hostarg, portarg, s) + const 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); + hostarg = getenv ("LIBGTOP_HOST"); + if (portarg == 0 && (ptr = getenv("LIBGTOP_PORT")) != NULL) + portarg = atoi (ptr); #endif if (hostarg != NULL) { - /* hostname was given explicitly, via cmd line arg or GNU_HOST, + /* hostname was given explicitly, via cmd line arg or LIBGTOP_HOST, * so obey it. */ #ifdef UNIX_DOMAIN_SOCKETS - if (!strcmp(hostarg, "unix")) { - *s = connect_to_unix_server(); + 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); + *s = connect_to_internet_server (hostarg, portarg); return (int) CONN_INTERNET; #endif #ifdef SYSV_IPC @@ -107,16 +96,16 @@ int make_connection(hostarg, portarg, s) /* 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(); + *s = connect_to_unix_server (); return (int) CONN_UNIX; #elif defined(SYSV_IPC) - *s = connect_to_ipc_server(); + *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); + 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 */ @@ -128,26 +117,20 @@ int make_connection(hostarg, portarg, s) 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) +static int +connect_to_ipc_server (void) { int s; /* connected msqid */ key_t key; /* message key */ - char buf[GSERV_BUFSZ+1]; /* buffer for filename */ + 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); - } + sprintf (buf, "/tmp/lgtd%d", (int)geteuid()); + creat (buf, 0600); + if ((key = ftok (buf, 1)) == -1) + glibtop_error_io ("unable to get ipc key from %s", buf); - if ((s = msgget(key,0600)) == -1) { - perror(progname); - fprintf(stderr,"%s: unable to access msg queue\n",progname); - exit(1); - }; /* if */ + if ((s = msgget (key, 0600)) == -1) + glibtop_error_io ("unable to access msg queue"); return(s); @@ -194,7 +177,9 @@ void disconnect_from_ipc_server(s,msgp,echo) /* send_string -- send string to socket. */ -void send_string(s,msg) +#if 0 +static void +send_string(s,msg) int s; const char *msg; { @@ -225,7 +210,8 @@ void send_string(s,msg) /* read_line -- read a \n terminated line from a socket */ -int read_line(int s, char *dest) +static int +read_line(int s, char *dest) { int length; int offset=0; @@ -241,6 +227,7 @@ int read_line(int s, char *dest) strcpy(dest,buffer); return 1; } /* read_line */ +#endif #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ @@ -250,28 +237,23 @@ int read_line(int s, char *dest) domain socket. Returns socket descriptor for server if successful. */ -static int connect_to_unix_server (void) +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 */ + if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) + glibtop_error_io ("unable to create socket"); server.sun_family = AF_UNIX; #ifdef HIDE_UNIX_SOCKET - sprintf(server.sun_path,"/tmp/gsrvdir%d/gsrv",(int)geteuid()); + sprintf(server.sun_path, "/tmp/lgtddir%d/lgtd", (int)geteuid()); #else /* HIDE_UNIX_SOCKET */ - sprintf(server.sun_path,"/tmp/gsrv%d",(int)geteuid()); + sprintf(server.sun_path, "/tmp/lgtd%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 */ + if (connect (s, (struct sockaddr *)&server, strlen(server.sun_path)+2) < 0) + glibtop_error_io ("unable to connect to local"); return(s); @@ -284,8 +266,8 @@ static int connect_to_unix_server (void) internet_addr -- return the internet addr of the hostname or internet address passed. Return -1 on error. */ -int internet_addr(host) - char *host; +long glibtop_internet_addr (host) + const char *host; { struct hostent *hp; /* pointer to host info for remote host */ IN_ADDR numeric_addr; /* host address */ @@ -300,7 +282,7 @@ int internet_addr(host) return -1; } -} /* internet_addr */ +} /* glibtop_internet_addr */ #ifdef AUTH_MAGIC_COOKIE # include @@ -314,7 +296,8 @@ static Xauth *server_xauth = NULL; an internet domain socket. Returns socket descriptor for server if successful. */ -static int connect_to_internet_server (char *serverhost, u_short port) +static int +connect_to_internet_server (const char *serverhost, u_short port) { int s; /* connected socket descriptor */ struct servent *sp; /* pointer to service information */ @@ -322,43 +305,34 @@ static int connect_to_internet_server (char *serverhost, u_short port) char buf[512]; /* temporary buffer */ /* clear out address structures */ - memset((char *)&peeraddr_in,0,sizeof(struct sockaddr_in)); + 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 (((long) peeraddr_in.sin_addr.s_addr = glibtop_internet_addr (serverhost)) == -1) + glibtop_error ("unable to find %s in /etc/hosts or from YP", serverhost); if (port == 0) { - if ((sp = getservbyname ("gnuserv","tcp")) == NULL) - peeraddr_in.sin_port = htons(DEFAULT_PORT+getuid()); + if ((sp = getservbyname ("gtopd","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); + 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 */ + if ((s = socket (AF_INET, SOCK_STREAM, 0))== -1) + glibtop_error_io ("unable to create socket"); /* 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 */ + sizeof(struct sockaddr_in)) == -1) + glibtop_error_io ("unable to connect to remote"); #ifdef AUTH_MAGIC_COOKIE @@ -375,7 +349,7 @@ static int connect_to_internet_server (char *serverhost, u_short port) 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); } @@ -395,7 +369,9 @@ static int connect_to_internet_server (char *serverhost, u_short port) disconnect_from_server -- inform the server that sending has finished, and wait for its reply. */ -void disconnect_from_server(s,echo) +#if 0 +static void +disconnect_from_server(s,echo) int s; int echo; { @@ -453,4 +429,5 @@ void disconnect_from_server(s,echo) }; /* if */ } /* disconnect_from_server */ +#endif #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ From 2a281d0a53a1ac9a3032204658a3d3f83078a5af Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 21:30:41 +0000 Subject: [PATCH 0144/2539] Added `socket' field. 1998-06-14 Martin Baulig * glibtop.h (struct _glibtop): Added `socket' field. --- ChangeLog | 2 ++ glibtop.h | 1 + 2 files changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 103e882a..9307741c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 1998-06-14 Martin Baulig + * glibtop.h (struct _glibtop): Added `socket' field. + * include/glibtop/gnuserv.h: New file. Imported from xemacs 20.3. * sysdeps/common/gnuslib.c: New file. Imported from xemacs 20.3 diff --git a/glibtop.h b/glibtop.h index 3f833081..6bb29447 100644 --- a/glibtop.h +++ b/glibtop.h @@ -41,6 +41,7 @@ struct _glibtop #endif int input [2]; /* Pipe client <- server */ int output [2]; /* Pipe client -> server */ + int socket; /* Accepted connection of a socket */ 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 */ From 8d785595975142f7f9767144814ef525a6586ab7 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 21:32:00 +0000 Subject: [PATCH 0145/2539] Did some more work on the daemon. --- examples/Makefile.am | 8 +- lib/Makefile.am | 2 +- lib/gnuclient.c | 39 +------ lib/init.c | 4 +- lib/open.c | 24 +++- lib/read.c | 35 ++++-- lib/read_data.c | 31 ++++- lib/write.c | 32 ++++- src/daemon/Makefile.am | 25 ++++ src/daemon/gnuserv.c | 59 ++++++++-- src/daemon/main.c | 259 +++++++++++++++++++++++++++++++++++++++++ src/proxy/Makefile.am | 2 +- 12 files changed, 443 insertions(+), 77 deletions(-) create mode 100644 src/daemon/Makefile.am create mode 100644 src/daemon/main.c diff --git a/examples/Makefile.am b/examples/Makefile.am index a79cf4ce..945e8db1 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -16,8 +16,8 @@ bin_PROGRAMS = first first_static second second_static \ EXTRA_PROGRAMS = third third_static first_SOURCES = first.c -first_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ - $(top_builddir)/lib/libgtop.la \ +first_LDADD = $(top_builddir)/lib/libgtop.la \ + $(top_builddir)/sysdeps/common/libgtop_common.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ @@ -26,8 +26,8 @@ first_static_LDADD = $(first_LDADD) first_static_LDFLAGS = -static second_SOURCES = second.c -second_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ - $(top_builddir)/lib/libgtop.la \ +second_LDADD = $(top_builddir)/lib/libgtop.la \ + $(top_builddir)/sysdeps/common/libgtop_common.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ diff --git a/lib/Makefile.am b/lib/Makefile.am index 9e32e2e8..6f2a9116 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -24,4 +24,4 @@ bin_PROGRAMS = gnuclient gnuclient_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ @INTLLIBS@ @LIBSUPPORT@ @X_LIBS@ -lXau -gnuclient_LDFLAGS = -static +gnuclient_LDFLAGS = -static diff --git a/lib/gnuclient.c b/lib/gnuclient.c index e23fa8c9..122cc468 100644 --- a/lib/gnuclient.c +++ b/lib/gnuclient.c @@ -51,14 +51,9 @@ int main (int argc, char *argv[]) { int s; /* socket / msqid to server */ - int connect_type; /* CONN_UNIX, CONN_INTERNET, or - * CONN_IPC */ + int connect_type; /* CONN_UNIX, CONN_INTERNET, or CONN_IPC */ #ifdef INTERNET_DOMAIN_SOCKETS - char *hostarg = NULL; /* remote hostname */ - char thishost[HOSTNAMSZ]; /* this hostname */ - char remotepath[MAXPATHLEN+1]; /* remote pathname */ - int rflg = 0; /* pathname given on cmdline */ - u_short port = 0; /* port to server */ + char thishost [HOSTNAMSZ]; /* this hostname */ #endif /* INTERNET_DOMAIN_SOCKETS */ #ifdef SYSV_IPC struct msgbuf *msgp; /* message */ @@ -66,42 +61,12 @@ main (int argc, char *argv[]) glibtop_init (); -#ifdef INTERNET_DOMAIN_SOCKETS - memset (remotepath, 0, sizeof (remotepath)); -#endif /* INTERNET_DOMAIN_SOCKETS */ - -#if defined(INTERNET_DOMAIN_SOCKETS) - connect_type = glibtop_make_connection (hostarg, port, &s); -#else connect_type = glibtop_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 ("LIBGTOP_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 */ diff --git a/lib/init.c b/lib/init.c index f0094020..ceefe35e 100644 --- a/lib/init.c +++ b/lib/init.c @@ -27,7 +27,7 @@ glibtop *glibtop_global_server = NULL; glibtop * glibtop_init_r (glibtop **server, const unsigned long features, - const unsigned flags) + const unsigned flags) { if (*server != NULL) return *server; @@ -35,7 +35,7 @@ glibtop_init_r (glibtop **server, const unsigned long features, if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; glibtop_open_l (glibtop_global_server, "glibtop", - features, flags); + features, flags); } return *server = glibtop_global_server; diff --git a/lib/open.c b/lib/open.c index d3501fa4..2411b1c0 100644 --- a/lib/open.c +++ b/lib/open.c @@ -25,25 +25,45 @@ #include #include +#include + /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void glibtop_open_l (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) + 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; + int connect_type; memset (server, 0, sizeof (glibtop)); server->name = program_name; /* Is the user allowed to override the server ? */ - + if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) { + connect_type = glibtop_make_connection + (NULL, (u_short) 0, &server->socket); + +#ifdef INTERNET_DOMAIN_SOCKETS + if (connect_type == (int) CONN_INTERNET) { + 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); + return; + } +#endif /* INTERNET_DOMAIN_SOCKETS */ + /* Try to get data from environment. */ temp = getenv ("LIBGTOP_SERVER") ? diff --git a/lib/read.c b/lib/read.c index e8b2e623..361bb5a4 100644 --- a/lib/read.c +++ b/lib/read.c @@ -27,15 +27,36 @@ void glibtop_read_l (glibtop *server, size_t size, void *buf) { size_t ssize; + int ret; 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)); + +#ifdef DEBUG + fprintf (stderr, "LIBRARY: reading %d bytes, should be %d.\n", sizeof (size_t), size); +#endif + + if (server->socket) { + ret = recv (server->socket, &ssize, sizeof (size_t), 0); + } else { + ret = read (server->input [0], &ssize, sizeof (size_t)); + } + + if (ret < 0) + glibtop_error_io_r (server, _("read size")); if (size != ssize) - 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, _("got %d bytes but requested %d (ret = %d)"), ssize, size, ret); + +#ifdef DEBUG + fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size); +#endif + + if (server->socket) { + ret = recv (server->socket, buf, size, 0); + } else { + ret = read (server->input [0], buf, size); + } + + if (ret < 0) + glibtop_error_io_r (server, _("read %d bytes"), size); } diff --git a/lib/read_data.c b/lib/read_data.c index d11b28d9..f7ac86c9 100644 --- a/lib/read_data.c +++ b/lib/read_data.c @@ -29,20 +29,39 @@ glibtop_read_data_l (glibtop *server) { size_t size; void *ptr; + int ret; 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)); +#ifdef DEBUG + fprintf (stderr, "LIBRARY: reading %d data bytes.\n", sizeof (size_t)); +#endif + + if (server->socket) { + ret = recv (server->socket, &size, sizeof (size_t), 0); + } else { + ret = read (server->input [0], &size, sizeof (size_t)); + } + + if (ret < 0) + glibtop_error_io_r (server, _("read data size")); + +#ifdef DEBUG + fprintf (stderr, "LIBRARY: really reading %d data bytes (ret = %d).\n", size, ret); +#endif if (!size) return NULL; 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)); + if (server->socket) { + ret = recv (server->socket, ptr, size, 0); + } else { + ret = read (server->input [0], ptr, size); + } + + if (ret < 0) + glibtop_error_io_r (server, _("read data %d bytes")); return ptr; } diff --git a/lib/write.c b/lib/write.c index ac03ecae..f91858ee 100644 --- a/lib/write.c +++ b/lib/write.c @@ -26,13 +26,35 @@ void glibtop_write_l (glibtop *server, size_t size, void *buf) { + int ret; + 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)); +#ifdef DEBUG + fprintf (stderr, "LIBRARY: writing %d bytes = %d.\n", sizeof (size_t), size); +#endif + + if (server->socket) { + ret = send (server->socket, &size, sizeof (size_t), 0); + } else { + ret = write (server->output [1], &size, sizeof (size_t)); + } + + if (ret < 0) + glibtop_error_io_r (server, _("write size")); if (!size) return; - - if (write (server->output [1], buf, size) < 0) - glibtop_error_r (server, _("write %d bytes: %s"), size, strerror (errno)); + +#ifdef DEBUG + fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size); +#endif + + if (server->socket) { + ret = send (server->socket, buf, size, 0); + } else { + ret = write (server->output [1], buf, size); + } + + if (ret < 0) + glibtop_error_io_r (server, _("write %d bytes"), size); } diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am new file mode 100644 index 00000000..7ac13ca7 --- /dev/null +++ b/src/daemon/Makefile.am @@ -0,0 +1,25 @@ +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 = gnuserv + +EXTRA_PROGRAMS = gtop_daemon + +gnuserv_SOURCES = gnuserv.c main.c +gnuserv_LDADD = $(top_builddir)/lib/libgtop.la \ + $(top_builddir)/sysdeps/common/libgtop_common.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ + @INTLLIBS@ @LIBSUPPORT@ @X_LIBS@ -lXau +gnuserv_LDFLAGS = -static + +gtop_daemon_SOURCES = main.c inet.c loop.c output.c version.c +gtop_daemon_LDADD = $(top_builddir)/lib/libgtop.la \ + $(top_builddir)/sysdeps/common/libgtop_common.la \ + $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ + @INTLLIBS@ @LIBSUPPORT@ +gtop_daemon_LDFLAGS = -static diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index 9077b023..e5016e7d 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -33,12 +33,17 @@ static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; #endif +#define DEBUG + #include +#include #ifdef AIX #include #endif +extern void handle_socket_connection __P((int)); + #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) main () { @@ -417,6 +422,10 @@ permitted (u_long host_addr, int fd) if (timed_read(fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0) return FALSE; +#ifdef DEBUG + fprintf (stderr, "Client sent authenticatin protocol '%s'\n", auth_protocol); +#endif + if (strcmp (auth_protocol, DEFAUTH_NAME) && strcmp (auth_protocol, MCOOKIE_NAME)) { @@ -425,24 +434,24 @@ permitted (u_long host_addr, int fd) return FALSE; } - if (!strcmp(auth_protocol, MCOOKIE_NAME)) + if (!strcmp (auth_protocol, MCOOKIE_NAME)) { /* * doing magic cookie auth */ - if (timed_read(fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) + if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) return FALSE; - auth_data_len = atoi(buf); + auth_data_len = atoi (buf); - if (timed_read(fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) + 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)) + !memcmp (buf, server_xauth->data, auth_data_len)) { return TRUE; } @@ -470,11 +479,19 @@ permitted (u_long host_addr, int fd) /* First find the hash key */ key = HASH(host_addr) % TABLE_SIZE; + +#ifdef DEBUG + fprintf (stderr, "Doing GNU_SECURE auth ...\n"); +#endif /* Now check the chain for that hash key */ - for(entry = permitted_hosts[key]; entry != NULL; entry=entry->next) + for(entry = permitted_hosts [key]; entry != NULL; entry = entry->next) { +#ifdef DEBUG + fprintf (stderr, "Trying %ld\n", entry->host_addr); +#endif if (host_addr == entry->host_addr) return(TRUE); + } return(FALSE); @@ -625,20 +642,34 @@ handle_internet_request (int ls) size_t addrlen = sizeof(struct sockaddr_in); struct sockaddr_in peer; /* for peer socket address */ - memset((char *)&peer,0,sizeof(struct sockaddr_in)); + memset((char *)&peer, 0, sizeof (struct sockaddr_in)); - if ((s = accept(ls,(struct sockaddr *)&peer, (void *) &addrlen)) == -1) + if ((s = accept (ls, (struct sockaddr *)&peer, (void *) &addrlen)) == -1) glibtop_error_io ("accept"); + +#ifdef DEBUG + fprintf (stderr, "Connection was made from %s.\n", inet_ntoa (peer.sin_addr)); +#endif /* Check that access is allowed - if not return crud to the client */ - if (!permitted(peer.sin_addr.s_addr, s)) + if (!permitted (peer.sin_addr.s_addr, s)) { close(s); - glibtop_warn ("Refused connection from %s", inet_ntoa (peer.sin_addr)); + glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr)); return; } /* if */ - echo_request(s); +#ifdef DEBUG + fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr)); +#endif + + handle_socket_connection (s); + + close (s); + +#ifdef DEBUG + fprintf (stderr, "Closed connection to %s.\n", inet_ntoa (peer.sin_addr)); +#endif } /* handle_internet_request */ #endif /* INTERNET_DOMAIN_SOCKETS */ @@ -746,7 +777,7 @@ main(argc,argv) struct msgbuf *msgp; /* message buffer */ #endif /* SYSV_IPC */ - glibtop_init (); + glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE); for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */ ; @@ -774,6 +805,10 @@ main(argc,argv) FD_SET(uls, &rmask); if (ils >= 0) FD_SET(ils, &rmask); + +#ifdef DEBUG + fprintf (stderr, "Server ready and waiting for connections.\n"); +#endif if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask, (fd_set *)NULL, (fd_set *)NULL, (struct timeval *)NULL) < 0) diff --git a/src/daemon/main.c b/src/daemon/main.c new file mode 100644 index 00000000..050de8bf --- /dev/null +++ b/src/daemon/main.c @@ -0,0 +1,259 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 + +#include +#include +#include +#include +#include + +#include +#include + +#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 + +static void +do_output (int s, size_t size, const void *buf) +{ +#ifdef REAL_DEBUG + fprintf (stderr, "Writing %d bytes = %d.\n", sizeof (size_t), size); +#endif + + if (send (s, &size, sizeof (size_t), 0) < 0) + glibtop_warn_io ("send"); + + if (!size) + return; + +#ifdef REAL_DEBUG + fprintf (stderr, "Really writing %d bytes.\n", size); +#endif + + if (send (s, buf, size, 0) < 0) + glibtop_warn_io ("send"); +} + +void +handle_socket_connection (int s) +{ + pid_t pid; + int nread; + size_t size, dsize; + char parameter [BUFSIZ]; + struct timeval tv; + glibtop_union data; + glibtop_command cmnd; + glibtop_sysdeps sysdeps; + glibtop server; + void *ptr; + + tv.tv_sec = 5; + tv.tv_usec = 0; + + while(1) { + nread = recv (s, &size, sizeof (size_t), 0); + + if (nread < 0) { + glibtop_warn_io ("recv"); + return; + } + + if (nread == 0) + return; + + if (nread != sizeof (size_t)) { + glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread); + return; + } + + if (size != sizeof (glibtop_command)) { + glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread); + return; + } + + nread = recv (s, &cmnd, size, 0); + + if (nread < 0) { + glibtop_warn_io ("recv"); + return; + } + + if (nread == 0) + return; + +#ifdef REAL_DEBUG + fprintf (stderr, "Received command %d from client.\n", cmnd.command); +#endif + + nread = recv (s, &dsize, sizeof (size_t), 0); + + /* will return 0 if parent exits. */ + + if (nread < 0) { + glibtop_warn_io ("recv"); + return; + } + + if (nread == 0) + return; + + if (dsize >= BUFSIZ) { + glibtop_warn ("Client sent %d bytes, but buffer is %d", dsize, BUFSIZ); + return; + } + + memset (parameter, 0, sizeof (parameter)); + + if (dsize) { +#ifdef REAL_DEBUG + fprintf (stderr, "Client has %d bytes of data.\n", dsize); +#endif + + nread = recv (s, parameter, dsize, 0); + + /* will return 0 if parent exits. */ + + if (nread < 0) { + glibtop_warn_io ("recv"); + return; + } + + if (nread == 0) + return; + + if (nread != (int) dsize) { + glibtop_warn ("Expected %d bytes but got %d", dsize, nread); + return; + } + } + + switch (cmnd.command) { + case GLIBTOP_CMND_SYSDEPS: + sysdeps.features = GLIBTOP_SYSDEPS_ALL; + do_output (s, sizeof (glibtop_sysdeps), &sysdeps); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_CPU: + glibtop_get_cpu_l (&server, &data.cpu); + do_output (s, sizeof (glibtop_cpu), &data.cpu); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_MEM: + glibtop_get_mem_l (&server, &data.mem); + do_output (s, sizeof (glibtop_mem), &data.mem); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_SWAP: + glibtop_get_swap_l (&server, &data.swap); + do_output (s, sizeof (glibtop_swap), &data.swap); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_UPTIME: + glibtop_get_uptime_l (&server, &data.uptime); + do_output (s, sizeof (glibtop_uptime), &data.uptime); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_LOADAVG: + glibtop_get_loadavg_l (&server, &data.loadavg); + do_output (s, sizeof (glibtop_loadavg), &data.loadavg); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_SHM_LIMITS: + glibtop_get_shm_limits_l (&server, &data.shm_limits); + do_output (s, sizeof (glibtop_shm_limits), &data.shm_limits); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_MSG_LIMITS: + glibtop_get_msg_limits_l (&server, &data.msg_limits); + do_output (s, sizeof (glibtop_msg_limits), &data.msg_limits); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_SEM_LIMITS: + glibtop_get_sem_limits_l (&server, &data.sem_limits); + do_output (s, sizeof (glibtop_sem_limits), &data.sem_limits); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_PROCLIST: + ptr = glibtop_get_proclist_l (&server, &data.proclist); + do_output (s, sizeof (glibtop_proclist), &data.proclist); + do_output (s, 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); + do_output (s, sizeof (glibtop_proc_state), &data.proc_state); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_PROC_UID: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_uid_l + (&server, &data.proc_uid, pid); + do_output (s, sizeof (glibtop_proc_uid), &data.proc_uid); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_PROC_MEM: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_mem_l + (&server, &data.proc_mem, pid); + do_output (s, sizeof (glibtop_proc_mem), &data.proc_mem); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_PROC_TIME: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_time_l + (&server, &data.proc_time, pid); + do_output (s, sizeof (glibtop_proc_time), &data.proc_time); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_PROC_SIGNAL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_signal_l + (&server, &data.proc_signal, pid); + do_output (s, sizeof (glibtop_proc_signal), &data.proc_signal); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_PROC_KERNEL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_kernel_l + (&server, &data.proc_kernel, pid); + do_output (s, sizeof (glibtop_proc_kernel), &data.proc_kernel); + do_output (s, 0, NULL); + break; + case GLIBTOP_CMND_PROC_SEGMENT: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_segment_l + (&server, &data.proc_segment, pid); + do_output (s, sizeof (glibtop_proc_segment), &data.proc_segment); + do_output (s, 0, NULL); + break; + } + } +} diff --git a/src/proxy/Makefile.am b/src/proxy/Makefile.am index 66badb1a..c2733c05 100644 --- a/src/proxy/Makefile.am +++ b/src/proxy/Makefile.am @@ -12,5 +12,5 @@ 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@ + @INTLLIBS@ @LIBSUPPORT@ @libs_xauth@ gtop_proxy_LDFLAGS = -static From d9e6288b7a6583a4f3a8dafeeb1225146b2c2927 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 14 Jun 1998 21:33:26 +0000 Subject: [PATCH 0146/2539] *** empty log message *** --- src/daemon/.cvsignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/daemon/.cvsignore diff --git a/src/daemon/.cvsignore b/src/daemon/.cvsignore new file mode 100644 index 00000000..3dda7298 --- /dev/null +++ b/src/daemon/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile From 2de9ea5c7d316930fe49ba8a53803487f39bf282 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 10:22:39 +0000 Subject: [PATCH 0147/2539] Changed client <-> server interface to make less system calls. 1998-06-18 Martin Baulig * lib/{command, write, read}.c: Changed client <-> server interface to make less system calls. * src/daemon/main.c: Changed server side of interface. * include/glibtop/command.h (struct _glibtop_response): New structure to return data from the server to the client. --- ChangeLog | 10 ++ include/glibtop/command.h | 24 ++- lib/Makefile.am | 2 +- lib/command.c | 42 +++-- lib/read.c | 17 -- lib/write.c | 15 +- src/daemon/Makefile.am | 2 +- src/daemon/main.c | 326 +++++++++++++++++--------------------- 8 files changed, 203 insertions(+), 235 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9307741c..596cd3ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1998-06-18 Martin Baulig + + * lib/{command, write, read}.c: Changed client <-> server + interface to make less system calls. + + * src/daemon/main.c: Changed server side of interface. + + * include/glibtop/command.h (struct _glibtop_response): New + structure to return data from the server to the client. + 1998-06-14 Martin Baulig * glibtop.h (struct _glibtop): Added `socket' field. diff --git a/include/glibtop/command.h b/include/glibtop/command.h index 8314699f..259bdec0 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -50,13 +50,29 @@ __BEGIN_DECLS #define GLIBTOP_MAX_CMND 18 -typedef struct _glibtop_command glibtop_command; +#define _GLIBTOP_PARAM_SIZE 16 + +typedef struct _glibtop_command glibtop_command; +typedef struct _glibtop_response glibtop_response; struct _glibtop_command { - glibtop server; - unsigned command; - size_t size; + glibtop server; + unsigned command; + size_t size, data_size; + char parameter [_GLIBTOP_PARAM_SIZE]; +}; + +union _glibtop_response_union +{ + glibtop_union data; + glibtop_sysdeps sysdeps; +}; + +struct _glibtop_response +{ + size_t data_size; + union _glibtop_response_union u; }; #define glibtop_call(p1, p2, p3, p4) glibtop_call_r(glibtop_global_server, p1, p2, p3, p4) diff --git a/lib/Makefile.am b/lib/Makefile.am index 6f2a9116..c2835361 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -4,7 +4,7 @@ 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@"\" +CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\" -DDEBUG lib_LTLIBRARIES = libgtop.la diff --git a/lib/command.c b/lib/command.c index e8d2dc97..b7f6ccd4 100644 --- a/lib/command.c +++ b/lib/command.c @@ -28,27 +28,43 @@ void * glibtop_call_l (glibtop *server, unsigned command, size_t send_size, void *send_buf, - size_t recv_size, void *recv_buf) + size_t recv_size, void *recv_buf) { - glibtop_command *cmnd; + glibtop_command cmnd; + glibtop_response response; void *ptr; glibtop_init_r (&server, 0, 0); - cmnd = glibtop_calloc_r (server, 1, sizeof (glibtop_command)); + memset (&cmnd, 0, sizeof (glibtop_command)); + + memcpy (&cmnd.server, server, sizeof (glibtop)); - memcpy (&cmnd->server, server, sizeof (glibtop)); + cmnd.command = command; + + /* If send_size is less than _GLIBTOP_PARAM_SIZE (normally 16 Bytes), we + * send it together with command, so we only need one system call instead + * of two. */ + +#ifdef DEBUG + fprintf (stderr, "COMMAND: send_size = %d; command = %d; sizeof (cmnd) = %d\n", + send_size, command, sizeof (glibtop_command)); +#endif + + + if (send_size <= _GLIBTOP_PARAM_SIZE) + memcpy (cmnd.parameter, send_buf, send_size); + else + cmnd.size = send_size; - cmnd->command = command; - cmnd->size = send_size; - - glibtop_write_l (server, sizeof (glibtop_command), cmnd); + glibtop_write_l (server, sizeof (glibtop_command), &cmnd); glibtop_write_l (server, send_size, send_buf); - glibtop_read_l (server, recv_size, recv_buf); + + glibtop_read_l (server, sizeof (glibtop_response), &response); + + /* glibtop_read_l (server, recv_size, recv_buf); */ - ptr = glibtop_read_data_l (server); + /* ptr = glibtop_read_data_l (server); */ - glibtop_free_r (server, cmnd); - - return ptr; + return NULL; } diff --git a/lib/read.c b/lib/read.c index 361bb5a4..55fb922e 100644 --- a/lib/read.c +++ b/lib/read.c @@ -26,27 +26,10 @@ void glibtop_read_l (glibtop *server, size_t size, void *buf) { - size_t ssize; int ret; glibtop_init_r (&server, 0, 0); -#ifdef DEBUG - fprintf (stderr, "LIBRARY: reading %d bytes, should be %d.\n", sizeof (size_t), size); -#endif - - if (server->socket) { - ret = recv (server->socket, &ssize, sizeof (size_t), 0); - } else { - ret = read (server->input [0], &ssize, sizeof (size_t)); - } - - if (ret < 0) - glibtop_error_io_r (server, _("read size")); - - if (size != ssize) - glibtop_error_r (server, _("got %d bytes but requested %d (ret = %d)"), ssize, size, ret); - #ifdef DEBUG fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size); #endif diff --git a/lib/write.c b/lib/write.c index f91858ee..b786c0e7 100644 --- a/lib/write.c +++ b/lib/write.c @@ -30,20 +30,7 @@ glibtop_write_l (glibtop *server, size_t size, void *buf) glibtop_init_r (&server, 0, 0); -#ifdef DEBUG - fprintf (stderr, "LIBRARY: writing %d bytes = %d.\n", sizeof (size_t), size); -#endif - - if (server->socket) { - ret = send (server->socket, &size, sizeof (size_t), 0); - } else { - ret = write (server->output [1], &size, sizeof (size_t)); - } - - if (ret < 0) - glibtop_error_io_r (server, _("write size")); - - if (!size) return; + if (size == 0) return; #ifdef DEBUG fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size); diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index 7ac13ca7..fd221379 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -4,7 +4,7 @@ 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@"\" +CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\" -DDEBUG -DREAL_DEBUG bin_PROGRAMS = gnuserv diff --git a/src/daemon/main.c b/src/daemon/main.c index 050de8bf..f0696f0d 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -39,221 +39,177 @@ #endif static void -do_output (int s, size_t size, const void *buf) +do_output (int s, glibtop_response *response, size_t data_size, const void *data) { #ifdef REAL_DEBUG - fprintf (stderr, "Writing %d bytes = %d.\n", sizeof (size_t), size); + fprintf (stderr, "Really writing %d bytes.\n", sizeof (glibtop_response)); #endif - if (send (s, &size, sizeof (size_t), 0) < 0) - glibtop_warn_io ("send"); - - if (!size) - return; + response->data_size = data_size; + + if (send (s, response, sizeof (glibtop_response), 0) < 0) + glibtop_warn_io ("send"); + if (response->data_size) { #ifdef REAL_DEBUG - fprintf (stderr, "Really writing %d bytes.\n", size); + fprintf (stderr, "Writing %d bytes of data.\n", response->data_size); #endif - if (send (s, buf, size, 0) < 0) - glibtop_warn_io ("send"); + if (send (s, data, response->data_size, 0) , 0) + glibtop_warn_io ("send"); + } } void handle_socket_connection (int s) { - pid_t pid; - int nread; - size_t size, dsize; - char parameter [BUFSIZ]; - struct timeval tv; - glibtop_union data; - glibtop_command cmnd; - glibtop_sysdeps sysdeps; - glibtop server; - void *ptr; + pid_t pid; + int nread; + size_t size; + char parameter [BUFSIZ]; + struct timeval tv; + glibtop_response response; + glibtop_command cmnd; + glibtop server; + void *ptr; - tv.tv_sec = 5; - tv.tv_usec = 0; + tv.tv_sec = 5; + tv.tv_usec = 0; - while(1) { - nread = recv (s, &size, sizeof (size_t), 0); + while(1) { + nread = recv (s, &cmnd, sizeof (glibtop_command), 0); - if (nread < 0) { - glibtop_warn_io ("recv"); - return; - } + if (nread < 0) { + glibtop_warn_io ("recv"); + return; + } - if (nread == 0) - return; + if (nread == 0) + return; - if (nread != sizeof (size_t)) { - glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread); - return; - } - - if (size != sizeof (glibtop_command)) { - glibtop_warn ("Expected %d bytes but got %d", sizeof (size_t), nread); - return; - } - - nread = recv (s, &cmnd, size, 0); - - if (nread < 0) { - glibtop_warn_io ("recv"); - return; - } - - if (nread == 0) - return; + if (nread != sizeof (glibtop_command)) + glibtop_warn ("Received %d bytes, but expected %d\n", + nread, sizeof (glibtop_command)); #ifdef REAL_DEBUG - fprintf (stderr, "Received command %d from client.\n", cmnd.command); + fprintf (stderr, "Received command %d from client.\n", cmnd.command); #endif - nread = recv (s, &dsize, sizeof (size_t), 0); - - /* will return 0 if parent exits. */ - - if (nread < 0) { - glibtop_warn_io ("recv"); - return; - } - - if (nread == 0) - return; + if (cmnd.size >= BUFSIZ) { + glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd.size, BUFSIZ); + return; + } - if (dsize >= BUFSIZ) { - glibtop_warn ("Client sent %d bytes, but buffer is %d", dsize, BUFSIZ); - return; - } - - memset (parameter, 0, sizeof (parameter)); + memset (parameter, 0, sizeof (parameter)); - if (dsize) { + if (cmnd.size) { #ifdef REAL_DEBUG - fprintf (stderr, "Client has %d bytes of data.\n", dsize); + fprintf (stderr, "Client has %d bytes of data.\n", cmnd.size); #endif - nread = recv (s, parameter, dsize, 0); + nread = recv (s, parameter, cmnd.size, 0); - /* will return 0 if parent exits. */ + /* will return 0 if parent exits. */ - if (nread < 0) { - glibtop_warn_io ("recv"); - return; - } + if (nread < 0) { + glibtop_warn_io ("recv"); + return; + } - if (nread == 0) - return; + if (nread == 0) + return; - if (nread != (int) dsize) { - glibtop_warn ("Expected %d bytes but got %d", dsize, nread); - return; - } - } + if (nread != (int) cmnd.size) { + glibtop_warn ("Expected %d bytes but got %d", + cmnd.size, nread); + return; + } + } - switch (cmnd.command) { - case GLIBTOP_CMND_SYSDEPS: - sysdeps.features = GLIBTOP_SYSDEPS_ALL; - do_output (s, sizeof (glibtop_sysdeps), &sysdeps); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_CPU: - glibtop_get_cpu_l (&server, &data.cpu); - do_output (s, sizeof (glibtop_cpu), &data.cpu); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_MEM: - glibtop_get_mem_l (&server, &data.mem); - do_output (s, sizeof (glibtop_mem), &data.mem); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_SWAP: - glibtop_get_swap_l (&server, &data.swap); - do_output (s, sizeof (glibtop_swap), &data.swap); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_UPTIME: - glibtop_get_uptime_l (&server, &data.uptime); - do_output (s, sizeof (glibtop_uptime), &data.uptime); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_LOADAVG: - glibtop_get_loadavg_l (&server, &data.loadavg); - do_output (s, sizeof (glibtop_loadavg), &data.loadavg); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_SHM_LIMITS: - glibtop_get_shm_limits_l (&server, &data.shm_limits); - do_output (s, sizeof (glibtop_shm_limits), &data.shm_limits); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_MSG_LIMITS: - glibtop_get_msg_limits_l (&server, &data.msg_limits); - do_output (s, sizeof (glibtop_msg_limits), &data.msg_limits); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_SEM_LIMITS: - glibtop_get_sem_limits_l (&server, &data.sem_limits); - do_output (s, sizeof (glibtop_sem_limits), &data.sem_limits); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_PROCLIST: - ptr = glibtop_get_proclist_l (&server, &data.proclist); - do_output (s, sizeof (glibtop_proclist), &data.proclist); - do_output (s, 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); - do_output (s, sizeof (glibtop_proc_state), &data.proc_state); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_PROC_UID: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_uid_l - (&server, &data.proc_uid, pid); - do_output (s, sizeof (glibtop_proc_uid), &data.proc_uid); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_PROC_MEM: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_mem_l - (&server, &data.proc_mem, pid); - do_output (s, sizeof (glibtop_proc_mem), &data.proc_mem); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_PROC_TIME: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_time_l - (&server, &data.proc_time, pid); - do_output (s, sizeof (glibtop_proc_time), &data.proc_time); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_PROC_SIGNAL: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_signal_l - (&server, &data.proc_signal, pid); - do_output (s, sizeof (glibtop_proc_signal), &data.proc_signal); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_PROC_KERNEL: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_kernel_l - (&server, &data.proc_kernel, pid); - do_output (s, sizeof (glibtop_proc_kernel), &data.proc_kernel); - do_output (s, 0, NULL); - break; - case GLIBTOP_CMND_PROC_SEGMENT: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_segment_l - (&server, &data.proc_segment, pid); - do_output (s, sizeof (glibtop_proc_segment), &data.proc_segment); - do_output (s, 0, NULL); - break; - } - } + switch (cmnd.command) { + case GLIBTOP_CMND_SYSDEPS: + response.u.sysdeps.features = GLIBTOP_SYSDEPS_ALL; + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_CPU: + glibtop_get_cpu_l (&server, &response.u.data.cpu); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_MEM: + glibtop_get_mem_l (&server, &response.u.data.mem); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_SWAP: + glibtop_get_swap_l (&server, &response.u.data.swap); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_UPTIME: + glibtop_get_uptime_l (&server, &response.u.data.uptime); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_LOADAVG: + glibtop_get_loadavg_l (&server, &response.u.data.loadavg); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_SHM_LIMITS: + glibtop_get_shm_limits_l (&server, &response.u.data.shm_limits); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_MSG_LIMITS: + glibtop_get_msg_limits_l (&server, &response.u.data.msg_limits); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_SEM_LIMITS: + glibtop_get_sem_limits_l (&server, &response.u.data.sem_limits); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_PROCLIST: + ptr = glibtop_get_proclist_l (&server, &response.u.data.proclist); + do_output (s, &response, response.u.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, &response.u.data.proc_state, pid); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_PROC_UID: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_uid_l + (&server, &response.u.data.proc_uid, pid); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_PROC_MEM: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_mem_l + (&server, &response.u.data.proc_mem, pid); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_PROC_TIME: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_time_l + (&server, &response.u.data.proc_time, pid); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_PROC_SIGNAL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_signal_l + (&server, &response.u.data.proc_signal, pid); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_PROC_KERNEL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_kernel_l + (&server, &response.u.data.proc_kernel, pid); + do_output (s, &response, 0, NULL); + break; + case GLIBTOP_CMND_PROC_SEGMENT: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_segment_l + (&server, &response.u.data.proc_segment, pid); + do_output (s, &response, 0, NULL); + break; + } + } } From 8b025ff2c27380b1b881fec354be99e6efa6e897 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 12:31:40 +0000 Subject: [PATCH 0148/2539] Removed. 1998-06-18 Martin Baulig * lib/gnuclient.c: Removed. --- lib/Makefile.am | 5 --- lib/gnuclient.c | 94 ------------------------------------------------- 2 files changed, 99 deletions(-) delete mode 100644 lib/gnuclient.c diff --git a/lib/Makefile.am b/lib/Makefile.am index c2835361..1e9e7c28 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -20,8 +20,3 @@ EXTRA_DIST = lib.awk CLEANFILES = lib.c -bin_PROGRAMS = gnuclient -gnuclient_LDADD = $(top_builddir)/sysdeps/common/libgtop_common.la \ - $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ - @INTLLIBS@ @LIBSUPPORT@ @X_LIBS@ -lXau -gnuclient_LDFLAGS = -static diff --git a/lib/gnuclient.c b/lib/gnuclient.c deleted file mode 100644 index 122cc468..00000000 --- a/lib/gnuclient.c +++ /dev/null @@ -1,94 +0,0 @@ -/* -*-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 , - * Darrell Kindred and Arup Mukherjee . - * GNUATTACH support added by Ben Wing . - * 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 - -#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) -#else /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */ - -int -main (int argc, char *argv[]) -{ - int s; /* socket / msqid to server */ - int connect_type; /* CONN_UNIX, CONN_INTERNET, or CONN_IPC */ -#ifdef INTERNET_DOMAIN_SOCKETS - char thishost [HOSTNAMSZ]; /* this hostname */ -#endif /* INTERNET_DOMAIN_SOCKETS */ -#ifdef SYSV_IPC - struct msgbuf *msgp; /* message */ -#endif /* SYSV_IPC */ - - glibtop_init (); - - connect_type = glibtop_make_connection (NULL, (u_short) 0, &s); - -#ifdef INTERNET_DOMAIN_SOCKETS - if (connect_type == (int) CONN_INTERNET) - { - gethostname (thishost, HOSTNAMSZ); - } -#endif /* INTERNET_DOMAIN_SOCKETS */ - -#ifdef SYSV_IPC - if ((msgp = (struct msgbuf *) - malloc (sizeof *msgp + GSERV_BUFSZ)) == NULL) - glibtop_error_io ("not enough memory for message buffer"); - - msgp->mtext[0] = '\0'; /* ready for later strcats */ -#endif /* SYSV_IPC */ - - raise (SIGSTOP); - -#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 */ - - return 0; -} /* main */ - -#endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */ From 81c75477f40b716197ffb3a7af2e6cf28b25185b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 13:06:40 +0000 Subject: [PATCH 0149/2539] New function. 1998-06-18 Martin Baulig * lib/xmalloc.c (glibtop_strdup_r): New function. --- ChangeLog | 4 ++++ include/glibtop/xmalloc.h | 2 ++ sysdeps/common/xmalloc.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 596cd3ec..6b0cd7f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 1998-06-18 Martin Baulig + * lib/xmalloc.c (glibtop_strdup_r): New function. + + * lib/gnuclient.c: Removed. + * lib/{command, write, read}.c: Changed client <-> server interface to make less system calls. diff --git a/include/glibtop/xmalloc.h b/include/glibtop/xmalloc.h index 5c2b5024..4a67212d 100644 --- a/include/glibtop/xmalloc.h +++ b/include/glibtop/xmalloc.h @@ -30,11 +30,13 @@ __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_strdup(p2) glibtop_strdup_r(glibtop_global_server, p1) #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 char *glibtop_strdup_r __P((glibtop *, const char *)); extern void glibtop_free_r __P((glibtop *, void *)); __END_DECLS diff --git a/sysdeps/common/xmalloc.c b/sysdeps/common/xmalloc.c index fec5b99f..54b48eaa 100644 --- a/sysdeps/common/xmalloc.c +++ b/sysdeps/common/xmalloc.c @@ -59,6 +59,12 @@ glibtop_realloc_r (glibtop *server, void *ptr, size_t size) return buf; } +char * +glibtop_strdup_r (glibtop *server, const char *string) +{ + return strcpy (glibtop_malloc_r (server, strlen (string) + 1), string); +} + void glibtop_free_r (glibtop *server, void *ptr) { From 3fcc477b2556c5df5452da75f3d78fa44719ec80 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 13:08:40 +0000 Subject: [PATCH 0150/2539] New field `server_port'. 1998-06-18 Martin Baulig * glibtop.h (_glibtop): New field `server_port'. --- ChangeLog | 2 ++ glibtop.h | 1 + 2 files changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6b0cd7f6..e9d9a3ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 1998-06-18 Martin Baulig + * glibtop.h (_glibtop): New field `server_port'. + * lib/xmalloc.c (glibtop_strdup_r): New function. * lib/gnuclient.c: Removed. diff --git a/glibtop.h b/glibtop.h index 6bb29447..2ac3a5ec 100644 --- a/glibtop.h +++ b/glibtop.h @@ -49,6 +49,7 @@ struct _glibtop 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 */ + unsigned long server_port; /* Port on which daemon is listening */ pid_t pid; /* PID of the server */ }; From 1b90ed4fcc3204d9737654491b9cd431a8b56c7a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 19:02:49 +0000 Subject: [PATCH 0151/2539] Reverted some stuff from 06-07-1998 since it was too buggy. 1998-06-18 Martin Baulig * sysdeps/linux/*.c: Reverted some stuff from 06-07-1998 since it was too buggy. --- sysdeps/linux/cpu.c | 21 +++--------- sysdeps/linux/loadavg.c | 19 +++-------- sysdeps/linux/mem.c | 19 +++-------- sysdeps/linux/prockernel.c | 38 +++++++--------------- sysdeps/linux/procmem.c | 65 +++++++++++++------------------------ sysdeps/linux/procsegment.c | 65 +++++++++++++------------------------ sysdeps/linux/procsignal.c | 38 +++++++--------------- sysdeps/linux/procstate.c | 9 ----- sysdeps/linux/proctime.c | 38 +++++++--------------- sysdeps/linux/procuid.c | 65 +++++++++++++------------------------ sysdeps/linux/swap.c | 20 +++--------- 11 files changed, 117 insertions(+), 280 deletions(-) diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index 202a8476..b078d716 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -44,17 +44,10 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) buf->flags = _glibtop_sysdeps_cpu; -#ifdef GLIBTOP_CACHE_OPEN - fd = server->machine.fd_stat; -#endif - if (fd == 0) { - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); - } else { - lseek (fd, 0, SEEK_SET); - } + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); ret = read (fd, buffer, BUFSIZ); if (ret == -1) @@ -63,6 +56,7 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) tmp = strchr (buffer, '\n'); tmp = skip_token (tmp); /* "cpu" */ + buf->user = strtoul (tmp, &tmp, 10); buf->nice = strtoul (tmp, &tmp, 10); buf->sys = strtoul (tmp, &tmp, 10); @@ -71,10 +65,5 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) buf->total = buf->user + buf->nice + buf->sys + buf->idle; buf->frequency = 100; - -#ifdef GLIBTOP_CACHE_OPEN - server->machine.fd_stat = fd; -#else close (fd); -#endif } diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c index bb8b70e6..57717205 100644 --- a/sysdeps/linux/loadavg.c +++ b/sysdeps/linux/loadavg.c @@ -42,17 +42,10 @@ glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) buf->flags = _glibtop_sysdeps_loadavg; -#ifdef GLIBTOP_CACHE_OPEN - fd = server->machine.fd_loadavg; -#endif - if (fd == 0) { - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); - } else { - lseek (fd, 0, SEEK_SET); - } + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); ret = read (fd, buffer, BUFSIZ); if (ret == -1) @@ -63,9 +56,5 @@ glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) buf->loadavg [1] = strtod (tmp, &tmp); buf->loadavg [2] = strtod (tmp, &tmp); -#ifdef GLIBTOP_CACHE_OPEN - server->machine.fd_loadavg = fd; -#else close (fd); -#endif } diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index b53db6e2..b605a35d 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -45,17 +45,10 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) buf->flags = _glibtop_sysdeps_mem; -#ifdef GLIBTOP_CACHE_OPEN - fd = server->machine.fd_meminfo; -#endif - if (fd == 0) { - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); - } else { - lseek (fd, 0, SEEK_SET); - } + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); ret = read (fd, buffer, BUFSIZ); if (ret == -1) @@ -75,9 +68,5 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) buf->user = buf->total - buf->free - buf->shared - buf->buffer; -#ifdef GLIBTOP_CACHE_OPEN - server->machine.fd_meminfo = fd; -#else close (fd); -#endif } diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c index e9fc8eb9..7784eac3 100644 --- a/sysdeps/linux/prockernel.c +++ b/sysdeps/linux/prockernel.c @@ -47,36 +47,20 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) return; } - if (pid != server->machine.last_pid) { - server->machine.last_pid = pid; - server->machine.no_update = 0; - } - - if (!server->machine.no_update) { - server->machine.proc_status [0] = 0; - server->machine.proc_statm [0] = 0; - server->machine.proc_stat [0] = 0; - } - - if (server->machine.proc_stat [0]) { - strcpy (buffer, server->machine.proc_stat); - } else { - sprintf (input, "/proc/%d/stat", pid); + sprintf (input, "/proc/%d/stat", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_stat, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); /* This is from guile-utils/gtop/proc/readproc.c */ diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index fb03466e..f1108eb3 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -46,36 +46,20 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) return; } - if (pid != server->machine.last_pid) { - server->machine.last_pid = pid; - server->machine.no_update = 0; - } - - if (!server->machine.no_update) { - server->machine.proc_status [0] = 0; - server->machine.proc_statm [0] = 0; - server->machine.proc_stat [0] = 0; - } - - if (server->machine.proc_stat [0]) { - strcpy (buffer, server->machine.proc_stat); - } else { - sprintf (input, "/proc/%d/stat", pid); + sprintf (input, "/proc/%d/stat", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_stat, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); /* This is from guile-utils/gtop/proc/readproc.c */ @@ -88,25 +72,20 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) "%*d %*d %*d %*d %*d %*d %*u %*u %*d %lu " "%lu %lu", &buf->vsize, &buf->rss, &buf->rss_rlim); - if (server->machine.proc_statm [0]) { - strcpy (buffer, server->machine.proc_statm); - } else { - sprintf (input, "/proc/%d/statm", pid); + sprintf (input, "/proc/%d/statm", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_statm, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); sscanf (buffer, "%ld %ld %ld", &buf->size, &buf->resident, &buf->share); diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index 1ecefa2a..3c4ea965 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -48,36 +48,20 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, return; } - if (pid != server->machine.last_pid) { - server->machine.last_pid = pid; - server->machine.no_update = 0; - } - - if (!server->machine.no_update) { - server->machine.proc_status [0] = 0; - server->machine.proc_statm [0] = 0; - server->machine.proc_stat [0] = 0; - } - - if (server->machine.proc_stat [0]) { - strcpy (buffer, server->machine.proc_stat); - } else { - sprintf (input, "/proc/%d/stat", pid); + sprintf (input, "/proc/%d/stat", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_stat, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); /* This is from guile-utils/gtop/proc/readproc.c */ @@ -91,25 +75,20 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, "%*u %*u %lu %lu %lu", &buf->start_code, &buf->end_code, &buf->start_stack); - if (server->machine.proc_statm [0]) { - strcpy (buffer, server->machine.proc_statm); - } else { - sprintf (input, "/proc/%d/statm", pid); + sprintf (input, "/proc/%d/statm", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_statm, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); sscanf (buffer, "%*d %*d %*d %ld %ld %ld %ld", &buf->trs, &buf->lrs, &buf->drs, &buf->dt); diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c index 7ae451a1..14bdb353 100644 --- a/sysdeps/linux/procsignal.c +++ b/sysdeps/linux/procsignal.c @@ -45,36 +45,20 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) return; } - if (pid != server->machine.last_pid) { - server->machine.last_pid = pid; - server->machine.no_update = 0; - } - - if (!server->machine.no_update) { - server->machine.proc_status [0] = 0; - server->machine.proc_statm [0] = 0; - server->machine.proc_stat [0] = 0; - } - - if (server->machine.proc_stat [0]) { - strcpy (buffer, server->machine.proc_stat); - } else { - sprintf (input, "/proc/%d/stat", pid); + sprintf (input, "/proc/%d/stat", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_stat, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); /* This is from guile-utils/gtop/proc/readproc.c */ diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index 87656e1e..03432969 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -48,12 +48,6 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) return; } - server->machine.last_pid = pid; - server->machine.no_update = 0; - server->machine.proc_status [0] = 0; - server->machine.proc_statm [0] = 0; - server->machine.proc_stat [0] = 0; - sprintf (input, "/proc/%d/stat", pid); /* IMPORTANT NOTICE: For security reasons it is extremely important @@ -80,9 +74,6 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) buffer [nread] = 0; - server->machine.last_pid = pid; - strcpy (server->machine.proc_stat, buffer); - /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index 949deb2a..0d740bf0 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -47,36 +47,20 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) return; } - if (pid != server->machine.last_pid) { - server->machine.last_pid = pid; - server->machine.no_update = 0; - } - - if (!server->machine.no_update) { - server->machine.proc_status [0] = 0; - server->machine.proc_statm [0] = 0; - server->machine.proc_stat [0] = 0; - } - - if (server->machine.proc_stat [0]) { - strcpy (buffer, server->machine.proc_stat); - } else { - sprintf (input, "/proc/%d/stat", pid); + sprintf (input, "/proc/%d/stat", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_stat, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); /* This is from guile-utils/gtop/proc/readproc.c */ diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c index 0c25bddd..ff2afb19 100644 --- a/sysdeps/linux/procuid.c +++ b/sysdeps/linux/procuid.c @@ -51,36 +51,20 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) return; } - if (pid != server->machine.last_pid) { - server->machine.last_pid = pid; - server->machine.no_update = 0; - } - - if (!server->machine.no_update) { - server->machine.proc_status [0] = 0; - server->machine.proc_statm [0] = 0; - server->machine.proc_stat [0] = 0; - } - - if (server->machine.proc_status [0]) { - strcpy (buffer, server->machine.proc_status); - } else { - sprintf (input, "/proc/%d/status", pid); + sprintf (input, "/proc/%d/status", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_status, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); /* Search substring 'Pid:' */ @@ -92,25 +76,20 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) "Gid: %u %u %*u %*u\n", &buf->pid, &buf->ppid, &buf->uid, &buf->euid, &buf->gid, &buf->egid); - if (server->machine.proc_stat [0]) { - strcpy (buffer, server->machine.proc_stat); - } else { - sprintf (input, "/proc/%d/stat", pid); + sprintf (input, "/proc/%d/stat", pid); - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); + fd = open (input, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + input, strerror (errno)); - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + nread = read (fd, buffer, BUFSIZ); + if (nread == -1) + glibtop_error_r (server, "read (%s): %s", + input, strerror (errno)); - buffer [nread] = 0; - strcpy (server->machine.proc_stat, buffer); - close (fd); - } + buffer [nread] = 0; + close (fd); /* This is from guile-utils/gtop/proc/readproc.c */ diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index 24d44c06..57f159dd 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -43,17 +43,10 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) buf->flags = _glibtop_sysdeps_swap; -#ifdef GLIBTOP_CACHE_OPEN - fd = server->machine.fd_meminfo; -#endif - if (fd == 0) { - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); - } else { - lseek (fd, 0, SEEK_SET); - } + fd = open (FILENAME, O_RDONLY); + if (fd == -1) + glibtop_error_r (server, "open (%s): %s", + FILENAME, strerror (errno)); ret = read (fd, buffer, BUFSIZ); if (ret == -1) @@ -64,13 +57,10 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) tmp = strchr (tmp+1, '\n'); tmp = skip_token (tmp); /* "Swap:" */ + buf->total = strtoul (tmp, &tmp, 10); buf->used = strtoul (tmp, &tmp, 10); buf->free = strtoul (tmp, &tmp, 10); -#ifdef GLIBTOP_CACHE_OPEN - server->machine.fd_meminfo = fd; -#else close (fd); -#endif } From 134ec106b3ee9e6f1eb9dab90a81839c50cb30c6 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 19:04:44 +0000 Subject: [PATCH 0152/2539] Did some more work on the daemon; many debug messages are in the code at the moment. --- src/daemon/gnuserv.c | 4 +- src/daemon/main.c | 147 ++++++++++++++++++++++--------------------- 2 files changed, 77 insertions(+), 74 deletions(-) diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index e5016e7d..86a2655b 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -42,7 +42,7 @@ static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !" #include #endif -extern void handle_socket_connection __P((int)); +extern void handle_socket_connection __P((glibtop *, int)); #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) main () @@ -663,7 +663,7 @@ handle_internet_request (int ls) fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr)); #endif - handle_socket_connection (s); + handle_socket_connection (&glibtop_global_server, s); close (s); diff --git a/src/daemon/main.c b/src/daemon/main.c index f0696f0d..54cfe444 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -38,13 +38,19 @@ #define GET_MAX_FDS() 256 #endif +#define _offset_union(p) ((char *) &response.u.p - (char *) &response) +#define _offset_data(p) _offset_union (data.p) + static void -do_output (int s, glibtop_response *response, size_t data_size, const void *data) +do_output (int s, glibtop_response *response, off_t offset, + size_t data_size, const void *data) { #ifdef REAL_DEBUG - fprintf (stderr, "Really writing %d bytes.\n", sizeof (glibtop_response)); + fprintf (stderr, "Really writing %d bytes at offset %d.\n", + sizeof (glibtop_response), offset); #endif + response->offset = offset; response->data_size = data_size; if (send (s, response, sizeof (glibtop_response), 0) < 0) @@ -60,155 +66,152 @@ do_output (int s, glibtop_response *response, size_t data_size, const void *data } } +static void +do_read (int s, void *ptr, size_t total_size) +{ + int nread; + size_t already_read = 0, remaining = total_size; + + while (already_read < total_size) { + nread = recv (s, ptr, remaining, 0); + + if (nread <= 0) { + glibtop_error_io ("recv"); + return; + } + + already_read += nread; + remaining -= nread; + (char *) ptr += nread; + + fprintf (stderr, "READ (%d): %d - %d - %d\n", + nread, already_read, remaining, total_size); + } +} + void -handle_socket_connection (int s) +handle_socket_connection (glibtop *server, int s) { pid_t pid; - int nread; - size_t size; char parameter [BUFSIZ]; struct timeval tv; glibtop_response response; glibtop_command cmnd; - glibtop server; void *ptr; tv.tv_sec = 5; tv.tv_usec = 0; while(1) { - nread = recv (s, &cmnd, sizeof (glibtop_command), 0); - - if (nread < 0) { - glibtop_warn_io ("recv"); - return; - } - - if (nread == 0) - return; - - if (nread != sizeof (glibtop_command)) - glibtop_warn ("Received %d bytes, but expected %d\n", - nread, sizeof (glibtop_command)); + do_read (s, &cmnd, sizeof (glibtop_command)); #ifdef REAL_DEBUG fprintf (stderr, "Received command %d from client.\n", cmnd.command); #endif - if (cmnd.size >= BUFSIZ) { + if (cmnd.data_size >= BUFSIZ) { glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd.size, BUFSIZ); return; } memset (parameter, 0, sizeof (parameter)); - if (cmnd.size) { + if (cmnd.data_size) { #ifdef REAL_DEBUG - fprintf (stderr, "Client has %d bytes of data.\n", cmnd.size); + fprintf (stderr, "Client has %d bytes of data.\n", cmnd.data_size); #endif - nread = recv (s, parameter, cmnd.size, 0); - - /* will return 0 if parent exits. */ - - if (nread < 0) { - glibtop_warn_io ("recv"); - return; - } - - if (nread == 0) - return; + do_read (s, parameter, cmnd.data_size); - if (nread != (int) cmnd.size) { - glibtop_warn ("Expected %d bytes but got %d", - cmnd.size, nread); - return; - } + } else if (cmnd.size) { + memcpy (parameter, cmnd.parameter, cmnd.size); } switch (cmnd.command) { case GLIBTOP_CMND_SYSDEPS: response.u.sysdeps.features = GLIBTOP_SYSDEPS_ALL; - do_output (s, &response, 0, NULL); + do_output (s, &response, _offset_union (sysdeps), 0, NULL); break; case GLIBTOP_CMND_CPU: - glibtop_get_cpu_l (&server, &response.u.data.cpu); - do_output (s, &response, 0, NULL); + glibtop_get_cpu_l (server, &response.u.data.cpu); + do_output (s, &response, _offset_data (cpu), 0, NULL); break; case GLIBTOP_CMND_MEM: - glibtop_get_mem_l (&server, &response.u.data.mem); - do_output (s, &response, 0, NULL); + glibtop_get_mem_l (server, &response.u.data.mem); + do_output (s, &response, _offset_data (mem), 0, NULL); break; case GLIBTOP_CMND_SWAP: - glibtop_get_swap_l (&server, &response.u.data.swap); - do_output (s, &response, 0, NULL); + glibtop_get_swap_l (server, &response.u.data.swap); + do_output (s, &response, _offset_data (swap), 0, NULL); break; case GLIBTOP_CMND_UPTIME: - glibtop_get_uptime_l (&server, &response.u.data.uptime); - do_output (s, &response, 0, NULL); + glibtop_get_uptime_l (server, &response.u.data.uptime); + do_output (s, &response, _offset_data (uptime), 0, NULL); break; case GLIBTOP_CMND_LOADAVG: - glibtop_get_loadavg_l (&server, &response.u.data.loadavg); - do_output (s, &response, 0, NULL); + glibtop_get_loadavg_l (server, &response.u.data.loadavg); + do_output (s, &response, _offset_data (loadavg), 0, NULL); break; case GLIBTOP_CMND_SHM_LIMITS: - glibtop_get_shm_limits_l (&server, &response.u.data.shm_limits); - do_output (s, &response, 0, NULL); + glibtop_get_shm_limits_l (server, &response.u.data.shm_limits); + do_output (s, &response, _offset_data (shm_limits), 0, NULL); break; case GLIBTOP_CMND_MSG_LIMITS: - glibtop_get_msg_limits_l (&server, &response.u.data.msg_limits); - do_output (s, &response, 0, NULL); + glibtop_get_msg_limits_l (server, &response.u.data.msg_limits); + do_output (s, &response, _offset_data (msg_limits), 0, NULL); break; case GLIBTOP_CMND_SEM_LIMITS: - glibtop_get_sem_limits_l (&server, &response.u.data.sem_limits); - do_output (s, &response, 0, NULL); + glibtop_get_sem_limits_l (server, &response.u.data.sem_limits); + do_output (s, &response, _offset_data (sem_limits), 0, NULL); break; case GLIBTOP_CMND_PROCLIST: - ptr = glibtop_get_proclist_l (&server, &response.u.data.proclist); - do_output (s, &response, response.u.data.proclist.total, ptr); - glibtop_free_r (&server, ptr); + ptr = glibtop_get_proclist_l (server, &response.u.data.proclist); + do_output (s, &response, _offset_data (proclist), + response.u.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, &response.u.data.proc_state, pid); - do_output (s, &response, 0, NULL); + (server, &response.u.data.proc_state, pid); + do_output (s, &response, _offset_data (proc_state), 0, NULL); break; case GLIBTOP_CMND_PROC_UID: + pid = 1; memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_uid_l - (&server, &response.u.data.proc_uid, pid); - do_output (s, &response, 0, NULL); + (server, &response.u.data.proc_uid, pid); + do_output (s, &response, _offset_data (proc_uid), 0, NULL); break; case GLIBTOP_CMND_PROC_MEM: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_mem_l - (&server, &response.u.data.proc_mem, pid); - do_output (s, &response, 0, NULL); + (server, &response.u.data.proc_mem, pid); + do_output (s, &response, _offset_data (proc_mem), 0, NULL); break; case GLIBTOP_CMND_PROC_TIME: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_time_l - (&server, &response.u.data.proc_time, pid); - do_output (s, &response, 0, NULL); + (server, &response.u.data.proc_time, pid); + do_output (s, &response, _offset_data (proc_time), 0, NULL); break; case GLIBTOP_CMND_PROC_SIGNAL: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_signal_l - (&server, &response.u.data.proc_signal, pid); - do_output (s, &response, 0, NULL); + (server, &response.u.data.proc_signal, pid); + do_output (s, &response, _offset_data (proc_signal), 0, NULL); break; case GLIBTOP_CMND_PROC_KERNEL: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_kernel_l - (&server, &response.u.data.proc_kernel, pid); - do_output (s, &response, 0, NULL); + (server, &response.u.data.proc_kernel, pid); + do_output (s, &response, _offset_data (proc_kernel), 0, NULL); break; case GLIBTOP_CMND_PROC_SEGMENT: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_segment_l - (&server, &response.u.data.proc_segment, pid); - do_output (s, &response, 0, NULL); + (server, &response.u.data.proc_segment, pid); + do_output (s, &response, _offset_data (proc_segment), 0, NULL); break; } } From b54a5d2dfdce076438da84046b4d0589cbaece36 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 19:04:47 +0000 Subject: [PATCH 0153/2539] *** empty log message *** --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index e9d9a3ab..a50c2e79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 1998-06-18 Martin Baulig + * sysdeps/linux/*.c: Reverted some stuff from 06-07-1998 + since it was too buggy. + * glibtop.h (_glibtop): New field `server_port'. * lib/xmalloc.c (glibtop_strdup_r): New function. From 71187a5e519bd03926c933c57e307f29b07e77c6 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 18 Jun 1998 19:06:55 +0000 Subject: [PATCH 0154/2539] Some more daemon stuff. --- examples/first.c | 348 +++++++++++++++++++------------------- include/glibtop/command.h | 3 +- lib/command.c | 31 ++-- lib/open.c | 195 ++++++++------------- lib/read.c | 29 +++- 5 files changed, 297 insertions(+), 309 deletions(-) diff --git a/examples/first.c b/examples/first.c index d93e8f3b..d6031e9a 100644 --- a/examples/first.c +++ b/examples/first.c @@ -52,93 +52,93 @@ main (int argc, char *argv []) 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); + printf ("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); 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); + printf ("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); 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); + printf ("Swap (0x%08lx): %lu, %lu, %lu\n", data.swap.flags, + data.swap.total, data.swap.used, data.swap.free); 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); + printf ("Uptime (0x%08lx): %f, %f\n", data.uptime.flags, + data.uptime.uptime, data.uptime.idletime); 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]); + printf ("Loadavg (0x%08lx): %f, %f, %f\n", data.loadavg.flags, + data.loadavg.loadavg [0], data.loadavg.loadavg [1], + data.loadavg.loadavg [2]); 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); + printf ("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); 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, - data.msg_limits.msgmap, data.msg_limits.msgmax, - data.msg_limits.msgmnb, data.msg_limits.msgmni, - data.msg_limits.msgssz, data.msg_limits.msgtql); + printf ("Msg Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld, %ld, %ld\n", + data.msg_limits.flags, data.msg_limits.msgpool, + data.msg_limits.msgmap, data.msg_limits.msgmax, + data.msg_limits.msgmnb, data.msg_limits.msgmni, + data.msg_limits.msgssz, data.msg_limits.msgtql); 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", - data.sem_limits.flags, data.sem_limits.semmap, - data.sem_limits.semmni, data.sem_limits.semmns, - data.sem_limits.semmnu, data.sem_limits.semmsl, - data.sem_limits.semopm, data.sem_limits.semume, - data.sem_limits.semusz, data.sem_limits.semvmx, - data.sem_limits.semaem); + printf ("Sem Limits (0x%08lx): " + "%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n", + data.sem_limits.flags, data.sem_limits.semmap, + data.sem_limits.semmni, data.sem_limits.semmns, + data.sem_limits.semmnu, data.sem_limits.semmsl, + data.sem_limits.semopm, data.sem_limits.semume, + data.sem_limits.semusz, data.sem_limits.semvmx, + data.sem_limits.semaem); - fprintf (stderr, "\n"); + printf ("\n"); glibtop_get_sysdeps (&sysdeps); - fprintf (stderr, "Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " - "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", - sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap, - sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits, - sysdeps.msg_limits, sysdeps.sem_limits, - sysdeps.proclist, sysdeps.proc_state, - sysdeps.proc_uid, sysdeps.proc_mem, - sysdeps.proc_time, sysdeps.proc_signal, - sysdeps.proc_kernel, sysdeps.proc_segment); + printf ("Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " + "%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", + sysdeps.flags, sysdeps.cpu, sysdeps.mem, sysdeps.swap, + sysdeps.uptime, sysdeps.loadavg, sysdeps.shm_limits, + sysdeps.msg_limits, sysdeps.sem_limits, + sysdeps.proclist, sysdeps.proc_state, + sysdeps.proc_uid, sysdeps.proc_mem, + sysdeps.proc_time, sysdeps.proc_signal, + sysdeps.proc_kernel, sysdeps.proc_segment); - fprintf (stderr, "\n"); + printf ("\n"); ptr = glibtop_get_proclist (&data.proclist); - fprintf (stderr, "Proclist (0x%08lx): %ld, %ld, %ld\n", - data.proclist.flags, data.proclist.number, - data.proclist.size, data.proclist.total); + printf ("Proclist (0x%08lx): %ld, %ld, %ld\n", + data.proclist.flags, data.proclist.number, + data.proclist.size, data.proclist.total); if (ptr) { - fprintf (stderr, "\nProcess: "); + printf ("\nProcess: "); for (i = 0; i < data.proclist.number; i++) - fprintf (stderr, "%s%u", i ? ", " : "", ptr [i]); - fprintf (stderr, "\n"); + printf ("%s%u", i ? ", " : "", ptr [i]); + printf ("\n"); } glibtop_free (ptr); @@ -146,218 +146,218 @@ main (int argc, char *argv []) pid = getpid (); ppid = getppid (); - fprintf (stderr, "\n"); + printf ("\n"); 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); + printf ("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); 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", - pid, data.proc_uid.flags, data.proc_uid.uid, - data.proc_uid.euid, data.proc_uid.gid, - data.proc_uid.egid, data.proc_uid.pid, - data.proc_uid.ppid, data.proc_uid.pgrp, - data.proc_uid.session, data.proc_uid.tty, - data.proc_uid.tpgid, data.proc_uid.priority, - data.proc_uid.nice); + printf ("Proc_Uid PID %5u (0x%08lx): " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + pid, data.proc_uid.flags, data.proc_uid.uid, + data.proc_uid.euid, data.proc_uid.gid, + data.proc_uid.egid, data.proc_uid.pid, + data.proc_uid.ppid, data.proc_uid.pgrp, + data.proc_uid.session, data.proc_uid.tty, + data.proc_uid.tpgid, data.proc_uid.priority, + data.proc_uid.nice); 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, - data.proc_mem.size, data.proc_mem.vsize, - data.proc_mem.resident, data.proc_mem.share, - data.proc_mem.rss, data.proc_mem.rss_rlim); + printf ("Proc_Mem PID %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld\n", pid, data.proc_mem.flags, + data.proc_mem.size, data.proc_mem.vsize, + data.proc_mem.resident, data.proc_mem.share, + data.proc_mem.rss, data.proc_mem.rss_rlim); 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, - data.proc_time.start_time, data.proc_time.utime, - data.proc_time.stime, data.proc_time.cutime, - data.proc_time.cstime, data.proc_time.timeout, - data.proc_time.it_real_value); + printf ("Proc_Time PID %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld %ld\n", pid, data.proc_time.flags, + data.proc_time.start_time, data.proc_time.utime, + data.proc_time.stime, data.proc_time.cutime, + data.proc_time.cstime, data.proc_time.timeout, + data.proc_time.it_real_value); 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); + printf ("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); 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, - data.proc_kernel.flags, data.proc_kernel.k_flags, - data.proc_kernel.min_flt, data.proc_kernel.maj_flt, - data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, - data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, - data.proc_kernel.wchan); + printf ("Proc_Kernel PID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", pid, + data.proc_kernel.flags, data.proc_kernel.k_flags, + data.proc_kernel.min_flt, data.proc_kernel.maj_flt, + data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, + data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, + data.proc_kernel.wchan); 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, - data.proc_segment.trs, data.proc_segment.lrs, - data.proc_segment.drs, data.proc_segment.dt, - data.proc_segment.start_code, data.proc_segment.end_code, - data.proc_segment.start_stack); + printf ("Proc_Segment PID %5u (0x%08lx): " + "%ld %ld %ld %ld %lu %lu %lu\n", pid, data.proc_segment.flags, + data.proc_segment.trs, data.proc_segment.lrs, + data.proc_segment.drs, data.proc_segment.dt, + data.proc_segment.start_code, data.proc_segment.end_code, + data.proc_segment.start_stack); - fprintf (stderr, "\n"); + printf ("\n"); 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); + printf ("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); 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", - ppid, data.proc_uid.flags, data.proc_uid.uid, - data.proc_uid.euid, data.proc_uid.gid, - data.proc_uid.egid, data.proc_uid.pid, - data.proc_uid.ppid, data.proc_uid.pgrp, - data.proc_uid.session, data.proc_uid.tty, - data.proc_uid.tpgid, data.proc_uid.priority, - data.proc_uid.nice); + printf ("Proc_Uid PPID %5u (0x%08lx): " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + ppid, data.proc_uid.flags, data.proc_uid.uid, + data.proc_uid.euid, data.proc_uid.gid, + data.proc_uid.egid, data.proc_uid.pid, + data.proc_uid.ppid, data.proc_uid.pgrp, + data.proc_uid.session, data.proc_uid.tty, + data.proc_uid.tpgid, data.proc_uid.priority, + data.proc_uid.nice); 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, - data.proc_mem.size, data.proc_mem.vsize, - data.proc_mem.resident, data.proc_mem.share, - data.proc_mem.rss, data.proc_mem.rss_rlim); + printf ("Proc_Mem PPID %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld\n", ppid, data.proc_mem.flags, + data.proc_mem.size, data.proc_mem.vsize, + data.proc_mem.resident, data.proc_mem.share, + data.proc_mem.rss, data.proc_mem.rss_rlim); 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, - data.proc_time.start_time, data.proc_time.utime, - data.proc_time.stime, data.proc_time.cutime, - data.proc_time.cstime, data.proc_time.timeout, - data.proc_time.it_real_value); + printf ("Proc_Time PPID %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld %ld\n", ppid, data.proc_time.flags, + data.proc_time.start_time, data.proc_time.utime, + data.proc_time.stime, data.proc_time.cutime, + data.proc_time.cstime, data.proc_time.timeout, + data.proc_time.it_real_value); 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); + printf ("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); 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, - data.proc_kernel.flags, data.proc_kernel.k_flags, - data.proc_kernel.min_flt, data.proc_kernel.maj_flt, - data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, - data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, - data.proc_kernel.wchan); + printf ("Proc_Kernel PPID %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", ppid, + data.proc_kernel.flags, data.proc_kernel.k_flags, + data.proc_kernel.min_flt, data.proc_kernel.maj_flt, + data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, + data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, + data.proc_kernel.wchan); 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, - data.proc_segment.trs, data.proc_segment.lrs, - data.proc_segment.drs, data.proc_segment.dt, - data.proc_segment.start_code, data.proc_segment.end_code, - data.proc_segment.start_stack); + printf ("Proc_Segment PPID %5u (0x%08lx): " + "%ld %ld %ld %ld %lu %lu %lu\n", ppid, data.proc_segment.flags, + data.proc_segment.trs, data.proc_segment.lrs, + data.proc_segment.drs, data.proc_segment.dt, + data.proc_segment.start_code, data.proc_segment.end_code, + data.proc_segment.start_stack); - fprintf (stderr, "\n"); + printf ("\n"); 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); + printf ("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); 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", - 1, data.proc_uid.flags, data.proc_uid.uid, - data.proc_uid.euid, data.proc_uid.gid, - data.proc_uid.egid, data.proc_uid.pid, - data.proc_uid.ppid, data.proc_uid.pgrp, - data.proc_uid.session, data.proc_uid.tty, - data.proc_uid.tpgid, data.proc_uid.priority, - data.proc_uid.nice); + printf ("Proc_Uid INIT %5u (0x%08lx): " + "%d %d %d %d %d %d %d %d %d %d %d %d\n", + 1, data.proc_uid.flags, data.proc_uid.uid, + data.proc_uid.euid, data.proc_uid.gid, + data.proc_uid.egid, data.proc_uid.pid, + data.proc_uid.ppid, data.proc_uid.pgrp, + data.proc_uid.session, data.proc_uid.tty, + data.proc_uid.tpgid, data.proc_uid.priority, + data.proc_uid.nice); 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, - data.proc_mem.size, data.proc_mem.vsize, - data.proc_mem.resident, data.proc_mem.share, - data.proc_mem.rss, data.proc_mem.rss_rlim); + printf ("Proc_Mem INIT %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld\n", 1, data.proc_mem.flags, + data.proc_mem.size, data.proc_mem.vsize, + data.proc_mem.resident, data.proc_mem.share, + data.proc_mem.rss, data.proc_mem.rss_rlim); 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, - data.proc_time.start_time, data.proc_time.utime, - data.proc_time.stime, data.proc_time.cutime, - data.proc_time.cstime, data.proc_time.timeout, - data.proc_time.it_real_value); + printf ("Proc_Time INIT %5u (0x%08lx): " + "%ld %ld %ld %ld %ld %ld %ld\n", 1, data.proc_time.flags, + data.proc_time.start_time, data.proc_time.utime, + data.proc_time.stime, data.proc_time.cutime, + data.proc_time.cstime, data.proc_time.timeout, + data.proc_time.it_real_value); 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); + printf ("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); 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, - data.proc_kernel.flags, data.proc_kernel.k_flags, - data.proc_kernel.min_flt, data.proc_kernel.maj_flt, - data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, - data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, - data.proc_kernel.wchan); + printf ("Proc_Kernel INIT %5u (0x%08lx): " + "%lu %lu %lu %lu %lu %lu %lu %lu\n", 1, + data.proc_kernel.flags, data.proc_kernel.k_flags, + data.proc_kernel.min_flt, data.proc_kernel.maj_flt, + data.proc_kernel.cmin_flt, data.proc_kernel.cmaj_flt, + data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, + data.proc_kernel.wchan); 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, - data.proc_segment.trs, data.proc_segment.lrs, - data.proc_segment.drs, data.proc_segment.dt, - data.proc_segment.start_code, data.proc_segment.end_code, - data.proc_segment.start_stack); + printf ("Proc_Segment INIT %5u (0x%08lx): " + "%ld %ld %ld %ld %lu %lu %lu\n", 1, data.proc_segment.flags, + data.proc_segment.trs, data.proc_segment.lrs, + data.proc_segment.drs, data.proc_segment.dt, + data.proc_segment.start_code, data.proc_segment.end_code, + data.proc_segment.start_stack); exit (0); } diff --git a/include/glibtop/command.h b/include/glibtop/command.h index 259bdec0..1987e5d1 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -71,7 +71,8 @@ union _glibtop_response_union struct _glibtop_response { - size_t data_size; + off_t offset; + size_t size, data_size; union _glibtop_response_union u; }; diff --git a/lib/command.c b/lib/command.c index b7f6ccd4..abef8bcd 100644 --- a/lib/command.c +++ b/lib/command.c @@ -32,7 +32,6 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size, void *send_ { glibtop_command cmnd; glibtop_response response; - void *ptr; glibtop_init_r (&server, 0, 0); @@ -47,24 +46,34 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size, void *send_ * of two. */ #ifdef DEBUG - fprintf (stderr, "COMMAND: send_size = %d; command = %d; sizeof (cmnd) = %d\n", - send_size, command, sizeof (glibtop_command)); + // fprintf (stderr, "COMMAND: send_size = %d; command = %d; sizeof (cmnd) = %d\n", + // send_size, command, sizeof (glibtop_command)); #endif - - if (send_size <= _GLIBTOP_PARAM_SIZE) + if (send_size <= _GLIBTOP_PARAM_SIZE) { memcpy (cmnd.parameter, send_buf, send_size); - else cmnd.size = send_size; + } else { + cmnd.data_size = send_size; + } glibtop_write_l (server, sizeof (glibtop_command), &cmnd); - glibtop_write_l (server, send_size, send_buf); + // glibtop_write_l (server, cmnd.data_size, send_buf); glibtop_read_l (server, sizeof (glibtop_response), &response); - /* glibtop_read_l (server, recv_size, recv_buf); */ - - /* ptr = glibtop_read_data_l (server); */ - + fprintf (stderr, "RESPONSE: %d - %d\n", response.offset, response.data_size); + + if (recv_buf) + memcpy (recv_buf, ((char *) &response) + response.offset, recv_size); + + if (response.data_size) { + void *ptr = glibtop_malloc_r (server, response.data_size); + + glibtop_read_l (server, response.data_size, ptr); + + return ptr; + } + return NULL; } diff --git a/lib/open.c b/lib/open.c index 2411b1c0..fccf3635 100644 --- a/lib/open.c +++ b/lib/open.c @@ -33,144 +33,97 @@ void 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; + char version [BUFSIZ], buffer [BUFSIZ], *temp, *temp2; glibtop_sysdeps sysdeps; - int connect_type; + int connect_type, ret; memset (server, 0, sizeof (glibtop)); server->name = program_name; /* Is the user allowed to override the server ? */ + + if (flags & GLIBTOP_OPEN_NO_OVERRIDE) + return; - if ((flags & GLIBTOP_OPEN_NO_OVERRIDE) == 0) { - connect_type = glibtop_make_connection - (NULL, (u_short) 0, &server->socket); + /* Try to get data from environment. */ + + temp = getenv ("LIBGTOP_SERVER") ? + getenv ("LIBGTOP_SERVER") : GTOP_SERVER; + + server->server_command = glibtop_strdup_r (server, temp); + + temp = getenv ("LIBGTOP_RSH") ? + getenv ("LIBGTOP_RSH") : "rsh"; + + server->server_rsh = glibtop_strdup_r (server, temp); + + /* If the first character of 'server_command' is a colon, + * the first field is the method to connect to the server. */ + + if (server->server_command [0] == ':') { -#ifdef INTERNET_DOMAIN_SOCKETS - if (connect_type == (int) CONN_INTERNET) { - fprintf (stderr, "Calling GLITOP_CMND_SYSDEPS ...\n"); + /* Everything up to the next colon is the method. */ - glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL, - sizeof (glibtop_sysdeps), &sysdeps); + temp = strstr (server->server_command+1, ":"); + if (temp) *temp = 0; + + /* Dispatch method. */ - server->features = sysdeps.features; + if (!strcmp (server->server_command+1, "direct")) { + + /* Use sysdeps dir instead of connecting to server + * even if using the server would be required on + * the current system. */ + + return; - fprintf (stderr, "Features: %lu\n", server->features); + } else if (!strcmp (server->server_command+1, "inet")) { + + /* Connect to internet server. */ + + if (temp == NULL) { + server->server_host = glibtop_strdup_r + (server, "localhost"); + } else { + temp2 = strstr (temp+1, ":"); + if (temp2) *temp2 = 0; + + server->server_host = glibtop_strdup_r + (server, temp+1); + + temp = temp2; + } + + if (temp == NULL) { + server->server_port = DEFAULT_PORT; + } else { + temp2 = strstr (temp+1, ":"); + if (temp2) *temp2 = 0; + + ret = sscanf (temp+1, "%d", &server->server_port); + + if (ret != 1) + server->server_port = DEFAULT_PORT; + + temp = temp2 ? temp2 + 1 : temp2; + } + + fprintf (stderr, "Connecting to '%s' port %d.\n", + server->server_host, server->server_port); + + connect_type = glibtop_make_connection + (server->server_host, server->server_port, + &server->socket); + + server->features = -1; return; } -#endif /* INTERNET_DOMAIN_SOCKETS */ - - /* 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)); - - server->pid = fork (); - - if (server->pid < 0) { - 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); - - 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_l (server, strlen (version), buffer); - - if (memcmp (version, buffer, strlen (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); - + sizeof (glibtop_sysdeps), &sysdeps); + server->features = sysdeps.features; - - fprintf (stderr, "Features: %lu\n", server->features); } diff --git a/lib/read.c b/lib/read.c index 55fb922e..c9a0c565 100644 --- a/lib/read.c +++ b/lib/read.c @@ -23,10 +23,35 @@ /* Reads some data from server. */ +static void +do_read (int s, void *ptr, size_t total_size) +{ + int nread; + size_t already_read = 0, remaining = total_size; + + while (already_read < total_size) { + nread = recv (s, ptr, remaining, 0); + + if (nread == 0) { + close (s); + continue; + } + + if (nread <= 0) { + glibtop_error_io ("recv"); + return; + } + + already_read += nread; + remaining -= nread; + (char *) ptr += nread; + } +} + void glibtop_read_l (glibtop *server, size_t size, void *buf) { - int ret; + int ret = 0; glibtop_init_r (&server, 0, 0); @@ -35,7 +60,7 @@ glibtop_read_l (glibtop *server, size_t size, void *buf) #endif if (server->socket) { - ret = recv (server->socket, buf, size, 0); + do_read (server->socket, buf, size); } else { ret = read (server->input [0], buf, size); } From a76522a990c40724f06fc7122b21d72ba20e29ce Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 21 Jun 1998 22:24:18 +0000 Subject: [PATCH 0155/2539] Added perl interface. 1998-06-21 Martin Baulig * perl/*: Added perl interface. * sysdeps/linux/cpu.c: Bug fix. * include/glibtop/global.h: Only including guile header files within libgtop. * configure.in (LIGBTOP_LIBS): Added `-lgtop'. * Makefile.am: Creating `perl/Makefile.PL' from `perl/Makefile.PL.in' and `perl/Libgtop.xs' using `perl/perl.awk'. --- ChangeLog | 14 ++++++ Makefile.am | 27 ++++++++++++ configure.in | 2 +- include/glibtop/Makefile.am | 2 +- include/glibtop/global.h | 5 +++ perl/.cvsignore | 1 + perl/Changes | 5 +++ perl/Libgtop.pm | 26 +++++++++++ perl/MANIFEST | 8 ++++ perl/Makefile.PL.in | 10 +++++ perl/new.pl | 13 ++++++ perl/perl.awk | 86 +++++++++++++++++++++++++++++++++++++ perl/test.pl | 20 +++++++++ sysdeps/linux/cpu.c | 3 +- 14 files changed, 218 insertions(+), 4 deletions(-) create mode 100644 perl/.cvsignore create mode 100644 perl/Changes create mode 100644 perl/Libgtop.pm create mode 100644 perl/MANIFEST create mode 100644 perl/Makefile.PL.in create mode 100755 perl/new.pl create mode 100644 perl/perl.awk create mode 100644 perl/test.pl diff --git a/ChangeLog b/ChangeLog index a50c2e79..22fb4b80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +1998-06-21 Martin Baulig + + * perl/*: Added perl interface. + + * sysdeps/linux/cpu.c: Bug fix. + + * include/glibtop/global.h: Only including guile header files + within libgtop. + + * configure.in (LIGBTOP_LIBS): Added `-lgtop'. + + * Makefile.am: Creating `perl/Makefile.PL' from `perl/Makefile.PL.in' + and `perl/Libgtop.xs' using `perl/perl.awk'. + 1998-06-18 Martin Baulig * sysdeps/linux/*.c: Reverted some stuff from 06-07-1998 diff --git a/Makefile.am b/Makefile.am index 57ae4886..a9a51430 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,6 +22,9 @@ release: confexecdir=$(libdir) confexec_DATA = $(top_builddir)/libgtopConf.sh +noinst_DATA = $(top_builddir)/perl/Makefile.PL \ + $(top_builddir)/perl/Libgtop.xs + ## to automatically rebuild aclocal.m4 if any of the macros in ## `macros/' change @MAINT@include macros/macros.dep @@ -51,3 +54,27 @@ libgtopConf.sh: libgtopConf.sh.in Makefile -e 's,\@libgtop_want_examples\@,$(libgtop_want_examples),g' \ < $(srcdir)/libgtopConf.sh.in > libgtopConf.tmp \ && mv libgtopConf.tmp libgtopConf.sh + +perl/Makefile.PL: perl/Makefile.PL.in Makefile +## Use sed and then mv to avoid problems if the user interrupts. + sed -e 's,\@LIBGTOP_LIBDIR\@,$(libdir),g' \ + -e 's,\@LIBGTOP_INCLUDEDIR\@,$(includedir),g' \ + -e 's,\@LIBGTOP_LIBS\@,$(LIBGTOP_LIBS),g' \ + -e 's,\@LIBGTOP_INCS\@,$(LIBGTOP_INCS),g' \ + -e 's,\@LIBGTOP_GUILE_LIBS\@,$(LIBGTOP_GUILE_LIBS),g' \ + -e 's,\@LIBGTOP_GUILE_INCS\@,$(LIBGTOP_GUILE_INCS),g' \ + -e 's,\@LIBGTOP_BINDIR\@,$(LIBGTOP_BINDIR),g' \ + -e 's,\@LIBGTOP_SERVER\@,$(LIBGTOP_SERVER),g' \ + -e 's,\@libgtop_sysdeps_dir\@,$(libgtop_sysdeps_dir),g' \ + -e 's,\@libgtop_need_server\@,$(libgtop_need_server),g' \ + -e 's,\@libgtop_use_machine_h\@,$(libgtop_use_machine_h),g' \ + -e 's,\@libgtop_guile_found\@,$(libgtop_guile_found),g' \ + -e 's,\@libgtop_want_names\@,$(libgtop_want_names),g' \ + -e 's,\@libgtop_want_guile_names\@,$(libgtop_want_guile_names),g' \ + -e 's,\@libgtop_want_examples\@,$(libgtop_want_examples),g' \ + < $(srcdir)/perl/Makefile.PL.in > perl/Makefile.tmp \ + && mv perl/Makefile.tmp perl/Makefile.PL + +perl/Libgtop.xs: perl/perl.awk $(top_builddir)/config.h $(top_srcdir)/features.def + $(AWK) -f $(top_srcdir)/perl/perl.awk < $(top_srcdir)/features.def > perl/lgt-t + mv perl/lgt_t perl/Libgtop.xs diff --git a/configure.in b/configure.in index 95793460..ef605d8e 100644 --- a/configure.in +++ b/configure.in @@ -154,7 +154,7 @@ AC_SUBST(LIBSUPPORT) AC_SUBST(SUPPORTINCS) dnl These definitions are expanded in make. -LIBGTOP_LIBS='-L$(libdir)' +LIBGTOP_LIBS='-L$(libdir) -lgtop' LIBGTOP_INCS='-I$(includedir)' LIBGTOP_GUILE_LIBS="$LIBGTOP_LIBS" LIBGTOP_GUILE_INCS="$LIBGTOP_INCS" diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am index 1a5941fc..53ee5c51 100644 --- a/include/glibtop/Makefile.am +++ b/include/glibtop/Makefile.am @@ -5,4 +5,4 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \ proctime.h shm_limits.h version.h cpu.h msg_limits.h \ procmem.h procuid.h swap.h write.h error.h open.h \ procsegment.h read.h sysdeps.h xmalloc.h global.h \ - output.h procsignal.h read_data.h union.h + output.h procsignal.h read_data.h union.h types.h diff --git a/include/glibtop/global.h b/include/glibtop/global.h index 1ad60784..46bc9538 100644 --- a/include/glibtop/global.h +++ b/include/glibtop/global.h @@ -62,6 +62,11 @@ # endif #endif +#ifdef WITHOUT_GUILE +#undef HAVE_GUILE +#undef GLIBTOP_GUILE_NAMES +#endif + #ifdef HAVE_GUILE #include #endif diff --git a/perl/.cvsignore b/perl/.cvsignore new file mode 100644 index 00000000..ec86ab39 --- /dev/null +++ b/perl/.cvsignore @@ -0,0 +1 @@ +Libgtop.xs Makefile blib pm_to_blib Libgtop.c Libgtop.bs Makefile.PL diff --git a/perl/Changes b/perl/Changes new file mode 100644 index 00000000..59504ce4 --- /dev/null +++ b/perl/Changes @@ -0,0 +1,5 @@ +Revision history for Perl extension Libgtop. + +0.01 Sun Jun 21 21:00:59 1998 + - original version; created by h2xs 1.18 + diff --git a/perl/Libgtop.pm b/perl/Libgtop.pm new file mode 100644 index 00000000..e146b93c --- /dev/null +++ b/perl/Libgtop.pm @@ -0,0 +1,26 @@ +package Libgtop; + +use strict; +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); + +require Exporter; +require DynaLoader; +require AutoLoader; + +@ISA = qw(Exporter DynaLoader); +# Items to export into callers namespace by default. Note: do not export +# names by default without a very good reason. Use EXPORT_OK instead. +# Do not simply export all your public functions/methods/constants. +@EXPORT = qw( + +); +$VERSION = '0.01'; + +bootstrap Libgtop $VERSION; + +# Preloaded methods go here. + +# Autoload methods go after __END__, and are processed by the autosplit program. + +1; +__END__ diff --git a/perl/MANIFEST b/perl/MANIFEST new file mode 100644 index 00000000..845b5f4d --- /dev/null +++ b/perl/MANIFEST @@ -0,0 +1,8 @@ +.cvsignore +Changes +Libgtop.pm +MANIFEST +Makefile.PL.in +new.pl +perl.awk +test.pl diff --git a/perl/Makefile.PL.in b/perl/Makefile.PL.in new file mode 100644 index 00000000..1365c98d --- /dev/null +++ b/perl/Makefile.PL.in @@ -0,0 +1,10 @@ +# -*-cperl-*- +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile('NAME' => 'Libgtop', + 'VERSION_FROM' => 'Libgtop.pm', + 'LIBS' => ['@LIBGTOP_GUILE_LIBS@'], + 'DEFINE' => '', + 'INC' => '@LIBGTOP_GUILE_INCS@', + ); diff --git a/perl/new.pl b/perl/new.pl new file mode 100755 index 00000000..b6e0faca --- /dev/null +++ b/perl/new.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl -w + +require 5.004; + +use blib; +use strict; +use Libgtop; + +print "CPU Usage: ".join (':', Libgtop::cpu)."\n"; +print "Memory Usage: ".join (':', Libgtop::mem)."\n"; +print "Swap Usage: ".join (':', Libgtop::swap)."\n"; + + diff --git a/perl/perl.awk b/perl/perl.awk new file mode 100644 index 00000000..1b3bc513 --- /dev/null +++ b/perl/perl.awk @@ -0,0 +1,86 @@ +BEGIN { + print "/* Libgtop.xs */"; + print "/* This is a generated file. Please modify `perl.awk' */"; + print ""; + + print "#ifdef __cplusplus"; + print "extern \"C\" {"; + print "#endif"; + print "#include \"EXTERN.h\""; + print "#include \"perl.h\""; + print "#include \"XSUB.h\""; + print "#ifdef __cplusplus"; + print "}"; + print "#endif"; + print ""; + print "#undef PACKAGE"; + print ""; + print "#include "; + print "#include "; + print ""; + print "MODULE = Libgtop\t\tPACKAGE = Libgtop"; + print ""; + + convert["long"] = "newSViv"; + convert["ulong"] = "newSViv"; + convert["double"] = "newSVnv"; +} + +/^(\w+)/ { + feature = $1; + + print "void"; + if (feature ~ /^proc_/) { + print feature"(pid)"; + print "\tunsigned\tpid;"; + } else { + print feature"()"; + } + + print "PREINIT:"; + print "\tglibtop_"feature" "feature";"; + + if (feature ~ /^proclist/) { + print "\tunsigned i, *ptr;"; + print "PPCODE:"; + print "\tptr = glibtop_get_proclist (&proclist);"; + print ""; + print "\tif (ptr) {"; + print "\t\tfor (i = 0; i < proclist.number; i++)"; + print "\t\t\tXPUSHs (sv_2mortal (newSViv (ptr [i])));"; + print "\t}"; + print ""; + print "\tglibtop_free (ptr);"; + } else { + print "PPCODE:"; + if (feature ~ /^proc_/) { + print "\tglibtop_get_"feature" (&"feature", pid);"; + } else { + print "\tglibtop_get_"feature" (&"feature");"; + } + print ""; + + 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++) { + if (type ~ /^str$/) { + print "\tXPUSHs (sv_2mortal (newSVpv ("$1"."fields[field]", 0)));"; + } else { + if (type ~ /^char$/) { + print "\tXPUSHs (sv_2mortal (newSVpv (&"$1"."fields[field]", 1)));"; + } else { + print "\tXPUSHs (sv_2mortal ("convert[type]" ("$1"."fields[field]")));"; + } + } + } + } + } + + print ""; +} + diff --git a/perl/test.pl b/perl/test.pl new file mode 100644 index 00000000..1406ebc0 --- /dev/null +++ b/perl/test.pl @@ -0,0 +1,20 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. + +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..1\n"; } +END {print "not ok 1\n" unless $loaded;} +use Libgtop; +$loaded = 1; +print "ok 1\n"; + +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index b078d716..c6ce8976 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -54,8 +54,7 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) glibtop_error_r (server, "read (%s): %s", FILENAME, strerror (errno)); - tmp = strchr (buffer, '\n'); - tmp = skip_token (tmp); /* "cpu" */ + tmp = skip_token (buffer); /* "cpu" */ buf->user = strtoul (tmp, &tmp, 10); buf->nice = strtoul (tmp, &tmp, 10); From eb36f97c5001368ca39bdbf3c5062ee399250d8a Mon Sep 17 00:00:00 2001 From: Vincent Renardias Date: Mon, 22 Jun 1998 10:45:16 +0000 Subject: [PATCH 0156/2539] Mon, 22 Jun 1998 12:38:50 +0200 [Vincent] * .fr translation updates. --- po/fr.po | 124 +++++++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/po/fr.po b/po/fr.po index e226dd2c..6b8d22d2 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: libgtop VERSION\n" -"POT-Creation-Date: 1998-05-31 22:31+0200\n" +"POT-Creation-Date: 1998-06-20 15:28+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Vincent Renardias \n" "Language-Team: Vincent Renardias \n" @@ -17,67 +17,67 @@ msgstr "" #: lib/open.c:36 #, c-format msgid "cannot make a pipe: %s\n" -msgstr "" +msgstr "impossible de crr un tube: %s\n" #: lib/open.c:41 #, c-format msgid "%s: fork failed: %s\n" -msgstr "" +msgstr "%s: duplication choue: %s\n" #: lib/open.c:59 #, c-format msgid "server version is not %s" -msgstr "" +msgstr "la version du serveur n'est pas %s" #: lib/read.c:34 #, c-format msgid "read size: %s" -msgstr "" +msgstr "taille lue: %s" #: lib/read.c:37 #, c-format msgid "got %d bytes but requested %d" -msgstr "" +msgstr "obtenu %d octets, mais %d taient demands" #: lib/read.c:40 #, c-format msgid "read %d bytes: %s" -msgstr "" +msgstr "lecture de %d octets: %s" #: lib/write.c:32 #, c-format msgid "write size: %s" -msgstr "" +msgstr "taille crite: %s" #: lib/write.c:37 #, c-format msgid "write %d bytes: %s" -msgstr "" +msgstr "crit %d octets: %s" #: lib/read_data.c:36 #, c-format msgid "read data size: %s" -msgstr "" +msgstr "taille de la lecture: %s" #: lib/read_data.c:46 #, c-format msgid "read data %d bytes: %s" -msgstr "" +msgstr "lecture de %d octets de donnes: %s" #: sysdeps/common/xmalloc.c:32 #, c-format msgid "malloc %d bytes: %s" -msgstr "" +msgstr "malloc de %d octets: %s" #: sysdeps/common/xmalloc.c:44 #, c-format msgid "calloc %d block (%d bytes each): %s" -msgstr "" +msgstr "calloc de %d blocks (%d octets chacuns): %s" #: sysdeps/common/xmalloc.c:56 #, c-format msgid "realloc %d bytes: %s" -msgstr "" +msgstr "realloc de %d octets: %s" #: sysdeps/names/sysdeps.c:42 sysdeps/names/sysdeps.c:62 msgid "CPU Usage" @@ -93,7 +93,7 @@ msgstr "Utilisation du Swap" #: sysdeps/names/sysdeps.c:45 sysdeps/names/sysdeps.c:65 msgid "System Uptime" -msgstr "" +msgstr "Uptime du systme" #: sysdeps/names/sysdeps.c:46 sysdeps/names/sysdeps.c:66 msgid "Load Averange" @@ -117,31 +117,31 @@ msgstr "Liste des taches en cours d' #: sysdeps/names/sysdeps.c:51 sysdeps/names/sysdeps.c:71 msgid "Process Status information" -msgstr "" +msgstr "Information sur l'tat du processus" #: sysdeps/names/sysdeps.c:52 sysdeps/names/sysdeps.c:72 msgid "Process UID and TTY information" -msgstr "" +msgstr "Information UID et TTY du processus" #: sysdeps/names/sysdeps.c:53 sysdeps/names/sysdeps.c:73 msgid "Process Memory information" -msgstr "" +msgstr "Information Mmoire du Processus" #: sysdeps/names/sysdeps.c:54 sysdeps/names/sysdeps.c:74 msgid "Process Time information" -msgstr "" +msgstr "Information Temporelle sur le processus" #: sysdeps/names/sysdeps.c:55 sysdeps/names/sysdeps.c:75 msgid "Process Signal information" -msgstr "" +msgstr "Information sur les signaux du processus" #: sysdeps/names/sysdeps.c:56 sysdeps/names/sysdeps.c:76 msgid "Process Kernel Data information" -msgstr "" +msgstr "Information sur les donnes noyau du processus" #: sysdeps/names/sysdeps.c:57 sysdeps/names/sysdeps.c:77 msgid "Process Segment information" -msgstr "" +msgstr "Information sur la segmentation du processus" #: sysdeps/names/cpu.c:37 msgid "Total CPU Time" @@ -153,7 +153,7 @@ msgstr "Temps CPU en mode utilisateur" #: sysdeps/names/cpu.c:39 msgid "CPU Time in User Mode (nice)" -msgstr "" +msgstr "Temps CPU en mode utilisateur (nice)" #: sysdeps/names/cpu.c:40 msgid "CPU Time in System Mode" @@ -165,7 +165,7 @@ msgstr "Temps CPU pour la tache inactive" #: sysdeps/names/cpu.c:42 msgid "Tick Frequency" -msgstr "" +msgstr "Frquence des ticks" #: sysdeps/names/cpu.c:47 msgid "The number of jiffies (1/100ths of a second) since system boot" @@ -175,31 +175,31 @@ msgstr "Nombre de jiffies (1/100e de seconde) depuis le boot du syst msgid "" "The number of jiffies (1/100ths of a second) that the system spent in user " "mode" -msgstr "" +msgstr "Le nombre de jiffies (1/100me de seconde) que le systme a pass en mode utilisateur" #: 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 "" +msgstr "Le nombre de jiffies (1/100me de seconde) que le systme a pass en mode utilisateur en priorit basse (nice)" #: sysdeps/names/cpu.c:53 msgid "" "The number of jiffies (1/100ths of a second) that the system spent in system " "mode" -msgstr "" +msgstr "Le nombre de jiffies (1/100me de seconde) que le systme a pass en mode systme" #: sysdeps/names/cpu.c:55 msgid "" "The number of jiffies (1/100ths of a second) that the system spend in the " "idle task" -msgstr "" +msgstr "Le nombre de jiffies (1/100me de seconde) que le systme a pass dans le processus inactif (idle task)" #: 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 "" +msgstr "Toutes les valeurs ci-dessus sont exprimes en jiffies (1/100me de seconde) sauf prcision contraire (i.e.: frquence != 100)" #: sysdeps/names/loadavg.c:36 msgid "Load Average" @@ -207,7 +207,7 @@ msgstr "Charge Moyenne" #: sysdeps/names/loadavg.c:41 msgid "Number of jobs running simultaneously averaged over 1, 5 and 15 minutes" -msgstr "" +msgstr "Nombre de processus tournant simultannement en moyenne sur 1, 5 et 15 minutes" #: sysdeps/names/mem.c:39 msgid "Total Memory" @@ -231,7 +231,7 @@ msgstr "Tampons" #: sysdeps/names/mem.c:44 msgid "Cached" -msgstr "" +msgstr "Dans le cache" #: sysdeps/names/mem.c:45 msgid "User" @@ -247,83 +247,83 @@ msgstr "M #: sysdeps/names/mem.c:52 msgid "Used memory size in kB" -msgstr "" +msgstr "Mmoire utilise en Ko" #: sysdeps/names/mem.c:53 msgid "Free memory size in kB" -msgstr "" +msgstr "Mmoire libre en Ko" #: sysdeps/names/mem.c:54 msgid "Shared memory size in kB" -msgstr "" +msgstr "Mmoire partage en Ko" #: sysdeps/names/mem.c:55 msgid "Size of buffers kB" -msgstr "" +msgstr "Taille des tampons en Ko" #: sysdeps/names/mem.c:56 msgid "Size of cached memory in kB" -msgstr "" +msgstr "Taille de la mmoire dans le cache en Ko" #: sysdeps/names/mem.c:57 msgid "Memory used from user processes in kB" -msgstr "" +msgstr "Mmoire utilise par les processus utilisateurs en Ko" #: sysdeps/names/mem.c:58 msgid "Memory in locked pages in kB" -msgstr "" +msgstr "Mmoire dans les pages vrouilles en Ko" #: sysdeps/names/swap.c:36 sysdeps/names/swap.c:43 msgid "Total Swap Space" -msgstr "" +msgstr "Taille totalle de la zone d'change" #: sysdeps/names/swap.c:37 sysdeps/names/swap.c:44 msgid "Used Swap Space" -msgstr "" +msgstr "Taille utilise de la zone d'change" #: sysdeps/names/swap.c:38 sysdeps/names/swap.c:45 msgid "Free Swap Space" -msgstr "" +msgstr "Espace libre de la zone d'change" #: sysdeps/names/uptime.c:36 msgid "Uptime" -msgstr "" +msgstr "Uptime" #: sysdeps/names/uptime.c:37 msgid "Idletime" -msgstr "" +msgstr "Idletime" #: sysdeps/names/uptime.c:42 msgid "Time in seconds since system boot" -msgstr "" +msgstr "Temps en secondes depuis le dmarrage du systme" #: sysdeps/names/uptime.c:43 msgid "Time in seconds the system spent in the idle task since system boot" -msgstr "" +msgstr "Temps en secondes pass dans le processus inactif depuis le dmarrage du systme" #: sysdeps/names/shm_limits.c:37 sysdeps/names/shm_limits.c:46 msgid "Max segment size" -msgstr "" +msgstr "Taille maximum des segments" #: sysdeps/names/shm_limits.c:38 sysdeps/names/shm_limits.c:47 msgid "Min segment size" -msgstr "" +msgstr "Taille minimum des segments" #: sysdeps/names/shm_limits.c:39 sysdeps/names/shm_limits.c:48 msgid "Max number of segments" -msgstr "" +msgstr "Nombre maximum des segments" #: sysdeps/names/shm_limits.c:40 sysdeps/names/shm_limits.c:49 msgid "Max shared segments per process" -msgstr "" +msgstr "Nombre maximum de segments partags par processus" #: sysdeps/names/shm_limits.c:41 sysdeps/names/shm_limits.c:50 msgid "Max total shared memory" -msgstr "" +msgstr "Taille totalle de la mmoire partage" #: sysdeps/names/msg_limits.c:37 sysdeps/names/msg_limits.c:48 msgid "Size in kilobytes of message pool" -msgstr "" +msgstr "Taille en kilo-octets du pool de messages" #: sysdeps/names/msg_limits.c:38 sysdeps/names/msg_limits.c:49 msgid "Number of entries in message map" @@ -331,23 +331,23 @@ msgstr "" #: sysdeps/names/msg_limits.c:39 sysdeps/names/msg_limits.c:50 msgid "Max size of message" -msgstr "" +msgstr "Taille maximum des messages" #: sysdeps/names/msg_limits.c:40 sysdeps/names/msg_limits.c:51 msgid "Default max size of queue" -msgstr "" +msgstr "Taille maximum par dfaut de la queue" #: sysdeps/names/msg_limits.c:41 sysdeps/names/msg_limits.c:52 msgid "Max queues system wide" -msgstr "" +msgstr "Nombre maximum de queues dans le systme" #: sysdeps/names/msg_limits.c:42 sysdeps/names/msg_limits.c:53 msgid "Message segment size" -msgstr "" +msgstr "Taille des segments de messages" #: sysdeps/names/msg_limits.c:43 sysdeps/names/msg_limits.c:54 msgid "Number of system message headers" -msgstr "" +msgstr "Nombre d'entetes de messages systme" #: sysdeps/names/sem_limits.c:39 sysdeps/names/sem_limits.c:53 msgid "Number of entries in semaphore map" @@ -355,19 +355,19 @@ msgstr "" #: sysdeps/names/sem_limits.c:40 sysdeps/names/sem_limits.c:54 msgid "Max number of arrays" -msgstr "" +msgstr "Nombre maximum de tables" #: sysdeps/names/sem_limits.c:41 sysdeps/names/sem_limits.c:55 msgid "Max semaphores system wide" -msgstr "" +msgstr "Nombre maximum de smaphores dans le systme" #: sysdeps/names/sem_limits.c:42 sysdeps/names/sem_limits.c:56 msgid "Number of undo structures system wide" -msgstr "" +msgstr "Nombre de structures 'undo' dans le systme" #: sysdeps/names/sem_limits.c:43 sysdeps/names/sem_limits.c:57 msgid "Max semaphores per array" -msgstr "" +msgstr "Nombre maximum de smaphores par table" #: sysdeps/names/sem_limits.c:44 sysdeps/names/sem_limits.c:58 msgid "Max ops per semop call" @@ -379,11 +379,11 @@ msgstr "" #: sysdeps/names/sem_limits.c:46 sysdeps/names/sem_limits.c:60 msgid "sizeof struct sem_undo" -msgstr "" +msgstr "sizeof struct sem_undo" #: sysdeps/names/sem_limits.c:47 sysdeps/names/sem_limits.c:61 msgid "Semaphore max value" -msgstr "" +msgstr "Valeur maximum d'un smaphore" #: sysdeps/names/sem_limits.c:48 sysdeps/names/sem_limits.c:62 msgid "Adjust on exit max value" From 4d2072ce65f9ca1aab6a56999930f0af38dff5ec Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Sun, 28 Jun 1998 21:04:40 +0000 Subject: [PATCH 0157/2539] Fixed a type in the Makefile --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index a9a51430..4bae60c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -77,4 +77,4 @@ perl/Makefile.PL: perl/Makefile.PL.in Makefile perl/Libgtop.xs: perl/perl.awk $(top_builddir)/config.h $(top_srcdir)/features.def $(AWK) -f $(top_srcdir)/perl/perl.awk < $(top_srcdir)/features.def > perl/lgt-t - mv perl/lgt_t perl/Libgtop.xs + mv perl/lgt-t perl/Libgtop.xs From 44bb75cf6ed30745bdce6cf3ff6c433ae2035b1c Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Sun, 28 Jun 1998 21:37:14 +0000 Subject: [PATCH 0158/2539] Made glibtop_machine.h get put in include_HEADERS --- sysdeps/linux/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index 5c5cb132..04962feb 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -14,4 +14,4 @@ libgtop_sysdeps_la_SOURCES = init.c open.c close.c cpu.c mem.c swap.c \ proctime.c procmem.c procsignal.c prockernel.c \ procsegment.c -include_HEADERS = glibtop_server.h +include_HEADERS = glibtop_server.h glibtop_machine.h From 94715ef7184e5aa1e8b66d1e4286cd373fa62a5b Mon Sep 17 00:00:00 2001 From: Manish Vachharajani Date: Sun, 28 Jun 1998 22:37:56 +0000 Subject: [PATCH 0159/2539] Fixed a typo for determining gtop libs --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index ef605d8e..ce320244 100644 --- a/configure.in +++ b/configure.in @@ -186,7 +186,7 @@ fi AC_SUBST(libgtop_want_guile_names) -LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common $ibs_xauth" +LIBGTOP_LIBS="$LIBGTOP_LIBS -lgtop_common $libs_xauth" LIBGTOP_GUILE_LIBS="$LIBGTOP_GUILE_LIBS -lgtop_common $libs_xauth" if test "x$need_server" = "xyes" ; then From 9532dadc2e391e731be897d25e05a8123192e5fd Mon Sep 17 00:00:00 2001 From: Martin baulig Date: Fri, 3 Jul 1998 17:19:25 +0000 Subject: [PATCH 0160/2539] No longer use `glibtop_machine.h' for Linux. 1998-07-03 Martin baulig * macros/gnome-libgtop-sysdeps.m4: No longer use `glibtop_machine.h' for Linux. * sysdeps/linux/glibtop_machine.h: Removed. * sysdeps/guile/guile.awk: Using `scm_append' instead of `gh_append'. * sysdeps/guile/names/guile-names.awk: dito. * sysdeps/linux/*.c: Using code from stable branch again. * include/glibtop/parameter.h: New file. * lib/parameter.c: New file. * lib/{open, init}.c: Done some more work on server initialization --- ChangeLog | 21 ++++ examples/first.c | 23 +++- glibtop.h | 3 +- include/glibtop/Makefile.am | 3 +- include/glibtop/open.h | 11 ++ include/glibtop/parameter.h | 42 +++++++ lib/Makefile.am | 3 +- lib/init.c | 165 ++++++++++++++++++++++++++-- lib/lib.awk | 5 +- lib/open.c | 113 +++++-------------- lib/parameter.c | 62 +++++++++++ src/daemon/.cvsignore | 1 + sysdeps/guile/guile.awk | 2 +- sysdeps/guile/names/guile-names.awk | 8 +- sysdeps/linux/cpu.c | 25 ++--- sysdeps/linux/loadavg.c | 23 ++-- sysdeps/linux/mem.c | 28 +---- sysdeps/linux/prockernel.c | 36 +++--- sysdeps/linux/procmem.c | 65 +++++------ sysdeps/linux/procsegment.c | 65 +++++------ sysdeps/linux/procsignal.c | 34 +++--- sysdeps/linux/procstate.c | 35 +++--- sysdeps/linux/proctime.c | 34 +++--- sysdeps/linux/procuid.c | 61 +++++----- sysdeps/linux/swap.c | 26 +---- sysdeps/linux/uptime.c | 18 +-- 26 files changed, 557 insertions(+), 355 deletions(-) create mode 100644 include/glibtop/parameter.h create mode 100644 lib/parameter.c diff --git a/ChangeLog b/ChangeLog index 22fb4b80..87de4161 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +1998-07-03 Martin baulig + + * macros/gnome-libgtop-sysdeps.m4: No longer use + `glibtop_machine.h' for Linux. + + * sysdeps/linux/glibtop_machine.h: Removed. + + * sysdeps/guile/guile.awk: Using `scm_append' + instead of `gh_append'. + + * sysdeps/guile/names/guile-names.awk: dito. + + * sysdeps/linux/*.c: Using code from stable branch again. + + * include/glibtop/parameter.h: New file. + + * lib/parameter.c: New file. + + * lib/{open, init}.c: Done some more work on server + initialization + 1998-06-21 Martin Baulig * perl/*: Added perl interface. diff --git a/examples/first.c b/examples/first.c index d6031e9a..79180446 100644 --- a/examples/first.c +++ b/examples/first.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include @@ -38,7 +40,8 @@ main (int argc, char *argv []) { glibtop_union data; glibtop_sysdeps sysdeps; - unsigned c, count, i, *ptr; + unsigned c, method, count, port, i, *ptr; + char buffer [BUFSIZ]; pid_t pid, ppid; count = PROFILE_COUNT; @@ -47,7 +50,23 @@ main (int argc, char *argv []) bindtextdomain (PACKAGE, GTOPLOCALEDIR); textdomain (PACKAGE); - glibtop_init (); + glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN); + + glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method)); + + printf ("Method = %d\n", method); + + count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ); + buffer [count] = 0; + + printf ("Command = '%s'\n", buffer); + + count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ); + buffer [count] = 0; + + glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port)); + + printf ("Host = '%s' - %u\n\n", buffer, port); for (c = 0; c < count; c++) glibtop_get_cpu (&data.cpu); diff --git a/glibtop.h b/glibtop.h index 2ac3a5ec..9db6c74c 100644 --- a/glibtop.h +++ b/glibtop.h @@ -35,7 +35,8 @@ typedef struct _glibtop glibtop; struct _glibtop { - int fd; /* Server file descriptor */ + unsigned flags; + unsigned method; /* Server Method */ #ifdef HAVE_GLIBTOP_MACHINE_H glibtop_machine machine; /* Machine dependent data */ #endif diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am index 53ee5c51..a0157346 100644 --- a/include/glibtop/Makefile.am +++ b/include/glibtop/Makefile.am @@ -5,4 +5,5 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \ proctime.h shm_limits.h version.h cpu.h msg_limits.h \ procmem.h procuid.h swap.h write.h error.h open.h \ procsegment.h read.h sysdeps.h xmalloc.h global.h \ - output.h procsignal.h read_data.h union.h types.h + output.h procsignal.h read_data.h union.h types.h \ + parameter.h diff --git a/include/glibtop/open.h b/include/glibtop/open.h index 4e4e5408..a891727d 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -26,8 +26,19 @@ __BEGIN_DECLS +#define _GLIBTOP_INIT_STATE_INIT 0x10000 +#define _GLIBTOP_INIT_STATE_OPEN 0x20000 +#define _GLIBTOP_INIT_STATE_SERVER 0x40000 + +#define GLIBTOP_INIT_NO_OPEN 1 +#define GLIBTOP_INIT_NO_INIT 2 + #define GLIBTOP_OPEN_NO_OVERRIDE 1 +#define GLIBTOP_METHOD_DIRECT 1 +#define GLIBTOP_METHOD_PIPE 2 +#define GLIBTOP_METHOD_INET 3 + 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)); diff --git a/include/glibtop/parameter.h b/include/glibtop/parameter.h new file mode 100644 index 00000000..7614d3e5 --- /dev/null +++ b/include/glibtop/parameter.h @@ -0,0 +1,42 @@ +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_PARAMETER_H__ +#define __GLIBTOP_PARAMETER_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PARAM_METHOD 1 +#define GLIBTOP_PARAM_FEATURES 2 +#define GLIBTOP_PARAM_COMMAND 3 +#define GLIBTOP_PARAM_HOST 4 +#define GLIBTOP_PARAM_PORT 5 + +#define glibtop_get_parameter(p1,p2,p3) glibtop_get_parameter_l(glibtop_global_server,p1,p2,p3) +#define glibtop_set_parameter(p1,p2,p3) glibtop_set_parameter_l(glibtop_global_server,p1,p2,p3) + +extern size_t glibtop_get_parameter_l __P((glibtop *, const unsigned, void *, size_t)); +extern void glibtop_set_parameter_l __P((glibtop *, const unsigned, const void *, size_t)); + +__END_DECLS + +#endif diff --git a/lib/Makefile.am b/lib/Makefile.am index 1e9e7c28..87d16c29 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -8,7 +8,8 @@ CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\" -DDEBUG lib_LTLIBRARIES = libgtop.la -libgtop_la_SOURCES = init.c open.c close.c command.c read.c read_data.c write.c lib.c +libgtop_la_SOURCES = init.c open.c close.c command.c read.c read_data.c \ + write.c lib.c parameter.c BUILT_SOURCES = lib.c diff --git a/lib/init.c b/lib/init.c index ceefe35e..bc202c62 100644 --- a/lib/init.c +++ b/lib/init.c @@ -20,23 +20,168 @@ Boston, MA 02111-1307, USA. */ #include -#include +#include +#include -static glibtop _glibtop_global_server; -glibtop *glibtop_global_server = NULL; +#ifndef DEFAULT_PORT +#define DEFAULT_PORT 42800 +#endif + +static glibtop _glibtop_global_server; +glibtop *glibtop_global_server = &_glibtop_global_server; + + +void +_init_server (glibtop *server, const unsigned features) +{ + char *command, *temp; + + /* Try to get server command, but don't override if already + * set via glibtop_set_parameter () */ + + if (server->server_command == NULL) { + const char *temp = getenv ("LIBGTOP_SERVER") ? + getenv ("LIBGTOP_SERVER") : GTOP_SERVER; + + server->server_command = glibtop_strdup_r (server, temp); + } + + if (server->server_rsh == NULL) { + const char *temp = getenv ("LIBGTOP_RSH") ? + getenv ("LIBGTOP_RSH") : "/usr/bin/ssh"; + + server->server_rsh = glibtop_strdup_r (server, temp); + } + + /* Try to get server method, but don't override if already + * set via glibtop_set_parameter () */ + + if (server->method) return; + + /* If server->command doesn't start with a colon, then it is + * the full pathname of the server executable. */ + + if (server->server_command [0] != ':') { + if (features & glibtop_server_features) { + + /* We really need the server. */ + + server->method = GLIBTOP_METHOD_PIPE; + + } else { + + /* Fine. No server is needed, so we call the + * sysdeps functions directly. */ + + server->method = GLIBTOP_METHOD_DIRECT; + } + + return; + } + + + /* If the first character of 'server_command' is a colon, + * the first field is the method to connect to the server. */ + + /* Everything up to the next colon is the method. */ + + command = glibtop_strdup_r (server, server->server_command+1); + temp = strstr (command, ":"); + if (temp) *temp = 0; + + /* Dispatch method. */ + + if (!strcmp (command, "direct")) { + + /* Use sysdeps dir instead of connecting to server + * even if using the server would be required on + * the current system. */ + + server->method = GLIBTOP_METHOD_DIRECT; + + } else if (!strcmp (command, "inet")) { + + server->method = GLIBTOP_METHOD_INET; + + /* Connect to internet server. */ + + if (temp == NULL) { + /* If no value was set, we use 'localhost'. */ + if (server->server_host == NULL) + server->server_host = glibtop_strdup_r + (server, "localhost"); + } else { + char *temp2 = strstr (temp+1, ":"); + if (temp2) *temp2 = 0; + + /* Override default. */ + if (server->server_host) + glibtop_free_r (server, (char *) server->server_host); + + server->server_host = glibtop_strdup_r + (server, temp+1); + + temp = temp2; + } + + if (temp == NULL) { + /* If no value was set, we use DEFAULT_PORT. */ + if (server->server_port == 0) + server->server_port = DEFAULT_PORT; + } else { + char *temp2 = strstr (temp+1, ":"); + if (temp2) *temp2 = 0; + + if (sscanf (temp+1, "%ld", &server->server_port) != 1) + server->server_port = DEFAULT_PORT; + + temp = temp2 ? temp2 + 1 : temp2; + } + } else { + glibtop_error_r (server, "Unknown server method '%s'", + server->server_command+1); + } + + glibtop_free_r (server, command); +} glibtop * -glibtop_init_r (glibtop **server, const unsigned long features, +glibtop_init_r (glibtop **server_ptr, const unsigned long features, const unsigned flags) { - if (*server != NULL) - return *server; + glibtop *server; - if (glibtop_global_server == NULL) { - glibtop_global_server = &_glibtop_global_server; + if (server_ptr == NULL) + return NULL; + + if (*server_ptr == NULL) + *server_ptr = glibtop_global_server; + + server = *server_ptr; + + /* Should we do the initialization? */ + + if (flags & GLIBTOP_INIT_NO_INIT) + return server; + + /* Do the initialization, but only if not already initialized. */ + + if ((server->flags & _GLIBTOP_INIT_STATE_INIT) == 0) { + _init_server (server, features); + + server->flags |= _GLIBTOP_INIT_STATE_INIT; + } + + /* Should we open the server? */ + + if (flags & GLIBTOP_INIT_NO_OPEN) + return server; + + /* Open server, but only if not already opened. */ + + if ((server->flags & _GLIBTOP_INIT_STATE_OPEN) == 0) glibtop_open_l (glibtop_global_server, "glibtop", features, flags); - } - return *server = glibtop_global_server; + return server; } diff --git a/lib/lib.awk b/lib/lib.awk index fc901bcd..7498b841 100644 --- a/lib/lib.awk +++ b/lib/lib.awk @@ -4,6 +4,7 @@ BEGIN { print ""; print "#include "; + print "#include "; print "#include "; print "#include "; @@ -29,7 +30,9 @@ function output(feature) { print "{"; print "\tglibtop_init_r (&server, GLIBTOP_SYSDEPS_"toupper(feature)", 0);"; print ""; - print "\tif (server->features & GLIBTOP_SYSDEPS_"toupper(feature)") {"; + print "\tif ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&"; + print "\t (server->features & GLIBTOP_SYSDEPS_"toupper(feature)"))"; + print "\t{"; if (feature ~ /^proc_/) { print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", sizeof (pid_t),"; diff --git a/lib/open.c b/lib/open.c index fccf3635..1bf95032 100644 --- a/lib/open.c +++ b/lib/open.c @@ -33,97 +33,36 @@ void glibtop_open_l (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { - char version [BUFSIZ], buffer [BUFSIZ], *temp, *temp2; - glibtop_sysdeps sysdeps; - int connect_type, ret; - - memset (server, 0, sizeof (glibtop)); - server->name = program_name; - /* Is the user allowed to override the server ? */ + /* It is important to set _GLIBTOP_INIT_STATE_OPEN here when we + * do recursive calls to glibtop_init_r (). */ + + server->flags |= _GLIBTOP_INIT_STATE_OPEN; + + if (server->method == GLIBTOP_METHOD_INET) { + int connect_type; + + fprintf (stderr, "Connecting to '%s' port %d.\n", + server->server_host, server->server_port); + + connect_type = glibtop_make_connection + (server->server_host, server->server_port, + &server->socket); + + server->features = -1; - if (flags & GLIBTOP_OPEN_NO_OVERRIDE) return; - - /* Try to get data from environment. */ - - temp = getenv ("LIBGTOP_SERVER") ? - getenv ("LIBGTOP_SERVER") : GTOP_SERVER; - - server->server_command = glibtop_strdup_r (server, temp); - - temp = getenv ("LIBGTOP_RSH") ? - getenv ("LIBGTOP_RSH") : "rsh"; - - server->server_rsh = glibtop_strdup_r (server, temp); - - /* If the first character of 'server_command' is a colon, - * the first field is the method to connect to the server. */ - - if (server->server_command [0] == ':') { - - /* Everything up to the next colon is the method. */ - - temp = strstr (server->server_command+1, ":"); - if (temp) *temp = 0; - - /* Dispatch method. */ - - if (!strcmp (server->server_command+1, "direct")) { - - /* Use sysdeps dir instead of connecting to server - * even if using the server would be required on - * the current system. */ - - return; - - } else if (!strcmp (server->server_command+1, "inet")) { - - /* Connect to internet server. */ - - if (temp == NULL) { - server->server_host = glibtop_strdup_r - (server, "localhost"); - } else { - temp2 = strstr (temp+1, ":"); - if (temp2) *temp2 = 0; - - server->server_host = glibtop_strdup_r - (server, temp+1); - - temp = temp2; - } - - if (temp == NULL) { - server->server_port = DEFAULT_PORT; - } else { - temp2 = strstr (temp+1, ":"); - if (temp2) *temp2 = 0; - - ret = sscanf (temp+1, "%d", &server->server_port); - - if (ret != 1) - server->server_port = DEFAULT_PORT; - - temp = temp2 ? temp2 + 1 : temp2; - } - - fprintf (stderr, "Connecting to '%s' port %d.\n", - server->server_host, server->server_port); - - connect_type = glibtop_make_connection - (server->server_host, server->server_port, - &server->socket); - - server->features = -1; - - return; - } } - glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL, - sizeof (glibtop_sysdeps), &sysdeps); - - server->features = sysdeps.features; + /* If the server has been started, ask it for its features. */ + + if (server->flags & _GLIBTOP_INIT_STATE_SERVER) { + glibtop_sysdeps sysdeps; + + glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL, + sizeof (glibtop_sysdeps), &sysdeps); + + server->features = sysdeps.features; + } } diff --git a/lib/parameter.c b/lib/parameter.c new file mode 100644 index 00000000..ca3c5d0c --- /dev/null +++ b/lib/parameter.c @@ -0,0 +1,62 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#define _write_data(ptr,size) \ + if ((data_ptr == NULL) || (data_size < size)) return -size; \ + if (ptr == NULL) { strcpy (data_ptr, ""); return 1; } \ + memcpy (data_ptr, ptr, size); \ + return size; + +#define _strlen(ptr) (ptr ? strlen (ptr) : 0) + +size_t +glibtop_get_parameter_l (glibtop *server, const unsigned parameter, + void *data_ptr, size_t data_size) +{ + switch (parameter) { + case GLIBTOP_PARAM_METHOD: + _write_data (&server->method, + sizeof (server->method)); + case GLIBTOP_PARAM_FEATURES: + _write_data (&server->features, + sizeof (server->features)); + case GLIBTOP_PARAM_COMMAND: + _write_data (server->server_command, + _strlen(server->server_command)); + case GLIBTOP_PARAM_HOST: + _write_data (server->server_host, + _strlen(server->server_host)); + case GLIBTOP_PARAM_PORT: + _write_data (&server->server_port, + sizeof (server->server_port)); + } + + return 0; +} + +void +glibtop_set_parameter_l (glibtop *server, const unsigned parameter, + const void *data_ptr, size_t data_size) +{ +} diff --git a/src/daemon/.cvsignore b/src/daemon/.cvsignore index 3dda7298..e86ad538 100644 --- a/src/daemon/.cvsignore +++ b/src/daemon/.cvsignore @@ -1,2 +1,3 @@ Makefile.in Makefile +gnuserv diff --git a/sysdeps/guile/guile.awk b/sysdeps/guile/guile.awk index 25d293f0..8722a6e3 100644 --- a/sysdeps/guile/guile.awk +++ b/sysdeps/guile/guile.awk @@ -55,7 +55,7 @@ BEGIN { print ""; print "\tif (ptr) {"; print "\t\tfor (i = 0; i < proclist.number; i++)"; - print "\t\t\tlist = gh_append"; + print "\t\t\tlist = scm_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));"; diff --git a/sysdeps/guile/names/guile-names.awk b/sysdeps/guile/names/guile-names.awk index 11693343..c76f3b60 100644 --- a/sysdeps/guile/names/guile-names.awk +++ b/sysdeps/guile/names/guile-names.awk @@ -22,7 +22,7 @@ function output(feature) { print "\tlist = gh_list (SCM_UNDEFINED);"; print ""; print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)"; - print "\t\tlist = gh_append"; + print "\t\tlist = scm_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));"; @@ -41,7 +41,7 @@ function output(feature) { print "\tlist = gh_list (SCM_UNDEFINED);"; print ""; print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)"; - print "\t\tlist = gh_append"; + print "\t\tlist = scm_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));"; @@ -60,7 +60,7 @@ function output(feature) { print "\tlist = gh_list (SCM_UNDEFINED);"; print ""; print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)"; - print "\t\tlist = gh_append"; + print "\t\tlist = scm_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]))),"; @@ -80,7 +80,7 @@ function output(feature) { print "\tlist = gh_list (SCM_UNDEFINED);"; print ""; print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)"; - print "\t\tlist = gh_append"; + print "\t\tlist = scm_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]))),"; diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index c6ce8976..750161a6 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -35,8 +35,7 @@ static const unsigned long _glibtop_sysdeps_cpu = void glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) { - char buffer [BUFSIZ], *tmp; - int fd = 0, ret; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -44,25 +43,15 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) buf->flags = _glibtop_sysdeps_cpu; - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); + f = fopen ("/proc/stat", "r"); + if (!f) return; - ret = read (fd, buffer, BUFSIZ); - if (ret == -1) - glibtop_error_r (server, "read (%s): %s", - FILENAME, strerror (errno)); - - tmp = skip_token (buffer); /* "cpu" */ - - buf->user = strtoul (tmp, &tmp, 10); - buf->nice = strtoul (tmp, &tmp, 10); - buf->sys = strtoul (tmp, &tmp, 10); - buf->idle = strtoul (tmp, &tmp, 10); + fscanf (f, "cpu %lu %lu %lu %lu\n", + &buf->user, &buf->nice, &buf->sys, &buf->idle); buf->total = buf->user + buf->nice + buf->sys + buf->idle; buf->frequency = 100; - close (fd); + + fclose (f); } diff --git a/sysdeps/linux/loadavg.c b/sysdeps/linux/loadavg.c index 57717205..dbda3e6d 100644 --- a/sysdeps/linux/loadavg.c +++ b/sysdeps/linux/loadavg.c @@ -33,8 +33,7 @@ static const unsigned long _glibtop_sysdeps_loadavg = void glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) { - char buffer [BUFSIZ], *tmp; - int fd = 0, ret; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -42,19 +41,11 @@ glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) buf->flags = _glibtop_sysdeps_loadavg; - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); + f = fopen ("/proc/loadavg", "r"); + if (!f) return; - ret = read (fd, buffer, BUFSIZ); - if (ret == -1) - glibtop_error_r (server, "read (%s): %s", - FILENAME, strerror (errno)); - - buf->loadavg [0] = strtod (buffer, &tmp); - buf->loadavg [1] = strtod (tmp, &tmp); - buf->loadavg [2] = strtod (tmp, &tmp); - - close (fd); + fscanf (f, "%lf %lf %lf\n", + &buf->loadavg [0], &buf->loadavg [1], &buf->loadavg [2]); + + fclose (f); } diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index b605a35d..4d6d7f72 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -36,8 +36,7 @@ static const unsigned long _glibtop_sysdeps_mem = void glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) { - char buffer [BUFSIZ], *tmp; - int fd = 0, ret; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -45,28 +44,13 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) buf->flags = _glibtop_sysdeps_mem; - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); + f = fopen ("/proc/meminfo", "r"); + if (!f) return; - ret = read (fd, buffer, BUFSIZ); - if (ret == -1) - glibtop_error_r (server, "read (%s): %s", - FILENAME, strerror (errno)); - - tmp = strchr (buffer, '\n'); - tmp = skip_token (tmp); /* "Mem:" */ - tmp = skip_token (tmp); /* total memory */ - - buf->total = strtoul (tmp, &tmp, 10); - buf->used = strtoul (tmp, &tmp, 10); - buf->free = strtoul (tmp, &tmp, 10); - buf->shared = strtoul (tmp, &tmp, 10); - buf->buffer = strtoul (tmp, &tmp, 10); - buf->cached = strtoul (tmp, &tmp, 10); + fscanf (f, "%*[^\n]\nMem: %lu %lu %lu %lu %lu %lu\n", + &buf->total, &buf->used, &buf->free, &buf->shared, &buf->buffer, &buf->cached); buf->user = buf->total - buf->free - buf->shared - buf->buffer; - close (fd); + fclose (f); } diff --git a/sysdeps/linux/prockernel.c b/sysdeps/linux/prockernel.c index 7784eac3..777af80d 100644 --- a/sysdeps/linux/prockernel.c +++ b/sysdeps/linux/prockernel.c @@ -34,8 +34,9 @@ static const unsigned long _glibtop_sysdeps_proc_kernel = void glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) { - char buffer [BUFSIZ], input [BUFSIZ], *tmp; - int fd = 0, nread; + char input [BUFSIZ], *tmp; + int nread; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -48,24 +49,23 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) } sprintf (input, "/proc/%d/stat", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - - buffer [nread] = 0; - close (fd); - + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (buffer, ')'); + tmp = strrchr (input, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ @@ -76,6 +76,8 @@ glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid) &buf->k_flags, &buf->min_flt, &buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt, &buf->kstk_esp, &buf->kstk_eip, &buf->wchan); + + fclose (f); buf->flags = _glibtop_sysdeps_proc_kernel; } diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c index f1108eb3..a39a0553 100644 --- a/sysdeps/linux/procmem.c +++ b/sysdeps/linux/procmem.c @@ -33,8 +33,9 @@ static const unsigned long _glibtop_sysdeps_proc_mem = void glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) { - char buffer [BUFSIZ], input [BUFSIZ], *tmp; - int fd = 0, nread; + char input [BUFSIZ], *tmp; + int nread; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -47,24 +48,23 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) } sprintf (input, "/proc/%d/stat", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - - buffer [nread] = 0; - close (fd); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (buffer, ')'); + tmp = strrchr (input, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -72,23 +72,26 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) "%*d %*d %*d %*d %*d %*d %*u %*u %*d %lu " "%lu %lu", &buf->vsize, &buf->rss, &buf->rss_rlim); - sprintf (input, "/proc/%d/statm", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); + fclose (f); - buffer [nread] = 0; - close (fd); - - sscanf (buffer, "%ld %ld %ld", + sprintf (input, "/proc/%d/statm", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + sscanf (input, "%ld %ld %ld", &buf->size, &buf->resident, &buf->share); + fclose (f); + buf->flags = _glibtop_sysdeps_proc_mem; } diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c index 3c4ea965..b5b37ba4 100644 --- a/sysdeps/linux/procsegment.c +++ b/sysdeps/linux/procsegment.c @@ -35,8 +35,9 @@ void glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, pid_t pid) { - char buffer [BUFSIZ], input [BUFSIZ], *tmp; - int fd = 0, nread; + char input [BUFSIZ], *tmp; + int nread; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -49,24 +50,23 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, } sprintf (input, "/proc/%d/stat", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - - buffer [nread] = 0; - close (fd); + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (buffer, ')'); + tmp = strrchr (input, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -75,23 +75,26 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, "%*u %*u %lu %lu %lu", &buf->start_code, &buf->end_code, &buf->start_stack); - sprintf (input, "/proc/%d/statm", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - - buffer [nread] = 0; - close (fd); + fclose (f); - sscanf (buffer, "%*d %*d %*d %ld %ld %ld %ld", + sprintf (input, "/proc/%d/statm", pid); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + + sscanf (input, "%*d %*d %*d %ld %ld %ld %ld", &buf->trs, &buf->lrs, &buf->drs, &buf->dt); + fclose (f); + buf->flags = _glibtop_sysdeps_proc_segment; } diff --git a/sysdeps/linux/procsignal.c b/sysdeps/linux/procsignal.c index 14bdb353..3b409e8b 100644 --- a/sysdeps/linux/procsignal.c +++ b/sysdeps/linux/procsignal.c @@ -32,8 +32,9 @@ static const unsigned long _glibtop_sysdeps_proc_signal = void glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { - char buffer [BUFSIZ], input [BUFSIZ], *tmp; - int fd = 0, nread; + char input [BUFSIZ], *tmp; + int nread; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -46,24 +47,23 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) } sprintf (input, "/proc/%d/stat", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - - buffer [nread] = 0; - close (fd); + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (buffer, ')'); + tmp = strrchr (input, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -73,5 +73,7 @@ glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) &buf->signal, &buf->blocked, &buf->sigignore, &buf->sigcatch); + fclose (f); + buf->flags = _glibtop_sysdeps_proc_signal; } diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index 03432969..bcf55662 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -34,9 +34,10 @@ static const unsigned long _glibtop_sysdeps_proc_state = void glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) { - char buffer [BUFSIZ], input [BUFSIZ], *tmp; + char input [BUFSIZ], *tmp; struct stat statb; - int fd, nread; + int nread; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -61,30 +62,28 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) buf->uid = statb.st_uid; buf->gid = statb.st_gid; - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - buffer [nread] = 0; - + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (buffer, ')'); + tmp = strrchr (input, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ memset (buf->cmd, 0, sizeof (buf->cmd)); - sscanf (buffer, "%d (%39c", &pid, buf->cmd); + sscanf (input, "%d (%39c", &pid, buf->cmd); sscanf(tmp + 2, "%c", &buf->state); /* skip space after ')' too */ - close (fd); - buf->flags = _glibtop_sysdeps_proc_state; } diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index 0d740bf0..0d0eaeda 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -34,8 +34,9 @@ static const unsigned long _glibtop_sysdeps_proc_time = void glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) { - char buffer [BUFSIZ], input [BUFSIZ], *tmp; - int fd = 0, nread; + char input [BUFSIZ], *tmp; + int nread; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -48,24 +49,23 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) } sprintf (input, "/proc/%d/stat", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - - buffer [nread] = 0; - close (fd); + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (buffer, ')'); + tmp = strrchr (input, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -74,5 +74,7 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) &buf->utime, &buf->stime, &buf->cutime, &buf->cstime, &buf->timeout, &buf->it_real_value, &buf->start_time); + fclose (f); + buf->flags = _glibtop_sysdeps_proc_time; } diff --git a/sysdeps/linux/procuid.c b/sysdeps/linux/procuid.c index ff2afb19..582a9ebd 100644 --- a/sysdeps/linux/procuid.c +++ b/sysdeps/linux/procuid.c @@ -38,8 +38,9 @@ static const unsigned long _glibtop_sysdeps_proc_uid = void glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) { - char buffer [BUFSIZ], input [BUFSIZ], *tmp; - int fd = 0, nread; + char input [BUFSIZ], *tmp; + int nread; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -52,23 +53,22 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) } sprintf (input, "/proc/%d/status", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - buffer [nread] = 0; - close (fd); + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; /* Search substring 'Pid:' */ - tmp = strstr (buffer, "Pid:"); + tmp = strstr (input, "Pid:"); if (tmp == NULL) return; @@ -76,25 +76,26 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) "Gid: %u %u %*u %*u\n", &buf->pid, &buf->ppid, &buf->uid, &buf->euid, &buf->gid, &buf->egid); + fclose (f); + sprintf (input, "/proc/%d/stat", pid); - - fd = open (input, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - input, strerror (errno)); - - nread = read (fd, buffer, BUFSIZ); - if (nread == -1) - glibtop_error_r (server, "read (%s): %s", - input, strerror (errno)); - - buffer [nread] = 0; - close (fd); + + f = fopen (input, "r"); + if (!f) return; + + nread = fread (input, 1, BUFSIZ, f); + + if (nread < 0) { + fclose (f); + return; + } + + input [nread] = 0; /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ - tmp = strrchr (buffer, ')'); + tmp = strrchr (input, ')'); *tmp = '\0'; /* replace trailing ')' with NUL */ /* parse these two strings separately, skipping the leading "(". */ sscanf(tmp + 2, /* skip space after ')' too */ @@ -116,5 +117,7 @@ glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) /* when tty wasn't full devno */ buf->tty = 4*0x100 + buf->tty; + fclose (f); + buf->flags = _glibtop_sysdeps_proc_uid; } diff --git a/sysdeps/linux/swap.c b/sysdeps/linux/swap.c index 57f159dd..dd54e1bd 100644 --- a/sysdeps/linux/swap.c +++ b/sysdeps/linux/swap.c @@ -34,8 +34,7 @@ static unsigned long _glibtop_sysdeps_swap = void glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) { - char buffer [BUFSIZ], *tmp; - int fd = 0, ret; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -43,24 +42,11 @@ glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) buf->flags = _glibtop_sysdeps_swap; - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); + f = fopen ("/proc/meminfo", "r"); + if (!f) return; - ret = read (fd, buffer, BUFSIZ); - if (ret == -1) - glibtop_error_r (server, "read (%s): %s", - FILENAME, strerror (errno)); + fscanf (f, "%*[^\n]\n%*[^\n]\nSwap: %lu %lu %lu\n", + &buf->total, &buf->used, &buf->free); - tmp = strchr (buffer, '\n'); - tmp = strchr (tmp+1, '\n'); - - tmp = skip_token (tmp); /* "Swap:" */ - - buf->total = strtoul (tmp, &tmp, 10); - buf->used = strtoul (tmp, &tmp, 10); - buf->free = strtoul (tmp, &tmp, 10); - - close (fd); + fclose (f); } diff --git a/sysdeps/linux/uptime.c b/sysdeps/linux/uptime.c index 17b263cb..8233e1ff 100644 --- a/sysdeps/linux/uptime.c +++ b/sysdeps/linux/uptime.c @@ -33,8 +33,7 @@ static unsigned long _glibtop_sysdeps_uptime = void glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) { - int fd, ret; - char buffer [BUFSIZ]; + FILE *f; glibtop_init_r (&server, 0, 0); @@ -42,17 +41,10 @@ glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) buf->flags = _glibtop_sysdeps_uptime; - fd = open (FILENAME, O_RDONLY); - if (fd == -1) - glibtop_error_r (server, "open (%s): %s", - FILENAME, strerror (errno)); + f = fopen ("/proc/uptime", "r"); + if (!f) return; - ret = read (fd, buffer, BUFSIZ); - if (ret == -1) - glibtop_error_r (server, "read (%s): %s", - FILENAME, strerror (errno)); + fscanf (f, "%lf %lf\n", &buf->uptime, &buf->idletime); - sscanf (buffer, "%lf %lf\n", &buf->uptime, &buf->idletime); - - close (fd); + fclose (f); } From 15cc0113a9b599544ad506728bd2a59bb4c13209 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 6 Jul 1998 22:44:40 +0000 Subject: [PATCH 0161/2539] Initial revision --- sysdeps/common/fsusage.c | 274 ++++++++++++++++++ sysdeps/common/fsusage.h | 37 +++ sysdeps/common/mountlist.c | 577 +++++++++++++++++++++++++++++++++++++ sysdeps/common/mountlist.h | 32 ++ 4 files changed, 920 insertions(+) create mode 100644 sysdeps/common/fsusage.c create mode 100644 sysdeps/common/fsusage.h create mode 100644 sysdeps/common/mountlist.c create mode 100644 sysdeps/common/mountlist.h diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c new file mode 100644 index 00000000..e90abf94 --- /dev/null +++ b/sysdeps/common/fsusage.c @@ -0,0 +1,274 @@ +/* fsusage.c -- return space usage of mounted filesystems + Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc. + + This program 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. + + This program 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 this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#include +#include +#include "fsusage.h" + +int statfs (); + +#if HAVE_SYS_PARAM_H +# include +#endif + +#if HAVE_SYS_MOUNT_H +# include +#endif + +#if HAVE_SYS_VFS_H +# include +#endif + +#if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ +# include +#endif + +#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY) +# include /* SVR2 */ +#endif + +#if HAVE_FCNTL_H +# include +#endif + +#if HAVE_SYS_STATFS_H +# include +#endif + +#if HAVE_DUSTAT_H /* AIX PS/2 */ +# include +#endif + +#if HAVE_SYS_STATVFS_H /* SVR4 */ +# include +int statvfs (); +#endif + +int safe_read (); + +/* Return the number of TOSIZE-byte blocks used by + BLOCKS FROMSIZE-byte blocks, rounding away from zero. + TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */ + +static long +adjust_blocks (blocks, fromsize, tosize) + long blocks; + int fromsize, tosize; +{ + if (tosize <= 0) + abort (); + if (fromsize <= 0) + return -1; + + if (fromsize == tosize) /* e.g., from 512 to 512 */ + return blocks; + else if (fromsize > tosize) /* e.g., from 2048 to 512 */ + return blocks * (fromsize / tosize); + else /* e.g., from 256 to 512 */ + return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize); +} + +/* Fill in the fields of FSP with information about space usage for + the filesystem on which PATH resides. + DISK is the device on which PATH is mounted, for space-getting + methods that need to know it. + Return 0 if successful, -1 if not. When returning -1, ensure that + ERRNO is either a system error value, or zero if DISK is NULL + on a system that requires a non-NULL value. */ +int +get_fs_usage (path, disk, fsp) + const char *path; + const char *disk; + struct fs_usage *fsp; +{ +#ifdef STAT_STATFS3_OSF1 +# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) + + struct statfs fsd; + + if (statfs (path, &fsd, sizeof (struct statfs)) != 0) + return -1; + +#endif /* STAT_STATFS3_OSF1 */ + +#ifdef STAT_STATFS2_FS_DATA /* Ultrix */ +# define CONVERT_BLOCKS(B) adjust_blocks ((B), 1024, 512) + + struct fs_data fsd; + + if (statfs (path, &fsd) != 1) + return -1; + fsp->fsu_blocks = CONVERT_BLOCKS (fsd.fd_req.btot); + fsp->fsu_bfree = CONVERT_BLOCKS (fsd.fd_req.bfree); + fsp->fsu_bavail = CONVERT_BLOCKS (fsd.fd_req.bfreen); + fsp->fsu_files = fsd.fd_req.gtot; + fsp->fsu_ffree = fsd.fd_req.gfree; + +#endif /* STAT_STATFS2_FS_DATA */ + +#ifdef STAT_READ_FILSYS /* SVR2 */ +# ifndef SUPERBOFF +# define SUPERBOFF (SUPERB * 512) +# endif +# define CONVERT_BLOCKS(B) \ + adjust_blocks ((B), (fsd.s_type == Fs2b ? 1024 : 512), 512) + + struct filsys fsd; + int fd; + + if (! disk) + { + errno = 0; + return -1; + } + + fd = open (disk, O_RDONLY); + if (fd < 0) + return -1; + lseek (fd, (long) SUPERBOFF, 0); + if (safe_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd) + { + close (fd); + return -1; + } + close (fd); + fsp->fsu_blocks = CONVERT_BLOCKS (fsd.s_fsize); + fsp->fsu_bfree = CONVERT_BLOCKS (fsd.s_tfree); + fsp->fsu_bavail = CONVERT_BLOCKS (fsd.s_tfree); + fsp->fsu_files = (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1); + fsp->fsu_ffree = fsd.s_tinode; + +#endif /* STAT_READ_FILSYS */ + +#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ +# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512) + + struct statfs fsd; + + if (statfs (path, &fsd) < 0) + return -1; + +# ifdef STATFS_TRUNCATES_BLOCK_COUNTS + + /* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the + struct statfs are truncated to 2GB. These conditions detect that + truncation, presumably without botching the 4.1.1 case, in which + the values are not truncated. The correct counts are stored in + undocumented spare fields. */ + if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0) + { + fsd.f_blocks = fsd.f_spare[0]; + fsd.f_bfree = fsd.f_spare[1]; + fsd.f_bavail = fsd.f_spare[2]; + } +# endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ + +#endif /* STAT_STATFS2_BSIZE */ + +#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ +# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) + + struct statfs fsd; + + if (statfs (path, &fsd) < 0) + return -1; + +#endif /* STAT_STATFS2_FSIZE */ + +#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ +# if _AIX || defined(_CRAY) +# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512) +# ifdef _CRAY +# define f_bavail f_bfree +# endif +# else +# define CONVERT_BLOCKS(B) (B) +# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx */ +# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */ +# define f_bavail f_bfree +# endif +# endif +# endif + + struct statfs fsd; + + if (statfs (path, &fsd, sizeof fsd, 0) < 0) + return -1; + /* Empirically, the block counts on most SVR3 and SVR3-derived + systems seem to always be in terms of 512-byte blocks, + no matter what value f_bsize has. */ + +#endif /* STAT_STATFS4 */ + +#ifdef STAT_STATVFS /* SVR4 */ +# define CONVERT_BLOCKS(B) \ + adjust_blocks ((B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) + + struct statvfs fsd; + + if (statvfs (path, &fsd) < 0) + return -1; + /* f_frsize isn't guaranteed to be supported. */ + +#endif /* STAT_STATVFS */ + +#if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS) + /* !Ultrix && !SVR2 */ + + fsp->fsu_blocks = CONVERT_BLOCKS (fsd.f_blocks); + fsp->fsu_bfree = CONVERT_BLOCKS (fsd.f_bfree); + fsp->fsu_bavail = CONVERT_BLOCKS (fsd.f_bavail); + fsp->fsu_files = fsd.f_files; + fsp->fsu_ffree = fsd.f_ffree; + +#endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */ + + return 0; +} + +#if defined(_AIX) && defined(_I386) +/* AIX PS/2 does not supply statfs. */ + +int +statfs (path, fsb) + char *path; + struct statfs *fsb; +{ + struct stat stats; + struct dustat fsd; + + if (stat (path, &stats)) + return -1; + if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd))) + return -1; + fsb->f_type = 0; + fsb->f_bsize = fsd.du_bsize; + fsb->f_blocks = fsd.du_fsize - fsd.du_isize; + fsb->f_bfree = fsd.du_tfree; + fsb->f_bavail = fsd.du_tfree; + fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb; + fsb->f_ffree = fsd.du_tinode; + fsb->f_fsid.val[0] = fsd.du_site; + fsb->f_fsid.val[1] = fsd.du_pckno; + return 0; +} + +#endif /* _AIX && _I386 */ diff --git a/sysdeps/common/fsusage.h b/sysdeps/common/fsusage.h new file mode 100644 index 00000000..227c5b45 --- /dev/null +++ b/sysdeps/common/fsusage.h @@ -0,0 +1,37 @@ +/* fsusage.h -- declarations for filesystem space usage info + Copyright (C) 1991, 1992 Free Software Foundation, Inc. + + This program 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. + + This program 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 this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Space usage statistics for a filesystem. Blocks are 512-byte. */ +struct fs_usage +{ + long fsu_blocks; /* Total blocks. */ + long fsu_bfree; /* Free blocks available to superuser. */ + long fsu_bavail; /* Free blocks available to non-superuser. */ + long fsu_files; /* Total file nodes. */ + long fsu_ffree; /* Free file nodes. */ +}; + +#ifndef __P +#if defined (__GNUC__) || (defined (__STDC__) && __STDC__) +#define __P(args) args +#else +#define __P(args) () +#endif /* GCC. */ +#endif /* Not __P. */ + +int get_fs_usage __P ((const char *path, const char *disk, + struct fs_usage *fsp)); diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c new file mode 100644 index 00000000..cfe144e8 --- /dev/null +++ b/sysdeps/common/mountlist.c @@ -0,0 +1,577 @@ +/* mountlist.c -- return a list of mounted filesystems + Copyright (C) 1991, 1992 Free Software Foundation, Inc. + + This program 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. + + This program 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 this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include "mountlist.h" + +#ifdef STDC_HEADERS +#include +#else +void free (); +#endif +#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) +#include +#else +#include +#endif + +char *strstr (); +char *xmalloc (); +char *xrealloc (); +char *xstrdup (); +void error (); + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */ +# include +# include +#endif /* MOUNTED_GETFSSTAT */ + +#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ +#include +#if !defined(MOUNTED) +# if defined(MNT_MNTTAB) /* HP-UX. */ +# define MOUNTED MNT_MNTTAB +# endif +# if defined(MNTTABNAME) /* Dynix. */ +# define MOUNTED MNTTABNAME +# endif +#endif +#endif + +#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ +#include +#endif + +#ifdef MOUNTED_GETMNT /* Ultrix. */ +#include +#include +#endif + +#ifdef MOUNTED_FREAD /* SVR2. */ +#include +#endif + +#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */ +#include +#include +#include +#endif + +#ifdef MOUNTED_LISTMNTENT +#include +#endif + +#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ +#include +#endif + +#ifdef MOUNTED_VMOUNT /* AIX. */ +#include +#include +#endif + +#ifdef DOLPHIN +/* So special that it's not worth putting this in autoconf. */ +#undef MOUNTED_FREAD_FSTYP +#define MOUNTED_GETMNTTBL +#endif + +#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ +/* Return the value of the hexadecimal number represented by CP. + No prefix (like '0x') or suffix (like 'h') is expected to be + part of CP. */ + +static int +xatoi (cp) + char *cp; +{ + int val; + + val = 0; + while (*cp) + { + if (*cp >= 'a' && *cp <= 'f') + val = val * 16 + *cp - 'a' + 10; + else if (*cp >= 'A' && *cp <= 'F') + val = val * 16 + *cp - 'A' + 10; + else if (*cp >= '0' && *cp <= '9') + val = val * 16 + *cp - '0'; + else + break; + cp++; + } + return val; +} +#endif /* MOUNTED_GETMNTENT1. */ + +#if defined (MOUNTED_GETMNTINFO) && !defined (__NetBSD__) +static char * +fstype_to_string (t) + short t; +{ + switch (t) + { +#ifdef MOUNT_PC + case MOUNT_PC: + return "pc"; +#endif +#ifdef MOUNT_MFS + case MOUNT_MFS: + return "mfs"; +#endif +#ifdef MOUNT_LO + case MOUNT_LO: + return "lo"; +#endif +#ifdef MOUNT_TFS + case MOUNT_TFS: + return "tfs"; +#endif +#ifdef MOUNT_TMP + case MOUNT_TMP: + return "tmp"; +#endif +#ifdef MOUNT_UFS + case MOUNT_UFS: + return "ufs" ; +#endif +#ifdef MOUNT_NFS + case MOUNT_NFS: + return "nfs" ; +#endif +#ifdef MOUNT_MSDOS + case MOUNT_MSDOS: + return "msdos" ; +#endif +#ifdef MOUNT_LFS + case MOUNT_LFS: + return "lfs" ; +#endif +#ifdef MOUNT_LOFS + case MOUNT_LOFS: + return "lofs" ; +#endif +#ifdef MOUNT_FDESC + case MOUNT_FDESC: + return "fdesc" ; +#endif +#ifdef MOUNT_PORTAL + case MOUNT_PORTAL: + return "portal" ; +#endif +#ifdef MOUNT_NULL + case MOUNT_NULL: + return "null" ; +#endif +#ifdef MOUNT_UMAP + case MOUNT_UMAP: + return "umap" ; +#endif +#ifdef MOUNT_KERNFS + case MOUNT_KERNFS: + return "kernfs" ; +#endif +#ifdef MOUNT_PROCFS + case MOUNT_PROCFS: + return "procfs" ; +#endif +#ifdef MOUNT_AFS + case MOUNT_AFS: + return "afs" ; +#endif +#ifdef MOUNT_CD9660 + case MOUNT_CD9660: + return "cd9660" ; +#endif +#ifdef MOUNT_UNION + case MOUNT_UNION: + return "union" ; +#endif +#ifdef MOUNT_DEVFS + case MOUNT_DEVFS: + return "devfs" ; +#endif +#ifdef MOUNT_EXT2FS + case MOUNT_EXT2FS: + return "ext2fs" ; +#endif + default: + return "?"; + } +} +#endif /* MOUNTED_GETMNTINFO */ + +#ifdef MOUNTED_VMOUNT /* AIX. */ +static char * +fstype_to_string (t) + int t; +{ + struct vfs_ent *e; + + e = getvfsbytype (t); + if (!e || !e->vfsent_name) + return "none"; + else + return e->vfsent_name; +} +#endif /* MOUNTED_VMOUNT */ + +/* Return a list of the currently mounted filesystems, or NULL on error. + Add each entry to the tail of the list so that they stay in order. + If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in + the returned list are valid. Otherwise, they might not be. + If ALL_FS is zero, do not return entries for filesystems that + are automounter (dummy) entries. */ + +struct mount_entry * +read_filesystem_list (need_fs_type, all_fs) + int need_fs_type, all_fs; +{ + struct mount_entry *mount_list; + struct mount_entry *me; + struct mount_entry *mtail; + + /* Start the list off with a dummy entry. */ + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_next = NULL; + mount_list = mtail = me; + +#ifdef MOUNTED_LISTMNTENT + { + struct tabmntent *mntlist, *p; + struct mntent *mnt; + struct mount_entry *me; + + /* the third and fourth arguments could be used to filter mounts, + but Crays doesn't seem to have any mounts that we want to + remove. Specifically, automount create normal NFS mounts. + */ + + if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0) + return NULL; + p = mntlist; + while(p){ + mnt = p->ment; + me = (struct mount_entry*) xmalloc(sizeof (struct mount_entry)); + me->me_devname = xstrdup(mnt->mnt_fsname); + me->me_mountdir = xstrdup(mnt->mnt_dir); + me->me_type = xstrdup(mnt->mnt_type); + me->me_dev = -1; + me->me_next = NULL; + mtail->me_next = me; + mtail = me; + p = p->next; + } + freemntlist(mntlist); + } +#endif + +#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ + { + struct mntent *mnt; + char *table = MOUNTED; + FILE *fp; + char *devopt; + + fp = setmntent (table, "r"); + if (fp == NULL) + return NULL; + + while ((mnt = getmntent (fp))) + { + if (!all_fs && (!strcmp (mnt->mnt_type, "ignore") + || !strcmp (mnt->mnt_type, "auto"))) + continue; + + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_devname = xstrdup (mnt->mnt_fsname); + me->me_mountdir = xstrdup (mnt->mnt_dir); + me->me_type = xstrdup (mnt->mnt_type); + devopt = strstr (mnt->mnt_opts, "dev="); + if (devopt) + { + if (devopt[4] == '0' && (devopt[5] == 'x' || devopt[5] == 'X')) + me->me_dev = xatoi (devopt + 6); + else + me->me_dev = xatoi (devopt + 4); + } + else + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + + if (endmntent (fp) == 0) + return NULL; + } +#endif /* MOUNTED_GETMNTENT1. */ + +#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ + { + struct statfs *fsp; + int entries; + + entries = getmntinfo (&fsp, MNT_NOWAIT); + if (entries < 0) + return NULL; + while (entries-- > 0) + { + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_devname = xstrdup (fsp->f_mntfromname); + me->me_mountdir = xstrdup (fsp->f_mntonname); +#ifdef __NetBSD__ + me->me_type = xstrdup (fsp->f_fstypename); +#else + me->me_type = fstype_to_string (fsp->f_type); +#endif + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + fsp++; + } + } +#endif /* MOUNTED_GETMNTINFO */ + +#ifdef MOUNTED_GETMNT /* Ultrix. */ + { + int offset = 0; + int val; + struct fs_data fsd; + + while ((val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, + (char *) 0)) > 0) + { + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_devname = xstrdup (fsd.fd_req.devname); + me->me_mountdir = xstrdup (fsd.fd_req.path); + me->me_type = gt_names[fsd.fd_req.fstype]; + me->me_dev = fsd.fd_req.dev; + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + if (val < 0) + return NULL; + } +#endif /* MOUNTED_GETMNT. */ + +#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */ + { + int numsys, counter, bufsize; + struct statfs *stats; + + numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); + if (numsys < 0) + return (NULL); + + bufsize = (1 + numsys) * sizeof (struct statfs); + stats = (struct statfs *)xmalloc (bufsize); + numsys = getfsstat (stats, bufsize, MNT_WAIT); + + if (numsys < 0) + { + free (stats); + return (NULL); + } + + for (counter = 0; counter < numsys; counter++) + { + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_devname = xstrdup (stats[counter].f_mntfromname); + me->me_mountdir = xstrdup (stats[counter].f_mntonname); + me->me_type = mnt_names[stats[counter].f_type]; + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + + free (stats); + } +#endif /* MOUNTED_GETFSSTAT */ + +#if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23]. */ + { + struct mnttab mnt; + char *table = "/etc/mnttab"; + FILE *fp; + + fp = fopen (table, "r"); + if (fp == NULL) + return NULL; + + while (fread (&mnt, sizeof mnt, 1, fp) > 0) + { + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); +#ifdef GETFSTYP /* SVR3. */ + me->me_devname = xstrdup (mnt.mt_dev); +#else + me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6); + strcpy (me->me_devname, "/dev/"); + strcpy (me->me_devname + 5, mnt.mt_dev); +#endif + me->me_mountdir = xstrdup (mnt.mt_filsys); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me->me_type = ""; +#ifdef GETFSTYP /* SVR3. */ + if (need_fs_type) + { + struct statfs fsd; + char typebuf[FSTYPSZ]; + + if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1 + && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) + me->me_type = xstrdup (typebuf); + } +#endif + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + + if (fclose (fp) == EOF) + return NULL; + } +#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */ + +#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes it's own way */ + { + struct mntent **mnttbl=getmnttbl(),**ent; + for (ent=mnttbl;*ent;ent++) + { + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_devname = xstrdup ( (*ent)->mt_resource); + me->me_mountdir = xstrdup( (*ent)->mt_directory); + me->me_type = xstrdup ((*ent)->mt_fstype); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + endmnttbl(); + } +#endif + +#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ + { + struct mnttab mnt; + char *table = MNTTAB; + FILE *fp; + int ret; + + fp = fopen (table, "r"); + if (fp == NULL) + return NULL; + + while ((ret = getmntent (fp, &mnt)) == 0) + { + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_devname = xstrdup (mnt.mnt_special); + me->me_mountdir = xstrdup (mnt.mnt_mountp); + me->me_type = xstrdup (mnt.mnt_fstype); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + + if (ret > 0) + return NULL; + if (fclose (fp) == EOF) + return NULL; + } +#endif /* MOUNTED_GETMNTENT2. */ + +#ifdef MOUNTED_VMOUNT /* AIX. */ + { + int bufsize; + char *entries, *thisent; + struct vmount *vmp; + + /* Ask how many bytes to allocate for the mounted filesystem info. */ + mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize); + entries = xmalloc (bufsize); + + /* Get the list of mounted filesystems. */ + mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries); + + for (thisent = entries; thisent < entries + bufsize; + thisent += vmp->vmt_length) + { + vmp = (struct vmount *) thisent; + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + if (vmp->vmt_flags & MNT_REMOTE) + { + char *host, *path; + + /* Prepend the remote pathname. */ + host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off; + path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off; + me->me_devname = xmalloc (strlen (host) + strlen (path) + 2); + strcpy (me->me_devname, host); + strcat (me->me_devname, ":"); + strcat (me->me_devname, path); + } + else + { + me->me_devname = xstrdup (thisent + + vmp->vmt_data[VMT_OBJECT].vmt_off); + } + me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); + me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); + me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + free (entries); + } +#endif /* MOUNTED_VMOUNT. */ + + /* Free the dummy head. */ + me = mount_list; + mount_list = mount_list->me_next; + free (me); + return mount_list; +} diff --git a/sysdeps/common/mountlist.h b/sysdeps/common/mountlist.h new file mode 100644 index 00000000..0a6e6d8b --- /dev/null +++ b/sysdeps/common/mountlist.h @@ -0,0 +1,32 @@ +/* mountlist.h -- declarations for list of mounted filesystems + Copyright (C) 1991, 1992 Free Software Foundation, Inc. + + This program 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. + + This program 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 this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* A mount table entry. */ +struct mount_entry +{ + char *me_devname; /* Device node pathname, including "/dev/". */ + char *me_mountdir; /* Mount point directory pathname. */ + char *me_type; /* "nfs", "4.2", etc. */ + dev_t me_dev; /* Device number of me_mountdir. */ + struct mount_entry *me_next; +}; + +#if __STDC__ +struct mount_entry *read_filesystem_list (int need_fs_type, int all_fs); +#else +struct mount_entry *read_filesystem_list (); +#endif From 1d7491be0dcfd8826ef3522da939b89e86ce0cdc Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 6 Jul 1998 22:44:40 +0000 Subject: [PATCH 0162/2539] Importing from GNU Fileutils 3.16. From 576dde394a69510f98307f53a93002c91271de24 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 6 Jul 1998 22:48:25 +0000 Subject: [PATCH 0163/2539] using g_malloc, g_realloc and g_strdup. * mountlist.c: using g_malloc, g_realloc and g_strdup. --- sysdeps/common/mountlist.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c index cfe144e8..c56824be 100644 --- a/sysdeps/common/mountlist.c +++ b/sysdeps/common/mountlist.c @@ -34,10 +34,17 @@ void free (); #include #endif +#include + +#undef xmalloc +#undef xrealloc +#undef xstrdup + +#define xmalloc g_malloc +#define xrealloc g_realloc +#define xstrdup g_strdup + char *strstr (); -char *xmalloc (); -char *xrealloc (); -char *xstrdup (); void error (); #ifdef HAVE_SYS_PARAM_H From 7d8ff8f72ed5dbbe39c7b5bb1ec6525a9ecfc350 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 6 Jul 1998 22:51:12 +0000 Subject: [PATCH 0164/2539] *** empty log message *** --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 87de4161..4a24ded4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1998-07-06 Martin Baulig + + * sysdeps/common/{fsusage, mountlist}.[ch]: + Imported from GNU Fileutils 3.16. + + * sysdeps/common/mountlist.c: using g_malloc, g_realloc and g_strdup. + 1998-07-03 Martin baulig * macros/gnome-libgtop-sysdeps.m4: No longer use From 2aa20e2060232a1a3a060f63c04c85616ce2eeaa Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 6 Jul 1998 23:00:48 +0000 Subject: [PATCH 0165/2539] New macros. 1998-07-06 Martin Baulig * acconfig.h (AFS, MOUNTED_FREAD, MOUNTED_FREAD_FSTYP, MOUNTED_GETFSSTAT, MOUNTED_GETMNT, MOUNTED_GETMNTENT1, MOUNTED_GETMNTENT2, MOUNTED_GETMNTINFO, MOUNTED_LISTMNTENT, MOUNTED_VMOUNT, STAT_STATFS3_OSF1, STAT_READ_FILSYS, STAT_STATFS2_BSIZE, STAT_STATFS2_FSIZE, STAT_STATFS2_FS_DATA, STAT_STATFS4, STAT_STATVFS, STATFS_TRUNCATES_BLOCK_COUNTS): New macros. * configure.in: added GNOME_FILEUTILS_CHECKS. --- acconfig.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 2 ++ 2 files changed, 81 insertions(+) diff --git a/acconfig.h b/acconfig.h index 17419302..cb99bfe2 100644 --- a/acconfig.h +++ b/acconfig.h @@ -12,6 +12,85 @@ /* Do not remove this comments and the empty lines; they are needed */ #undef HAVE_PROGRAM_INVOCATION_SHORT_NAME +/* Define if you have the Andrew File System. */ +#undef AFS + +/* Define one of the following to indicate how a program can + get a list of mounted filesystems. */ + +/* Define if there is no specific function for reading the list of + mounted filesystems. fread will be used to read /etc/mnttab. [SVR2] */ +#undef MOUNTED_FREAD + +/* Define if (like SVR2) there is no specific function for reading the + list of mounted filesystems, and your system has these header files: + and . [SVR3] */ +#undef MOUNTED_FREAD_FSTYP + +/* Define if there is a function named getfsstat for reading the list + of mounted filesystems. [DEC Alpha running OSF/1] */ +#undef MOUNTED_GETFSSTAT + +/* Define if there is a function named getmnt for reading the list of + mounted filesystems. [Ultrix] */ +#undef MOUNTED_GETMNT + +/* Define if there is a function named getmntent for reading the list + of mounted filesystems, and that function takes a single argument. + [4.3BSD, SunOS, HP-UX, Dynix, Irix] */ +#undef MOUNTED_GETMNTENT1 + +/* Define if there is a function named getmntent for reading the list of + mounted filesystems, and that function takes two arguments. [SVR4] */ +#undef MOUNTED_GETMNTENT2 + +/* Define if there is a function named getmntinfo for reading the list + of mounted filesystems. [4.4BSD] */ +#undef MOUNTED_GETMNTINFO + +/* Define if there is a function named listmntent that can be used to + list all mounted filesystems. [UNICOS] */ +#undef MOUNTED_LISTMNTENT + +/* Define if there is a function named mntctl that can be used to read + the list of mounted filesystems, and there is a system header file + that declares `struct vmount.' [AIX] */ +#undef MOUNTED_VMOUNT + +/* Define one of the following to indicate how a program can obtain + filesystems usage information. */ + +/* Define if statfs takes 3 args. [DEC Alpha running OSF/1] */ +#undef STAT_STATFS3_OSF1 + +/* Define if there is no specific function for reading filesystems usage + information and you have the header file. [SVR2] */ +#undef STAT_READ_FILSYS + +/* Define if statfs takes 2 args and struct statfs has a field named f_bsize. + [4.3BSD, SunOS 4, HP-UX, AIX PS/2] */ +#undef STAT_STATFS2_BSIZE + +/* Define if statfs takes 2 args and struct statfs has a field named f_fsize. + [4.4BSD, NetBSD] */ +#undef STAT_STATFS2_FSIZE + +/* Define if statfs takes 2 args and the second argument has + type struct fs_data. [Ultrix] */ +#undef STAT_STATFS2_FS_DATA + +/* Define if statfs takes 4 args. [SVR3, Dynix, Irix, Dolphin] */ +#undef STAT_STATFS4 + +/* Define if there is a function named statvfs. [SVR4] */ +#undef STAT_STATVFS + +/* Define if the block counts reported by statfs may be truncated to 2GB + and the correct values may be stored in the f_spare array. + [SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. + SunOS 4.1.1 seems not to be affected.] */ +#undef STATFS_TRUNCATES_BLOCK_COUNTS + /* to fix a bug in autoheader on DEC OSF1. */ #undef HAVE_PROGRAM_INVOCATION_NAME diff --git a/configure.in b/configure.in index ce320244..6d26d22c 100644 --- a/configure.in +++ b/configure.in @@ -125,6 +125,8 @@ if test "$with_xauth" = "yes"; then fi AC_SUBST(libs_xauth) +dnl For diskusage stuff +GNOME_FILEUTILS_CHECKS CFLAGS="$CFLAGS -D_IN_LIBGTOP" From 0b4f757b2b1d4f791ef85e1f2533587afbafd203 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 7 Jul 1998 00:10:49 +0000 Subject: [PATCH 0166/2539] using functions from `xmalloc.c'. 1998-07-06 Martin Baulig * sysdeps/common/mountlist.c: using functions from `xmalloc.c'. * sysdeps/common/error.c: all functions now accept NULL as `server' argument. --- ChangeLog | 15 +++++++++++++++ sysdeps/common/error.c | 10 ++++++---- sysdeps/common/mountlist.c | 10 ++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a24ded4..ee38badc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 1998-07-06 Martin Baulig + * sysdeps/common/mountlist.c: using functions from `xmalloc.c'. + + * sysdeps/common/error.c: all functions now accept NULL as + `server' argument. + + * acconfig.h (AFS, MOUNTED_FREAD, MOUNTED_FREAD_FSTYP, + MOUNTED_GETFSSTAT, MOUNTED_GETMNT, MOUNTED_GETMNTENT1, + MOUNTED_GETMNTENT2, MOUNTED_GETMNTINFO, MOUNTED_LISTMNTENT, + MOUNTED_VMOUNT, STAT_STATFS3_OSF1, STAT_READ_FILSYS, + STAT_STATFS2_BSIZE, STAT_STATFS2_FSIZE, STAT_STATFS2_FS_DATA, + STAT_STATFS4, STAT_STATVFS, STATFS_TRUNCATES_BLOCK_COUNTS): + New macros. + + * configure.in: added GNOME_FILEUTILS_CHECKS. + * sysdeps/common/{fsusage, mountlist}.[ch]: Imported from GNU Fileutils 3.16. diff --git a/sysdeps/common/error.c b/sysdeps/common/error.c index 55e9e265..df01ede8 100644 --- a/sysdeps/common/error.c +++ b/sysdeps/common/error.c @@ -21,6 +21,8 @@ #include +#define DEFAULT_NAME "ERROR" + /* Prints error message and exits. */ void @@ -30,7 +32,7 @@ glibtop_error_r (glibtop *server, char *format, ...) va_start (ap, format); - fprintf (stderr, "%s: ", server->name); + fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME); vfprintf (stderr, format, ap); fprintf (stderr, "\n"); @@ -45,7 +47,7 @@ glibtop_error_io_r (glibtop *server, char *format, ...) va_start (ap, format); - fprintf (stderr, "%s: ", server->name); + fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME); vfprintf (stderr, format, ap); fprintf (stderr, ": %s\n", strerror (errno)); @@ -60,7 +62,7 @@ glibtop_warn_r (glibtop *server, char *format, ...) va_start (ap, format); - fprintf (stderr, "%s: ", server->name); + fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME); vfprintf (stderr, format, ap); fprintf (stderr, "\n"); @@ -74,7 +76,7 @@ glibtop_warn_io_r (glibtop *server, char *format, ...) va_start (ap, format); - fprintf (stderr, "%s: ", server->name); + fprintf (stderr, "%s: ", server ? server->name : DEFAULT_NAME); vfprintf (stderr, format, ap); fprintf (stderr, ": %s\n", strerror (errno)); diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c index c56824be..69768d10 100644 --- a/sysdeps/common/mountlist.c +++ b/sysdeps/common/mountlist.c @@ -34,15 +34,17 @@ void free (); #include #endif -#include +#include +#include #undef xmalloc #undef xrealloc #undef xstrdup -#define xmalloc g_malloc -#define xrealloc g_realloc -#define xstrdup g_strdup +#define xmalloc(p1) glibtop_malloc_r (NULL, p1) +#define xrealloc(p1,p2) glibtop_realloc_r (NULL, p1, p2) +#define xstrdup(p1) glibtop_strdup_r (NULL, p1) +#define xfree(p1) glibtop_free_r (NULL, p1) char *strstr (); void error (); From eb8d28b694d9432b0a55250f6a01602ca6975071 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 9 Jul 1998 23:03:27 +0000 Subject: [PATCH 0167/2539] Removed `proxy'. This directory is considered obsolete and will be removed 1998-07-10 Martin Baulig * src/Makefile.am (SUBDIRS): Removed `proxy'. This directory is considered obsolete and will be removed soon. --- ChangeLog | 5 +++++ src/Makefile.am | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ee38badc..9f4354b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1998-07-10 Martin Baulig + + * src/Makefile.am (SUBDIRS): Removed `proxy'. This directory + is considered obsolete and will be removed soon. + 1998-07-06 Martin Baulig * sysdeps/common/mountlist.c: using functions from `xmalloc.c'. diff --git a/src/Makefile.am b/src/Makefile.am index 6c285f4f..1f27265f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = server proxy daemon +SUBDIRS = server daemon From b177c3930d94da9d9f8d6bc79a237eefa7a8db5b Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 12 Jul 1998 14:22:45 +0000 Subject: [PATCH 0168/2539] Changed indentation using 'indent -br -ce -sc -pcs -cs -bs -i8 -bad -bap -fca' --- src/daemon/gnuserv.c | 1079 ++++++++++++++++++++---------------------- 1 file changed, 526 insertions(+), 553 deletions(-) diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index 86a2655b..9be15895 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -1,22 +1,22 @@ /* -*-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. -*/ + * 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 + * 11-Nov-1990 bristor@simba * Added EOT stuff. */ @@ -30,7 +30,8 @@ */ #if 0 -static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; +static char rcsid[] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; + #endif #define DEBUG @@ -42,15 +43,16 @@ static char rcsid [] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !" #include #endif -extern void handle_socket_connection __P((glibtop *, int)); +extern void handle_socket_connection __P ((glibtop *, int)); #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 */ + 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 @@ -60,776 +62,747 @@ 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. -*/ + * 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 */ + 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. -*/ + * ipc_handle_signal -- catch the signal given and clean up. + */ void -ipc_handle_signal(int sig) +ipc_handle_signal (int sig) { - ipc_exit (0); -} /* ipc_handle_signal */ + ipc_exit (0); +} /* ipc_handle_signal */ /* - ipc_spawn_watchdog -- spawn a watchdog task to clean up the message queue should the - server process die. -*/ + * 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 */ + 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. -*/ + * 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 */ + key_t key; /* messge key */ + char buf[GSERV_BUFSZ]; /* pathname for key */ - sprintf (buf,"/tmp/lgtd%d",(int)geteuid ()); - creat (buf,0600); - key = ftok (buf,1); + sprintf (buf, "/tmp/lgtd%d", (int) geteuid ()); + creat (buf, 0600); + key = ftok (buf, 1); - if ((ipc_qid = msgget (key,0600|IPC_CREAT)) == -1) - glibtop_error_io ("unable to create msg queue"); + if ((ipc_qid = msgget (key, 0600 | IPC_CREAT)) == -1) + glibtop_error_io ("unable to create msg queue"); - ipc_spawn_watchdog (); + ipc_spawn_watchdog (); - signal (SIGTERM,ipc_handle_signal); - signal (SIGINT,ipc_handle_signal); + signal (SIGTERM, ipc_handle_signal); + signal (SIGINT, ipc_handle_signal); - if ((*msgpp = (struct msgbuf *) - malloc (sizeof **msgpp + GSERV_BUFSZ)) == NULL) - { - glibtop_warn_io ("unable to allocate space for message buffer"); - ipc_exit(1); - } /* if */ -} /* ipc_init */ + if ((*msgpp = (struct msgbuf *) + malloc (sizeof **msgpp + GSERV_BUFSZ)) == NULL) { + glibtop_warn_io ("unable to allocate space for message buffer"); + 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. -*/ + * 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 */ + 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) - { - glibtop_warn_io ("msgrcv"); - ipc_exit (1); - } /* if */ + if ((len = msgrcv (ipc_qid, msgp, GSERV_BUFSZ - 1, 1, 0)) < 0) { + glibtop_warn_io ("msgrcv"); + ipc_exit (1); + } /* if */ + msgctl (ipc_qid, IPC_STAT, &msg_st); + strncpy (buf, msgp->mtext, len); + buf[len] = '\0'; /* terminate */ - msgctl (ipc_qid, IPC_STAT, &msg_st); - strncpy (buf, msgp->mtext, len); - buf[len] = '\0'; /* terminate */ - - printf ("%d %s", ipc_qid, buf); - fflush (stdout); + printf ("%d %s", ipc_qid, buf); + fflush (stdout); - /* now for the response from gnu */ - msgp->mtext[0] = '\0'; + /* now for the response from gnu */ + msgp->mtext[0] = '\0'; #if 0 - if ((len = read(0,buf,GSERV_BUFSZ-1)) < 0) - { - glibtop_warn_io ("read"); - ipc_exit (1); - } /* if */ - - sscanf (buf, "%d:%[^\n]\n", &junk, msgp->mtext); + if ((len = read (0, buf, GSERV_BUFSZ - 1)) < 0) { + glibtop_warn_io ("read"); + ipc_exit (1); + } /* if */ + sscanf (buf, "%d:%[^\n]\n", &junk, msgp->mtext); #else - /* read in "n/m:" (n=client fd, m=message length) */ + /* 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) - glibtop_error_io ("read"); - - /* 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) - glibtop_error_io ("read"); - - /* 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); + while (offset < (GSERV_BUFSZ - 1) && + ((len = read (0, buf + offset, 1)) > 0) && + buf[offset] != ':') { + offset += len; } - result_len -= len; - } + if (len < 0) + glibtop_error_io ("read"); - /* eat the newline */ - while ((len = read (0,buf,1)) == 0) - ; - if (len < 0) - glibtop_error_io ("read"); + /* parse the response from emacs, getting client fd & result length */ + buf[offset] = '\0'; + sscanf (buf, "%d/%d", &s, &result_len); - if (buf[0] != '\n') - glibtop_error ("garbage after result [%c]", buf[0]); + while (result_len > 0) { + if ((len = read (0, buf, min2 (result_len, GSERV_BUFSZ - 1))) < 0) + glibtop_error_io ("read"); + + /* 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) + glibtop_error_io ("read"); + + if (buf[0] != '\n') + glibtop_error ("garbage after result [%c]", buf[0]); #endif - /* Send a response back to the client. */ + /* Send a response back to the client. */ - msgp->mtype = msg_st.msg_lspid; - if (msgsnd (ipc_qid,msgp,strlen(msgp->mtext)+1,0) < 0) - glibtop_warn_io ("msgsend(gnuserv)"); + msgp->mtype = msg_st.msg_lspid; + if (msgsnd (ipc_qid, msgp, strlen (msgp->mtext) + 1, 0) < 0) + glibtop_warn_io ("msgsend(gnuserv)"); -} /* handle_ipc_request */ +} /* 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). -*/ + * 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; + 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); + printf ("%d ", s); - if (buf[len-1] == EOT_CHR) { - fflush(stdout); - break; /* end of message */ - } + /* 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); - } /* while */ + if (buf[len - 1] == EOT_CHR) { + fflush (stdout); + break; /* end of message */ + } + } /* while */ - if (len < 0) - glibtop_error_io ("recv"); - -} /* echo_request */ + if (len < 0) + glibtop_error_io ("recv"); + +} /* echo_request */ /* - handle_response -- accept a response from stdin (the gnu process) and pass the - information on to the relevant client. -*/ + * handle_response -- accept a response from stdin (the gnu process) and pass the + * information on to the relevant client. + */ static void handle_response (void) { #if 0 - char buf[GSERV_BUFSZ+1]; - int offset=0; - int s; - int len; - int result_len; + 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; - } + /* 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) - glibtop_error_io ("read"); - - /* parse the response from emacs, getting client fd & result length */ - buf[offset] = '\0'; - sscanf(buf,"%d/%d", &s, &result_len); + if (len < 0) + glibtop_error_io ("read"); - while (result_len > 0) { - if ((len = read(0,buf,min2(result_len,GSERV_BUFSZ))) < 0) - glibtop_error_io ("read"); + /* parse the response from emacs, getting client fd & result length */ + buf[offset] = '\0'; + sscanf (buf, "%d/%d", &s, &result_len); - buf[len] = '\0'; - send_string(s,buf); - result_len -= len; - } + while (result_len > 0) { + if ((len = read (0, buf, min2 (result_len, GSERV_BUFSZ))) < 0) + glibtop_error_io ("read"); - /* eat the newline */ - while ((len = read(0,buf,1)) == 0) - ; - if (len < 0) - glibtop_error_io ("read"); + buf[len] = '\0'; + send_string (s, buf); + result_len -= len; + } - if (buf[0] != '\n') - glibtop_error ("garbage after result"); + /* eat the newline */ + while ((len = read (0, buf, 1)) == 0); + if (len < 0) + glibtop_error_io ("read"); - /* send the newline */ - buf[1] = '\0'; - send_string(s,buf); - close(s); + if (buf[0] != '\n') + glibtop_error ("garbage after result"); + + /* send the newline */ + buf[1] = '\0'; + send_string (s, buf); + close (s); #else - glibtop_error ("handle_response (): Function not implemented"); + glibtop_error ("handle_response (): Function not implemented"); #endif -} /* handle_response */ +} /* handle_response */ + #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ #ifdef INTERNET_DOMAIN_SOCKETS struct entry { - u_long host_addr; - struct entry *next; + u_long host_addr; + struct entry *next; }; struct entry *permitted_hosts[TABLE_SIZE]; #ifdef AUTH_MAGIC_COOKIE -# include -# include +#include +#include static Xauth *server_xauth = NULL; -#endif -static int +#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_set rmask; + struct timeval tv; /* = {timeout, 0}; */ + char c = 0; + int nbytes = 0; + int r; - FD_ZERO(&rmask); - FD_SET(fd, &rmask); - - do - { - r = select(fd + 1, &rmask, NULL, NULL, &tv); + tv.tv_sec = timeout; + tv.tv_usec = 0; - if (r > 0) - { - if (read (fd, &c, 1) == 1 ) - { - *buf++ = c; - ++nbytes; - } - else - { - glibtop_warn_io ("read error on socket"); - return -1; - } + 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 { + glibtop_warn_io ("read error on socket"); + return -1; + } + } else if (r == 0) { + glibtop_warn ("read timed out"); + return -1; + } else { + glibtop_warn_io ("error in select"); + return -1; + } + } while ((nbytes < max) && !(one_line && (c == '\n'))); + + --buf; + if (one_line && *buf == '\n') { + *buf = 0; } - else if (r == 0) - { - glibtop_warn ("read timed out"); - return -1; - } - else - { - glibtop_warn_io ("error in select"); - return -1; - } - } while ((nbytes < max) && !(one_line && (c == '\n'))); - - --buf; - if (one_line && *buf == '\n') - { - *buf = 0; - } - - return nbytes; + return nbytes; } - - + + /* - permitted -- return whether a given host is allowed to connect to the server. -*/ + * 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; + int key; + struct entry *entry; - char auth_protocol[128]; - char buf[1024]; - int auth_data_len; + char auth_protocol[128]; + char buf[1024]; + int auth_data_len; - if (fd > 0) - { - /* we are checking permission on a real connection */ + 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; + /* Read auth protocol name */ + + if (timed_read (fd, auth_protocol, AUTH_NAMESZ, AUTH_TIMEOUT, 1) <= 0) + return FALSE; #ifdef DEBUG - fprintf (stderr, "Client sent authenticatin protocol '%s'\n", auth_protocol); + fprintf (stderr, "Client sent authenticatin protocol '%s'\n", auth_protocol); #endif - if (strcmp (auth_protocol, DEFAUTH_NAME) && - strcmp (auth_protocol, MCOOKIE_NAME)) - { - glibtop_warn ("Authentication protocol from client is invalid", auth_protocol); - - return FALSE; - } + if (strcmp (auth_protocol, DEFAUTH_NAME) && + strcmp (auth_protocol, MCOOKIE_NAME)) { + glibtop_warn ("Authentication protocol from client is invalid", auth_protocol); - if (!strcmp (auth_protocol, MCOOKIE_NAME)) - { + return FALSE; + } + if (!strcmp (auth_protocol, MCOOKIE_NAME)) { - /* - * doing magic cookie auth - */ + /* + * doing magic cookie auth + */ - if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) - return FALSE; + if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) + return FALSE; - auth_data_len = atoi (buf); + auth_data_len = atoi (buf); + + if (timed_read (fd, buf, auth_data_len, AUTH_TIMEOUT, 0) != auth_data_len) + return FALSE; - 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 - glibtop_warn ("client tried Xauth, but server is not compiled with Xauth"); + if (server_xauth && server_xauth->data && + !memcmp (buf, server_xauth->data, auth_data_len)) { + return TRUE; + } +#else + glibtop_warn ("client tried Xauth, but server is not compiled with Xauth"); #endif - - /* - * auth failed, but allow this to fall through to the GNU_SECURE - * protocol.... - */ - glibtop_warn ("Xauth authentication failed, trying GNU_SECURE auth..."); - + /* + * auth failed, but allow this to fall through to the GNU_SECURE + * protocol.... + */ + + glibtop_warn ("Xauth authentication failed, trying GNU_SECURE auth..."); + + } + /* Other auth protocols go here, and should execute only if + * the * auth_protocol name matches. */ + } - - /* Other auth protocols go here, and should execute only if the - * auth_protocol name matches. - */ + /* Now, try the old GNU_SECURE stuff... */ - } - - - /* Now, try the old GNU_SECURE stuff... */ - - /* First find the hash key */ - key = HASH(host_addr) % TABLE_SIZE; + /* First find the hash key */ + key = HASH (host_addr) % TABLE_SIZE; #ifdef DEBUG - fprintf (stderr, "Doing GNU_SECURE auth ...\n"); + fprintf (stderr, "Doing GNU_SECURE auth ...\n"); #endif - - /* Now check the chain for that hash key */ - for(entry = permitted_hosts [key]; entry != NULL; entry = entry->next) { -#ifdef DEBUG - fprintf (stderr, "Trying %ld\n", entry->host_addr); -#endif - if (host_addr == entry->host_addr) - return(TRUE); - } - - return(FALSE); -} /* permitted */ + /* Now check the chain for that hash key */ + for (entry = permitted_hosts[key]; entry != NULL; entry = entry->next) { +#ifdef DEBUG + fprintf (stderr, "Trying %ld\n", entry->host_addr); +#endif + 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. -*/ + * 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) - glibtop_error_io ("unable to malloc space for permitted host entry"); + int key; + struct entry *new_entry; - new_entry->host_addr = host_addr; - key = HASH(host_addr) % TABLE_SIZE; - new_entry->next = permitted_hosts[key]; - permitted_hosts[key] = new_entry; - } /* if */ + if (!permitted (host_addr, -1)) { + if ((new_entry = (struct entry *) malloc (sizeof (struct entry))) == NULL) + glibtop_error_io ("unable to malloc space for permitted host entry"); -} /* add_host */ + 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. -*/ + * 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; + FILE *host_file; + char *file_name; + char hostname[HOSTNAMSZ]; + u_int host_addr; + int i, hosts = 0; - gethostname (hostname, HOSTNAMSZ); + /* Make sure every entry is null */ + for (i = 0; i < TABLE_SIZE; i++) + permitted_hosts[i] = NULL; - if (((long) host_addr = glibtop_internet_addr (hostname)) == -1) - glibtop_error ("unable to find %s in /etc/hosts or from YP", hostname); + gethostname (hostname, HOSTNAMSZ); + + if (((long) host_addr = glibtop_internet_addr (hostname)) == -1) + glibtop_error ("unable to find %s in /etc/hosts or from YP", hostname); #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++; + + 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 */ - hosts++; -#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 (((long) host_addr = glibtop_internet_addr (hostname)) != -1)/* get its addr */ - { - add_host (host_addr); /* add the addr */ - hosts++; - } - fclose (host_file); - } /* if */ +#if 0 /* Don't even want to allow access from the + * local host by default */ + add_host (host_addr); /* add local host */ + hosts++; +#endif - return hosts; -} /* setup_table */ + 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 (((long) host_addr = glibtop_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. -*/ + * 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 */ + 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; + 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; + /* clear out address structure */ + memset ((char *) &server, 0, sizeof (struct sockaddr_in)); - /* 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) - glibtop_error_io ("unable to create socket"); - - /* Bind the listen address to the socket. */ - if (bind(ls,(struct sockaddr *) &server,sizeof(struct sockaddr_in)) == -1) - glibtop_error_io ("bind"); + /* Set up address structure for the listen socket. */ + server.sin_family = AF_INET; + server.sin_addr.s_addr = INADDR_ANY; - /* Initiate the listen on the socket so remote users - * can connect. - */ - if (listen(ls,20) == -1) - glibtop_error_io ("listen"); + /* 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; - return(ls); + /* Create the listen socket. */ + if ((ls = socket (AF_INET, SOCK_STREAM, 0)) == -1) + glibtop_error_io ("unable to create socket"); -} /* internet_init */ + /* Bind the listen address to the socket. */ + if (bind (ls, (struct sockaddr *) &server, sizeof (struct sockaddr_in)) == -1) + glibtop_error_io ("bind"); + + /* Initiate the listen on the socket so remote users * can connect. */ + if (listen (ls, 20) == -1) + glibtop_error_io ("listen"); + + return (ls); + +} /* internet_init */ /* - handle_internet_request -- accept a request from a client and send the information - to stdout (the gnu process). -*/ + * 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 */ + 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)); + memset ((char *) &peer, 0, sizeof (struct sockaddr_in)); - if ((s = accept (ls, (struct sockaddr *)&peer, (void *) &addrlen)) == -1) - glibtop_error_io ("accept"); + if ((s = accept (ls, (struct sockaddr *) &peer, (void *) &addrlen)) == -1) + glibtop_error_io ("accept"); #ifdef DEBUG - fprintf (stderr, "Connection was made from %s.\n", inet_ntoa (peer.sin_addr)); + fprintf (stderr, "Connection was made from %s.\n", inet_ntoa (peer.sin_addr)); #endif - - /* Check that access is allowed - if not return crud to the client */ - if (!permitted (peer.sin_addr.s_addr, s)) - { - close(s); - glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr)); - return; - } /* if */ + + /* Check that access is allowed - if not return crud to the client */ + if (!permitted (peer.sin_addr.s_addr, s)) { + close (s); + glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr)); + return; + } /* if */ +#tifdef DEBUG + fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr)); +#endif + + handle_socket_connection (&glibtop_global_server, s); + + close (s); #ifdef DEBUG - fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr)); + fprintf (stderr, "Closed connection to %s.\n", inet_ntoa (peer.sin_addr)); #endif - handle_socket_connection (&glibtop_global_server, s); - - close (s); - -#ifdef DEBUG - fprintf (stderr, "Closed connection to %s.\n", inet_ntoa (peer.sin_addr)); -#endif - -} /* handle_internet_request */ +} /* 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. -*/ + * 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; + int ls; /* socket descriptor */ + struct sockaddr_un server; /* unix socket address */ + int bindlen; - if ((ls = socket (AF_UNIX,SOCK_STREAM, 0)) < 0) - glibtop_error_io ("unable to create socket"); + if ((ls = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) + glibtop_error_io ("unable to create socket"); - /* Set up address structure for the listen socket. */ + /* Set up address structure for the listen socket. */ #ifdef HIDE_UNIX_SOCKET - sprintf (server.sun_path, "/tmp/lgtddir%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) - glibtop_error_io ("Can't set permissions on %s", server.sun_path); - } - strcat(server.sun_path, "/lgtd"); - unlink(server.sun_path); /* remove old file if it exists */ + sprintf (server.sun_path, "/tmp/lgtddir%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) + glibtop_error_io ("Can't set permissions on %s", server.sun_path); + } + strcat (server.sun_path, "/lgtd"); + unlink (server.sun_path); /* remove old file if it exists */ #else /* HIDE_UNIX_SOCKET */ - sprintf(server.sun_path, "/tmp/lgtd%d", (int)geteuid()); - unlink(server.sun_path); /* remove old file if it exists */ + sprintf (server.sun_path, "/tmp/lgtd%d", (int) geteuid ()); + unlink (server.sun_path); /* remove old file if it exists */ #endif /* HIDE_UNIX_SOCKET */ - server.sun_family = AF_UNIX; + 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; + /* 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); + bindlen = strlen (server.sun_path) + sizeof (server.sun_family); #endif - - if (bind (ls, (struct sockaddr *)&server, bindlen) < 0) - glibtop_error_io ("bind"); - chmod(server.sun_path,0700); /* only this user can send commands */ + if (bind (ls, (struct sockaddr *) &server, bindlen) < 0) + glibtop_error_io ("bind"); - if (listen(ls,20) < 0) - glibtop_error_io ("listen"); + chmod (server.sun_path, 0700); /* only this user can send commands */ - /* #### there are also better ways of dealing with this when - sigvec() is present. */ + if (listen (ls, 20) < 0) + glibtop_error_io ("listen"); + + /* #### 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); - } + { + sigset_t _mask; + + sigemptyset (&_mask); + sigaddset (&_mask, SIGPIPE); + sigprocmask (SIG_BLOCK, &_mask, NULL); + } #else - signal (SIGPIPE, SIG_IGN); /* in case user kills client */ + signal (SIGPIPE, SIG_IGN); /* in case user kills client */ #endif - return (ls); + return (ls); -} /* unix_init */ +} /* unix_init */ /* - handle_unix_request -- accept a request from a client and send the information - to stdout (the gnu process). -*/ + * 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 */ + int s; + size_t len = sizeof (struct sockaddr_un); + struct sockaddr_un server; /* for unix socket address */ - server.sun_family = AF_UNIX; + server.sun_family = AF_UNIX; - if ((s = accept (ls, (struct sockaddr *)&server, (void *)&len)) < 0) - glibtop_error_io ("accept"); + if ((s = accept (ls, (struct sockaddr *) &server, (void *) &len)) < 0) + glibtop_error_io ("accept"); + + echo_request (s); + +} /* handle_unix_request */ - echo_request(s); - -} /* handle_unix_request */ #endif /* UNIX_DOMAIN_SOCKETS */ int -main(argc,argv) +main (argc, argv) int argc; char *argv[]; { - int chan; /* temporary channel number */ - int ils = -1; /* internet domain listen socket */ - int uls = -1; /* unix domain listen socket */ + int chan; /* temporary channel number */ + int ils = -1; /* internet domain listen socket */ + int uls = -1; /* unix domain listen socket */ + #ifdef SYSV_IPC - struct msgbuf *msgp; /* message buffer */ + struct msgbuf *msgp; /* message buffer */ + #endif /* SYSV_IPC */ - glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE); + glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE); - for(chan=3; chan < _NFILE; close(chan++)) /* close unwanted channels */ - ; + 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 */ + 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 */ + 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 */ + uls = unix_init (); /* get a unix domain socket to listen on */ #endif /* UNIX_DOMAIN_SOCKETS */ - while (1) { + while (1) { #ifdef SYSV_IPC - handle_ipc_request(msgp); + 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); + 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); #ifdef DEBUG - fprintf (stderr, "Server ready and waiting for connections.\n"); + fprintf (stderr, "Server ready and waiting for connections.\n"); #endif - - if (select(max2(fileno(stdin),max2(uls,ils)) + 1, &rmask, - (fd_set *)NULL, (fd_set *)NULL, (struct timeval *)NULL) < 0) - glibtop_error_io ("select"); + + if (select (max2 (fileno (stdin), max2 (uls, ils)) + 1, &rmask, + (fd_set *) NULL, (fd_set *) NULL, (struct timeval *) NULL) < 0) + glibtop_error_io ("select"); #ifdef UNIX_DOMAIN_SOCKETS - if (uls > 0 && FD_ISSET(uls, &rmask)) - handle_unix_request(uls); + 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); + 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(); + if (FD_ISSET (fileno (stdin), &rmask)) /* from stdin (gnu + * process) */ + handle_response (); #endif /* NOT SYSV_IPC */ - } /* while */ + } /* while */ - return 0; -} /* main */ + return 0; +} /* main */ #endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */ From 61071132bf39cbfe7e7d3911724d1ef6a2335bff Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 12 Jul 1998 14:24:49 +0000 Subject: [PATCH 0169/2539] Changed indentation using 'indent -br -ce -sc -pcs -cs -bs -i8 -bad -bap -fca ' --- sysdeps/common/gnuslib.c | 552 ++++++++++++++++++++------------------- 1 file changed, 285 insertions(+), 267 deletions(-) diff --git a/sysdeps/common/gnuslib.c b/sysdeps/common/gnuslib.c index dad417a8..99cbf47b 100644 --- a/sysdeps/common/gnuslib.c +++ b/sysdeps/common/gnuslib.c @@ -1,22 +1,22 @@ /* -*-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. -*/ + * 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 + * 11-Nov-1990 bristor@simba * Added EOT stuff. */ @@ -30,7 +30,8 @@ */ #if 0 -static char rcsid [] = "!Header: gnuslib.c,v 2.4 95/02/16 11:57:37 arup alpha !"; +static char rcsid[] = "!Header: gnuslib.c,v 2.4 95/02/16 11:57:37 arup alpha !"; + #endif #include @@ -39,25 +40,28 @@ static char rcsid [] = "!Header: gnuslib.c,v 2.4 95/02/16 11:57:37 arup alpha !" #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 (const 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) +#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) +#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 @@ -69,365 +73,379 @@ glibtop_make_connection (hostarg, portarg, s) int *s; { #ifdef INTERNET_DOMAIN_SOCKETS - char *ptr; - if (hostarg == NULL) - hostarg = getenv ("LIBGTOP_HOST"); - if (portarg == 0 && (ptr = getenv("LIBGTOP_PORT")) != NULL) - portarg = atoi (ptr); + char *ptr; + + if (hostarg == NULL) + hostarg = getenv ("LIBGTOP_HOST"); + if (portarg == 0 && (ptr = getenv ("LIBGTOP_PORT")) != NULL) + portarg = atoi (ptr); #endif - if (hostarg != NULL) { - /* hostname was given explicitly, via cmd line arg or LIBGTOP_HOST, - * so obey it. */ + if (hostarg != NULL) { + /* hostname was given explicitly, via cmd line arg or + * LIBGTOP_HOST, * so obey it. */ #ifdef UNIX_DOMAIN_SOCKETS - if (!strcmp (hostarg, "unix")) { - *s = connect_to_unix_server (); - return (int) CONN_UNIX; - } + 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; + *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 */ + 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. */ + } 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; + *s = connect_to_unix_server (); + return (int) CONN_UNIX; #elif defined(SYSV_IPC) - *s = connect_to_ipc_server (); - return (int) CONN_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; - } + { + 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. -*/ + * 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 */ + int s; /* connected msqid */ + key_t key; /* message key */ + char buf[GSERV_BUFSZ + 1]; /* buffer for filename */ - sprintf (buf, "/tmp/lgtd%d", (int)geteuid()); - creat (buf, 0600); - if ((key = ftok (buf, 1)) == -1) - glibtop_error_io ("unable to get ipc key from %s", buf); + sprintf (buf, "/tmp/lgtd%d", (int) geteuid ()); + creat (buf, 0600); + if ((key = ftok (buf, 1)) == -1) + glibtop_error_io ("unable to get ipc key from %s", buf); - if ((s = msgget (key, 0600)) == -1) - glibtop_error_io ("unable to access msg queue"); + if ((s = msgget (key, 0600)) == -1) + glibtop_error_io ("unable to access msg queue"); - return(s); + return (s); -} /* connect_to_ipc_server */ +} /* 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) + * 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 */ + int len; /* length of received message */ - send_string(s,EOT_STR); /* EOT terminates this message */ - msgp->mtype = 1; + 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 (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 (echo) { - msgp->mtext[len] = '\0'; /* string terminate message */ - fputs(msgp->mtext, stdout); - if (msgp->mtext[len-1] != '\n') putchar ('\n'); - }; /* 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 */ -} /* disconnect_from_ipc_server */ + 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. -*/ + * send_string -- send string to socket. + */ #if 0 static void -send_string(s,msg) +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 */ + 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 */ +} /* send_string */ /* - read_line -- read a \n terminated line from a socket -*/ + * read_line -- read a \n terminated line from a socket + */ static int -read_line(int s, char *dest) +read_line (int s, char *dest) { - int length; - int offset=0; - char buffer[GSERV_BUFSZ+1]; + 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 */ + 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 #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. -*/ + * 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 */ + int s; /* connected socket descriptor */ + struct sockaddr_un server; /* for unix connections */ - if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) - glibtop_error_io ("unable to create socket"); - - server.sun_family = AF_UNIX; + if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) + glibtop_error_io ("unable to create socket"); + + server.sun_family = AF_UNIX; #ifdef HIDE_UNIX_SOCKET - sprintf(server.sun_path, "/tmp/lgtddir%d/lgtd", (int)geteuid()); -#else /* HIDE_UNIX_SOCKET */ - sprintf(server.sun_path, "/tmp/lgtd%d", (int)geteuid()); + sprintf (server.sun_path, "/tmp/lgtddir%d/lgtd", (int) geteuid ()); +#else /* HIDE_UNIX_SOCKET */ + sprintf (server.sun_path, "/tmp/lgtd%d", (int) geteuid ()); #endif /* HIDE_UNIX_SOCKET */ - if (connect (s, (struct sockaddr *)&server, strlen(server.sun_path)+2) < 0) - glibtop_error_io ("unable to connect to local"); + if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2) < 0) + glibtop_error_io ("unable to connect to local"); - return(s); + return (s); -} /* connect_to_unix_server */ +} /* 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. -*/ -long glibtop_internet_addr (host) + * internet_addr -- return the internet addr of the hostname or + * internet address passed. Return -1 on error. + */ +long +glibtop_internet_addr (host) const char *host; { - struct hostent *hp; /* pointer to host info for remote host */ - IN_ADDR numeric_addr; /* host address */ + 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; - } + 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; + } -} /* glibtop_internet_addr */ +} /* glibtop_internet_addr */ #ifdef AUTH_MAGIC_COOKIE -# include -# include +#include +#include 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. -*/ + * 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 (const 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 */ + 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; + /* clear out address structures */ + memset ((char *) &peeraddr_in, 0, sizeof (struct sockaddr_in)); - /* look up the server host's internet address */ - if (((long) peeraddr_in.sin_addr.s_addr = glibtop_internet_addr (serverhost)) == -1) - glibtop_error ("unable to find %s in /etc/hosts or from YP", serverhost); - - if (port == 0) { - if ((sp = getservbyname ("gtopd","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) - glibtop_error_io ("unable to create socket"); - - /* 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) - glibtop_error_io ("unable to connect to remote"); + /* 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 (((long) peeraddr_in.sin_addr.s_addr = glibtop_internet_addr (serverhost)) == -1) + glibtop_error ("unable to find %s in /etc/hosts or from YP", serverhost); + + if (port == 0) { + if ((sp = getservbyname ("gtopd", "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) + glibtop_error_io ("unable to create socket"); + + /* 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) + glibtop_error_io ("unable to connect to remote"); #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); + /* send credentials using MIT-MAGIC-COOKIE-1 protocol */ - 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); - } + 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)); + sprintf (buf, "%s\n", DEFAUTH_NAME); + write (s, buf, strlen (buf)); - return(s); + return (s); -} /* connect_to_internet_server */ +} /* 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. -*/ + * disconnect_from_server -- inform the server that sending has finished, and wait for + * its reply. + */ #if 0 static void -disconnect_from_server(s,echo) +disconnect_from_server (s, echo) int s; int echo; { #if 0 - char buffer[REPLYSIZ+1]; + char buffer[REPLYSIZ + 1]; + #else - char buffer[GSERV_BUFSZ+1]; + char buffer[GSERV_BUFSZ + 1]; + #endif - int add_newline = 1; - int length; + int add_newline = 1; + int length; - send_string(s,EOT_STR); /* make sure server gets string */ + 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 !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 */ + 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 */ + 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 */ + 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 */ + if (echo && add_newline) + putchar ('\n'); -} /* disconnect_from_server */ + 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 #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ From 8a666eb5a4e3d534f1266879ff4d3f231f4f0fa7 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 12 Jul 1998 14:29:30 +0000 Subject: [PATCH 0170/2539] Fixed unbalanced '#endif'. --- src/daemon/gnuserv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index 9be15895..c84bb87f 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -625,7 +625,7 @@ handle_internet_request (int ls) glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr)); return; } /* if */ -#tifdef DEBUG +#ifdef DEBUG fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr)); #endif From f30dfecaf7c284f358fb1cb00a2da296ec4e6738 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 00:18:44 +0000 Subject: [PATCH 0171/2539] Changed indentation, removed some lines already commented out. Enclosed debugging statement in '#ifdef DEBUG'. --- lib/command.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/command.c b/lib/command.c index abef8bcd..b9d927c3 100644 --- a/lib/command.c +++ b/lib/command.c @@ -27,8 +27,8 @@ #include void * -glibtop_call_l (glibtop *server, unsigned command, size_t send_size, void *send_buf, - size_t recv_size, void *recv_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; glibtop_response response; @@ -45,11 +45,6 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size, void *send_ * send it together with command, so we only need one system call instead * of two. */ -#ifdef DEBUG - // fprintf (stderr, "COMMAND: send_size = %d; command = %d; sizeof (cmnd) = %d\n", - // send_size, command, sizeof (glibtop_command)); -#endif - if (send_size <= _GLIBTOP_PARAM_SIZE) { memcpy (cmnd.parameter, send_buf, send_size); cmnd.size = send_size; @@ -58,14 +53,17 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size, void *send_ } glibtop_write_l (server, sizeof (glibtop_command), &cmnd); - // glibtop_write_l (server, cmnd.data_size, send_buf); glibtop_read_l (server, sizeof (glibtop_response), &response); - fprintf (stderr, "RESPONSE: %d - %d\n", response.offset, response.data_size); +#ifdef DEBUG + fprintf (stderr, "RESPONSE: %d - %d\n", + response.offset, response.data_size); +#endif if (recv_buf) - memcpy (recv_buf, ((char *) &response) + response.offset, recv_size); + memcpy (recv_buf, ((char *) &response) + response.offset, + recv_size); if (response.data_size) { void *ptr = glibtop_malloc_r (server, response.data_size); From 3477d30dc5cbefcaa5a717c6f9aaffe6c3f46ef9 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 00:39:46 +0000 Subject: [PATCH 0172/2539] Basically did some work on the new daemon. Things are still unstable. 1998-07-13 Martin Baulig * glibtop.h: Fixed invocation of `glibtop_close_r'. * sysdeps/linux/procstate.c: Added missing `fclose'. * include/glibtop/gnuserv.h (UNIX_DOMAIN_SOCKETS): Defining. * include/glibtop/open.h (GLIBTOP_METHOD_UNIX): Added. * lib/init.c: Added new method `GLIBTOP_METHOD_UNIX'. * lib/open.c: Added support for Unix Domain Sockets. * lib/close.c: Now closing inet and unix connections. * lib/parameter.c (glibtop_set_parameter_l): You can now set the `method' and `features' fields. * src/daemon/server_config.h: New file. * src/daemon/{gnuserv.c, main.c}: More work on the server. --- ChangeLog | 23 ++ examples/first.c | 62 +++--- glibtop.h | 2 +- include/glibtop/gnuserv.h | 3 +- include/glibtop/open.h | 1 + lib/Makefile.am | 2 +- lib/close.c | 24 ++- lib/init.c | 31 +-- lib/open.c | 29 ++- lib/parameter.c | 18 ++ src/daemon/gnuserv.c | 415 +++++++++++++++++++------------------ src/daemon/main.c | 219 +++++++++++++++++-- src/daemon/server_config.h | 14 ++ sysdeps/linux/procstate.c | 4 +- 14 files changed, 572 insertions(+), 275 deletions(-) create mode 100644 src/daemon/server_config.h diff --git a/ChangeLog b/ChangeLog index 9f4354b6..0ed291db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +1998-07-13 Martin Baulig + + * glibtop.h: Fixed invocation of `glibtop_close_r'. + + * sysdeps/linux/procstate.c: Added missing `fclose'. + + * include/glibtop/gnuserv.h (UNIX_DOMAIN_SOCKETS): Defining. + + * include/glibtop/open.h (GLIBTOP_METHOD_UNIX): Added. + + * lib/init.c: Added new method `GLIBTOP_METHOD_UNIX'. + + * lib/open.c: Added support for Unix Domain Sockets. + + * lib/close.c: Now closing inet and unix connections. + + * lib/parameter.c (glibtop_set_parameter_l): You can now + set the `method' and `features' fields. + + * src/daemon/server_config.h: New file. + + * src/daemon/{gnuserv.c, main.c}: More work on the server. + 1998-07-10 Martin Baulig * src/Makefile.am (SUBDIRS): Removed `proxy'. This directory diff --git a/examples/first.c b/examples/first.c index 79180446..115a8be2 100644 --- a/examples/first.c +++ b/examples/first.c @@ -32,7 +32,7 @@ #include #ifndef PROFILE_COUNT -#define PROFILE_COUNT 1 +#define PROFILE_COUNT 1000 #endif int @@ -68,14 +68,14 @@ main (int argc, char *argv []) printf ("Host = '%s' - %u\n\n", buffer, port); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_cpu (&data.cpu); printf ("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); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_mem (&data.mem); printf ("Memory (0x%08lx): %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu\n", @@ -83,26 +83,26 @@ main (int argc, char *argv []) data.mem.shared, data.mem.buffer, data.mem.cached, data.mem.user, data.mem.locked); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_swap (&data.swap); printf ("Swap (0x%08lx): %lu, %lu, %lu\n", data.swap.flags, data.swap.total, data.swap.used, data.swap.free); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_uptime (&data.uptime); printf ("Uptime (0x%08lx): %f, %f\n", data.uptime.flags, data.uptime.uptime, data.uptime.idletime); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_loadavg (&data.loadavg); printf ("Loadavg (0x%08lx): %f, %f, %f\n", data.loadavg.flags, data.loadavg.loadavg [0], data.loadavg.loadavg [1], data.loadavg.loadavg [2]); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_shm_limits (&data.shm_limits); printf ("Shm Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld\n", @@ -110,7 +110,7 @@ main (int argc, char *argv []) data.shm_limits.shmmin, data.shm_limits.shmmni, data.shm_limits.shmseg, data.shm_limits.shmall); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_msg_limits (&data.msg_limits); printf ("Msg Limits (0x%08lx): %ld, %ld, %ld, %ld, %ld, %ld, %ld\n", @@ -119,7 +119,7 @@ main (int argc, char *argv []) data.msg_limits.msgmnb, data.msg_limits.msgmni, data.msg_limits.msgssz, data.msg_limits.msgtql); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_sem_limits (&data.sem_limits); printf ("Sem Limits (0x%08lx): " @@ -167,7 +167,7 @@ main (int argc, char *argv []) printf ("\n"); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, pid); printf ("Proc_State PID %5u (0x%08lx): '%s', %c, %u, %u\n", @@ -175,7 +175,7 @@ main (int argc, char *argv []) data.proc_state.state, data.proc_state.uid, data.proc_state.gid); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_uid (&data.proc_uid, pid); printf ("Proc_Uid PID %5u (0x%08lx): " @@ -188,7 +188,7 @@ main (int argc, char *argv []) data.proc_uid.tpgid, data.proc_uid.priority, data.proc_uid.nice); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_mem (&data.proc_mem, pid); printf ("Proc_Mem PID %5u (0x%08lx): " @@ -197,7 +197,7 @@ main (int argc, char *argv []) data.proc_mem.resident, data.proc_mem.share, data.proc_mem.rss, data.proc_mem.rss_rlim); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, pid); printf ("Proc_Time PID %5u (0x%08lx): " @@ -207,7 +207,7 @@ main (int argc, char *argv []) data.proc_time.cstime, data.proc_time.timeout, data.proc_time.it_real_value); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_signal (&data.proc_signal, pid); printf ("Proc_Signal PID %5u (0x%08lx): " @@ -215,7 +215,7 @@ main (int argc, char *argv []) data.proc_signal.signal, data.proc_signal.blocked, data.proc_signal.sigignore, data.proc_signal.sigcatch); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_kernel (&data.proc_kernel, pid); printf ("Proc_Kernel PID %5u (0x%08lx): " @@ -226,7 +226,7 @@ main (int argc, char *argv []) data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, data.proc_kernel.wchan); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_segment (&data.proc_segment, pid); printf ("Proc_Segment PID %5u (0x%08lx): " @@ -238,7 +238,7 @@ main (int argc, char *argv []) printf ("\n"); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, ppid); printf ("Proc_State PPID %5u (0x%08lx): '%s', %c, %u, %u\n", @@ -246,7 +246,7 @@ main (int argc, char *argv []) data.proc_state.state, data.proc_state.uid, data.proc_state.gid); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_uid (&data.proc_uid, ppid); printf ("Proc_Uid PPID %5u (0x%08lx): " @@ -259,7 +259,7 @@ main (int argc, char *argv []) data.proc_uid.tpgid, data.proc_uid.priority, data.proc_uid.nice); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_mem (&data.proc_mem, ppid); printf ("Proc_Mem PPID %5u (0x%08lx): " @@ -268,7 +268,7 @@ main (int argc, char *argv []) data.proc_mem.resident, data.proc_mem.share, data.proc_mem.rss, data.proc_mem.rss_rlim); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, ppid); printf ("Proc_Time PPID %5u (0x%08lx): " @@ -278,7 +278,7 @@ main (int argc, char *argv []) data.proc_time.cstime, data.proc_time.timeout, data.proc_time.it_real_value); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_signal (&data.proc_signal, ppid); printf ("Proc_Signal PPID %5u (0x%08lx): " @@ -286,7 +286,7 @@ main (int argc, char *argv []) data.proc_signal.signal, data.proc_signal.blocked, data.proc_signal.sigignore, data.proc_signal.sigcatch); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_kernel (&data.proc_kernel, ppid); printf ("Proc_Kernel PPID %5u (0x%08lx): " @@ -297,7 +297,7 @@ main (int argc, char *argv []) data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, data.proc_kernel.wchan); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_segment (&data.proc_segment, ppid); printf ("Proc_Segment PPID %5u (0x%08lx): " @@ -309,7 +309,7 @@ main (int argc, char *argv []) printf ("\n"); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_state (&data.proc_state, 1); printf ("Proc_State INIT %5u (0x%08lx): '%s', %c, %u, %u\n", @@ -317,7 +317,7 @@ main (int argc, char *argv []) data.proc_state.state, data.proc_state.uid, data.proc_state.gid); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_uid (&data.proc_uid, 1); printf ("Proc_Uid INIT %5u (0x%08lx): " @@ -330,7 +330,7 @@ main (int argc, char *argv []) data.proc_uid.tpgid, data.proc_uid.priority, data.proc_uid.nice); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_mem (&data.proc_mem, 1); printf ("Proc_Mem INIT %5u (0x%08lx): " @@ -339,7 +339,7 @@ main (int argc, char *argv []) data.proc_mem.resident, data.proc_mem.share, data.proc_mem.rss, data.proc_mem.rss_rlim); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_time (&data.proc_time, 1); printf ("Proc_Time INIT %5u (0x%08lx): " @@ -349,7 +349,7 @@ main (int argc, char *argv []) data.proc_time.cstime, data.proc_time.timeout, data.proc_time.it_real_value); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_signal (&data.proc_signal, 1); printf ("Proc_Signal INIT %5u (0x%08lx): " @@ -357,7 +357,7 @@ main (int argc, char *argv []) data.proc_signal.signal, data.proc_signal.blocked, data.proc_signal.sigignore, data.proc_signal.sigcatch); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_kernel (&data.proc_kernel, 1); printf ("Proc_Kernel INIT %5u (0x%08lx): " @@ -368,7 +368,7 @@ main (int argc, char *argv []) data.proc_kernel.kstk_esp, data.proc_kernel.kstk_eip, data.proc_kernel.wchan); - for (c = 0; c < count; c++) + for (c = 0; c < PROFILE_COUNT; c++) glibtop_get_proc_segment (&data.proc_segment, 1); printf ("Proc_Segment INIT %5u (0x%08lx): " @@ -378,5 +378,7 @@ main (int argc, char *argv []) data.proc_segment.start_code, data.proc_segment.end_code, data.proc_segment.start_stack); + glibtop_close (); + exit (0); } diff --git a/glibtop.h b/glibtop.h index 9db6c74c..aa8e99b5 100644 --- a/glibtop.h +++ b/glibtop.h @@ -60,7 +60,7 @@ extern const unsigned long glibtop_server_features; #define glibtop_init() glibtop_init_r(&glibtop_global_server, 0, 0); -#define glibtop_close() glibtop_close_r(&glibtop_global_server); +#define glibtop_close() glibtop_close_r(glibtop_global_server); extern glibtop *glibtop_init_r __P((glibtop **, const unsigned long, const unsigned)); diff --git a/include/glibtop/gnuserv.h b/include/glibtop/gnuserv.h index 082637e4..6d1df518 100644 --- a/include/glibtop/gnuserv.h +++ b/include/glibtop/gnuserv.h @@ -54,9 +54,8 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a * sockets with sysv ipc */ - #define INTERNET_DOMAIN_SOCKETS -// #define UNIX_DOMAIN_SOCKETS +#define UNIX_DOMAIN_SOCKETS // #define SYSV_IPC /* diff --git a/include/glibtop/open.h b/include/glibtop/open.h index a891727d..0da35985 100644 --- a/include/glibtop/open.h +++ b/include/glibtop/open.h @@ -38,6 +38,7 @@ __BEGIN_DECLS #define GLIBTOP_METHOD_DIRECT 1 #define GLIBTOP_METHOD_PIPE 2 #define GLIBTOP_METHOD_INET 3 +#define GLIBTOP_METHOD_UNIX 4 extern void glibtop_open_l __P((glibtop *, const char *, const unsigned long, const unsigned)); diff --git a/lib/Makefile.am b/lib/Makefile.am index 87d16c29..32a555a9 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -4,7 +4,7 @@ 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@"\" -DDEBUG +CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\" lib_LTLIBRARIES = libgtop.la diff --git a/lib/close.c b/lib/close.c index f4f0ba00..b5f60a51 100644 --- a/lib/close.c +++ b/lib/close.c @@ -19,14 +19,30 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include #include +#include -/* Closes pipe to gtop server. */ +/* Closes server. */ void glibtop_close_r (glibtop *server) { - kill (server->pid, SIGKILL); - close (server->input [0]); - close (server->output [1]); + switch (server->method) { + case GLIBTOP_METHOD_UNIX: + case GLIBTOP_METHOD_INET: + glibtop_call_l (server, GLIBTOP_CMND_QUIT, + 0, NULL, 0, NULL); + + if (close (server->socket)) + glibtop_warn_io ("close"); + + break; + case GLIBTOP_METHOD_PIPE: + kill (server->pid, SIGKILL); + close (server->input [0]); + close (server->output [1]); + break; + } } diff --git a/lib/init.c b/lib/init.c index bc202c62..367d5e14 100644 --- a/lib/init.c +++ b/lib/init.c @@ -63,16 +63,11 @@ _init_server (glibtop *server, const unsigned features) if (server->server_command [0] != ':') { if (features & glibtop_server_features) { - /* We really need the server. */ - server->method = GLIBTOP_METHOD_PIPE; - } else { - /* Fine. No server is needed, so we call the * sysdeps functions directly. */ - server->method = GLIBTOP_METHOD_DIRECT; } @@ -92,21 +87,19 @@ _init_server (glibtop *server, const unsigned features) /* Dispatch method. */ if (!strcmp (command, "direct")) { - - /* Use sysdeps dir instead of connecting to server - * even if using the server would be required on - * the current system. */ - + /* Use sysdeps dir instead of connecting to server + * even if using the server would be required on + * the current system. */ server->method = GLIBTOP_METHOD_DIRECT; - + } else if (!strcmp (command, "inet")) { server->method = GLIBTOP_METHOD_INET; - /* Connect to internet server. */ + /* Connect to internet server. */ if (temp == NULL) { - /* If no value was set, we use 'localhost'. */ + /* If no value was set, we use 'localhost'. */ if (server->server_host == NULL) server->server_host = glibtop_strdup_r (server, "localhost"); @@ -114,7 +107,7 @@ _init_server (glibtop *server, const unsigned features) char *temp2 = strstr (temp+1, ":"); if (temp2) *temp2 = 0; - /* Override default. */ + /* Override default. */ if (server->server_host) glibtop_free_r (server, (char *) server->server_host); @@ -125,7 +118,7 @@ _init_server (glibtop *server, const unsigned features) } if (temp == NULL) { - /* If no value was set, we use DEFAULT_PORT. */ + /* If no value was set, we use DEFAULT_PORT. */ if (server->server_port == 0) server->server_port = DEFAULT_PORT; } else { @@ -137,9 +130,17 @@ _init_server (glibtop *server, const unsigned features) temp = temp2 ? temp2 + 1 : temp2; } + + } else if (!strcmp (command, "unix")) { + + /* Connect to unix domain socket. */ + server->method = GLIBTOP_METHOD_UNIX; + } else { + glibtop_error_r (server, "Unknown server method '%s'", server->server_command+1); + } glibtop_free_r (server, command); diff --git a/lib/open.c b/lib/open.c index 1bf95032..783744ab 100644 --- a/lib/open.c +++ b/lib/open.c @@ -33,6 +33,8 @@ void glibtop_open_l (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { + int connect_type; + server->name = program_name; /* It is important to set _GLIBTOP_INIT_STATE_OPEN here when we @@ -40,19 +42,33 @@ glibtop_open_l (glibtop *server, const char *program_name, server->flags |= _GLIBTOP_INIT_STATE_OPEN; - if (server->method == GLIBTOP_METHOD_INET) { - int connect_type; - - fprintf (stderr, "Connecting to '%s' port %d.\n", + switch (server->method) { + case GLIBTOP_METHOD_INET: + fprintf (stderr, "Connecting to '%s' port %ld.\n", server->server_host, server->server_port); connect_type = glibtop_make_connection (server->server_host, server->server_port, &server->socket); + + fprintf (stderr, "Connect Type is %d.\n", connect_type); + + server->flags |= _GLIBTOP_INIT_STATE_SERVER; server->features = -1; + break; + case GLIBTOP_METHOD_UNIX: + fprintf (stderr, "Connecting to Unix Domain Socket.\n"); - return; + connect_type = glibtop_make_connection + ("unix", 0, &server->socket); + + fprintf (stderr, "Connect Type is %d.\n", connect_type); + + server->flags |= _GLIBTOP_INIT_STATE_SERVER; + + server->features = -1; + break; } /* If the server has been started, ask it for its features. */ @@ -64,5 +80,8 @@ glibtop_open_l (glibtop *server, const char *program_name, sizeof (glibtop_sysdeps), &sysdeps); server->features = sysdeps.features; + + fprintf (stderr, "Server features are %lu.\n", + server->features); } } diff --git a/lib/parameter.c b/lib/parameter.c index ca3c5d0c..8d6403e3 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -28,6 +28,14 @@ memcpy (data_ptr, ptr, size); \ return size; +#define _check_data(size) \ + if ((data_ptr == NULL) || (data_size != size)) { \ + glibtop_error_r (server, "glibtop_set_parameter (%d): " \ + "Expected %lu bytes but got %lu.", \ + parameter, size, data_size); \ + return; \ + } + #define _strlen(ptr) (ptr ? strlen (ptr) : 0) size_t @@ -59,4 +67,14 @@ void glibtop_set_parameter_l (glibtop *server, const unsigned parameter, const void *data_ptr, size_t data_size) { + switch (parameter) { + case GLIBTOP_PARAM_METHOD: + _check_data (sizeof (server->method)); + memcpy (&server->method, data_ptr, data_size); + break; + case GLIBTOP_PARAM_FEATURES: + _check_data (sizeof (server->features)); + memcpy (&server->features, data_ptr, data_size); + break; + } } diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index c84bb87f..4e40e4d2 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -29,21 +29,25 @@ * ../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 +#include +#include -#define DEBUG +#include "server_config.h" #include -#include + +#include +#include #ifdef AIX #include #endif -extern void handle_socket_connection __P ((glibtop *, int)); +extern void handle_parent_connection __P ((glibtop *, int)); +extern void handle_child_connection __P ((glibtop *, int)); #if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) main () @@ -148,6 +152,7 @@ ipc_init (struct msgbuf **msgpp) void handle_ipc_request (struct msgbuf *msgp) { +#if 0 struct msqid_ds msg_st; /* message status */ char buf[GSERV_BUFSZ]; int len; /* length of message / read */ @@ -224,106 +229,14 @@ handle_ipc_request (struct msgbuf *msgp) msgp->mtype = msg_st.msg_lspid; if (msgsnd (ipc_qid, msgp, strlen (msgp->mtext) + 1, 0) < 0) glibtop_warn_io ("msgsend(gnuserv)"); - +#else + glibtop_error ("handle_ipc_request (): Function not implemented"); +#endif } /* 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) - glibtop_error_io ("recv"); - -} /* 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) -{ -#if 0 - 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) - glibtop_error_io ("read"); - - /* 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) - glibtop_error_io ("read"); - - buf[len] = '\0'; - send_string (s, buf); - result_len -= len; - } - - /* eat the newline */ - while ((len = read (0, buf, 1)) == 0); - if (len < 0) - glibtop_error_io ("read"); - - if (buf[0] != '\n') - glibtop_error ("garbage after result"); - - /* send the newline */ - buf[1] = '\0'; - send_string (s, buf); - close (s); -#else - glibtop_error ("handle_response (): Function not implemented"); -#endif - -} /* 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 @@ -383,8 +296,7 @@ timed_read (int fd, char *buf, int max, int timeout, int one_line) static int permitted (u_long host_addr, int fd) { - int key; - struct entry *entry; + int i; char auth_protocol[128]; char buf[1024]; @@ -445,49 +357,24 @@ permitted (u_long host_addr, int fd) } /* Now, try the old GNU_SECURE stuff... */ - /* First find the hash key */ - key = HASH (host_addr) % TABLE_SIZE; - #ifdef DEBUG fprintf (stderr, "Doing GNU_SECURE auth ...\n"); #endif /* Now check the chain for that hash key */ - for (entry = permitted_hosts[key]; entry != NULL; entry = entry->next) { + for (i = 0; i < HOST_TABLE_ENTRIES; i++) { #ifdef DEBUG - fprintf (stderr, "Trying %ld\n", entry->host_addr); + fprintf (stderr, "Trying %lx - %lx\n", + host_addr, permitted_hosts [i]); #endif - if (host_addr == entry->host_addr) + if (host_addr == permitted_hosts [i]) 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) - glibtop_error_io ("unable to malloc space for permitted host entry"); - - 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 @@ -499,54 +386,53 @@ add_host (u_long host_addr) static int setup_table (void) { - FILE *host_file; - char *file_name; - char hostname[HOSTNAMSZ]; + 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; + for (i = 0; i < HOST_TABLE_ENTRIES; i++) + permitted_hosts [i] = 0; gethostname (hostname, HOSTNAMSZ); if (((long) host_addr = glibtop_internet_addr (hostname)) == -1) - glibtop_error ("unable to find %s in /etc/hosts or from YP", hostname); + glibtop_error ("Can't resolve '%s'", hostname); #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); + 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 */ + /* Resolv host names from permitted_host_names []. */ -#if 0 /* Don't even want to allow access from the - * local host by default */ - add_host (host_addr); /* add local host */ - hosts++; + for (i = 0; i < HOST_TABLE_ENTRIES; i++) { +#ifdef DEBUG + fprintf (stderr, "Resolving %s ...\n", + permitted_host_names [i]); +#endif + permitted_hosts [i] = + glibtop_internet_addr (permitted_host_names [i]); + if ((long) permitted_hosts [i] == -1) + glibtop_error ("Can't resolve '%s'", + permitted_host_names [i]); + } + +#ifdef DEBUG + for (i = 0; i < HOST_TABLE_ENTRIES; i++) + fprintf (stderr, "Host %s - %lx\n", + permitted_host_names [i], + permitted_hosts [i]); #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 (((long) host_addr = glibtop_internet_addr (hostname)) != -1) { /* get - * its - * addr - */ - add_host (host_addr); /* add the addr */ - hosts++; - } - fclose (host_file); - } /* if */ + hosts += HOST_TABLE_ENTRIES; + return hosts; } /* setup_table */ @@ -559,9 +445,7 @@ 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; @@ -573,19 +457,15 @@ internet_init (void) 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; + /* We use a fixed port given in the config file. */ + server.sin_port = htons (SERVER_PORT); + + fprintf (stderr, "Using port %u.\n", server.sin_port); /* Create the listen socket. */ if ((ls = socket (AF_INET, SOCK_STREAM, 0)) == -1) glibtop_error_io ("unable to create socket"); - + /* Bind the listen address to the socket. */ if (bind (ls, (struct sockaddr *) &server, sizeof (struct sockaddr_in)) == -1) glibtop_error_io ("bind"); @@ -595,7 +475,6 @@ internet_init (void) glibtop_error_io ("listen"); return (ls); - } /* internet_init */ @@ -609,6 +488,7 @@ handle_internet_request (int ls) int s; size_t addrlen = sizeof (struct sockaddr_in); struct sockaddr_in peer; /* for peer socket address */ + pid_t pid; memset ((char *) &peer, 0, sizeof (struct sockaddr_in)); @@ -625,18 +505,30 @@ handle_internet_request (int ls) glibtop_warn ("Refused connection from %s.", inet_ntoa (peer.sin_addr)); return; } /* if */ + #ifdef DEBUG - fprintf (stderr, "Accepted connection from %s.\n", inet_ntoa (peer.sin_addr)); + fprintf (stderr, "Accepted connection from %s (%u) on socket %d.\n", + inet_ntoa (peer.sin_addr), ntohs (peer.sin_port), s); #endif - handle_socket_connection (&glibtop_global_server, s); + pid = fork (); + + if (pid == -1) + glibtop_error_io ("fork failed"); + + if (pid) + return; + + handle_parent_connection (glibtop_global_server, s); close (s); - + #ifdef DEBUG - fprintf (stderr, "Closed connection to %s.\n", inet_ntoa (peer.sin_addr)); + fprintf (stderr, "Closed connection to %s (%d).\n", + inet_ntoa (peer.sin_addr), ntohs (peer.sin_port)); #endif + _exit (0); } /* handle_internet_request */ #endif /* INTERNET_DOMAIN_SOCKETS */ @@ -657,12 +549,14 @@ unix_init (void) glibtop_error_io ("unable to create socket"); /* Set up address structure for the listen socket. */ + #ifdef HIDE_UNIX_SOCKET sprintf (server.sun_path, "/tmp/lgtddir%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) - glibtop_error_io ("Can't set permissions on %s", server.sun_path); + glibtop_error_io ("Can't set permissions on %s", + server.sun_path); } strcat (server.sun_path, "/lgtd"); unlink (server.sun_path); /* remove old file if it exists */ @@ -705,7 +599,6 @@ unix_init (void) #endif return (ls); - } /* unix_init */ @@ -719,27 +612,52 @@ handle_unix_request (int ls) int s; size_t len = sizeof (struct sockaddr_un); struct sockaddr_un server; /* for unix socket address */ + pid_t pid; server.sun_family = AF_UNIX; if ((s = accept (ls, (struct sockaddr *) &server, (void *) &len)) < 0) glibtop_error_io ("accept"); - echo_request (s); +#ifdef DEBUG + fprintf (stderr, "Accepted connection on socket %d.\n", s); +#endif + pid = fork (); + + if (pid == -1) + glibtop_error_io ("fork failed"); + + if (pid) + return; + + handle_child_connection (glibtop_global_server, s); + + close (s); + +#ifdef DEBUG + fprintf (stderr, "Closed connection on socket %d.\n", s); +#endif + + glibtop_close_r (glibtop_global_server); + + exit (0); } /* handle_unix_request */ #endif /* UNIX_DOMAIN_SOCKETS */ +void +handle_signal (int sig) +{ + fprintf (stderr, "Catched signal %d.\n", sig); +} int -main (argc, argv) - int argc; - char *argv[]; +main (int argc, char *argv []) { - int chan; /* temporary channel number */ int ils = -1; /* internet domain listen socket */ int uls = -1; /* unix domain listen socket */ + pid_t pid; #ifdef SYSV_IPC struct msgbuf *msgp; /* message buffer */ @@ -748,31 +666,127 @@ main (argc, argv) glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE); - for (chan = 3; chan < _NFILE; close (chan++)) /* close unwanted - * channels */ - ; + /* Fork a child. + * + * The parent will listen for incoming internet connections + * and the child will listen for connections from the local + * host using unix domain name sockets or SysV IPC. + */ + + signal (SIGCHLD, handle_signal); + + pid = fork (); + + if (pid == -1) + glibtop_error_io ("fork failed"); + else if (pid == 0) { + /* We are the child. */ + + /* Temporarily drop our priviledges. */ + + fprintf (stderr, "Child ID: (%d, %d) - (%d, %d)\n", + getuid (), geteuid (), getgid (), getegid ()); + + if (setreuid (geteuid (), getuid ())) + glibtop_error_io ("setreuid (euid <-> uid)"); + + if (setregid (getegid (), getgid ())) + glibtop_error_io ("setregid (egid <-> gid)"); + + fprintf (stderr, "Child ID: (%d, %d) - (%d, %d)\n", + getuid (), geteuid (), getgid (), getegid ()); #ifdef SYSV_IPC - ipc_init (&msgp); /* get a msqid to listen on, and a message - * buffer */ + /* get a msqid to listen on, and a message buffer. */ + ipc_init (&msgp); #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 */ + /* get a unix domain socket to listen on. */ + uls = unix_init (); #endif /* UNIX_DOMAIN_SOCKETS */ + } else { + /* We are the parent. */ + + /* If we are root, completely switch to SERVER_UID and + * SERVER_GID. Otherwise we completely drop any priviledges. + */ + +#ifdef DEBUG + fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n", + getuid (), geteuid (), getgid (), getegid ()); +#endif + + if (setreuid (geteuid (), getuid ())) + glibtop_error_io ("setreuid (euid <-> uid)"); + + if (setregid (getegid (), getgid ())) + glibtop_error_io ("setregid (egid <-> gid)"); + +#ifdef DEBUG + fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n", + getuid (), geteuid (), getgid (), getegid ()); +#endif + + if ((geteuid () == 0) || (getuid () == 0)) { + if (setreuid (0, 0)) + glibtop_error_io ("setreuid (root)"); + } + +#ifdef DEBUG + fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n", + getuid (), geteuid (), getgid (), getegid ()); +#endif + + if (geteuid () == 0) { + if (setregid (SERVER_GID, SERVER_GID)) + glibtop_error_io ("setregid (SERVER_GID)"); + if (setreuid (SERVER_UID, SERVER_UID)) + glibtop_error_io ("setreuid (SERVER_UID)"); + } else { + if (setreuid (geteuid (), geteuid ())) + glibtop_error_io ("setreuid (euid)"); + } + +#ifdef DEBUG + fprintf (stderr, "Parent ID: (%d, %d) - (%d, %d)\n", + getuid (), geteuid (), getgid (), getegid ()); +#endif + +#ifdef INTERNET_DOMAIN_SOCKETS + /* get a internet domain socket to listen on. */ + ils = internet_init (); +#endif /* INTERNET_DOMAIN_SOCKETS */ + } while (1) { #ifdef SYSV_IPC handle_ipc_request (msgp); #else /* NOT SYSV_IPC */ fd_set rmask; + int ret; + while ((ret = wait3 (NULL, WNOHANG, NULL)) != 0) { + if ((ret == -1) && (errno == ECHILD)) + break; + + if ((ret == -1) && ((errno == EAGAIN) || + (errno == ERESTART))) + continue; + if (ret > 0) + fprintf (stderr, "Child %d exited.\n", ret); + else + glibtop_warn_io ("wait3: %d", ret); + } + FD_ZERO (&rmask); - FD_SET (fileno (stdin), &rmask); + + /* Only the child accepts connections from standard + * input made by its parent. */ + + if (pid == 0) + FD_SET (fileno (stdin), &rmask); + if (uls >= 0) FD_SET (uls, &rmask); if (ils >= 0) @@ -783,8 +797,12 @@ main (argc, argv) #endif if (select (max2 (fileno (stdin), max2 (uls, ils)) + 1, &rmask, - (fd_set *) NULL, (fd_set *) NULL, (struct timeval *) NULL) < 0) + (fd_set *) NULL, (fd_set *) NULL, + (struct timeval *) NULL) < 0) { + if (errno == EINTR) + continue; glibtop_error_io ("select"); + } #ifdef UNIX_DOMAIN_SOCKETS if (uls > 0 && FD_ISSET (uls, &rmask)) @@ -796,9 +814,8 @@ main (argc, argv) handle_internet_request (ils); #endif /* INTERNET_DOMAIN_SOCKETS */ - if (FD_ISSET (fileno (stdin), &rmask)) /* from stdin (gnu - * process) */ - handle_response (); + if (FD_ISSET (fileno (stdin), &rmask)) + handle_child_connection (glibtop_global_server, fileno (stdin)); #endif /* NOT SYSV_IPC */ } /* while */ diff --git a/src/daemon/main.c b/src/daemon/main.c index 54cfe444..3537ee92 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -21,15 +21,19 @@ #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include #include +#undef REAL_DEBUG +#define PARENT_DEBUG + #if defined(HAVE_GETDTABLESIZE) #define GET_MAX_FDS() getdtablesize() #else @@ -46,7 +50,7 @@ do_output (int s, glibtop_response *response, off_t offset, size_t data_size, const void *data) { #ifdef REAL_DEBUG - fprintf (stderr, "Really writing %d bytes at offset %d.\n", + fprintf (stderr, "Really writing %d bytes at offset %lu.\n", sizeof (glibtop_response), offset); #endif @@ -66,31 +70,201 @@ do_output (int s, glibtop_response *response, off_t offset, } } -static void +static int do_read (int s, void *ptr, size_t total_size) { int nread; size_t already_read = 0, remaining = total_size; while (already_read < total_size) { - nread = recv (s, ptr, remaining, 0); + if (s) + nread = recv (s, ptr, remaining, 0); + else + nread = read (0, ptr, remaining); + + if ((already_read == 0) && (nread == 0)) { + glibtop_warn ("pid %d received eof.", getpid ()); + return 0; + } if (nread <= 0) { - glibtop_error_io ("recv"); - return; + glibtop_warn_io ("recv"); + return 0; } already_read += nread; remaining -= nread; (char *) ptr += nread; +#ifdef REAL_DEBUG fprintf (stderr, "READ (%d): %d - %d - %d\n", nread, already_read, remaining, total_size); +#endif + } + + return already_read; +} + +void +handle_parent_connection (glibtop *server, int s) +{ + pid_t pid; + char parameter [BUFSIZ]; + struct timeval tv; + glibtop_response response; + glibtop_command cmnd; + unsigned method; + int null = 0; + void *ptr; + + tv.tv_sec = 5; + tv.tv_usec = 0; + + method = GLIBTOP_METHOD_UNIX; + + glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD, + &method, sizeof (method)); + + glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES, + &glibtop_server_features, + sizeof (glibtop_server_features)); + + fprintf (stderr, "Parent features = %lu\n", glibtop_server_features); + + while (do_read (s, &cmnd, sizeof (glibtop_command))) { +#ifdef PARENT_DEBUG + fprintf (stderr, "Parent (%d) received command %d from client.\n", + getpid (), cmnd.command); +#endif + + if (cmnd.data_size >= BUFSIZ) { + glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd.size, BUFSIZ); + return; + } + + memset (parameter, 0, sizeof (parameter)); + + if (cmnd.data_size) { +#ifdef PARENT_DEBUG + fprintf (stderr, "Client has %d bytes of data.\n", cmnd.data_size); +#endif + + do_read (s, parameter, cmnd.data_size); + + } else if (cmnd.size) { + memcpy (parameter, cmnd.parameter, cmnd.size); + } + + switch (cmnd.command) { + case GLIBTOP_CMND_QUIT: + do_output (s, &response, 0, 0, NULL); + + fprintf (stderr, "Sending QUIT command (%d).\n", + server->socket); + + glibtop_call_l (server, GLIBTOP_CMND_QUIT, + 0, NULL, 0, NULL); + + fprintf (stderr, "Done sending QUIT command (%d).\n", + server->socket); + + close (server->socket); + return; + case GLIBTOP_CMND_SYSDEPS: + response.u.sysdeps.features = GLIBTOP_SYSDEPS_ALL; + do_output (s, &response, _offset_union (sysdeps), 0, NULL); + break; + case GLIBTOP_CMND_CPU: + glibtop_get_cpu_l (server, &response.u.data.cpu); + do_output (s, &response, _offset_data (cpu), 0, NULL); + break; + case GLIBTOP_CMND_MEM: + glibtop_get_mem_l (server, &response.u.data.mem); + do_output (s, &response, _offset_data (mem), 0, NULL); + break; + case GLIBTOP_CMND_SWAP: + glibtop_get_swap_l (server, &response.u.data.swap); + do_output (s, &response, _offset_data (swap), 0, NULL); + break; + case GLIBTOP_CMND_UPTIME: + glibtop_get_uptime_l (server, &response.u.data.uptime); + do_output (s, &response, _offset_data (uptime), 0, NULL); + break; + case GLIBTOP_CMND_LOADAVG: + glibtop_get_loadavg_l (server, &response.u.data.loadavg); + do_output (s, &response, _offset_data (loadavg), 0, NULL); + break; + case GLIBTOP_CMND_SHM_LIMITS: + glibtop_get_shm_limits_l (server, &response.u.data.shm_limits); + do_output (s, &response, _offset_data (shm_limits), 0, NULL); + break; + case GLIBTOP_CMND_MSG_LIMITS: + glibtop_get_msg_limits_l (server, &response.u.data.msg_limits); + do_output (s, &response, _offset_data (msg_limits), 0, NULL); + break; + case GLIBTOP_CMND_SEM_LIMITS: + glibtop_get_sem_limits_l (server, &response.u.data.sem_limits); + do_output (s, &response, _offset_data (sem_limits), 0, NULL); + break; + case GLIBTOP_CMND_PROCLIST: + ptr = glibtop_get_proclist_l (server, &response.u.data.proclist); + do_output (s, &response, _offset_data (proclist), + response.u.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, &response.u.data.proc_state, pid); + do_output (s, &response, _offset_data (proc_state), 0, NULL); + break; + case GLIBTOP_CMND_PROC_UID: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_uid_l + (server, &response.u.data.proc_uid, pid); + do_output (s, &response, _offset_data (proc_uid), 0, NULL); + break; + case GLIBTOP_CMND_PROC_MEM: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_mem_l + (server, &response.u.data.proc_mem, pid); + do_output (s, &response, _offset_data (proc_mem), 0, NULL); + break; + case GLIBTOP_CMND_PROC_TIME: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_time_l + (server, &response.u.data.proc_time, pid); + do_output (s, &response, _offset_data (proc_time), 0, NULL); + break; + case GLIBTOP_CMND_PROC_SIGNAL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_signal_l + (server, &response.u.data.proc_signal, pid); + do_output (s, &response, _offset_data (proc_signal), 0, NULL); + break; + case GLIBTOP_CMND_PROC_KERNEL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_kernel_l + (server, &response.u.data.proc_kernel, pid); + do_output (s, &response, _offset_data (proc_kernel), 0, NULL); + break; + case GLIBTOP_CMND_PROC_SEGMENT: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_segment_l + (server, &response.u.data.proc_segment, pid); + do_output (s, &response, _offset_data (proc_segment), 0, NULL); + break; + default: + glibtop_warn_r (server, + "Parent received unknown command %u", + cmnd.command); + break; + } } } void -handle_socket_connection (glibtop *server, int s) +handle_child_connection (glibtop *server, int s) { pid_t pid; char parameter [BUFSIZ]; @@ -102,11 +276,10 @@ handle_socket_connection (glibtop *server, int s) tv.tv_sec = 5; tv.tv_usec = 0; - while(1) { - do_read (s, &cmnd, sizeof (glibtop_command)); - -#ifdef REAL_DEBUG - fprintf (stderr, "Received command %d from client.\n", cmnd.command); + while (do_read (s, &cmnd, sizeof (glibtop_command))) { +#ifdef CHILD_DEBUG + fprintf (stderr, "Child (%d - %d) received command " + "%d from client.\n", getpid (), s, cmnd.command); #endif if (cmnd.data_size >= BUFSIZ) { @@ -117,7 +290,7 @@ handle_socket_connection (glibtop *server, int s) memset (parameter, 0, sizeof (parameter)); if (cmnd.data_size) { -#ifdef REAL_DEBUG +#ifdef CHILD_DEBUG fprintf (stderr, "Client has %d bytes of data.\n", cmnd.data_size); #endif @@ -128,8 +301,14 @@ handle_socket_connection (glibtop *server, int s) } switch (cmnd.command) { + case GLIBTOP_CMND_QUIT: + do_output (s, &response, 0, 0, NULL); + + fprintf (stderr, "Child received QUIT command.\n"); + + return; case GLIBTOP_CMND_SYSDEPS: - response.u.sysdeps.features = GLIBTOP_SYSDEPS_ALL; + response.u.sysdeps.features = glibtop_server_features; do_output (s, &response, _offset_union (sysdeps), 0, NULL); break; case GLIBTOP_CMND_CPU: @@ -213,6 +392,12 @@ handle_socket_connection (glibtop *server, int s) (server, &response.u.data.proc_segment, pid); do_output (s, &response, _offset_data (proc_segment), 0, NULL); break; + default: + glibtop_warn_r (server, + "Child received unknown command %u", + cmnd.command); + break; + } } } diff --git a/src/daemon/server_config.h b/src/daemon/server_config.h new file mode 100644 index 00000000..9a563865 --- /dev/null +++ b/src/daemon/server_config.h @@ -0,0 +1,14 @@ +#define SERVER_PORT 42800 + +#define SERVER_UID 99 +#define SERVER_GID 99 + +#define HOST_TABLE_ENTRIES 3 + +const char *permitted_host_names [HOST_TABLE_ENTRIES] = +{ "localhost", + "voyager.home-of-linux.com", + "einstein.home-of-linux.com", +}; + +unsigned long permitted_hosts [HOST_TABLE_ENTRIES]; diff --git a/sysdeps/linux/procstate.c b/sysdeps/linux/procstate.c index bcf55662..7b843aa5 100644 --- a/sysdeps/linux/procstate.c +++ b/sysdeps/linux/procstate.c @@ -73,8 +73,10 @@ glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) return; } - input [nread] = 0; + fclose (f); + input [nread] = 0; + /* This is from guile-utils/gtop/proc/readproc.c */ /* split into "PID (cmd" and "" */ From 8ecb7f296e7eeea770fd56fab34cbbf3dff3a6be Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 15:02:20 +0000 Subject: [PATCH 0173/2539] Removed from CVS. This is a config file which needs to be edited. 1998-07-13 Martin Baulig * src/daemon/server_config.h: Removed from CVS. This is a config file which needs to be edited. * src/daemon/server_config.h.in: Added. This is just an example for `server_config.h'. --- src/daemon/{server_config.h => server_config.h.in} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/daemon/{server_config.h => server_config.h.in} (100%) diff --git a/src/daemon/server_config.h b/src/daemon/server_config.h.in similarity index 100% rename from src/daemon/server_config.h rename to src/daemon/server_config.h.in From 2c8ae097761b15d0d52ec4a765d9dd711ad211e1 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 15:04:40 +0000 Subject: [PATCH 0174/2539] Added `server_config.h'. --- src/daemon/.cvsignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/daemon/.cvsignore b/src/daemon/.cvsignore index e86ad538..7ebf5f4a 100644 --- a/src/daemon/.cvsignore +++ b/src/daemon/.cvsignore @@ -1,3 +1,4 @@ Makefile.in Makefile gnuserv +server_config.h From b991ecaf9a2c2fb102636ffc4d9d35ec5640a919 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 22:32:00 +0000 Subject: [PATCH 0175/2539] changed suffix of all functions from '_s' to '_r'; see also ChangeLog 1998-07-14 Martin Baulig * sysdeps/stub/*.c: changed suffix of all functions from '_s' to '_r'; see also ChangeLog entry from Jun 6. --- sysdeps/stub/close.c | 2 +- sysdeps/stub/cpu.c | 2 +- sysdeps/stub/glibtop_server.h | 46 +++++++++++++++++++++++++++++++++++ sysdeps/stub/init.c | 6 +++-- sysdeps/stub/loadavg.c | 2 +- sysdeps/stub/mem.c | 2 +- sysdeps/stub/msg_limits.c | 2 +- sysdeps/stub/open.c | 3 ++- sysdeps/stub/prockernel.c | 4 +-- sysdeps/stub/proclist.c | 2 +- sysdeps/stub/procmem.c | 4 +-- sysdeps/stub/procsegment.c | 4 +-- sysdeps/stub/procsignal.c | 2 +- sysdeps/stub/procstate.c | 4 +-- sysdeps/stub/proctime.c | 4 +-- sysdeps/stub/procuid.c | 4 +-- sysdeps/stub/sem_limits.c | 2 +- sysdeps/stub/shm_limits.c | 2 +- sysdeps/stub/swap.c | 2 +- sysdeps/stub/uptime.c | 2 +- 20 files changed, 75 insertions(+), 26 deletions(-) create mode 100644 sysdeps/stub/glibtop_server.h diff --git a/sysdeps/stub/close.c b/sysdeps/stub/close.c index ff7ebea4..02f2e5b3 100644 --- a/sysdeps/stub/close.c +++ b/sysdeps/stub/close.c @@ -24,5 +24,5 @@ /* Closes pipe to gtop server. */ void -glibtop_close (glibtop *server) +glibtop_close_l (glibtop *server) { } diff --git a/sysdeps/stub/cpu.c b/sysdeps/stub/cpu.c index a7d31ad6..9a40ed3c 100644 --- a/sysdeps/stub/cpu.c +++ b/sysdeps/stub/cpu.c @@ -25,7 +25,7 @@ /* Provides information about cpu usage. */ void -glibtop_get_cpu_r (glibtop *server, glibtop_cpu *buf) +glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) { memset (buf, 0, sizeof (glibtop_cpu)); } diff --git a/sysdeps/stub/glibtop_server.h b/sysdeps/stub/glibtop_server.h new file mode 100644 index 00000000..52b1b3c0 --- /dev/null +++ b/sysdeps/stub/glibtop_server.h @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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. */ + +#ifndef __GLIBTOP_SERVER_H__ +#define __GLIBTOP_SERVER_H__ + +__BEGIN_DECLS + +#define GLIBTOP_SUID_CPU 0 +#define GLIBTOP_SUID_MEM 0 +#define GLIBTOP_SUID_SWAP 0 +#define GLIBTOP_SUID_UPTIME 0 +#define GLIBTOP_SUID_LOADAVG 0 +#define GLIBTOP_SUID_SHM_LIMITS 0 +#define GLIBTOP_SUID_MSG_LIMITS 0 +#define GLIBTOP_SUID_SEM_LIMITS 0 +#define GLIBTOP_SUID_PROCLIST 0 +#define GLIBTOP_SUID_PROC_STATE 0 +#define GLIBTOP_SUID_PROC_UID 0 +#define GLIBTOP_SUID_PROC_MEM 0 +#define GLIBTOP_SUID_PROC_TIME 0 +#define GLIBTOP_SUID_PROC_SIGNAL 0 +#define GLIBTOP_SUID_PROC_KERNEL 0 +#define GLIBTOP_SUID_PROC_SEGMENT 0 + +__END_DECLS + +#endif diff --git a/sysdeps/stub/init.c b/sysdeps/stub/init.c index 43f7469c..9960bb17 100644 --- a/sysdeps/stub/init.c +++ b/sysdeps/stub/init.c @@ -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_r (glibtop_global_server, "glibtop", + features, flags); } return *server = glibtop_global_server; diff --git a/sysdeps/stub/loadavg.c b/sysdeps/stub/loadavg.c index 06365338..631048e1 100644 --- a/sysdeps/stub/loadavg.c +++ b/sysdeps/stub/loadavg.c @@ -25,7 +25,7 @@ /* Provides load averange. */ void -glibtop_get_loadavg_r (glibtop *server, glibtop_loadavg *buf) +glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) { memset (buf, 0, sizeof (glibtop_loadavg)); } diff --git a/sysdeps/stub/mem.c b/sysdeps/stub/mem.c index eb930453..e9e06a93 100644 --- a/sysdeps/stub/mem.c +++ b/sysdeps/stub/mem.c @@ -25,7 +25,7 @@ /* Provides information about memory usage. */ void -glibtop_get_mem_r (glibtop *server, glibtop_mem *buf) +glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) { memset (buf, 0, sizeof (glibtop_mem)); } diff --git a/sysdeps/stub/msg_limits.c b/sysdeps/stub/msg_limits.c index f554a09e..780ed033 100644 --- a/sysdeps/stub/msg_limits.c +++ b/sysdeps/stub/msg_limits.c @@ -24,7 +24,7 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_msg_limits_r (glibtop *server, glibtop_msg_limits *buf) +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) { memset (buf, 0, sizeof (glibtop_msg_limits)); } diff --git a/sysdeps/stub/open.c b/sysdeps/stub/open.c index c2d58069..7219ab1e 100644 --- a/sysdeps/stub/open.c +++ b/sysdeps/stub/open.c @@ -24,7 +24,8 @@ /* Opens pipe to gtop server. Returns 0 on success and -1 on error. */ void -glibtop_open (glibtop *server, const char *program_name) +glibtop_open_r (glibtop *server, const char *program_name, + const unsigned long features, const unsigned flags) { memset (server, 0, sizeof (glibtop)); server->name = program_name; diff --git a/sysdeps/stub/prockernel.c b/sysdeps/stub/prockernel.c index bd04ca29..51aadf94 100644 --- a/sysdeps/stub/prockernel.c +++ b/sysdeps/stub/prockernel.c @@ -25,8 +25,8 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_kernel_r (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) +glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, + pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_kernel)); } diff --git a/sysdeps/stub/proclist.c b/sysdeps/stub/proclist.c index cd7cf2d1..654f0b19 100644 --- a/sysdeps/stub/proclist.c +++ b/sysdeps/stub/proclist.c @@ -32,7 +32,7 @@ * each buf->size big. The total size is stored in buf->total. */ unsigned * -glibtop_get_proclist_r (glibtop *server, glibtop_proclist *buf) +glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf) { memset (buf, 0, sizeof (glibtop_proclist)); return NULL; diff --git a/sysdeps/stub/procmem.c b/sysdeps/stub/procmem.c index bb1e4795..08d125d8 100644 --- a/sysdeps/stub/procmem.c +++ b/sysdeps/stub/procmem.c @@ -25,8 +25,8 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_mem_r (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) +glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, + pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_mem)); } diff --git a/sysdeps/stub/procsegment.c b/sysdeps/stub/procsegment.c index 21cd4814..3bc840da 100644 --- a/sysdeps/stub/procsegment.c +++ b/sysdeps/stub/procsegment.c @@ -25,8 +25,8 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_segment_r (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) +glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_segment)); } diff --git a/sysdeps/stub/procsignal.c b/sysdeps/stub/procsignal.c index d4674f8f..7578fac4 100644 --- a/sysdeps/stub/procsignal.c +++ b/sysdeps/stub/procsignal.c @@ -25,7 +25,7 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_signal_r (glibtop *server, glibtop_proc_signal *buf, +glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_signal)); diff --git a/sysdeps/stub/procstate.c b/sysdeps/stub/procstate.c index acf32c2e..1e4bb4f8 100644 --- a/sysdeps/stub/procstate.c +++ b/sysdeps/stub/procstate.c @@ -25,8 +25,8 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_state_r (glibtop *server, glibtop_proc_state *buf, - pid_t pid) +glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, + pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_state)); } diff --git a/sysdeps/stub/proctime.c b/sysdeps/stub/proctime.c index d2417173..d646c321 100644 --- a/sysdeps/stub/proctime.c +++ b/sysdeps/stub/proctime.c @@ -25,8 +25,8 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_time_r (glibtop *server, glibtop_proc_time *buf, - pid_t pid) +glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, + pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_time)); } diff --git a/sysdeps/stub/procuid.c b/sysdeps/stub/procuid.c index e3a7e741..a753f0d3 100644 --- a/sysdeps/stub/procuid.c +++ b/sysdeps/stub/procuid.c @@ -25,8 +25,8 @@ /* Provides detailed information about a process. */ void -glibtop_get_proc_uid_r (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) +glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, + pid_t pid) { memset (buf, 0, sizeof (glibtop_proc_uid)); } diff --git a/sysdeps/stub/sem_limits.c b/sysdeps/stub/sem_limits.c index 81676129..062d4886 100644 --- a/sysdeps/stub/sem_limits.c +++ b/sysdeps/stub/sem_limits.c @@ -24,7 +24,7 @@ /* Provides information about sysv sem limits. */ void -glibtop_get_sem_limits_r (glibtop *server, glibtop_sem_limits *buf) +glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) { memset (buf, 0, sizeof (glibtop_sem_limits)); } diff --git a/sysdeps/stub/shm_limits.c b/sysdeps/stub/shm_limits.c index aa671129..b4ac4bb3 100644 --- a/sysdeps/stub/shm_limits.c +++ b/sysdeps/stub/shm_limits.c @@ -24,7 +24,7 @@ /* Provides information about sysv ipc limits. */ void -glibtop_get_shm_limits_r (glibtop *server, glibtop_shm_limits *buf) +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) { memset (buf, 0, sizeof (glibtop_shm_limits)); } diff --git a/sysdeps/stub/swap.c b/sysdeps/stub/swap.c index c58f0e5b..dbd7ef6c 100644 --- a/sysdeps/stub/swap.c +++ b/sysdeps/stub/swap.c @@ -25,7 +25,7 @@ /* Provides information about swap usage. */ void -glibtop_get_swap_r (glibtop *server, glibtop_swap *buf) +glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) { memset (buf, 0, sizeof (glibtop_swap)); } diff --git a/sysdeps/stub/uptime.c b/sysdeps/stub/uptime.c index 0b33cca4..e9d887df 100644 --- a/sysdeps/stub/uptime.c +++ b/sysdeps/stub/uptime.c @@ -25,7 +25,7 @@ /* Provides uptime and idle time. */ void -glibtop_get_uptime_r (glibtop *server, glibtop_uptime *buf) +glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) { memset (buf, 0, sizeof (glibtop_uptime)); } From 49adb94af0689312c017445ba5bc3fd0fa783c76 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 22:34:23 +0000 Subject: [PATCH 0176/2539] Only changed indentation. --- sysdeps/linux/init.c | 4 ++-- sysdeps/linux/mem.c | 3 ++- sysdeps/linux/open.c | 2 +- sysdeps/sun4/init.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sysdeps/linux/init.c b/sysdeps/linux/init.c index f491070f..4ccea04f 100644 --- a/sysdeps/linux/init.c +++ b/sysdeps/linux/init.c @@ -27,7 +27,7 @@ glibtop *glibtop_global_server = NULL; glibtop * glibtop_init_r (glibtop **server, const unsigned long features, - const unsigned flags) + const unsigned flags) { if (*server != NULL) return *server; @@ -37,7 +37,7 @@ glibtop_init_r (glibtop **server, const unsigned long features, if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; glibtop_open_r (glibtop_global_server, "glibtop", - features, flags); + features, flags); } return *server = glibtop_global_server; diff --git a/sysdeps/linux/mem.c b/sysdeps/linux/mem.c index 4d6d7f72..6b17b671 100644 --- a/sysdeps/linux/mem.c +++ b/sysdeps/linux/mem.c @@ -48,7 +48,8 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) if (!f) return; fscanf (f, "%*[^\n]\nMem: %lu %lu %lu %lu %lu %lu\n", - &buf->total, &buf->used, &buf->free, &buf->shared, &buf->buffer, &buf->cached); + &buf->total, &buf->used, &buf->free, &buf->shared, + &buf->buffer, &buf->cached); buf->user = buf->total - buf->free - buf->shared - buf->buffer; diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index 69f00051..f893c171 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -52,7 +52,7 @@ static void set_linux_version(void) { void glibtop_open_r (glibtop *server, const char *program_name, - const unsigned long features, const unsigned flags) + const unsigned long features, const unsigned flags) { memset (server, 0, sizeof (glibtop)); server->name = program_name; diff --git a/sysdeps/sun4/init.c b/sysdeps/sun4/init.c index 5613d1cb..9960bb17 100644 --- a/sysdeps/sun4/init.c +++ b/sysdeps/sun4/init.c @@ -27,7 +27,7 @@ glibtop *glibtop_global_server = NULL; glibtop * glibtop_init_r (glibtop **server, const unsigned long features, - const unsigned flags) + const unsigned flags) { if (*server != NULL) return *server; @@ -35,7 +35,7 @@ glibtop_init_r (glibtop **server, const unsigned long features, if (glibtop_global_server == NULL) { glibtop_global_server = &_glibtop_global_server; glibtop_open_r (glibtop_global_server, "glibtop", - features, flags); + features, flags); } return *server = glibtop_global_server; From c5263a881e95b6a24924be75d997877d37d0c71a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 22:37:05 +0000 Subject: [PATCH 0177/2539] Using `$(top_srcdir)/features.def' instead of 1998-07-14 Martin Baulig * sysdeps/guile/Makefile.am: Using `$(top_srcdir)/features.def' instead of `$(top_builddir)/features.def'. * sysdeps/guile/names/Makefile.am: Dito. --- sysdeps/guile/Makefile.am | 4 ++-- sysdeps/guile/names/Makefile.am | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdeps/guile/Makefile.am b/sysdeps/guile/Makefile.am index ed83e8e0..26b742ae 100644 --- a/sysdeps/guile/Makefile.am +++ b/sysdeps/guile/Makefile.am @@ -18,8 +18,8 @@ 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 +guile.c: guile.awk $(top_builddir)/config.h $(top_srcdir)/features.def + $(AWK) -f $(srcdir)/guile.awk < $(top_srcdir)/features.def > gnc-t mv gnc-t guile.c EXTRA_DIST = guile.awk diff --git a/sysdeps/guile/names/Makefile.am b/sysdeps/guile/names/Makefile.am index cd86bc57..bf6edbbf 100644 --- a/sysdeps/guile/names/Makefile.am +++ b/sysdeps/guile/names/Makefile.am @@ -12,8 +12,8 @@ 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 +guile-names.c: guile-names.awk $(top_builddir)/config.h $(top_srcdir)/features.def + $(AWK) -f $(srcdir)/guile-names.awk < $(top_srcdir)/features.def > gnc-t mv gnc-t guile-names.c EXTRA_DIST = guile-names.awk From da7d7ff1163371de85e4735b94d1749fe12e0860 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 23:21:40 +0000 Subject: [PATCH 0178/2539] Fixed type in debugging statement. --- lib/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/command.c b/lib/command.c index b9d927c3..acd60081 100644 --- a/lib/command.c +++ b/lib/command.c @@ -57,7 +57,7 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size, glibtop_read_l (server, sizeof (glibtop_response), &response); #ifdef DEBUG - fprintf (stderr, "RESPONSE: %d - %d\n", + fprintf (stderr, "RESPONSE: %lu - %d\n", response.offset, response.data_size); #endif From 345a657d2c5bbfae11b848016f012c199a6b328d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 23:27:10 +0000 Subject: [PATCH 0179/2539] New file. 1998-07-14 Martin Baulig * src/daemon/slave.c: New file. * src/daemon/*.c: Done some more work on the daemon. * sysdeps/common/gnuslib.c: Removed IPC stuff. * include/glibtop/gnuserv.h: Removed IPC stuff. * include/glibtop/command.h (glibtop_response_unit): Added typedef for `struct _glibtop_response_unit'. * lib/Makefile.am: Using `$(top_srcdir)/features.def' instead of `$(top_builddir)/features.def'. * sysdeps/guile/Makefile.am: Using `$(top_srcdir)/features.def' instead of `$(top_builddir)/features.def'. * sysdeps/guile/names/Makefile.am: Dito. * sysdeps/stub/*.c: changed suffix of all functions from '_s' to '_r'; see also ChangeLog entry from Jun 6. --- .cvsignore | 1 + ChangeLog | 24 ++++ include/glibtop/command.h | 4 +- include/glibtop/gnuserv.h | 44 +----- lib/Makefile.am | 4 +- src/daemon/Makefile.am | 2 +- src/daemon/gnuserv.c | 283 +++++++------------------------------- src/daemon/main.c | 259 ++++++++++++---------------------- src/daemon/slave.c | 155 +++++++++++++++++++++ sysdeps/common/gnuslib.c | 87 +----------- 10 files changed, 329 insertions(+), 534 deletions(-) create mode 100644 src/daemon/slave.c diff --git a/.cvsignore b/.cvsignore index abed9664..6b0b0b60 100644 --- a/.cvsignore +++ b/.cvsignore @@ -24,3 +24,4 @@ stamp-h sun4 sun4sol2 support +i386-freebsd diff --git a/ChangeLog b/ChangeLog index 0ed291db..2a965cb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +1998-07-14 Martin Baulig + + * src/daemon/slave.c: New file. + + * src/daemon/*.c: Done some more work on the daemon. + + * sysdeps/common/gnuslib.c: Removed IPC stuff. + + * include/glibtop/gnuserv.h: Removed IPC stuff. + + * include/glibtop/command.h (glibtop_response_unit): Added + typedef for `struct _glibtop_response_unit'. + + * lib/Makefile.am: Using `$(top_srcdir)/features.def' + instead of `$(top_builddir)/features.def'. + + * sysdeps/guile/Makefile.am: Using `$(top_srcdir)/features.def' + instead of `$(top_builddir)/features.def'. + + * sysdeps/guile/names/Makefile.am: Dito. + + * sysdeps/stub/*.c: changed suffix of all functions + from '_s' to '_r'; see also ChangeLog entry from Jun 6. + 1998-07-13 Martin Baulig * glibtop.h: Fixed invocation of `glibtop_close_r'. diff --git a/include/glibtop/command.h b/include/glibtop/command.h index 1987e5d1..c76ed0ed 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -53,7 +53,9 @@ __BEGIN_DECLS #define _GLIBTOP_PARAM_SIZE 16 typedef struct _glibtop_command glibtop_command; + typedef struct _glibtop_response glibtop_response; +typedef union _glibtop_response_union glibtop_response_union; struct _glibtop_command { @@ -73,7 +75,7 @@ struct _glibtop_response { off_t offset; size_t size, data_size; - union _glibtop_response_union u; + glibtop_response_union u; }; #define glibtop_call(p1, p2, p3, p4) glibtop_call_r(glibtop_global_server, p1, p2, p3, p4) diff --git a/include/glibtop/gnuserv.h b/include/glibtop/gnuserv.h index 6d1df518..96099259 100644 --- a/include/glibtop/gnuserv.h +++ b/include/glibtop/gnuserv.h @@ -55,8 +55,7 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a */ #define INTERNET_DOMAIN_SOCKETS -#define UNIX_DOMAIN_SOCKETS -// #define SYSV_IPC +#define UNIX_DOMAIN_SOCKETS /* * Define additional authentication protocols to be used. These methods will @@ -90,15 +89,13 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a * Pick a default communication scheme, if none was specified. */ -#if !defined(SYSV_IPC) && !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) +#if !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) -#ifdef HAVE_SYSVIPC -#define SYSV_IPC /* SYSV systems use SYSV IPC by default */ -#endif /* HAVE_SYSVIPC */ +/* BSD systems use Unix Domain sockets by default */ #ifdef BSD -#define UNIX_DOMAIN_SOCKETS /* BSD systems use Unix Domain sockets by default */ -#endif /* BSD */ +#define UNIX_DOMAIN_SOCKETS +#endif #endif /* No communication method pre-defined */ @@ -110,24 +107,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a * what you want. */ -# define GSERV_BUFSZ BUFSIZ - - -#ifdef SYSV_IPC -#include -#include - -#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 #endif /* INTERNET_DOMAIN_SOCKETS || UNIX_DOMAIN_SOCKETS */ @@ -154,9 +133,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a #undef TRUE #define TRUE 1 -// extern char *optarg; -// extern int optind; - /* 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)) @@ -177,16 +153,6 @@ static char header_rcsid [] = "!Header: gnuserv.h,v 2.4 95/02/16 11:58:11 arup a /* function declarations */ extern int glibtop_make_connection __P((const char *, int, int *)); -#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 extern long glibtop_internet_addr __P((const char *)); #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index 32a555a9..23e211e1 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -13,8 +13,8 @@ libgtop_la_SOURCES = init.c open.c close.c command.c read.c read_data.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 +lib.c: lib.awk $(top_builddir)/config.h $(top_srcdir)/features.def + $(AWK) -f $(srcdir)/lib.awk < $(top_srcdir)/features.def > lib-t mv lib-t lib.c EXTRA_DIST = lib.awk diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index fd221379..ab15886e 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -10,7 +10,7 @@ bin_PROGRAMS = gnuserv EXTRA_PROGRAMS = gtop_daemon -gnuserv_SOURCES = gnuserv.c main.c +gnuserv_SOURCES = gnuserv.c main.c slave.c gnuserv_LDADD = $(top_builddir)/lib/libgtop.la \ $(top_builddir)/sysdeps/common/libgtop_common.la \ $(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps.la \ diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index 4e40e4d2..18bff88c 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -29,11 +29,11 @@ * ../etc/gnuserv.README relative to the directory containing this file) */ -static char rcsid[] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; - #include #include #include +#include +#include #include "server_config.h" @@ -46,196 +46,14 @@ static char rcsid[] = "!Header: gnuserv.c,v 2.1 95/02/16 11:58:27 arup alpha !"; #include #endif -extern void handle_parent_connection __P ((glibtop *, int)); -extern void handle_child_connection __P ((glibtop *, int)); +extern void handle_parent_connection __P ((int)); +extern void handle_child_connection __P ((int)); +extern void handle_ipc_connection __P ((int)); -#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/lgtd%d", (int) geteuid ()); - creat (buf, 0600); - key = ftok (buf, 1); - - if ((ipc_qid = msgget (key, 0600 | IPC_CREAT)) == -1) - glibtop_error_io ("unable to create msg queue"); - - ipc_spawn_watchdog (); - - signal (SIGTERM, ipc_handle_signal); - signal (SIGINT, ipc_handle_signal); - - if ((*msgpp = (struct msgbuf *) - malloc (sizeof **msgpp + GSERV_BUFSZ)) == NULL) { - glibtop_warn_io ("unable to allocate space for message buffer"); - 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) -{ -#if 0 - 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) { - glibtop_warn_io ("msgrcv"); - 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) { - glibtop_warn_io ("read"); - 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) - glibtop_error_io ("read"); - - /* 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) - glibtop_error_io ("read"); - - /* 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) - glibtop_error_io ("read"); - - if (buf[0] != '\n') - glibtop_error ("garbage after result [%c]", buf[0]); +#if !defined(UNIX_DOMAIN_SOCKETS) && !defined(INTERNET_DOMAIN_SOCKETS) +#error "Unix Domain sockets or Internet Domain sockets are required" #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) - glibtop_warn_io ("msgsend(gnuserv)"); -#else - glibtop_error ("handle_ipc_request (): Function not implemented"); -#endif -} /* handle_ipc_request */ -#endif /* SYSV_IPC */ - - #ifdef INTERNET_DOMAIN_SOCKETS #ifdef AUTH_MAGIC_COOKIE @@ -244,7 +62,11 @@ handle_ipc_request (struct msgbuf *msgp) static Xauth *server_xauth = NULL; -#endif +#endif /* INTERNET_DOMAIN_SOCKETS */ + +/* + * timed_read - Read with timeout. + */ static int timed_read (int fd, char *buf, int max, int timeout, int one_line) @@ -289,10 +111,10 @@ timed_read (int fd, char *buf, int max, int timeout, int one_line) } - /* * permitted -- return whether a given host is allowed to connect to the server. */ + static int permitted (u_long host_addr, int fd) { @@ -311,21 +133,22 @@ permitted (u_long host_addr, int fd) return FALSE; #ifdef DEBUG - fprintf (stderr, "Client sent authenticatin protocol '%s'\n", auth_protocol); + fprintf (stderr, "Client sent authenticatin protocol '%s'\n", + auth_protocol); #endif if (strcmp (auth_protocol, DEFAUTH_NAME) && strcmp (auth_protocol, MCOOKIE_NAME)) { - glibtop_warn ("Authentication protocol from client is invalid", auth_protocol); - + glibtop_warn ("Invalid authentication protocol " + "'%s' from client", auth_protocol); return FALSE; } - if (!strcmp (auth_protocol, MCOOKIE_NAME)) { + if (!strcmp (auth_protocol, MCOOKIE_NAME)) { /* * doing magic cookie auth */ - + if (timed_read (fd, buf, 10, AUTH_TIMEOUT, 1) <= 0) return FALSE; @@ -336,27 +159,30 @@ permitted (u_long host_addr, int fd) #ifdef AUTH_MAGIC_COOKIE if (server_xauth && server_xauth->data && - !memcmp (buf, server_xauth->data, auth_data_len)) { + !memcmp (buf, server_xauth->data, auth_data_len)) { return TRUE; } #else - glibtop_warn ("client tried Xauth, but server is not compiled with Xauth"); + glibtop_warn ("Client tried Xauth, but server is " + "not compiled with Xauth"); #endif /* - * auth failed, but allow this to fall through to the GNU_SECURE - * protocol.... + * auth failed, but allow this to fall through to the + * GNU_SECURE protocol.... */ - glibtop_warn ("Xauth authentication failed, trying GNU_SECURE auth..."); - + glibtop_warn ("Xauth authentication failed, " + "trying GNU_SECURE auth..."); + } + /* Other auth protocols go here, and should execute only if * the * auth_protocol name matches. */ - } + /* Now, try the old GNU_SECURE stuff... */ - + #ifdef DEBUG fprintf (stderr, "Doing GNU_SECURE auth ...\n"); #endif @@ -370,9 +196,9 @@ permitted (u_long host_addr, int fd) if (host_addr == permitted_hosts [i]) return (TRUE); } - + return (FALSE); -} /* permitted */ +} /* @@ -383,6 +209,7 @@ permitted (u_long host_addr, int fd) * add each host that is named in the file. * Return the number of hosts added. */ + static int setup_table (void) { @@ -436,11 +263,11 @@ setup_table (void) return hosts; } /* setup_table */ - /* * internet_init -- initialize server, returning an internet socket that can * be listened on. */ + static int internet_init (void) { @@ -479,9 +306,10 @@ internet_init (void) /* - * handle_internet_request -- accept a request from a client and send the information - * to stdout (the gnu process). + * 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) { @@ -519,7 +347,7 @@ handle_internet_request (int ls) if (pid) return; - handle_parent_connection (glibtop_global_server, s); + handle_parent_connection (s); close (s); @@ -631,7 +459,7 @@ handle_unix_request (int ls) if (pid) return; - handle_child_connection (glibtop_global_server, s); + handle_child_connection (s); close (s); @@ -659,18 +487,13 @@ main (int argc, char *argv []) int uls = -1; /* unix domain listen socket */ pid_t pid; -#ifdef SYSV_IPC - struct msgbuf *msgp; /* message buffer */ - -#endif /* SYSV_IPC */ - glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE); /* Fork a child. * * The parent will listen for incoming internet connections * and the child will listen for connections from the local - * host using unix domain name sockets or SysV IPC. + * host using unix domain name sockets. */ signal (SIGCHLD, handle_signal); @@ -696,15 +519,10 @@ main (int argc, char *argv []) fprintf (stderr, "Child ID: (%d, %d) - (%d, %d)\n", getuid (), geteuid (), getgid (), getegid ()); -#ifdef SYSV_IPC - /* get a msqid to listen on, and a message buffer. */ - ipc_init (&msgp); -#endif /* SYSV_IPC */ - #ifdef UNIX_DOMAIN_SOCKETS /* get a unix domain socket to listen on. */ uls = unix_init (); -#endif /* UNIX_DOMAIN_SOCKETS */ +#endif } else { /* We are the parent. */ @@ -756,13 +574,10 @@ main (int argc, char *argv []) #ifdef INTERNET_DOMAIN_SOCKETS /* get a internet domain socket to listen on. */ ils = internet_init (); -#endif /* INTERNET_DOMAIN_SOCKETS */ +#endif } while (1) { -#ifdef SYSV_IPC - handle_ipc_request (msgp); -#else /* NOT SYSV_IPC */ fd_set rmask; int ret; @@ -770,8 +585,7 @@ main (int argc, char *argv []) if ((ret == -1) && (errno == ECHILD)) break; - if ((ret == -1) && ((errno == EAGAIN) || - (errno == ERESTART))) + if ((ret == -1) && ((errno == EAGAIN))) continue; if (ret > 0) fprintf (stderr, "Child %d exited.\n", ret); @@ -812,14 +626,11 @@ main (int argc, char *argv []) #ifdef INTERNET_DOMAIN_SOCKETS if (ils > 0 && FD_ISSET (ils, &rmask)) handle_internet_request (ils); -#endif /* INTERNET_DOMAIN_SOCKETS */ +#endif if (FD_ISSET (fileno (stdin), &rmask)) - handle_child_connection (glibtop_global_server, fileno (stdin)); -#endif /* NOT SYSV_IPC */ - } /* while */ + handle_child_connection (fileno (stdin)); + } return 0; -} /* main */ - -#endif /* SYSV_IPC || UNIX_DOMAIN_SOCKETS || INTERNET_DOMAIN_SOCKETS */ +} diff --git a/src/daemon/main.c b/src/daemon/main.c index 3537ee92..6351e33e 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -34,6 +34,9 @@ #undef REAL_DEBUG #define PARENT_DEBUG +#define MSG_BUFSZ sizeof (struct _glibtop_ipc_message) +#define MSG_MSGSZ (MSG_BUFSZ - sizeof (long)) + #if defined(HAVE_GETDTABLESIZE) #define GET_MAX_FDS() getdtablesize() #else @@ -42,11 +45,13 @@ #define GET_MAX_FDS() 256 #endif -#define _offset_union(p) ((char *) &response.u.p - (char *) &response) +extern void handle_slave_command __P((glibtop_command *, glibtop_response *, const void *)); + +#define _offset_union(p) ((char *) &resp->u.p - (char *) resp) #define _offset_data(p) _offset_union (data.p) static void -do_output (int s, glibtop_response *response, off_t offset, +do_output (int s, glibtop_response *resp, off_t offset, size_t data_size, const void *data) { #ifdef REAL_DEBUG @@ -54,18 +59,18 @@ do_output (int s, glibtop_response *response, off_t offset, sizeof (glibtop_response), offset); #endif - response->offset = offset; - response->data_size = data_size; + resp->offset = offset; + resp->data_size = data_size; - if (send (s, response, sizeof (glibtop_response), 0) < 0) + if (send (s, resp, sizeof (glibtop_response), 0) < 0) glibtop_warn_io ("send"); - if (response->data_size) { + if (resp->data_size) { #ifdef REAL_DEBUG - fprintf (stderr, "Writing %d bytes of data.\n", response->data_size); + fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size); #endif - if (send (s, data, response->data_size, 0) , 0) + if (send (s, data, resp->data_size, 0) , 0) glibtop_warn_io ("send"); } } @@ -106,20 +111,16 @@ do_read (int s, void *ptr, size_t total_size) } void -handle_parent_connection (glibtop *server, int s) +handle_parent_connection (int s) { - pid_t pid; + glibtop *server = glibtop_global_server; + glibtop_response _resp, *resp = &_resp; + glibtop_command _cmnd, *cmnd = &_cmnd; char parameter [BUFSIZ]; - struct timeval tv; - glibtop_response response; - glibtop_command cmnd; unsigned method; - int null = 0; + pid_t pid; void *ptr; - tv.tv_sec = 5; - tv.tv_usec = 0; - method = GLIBTOP_METHOD_UNIX; glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD, @@ -134,30 +135,30 @@ handle_parent_connection (glibtop *server, int s) while (do_read (s, &cmnd, sizeof (glibtop_command))) { #ifdef PARENT_DEBUG fprintf (stderr, "Parent (%d) received command %d from client.\n", - getpid (), cmnd.command); + getpid (), cmnd->command); #endif - if (cmnd.data_size >= BUFSIZ) { - glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd.size, BUFSIZ); + if (cmnd->data_size >= BUFSIZ) { + glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd->size, BUFSIZ); return; } memset (parameter, 0, sizeof (parameter)); - if (cmnd.data_size) { + if (cmnd->data_size) { #ifdef PARENT_DEBUG - fprintf (stderr, "Client has %d bytes of data.\n", cmnd.data_size); + fprintf (stderr, "Client has %d bytes of data.\n", cmnd->data_size); #endif - do_read (s, parameter, cmnd.data_size); + do_read (s, parameter, cmnd->data_size); - } else if (cmnd.size) { - memcpy (parameter, cmnd.parameter, cmnd.size); + } else if (cmnd->size) { + memcpy (parameter, cmnd->parameter, cmnd->size); } - switch (cmnd.command) { + switch (cmnd->command) { case GLIBTOP_CMND_QUIT: - do_output (s, &response, 0, 0, NULL); + do_output (s, resp, 0, 0, NULL); fprintf (stderr, "Sending QUIT command (%d).\n", server->socket); @@ -171,233 +172,147 @@ handle_parent_connection (glibtop *server, int s) close (server->socket); return; case GLIBTOP_CMND_SYSDEPS: - response.u.sysdeps.features = GLIBTOP_SYSDEPS_ALL; - do_output (s, &response, _offset_union (sysdeps), 0, NULL); + resp->u.sysdeps.features = GLIBTOP_SYSDEPS_ALL; + do_output (s, resp, _offset_union (sysdeps), 0, NULL); break; case GLIBTOP_CMND_CPU: - glibtop_get_cpu_l (server, &response.u.data.cpu); - do_output (s, &response, _offset_data (cpu), 0, NULL); + glibtop_get_cpu_l (server, &resp->u.data.cpu); + do_output (s, resp, _offset_data (cpu), 0, NULL); break; case GLIBTOP_CMND_MEM: - glibtop_get_mem_l (server, &response.u.data.mem); - do_output (s, &response, _offset_data (mem), 0, NULL); + glibtop_get_mem_l (server, &resp->u.data.mem); + do_output (s, resp, _offset_data (mem), 0, NULL); break; case GLIBTOP_CMND_SWAP: - glibtop_get_swap_l (server, &response.u.data.swap); - do_output (s, &response, _offset_data (swap), 0, NULL); + glibtop_get_swap_l (server, &resp->u.data.swap); + do_output (s, resp, _offset_data (swap), 0, NULL); break; case GLIBTOP_CMND_UPTIME: - glibtop_get_uptime_l (server, &response.u.data.uptime); - do_output (s, &response, _offset_data (uptime), 0, NULL); + glibtop_get_uptime_l (server, &resp->u.data.uptime); + do_output (s, resp, _offset_data (uptime), 0, NULL); break; case GLIBTOP_CMND_LOADAVG: - glibtop_get_loadavg_l (server, &response.u.data.loadavg); - do_output (s, &response, _offset_data (loadavg), 0, NULL); + glibtop_get_loadavg_l (server, &resp->u.data.loadavg); + do_output (s, resp, _offset_data (loadavg), 0, NULL); break; case GLIBTOP_CMND_SHM_LIMITS: - glibtop_get_shm_limits_l (server, &response.u.data.shm_limits); - do_output (s, &response, _offset_data (shm_limits), 0, NULL); + glibtop_get_shm_limits_l (server, &resp->u.data.shm_limits); + do_output (s, resp, _offset_data (shm_limits), 0, NULL); break; case GLIBTOP_CMND_MSG_LIMITS: - glibtop_get_msg_limits_l (server, &response.u.data.msg_limits); - do_output (s, &response, _offset_data (msg_limits), 0, NULL); + glibtop_get_msg_limits_l (server, &resp->u.data.msg_limits); + do_output (s, resp, _offset_data (msg_limits), 0, NULL); break; case GLIBTOP_CMND_SEM_LIMITS: - glibtop_get_sem_limits_l (server, &response.u.data.sem_limits); - do_output (s, &response, _offset_data (sem_limits), 0, NULL); + glibtop_get_sem_limits_l (server, &resp->u.data.sem_limits); + do_output (s, resp, _offset_data (sem_limits), 0, NULL); break; case GLIBTOP_CMND_PROCLIST: - ptr = glibtop_get_proclist_l (server, &response.u.data.proclist); - do_output (s, &response, _offset_data (proclist), - response.u.data.proclist.total, ptr); + ptr = glibtop_get_proclist_l (server, &resp->u.data.proclist); + do_output (s, resp, _offset_data (proclist), + resp->u.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, &response.u.data.proc_state, pid); - do_output (s, &response, _offset_data (proc_state), 0, NULL); + (server, &resp->u.data.proc_state, pid); + do_output (s, resp, _offset_data (proc_state), 0, NULL); break; case GLIBTOP_CMND_PROC_UID: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_uid_l - (server, &response.u.data.proc_uid, pid); - do_output (s, &response, _offset_data (proc_uid), 0, NULL); + (server, &resp->u.data.proc_uid, pid); + do_output (s, resp, _offset_data (proc_uid), 0, NULL); break; case GLIBTOP_CMND_PROC_MEM: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_mem_l - (server, &response.u.data.proc_mem, pid); - do_output (s, &response, _offset_data (proc_mem), 0, NULL); + (server, &resp->u.data.proc_mem, pid); + do_output (s, resp, _offset_data (proc_mem), 0, NULL); break; case GLIBTOP_CMND_PROC_TIME: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_time_l - (server, &response.u.data.proc_time, pid); - do_output (s, &response, _offset_data (proc_time), 0, NULL); + (server, &resp->u.data.proc_time, pid); + do_output (s, resp, _offset_data (proc_time), 0, NULL); break; case GLIBTOP_CMND_PROC_SIGNAL: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_signal_l - (server, &response.u.data.proc_signal, pid); - do_output (s, &response, _offset_data (proc_signal), 0, NULL); + (server, &resp->u.data.proc_signal, pid); + do_output (s, resp, _offset_data (proc_signal), 0, NULL); break; case GLIBTOP_CMND_PROC_KERNEL: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_kernel_l - (server, &response.u.data.proc_kernel, pid); - do_output (s, &response, _offset_data (proc_kernel), 0, NULL); + (server, &resp->u.data.proc_kernel, pid); + do_output (s, resp, _offset_data (proc_kernel), 0, NULL); break; case GLIBTOP_CMND_PROC_SEGMENT: memcpy (&pid, parameter, sizeof (pid_t)); glibtop_get_proc_segment_l - (server, &response.u.data.proc_segment, pid); - do_output (s, &response, _offset_data (proc_segment), 0, NULL); + (server, &resp->u.data.proc_segment, pid); + do_output (s, resp, _offset_data (proc_segment), 0, NULL); break; default: - glibtop_warn_r (server, - "Parent received unknown command %u", - cmnd.command); + glibtop_warn ("Parent received unknown command %u", + cmnd->command); break; } } } void -handle_child_connection (glibtop *server, int s) +handle_child_connection (int s) { - pid_t pid; + glibtop *server = glibtop_global_server; + glibtop_response _resp, *resp = &_resp; + glibtop_command _cmnd, *cmnd = &_cmnd; char parameter [BUFSIZ]; - struct timeval tv; - glibtop_response response; - glibtop_command cmnd; void *ptr; - tv.tv_sec = 5; - tv.tv_usec = 0; - while (do_read (s, &cmnd, sizeof (glibtop_command))) { #ifdef CHILD_DEBUG fprintf (stderr, "Child (%d - %d) received command " - "%d from client.\n", getpid (), s, cmnd.command); + "%d from client.\n", getpid (), s, cmnd->command); #endif - if (cmnd.data_size >= BUFSIZ) { - glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd.size, BUFSIZ); + if (cmnd->data_size >= BUFSIZ) { + glibtop_warn ("Client sent %d bytes, but buffer is %d", cmnd->size, BUFSIZ); return; } memset (parameter, 0, sizeof (parameter)); - if (cmnd.data_size) { + if (cmnd->data_size) { #ifdef CHILD_DEBUG - fprintf (stderr, "Client has %d bytes of data.\n", cmnd.data_size); + fprintf (stderr, "Client has %d bytes of data.\n", cmnd->data_size); #endif - do_read (s, parameter, cmnd.data_size); + do_read (s, parameter, cmnd->data_size); - } else if (cmnd.size) { - memcpy (parameter, cmnd.parameter, cmnd.size); + } else if (cmnd->size) { + memcpy (parameter, cmnd->parameter, cmnd->size); } - switch (cmnd.command) { + switch (cmnd->command) { case GLIBTOP_CMND_QUIT: - do_output (s, &response, 0, 0, NULL); - - fprintf (stderr, "Child received QUIT command.\n"); - + do_output (s, resp, 0, 0, NULL); return; - case GLIBTOP_CMND_SYSDEPS: - response.u.sysdeps.features = glibtop_server_features; - do_output (s, &response, _offset_union (sysdeps), 0, NULL); - break; - case GLIBTOP_CMND_CPU: - glibtop_get_cpu_l (server, &response.u.data.cpu); - do_output (s, &response, _offset_data (cpu), 0, NULL); - break; - case GLIBTOP_CMND_MEM: - glibtop_get_mem_l (server, &response.u.data.mem); - do_output (s, &response, _offset_data (mem), 0, NULL); - break; - case GLIBTOP_CMND_SWAP: - glibtop_get_swap_l (server, &response.u.data.swap); - do_output (s, &response, _offset_data (swap), 0, NULL); - break; - case GLIBTOP_CMND_UPTIME: - glibtop_get_uptime_l (server, &response.u.data.uptime); - do_output (s, &response, _offset_data (uptime), 0, NULL); - break; - case GLIBTOP_CMND_LOADAVG: - glibtop_get_loadavg_l (server, &response.u.data.loadavg); - do_output (s, &response, _offset_data (loadavg), 0, NULL); - break; - case GLIBTOP_CMND_SHM_LIMITS: - glibtop_get_shm_limits_l (server, &response.u.data.shm_limits); - do_output (s, &response, _offset_data (shm_limits), 0, NULL); - break; - case GLIBTOP_CMND_MSG_LIMITS: - glibtop_get_msg_limits_l (server, &response.u.data.msg_limits); - do_output (s, &response, _offset_data (msg_limits), 0, NULL); - break; - case GLIBTOP_CMND_SEM_LIMITS: - glibtop_get_sem_limits_l (server, &response.u.data.sem_limits); - do_output (s, &response, _offset_data (sem_limits), 0, NULL); - break; +#if GLIBTOP_SUID_PROCLIST case GLIBTOP_CMND_PROCLIST: - ptr = glibtop_get_proclist_l (server, &response.u.data.proclist); - do_output (s, &response, _offset_data (proclist), - response.u.data.proclist.total, ptr); + ptr = glibtop_get_proclist_p + (server, &resp->u.data.proclist); + do_output (s, resp, _offset_data (proclist), + resp->u.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, &response.u.data.proc_state, pid); - do_output (s, &response, _offset_data (proc_state), 0, NULL); - break; - case GLIBTOP_CMND_PROC_UID: - pid = 1; - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_uid_l - (server, &response.u.data.proc_uid, pid); - do_output (s, &response, _offset_data (proc_uid), 0, NULL); - break; - case GLIBTOP_CMND_PROC_MEM: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_mem_l - (server, &response.u.data.proc_mem, pid); - do_output (s, &response, _offset_data (proc_mem), 0, NULL); - break; - case GLIBTOP_CMND_PROC_TIME: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_time_l - (server, &response.u.data.proc_time, pid); - do_output (s, &response, _offset_data (proc_time), 0, NULL); - break; - case GLIBTOP_CMND_PROC_SIGNAL: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_signal_l - (server, &response.u.data.proc_signal, pid); - do_output (s, &response, _offset_data (proc_signal), 0, NULL); - break; - case GLIBTOP_CMND_PROC_KERNEL: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_kernel_l - (server, &response.u.data.proc_kernel, pid); - do_output (s, &response, _offset_data (proc_kernel), 0, NULL); - break; - case GLIBTOP_CMND_PROC_SEGMENT: - memcpy (&pid, parameter, sizeof (pid_t)); - glibtop_get_proc_segment_l - (server, &response.u.data.proc_segment, pid); - do_output (s, &response, _offset_data (proc_segment), 0, NULL); - break; +#endif default: - glibtop_warn_r (server, - "Child received unknown command %u", - cmnd.command); + handle_slave_command (cmnd, resp, parameter); + do_output (s, resp, resp->offset, 0, NULL); break; - } } } diff --git a/src/daemon/slave.c b/src/daemon/slave.c new file mode 100644 index 00000000..19c07025 --- /dev/null +++ b/src/daemon/slave.c @@ -0,0 +1,155 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +#include +#include + +#include +#include + +#define _offset_union(p) ((char *) &resp->u.p - (char *) resp) +#define _offset_data(p) _offset_union (data.p) + +void +handle_slave_command (glibtop_command *cmnd, glibtop_response *resp, + const void *parameter) +{ + glibtop *server = glibtop_global_server; + pid_t pid; + + switch (cmnd->command) { + case GLIBTOP_CMND_SYSDEPS: + resp->u.sysdeps.features = glibtop_server_features; + resp->offset = _offset_union (sysdeps); + break; +#if GLIBTOP_SUID_CPU + case GLIBTOP_CMND_CPU: + glibtop_get_cpu_p (server, &resp->u.data.cpu); + resp->offset = _offset_data (cpu); + break; +#endif +#if GLIBTOP_SUID_MEM + case GLIBTOP_CMND_MEM: + glibtop_get_mem_p (server, &resp->u.data.mem); + resp->offset = _offset_data (mem); + break; +#endif +#if GLIBTOP_SUID_SWAP + case GLIBTOP_CMND_SWAP: + glibtop_get_swap_p (server, &resp->u.data.swap); + resp->offset = _offset_data (swap); + break; +#endif +#if GLIBTOP_SUID_UPTIME + case GLIBTOP_CMND_UPTIME: + glibtop_get_uptime_p (server, &resp->u.data.uptime); + resp->offset = _offset_data (uptime); + break; +#endif +#if GLIBTOP_SUID_LOADAVG + case GLIBTOP_CMND_LOADAVG: + glibtop_get_loadavg_p (server, &resp->u.data.loadavg); + resp->offset = _offset_data (loadavg); + break; +#endif +#if GLIBTOP_SUID_SHM_LIMITS + case GLIBTOP_CMND_SHM_LIMITS: + glibtop_get_shm_limits_p (server, &resp->u.data.shm_limits); + resp->offset = _offset_data (shm_limits); + break; +#endif +#if GLIBTOP_SUID_MSG_LIMITS + case GLIBTOP_CMND_MSG_LIMITS: + glibtop_get_msg_limits_p (server, &resp->u.data.msg_limits); + resp->offset = _offset_data (msg_limits); + break; +#endif +#if GLIBTOP_SUID_SEM_LIMITS + case GLIBTOP_CMND_SEM_LIMITS: + glibtop_get_sem_limits_p (server, &resp->u.data.sem_limits); + resp->offset = _offset_data (sem_limits); + break; +#endif +#if GLIBTOP_SUID_PROC_STATE + case GLIBTOP_CMND_PROC_STATE: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_state_p + (server, &resp->u.data.proc_state, pid); + resp->offset = _offset_data (proc_state); + break; +#endif +#if GLIBTOP_SUID_PROC_UID + case GLIBTOP_CMND_PROC_UID: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_uid_p + (server, &resp->u.data.proc_uid, pid); + resp->offset = _offset_data (proc_uid); + break; +#endif +#if GLIBTOP_SUID_PROC_MEM + case GLIBTOP_CMND_PROC_MEM: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_mem_p + (server, &resp->u.data.proc_mem, pid); + resp->offset = _offset_data (proc_mem); + break; +#endif +#if GLIBTOP_SUID_PROC_TIME + case GLIBTOP_CMND_PROC_TIME: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_time_p + (server, &resp->u.data.proc_time, pid); + resp->offset = _offset_data (proc_time); + break; +#endif +#if GLIBTOP_SUID_PROC_SIGNAL + case GLIBTOP_CMND_PROC_SIGNAL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_signal_p + (server, &resp->u.data.proc_signal, pid); + resp->offset = _offset_data (proc_signal); + break; +#endif +#if GLIBTOP_SUID_PROC_KERNEL + case GLIBTOP_CMND_PROC_KERNEL: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_kernel_p + (server, &resp->u.data.proc_kernel, pid); + resp->offset = _offset_data (proc_kernel); + break; +#endif +#if GLIBTOP_SUID_PROC_SEGMENT + case GLIBTOP_CMND_PROC_SEGMENT: + memcpy (&pid, parameter, sizeof (pid_t)); + glibtop_get_proc_segment_p + (server, &resp->u.data.proc_segment, pid); + resp->offset = _offset_data (proc_segment); + break; +#endif + default: + glibtop_error ("Child received unknown command %u", + cmnd->command); + break; + } +} diff --git a/sysdeps/common/gnuslib.c b/sysdeps/common/gnuslib.c index 99cbf47b..0a6d0e05 100644 --- a/sysdeps/common/gnuslib.c +++ b/sysdeps/common/gnuslib.c @@ -29,26 +29,17 @@ * ../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 #include #include -#ifdef SYSV_IPC -static int connect_to_ipc_server (void); - -#endif #ifdef UNIX_DOMAIN_SOCKETS -static int connect_to_unix_server (void); - +static int connect_to_unix_server __P((void)); #endif -#ifdef INTERNET_DOMAIN_SOCKETS -static int connect_to_internet_server (const char *serverhost, u_short port); +#ifdef INTERNET_DOMAIN_SOCKETS +static int connect_to_internet_server __P((const char *, u_short)); #endif /* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */ @@ -93,10 +84,6 @@ glibtop_make_connection (hostarg, portarg, s) #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 * @@ -105,9 +92,6 @@ glibtop_make_connection (hostarg, portarg, s) #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]; @@ -122,69 +106,6 @@ glibtop_make_connection (hostarg, portarg, s) } } -#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/lgtd%d", (int) geteuid ()); - creat (buf, 0600); - if ((key = ftok (buf, 1)) == -1) - glibtop_error_io ("unable to get ipc key from %s", buf); - - if ((s = msgget (key, 0600)) == -1) - glibtop_error_io ("unable to access msg queue"); - - 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. From aa04293fc3b0b6c42e44ecb12f33b4240e9358e4 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Mon, 13 Jul 1998 23:29:31 +0000 Subject: [PATCH 0180/2539] Forgot to commit this file yesterday. --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2a965cb7..09523fc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,14 @@ * sysdeps/stub/*.c: changed suffix of all functions from '_s' to '_r'; see also ChangeLog entry from Jun 6. +1998-07-13 Martin Baulig + + * src/daemon/server_config.h: Removed from CVS. + This is a config file which needs to be edited. + + * src/daemon/server_config.h.in: Added. This is just + an example for `server_config.h'. + 1998-07-13 Martin Baulig * glibtop.h: Fixed invocation of `glibtop_close_r'. From ef693a93bc715cbe453371de711cf102c1ddb83f Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 08:36:23 +0000 Subject: [PATCH 0181/2539] Doing correct server initialization using `glibtop_set_parameter_l' and 1998-07-14 Martin Baulig * src/daemon/gnuserv.c: Doing correct server initialization using `glibtop_set_parameter_l' and `glibtop_init_r'. * src/daemon/main.c: Removed call to `glibtop_init_r'. * lib/open.c (glibtop_open_l): We now call the open function of the sysdeps directory (glibtop_open_r) for server method `GLIBTOP_METHOD_DIRECT'. * sysdeps/{linux, sun4, stub}/open.c: No longer `memset' server to zero. --- ChangeLog | 12 ++++++++++++ lib/open.c | 6 ++++++ src/daemon/gnuserv.c | 31 ++++++++++++++++++++++++++++++- src/daemon/main.c | 10 ---------- sysdeps/linux/open.c | 1 - sysdeps/stub/open.c | 1 - sysdeps/sun4/open.c | 1 - 7 files changed, 48 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09523fc9..5baabd99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 1998-07-14 Martin Baulig + * src/daemon/gnuserv.c: Doing correct server initialization + using `glibtop_set_parameter_l' and `glibtop_init_r'. + + * src/daemon/main.c: Removed call to `glibtop_init_r'. + + * lib/open.c (glibtop_open_l): We now call the open function + of the sysdeps directory (glibtop_open_r) for server method + `GLIBTOP_METHOD_DIRECT'. + + * sysdeps/{linux, sun4, stub}/open.c: No longer `memset' + server to zero. + * src/daemon/slave.c: New file. * src/daemon/*.c: Done some more work on the daemon. diff --git a/lib/open.c b/lib/open.c index 783744ab..7bf1126b 100644 --- a/lib/open.c +++ b/lib/open.c @@ -43,6 +43,12 @@ glibtop_open_l (glibtop *server, const char *program_name, server->flags |= _GLIBTOP_INIT_STATE_OPEN; switch (server->method) { + case GLIBTOP_METHOD_DIRECT: + fprintf (stderr, "Calling sysdeps open function.\n"); + + glibtop_open_r (server, program_name, features, flags); + + break; case GLIBTOP_METHOD_INET: fprintf (stderr, "Connecting to '%s' port %ld.\n", server->server_host, server->server_port); diff --git a/src/daemon/gnuserv.c b/src/daemon/gnuserv.c index 18bff88c..cebe4431 100644 --- a/src/daemon/gnuserv.c +++ b/src/daemon/gnuserv.c @@ -35,6 +35,8 @@ #include #include +#include + #include "server_config.h" #include @@ -483,11 +485,13 @@ handle_signal (int sig) int main (int argc, char *argv []) { + glibtop *server = glibtop_global_server; + int ils = -1; /* internet domain listen socket */ int uls = -1; /* unix domain listen socket */ pid_t pid; - glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_OPEN_NO_OVERRIDE); + glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_INIT); /* Fork a child. * @@ -504,6 +508,8 @@ main (int argc, char *argv []) glibtop_error_io ("fork failed"); else if (pid == 0) { /* We are the child. */ + + const unsigned method = GLIBTOP_METHOD_DIRECT; /* Temporarily drop our priviledges. */ @@ -523,8 +529,22 @@ main (int argc, char *argv []) /* get a unix domain socket to listen on. */ uls = unix_init (); #endif + + glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD, + &method, sizeof (method)); + + glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES, + &glibtop_server_features, + sizeof (glibtop_server_features)); + + glibtop_init_r (&server, 0, 0); + } else { /* We are the parent. */ + + const unsigned method = GLIBTOP_METHOD_UNIX; + + const unsigned long features = GLIBTOP_SYSDEPS_ALL; /* If we are root, completely switch to SERVER_UID and * SERVER_GID. Otherwise we completely drop any priviledges. @@ -575,6 +595,15 @@ main (int argc, char *argv []) /* get a internet domain socket to listen on. */ ils = internet_init (); #endif + + glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD, + &method, sizeof (method)); + + glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES, + &features, sizeof (features)); + + glibtop_init_r (&server, 0, 0); + } while (1) { diff --git a/src/daemon/main.c b/src/daemon/main.c index 6351e33e..a7d97f43 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -117,19 +117,9 @@ handle_parent_connection (int s) glibtop_response _resp, *resp = &_resp; glibtop_command _cmnd, *cmnd = &_cmnd; char parameter [BUFSIZ]; - unsigned method; pid_t pid; void *ptr; - method = GLIBTOP_METHOD_UNIX; - - glibtop_set_parameter_l (server, GLIBTOP_PARAM_METHOD, - &method, sizeof (method)); - - glibtop_set_parameter_l (server, GLIBTOP_PARAM_FEATURES, - &glibtop_server_features, - sizeof (glibtop_server_features)); - fprintf (stderr, "Parent features = %lu\n", glibtop_server_features); while (do_read (s, &cmnd, sizeof (glibtop_command))) { diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index f893c171..cf44cc3d 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -54,7 +54,6 @@ void glibtop_open_r (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { - memset (server, 0, sizeof (glibtop)); server->name = program_name; set_linux_version (); diff --git a/sysdeps/stub/open.c b/sysdeps/stub/open.c index 7219ab1e..a45a6a60 100644 --- a/sysdeps/stub/open.c +++ b/sysdeps/stub/open.c @@ -27,6 +27,5 @@ void glibtop_open_r (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { - memset (server, 0, sizeof (glibtop)); server->name = program_name; } diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index 4e5cc6bd..7f68913c 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -64,7 +64,6 @@ glibtop_open_r (glibtop *server, const char *program_name, /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - memset (server, 0, sizeof (glibtop)); server->name = program_name; server->machine.uid = getuid (); From 9fd8936e9325e2e2e17361c49d26b8cbc1b87a16 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 10:31:17 +0000 Subject: [PATCH 0182/2539] Replaced this test with explicit test for `gawk' and `awk' since `mawk' 1998-07-14 Martin Baulig * configure.in (AC_PROG_AWK): Replaced this test with explicit test for `gawk' and `awk' since `mawk' doesn't work. --- ChangeLog | 5 +++++ configure.in | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5baabd99..f2168116 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1998-07-14 Martin Baulig + + * configure.in (AC_PROG_AWK): Replaced this test with explicit test + for `gawk' and `awk' since `mawk' doesn't work. + 1998-07-14 Martin Baulig * src/daemon/gnuserv.c: Doing correct server initialization diff --git a/configure.in b/configure.in index 6d26d22c..9c70dbac 100644 --- a/configure.in +++ b/configure.in @@ -15,7 +15,10 @@ AC_PROG_CC AC_STDC_HEADERS AC_ARG_PROGRAM -AC_PROG_AWK +dnl We don't use `AC_PROG_AWK' since it checks for mawk first which +dnl does not work for libgtop. +AC_CHECK_PROGS(AWK, gawk awk, ) +test -z "$AWK" && AC_MSG_ERROR([Sorry, you need a working awk interpreter.]) AC_CHECK_TOOL(CC,gcc) AC_CHECK_TOOL(RANLIB,ranlib) From 61f887fc673995d6d5ec0c3032deef854c20e29d Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 20:06:37 +0000 Subject: [PATCH 0183/2539] Added some comments. 1998-07-14 Martin Baulig * src/daemon/server_config.h.in: Added some comments. * src/daemon/server_config.pl: New file. This is a script you can use to create `server_config.h'. It will query you for some configuration options. --- ChangeLog | 6 ++ src/daemon/server_config.h.in | 42 ++++++++++--- src/daemon/server_config.pl | 111 ++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 8 deletions(-) create mode 100755 src/daemon/server_config.pl diff --git a/ChangeLog b/ChangeLog index f2168116..a679b801 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 1998-07-14 Martin Baulig + * src/daemon/server_config.h.in: Added some comments. + + * src/daemon/server_config.pl: New file. This is a script you can use + to create `server_config.h'. It will query you for some configuration + options. + * configure.in (AC_PROG_AWK): Replaced this test with explicit test for `gawk' and `awk' since `mawk' doesn't work. diff --git a/src/daemon/server_config.h.in b/src/daemon/server_config.h.in index 9a563865..06f2f308 100644 --- a/src/daemon/server_config.h.in +++ b/src/daemon/server_config.h.in @@ -1,14 +1,40 @@ -#define SERVER_PORT 42800 +/* This is a sample config file. + * + * Copy this file to 'server_config.h' and edit it to fix your needs ! + * + * You can also use the 'server_config.pl' script to create 'server_config.h'. + * +/ -#define SERVER_UID 99 -#define SERVER_GID 99 +#define SERVER_PORT 42800 /* Port the server should listen on. */ -#define HOST_TABLE_ENTRIES 3 +/* NOTE: On RedHat 5.1 nobody is UID 99 and GID 99. + * + * The 'server_config.pl' script will use the real UID and GID of 'nobody' + * on your system as default. + * + * NOTE: This only works if the server is started as root or SUID to root. + */ + +#define SERVER_UID 99 /* User ID the server should run as. */ +#define SERVER_GID 99 /* Group ID the server should run as. */ + +#define HOST_TABLE_ENTRIES 1 /* Number of entries in the host table. */ + +/* List of hosts that should be authorized to connect to the server. + * + * SECURITY WARNING: + * Enabling access for a particular hosts means the ALL USERS on this host will + * be allowed to connect to the server ! + * + * If you want security, let this table empty and use the 'xauth' method instead. + * Look at the manpage of gnuserv (1) as shipped with GNU Emacs for more details + * about security. The server uses the same security mechanisms like gnuserv from + * XEmacs 20.3. + */ const char *permitted_host_names [HOST_TABLE_ENTRIES] = -{ "localhost", - "voyager.home-of-linux.com", - "einstein.home-of-linux.com", -}; +{ "localhost" }; unsigned long permitted_hosts [HOST_TABLE_ENTRIES]; + diff --git a/src/daemon/server_config.pl b/src/daemon/server_config.pl new file mode 100755 index 00000000..3e78ca8f --- /dev/null +++ b/src/daemon/server_config.pl @@ -0,0 +1,111 @@ +#!/usr/bin/perl -w + +require 5.004; +use strict; + +print "Enter port the server should listen on [42800]: "; + +my $port = ; chop $port; +$port = 42800 unless $port =~ /^\d+$/; + +print "\nUser name or UID to run as [nobody]: "; + +my $user = ; chop $user; $user = 'nobody' if $user eq ''; + +my ($login, $pass, $uid, $gid); + +unless ($user =~ /^\d+$/) { + ($login, $pass, $uid, $gid) = getpwnam ($user) or + die "User '$user' not in passwd file."; +} + +my $g_default = (defined $gid) ? $gid : 'nogroup'; + +print "Group name or GID to run as [$g_default]: "; + +my $group = ; chop $group; $group = $g_default if $group eq ''; + +unless ($group =~ /^\d+$/) { + $gid = getgrnam ($group) or + die "Group '$group' not in group file."; +} + +print "\nEnter list of hosts which should be authorized to"; +print "\nconnect to the server (terminate with a blank line):\n\n"; + +print "SECURITY WARNING:\n"; +print " Enabling access for a particular hosts means the ALL USERS on this host will\n"; +print " be allowed to connect to the server !\n\n"; + +print " If you want security, let this table empty and use the 'xauth' method instead.\n"; +print " Look at the manpage of gnuserv (1) as shipped with GNU Emacs for more details\n"; +print " about security. The server uses the same security mechanisms like gnuserv from\n"; +print " XEmacs 20.3\n\n"; + +my @hosts = (); +my @host_addrs = (); +my @host_names = (); + +while (1) { + print "Host: "; + + my $host = ; chop $host; + last if $host eq ''; + + my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname ($host) or + die "gethostbyname (): Can't resolve '$host'"; + + my ($a,$b,$c,$d) = unpack('C4',$addrs[0]); + + push @hosts, sprintf ("0x%02X%02X%02X%02X", $d, $c, $b, $a); + push @host_addrs, sprintf ("%d.%d.%d.%d", $a, $b, $c, $d); + push @host_names, $name; +}; + +print "\n"; +print "This is your config:\n"; +print "====================\n\n"; + +printf qq[%-30s: %d\n\n], 'Port', $port; +printf qq[%-30s: %d\n], 'UID', $uid; +printf qq[%-30s: %d\n\n], 'GID', $gid; + +foreach (0..$#hosts) { + printf qq[%-30s (%s - %s)\n], $host_names[$_], $hosts[$_], $host_addrs [$_]; +} + +print "\n"; + +print "Accept? (yes/no) "; + +my $accept = ; chop $accept; + +exit unless $accept eq 'yes'; + +print "\n"; + +open CONFIG, "> server_config.h" or + die "open (server_config.h): $!"; +select CONFIG; + +printf qq[\#define SERVER_PORT\t\t%d\n\n], $port; + +printf qq[\#define SERVER_UID\t\t%d\n], $uid; +printf qq[\#define SERVER_GID\t\t%d\n\n], $gid; + +printf qq[\#define HOST_TABLE_ENTRIES\t%d\n\n], $#hosts + 1; + +foreach (@host_names) { + $_ = qq["$_"]; +} + +printf qq[const char *permitted_host_names [HOST_TABLE_ENTRIES] = \n]; +printf qq[{ %s };\n\n], join (', ', @host_names); + +printf qq[unsigned long permitted_hosts [HOST_TABLE_ENTRIES];\n]; + +close CONFIG; + +select STDOUT; + +print "Your config has successfully been written to 'server_config.h'.\n"; From f8bdfa9a437418dd0df238dcb2ed75d1a9db944c Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 20:24:55 +0000 Subject: [PATCH 0184/2539] Fixed wrong type which caused a core dump. --- src/daemon/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/daemon/main.c b/src/daemon/main.c index a7d97f43..9cef3083 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -50,6 +50,9 @@ extern void handle_slave_command __P((glibtop_command *, glibtop_response *, con #define _offset_union(p) ((char *) &resp->u.p - (char *) resp) #define _offset_data(p) _offset_union (data.p) +static void do_output __P((int, glibtop_response *, off_t, size_t, const void *)); +static int do_read __P((int, void *, size_t)); + static void do_output (int s, glibtop_response *resp, off_t offset, size_t data_size, const void *data) @@ -262,7 +265,7 @@ handle_child_connection (int s) char parameter [BUFSIZ]; void *ptr; - while (do_read (s, &cmnd, sizeof (glibtop_command))) { + while (do_read (s, cmnd, sizeof (glibtop_command))) { #ifdef CHILD_DEBUG fprintf (stderr, "Child (%d - %d) received command " "%d from client.\n", getpid (), s, cmnd->command); From 16cb163bb0c0cff30fe235e03d0f93b398b0dfe3 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 22:42:16 +0000 Subject: [PATCH 0185/2539] Importing from top 3.4 --- sysdeps/sun4/loadavg.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c index 0e553b4a..df1a0dc6 100644 --- a/sysdeps/sun4/loadavg.c +++ b/sysdeps/sun4/loadavg.c @@ -19,15 +19,45 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include +static const unsigned long _glibtop_sysdeps_loadavg = +(1 << GLIBTOP_LOADAVG_LOADAVG); + /* Provides load averange. */ void glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) { + load_avg avenrun [3]; + int i; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_loadavg)); + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* get the load average array */ + + (void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value, + (int *) avenrun, sizeof (avenrun), + _glibtop_nlist [X_AVENRUN].n_name); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SGID KMEM PART !!! */ + + for (i = 0; i < 3; i++) { + /* Calculate loadavg values from avenrun. */ + buf->loadavg [i] = loaddouble (avenrun [i]); + } + + /* Now we can set the flags. */ + + buf->flags = _glibtop_sysdeps_loadavg; } From f18952a9d88dbeee8474dbf4c2909acc38e76093 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 22:57:20 +0000 Subject: [PATCH 0186/2539] Initial revision --- sysdeps/sun4/loadavg.h | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sysdeps/sun4/loadavg.h diff --git a/sysdeps/sun4/loadavg.h b/sysdeps/sun4/loadavg.h new file mode 100644 index 00000000..f49541e7 --- /dev/null +++ b/sysdeps/sun4/loadavg.h @@ -0,0 +1,57 @@ +/* + * Top - a top users display for Berkeley Unix + * + * Defines required to access load average figures. + * + * This include file sets up everything we need to access the load average + * values in the kernel in a machine independent way. First, it sets the + * typedef "load_avg" to be either double or long (depending on what is + * needed), then it defines these macros appropriately: + * + * loaddouble(la) - convert load_avg to double. + * intload(i) - convert integer to load_avg. + */ + +/* + * We assume that if FSCALE is defined, then avenrun and ccpu are type long. + * If your machine is an exception (mips, perhaps?) then make adjustments + * here. + * + * Defined types: load_avg for load averages, pctcpu for cpu percentages. + */ +#if defined(mips) && !defined(NetBSD) +# include +# if defined(FBITS) && !defined(FSCALE) +# define FSCALE (1 << FBITS) /* mips */ +# endif +#endif + +#ifdef FSCALE +# define FIXED_LOADAVG FSCALE +# define FIXED_PCTCPU FSCALE +#endif + +#ifdef ibm032 +# undef FIXED_LOADAVG +# undef FIXED_PCTCPU +# define FIXED_PCTCPU PCT_SCALE +#endif + + +#ifdef FIXED_PCTCPU + typedef long pctcpu; +# define pctdouble(p) ((double)(p) / FIXED_PCTCPU) +#else +typedef double pctcpu; +# define pctdouble(p) (p) +#endif + +#ifdef FIXED_LOADAVG + typedef long load_avg; +# define loaddouble(la) ((double)(la) / FIXED_LOADAVG) +# define intload(i) ((int)((i) * FIXED_LOADAVG)) +#else + typedef double load_avg; +# define loaddouble(la) (la) +# define intload(i) ((double)(i)) +#endif From f77eba3d57aaf5b06be1c02e0d1d58196a654e46 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 22:57:20 +0000 Subject: [PATCH 0187/2539] Importing from top-3.4. From 4bfef8c2544392ab9471d36b2f4bb23fc0660b83 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 23:19:19 +0000 Subject: [PATCH 0188/2539] Imported the wrong file, so removing it again. --- sysdeps/sun4/loadavg.c | 63 ------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 sysdeps/sun4/loadavg.c diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c deleted file mode 100644 index df1a0dc6..00000000 --- a/sysdeps/sun4/loadavg.c +++ /dev/null @@ -1,63 +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 , 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 -#include - -static const unsigned long _glibtop_sysdeps_loadavg = -(1 << GLIBTOP_LOADAVG_LOADAVG); - -/* Provides load averange. */ - -void -glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) -{ - load_avg avenrun [3]; - int i; - - glibtop_init_r (&server, 0, 0); - - memset (buf, 0, sizeof (glibtop_loadavg)); - - /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ - - setregid (server->machine.gid, server->machine.egid); - - /* get the load average array */ - - (void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value, - (int *) avenrun, sizeof (avenrun), - _glibtop_nlist [X_AVENRUN].n_name); - - if (setregid (server->machine.egid, server->machine.gid)) - _exit (1); - - /* !!! END OF SGID KMEM PART !!! */ - - for (i = 0; i < 3; i++) { - /* Calculate loadavg values from avenrun. */ - buf->loadavg [i] = loaddouble (avenrun [i]); - } - - /* Now we can set the flags. */ - - buf->flags = _glibtop_sysdeps_loadavg; -} From 5f4131f248253a7cd10b0bbcf4d49c79f4fd38a5 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 14 Jul 1998 23:30:36 +0000 Subject: [PATCH 0189/2539] New file. Imported from top 3.4. 1998-07-15 Martin Baulig * sysdeps/sun4/loadavg.h: New file. Imported from top 3.4. * sysdeps/sun4/uptime.c (glibtop_get_uptime_p): Added implementation of that function using glibtop_get_cpu (). * sysdeps/sun4/loadavg.c (glibtop_get_loadavg_p): Added implementation of that feature. * sysdeps/sun4/{shm_limits.c, msg_limits.c, shm_limits.c}: Added implementation of this features. --- ChangeLog | 13 +++++++ sysdeps/sun4/cpu.c | 2 +- sysdeps/sun4/glibtop_machine.h | 9 +++-- sysdeps/sun4/loadavg.c | 63 ++++++++++++++++++++++++++++++++++ sysdeps/sun4/mem.c | 2 +- sysdeps/sun4/msg_limits.c | 39 +++++++++++++++++++++ sysdeps/sun4/open.c | 6 ++++ sysdeps/sun4/sem_limits.c | 45 ++++++++++++++++++++++++ sysdeps/sun4/shm_limits.c | 38 ++++++++++++++++++++ sysdeps/sun4/swap.c | 2 +- sysdeps/sun4/uptime.c | 28 +++++++++++++-- 11 files changed, 240 insertions(+), 7 deletions(-) create mode 100644 sysdeps/sun4/loadavg.c diff --git a/ChangeLog b/ChangeLog index a679b801..6108cd01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +1998-07-15 Martin Baulig + + * sysdeps/sun4/loadavg.h: New file. Imported from top 3.4. + + * sysdeps/sun4/uptime.c (glibtop_get_uptime_p): Added + implementation of that function using glibtop_get_cpu (). + + * sysdeps/sun4/loadavg.c (glibtop_get_loadavg_p): Added + implementation of that feature. + + * sysdeps/sun4/{shm_limits.c, msg_limits.c, shm_limits.c}: + Added implementation of this features. + 1998-07-14 Martin Baulig * src/daemon/server_config.h.in: Added some comments. diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c index 68cf0003..7fd278c5 100644 --- a/sysdeps/sun4/cpu.c +++ b/sysdeps/sun4/cpu.c @@ -19,7 +19,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include static const unsigned long _glibtop_sysdeps_cpu = diff --git a/sysdeps/sun4/glibtop_machine.h b/sysdeps/sun4/glibtop_machine.h index 8fb3d133..55ec3cd6 100644 --- a/sysdeps/sun4/glibtop_machine.h +++ b/sysdeps/sun4/glibtop_machine.h @@ -44,6 +44,8 @@ #include #endif +#include "loadavg.h" + __BEGIN_DECLS /* Older versions of SunOS don't have a typedef for pid_t. @@ -63,10 +65,13 @@ typedef int pid_t; #define X_CP_TIME 6 #define X_PAGES 7 #define X_EPAGES 8 +#define X_SHMINFO 9 +#define X_MSGINFO 10 +#define X_SEMINFO 11 #ifdef MULTIPROCESSOR -#define X_NCPU 9 -#define X_MP_TIME 10 +#define X_NCPU 12 +#define X_MP_TIME 13 #endif /* Log base 2 of 1024 is 10 (2^10 == 1024) */ diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c new file mode 100644 index 00000000..df1a0dc6 --- /dev/null +++ b/sysdeps/sun4/loadavg.c @@ -0,0 +1,63 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , 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 +#include + +static const unsigned long _glibtop_sysdeps_loadavg = +(1 << GLIBTOP_LOADAVG_LOADAVG); + +/* Provides load averange. */ + +void +glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf) +{ + load_avg avenrun [3]; + int i; + + glibtop_init_r (&server, 0, 0); + + memset (buf, 0, sizeof (glibtop_loadavg)); + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* get the load average array */ + + (void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value, + (int *) avenrun, sizeof (avenrun), + _glibtop_nlist [X_AVENRUN].n_name); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SGID KMEM PART !!! */ + + for (i = 0; i < 3; i++) { + /* Calculate loadavg values from avenrun. */ + buf->loadavg [i] = loaddouble (avenrun [i]); + } + + /* Now we can set the flags. */ + + buf->flags = _glibtop_sysdeps_loadavg; +} diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c index 6f3b74c2..0eb195b5 100644 --- a/sysdeps/sun4/mem.c +++ b/sysdeps/sun4/mem.c @@ -19,7 +19,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include static const unsigned long _glibtop_sysdeps_mem = diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c index 5a8fff58..504cc389 100644 --- a/sysdeps/sun4/msg_limits.c +++ b/sysdeps/sun4/msg_limits.c @@ -19,14 +19,53 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include +/* #define KERNEL to get declaration of `struct msginfo'. */ + +#define KERNEL + +#include +#include + +static const unsigned long _glibtop_sysdeps_msg_limits = +(1 << GLIBTOP_IPC_MSGMAP) + (1 << GLIBTOP_IPC_MSGMAX) + +(1 << GLIBTOP_IPC_MSGMNB) + (1 << GLIBTOP_IPC_MSGMNI) + +(1 << GLIBTOP_IPC_MSGSSZ) + (1 << GLIBTOP_IPC_MSGTQL); + /* Provides information about sysv ipc limits. */ void glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) { + struct msginfo msginfo; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_msg_limits)); + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* get the load average array */ + + (void) _glibtop_getkval (server, _glibtop_nlist [X_MSGINFO].n_value, + (int *) &msginfo, sizeof (msginfo), + _glibtop_nlist [X_MSGINFO].n_name); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SGID KMEM PART !!! */ + + buf->msgmap = msginfo.msgmap; + buf->msgmax = msginfo.msgmax; + buf->msgmnb = msginfo.msgmnb; + buf->msgmni = msginfo.msgmni; + buf->msgssz = msginfo.msgssz; + buf->msgtql = msginfo.msgtql; + + buf->flags = _glibtop_sysdeps_msg_limits; } diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index 7f68913c..60f3c64b 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -34,6 +34,9 @@ struct nlist _glibtop_nlist[] = { { "cp_time" }, /* 6 */ { "pages" }, /* 7 */ { "epages" }, /* 8 */ + { "shminfo" }, /* 9 */ + { "msginfo" }, /* 10 */ + { "seminfo" }, /* 11 */ #else { "_avenrun" }, /* 0 */ { "_ccpu" }, /* 1 */ @@ -44,6 +47,9 @@ struct nlist _glibtop_nlist[] = { { "_cp_time" }, /* 6 */ { "_pages" }, /* 7 */ { "_epages" }, /* 8 */ + { "_shminfo" }, /* 9 */ + { "_msginfo" }, /* 10 */ + { "_seminfo" }, /* 11 */ #ifdef MULTIPROCESSOR { "_ncpu" }, { "_mp_time" }, diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c index 1e7eaa0f..ef8aa1e8 100644 --- a/sysdeps/sun4/sem_limits.c +++ b/sysdeps/sun4/sem_limits.c @@ -19,14 +19,59 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include +/* #define KERNEL to get declaration of `struct seminfo'. */ + +#define KERNEL + +#include +#include + +static unsigned long _glibtop_sysdeps_sem_limits = +(1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) + +(1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) + +(1 << GLIBTOP_IPC_SEMMSL) + (1 << GLIBTOP_IPC_SEMOPM) + +(1 << GLIBTOP_IPC_SEMUME) + (1 << GLIBTOP_IPC_SEMUSZ) + +(1 << GLIBTOP_IPC_SEMVMX) + (1 << GLIBTOP_IPC_SEMAEM); + /* Provides information about sysv sem limits. */ void glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) { + struct seminfo seminfo; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_sem_limits)); + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* get the load average array */ + + (void) _glibtop_getkval (server, _glibtop_nlist [X_SEMINFO].n_value, + (int *) &seminfo, sizeof (seminfo), + _glibtop_nlist [X_SEMINFO].n_name); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SGID KMEM PART !!! */ + + buf->semmap = seminfo.semmap; + buf->semmni = seminfo.semmni; + buf->semmns = seminfo.semmns; + buf->semmnu = seminfo.semmnu; + buf->semmsl = seminfo.semmsl; + buf->semopm = seminfo.semopm; + buf->semume = seminfo.semume; + buf->semusz = seminfo.semusz; + buf->semvmx = seminfo.semvmx; + buf->semaem = seminfo.semaem; + + buf->flags = _glibtop_sysdeps_sem_limits; } diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c index bb7facb7..f43cef8b 100644 --- a/sysdeps/sun4/shm_limits.c +++ b/sysdeps/sun4/shm_limits.c @@ -19,14 +19,52 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include +/* #define KERNEL to get declaration of `struct shminfo'. */ + +#define KERNEL + +#include +#include + +static unsigned long _glibtop_sysdeps_shm_limits = +(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) + +(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG) + +(1 << GLIBTOP_IPC_SHMALL); + /* Provides information about sysv ipc limits. */ void glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) { + struct shminfo shminfo; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_shm_limits)); + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* get the load average array */ + + (void) _glibtop_getkval (server, _glibtop_nlist [X_SHMINFO].n_value, + (int *) &shminfo, sizeof (shminfo), + _glibtop_nlist [X_SHMINFO].n_name); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SGID KMEM PART !!! */ + + buf->shmmax = shminfo.shmmax; + buf->shmmin = shminfo.shmmin; + buf->shmmni = shminfo.shmmni; + buf->shmseg = shminfo.shmseg; + buf->shmall = shminfo.shmall; + + buf->flags = _glibtop_sysdeps_shm_limits; } diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c index d6a402fc..853e9477 100644 --- a/sysdeps/sun4/swap.c +++ b/sysdeps/sun4/swap.c @@ -19,7 +19,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include /* Provides information about swap usage. */ diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c index e1a6cc51..db0d4a52 100644 --- a/sysdeps/sun4/uptime.c +++ b/sysdeps/sun4/uptime.c @@ -19,15 +19,39 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include +#include #include +static const unsigned long _glibtop_sysdeps_uptime = +(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME); + /* Provides uptime and idle time. */ void glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) { + glibtop_cpu cpu; + glibtop_init_r (&server, 0, 0); - memset (buf, 0, sizeof (glibtop_uptime)); + /* Get currect cpu usage. */ + + glibtop_get_cpu_p (server, &cpu); + + /* Make sure all required fields are present. */ + + if (((cpu.flags & GLIBTOP_CPU_TOTAL) == 0) || + ((cpu.flags & GLIBTOP_CPU_IDLE) == 0) || + ((cpu.flags & GLIBTOP_CPU_FREQUENCY) == 0) || + (cpu.frequency == 0)) + return; + + /* Simply calculate uptime and idle time from + * cpu usage. */ + + buf->uptime = (double) cpu.total / (double) cpu.frequency; + buf->idletime = (double) cpu.idle / (double) cpu.frequency; + + buf->flags = _glibtop_sysdeps_uptime; } From 74ca45f7950c6e1143f6050497dcee854f9d3550 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 17 Jul 1998 13:56:37 +0000 Subject: [PATCH 0190/2539] Applied patch from Albert K T Hui for glibc 2.1. 1998-07-17 Martin Baulig * sysdeps/linux/sem_limits.c: Applied patch from Albert K T Hui for glibc 2.1. --- ChangeLog | 5 +++++ sysdeps/linux/sem_limits.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6108cd01..f34a7989 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1998-07-17 Martin Baulig + + * sysdeps/linux/sem_limits.c: Applied patch from Albert K T Hui + for glibc 2.1. + 1998-07-15 Martin Baulig * sysdeps/sun4/loadavg.h: New file. Imported from top 3.4. diff --git a/sysdeps/linux/sem_limits.c b/sysdeps/linux/sem_limits.c index 88176f0b..19203a33 100644 --- a/sysdeps/linux/sem_limits.c +++ b/sysdeps/linux/sem_limits.c @@ -24,6 +24,16 @@ #include #include +#ifdef _SEM_SEMUN_UNDEFINED +union semun +{ + int val; + struct semid_ds *buf; + unsigned short int *array; + struct seminfo *__buf; +}; +#endif + static unsigned long _glibtop_sysdeps_sem_limits = (1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) + (1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) + From c41d6e5a7774e1eaf94d94fa1d1c151a580a6104 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 17 Jul 1998 16:40:02 +0000 Subject: [PATCH 0191/2539] Added implementation of that feature. 1998-07-17 Martin Baulig * sysdeps/sun4/proclist.c (glibtop_get_proclist_p): Added implementation of that feature. * sysdeps/sun4/proc_{uid,state}.c: Now working quite well. * sysdeps/sun4/proc_{mem,time,signal,kernel,segment}.c: Added some basic implementation; this isn't really working yet. --- ChangeLog | 8 +++++ examples/first.c | 2 +- sysdeps/sun4/glibtop_machine.h | 8 +++++ sysdeps/sun4/open.c | 61 ++++++++++++++++++++++++++++++++++ sysdeps/sun4/prockernel.c | 26 +++++++++++++-- sysdeps/sun4/proclist.c | 57 +++++++++++++++++++++++++++++-- sysdeps/sun4/procmem.c | 27 ++++++++++++++- sysdeps/sun4/procsegment.c | 26 +++++++++++++-- sysdeps/sun4/procsignal.c | 29 ++++++++++++++-- sysdeps/sun4/procstate.c | 26 +++++++++++++-- sysdeps/sun4/proctime.c | 26 +++++++++++++-- sysdeps/sun4/procuid.c | 37 +++++++++++++++++++-- sysdeps/sun4/uptime.c | 6 ++-- 13 files changed, 319 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index f34a7989..8815a9a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 1998-07-17 Martin Baulig + * sysdeps/sun4/proclist.c (glibtop_get_proclist_p): Added + implementation of that feature. + + * sysdeps/sun4/proc_{uid,state}.c: Now working quite well. + + * sysdeps/sun4/proc_{mem,time,signal,kernel,segment}.c: Added + some basic implementation; this isn't really working yet. + * sysdeps/linux/sem_limits.c: Applied patch from Albert K T Hui for glibc 2.1. diff --git a/examples/first.c b/examples/first.c index 115a8be2..bd7a35b7 100644 --- a/examples/first.c +++ b/examples/first.c @@ -32,7 +32,7 @@ #include #ifndef PROFILE_COUNT -#define PROFILE_COUNT 1000 +#define PROFILE_COUNT 1 #endif int diff --git a/sysdeps/sun4/glibtop_machine.h b/sysdeps/sun4/glibtop_machine.h index 55ec3cd6..662cf03c 100644 --- a/sysdeps/sun4/glibtop_machine.h +++ b/sysdeps/sun4/glibtop_machine.h @@ -85,6 +85,10 @@ struct _glibtop_machine gid_t gid, egid; /* Real and effective group id */ int nlist_count; /* Number of symbols in the nlist */ int ncpu; /* Number of CPUs we have */ + int nproc; /* Number of entries in the process array */ + size_t ptable_size; /* Size of process array. */ + unsigned long ptable_offset; /* Offset of process array in kernel. */ + struct proc *proc_table; /* Process array. */ unsigned long pages, epages; struct page *physpage; int bytesize, count; @@ -102,6 +106,10 @@ extern int _glibtop_check_nlist __P((void *, register struct nlist *)); extern int _glibtop_getkval __P((void *, unsigned long, int *, int, char *)); +extern void _glibtop_read_proc_table __P((void *)); + +extern struct proc *_glibtop_find_pid __P((void *, pid_t)); + #endif __END_DECLS diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c index 60f3c64b..f97fec38 100644 --- a/sysdeps/sun4/open.c +++ b/sysdeps/sun4/open.c @@ -118,6 +118,24 @@ glibtop_open_r (glibtop *server, const char *program_name, (_glibtop_check_nlist (server, _glibtop_nlist) > 0)) _exit (1); + /* Get process array stuff. */ + + (void) _glibtop_getkval (server, _glibtop_nlist[X_NPROC].n_value, + (int *)(&server->machine.nproc), + sizeof (server->machine.nproc), + _glibtop_nlist[X_NPROC].n_name); + + (void) _glibtop_getkval (server, _glibtop_nlist[X_PROC].n_value, + (int *)(&server->machine.ptable_offset), + sizeof (server->machine.ptable_offset), + _glibtop_nlist[X_PROC].n_name); + + server->machine.ptable_size = (unsigned long) server->machine.nproc * + (unsigned long) sizeof (struct proc); + + server->machine.proc_table = glibtop_malloc_r + (server, server->machine.ptable_size); + /* This are for the memory statistics. */ (void) _glibtop_getkval (server, _glibtop_nlist[X_PAGES].n_value, @@ -221,3 +239,46 @@ _glibtop_getkval (void *void_server, unsigned long offset, int *ptr, int size, c return 1; } + +/* Used internally. Reads process table from kernel. */ + +void +_glibtop_read_proc_table (void *void_server) +{ + glibtop *server = (glibtop *) void_server; + + /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */ + + setregid (server->machine.gid, server->machine.egid); + + /* Read process table from kernel. */ + + (void) _glibtop_getkval (server, server->machine.ptable_offset, + (int *) server->machine.proc_table, + (size_t) server->machine.ptable_size, + _glibtop_nlist[X_PROC].n_name); + + if (setregid (server->machine.egid, server->machine.gid)) + _exit (1); + + /* !!! END OF SGID KMEM PART !!! */ +} + +/* Used internally. Finds pid in process table. */ + +struct proc * +_glibtop_find_pid (void *void_server, pid_t pid) +{ + register struct proc *pp; + register int i; + + glibtop *server = (glibtop *) void_server; + + for (pp = server->machine.proc_table, i = 0; + i < server->machine.nproc; pp++, i++) { + if ((pp->p_stat != 0) && (pp->p_pid == pid)) + return pp; + } + + return NULL; +} diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c index f8596820..5f13b69f 100644 --- a/sysdeps/sun4/prockernel.c +++ b/sysdeps/sun4/prockernel.c @@ -19,16 +19,38 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include +static const unsigned long _glibtop_sysdeps_proc_kernel = +(1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_WCHAN); + /* Provides detailed information about a process. */ void glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf, - pid_t pid) + pid_t pid) { + struct proc *pp; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_kernel)); + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Find the pid in the process table. */ + + pp = _glibtop_find_pid (server, pid); + + if (pp == NULL) return; + + /* Fill in data fields. */ + + buf->k_flags = pp->p_flag; + buf->wchan = pp->p_wchan; + + buf->flags = _glibtop_sysdeps_proc_kernel; } diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c index 0623dd23..bc8dfebc 100644 --- a/sysdeps/sun4/proclist.c +++ b/sysdeps/sun4/proclist.c @@ -19,10 +19,13 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include +#include #include -#define GLIBTOP_PROCLIST_FLAGS 3 +static const unsigned long _glibtop_sysdeps_proclist = +(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) + +(1 << GLIBTOP_PROCLIST_SIZE); /* Fetch list of currently running processes. * @@ -34,8 +37,56 @@ unsigned * glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf) { + register struct proc *pp; + register int i, nproc = 0; + unsigned *proc_list = NULL; + size_t proc_size; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proclist)); - return NULL; + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Count number of processes. */ + + for (pp = server->machine.proc_table, i = 0; + i < server->machine.nproc; pp++, i++) { + if (pp->p_stat == 0) + continue; + else + nproc++; + } + + if (nproc == 0) /* Should never happen. */ + return NULL; + + /* Allocate space for process list. */ + + proc_size = nproc * sizeof (unsigned); + + proc_list = glibtop_malloc_r (server, proc_size); + + /* Write process list. */ + + for (pp = server->machine.proc_table, i = 0, nproc = 0; + i < server->machine.nproc; pp++, i++) { + if (pp->p_stat == 0) + continue; + proc_list [nproc++] = pp->p_pid; + } + + /* Since everything is ok now, we can set buf->flags, fill in the remaining fields + and return proc_list. */ + + buf->flags = _glibtop_sysdeps_proclist; + + buf->size = sizeof (unsigned); + buf->number = nproc; + + buf->total = nproc * sizeof (unsigned); + + return proc_list; } diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c index c6971c8b..256fa98c 100644 --- a/sysdeps/sun4/procmem.c +++ b/sysdeps/sun4/procmem.c @@ -22,13 +22,38 @@ #include #include +static const unsigned long _glibtop_sysdeps_proc_mem = +(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_RSS) + +(1 << GLIBTOP_PROC_MEM_RSS_RLIM); + /* Provides detailed information about a process. */ void glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf, - pid_t pid) + pid_t pid) { + struct proc *pp; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_mem)); + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Find the pid in the process table. */ + + pp = _glibtop_find_pid (server, pid); + + if (pp == NULL) return; + + /* Fill in data fields. */ + + buf->size = (pp)->p_tsize + (pp)->p_dsize + (pp)->p_ssize; + + buf->rss = pp->p_rssize; + buf->rss_rlim = pp->p_maxrss; + + buf->flags = _glibtop_sysdeps_proc_mem; } diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c index d0d957c3..8df0f083 100644 --- a/sysdeps/sun4/procsegment.c +++ b/sysdeps/sun4/procsegment.c @@ -19,16 +19,38 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include +static const unsigned long _glibtop_sysdeps_proc_segment = +(1 << GLIBTOP_PROC_SEGMENT_TRS) + (1 << GLIBTOP_PROC_SEGMENT_DRS); + /* Provides detailed information about a process. */ void glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf, - pid_t pid) + pid_t pid) { + struct proc *pp; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_segment)); + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Find the pid in the process table. */ + + pp = _glibtop_find_pid (server, pid); + + if (pp == NULL) return; + + /* Fill in data fields. */ + + buf->trs = pp->p_tsize; + buf->drs = pp->p_dsize; + + buf->flags = _glibtop_sysdeps_proc_segment; } diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c index bee1dc5f..ff256200 100644 --- a/sysdeps/sun4/procsignal.c +++ b/sysdeps/sun4/procsignal.c @@ -19,16 +19,41 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include +static const unsigned long _glibtop_sysdeps_proc_signal = +(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 << GLIBTOP_PROC_SIGNAL_BLOCKED) + +(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 << GLIBTOP_PROC_SIGNAL_SIGCATCH); + /* Provides detailed information about a process. */ void glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf, - pid_t pid) + pid_t pid) { + struct proc *pp; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_signal)); + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Find the pid in the process table. */ + + pp = _glibtop_find_pid (server, pid); + + if (pp == NULL) return; + + /* Fill in data fields. */ + + buf->signal = pp->p_sig; + buf->blocked = pp->p_sigmask; + buf->sigignore = pp->p_sigignore; + buf->sigcatch = pp->p_sigcatch; + + buf->flags = _glibtop_sysdeps_proc_signal; } diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c index ddc6d92c..d3066a9c 100644 --- a/sysdeps/sun4/procstate.c +++ b/sysdeps/sun4/procstate.c @@ -19,16 +19,38 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include +static const unsigned long _glibtop_sysdeps_proc_state = +(1 << GLIBTOP_PROC_STATE_STATE) + (1 << GLIBTOP_PROC_STATE_UID); + /* Provides detailed information about a process. */ void glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf, - pid_t pid) + pid_t pid) { + struct proc *pp; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_state)); + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Find the pid in the process table. */ + + pp = _glibtop_find_pid (server, pid); + + if (pp == NULL) return; + + /* Fill in data fields. */ + + buf->state = pp->p_stat; + buf->uid = pp->p_uid; + + buf->flags = _glibtop_sysdeps_proc_state; } diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c index 32b237db..89673e11 100644 --- a/sysdeps/sun4/proctime.c +++ b/sysdeps/sun4/proctime.c @@ -19,16 +19,38 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include +static const unsigned long _glibtop_sysdeps_proc_time = +(1 << GLIBTOP_PROC_TIME_START_TIME) + (1 << GLIBTOP_PROC_TIME_UTIME); + /* Provides detailed information about a process. */ void glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf, - pid_t pid) + pid_t pid) { + struct proc *pp; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_time)); + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Find the pid in the process table. */ + + pp = _glibtop_find_pid (server, pid); + + if (pp == NULL) return; + + /* Fill in data fields. */ + + buf->start_time = pp->p_time; + buf->utime = pp->p_cpticks; + + buf->flags = _glibtop_sysdeps_proc_time; } diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c index bf132521..f30142b1 100644 --- a/sysdeps/sun4/procuid.c +++ b/sysdeps/sun4/procuid.c @@ -19,16 +19,49 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include +#include #include +static const unsigned long _glibtop_sysdeps_proc_uid = +(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) + +(1 << GLIBTOP_PROC_UID_EGID) + (1 << GLIBTOP_PROC_UID_PID) + +(1 << GLIBTOP_PROC_UID_PPID) + (1 << GLIBTOP_PROC_UID_PGRP) + +(1 << GLIBTOP_PROC_UID_TPGID) + (1 << GLIBTOP_PROC_UID_PRIORITY) + +(1 << GLIBTOP_PROC_UID_NICE); + /* Provides detailed information about a process. */ void glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf, - pid_t pid) + pid_t pid) { + struct proc *pp; + glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_proc_uid)); + + /* Read process table from kernel. */ + + _glibtop_read_proc_table (server); + + /* Find the pid in the process table. */ + + pp = _glibtop_find_pid (server, pid); + + if (pp == NULL) return; + + /* Fill in data fields. */ + + buf->uid = pp->p_uid; + buf->euid = pp->p_suid; + buf->egid = pp->p_sgid; + buf->pid = pp->p_pid; + buf->ppid = pp->p_ppid; + buf->pgrp = pp->p_pgrp; + buf->tpgid = pp->p_pgrp; + buf->priority = pp->p_pri; + buf->nice = pp->p_nice; + + buf->flags = _glibtop_sysdeps_proc_uid; } diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c index db0d4a52..0a3827fb 100644 --- a/sysdeps/sun4/uptime.c +++ b/sysdeps/sun4/uptime.c @@ -41,9 +41,9 @@ glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) /* Make sure all required fields are present. */ - if (((cpu.flags & GLIBTOP_CPU_TOTAL) == 0) || - ((cpu.flags & GLIBTOP_CPU_IDLE) == 0) || - ((cpu.flags & GLIBTOP_CPU_FREQUENCY) == 0) || + if (((cpu.flags & (1 << GLIBTOP_CPU_TOTAL)) == 0) || + ((cpu.flags & (1 << GLIBTOP_CPU_IDLE)) == 0) || + ((cpu.flags & (1 << GLIBTOP_CPU_FREQUENCY)) == 0) || (cpu.frequency == 0)) return; From 540cd686916cffde4a32221b59bc7458ee2f4ec8 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 17 Jul 1998 17:21:00 +0000 Subject: [PATCH 0192/2539] Now correctly using `(1 << GLIBTOP_SYSDEPS_*)' instead of 1998-07-17 Martin Baulig * lib/lib.awk (glibtop_get_*): Now correctly using `(1 << GLIBTOP_SYSDEPS_*)' instead of `GLIBTOP_SYSDEPS_*'. --- ChangeLog | 3 +++ lib/lib.awk | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8815a9a9..5a1201d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 1998-07-17 Martin Baulig + * lib/lib.awk (glibtop_get_*): Now correctly using + `(1 << GLIBTOP_SYSDEPS_*)' instead of `GLIBTOP_SYSDEPS_*'. + * sysdeps/sun4/proclist.c (glibtop_get_proclist_p): Added implementation of that feature. diff --git a/lib/lib.awk b/lib/lib.awk index 7498b841..3ea6569e 100644 --- a/lib/lib.awk +++ b/lib/lib.awk @@ -31,7 +31,7 @@ function output(feature) { print "\tglibtop_init_r (&server, GLIBTOP_SYSDEPS_"toupper(feature)", 0);"; print ""; print "\tif ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&"; - print "\t (server->features & GLIBTOP_SYSDEPS_"toupper(feature)"))"; + print "\t (server->features & (1 << GLIBTOP_SYSDEPS_"toupper(feature)")))"; print "\t{"; if (feature ~ /^proc_/) { From 540385da7e909b0f05b141508e148b2abc3f638a Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Fri, 17 Jul 1998 17:26:22 +0000 Subject: [PATCH 0193/2539] Using library functions with '_l' prefix instead of directly calling 1998-07-17 Martin Baulig * sysdeps/common/sysdeps.c (glibtop_get_sysdeps_r): Using library functions with '_l' prefix instead of directly calling sysdeps code with '_r' prefix. This is necessary for client/server mode. --- ChangeLog | 5 +++++ sysdeps/common/sysdeps.c | 30 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a1201d7..21200173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 1998-07-17 Martin Baulig + * sysdeps/common/sysdeps.c (glibtop_get_sysdeps_r): Using + library functions with '_l' prefix instead of directly calling + sysdeps code with '_r' prefix. This is necessary for client/server + mode. + * lib/lib.awk (glibtop_get_*): Now correctly using `(1 << GLIBTOP_SYSDEPS_*)' instead of `GLIBTOP_SYSDEPS_*'. diff --git a/sysdeps/common/sysdeps.c b/sysdeps/common/sysdeps.c index 61d653b4..dce28c11 100644 --- a/sysdeps/common/sysdeps.c +++ b/sysdeps/common/sysdeps.c @@ -53,48 +53,48 @@ glibtop_get_sysdeps_r (glibtop *server, glibtop_sysdeps *buf) /* Call all system dependent functions to check which values * they return. */ - glibtop_get_cpu_r (server, &data.cpu); + glibtop_get_cpu_l (server, &data.cpu); buf->cpu = data.cpu.flags; - glibtop_get_mem_r (server, &data.mem); + glibtop_get_mem_l (server, &data.mem); buf->mem = data.mem.flags; - glibtop_get_swap_r (server, &data.swap); + glibtop_get_swap_l (server, &data.swap); buf->swap = data.swap.flags; - glibtop_get_uptime_r (server, &data.uptime); + glibtop_get_uptime_l (server, &data.uptime); buf->uptime = data.uptime.flags; - glibtop_get_loadavg_r (server, &data.loadavg); + glibtop_get_loadavg_l (server, &data.loadavg); buf->loadavg = data.loadavg.flags; - glibtop_get_shm_limits_r (server, &data.shm_limits); + glibtop_get_shm_limits_l (server, &data.shm_limits); buf->shm_limits = data.shm_limits.flags; - glibtop_get_msg_limits_r (server, &data.msg_limits); + glibtop_get_msg_limits_l (server, &data.msg_limits); buf->msg_limits = data.msg_limits.flags; - glibtop_get_sem_limits_r (server, &data.sem_limits); + glibtop_get_sem_limits_l (server, &data.sem_limits); buf->sem_limits = data.sem_limits.flags; - glibtop_get_proclist_r (server, &data.proclist); + glibtop_get_proclist_l (server, &data.proclist); buf->proclist = data.proclist.flags; - glibtop_get_proc_state_r (server, &data.proc_state, 0); + glibtop_get_proc_state_l (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_l (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_l (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_l (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_l (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_l (server, &data.proc_segment, 0); buf->proc_segment = data.proc_segment.flags; } From 0e086aef2513d7263ba21f6835f74945fa9915e2 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 18 Jul 1998 16:09:42 +0000 Subject: [PATCH 0194/2539] Added `GLIBTOP_METHOD_PIPE' again. 1998-07-18 Martin Baulig * lib/{init, open}.c: Added `GLIBTOP_METHOD_PIPE' again. * src/server/main.c: Removed gettext stuff. --- ChangeLog | 10 ++++++++-- configure.in | 1 + lib/init.c | 5 +++++ lib/open.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ src/server/main.c | 18 ------------------ 5 files changed, 62 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21200173..bc724f56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1998-07-18 Martin Baulig + + * lib/{init, open}.c: Added `GLIBTOP_METHOD_PIPE' again. + + * src/server/main.c: Removed gettext stuff. + 1998-07-17 Martin Baulig * sysdeps/common/sysdeps.c (glibtop_get_sysdeps_r): Using @@ -11,9 +17,9 @@ * sysdeps/sun4/proclist.c (glibtop_get_proclist_p): Added implementation of that feature. - * sysdeps/sun4/proc_{uid,state}.c: Now working quite well. + * sysdeps/sun4/proc_{uid, state}.c: Now working quite well. - * sysdeps/sun4/proc_{mem,time,signal,kernel,segment}.c: Added + * sysdeps/sun4/proc_{mem, time, signal, kernel, segment}.c: Added some basic implementation; this isn't really working yet. * sysdeps/linux/sem_limits.c: Applied patch from Albert K T Hui diff --git a/configure.in b/configure.in index 9c70dbac..1e426ed1 100644 --- a/configure.in +++ b/configure.in @@ -253,5 +253,6 @@ src/proxy/Makefile src/daemon/Makefile lib/Makefile examples/Makefile +perl/Makefile.PL support/Makefile macros/Makefile],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]) diff --git a/lib/init.c b/lib/init.c index 367d5e14..71b6b71a 100644 --- a/lib/init.c +++ b/lib/init.c @@ -136,6 +136,11 @@ _init_server (glibtop *server, const unsigned features) /* Connect to unix domain socket. */ server->method = GLIBTOP_METHOD_UNIX; + } else if (!strcmp (command, "pipe")) { + + /* Open pipe to server. */ + server->method = GLIBTOP_METHOD_PIPE; + } else { glibtop_error_r (server, "Unknown server method '%s'", diff --git a/lib/open.c b/lib/open.c index 7bf1126b..fe90bfff 100644 --- a/lib/open.c +++ b/lib/open.c @@ -33,7 +33,9 @@ void glibtop_open_l (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { + char version [BUFSIZ], buffer [BUFSIZ]; int connect_type; + unsigned nbytes; server->name = program_name; @@ -75,6 +77,52 @@ glibtop_open_l (glibtop *server, const char *program_name, server->features = -1; break; + case GLIBTOP_METHOD_PIPE: + fprintf (stderr, "Opening pipe to server (%s).\n", + GTOP_SERVER); + +#if 0 + if (socketpair (AF_UNIX, SOCK_STREAM, 0, server->input)) + glibtop_error_io_r (server, "socketpair"); + + if (socketpair (AF_UNIX, SOCK_STREAM, 0, server->output)) + glibtop_error_io_r (server, "socketpair"); +#endif + + if (pipe (server->input) || pipe (server->output)) + glibtop_error_io_r (server, "cannot make a pipe"); + + server->pid = fork (); + + if (server->pid < 0) { + glibtop_error_io_r (server, "fork failed"); + } else if (server->pid == 0) { + close (0); close (1); + close (server->input [0]); close (server->output [1]); + dup2 (server->input [1], 1); + dup2 (server->output [0], 0); + execl (GTOP_SERVER, NULL); + glibtop_error_io_r (server, "execl %s", GTOP_SERVER); + _exit (2); + } + + close (server->input [1]); + close (server->output [0]); + + sprintf (version, "%s server %s ready.\n", PACKAGE, VERSION); + + glibtop_read_l (server, sizeof (nbytes), &nbytes); + + if (nbytes != strlen (version)) + glibtop_error_r (server, "Requested %u bytes but got %u", + strlen (version), nbytes); + + glibtop_read_l (server, nbytes, buffer); + + if (memcmp (version, buffer, strlen (version))) + glibtop_error_r (server, "server version is not %s", + VERSION); + break; } /* If the server has been started, ask it for its features. */ diff --git a/src/server/main.c b/src/server/main.c index a248c862..3aa7ca70 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -55,25 +55,8 @@ int main(int argc, char *argv[]) uid = getuid (); euid = geteuid (); gid = getgid (); egid = getegid (); - if (setreuid (euid, uid)) _exit (1); - - if (setregid (egid, gid)) _exit (1); - - /* !!! END OF SUID ROOT PART !!! */ - - /* For security reasons, we temporarily drop our priviledges - * before doing the gettext stuff. */ - - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, GTOPLOCALEDIR); - textdomain (PACKAGE); - glibtop_version (); - /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ - - setreuid (uid, euid); setregid (gid, egid); - glibtop_open_r (&server, argv [0], 0, 0); if (setreuid (euid, uid)) _exit (1); @@ -89,7 +72,6 @@ int main(int argc, char *argv[]) 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. */ From 5e9d34c91a58103012dbc41bd3e2165f76ee99f0 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sat, 18 Jul 1998 16:15:56 +0000 Subject: [PATCH 0195/2539] Initial revision --- libproc/Makefile | 111 +++++++++++++ libproc/alloc.c | 49 ++++++ libproc/compare.c | 307 +++++++++++++++++++++++++++++++++++ libproc/devname.c | 269 ++++++++++++++++++++++++++++++ libproc/devname.h | 10 ++ libproc/ksym.c | 252 +++++++++++++++++++++++++++++ libproc/output.c | 52 ++++++ libproc/ps.h | 30 ++++ libproc/psdata.h | 103 ++++++++++++ libproc/pwcache.c | 37 +++++ libproc/readproc.c | 395 +++++++++++++++++++++++++++++++++++++++++++++ libproc/readproc.h | 168 +++++++++++++++++++ libproc/signals.c | 65 ++++++++ libproc/signals.h | 12 ++ libproc/signames.h | 32 ++++ libproc/status.c | 20 +++ libproc/sysinfo.c | 176 ++++++++++++++++++++ libproc/sysinfo.h | 17 ++ libproc/tree.h | 14 ++ libproc/version.c | 39 +++++ libproc/version.h | 24 +++ libproc/whattime.c | 89 ++++++++++ libproc/whattime.h | 9 ++ 23 files changed, 2280 insertions(+) create mode 100644 libproc/Makefile create mode 100644 libproc/alloc.c create mode 100644 libproc/compare.c create mode 100644 libproc/devname.c create mode 100644 libproc/devname.h create mode 100644 libproc/ksym.c create mode 100644 libproc/output.c create mode 100644 libproc/ps.h create mode 100644 libproc/psdata.h create mode 100644 libproc/pwcache.c create mode 100644 libproc/readproc.c create mode 100644 libproc/readproc.h create mode 100644 libproc/signals.c create mode 100644 libproc/signals.h create mode 100644 libproc/signames.h create mode 100644 libproc/status.c create mode 100644 libproc/sysinfo.c create mode 100644 libproc/sysinfo.h create mode 100644 libproc/tree.h create mode 100644 libproc/version.c create mode 100644 libproc/version.h create mode 100644 libproc/whattime.c create mode 100644 libproc/whattime.h diff --git a/libproc/Makefile b/libproc/Makefile new file mode 100644 index 00000000..6d72070b --- /dev/null +++ b/libproc/Makefile @@ -0,0 +1,111 @@ +# Auto-adaptive C library Makefile adapted for libproc, Chuck Blake. +# Assumptions are basically that all the .c files in the CWD are modules +# for the library and that all .h files are the interface to the library. + +# PROJECT SPECIFIC MACROS +NAME = proc + +# INSTALLATION OPTIONS +TOPDIR = /usr +HDRDIR = $(TOPDIR)/include/$(NAME)# where to put .h files +LIBDIR = $(TOPDIR)/lib# where to put library files +SHLIBDIR = /lib# where to put shared library files +HDROWN = -o root -g root # owner of header files +LIBOWN = -o root -g root # owner of library files +INSTALL = install + +# COMPILATION OPTIONS +CC = gcc -O2 -D_GNU_SOURCE #-ggdb # easy to command-line override +CFLAGS = -I.. -Wall + +# ----------------------------------------------------------------# +# The rest is the auto-magic section -- highly GNU make dependent # +# You should never need to edit this. # +# ----------------------------------------------------------------# + +VC_SUF = ,v +VC_PFX = RCS/ +RCSFILES = $(patsubst $(VC_PFX)%$(VC_SUF),%,$(wildcard $(VC_PFX)*$(VC_SUF))) + +# We take the union of RCS files and other files in CWD so that new files do +# not need to alter this makefile. 'sort' removes duplicates. This allows the +# convenience of compiling and testing new files before the initial check-in. + +SRC = $(sort $(wildcard *.c) $(filter %.c,$(RCSFILES))) +HDR = $(sort $(wildcard *.h) $(filter %.h,$(RCSFILES))) + +OBJ = $(SRC:.c=.o) +SONAME = lib$(NAME).so.$(LIBVERSION) + +ifeq ($(SHARED),1) +CFLAGS += -fpic +all: lib$(NAME).a $(SONAME) +else +all: lib$(NAME).a +endif + +lib$(NAME).a: $(OBJ) + $(AR) rcs $@ $^ + +$(SONAME): $(OBJ) + gcc -Wl,-shared -Wl,-soname,$(SONAME) -o $@ $^ -lc + ln -sf $(SONAME) lib$(NAME).so + +# AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT + +.depend: + $(strip $(CC) $(CFLAGS) -MM -MG $(SRC) > .depend) +include .depend + +# INSTALLATION + +install: all + if ! [ -d $(HDRDIR) ] ; then mkdir $(HDRDIR) ; fi + $(INSTALL) $(HDROWN) $(HDR) $(TOPDIR)/include/$(NAME) + $(INSTALL) $(LIBOWN) lib$(NAME).a $(LIBDIR) +ifeq ($(SHARED),1) + $(INSTALL) $(LIBOWN) $(SONAME) $(SHLIBDIR) + ln -sf $(SHLIBDIR)/$(SONAME) $(SHLIBDIR)/lib$(NAME).so + ldconfig +endif + +# VARIOUS SHORT CUT TARGETS +.PHONY: all install dep clean distclean checkout checkclean + +dep: .depend + +clean: + $(RM) lib$(NAME).* *.o + +distclean: clean + $(RM) .depend signames.h + +checkout: + $(CO) $(RCSFILES) + +checkclean: + $(RM) $(RCSFILES) + +# CUSTOM c -> o rule so that command-line has minimal whitespace + +%.o : %.c + $(strip $(CC) $(CFLAGS) -c $<) + +# PROJECT SPECIFIC DEPENDENCIES/BUILD RULES + + +version.o: version.c version.h +ifdef MINORVERSION + $(strip $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c version.c) +else + $(strip $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -c version.c) +endif + +signals.o : signames.h + +signames.h ../proc/signames.h : /usr/include/signal.h + /lib/cpp -dM signames.h + diff --git a/libproc/alloc.c b/libproc/alloc.c new file mode 100644 index 00000000..92fba2c5 --- /dev/null +++ b/libproc/alloc.c @@ -0,0 +1,49 @@ +/***********************************************************************\ +* Copyright (C) 1992 by Michael K. Johnson, johnsonm@sunsite.unc.edu * +* * +* This file is placed under the conditions of the GNU public * +* license, version 2, or any later version. See file COPYING * +* for information on distribution conditions. * +\***********************************************************************/ +#include +#include + +void *xcalloc(void *pointer, int size) { + void * ret; + if (pointer) + free(pointer); + if (!(ret = calloc(1, size))) { + fprintf(stderr, "xcalloc: allocation error, size = %d\n", size); + exit(1); + } else { + return ret; + } +} + +void *xmalloc(unsigned int size) { + void *p; + + if (size == 0) + ++size; + p = malloc(size); + if (!p) { + fprintf(stderr, "xmalloc: malloc(%d) failed", size); + perror(NULL); + exit(1); + } + return(p); +} + +void *xrealloc(void *oldp, unsigned int size) { + void *p; + + if (size == 0) + ++size; + p = realloc(oldp, size); + if (!p) { + fprintf(stderr, "xrealloc: realloc(%d) failed", size); + perror(NULL); + exit(1); + } + return(p); +} diff --git a/libproc/compare.c b/libproc/compare.c new file mode 100644 index 00000000..cfbdebd6 --- /dev/null +++ b/libproc/compare.c @@ -0,0 +1,307 @@ +/* + * + * Copyright 1994 Charles Blake and Michael K. Johnson + * This file is a part of procps, which is distributable + * under the conditions of the GNU Public License. See the + * file COPYING for details. + * + */ + +#include /* for strcmp */ +#include /* for parse error output */ +#include "proc/readproc.h" /* for proc_t */ +#include "proc/tree.h" /* for struct tree_node */ + +/* + This module was written by Charles Blake for procps. + +mult_lvl_cmp: + slick general purpose multi-level compare function I invented. +sort_depth: + the number of levels of functions *to use*. This means many more levels + can be defined than mult_lvl_cmp tres out. If this is 1 then mult_lvl_cmp + is just a trivial wrapper around (*sort_function[0]). +sort_direction: + multiplicative factor for the output of cmp_whatever. + 1 ==> default order, -1 ==> reverse order, 0 ==> forced equality + The 0 bit is the neat part. Since a value of zero is the code for equality + multiplying the output of cmp_foo(a,b) forces a==b to be true. This is a + convenient way to turn sorting off in middle levels of a multi-level sort. + If time is a problem, reforming the whole sort_function array to not include + these unsorted middle levels will be faster since then cmp_foo won't even + be called. It might simplify some code depending upon how you organize it. +sort_function[]: + array of function pointers that points to our family of comparison functions + (I have named them cmp_* but mult_lvl_cmp doesn't care what they're named). + This may be declared and initialized like so: + int (*sort_function[])(void* a, void* b)={&cmp_foo, &cmp_bar, &cmp_hiho}; + You could also use my command line '-O' parser below. + +Note that we only descend levels until the order is determined. If we descend +all levels, that means that the items are equal at all levels, so we return 0. +Otherwise we return whatever the level's cmp_foo function would have returned. +This allows whatever default behavior you want for cmp_foo. sort_direction[] +reverses this default behavior, but mult_lvl_cmp doesn't decide that ascending +or descending is the default. That is the job of your cmp_foo's. +*/ + +/* the only reason these are global is because qsort(3) likes it that way. + It's also a little more efficient if mult_lvl_cmp() is called many times. +*/ + +typedef int (*cmp_t)(void*,void*); /* for function pointer casts */ + +int sort_depth = 0; +int sort_direction[10]; /* storage for 10 levels, but 4 would be plenty!*/ +int (*sort_function[10])(void* a, void* b); + +int mult_lvl_cmp(void* a, void* b) { + int i, cmp_val; + for(i = 0; i < sort_depth; i++) { + cmp_val = sort_direction[i] * (*sort_function[i])(a,b); + if (cmp_val != 0) + return cmp_val; + } + return 0; +} + +int node_mult_lvl_cmp(void* a, void* b) { + int i, cmp_val; + for(i = 0; i < sort_depth; i++) { + cmp_val = sort_direction[i] * (*sort_function[i])(&(((struct tree_node *)a)->proc),&(((struct tree_node *)b)->proc)); + if (cmp_val != 0) + return cmp_val; + } + return 0; +} + +/* qsort(3) compliant comparison functions for all members of the ps_proc + structure (in the same order in which they appear in the proc_t declaration) + return is {-1,0,1} as {ab} + default ordering is ascending for all members. (flip 1,-1 to reverse) +*/ +/* pre-processor macros to cut down on source size (and typing!) + Note the use of the string concatenation operator ## +*/ +#define CMP_STR(NAME) \ +int cmp_ ## NAME(proc_t** P, proc_t** Q) { \ + return strcmp((*P)-> ## NAME, (*Q)-> ## NAME); \ +} + +#define CMP_INT(NAME) \ +int cmp_ ## NAME (proc_t** P, proc_t** Q) { \ + if ((*P)-> ## NAME < (*Q)-> ## NAME) return -1; \ + if ((*P)-> ## NAME > (*Q)-> ## NAME) return 1; \ + return 0; \ +} + +/* Define the (46!) cmp_ functions with the above macros for every element + of proc_t. If the binary gets too big, we could nuke inessentials. +*/ + +/* CMP_STR(cmdline) */ +CMP_STR(user) +CMP_STR(cmd) +/* CMP_INT(state) */ +/* CMP_STR(ttyc) */ +CMP_INT(uid) +CMP_INT(pid) +CMP_INT(ppid) +CMP_INT(pgrp) +CMP_INT(session) +CMP_INT(tty) +CMP_INT(tpgid) +CMP_INT(utime) +CMP_INT(stime) +CMP_INT(cutime) +CMP_INT(cstime) +/* CMP_INT(priority) */ +CMP_INT(nice) +CMP_INT(start_time) +/* CMP_INT(signal) */ +/* CMP_INT(blocked) */ +/* CMP_INT(sigignore) */ +/* CMP_INT(sigcatch) */ +CMP_INT(flags) +CMP_INT(min_flt) +CMP_INT(cmin_flt) +CMP_INT(maj_flt) +CMP_INT(cmaj_flt) +/* CMP_INT(timeout) */ +CMP_INT(vsize) +CMP_INT(rss) +/* CMP_INT(rss_rlim) */ +/* CMP_INT(start_code) */ +/* CMP_INT(end_code) */ +/* CMP_INT(start_stack) */ +/* CMP_INT(kstk_esp) */ +/* CMP_INT(kstk_eip) */ +/* CMP_INT(wchan) */ +CMP_INT(pcpu) +CMP_INT(size) +CMP_INT(resident) +CMP_INT(share) +/* CMP_INT(trs) */ +/* CMP_INT(lrs) */ +/* CMP_INT(drs) */ +/* CMP_INT(dt) */ + +/* define user interface to sort keys. Fairly self-explanatory. */ + +struct cmp_fun_struct { + char letter; /* single option-letter for key */ + char name[15]; /* long option name for key */ + int (*fun)(proc_t**, proc_t**); /* pointer to cmp_key */ +} cmp[] = { +/* { '?', "cmdline", &cmp_cmdline }, */ + { 'u', "user", &cmp_user }, + { 'c', "cmd", &cmp_cmd }, +/* { '?', "state", &cmp_state }, */ +/* { '?', "ttyc", &cmp_ttyc }, */ + { 'U', "uid", &cmp_uid }, + { 'p', "pid", &cmp_pid }, + { 'P', "ppid", &cmp_ppid }, + { 'g', "pgrp", &cmp_pgrp }, + { 'o', "session", &cmp_session }, + { 't', "tty", &cmp_tty }, + { 'G', "tpgid", &cmp_tpgid }, + { 'k', "utime", &cmp_utime }, + { 'K', "stime", &cmp_stime }, + { 'j', "cutime", &cmp_cutime }, + { 'J', "cstime", &cmp_cstime }, +/* { '?', "counter", &cmp_counter }, */ + { 'y', "priority", &cmp_nice }, + { 'T', "start_time", &cmp_start_time }, +/* { '?', "signal", &cmp_signal }, */ +/* { '?', "blocked", &cmp_blocked }, */ +/* { '?', "sigignore", &cmp_sigignore }, */ +/* { '?', "sigcatch", &cmp_sigcatch }, */ + { 'f', "flags", &cmp_flags }, + { 'm', "min_flt", &cmp_min_flt }, + { 'n', "cmin_flt", &cmp_cmin_flt }, + { 'M', "maj_flt", &cmp_maj_flt }, + { 'N', "cmaj_flt", &cmp_cmaj_flt }, +/* { 'C', "timeout", &cmp_timeout }, */ + { 'v', "vsize", &cmp_vsize }, + { 'r', "rss", &cmp_rss }, +/* { '?', "rss_rlim", &cmp_rss_rlim }, */ +/* { '?', "start_code", &cmp_start_code }, */ +/* { '?', "end_code", &cmp_end_code }, */ +/* { '?', "start_stack", &cmp_start_stack }, */ +/* { '?', "kstk_esp", &cmp_kstk_esp }, */ +/* { '?', "kstk_eip", &cmp_kstk_eip }, */ +/* { '?', "wchan", &cmp_wchan }, */ + { 'C', "pcpu", &cmp_pcpu }, + { 's', "size", &cmp_size }, + { 'R', "resident", &cmp_resident }, + { 'S', "share", &cmp_share }, +/* { '?', "trs", &cmp_trs }, */ +/* { '?', "lrs", &cmp_lrs }, */ +/* { '?', "drs", &cmp_drs }, */ +/* { '?', "dt", &cmp_dt }, */ + { '\0',"terminator", NULL } +}; + +void dump_keys(void) { + int i; + for(i=0; cmp[i].letter; i++) + fprintf(stderr, "%s-O%c , --sort:%-15.15s%s", + i%2?"":" ", + cmp[i].letter, cmp[i].name, + i%2?"\n":""); + if (i%2) + fprintf(stderr, "\n"); +} + +/* command line option parsing. Assign sort_{depth,direction[],function[]} + based upon a string of the form: + [+-]a[+-]b[+-]c... + with a,b,c,... being letter flags corresponding to a particular sort + key and the optional '-' specifying a reverse sort on that key. + doesn't + mean anything, but it keeps things looking balanced... +*/ +int parse_sort_opt(char* opt) { + int i, next_dir=1; + for(; *opt ; ++opt) { + if (*opt == '-' || *opt == '+') { + if (*opt == '-') + next_dir = -1; + opt++; + continue; + } + for (i = 0; cmp[i].letter; i++) + if (*opt == cmp[i].letter) + break; + if (!cmp[i].letter) { + fprintf(stderr, + "ps: no such sort key -- %c. Possibilities are:\n", *opt); + dump_keys(); + return -1; + } else { +#ifdef DEBUG + fprintf(stderr, + "sort level %d: key %s, direction % d\n", + sort_depth, cmp[i].name, next_dir); +#endif + sort_function[sort_depth] = (cmp_t)cmp[i].fun; + sort_direction[sort_depth++] = next_dir; + next_dir = 1; + } + } + return 0; +} + +int parse_long_sort(char* opt) { + char* comma; + int i, more_keys, next_dir=1; + do { + if (*opt == '-' || *opt == '+') { + if (*opt == '-') + next_dir = -1; + more_keys = 1; + opt++; + continue; + } + more_keys = ((comma=index(opt,',')) != NULL); + /* keys are ',' delimited */ + if (more_keys) + *comma='\0'; /* terminate for strcmp() */ + for(i = 0; cmp[i].letter; ++i) + if (strcmp(opt, cmp[i].name) == 0) + break; + if (!cmp[i].letter) { + fprintf(stderr, + "ps: no such sort key -- %s. Possibilities are:\n", opt); + dump_keys(); + return -1; + } else { +#ifdef DEBUG + fprintf(stderr, + "sort level %d: key %s, direction % d\n", + sort_depth, cmp[i].name, next_dir); +#endif + sort_function[sort_depth] = (cmp_t)cmp[i].fun; + sort_direction[sort_depth++] = next_dir; + next_dir = 1; + } + opt = comma + 1; /* do next loop on next key, if more keys, else done*/ + } while (more_keys); + return 0; +} + +void reset_sort_options (void) +{ + int i; + + sort_depth=0; + for (i=0;i<10;i++){ + sort_direction[i]=0; + sort_function[i]=(cmp_t)NULL; + } +} + +void register_sort_function (int dir, cmp_t func) +{ + sort_function[sort_depth] = func; + sort_direction[sort_depth++] = dir; +} diff --git a/libproc/devname.c b/libproc/devname.c new file mode 100644 index 00000000..f81af2dc --- /dev/null +++ b/libproc/devname.c @@ -0,0 +1,269 @@ +/* device name <-> number map system optimized for rapid, constant time lookup. + Copyright Charles Blake, 1996, see COPYING for details. +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define __KERNEL__ +#include +#undef __KERNEL__ + +#define DEVDIR "/dev" +#define DEVTAB "psdevtab" +static char *devtab_paths[] = { + "/etc/" DEVTAB, + "%s/." DEVTAB, + NULL +}; +#define DEVINITIALMODE 0664 +#define DEV_MAX_PATH (5+256) +#define DEV_NAME_MAX 8 + +static dev_t major[] = { 2, 3, 4, 5, 19, 20, 22, 23, 24, 25, 32, 33, + 46, 47, 48, 49 }; +#define Nminor 256 +#define Nmajor (sizeof(major)/sizeof(dev_t)) +#define Ndev (Nmajor*Nminor) +#define Ndevtab (Ndev*DEV_NAME_MAX) + +static char* devtab; /* the memory buffer holding all the name strings */ + +/* This macro evaluates to the address into the table of the string of + DEV_NAME_MAX chars for the device with major m, minor n. */ +#define TAB(m,n) (devtab + (m)*(Nminor*DEV_NAME_MAX) + (n)*DEV_NAME_MAX) + +static int devtab_initialized = 0; + +static char* name_to_path(char* name); /* forward declarations */ +static int init_devtab (void); + +/* Device Name -> Number Map + many-to-one: -1 on failed match. +*/ +dev_t name_to_dev(char* name) { + static struct stat sbuf; + return (stat(name_to_path(name), &sbuf) < 0) ? -1 : sbuf.st_rdev; +} + +/* find m in a[] assuming a is sorted into ascending order */ +/* in-line linear search placeholder until more majors warrant binary search */ +static __inline__ int lookup(dev_t m, dev_t* a, int n) { + int k; + for(k=0; k < n && a[k] != m; k++) + ; + return (k < n) ? k : -1; +} + +/* Device Number -> Name Map + one-to-many: first directory order match in DEVDIR, "" on failed match. +*/ +char* dev_to_name(dev_t num) { + static char rval[DEV_NAME_MAX+1]; + dev_t m = MAJOR(num), n = MINOR(num), tmp; + if (!devtab_initialized && !init_devtab()) + return ""; + if ((tmp = lookup(m, major, Nmajor)) == (dev_t)-1) + return ""; + strncpy(rval, TAB(tmp,n), DEV_NAME_MAX); + rval[DEV_NAME_MAX] = '\0'; + return rval; +} + +static int dev_to_devtab(int); + +static int init_devtab(void) { + static struct stat sbuf, lbuf; + static int fd; + char **fmt, path[64], *HOME = getenv("HOME") ? getenv("HOME") : ""; + for (fmt = devtab_paths; *fmt; fmt++) { + snprintf(path, sizeof path, *fmt, HOME); + lbuf.st_ino = 0; /* initialize for test later */ + if (lstat(path, &lbuf) >= 0 && S_ISLNK(lbuf.st_mode)) + /* don't follow symlinks */ + continue; + if ( (fd = open(path, O_RDONLY)) < 0 /* open DEVTAB file */ + || fstat(fd, &sbuf) < 0 /* fstat it */ + || (lbuf.st_ino && (sbuf.st_ino != lbuf.st_ino)) /* race */ + || sbuf.st_nlink > 1 /* hardlink attack */ + || sbuf.st_size != Ndevtab /* make sure it's the right size */ + || (devtab = mmap(0, Ndevtab, PROT_READ, MAP_SHARED, fd, 0)) == (caddr_t) -1 + || close(fd) == -1) + { /* could not open for read, attempt to fix/create */ + int oumsk = umask(0); + if (devtab) + munmap(devtab, Ndevtab); + if (((fd = open(path, O_RDWR|O_TRUNC|O_CREAT, DEVINITIALMODE)) == -1 && + (unlink(path), fd = open(path, O_RDWR|O_TRUNC|O_CREAT, DEVINITIALMODE)) == -1) + || !dev_to_devtab(fd)) { + close(fd); /* either both opens failed or the constructor failed */ + unlink(path); /* in case we created but could not fill a file */ + umask(oumsk); + continue; + } else { + devtab_initialized = 1; + close(fd); + umask(oumsk); + return 1; + } + } + else + return devtab_initialized = 1; + } + return devtab_initialized; +} + +/* stat every file in DEVDIR saving its basename in devtab[] if it has + a MAJOR(st_rdev) in our list of majors. return 0 on error otherwise 1. */ +static int dev_to_devtab(int fd) { + static struct stat sbuf; + int i; + dev_t m; + struct dirent* ent; + DIR* dev; + + if (!(dev = opendir(DEVDIR))) { + fprintf(stderr, "%s: %s\nCannot generate device number -> name mapping.\n", + DEVDIR, sys_errlist[errno]); + return 0; + } + if (!(devtab = malloc(Ndevtab))) { + fprintf(stderr, "%s: could not allocate memory\n", sys_errlist[errno]); + return 0; + } + memset((void*)devtab, 0, Ndevtab); + while ((ent = readdir(dev))) { /* loop over all dirents in DEVDIR */ + if (lstat(name_to_path(ent->d_name), &sbuf) < 0 + || !S_ISCHR(sbuf.st_mode)) /* only look for char special devs */ + continue; /* due to overloading of majors */ + m = MAJOR(sbuf.st_rdev); /* copy name to appropriate spot */ + if ((i = lookup(m, major, Nmajor)) != -1) + strncpy(TAB(i,MINOR(sbuf.st_rdev)), ent->d_name, DEV_NAME_MAX); + } + closedir(dev); + if (write(fd, devtab, Ndevtab) != Ndevtab) /* probably no disk space */ + return 0; + return 1; +} + +static char path[DEV_MAX_PATH]; + +static char* name_to_path(char* name) { + static char* Path; + if (!Path) { + strcpy(path, DEVDIR); /* copy DEVDIR */ + path[sizeof(DEVDIR) - 1] = '/'; /* change NUL to '/' */ + Path = path + sizeof(DEVDIR); /* put Path at start of basename */ + } + strncpy(Path, name, DEV_MAX_PATH - sizeof(DEVDIR)); + return path; +} + +#ifdef TEST_DEVNAME +int main(int argc, char** argv) { /* usage: cmd [ |] */ + dev_t tmp; + if (argc < 2) { + printf("%s: [ maj min... | name ... ]\n", argv[0]); + return 0; + } + if (argv[1][0] >= '0' && argv[1][0] <= '9') + for(argv++ ; argv[0] && argv[1] ; argv+=2) + printf("%s\n", dev_to_name(MKDEV( atoi(argv[0]), atoi(argv[1]) ))); + else + for(argv++ ; *argv ; argv++) { + tmp = name_to_dev(*argv); + printf("%d, %d\n", MAJOR(tmp), MINOR(tmp)); + } + return 0; +} +#endif +/* +Using this program on over 700 files in /dev to perform number->name resolution +took well under 300 microsecs per device number pair on a Pentium 90. It is +somewhat tough to time because once the 3 pages have been mapped in, the time is +almost zero. For things like top, this method may even be faster in the long +run. Those interested can gprof it for me. This system has the virtue of being +nearly perfectly adaptable to individual systems, self updating when /dev +changes and pretty darn fast when it hasn't. It will be slow for users without +perms to change the psdevtab file, though. So this is what I decided was +reasonable. If the process does not have perms to create or update +/etc/psdevtab and it is out of date, we try /tmp/psdevtab. If /tmp/psdevtab is +either out of date or unreadable (malicious user creates it and chmods it), +$HOME/.psdevtab is used. This secondarily allows for per-user naming of ttys, +but is really so that at most one user sees only a single delay per /dev +modification. + +To do the timings I did something like this with zsh: + a=(`ls -l *(%^@/) | awk '{print $5 $6}' | sed 's/,/ /'`); + time ./test $a + +Finally, for lack of a better file for these to be in, I have collected the +old algorithmic device number <-> device name mappings. + Let m = major device number and n = minor device number satisfy: + devno = m<<8 + n , m = devno>>8 , n = devno && 0x00FF, and let + char L[32]="pqrstuvwxyzABCDEFGHIJKLMNOPQRSTU", H[16]="01234567890abcdef"; + DEVICE NUMBERS SPECIAL FILE NAMES + OLD SYSTEM (64 pseudoterminal devices): + m=4: + n=0..63: tty + itoa_dec(n+1) + n=128..191: pty + L[(n-128)/16] + H[(n-128)%16] + n=192..255: tty + L[(n-192)/16] + H[(n-192)%16] + NEW SYSTEM (256/512 pseudoterminal devices): + m=2, n: pty + L[n/16] + H[n%16] + m=3, n: tty + L[n/16] + H[n%16] + m=4, n: tty + itoa_dec(n+1) + m=49, n: pty + L[16+n/16] + H[n%16] + m=50, n: tty + L[16+n/16] + H[n%16] + (THE SAME IN EITHER SYSTEM) + CALL-UNIX AND CONTROLLING TERMINAL DEVICES + m=5: + n=0: tty + n=64..128: cua + {'0' + (n-64)} + CYCLADES MULTIPORT: + m=19, n: ttyC + itoa_hex(n) + m=20, n: cub + itoa_hex(n) */ + +/* Re-implementation of old interface with the new generic functions. */ + +/* This does exactly the same thing as name_to_dev only now a full "ttyXX" + specification will work as well. +*/ +int tty_to_dev(char *tty) { + static char pref_name_1[32] = "tty", *pnam1 = pref_name_1 + 3, + pref_name_2[32] = "cu", *pnam2 = pref_name_2 + 2; + dev_t num; + if ((num = name_to_dev(tty)) != (dev_t) -1) /* try tty straight up */ + return num; + strncpy(pnam1, tty, 32 - 3); /* try with "tty" prepended */ + if ((num = name_to_dev(pref_name_1)) != (dev_t) -1) + return num; + strncpy(pnam2, tty, 32 - 2); /* try with "cu" prepended */ + if ((num = name_to_dev(pref_name_2)) != (dev_t) -1) + return num; + return -1; /* no match */ +} + +/* new abstraction that can maybe be generalized a little better. */ +char* abbrev_of_tty(char *tty) { + static char temp[32]; /* return buf: good only until next call */ + char *pos = strpbrk(tty, "yu"); /* end of (presumed) prefices: tty*, cu* */ + temp[0] = 0; + if (tty && tty[0] && pos && pos[0] && pos[1]) + sprintf(temp, "%*.*s", 3, 3, pos + 1); + else + strncpy(temp, " ? ", 31); + return temp; +} + +/* Do in-place modification of the 4-buffer `tty' based upon `dev' */ +void dev_to_tty(char *tty, int dev) { + char* new = abbrev_of_tty(dev_to_name(dev)); + strncpy(tty, new, 4); +} diff --git a/libproc/devname.h b/libproc/devname.h new file mode 100644 index 00000000..e1371f45 --- /dev/null +++ b/libproc/devname.h @@ -0,0 +1,10 @@ + +#include + +dev_t name_to_dev(char* name); +char* dev_to_name(dev_t num); + +dev_t tty_to_dev(char *tty); +void dev_to_tty(char *tty, int dev); + +char* abbrev_of_tty(char *tty); diff --git a/libproc/ksym.c b/libproc/ksym.c new file mode 100644 index 00000000..b3ae3284 --- /dev/null +++ b/libproc/ksym.c @@ -0,0 +1,252 @@ +/* kernel address -> symbol with next lower address. Charles Blake, 1996. + * Written to obviate the need for psdatabase initialization based upon kernel + * binary formats, etc. + * + * The basic algorithm is an approximate (intervals split vaguely 50-50) binary + * search taking advantage of the fact the System.map is already sorted in + * ascending order by the kernel makefile. It needs to assume an average symbol + * record length to avoid scanning the entire symbol table, but in practice the + * search time does not seem to be especially sensitive to this choice. + * + * The search could be an exact binary search if the lines of System.map were + * padded with blanks to the right. awk '{printf "%8s%2s %-21.21s\n",$1,$2,$3}' + * would do the trick for this but either makes the file large or truncates + * symbols. The approximate method seems to be plenty fast enough, costing + * only about as much as one extra fstat() or so per process. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "proc/psdata.h" +#include "proc/ps.h" +#include "proc/version.h" + +#define MAX_ADDR_SZ 32 +static char *sysmap, *sysmap_last, sysmap_fmt[10]; +static int sysmap_len, sysmap_mean = 32, sysmap_addrsz; + +/* scan backward in a string no further than address beg looking for c */ +static char *strchrrev(char *a, char *beg, char c) { + if (a) + while (--a > beg && *a != c) ; + return a; +} + +/* return ptr to the beg of approximately the i-th record */ +static char *addr_str(int i) { + char *guess = sysmap + sysmap_mean * i; + if (!i) return sysmap; + if (guess - sysmap > sysmap_len - 2) guess = sysmap + sysmap_len - 2; + for ( ; *guess != '\n' && guess > sysmap; guess--) + ; + return guess + 1; + +} + +/* return ptr to symbol string (\n terminated) given beg of record ptr */ +static char *sym_put(char *buf, int len, char *addrptr) { + char *s; + while (*addrptr++ != ' ') ; + while (*addrptr++ != ' ') ; + strncpy(buf, addrptr, len); + for (s = buf; s < buf + len; s++) + if (*s == '\n') + *s = '\0'; + buf[len - 1] = '\0'; + return buf; +} + +/* Try to open and mmap a single symbol table file and initialize globals */ +int sysmap_mmap(char *path) { + int fd; + struct stat sbuf; + char *p; + if (sysmap) /* do nothing if already mapped */ + return 1; + if ((fd = open(path, O_RDONLY)) < 0 + || fstat(fd, &sbuf) < 0 + || (sysmap = mmap(0, sbuf.st_size, + PROT_READ, MAP_SHARED, + fd, 0)) == (caddr_t) -1) + { + close(fd); + sysmap = NULL; + return 0; + } + sysmap_len = sbuf.st_size; + sysmap_last = strchrrev(sysmap + sysmap_len - 2, sysmap, '\n') + 1; + + /* Now check first line of sysmap for hex numbers in first column. Note: + 0x/0X prefixes are disallowed, but easily addable. Capitalization is + irrelevant because strncasecmp(3) is used below instead of strncmp. */ + for (p = sysmap; *p != ' ' + && ((*p >= '0' && *p <= '9') || + (*p >= 'A' && *p <= 'F') || + (*p >= 'a' && *p <= 'f')) + && p < sysmap + MAX_ADDR_SZ; + p++) /* no-op */ ; + if (*p != ' ') { /* uh-oh: cannot understand format */ + fprintf(stderr, "warning: %s not parseable as a System.map.\n", path); + munmap(sysmap, sysmap_len); + sysmap = NULL; + close(fd); + return 0; + } + sysmap_addrsz = p - sysmap; + snprintf(sysmap_fmt, sizeof sysmap_fmt, "%%0%dlx", sysmap_addrsz); + close(fd); + return 1; +} + +/* kernel address -> name resolver. + returned value is only good until the next call to the function. + */ +char *sysmap_symbol(unsigned long address) { + static char rval[128], *pc, addr[MAX_ADDR_SZ]; + int i, p, n = sysmap_len / (double)sysmap_mean; + + sprintf(addr, sysmap_fmt, address); + p = 0; pc = sysmap; + while (n) { + i = p + (n >> 1); + if (strncasecmp(addr, pc = addr_str(i), sysmap_addrsz) > 0) + p = i + 1; + n >>= 1; + } + if (pc == sysmap_last) /* scan forward but not past end */ + return sym_put(rval, sizeof rval, pc); + while (strncasecmp(addr, pc, sysmap_addrsz) > 0) + pc = strchr(pc, '\n') + 1; + if (pc == sysmap) /* scan backward but not past beg */ + return sym_put(rval, sizeof rval, pc); + while (strncasecmp(addr, pc, sysmap_addrsz) < 0) + pc = strchrrev(pc - 1, sysmap, '\n') + 1; + return sym_put(rval, sizeof rval, pc); +} + +/* extern struct nlist *namelist; */ +struct tbl_s vars, fncs; +struct psdb_hdr db_hdr; +int psdb = -1; + +int open_psdb(void) { + static char *sysmap_paths[] = { + "/boot/System.map-%s", + "/boot/System.map", + "/lib/modules/%s/System.map", + NULL + }; + static char *psdb_paths[] = { + "/etc/psdatabase", + "/boot/psdatabase-%s", + "/boot/psdatabase", + "/lib/modules/%s/psdatabase", + NULL + }; + char **fmt, *env, path[64]; + struct utsname uts; + uname(&uts); + if ((env = getenv("PS_SYSMAP")) && sysmap_mmap(env)) + return 0; + for (fmt = sysmap_paths; *fmt; fmt++) { + snprintf(path, sizeof path, *fmt, uts.release); + if (sysmap_mmap(path)) + return 0; + } + for (fmt = psdb_paths; *fmt; fmt++) { + snprintf(path, sizeof path, *fmt, uts.release); + if ((psdb = open(path, O_RDONLY)) != -1 && + read(psdb, (char*)&db_hdr, sizeof db_hdr) == sizeof db_hdr && + strncmp(db_hdr.magic, procps_version, sizeof(db_hdr.magic)) == 0) + /* && version_cmp(kernel,psdatabase) */ + return 0; + if (psdb != -1) + fprintf(stderr, + "psdatabase has magic no. %*s instead of %*s\n", + (int) sizeof db_hdr.magic, db_hdr.magic, + (int) sizeof db_hdr.magic, procps_version); + close(psdb); + } + return -1; +} + +void close_psdb(void) { + if (sysmap) + munmap(sysmap, sysmap_len); + else if (psdb != -1) + close(psdb); + psdb = -1; + sysmap = NULL; +} + +int read_tbl(struct dbtbl_s *dbtbl, struct tbl_s *tbl) { + lseek(psdb, dbtbl->off, SEEK_SET); + tbl->tbl = (struct sym_s *) xmalloc(dbtbl->size); + if (read(psdb, (char *) tbl->tbl, dbtbl->size) != dbtbl->size) { + perror(PSDATABASE); + exit(1); + } + tbl->nsym = dbtbl->nsym; + tbl->strings = (char *) (tbl->tbl + tbl->nsym); + return 0; +} + +char * find_func(unsigned long address) { + int n; + struct sym_s *p; + char *s; + + if (sysmap) + return sysmap_symbol(address); + if (psdb == -1) + return "(no psdb)"; + if (fncs.tbl == NULL) + read_tbl(&db_hdr.fncs, &fncs); + p = fncs.tbl; + n = fncs.nsym; + while (n) { + int i = n / 2; + if (p[i].addr < address) { + p = &p[i+1]; + if (p->addr > address) { + --p; + break; + } + --n; + } + n /= 2; + } + s = p->name + fncs.strings; + return *s=='_' ? s+1 : s; +} + +char * wchan(unsigned long address) { + static char zero = 0; + char *p; + + if (address) { + p = find_func(address); + if (strncmp(p, "sys_", 4) == 0) + p += 4; + while (*p == '_' && *p) + ++p; + } else /* 0 address means not in kernel space */ + p = &zero; + return p; +} + +#ifdef SYSMAP_TEST +int main(int ac, char** av) { + if (ac < 3) {printf("%s System.map lines hexaddr ...\n",av[0]); return 1;} + if (!sysmap_mmap(av[1])) return 1; + if ((sysmap_mean = atoi(av[2])) <= 0) return 1; + for (av += 3; *av; av++) + printf("%s %s\n", *av, sysmap_symbol(strtoul(*av, NULL, 16))); + return 0; +} +#endif diff --git a/libproc/output.c b/libproc/output.c new file mode 100644 index 00000000..66e4e407 --- /dev/null +++ b/libproc/output.c @@ -0,0 +1,52 @@ +/* + Some output conversion routines for libproc + Copyright (C) 1996, Charles Blake. See COPYING for details. +*/ +#include +#include +#include + +/* output a string, converting unprintables to octal as we go, and stopping after + processing max chars of output (accounting for expansion due to octal rep). +*/ +unsigned print_str(FILE* file, char *s, unsigned max) { + int i; + for (i=0; s[i] && i < max; i++) + if (isprint(s[i]) || s[i] == ' ') + fputc(s[i], file); + else { + if (max - i > 3) { + fprintf(file, "\\%03o", s[i]); + i += 3; /* 4 printed, but i counts one */ + } else + return max - i; + } + return max - i; +} + +/* output an argv style NULL-terminated string list, converting unprintables + to octal as we go, separating items of the list by 'sep' and stopping after + processing max chars of output (accounting for expansion due to octal rep). +*/ +unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max) { + int i, n, seplen = strlen(sep); + for (n=0; *strs && n < max; strs++) { + for (i=0; strs[0][i] && n+i < max; i++) + if (isprint(strs[0][i]) || strs[0][i] == ' ') + fputc(strs[0][i], file); + else { + if (max-(n+i) > 3) { + fprintf(file, "\\%03o", strs[0][i]); + n += 3; /* 4 printed, but i counts one */ + } else + return max - n; + } + n += i; + if (n + seplen < max) { + fputs(sep, file); + n += seplen; + } else + return max - n; + } + return max - n; +} diff --git a/libproc/ps.h b/libproc/ps.h new file mode 100644 index 00000000..aa065cbf --- /dev/null +++ b/libproc/ps.h @@ -0,0 +1,30 @@ +/* The shadow of the original with only common prototypes now. */ +#include +#include + +/* get definition of HZ */ +#include + +/* get page info */ +#include + +char *wchan(unsigned long); +char *find_func(unsigned long address); +void *xcalloc(void *pointer, int size); +void *xmalloc(unsigned int size); +void *xrealloc(void *oldp, unsigned int size); + +int mult_lvl_cmp(void* a, void* b); +int node_mult_lvl_cmp(void* a, void* b); +void dump_keys(void); + +char *user_from_uid(int uid); + +int open_sysmap(void); +int open_psdb(void); +void close_psdb(void); +void make_fnctbl(void); + +unsigned print_str (FILE* file, char *s, unsigned max); +unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max); +unsigned snprint_strlist(char *buf, int max, char **strs, char *sep); diff --git a/libproc/psdata.h b/libproc/psdata.h new file mode 100644 index 00000000..a6c480e8 --- /dev/null +++ b/libproc/psdata.h @@ -0,0 +1,103 @@ +/* + * psdata.h + * + * Jeffrey A. Uphoff , 1995, 1996. + * Michael K. Johnson. + * Bruno Lankester. + * (And others I'm sure...) + * + */ + +/* + * Capabilities are for reading system images and producing maps for + * WCHAN output. + * + * AOUT_CAPABLE and ELF_CAPABLE may have 32-bit word size limitations + * and have only been tested by the maintainer on Intel systems. They + * are retained in the source tree in case they are useful; they are + * intended to be generally deprecated. + * + * BFD_CAPABLE should work on any system with BFD. + * + * Set the capabilities in the top-level Makefile. + */ + +#if defined(ELF_CAPABLE) +# define ELF_OBJECT 1 +# define ELF_FUNC 2 +#endif + +#include +#include + +#define PSDATABASE "/etc/psdatabase" + +struct dbtbl_s { + off_t off; /* offset in psdatabase */ + int nsym; /* # symbols */ + int size; /* size of array + strings */ +}; + +/* + * header of psdatabase + */ +struct psdb_hdr { + /* Current procps package version goes here. kmemps doesn't like this. */ + char magic[32]; + /* + * These are not functional--they only reside in the database for + * informational purposes (i.e. if you want to look at the raw + * database and see what kernel it's for). + */ + char uts_release[__NEW_UTS_LEN]; + char uts_version[__NEW_UTS_LEN]; + /* + * Again, this is not functional, it's just there for information: it + * shows the path to the uncompressed kernel image that was used to + * generate this database. + */ + char sys_path[128]; + /* List of all functions. */ + struct dbtbl_s fncs; + /* + * This is currently only used to look up system_utsname while + * psupdate is building the database--it really should be phased out! + */ + /* List of all bss and data symbols. */ + struct dbtbl_s vars; + /* + * The list of tty names that kmemps likes/uses in no longer present + * in the procps psdatabase--it was never being built by procps' + * psupdate anyway, so I removed the entry from the database header. + */ +}; + +struct sym_s { + unsigned long addr; /* core address in kernel */ + int name; /* offset from strings ptr */ +}; + +struct tbl_s { + struct sym_s *tbl; + int nsym; + char *strings; /* ptr to start of strings */ +}; + +extern struct psdb_hdr db_hdr; +extern struct tbl_s fncs, vars; + +int read_tbl (struct dbtbl_s *, struct tbl_s *); +void *xmalloc (unsigned int); +void *xrealloc (void *, unsigned int); + +#define MLSEEK(FD, WHERE, WHENCE, ERROR)\ +if (lseek ((FD), (WHERE), (WHENCE)) == -1) {\ + perror ((ERROR));\ + exit (errno);\ +} + +#define MREAD(FD, WHAT, SIZE, ERROR)\ +if (read ((FD), (WHAT), (SIZE)) != (SIZE)) {\ + perror ((ERROR));\ + exit (errno);\ +} diff --git a/libproc/pwcache.c b/libproc/pwcache.c new file mode 100644 index 00000000..2d50054c --- /dev/null +++ b/libproc/pwcache.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include "proc/ps.h" + +#define HASHSIZE 16 /* power of 2 */ +#define HASH(x) ((x) & (HASHSIZE - 1)) + + +static struct pwbuf { + int uid; + char name[12]; + struct pwbuf *next; +} *pwhash[HASHSIZE]; + +char *user_from_uid(int uid) +{ + struct pwbuf **p; + struct passwd *pw; + + p = &pwhash[HASH(uid)]; + while (*p) { + if ((*p)->uid == uid) + return((*p)->name); + p = &(*p)->next; + } + *p = (struct pwbuf *) xmalloc(sizeof(struct pwbuf)); + (*p)->uid = uid; + if ((pw = getpwuid(uid)) == NULL) + sprintf((*p)->name, "#%d", uid); + else + sprintf((*p)->name, "%-.8s", pw->pw_name); + (*p)->next = NULL; + return((*p)->name); +} + +void bad_user_access_length() { } diff --git a/libproc/readproc.c b/libproc/readproc.c new file mode 100644 index 00000000..31836b0c --- /dev/null +++ b/libproc/readproc.c @@ -0,0 +1,395 @@ +/* + * New Interface to Process Table -- PROCTAB Stream (a la Directory streams) + * Copyright(C) 1996. Charles L. Blake. + */ +#include "proc/version.h" +#include "proc/readproc.h" +#include "proc/devname.h" +#include "proc/ps.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define Do(x) (flags & PROC_ ## x) /* convenient shorthand */ + +/* initiate a process table scan + */ +PROCTAB* openproc(int flags, ...) { + va_list ap; + PROCTAB* PT = xmalloc(sizeof(PROCTAB)); + + if (!Do(PID) && !(PT->procfs = opendir("/proc"))) + return NULL; + PT->flags = flags; + va_start(ap, flags); /* Init args list */ + if (Do(PID)) + PT->pids = va_arg(ap, pid_t*); + else if (Do(TTY)) + PT->ttys = va_arg(ap, dev_t*); + else if (Do(UID)) { + PT->uids = va_arg(ap, uid_t*); + PT->nuid = va_arg(ap, int); + } else if (Do(STAT)) + PT->stats = va_arg(ap, char*); + va_end(ap); /* Clean up args list */ + if (Do(ANYTTY) && Do(TTY)) + PT->flags = PT->flags & ~PROC_TTY; /* turn off TTY flag */ + return PT; +} + +/* terminate a process table scan + */ +void closeproc(PROCTAB* PT) { + if (PT->procfs) closedir(PT->procfs); + if (PT) free(PT); +} + +/* deallocate the space allocated by readproc if the passed rbuf was NULL + */ +void freeproc(proc_t* p) { + if (!p) /* in case p is NULL */ + return; + /* ptrs are after strings to avoid copying memory when building them. */ + /* so free is called on the address of the address of strvec[0]. */ + if (p->cmdline) + free((void*)*p->cmdline); + if (p->environ) + free((void*)*p->environ); + free(p); +} + +/* stat2proc() makes sure it can handle arbitrary executable file basenames + for `cmd', i.e. those with embedded whitespace or embedded ')'s. Such names + confuse %s (see scanf(3)), so the string is split and %39c is used instead. + (except for embedded ')' "(%[^)]c)" would work. +*/ +void stat2proc(char* S, proc_t* P) { + char* tmp = strrchr(S, ')'); /* split into "PID (cmd" and "" */ + *tmp = '\0'; /* replace trailing ')' with NUL */ + /* parse these two strings separately, skipping the leading "(". */ + memset(P->cmd, 0, sizeof P->cmd); /* clear even though *P xcalloc'd ?! */ + sscanf(S, "%d (%39c", &P->pid, P->cmd); + sscanf(tmp + 2, /* skip space after ')' too */ + "%c %d %d %d %d %d %lu %lu %lu %lu %lu %ld %ld %ld %ld %d " + "%d %lu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %LX %LX %LX %LX %lu", + &P->state, &P->ppid, &P->pgrp, &P->session, &P->tty, &P->tpgid, + &P->flags, &P->min_flt, &P->cmin_flt, &P->maj_flt, &P->cmaj_flt, + &P->utime, &P->stime, &P->cutime, &P->cstime, &P->priority, &P->nice, + &P->timeout, &P->it_real_value, &P->start_time, &P->vsize, &P->rss, + &P->rss_rlim, &P->start_code, &P->end_code, &P->start_stack, + &P->kstk_esp, &P->kstk_eip, &P->signal, &P->blocked, &P->sigignore, + &P->sigcatch, &P->wchan); + if (P->tty == 0) + P->tty = -1; /* the old notty val, update elsewhere bef. moving to 0 */ + if (linux_version_code < LINUX_VERSION(1,3,39)) { + P->priority = 2*15 - P->priority; /* map old meanings to new */ + P->nice = 15 - P->nice; + } + if (linux_version_code < LINUX_VERSION(1,1,30) && P->tty != -1) + P->tty = 4*0x100 + P->tty; /* when tty wasn't full devno */ +} + +void statm2proc(char* s, proc_t* P) { + sscanf(s, "%ld %ld %ld %ld %ld %ld %ld", + &P->size, &P->resident, &P->share, + &P->trs, &P->lrs, &P->drs, &P->dt); +} + +void nulls2sep(char* str, int len, char sep) { + int i; + for (i = 0; i < len; i++) + if (str[i] == 0) + str[i] = sep; +} + +int file2str(char *directory, char *what, char *ret, int cap) { + static char filename[80]; + int fd, num_read; + + sprintf(filename, "%s/%s", directory, what); + if ( (fd = open(filename, O_RDONLY, 0)) == -1 ) return -1; + if ( (num_read = read(fd, ret, cap - 1)) <= 0 ) return -1; + ret[num_read] = 0; + close(fd); + return num_read; +} + +char** file2strvec(char* directory, char* what) { + char buf[2048]; /* read buf bytes at a time */ + char *p, *rbuf = 0, *endbuf, **q, **ret; + int fd, tot = 0, n, c, end_of_file = 0; + int align; + + sprintf(buf, "%s/%s", directory, what); + if ( (fd = open(buf, O_RDONLY, 0) ) == -1 ) return NULL; + + /* read whole file into a memory buffer, allocating as we go */ + while ((n = read(fd, buf, sizeof buf - 1)) > 0) { + if (n < sizeof buf - 1) + end_of_file = 1; + if (n == 0 && rbuf == 0) + return NULL; /* process died between our open and read */ + if (n < 0) { + if (rbuf) + free(rbuf); + return NULL; /* read error */ + } + if (end_of_file && buf[n-1]) /* last read char not null */ + buf[n++] = '\0'; /* so append null-terminator */ + rbuf = xrealloc(rbuf, tot + n); /* allocate more memory */ + memcpy(rbuf + tot, buf, n); /* copy buffer into it */ + tot += n; /* increment total byte ctr */ + if (end_of_file) + break; + } + close(fd); + if (n <= 0 && !end_of_file) { + if (rbuf) free(rbuf); + return NULL; /* read error */ + } + endbuf = rbuf + tot; /* count space for pointers */ + align = (sizeof(char*)-1) - ((tot + sizeof(char*)-1) & (sizeof(char*)-1)); + for (c = 0, p = rbuf; p < endbuf; p++) + if (!*p) + c += sizeof(char*); + c += sizeof(char*); /* one extra for NULL term */ + + rbuf = xrealloc(rbuf, tot + c + align); /* make room for ptrs AT END */ + endbuf = rbuf + tot; /* addr just past data buf */ + q = ret = (char**) (endbuf+align); /* ==> free(*ret) to dealloc */ + *q++ = p = rbuf; /* point ptrs to the strings */ + endbuf--; /* do not traverse final NUL */ + while (++p < endbuf) + if (!*p) /* NUL char implies that */ + *q++ = p+1; /* next string -> next char */ + + *q = 0; /* null ptr list terminator */ + return ret; +} + + +/* These are some nice GNU C expression subscope "inline" functions. + The can be used with arbitrary types and evaluate their arguments + exactly once. +*/ + +/* Test if item X of type T is present in the 0 terminated list L */ +# define XinL(T, X, L) ( { \ + T x = (X), *l = (L); \ + while (*l && *l != x) l++; \ + *l == x; \ + } ) + +/* Test if item X of type T is present in the list L of length N */ +# define XinLN(T, X, L, N) ( { \ + T x = (X), *l = (L); \ + int i = 0, n = (N); \ + while (i < n && l[i] != x) i++; \ + i < n && l[i] == x; \ + } ) + +/* readproc: return a pointer to a proc_t filled with requested info about the + * next process available matching the restriction set. If no more such + * processes are available, return a null pointer (boolean false). Use the + * passed buffer instead of allocating space if it is non-NULL. */ + +/* This is optimized so that if a PID list is given, only those files are + * searched for in /proc. If other lists are given in addition to the PID list, + * the same logic can follow through as for the no-PID list case. This is + * fairly complex, but it does try to not to do any unnecessary work. + * Unfortunately, the reverse filtering option in which any PID *except* the + * ones listed is pursued. + */ +#define flags (PT->flags) +proc_t* readproc(PROCTAB* PT, proc_t* rbuf) { + static struct direct *ent; /* dirent handle */ + static struct stat sb; /* stat buffer */ + static char path[32], sbuf[256]; /* bufs for stat,statm */ + int allocated = 0, matched = 0; /* flags */ + proc_t *p = NULL; + + /* loop until a proc matching restrictions is found or no more processes */ + /* I know this could be a while loop -- this way is easier to indent ;-) */ +next_proc: /* get next PID for consideration */ + if (Do(PID)) { + if (!*PT->pids) /* set to next item in pids */ + return NULL; + sprintf(path, "/proc/%d", *(PT->pids)++); + matched = 1; + } else { /* get next numeric /proc ent */ + while ((ent = readdir(PT->procfs)) && + (*ent->d_name < '0' || *ent->d_name > '9')) + ; + if (!ent || !ent->d_name) + return NULL; + sprintf(path, "/proc/%s", ent->d_name); + } + if (stat(path, &sb) == -1) /* no such dirent (anymore) */ + goto next_proc; + if (Do(UID) && !XinLN(uid_t, sb.st_uid, PT->uids, PT->nuid)) + goto next_proc; /* not one of the requested uids */ + + if (!allocated) { /* assign mem for return buf */ + p = rbuf ? rbuf : xcalloc(p, sizeof *p); /* passed buf or alloced mem */ + allocated = 1; /* remember space is set up */ + } + p->uid = sb.st_uid; /* need a way to get real uid */ + + if ((file2str(path, "stat", sbuf, sizeof sbuf)) == -1) + goto next_proc; /* error reading /proc/#/stat */ + stat2proc(sbuf, p); /* parse /proc/#/stat */ + + if (!matched && Do(TTY) && !XinL(dev_t, p->tty, PT->ttys)) + goto next_proc; /* not one of the requested ttys */ + + if (!matched && Do(ANYTTY) && p->tty == -1) + goto next_proc; /* no controlling terminal */ + + if (!matched && Do(STAT) && !strchr(PT->stats,p->state)) + goto next_proc; /* not one of the requested states */ + + if (Do(FILLMEM)) { /* read, parse /proc/#/statm */ + if ((file2str(path, "statm", sbuf, sizeof sbuf)) != -1 ) + statm2proc(sbuf, p); /* ignore statm errors here */ + } /* statm fields just zero */ + + /* some number->text resolving which is time consuming */ + if (Do(FILLTTY)) + dev_to_tty(p->ttyc, p->tty); + if (Do(FILLUSR)) + strncpy(p->user, user_from_uid(p->uid), sizeof p->user); + + if (Do(FILLCMD)) /* read+parse /proc/#/cmdline */ + p->cmdline = file2strvec(path, "cmdline"); + if (Do(FILLENV)) /* read+parse /proc/#/environ */ + p->environ = file2strvec(path, "environ"); + + if (p->state == 'Z') /* fixup cmd for zombies */ + strncat(p->cmd," ", sizeof p->cmd); + + return p; +} +#undef flags + +/* Convenient wrapper around openproc and readproc to slurp in the whole process + * tree subset satisfying the constraints of flags and the optional PID list. + * Free allocated memory with freeproctree(). The tree structure is a classic + * left-list children + right-list siblings. The algorithm is a two-pass of the + * process table. Since most process trees will have children with strictly + * increasing PIDs, most of the structure will be picked up in the first pass. + * The second loop then cleans up any nodes which turn out to have preceeded + * their parent in /proc order. + */ + +/* Traverse tree 't' breadth-first looking for a process with pid p */ +proc_t* LookupPID(proc_t* t, pid_t p) { + proc_t* tmp = NULL; + if (!t) + return NULL; + if (t->pid == p) /* look here/terminate recursion */ + return t; + if ((tmp = LookupPID(t->l, p))) /* recurse over children */ + return tmp; + for (; t; t=t->r) /* recurse over siblings */ + if ((tmp = LookupPID(tmp, p))) + return tmp; + return NULL; +} + +proc_t* readproctree(int flags, ...) { + static proc_t tree; + PROCTAB* PT = NULL; + proc_t *node, *tmp=NULL, *tmp2=NULL; + va_list ap; + + /* pass through apropriate arguments to openproc */ + va_start(ap, flags); + if (Do(UID)) { + /* temporary variables to ensure that va_arg() instances + * are called in the right order + */ + uid_t* u; + int i; + + u = va_arg(ap, uid_t*); + i = va_arg(ap, int); + PT = openproc(flags, u, i); + } + else if (Do(PID) || Do(TTY) || Do(STAT)) + PT = openproc(flags, va_arg(ap, void*)); + else + PT = openproc(flags); + va_end(ap); + + /* first pass: build tree, putting orphans on the first level */ + tree.l = tree.r = NULL; + while ((node = readproc(PT,0))) + if ((tmp = LookupPID(&tree, node->ppid))) { + node->r = tmp->l->r; /* node --> left list of parent */ + tmp->l->r = node; + } else { + node->r = tree.r; /* node --> right list of 'tree' */ + tree.r = node; + } + /* second pass: scan tree for PPIDs of level-1 nodes moving links as necessary */ + for (node = &tree; node; node = node->r) + if ((tmp = LookupPID(&tree, node->r->ppid))) { + tmp2 = node->r; /* unlink from right list of 'tree' */ + node->r = node->r->r; + tmp2->r = tmp->l->r; /* insert as child of found node */ + tmp->l->r = node; + } + closeproc(PT); + return &tree; +} + +/* Convenient wrapper around openproc and readproc to slurp in the whole process + * table subset satisfying the constraints of flags and the optional PID list. + * Free allocated memory with freeproctab(). Access via tab[N]->member. The + * pointer list is NULL terminated. + */ +proc_t** readproctab(int flags, ...) { + PROCTAB* PT = NULL; + proc_t** tab = NULL; + int n = 0; + va_list ap; + + va_start(ap, flags); /* pass through args to openproc */ + if (Do(UID)) { + /* temporary variables to ensure that va_arg() instances + * are called in the right order + */ + uid_t* u; + int i; + + u = va_arg(ap, uid_t*); + i = va_arg(ap, int); + PT = openproc(flags, u, i); + } + else if (Do(PID) || Do(TTY) || Do(STAT)) + PT = openproc(flags, va_arg(ap, void*)); /* assume ptr sizes same */ + else + PT = openproc(flags); + va_end(ap); + do { /* read table: */ + tab = xrealloc(tab, (n+1)*sizeof(proc_t*));/* realloc as we go, using */ + tab[n] = readproc(PT, NULL); /* final null to terminate */ + } while (tab[n++]); /* stop when NULL reached */ + closeproc(PT); + return tab; +} + +/* deallocate a table of pointers to proc structures + */ +void freeproctab(proc_t** tab) { + proc_t** p; + for(p = tab; *p; p++) + freeproc(*p); + free(tab); +} diff --git a/libproc/readproc.h b/libproc/readproc.h new file mode 100644 index 00000000..b93f0198 --- /dev/null +++ b/libproc/readproc.h @@ -0,0 +1,168 @@ +/* + * New Interface to Process Table -- PROCTAB Stream (a la Directory streams) + * Copyright(C) 1996. Charles L. Blake. + */ + +/* Basic data structure which holds all information we can get about a process. + * (unless otherwise specified, fields are read from /proc/#/stat) + */ +typedef struct proc_s { + char + user[10], /* user name corresponding to owner of process */ + cmd[40], /* basename of executable file in call to exec(2) */ + state, /* single-char code for process state (S=sleeping) */ + ttyc[5], /* string representation of controlling tty device */ + **environ, /* environment string vector (/proc/#/environ) */ + **cmdline; /* command line string vector (/proc/#/cmdline) */ + int + uid, /* user id */ + pid, /* process id */ + ppid, /* pid of parent process */ + pgrp, /* process group id */ + session, /* session id */ + tty, /* full device number of controlling terminal */ + tpgid, /* terminal process group id */ + priority, /* kernel scheduling priority */ + nice; /* standard unix nice level of process */ + long long + signal, /* mask of pending signals */ + blocked, /* mask of blocked signals */ + sigignore, /* mask of ignored signals */ + sigcatch; /* mask of caught signals */ + long + start_time, /* start time of process -- seconds since 1-1-70 */ + utime, /* user-mode CPU time accumulated by process */ + stime, /* kernel-mode CPU time accumulated by process */ + cutime, /* cumulative utime of process and reaped children */ + cstime, /* cumulative stime of process and reaped children */ + /* the next 7 members come from /proc/#/statm */ + size, /* total # of pages of memory */ + resident, /* number of resident set (non-swapped) pages (4k) */ + share, /* number of pages of shared (mmap'd) memory */ + trs, /* text resident set size */ + lrs, /* shared-lib resident set size */ + drs, /* data resident set size */ + dt; /* dirty pages */ + unsigned + pcpu; /* %CPU usage (is not filled in by readproc!!!) */ + unsigned long + vsize, /* number of pages of virtual memory ... */ + rss, /* resident set size from /proc/#/stat */ + rss_rlim, /* resident set size ... ? */ + timeout, /* ? */ + it_real_value, /* ? */ + flags, /* kernel flags for the process */ + min_flt, /* number of minor page faults since process start */ + maj_flt, /* number of major page faults since process start */ + cmin_flt, /* cumulative min_flt of process and child processes */ + cmaj_flt, /* cumulative maj_flt of process and child processes */ + start_code, /* address of beginning of code segment */ + end_code, /* address of end of code segment */ + start_stack, /* address of the bottom of stack for the process */ + kstk_esp, /* kernel stack pointer */ + kstk_eip, /* kernel stack pointer */ + wchan; /* address of kernel wait channel proc is sleeping in */ + struct proc_s *l, /* ptrs for building arbitrary linked structs */ + *r; /* (i.e. singly/doubly-linked lists and trees */ +} proc_t; + +/* PROCTAB: data structure holding the persistent information readproc needs + * from openproc(). The setup is intentionally similar to the dirent interface + * and other system table interfaces (utmp+wtmp come to mind). + */ +#include +#include +#include +typedef struct { + DIR* procfs; + int flags; + pid_t* pids; /* pids of the procs */ + dev_t* ttys; /* devnos of the cttys */ + uid_t* uids; /* uids of procs */ + int nuid; /* cannot really sentinel-terminate unsigned short[] */ + char* stats; /* status chars (actually output into /proc//stat) */ +} PROCTAB; + +/* initialize a PROCTAB structure holding needed call-to-call persistent data + */ +PROCTAB* openproc(int flags, ... /* pid_t*|uid_t*|dev_t*|char* [, int n] */ ); + +/* Convenient wrapper around openproc and readproc to slurp in the whole process + * table subset satisfying the constraints of flags and the optional PID list. + * Free allocated memory with freeproctab(). Access via tab[N]->member. The + * pointer list is NULL terminated. + */ +proc_t** readproctab(int flags, ... /* same as openproc */ ); + +/* Convenient wrapper around openproc and readproc to slurp in the whole process + * tree subset satisfying the constraints of flags and the optional PID list. + */ +proc_t* readproctree(int flags, ... /* same as openproc */ ); + +/* clean-up open files, etc from the openproc() + */ +void closeproc(PROCTAB* PT); + +/* retrieve the next process matching the criteria set by the openproc() + */ +proc_t* readproc(PROCTAB* PT, proc_t* return_buf); + +/* deallocate space allocated by readproc + */ +void freeproc(proc_t* p); + +/* deallocate space allocated by readproctab + */ +void freeproctab(proc_t** p); + +/* openproc/readproctab: + * + * Return PROCTAB* / *proc_t[] or NULL on error ((probably) "/proc" cannot be + * opened.) By default readproc will consider all processes as valid to parse + * and return, but not actually fill in the cmdline, environ, and /proc/#/statm + * derived memory fields. + * + * `flags' (a bitwise-or of PROC_* below) modifies the default behavior. The + * "fill" options will cause more of the proc_t to be filled in. The "filter" + * options all use the second argument as the pointer to a list of objects: + * process status', process id's, user id's, and tty device numbers. The third + * argument is the length of the list (currently only used for lists of user + * id's since unsigned short[] supports no convenient termination sentinel.) + */ +#define PROC_FILLMEM 0x1 /* read statm into the appropriate proc_t entries */ +#define PROC_FILLCMD 0x2 /* alloc and fill in `cmdline' part of proc_t */ +#define PROC_FILLENV 0x4 /* alloc and fill in `environ' part of proc_t */ +#define PROC_FILLTTY 0x8 /* resolve device number -> tty name via psdevtab */ +#define PROC_FILLUSR 0x10 /* resolve user id number -> user name via passwd */ + /* consider only processes with one of the passed: */ +#define PROC_PID 0x100 /* process id numbers ( 0 terminated) */ +#define PROC_TTY 0x200 /* ctty device nos. ( 0 terminated) */ +#define PROC_UID 0x400 /* user id numbers ( length needed ) */ +#define PROC_STAT 0x800 /* status fields ('\0' terminated) */ +#define PROC_ANYTTY 0x1000 /* proc must have a controlling terminal */ + +/* utility functions which may be of general interest: */ + +/* slurp /proc/DIR/FILE into a single large string into the passed + buffer. return the number of bytes actually used. used for stat,statm + */ +int file2str(char *dir, char *file, char *buf, int buf_size); + +/* convert a file of null terminated strings into an argv-style string vector + * which may be de-allocated with a single free() on a dereference of the return + * value, e.g. free(*ret). used for cmdline, environ. + */ +char** file2strvec(char* directory, char* what); + +/* parse /proc/#/stat entries in string s into a proc_t + */ +void stat2proc(char* S, proc_t*); + +/* parse /proc/#/statm entries in string s into a proc_t + */ +void statm2proc(char* s, proc_t*); + +/* convert a memory buffer with nulls into a single string, + replacing the nulls with sep. No longer used. + */ +void nulls2sep(char* str, int len, char sep); diff --git a/libproc/signals.c b/libproc/signals.c new file mode 100644 index 00000000..5a1e8aa0 --- /dev/null +++ b/libproc/signals.c @@ -0,0 +1,65 @@ +/* signals.c - signal name handling */ + +#include +#include +#include +#include +#include "proc/signals.h" + + +typedef struct { + int number; + char *name; +} SIGNAME; + + +static SIGNAME signals[] = { +#include "signames.h" /* should be in same dir as this file */ + { 0,NULL }}; + + +void list_signals(void) +{ + SIGNAME *walk; + int col; + + col = 0; + for (walk = signals; walk->name; walk++) { + if (col+strlen(walk->name)+1 > 80) { + putchar('\n'); + col = 0; + } + printf("%s%s",col ? " " : "",walk->name); + col += strlen(walk->name)+1; + } + putchar('\n'); +} + + +int get_signal(char *name,char *cmd) +{ + SIGNAME *walk; + + if (isdigit(*name)) + return atoi(name); + for (walk = signals; walk->name; walk++) + if (!strcmp(walk->name,name)) break; + if (walk->name) return walk->number; + fprintf(stderr,"%s: unknown signal; %s -l lists signals.\n",name,cmd); + exit(1); +} + +/* get_signal2 is by Michael Shields. 1994/04/25. */ +int get_signal2(char *name) +{ + SIGNAME *walk; + + if (!name) + return(-1); + if (isdigit(*name)) + return atoi(name); + for (walk = signals; walk->name; walk++) + if (!strcmp(walk->name,name)) + return(walk->number); + return(-1); +} diff --git a/libproc/signals.h b/libproc/signals.h new file mode 100644 index 00000000..c793fae0 --- /dev/null +++ b/libproc/signals.h @@ -0,0 +1,12 @@ +/* signals.h - signal name handling */ + +void list_signals(void); + +/* Lists all known signal names on standard output. */ + +int get_signal(char *name,char *cmd); +int get_signal2(char *name); + +/* Returns the signal number of NAME. If no such signal exists, an error + message is displayed and the program is terminated. CMD is the name of the + application. */ diff --git a/libproc/signames.h b/libproc/signames.h new file mode 100644 index 00000000..edcd6a38 --- /dev/null +++ b/libproc/signames.h @@ -0,0 +1,32 @@ +{ 1,"HUP" }, +{ 2,"INT" }, +{ 3,"QUIT" }, +{ 4,"ILL" }, +{ 5,"TRAP" }, +{ 6,"ABRT" }, +{ 6,"IOT" }, +{ 7,"BUS" }, +{ 8,"FPE" }, +{ 9,"KILL" }, +{ 10,"USR1" }, +{ 11,"SEGV" }, +{ 12,"USR2" }, +{ 13,"PIPE" }, +{ 14,"ALRM" }, +{ 15,"TERM" }, +{ 16,"STKFLT" }, +{ 17,"CHLD" }, +{ 18,"CONT" }, +{ 19,"STOP" }, +{ 20,"TSTP" }, +{ 21,"TTIN" }, +{ 22,"TTOU" }, +{ 23,"URG" }, +{ 24,"XCPU" }, +{ 25,"XFSZ" }, +{ 26,"VTALRM" }, +{ 27,"PROF" }, +{ 28,"WINCH" }, +{ 29,"IO" }, +{ 30,"PWR" }, +{ 31,"UNUSED" }, diff --git a/libproc/status.c b/libproc/status.c new file mode 100644 index 00000000..92758196 --- /dev/null +++ b/libproc/status.c @@ -0,0 +1,20 @@ +#include "proc/ps.h" +#include "proc/readproc.h" + +char * status(proc_t* task) { + static char buf[4] = " "; + + buf[0] = task->state; + if (task->rss == 0 && task->state != 'Z') + buf[1] = 'W'; + else + buf[1] = ' '; + if (task->nice < 0) + buf[2] = '<'; + else if (task->nice > 0) + buf[2] = 'N'; + else + buf[2] = ' '; + + return(buf); +} diff --git a/libproc/sysinfo.c b/libproc/sysinfo.c new file mode 100644 index 00000000..8a5e1a7f --- /dev/null +++ b/libproc/sysinfo.c @@ -0,0 +1,176 @@ +/* File for parsing top-level /proc entities. */ +#include "proc/sysinfo.h" + +#include +#include +#include +#include + +#include +#include +#include "proc/version.h" + +#define BAD_OPEN_MESSAGE \ +"Error: /proc must be mounted\n" \ +" To mount /proc at boot you need an /etc/fstab line like:\n" \ +" /proc /proc proc defaults\n" \ +" In the meantime, mount /proc /proc -t proc\n" + +#define UPTIME_FILE "/proc/uptime" +#define LOADAVG_FILE "/proc/loadavg" +#define MEMINFO_FILE "/proc/meminfo" + +static char buf[1024]; + +/* This macro opens FILE only if necessary and seeks to 0 so that successive + calls to the functions are more efficient. It also reads the current + contents of the file into the global buf. +*/ +#define FILE_TO_BUF(FILE) { \ + static int n, fd = -1; \ + if (fd == -1 && (fd = open(FILE, O_RDONLY)) == -1) { \ + fprintf(stderr, BAD_OPEN_MESSAGE); \ + close(fd); \ + return 0; \ + } \ + lseek(fd, 0L, SEEK_SET); \ + if ((n = read(fd, buf, sizeof buf - 1)) < 0) { \ + perror(FILE); \ + close(fd); \ + fd = -1; \ + return 0; \ + } \ + buf[n] = '\0'; \ +} + +#define SET_IF_DESIRED(x,y) if (x) *(x) = (y) /* evals 'x' twice */ + +int uptime(double *uptime_secs, double *idle_secs) { + double up=0, idle=0; + + FILE_TO_BUF(UPTIME_FILE) + if (sscanf(buf, "%lf %lf", &up, &idle) < 2) { + fprintf(stderr, "bad data in " UPTIME_FILE "\n"); + return 0; + } + SET_IF_DESIRED(uptime_secs, up); + SET_IF_DESIRED(idle_secs, idle); + return up; /* assume never be zero seconds in practice */ +} + +int loadavg(double *av1, double *av5, double *av15) { + double avg_1=0, avg_5=0, avg_15=0; + + FILE_TO_BUF(LOADAVG_FILE) + if (sscanf(buf, "%lf %lf %lf", &avg_1, &avg_5, &avg_15) < 3) { + fprintf(stderr, "bad data in " LOADAVG_FILE "\n"); + exit(1); + } + SET_IF_DESIRED(av1, avg_1); + SET_IF_DESIRED(av5, avg_5); + SET_IF_DESIRED(av15, avg_15); + return 1; +} + +/* The following /proc/meminfo parsing routine assumes the following format: + [