diff -Naurp libgtop-1.0.13/Makefile.in libgtop-1.0.13-cygwin/Makefile.in --- libgtop-1.0.13/Makefile.in 2001-11-27 02:04:35.000000000 +0000 +++ libgtop-1.0.13-cygwin/Makefile.in 2002-07-28 14:24:55.000000000 +0100 @@ -184,7 +184,7 @@ sysdeps_suid_lib = @sysdeps_suid_lib@ @BUILD_GNOME_SUPPORT_TRUE@support = support -SUBDIRS = po intl $(support) macros misc include sysdeps lib src $(examples_SUBDIRS) doc +SUBDIRS = po intl $(support) macros misc include sysdeps lib src sysdeps/names $(examples_SUBDIRS) doc libgtopinclude_HEADERS = glibtop.h diff -Naurp libgtop-1.0.13/configure libgtop-1.0.13-cygwin/configure --- libgtop-1.0.13/configure 2001-11-26 22:50:58.000000000 +0000 +++ libgtop-1.0.13-cygwin/configure 2002-07-28 14:24:23.000000000 +0100 @@ -5458,8 +5458,8 @@ EOF else $CC -o impgen impgen.c ; fi)~ $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' - old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' - +# old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' +old_archive_from_expsyms_cmds= # cygwin and mingw dlls have different entry points and sets of symbols # to exclude. # FIXME: what about values for MSVC? @@ -7242,7 +7242,8 @@ old_postuninstall_cmds=$lt_old_postunins old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds +#old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds +old_archive_from_expsyms_cmds= # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds @@ -9964,6 +9965,11 @@ fi echo $ECHO_N "checking for libgtop sysdeps directory... $ECHO_C" >&6 case "$host_os" in + cygwin*) + libgtop_sysdeps_dir=cygwin + libgtop_use_machine_h=no + libgtop_have_sysinfo=yes + ;; linux*) if test x$linux_table = xyes ; then libgtop_sysdeps_dir=kernel @@ -11288,7 +11294,7 @@ EOF libgtop_guile_found=yes guile_examples='third' - guile_static_examples='third_static' + guile_static_examples='third_static.exe' guile_subdirs='guile' else libgtop_guile_found=no @@ -11299,14 +11305,14 @@ fi if test x$libgtop_smp = xyes ; then smp_examples='smp' - smp_static_examples='smp_static' + smp_static_examples='smp_static.exe' else smp_examples= smp_static_examples= fi if test "x$enable_static" != xno; then - static_targets="first_static second_static mountlist_static procmap_static netload_static sysdeps_static timings_static $guile_static_examples $smp_static_examples" + static_targets="first_static.exe second_static.exe mountlist_static.exe procmap_static.exe netload_static.exe sysdeps_static.exe timings_static.exe $guile_static_examples $smp_static_examples" else static_targets="" fi @@ -18298,7 +18304,7 @@ else server_programs= fi -ac_config_files="$ac_config_files Makefile libgtop.spec po/Makefile.in intl/Makefile misc/Makefile include/Makefile include/glibtop/Makefile sysdeps/Makefile sysdeps/common/Makefile sysdeps/names/Makefile sysdeps/guile/Makefile sysdeps/guile/names/Makefile sysdeps/stub/Makefile sysdeps/stub_suid/Makefile sysdeps/sun4/Makefile sysdeps/osf1/Makefile sysdeps/linux/Makefile sysdeps/kernel/Makefile sysdeps/freebsd/Makefile sysdeps/solaris/Makefile src/Makefile src/daemon/Makefile src/inodedb/Makefile lib/Makefile examples/Makefile doc/Makefile support/Makefile macros/Makefile" +ac_config_files="$ac_config_files Makefile libgtop.spec po/Makefile.in intl/Makefile misc/Makefile include/Makefile include/glibtop/Makefile sysdeps/Makefile sysdeps/common/Makefile sysdeps/names/Makefile sysdeps/guile/Makefile sysdeps/guile/names/Makefile sysdeps/stub/Makefile sysdeps/stub_suid/Makefile sysdeps/sun4/Makefile sysdeps/osf1/Makefile sysdeps/linux/Makefile sysdeps/cygwin/Makefile sysdeps/kernel/Makefile sysdeps/freebsd/Makefile sysdeps/solaris/Makefile src/Makefile src/daemon/Makefile src/inodedb/Makefile lib/Makefile examples/Makefile doc/Makefile support/Makefile macros/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -18635,6 +18641,7 @@ do "sysdeps/sun4/Makefile" ) CONFIG_FILES="$CONFIG_FILES sysdeps/sun4/Makefile" ;; "sysdeps/osf1/Makefile" ) CONFIG_FILES="$CONFIG_FILES sysdeps/osf1/Makefile" ;; "sysdeps/linux/Makefile" ) CONFIG_FILES="$CONFIG_FILES sysdeps/linux/Makefile" ;; + "sysdeps/cygwin/Makefile" ) CONFIG_FILES="$CONFIG_FILES sysdeps/cygwin/Makefile" ;; "sysdeps/kernel/Makefile" ) CONFIG_FILES="$CONFIG_FILES sysdeps/kernel/Makefile" ;; "sysdeps/freebsd/Makefile" ) CONFIG_FILES="$CONFIG_FILES sysdeps/freebsd/Makefile" ;; "sysdeps/solaris/Makefile" ) CONFIG_FILES="$CONFIG_FILES sysdeps/solaris/Makefile" ;; diff -Naurp libgtop-1.0.13/examples/Makefile.in libgtop-1.0.13-cygwin/examples/Makefile.in --- libgtop-1.0.13/examples/Makefile.in 2001-11-27 02:05:26.000000000 +0000 +++ libgtop-1.0.13-cygwin/examples/Makefile.in 2002-07-28 14:24:23.000000000 +0100 @@ -276,6 +276,7 @@ CONFIG_CLEAN_FILES = libgtop_PROGRAMS = first$(EXEEXT) second$(EXEEXT) mountlist$(EXEEXT) \ procmap$(EXEEXT) netload$(EXEEXT) sysdeps$(EXEEXT) timings$(EXEEXT) \ @static_targets@ @guile_examples@ @smp_examples@ +EXTRA_PROGRAMS = first_static$(EXEEXT) second_static$(EXEEXT) mountlist_static$(EXEEXT) procmap_static$(EXEEXT) third$(EXEEXT) third_static$(EXEEXT) smp smp_static$(EXEEXT) netload_static$(EXEEXT) sysdeps_static$(EXEEXT) timings_static$(EXEEXT) PROGRAMS = $(libgtop_PROGRAMS) CPPFLAGS = @CPPFLAGS@ diff -Naurp libgtop-1.0.13/lib/Makefile.in libgtop-1.0.13-cygwin/lib/Makefile.in --- libgtop-1.0.13/lib/Makefile.in 2001-11-27 02:05:16.000000000 +0000 +++ libgtop-1.0.13-cygwin/lib/Makefile.in 2002-07-28 14:24:23.000000000 +0100 @@ -306,9 +306,11 @@ distclean-libtool: maintainer-clean-libtool: + libgtop.la: $(libgtop_la_OBJECTS) $(libgtop_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libgtop_la_LDFLAGS) $(libgtop_la_OBJECTS) $(libgtop_la_LIBADD) $(LIBS) - + PREFIX=$(prefix) sh $(top_srcdir)/mkdll.sh $@ ../sysdeps/cygwin/.libs/libgtop_sysdeps.a ../sysdeps/common/.libs/libgtop_common.a -- $$(glib-config --libs) $(libs_xauth) -lintl + tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) diff -Naurp libgtop-1.0.13/lib/sysdeps.c libgtop-1.0.13-cygwin/lib/sysdeps.c --- libgtop-1.0.13/lib/sysdeps.c 2001-11-26 22:37:58.000000000 +0000 +++ libgtop-1.0.13-cygwin/lib/sysdeps.c 2002-07-28 14:24:24.000000000 +0100 @@ -61,6 +61,7 @@ glibtop_init_func_t _glibtop_init_hook_s #if !GLIBTOP_SUID_LOADAVG glibtop_init_loadavg_s, #endif +#ifndef __CYGWIN__ #if !GLIBTOP_SUID_SHM_LIMITS glibtop_init_shm_limits_s, #endif @@ -70,6 +71,7 @@ glibtop_init_func_t _glibtop_init_hook_s #if !GLIBTOP_SUID_SEM_LIMITS glibtop_init_sem_limits_s, #endif +#endif #if !GLIBTOP_SUID_PROCLIST glibtop_init_proclist_s, #endif @@ -103,9 +105,11 @@ glibtop_init_func_t _glibtop_init_hook_s #if !GLIBTOP_SUID_NETLOAD glibtop_init_netload_s, #endif +#ifndef __CYGWIN__ #if !GLIBTOP_SUID_PPP glibtop_init_ppp_s, #endif +#endif NULL }; diff -Naurp libgtop-1.0.13/libgtopConf.sh.in libgtop-1.0.13-cygwin/libgtopConf.sh.in --- libgtop-1.0.13/libgtopConf.sh.in 2001-11-26 22:37:57.000000000 +0000 +++ libgtop-1.0.13-cygwin/libgtopConf.sh.in 2002-07-28 14:25:39.000000000 +0100 @@ -9,16 +9,16 @@ LIBGTOP_DATADIR="@LIBGTOP_DATADIR@" LIBGTOP_EXTRA_LIBS="@LIBGTOP_EXTRA_LIBS@" -LIBGTOP_LIBS="@LIBGTOP_LIBS@" +LIBGTOP_LIBS="-L@LIBGTOP_LIBDIR@ -lgtop" LIBGTOP_INCS="@LIBGTOP_INCS@" -LIBGTOP_NAMES_LIBS="@LIBGTOP_NAMES_LIBS@" +LIBGTOP_NAMES_LIBS="-L@LIBGTOP_LIBDIR@ -lgtop_names -lgtop" LIBGTOP_NAMES_INCS="@LIBGTOP_NAMES_INCS@" -LIBGTOP_GUILE_LIBS="@LIBGTOP_GUILE_LIBS@" +LIBGTOP_GUILE_LIBS="-L@LIBGTOP_LIBDIR@ -lgtop" LIBGTOP_GUILE_INCS="@LIBGTOP_GUILE_INCS@" -LIBGTOP_GUILE_NAMES_LIBS="@LIBGTOP_GUILE_NAMES_LIBS@" +LIBGTOP_GUILE_NAMES_LIBS="-L@LIBGTOP_LIBDIR@ -lgtop_guile_names -lgtop_names -lgtop" LIBGTOP_GUILE_NAMES_INCS="@LIBGTOP_GUILE_NAMES_INCS@" LIBGTOP_BINDIR="@LIBGTOP_BINDIR@" diff -Naurp libgtop-1.0.13/mkdll.sh libgtop-1.0.13-cygwin/mkdll.sh --- libgtop-1.0.13/mkdll.sh 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/mkdll.sh 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,101 @@ +#!/bin/sh + +# script to generate dll from libtool-generated static archive (.la file) +# invoke with: +# mkdll.sh +# eg: +# mkdll.sh libtest.la -L/usr/local/lib -llocal + +# defaults to using gcc for libraries written in C. +# set the CC env var to use a different compiler driver: eg +# export CC=g++ +# for C++ libraries + +# defaults to using /usr/local as the installation PREFIX +# override this by setting the PREFIX env var: eg +# export PREFIX=/opt/gnome + +archive=$1 +test -f $archive || { echo $(basename $0): $archive not found; exit 1; } + +module=$(echo $(basename $archive) | sed -e 's,^lib,,' -e 's,.la$,,') + +test -n "$CC" || CC=gcc +prefix=${PREFIX:=/usr/local} +case "$DLDIR" in + :) dldir= + ;; + "") dldir=../bin/ + ;; + *) dldir=$DLDIR/ + ;; +esac +case "$DLPREFIX" in + :) dlprefix= + ;; + "") dlprefix=cyg + ;; + *) dlprefix=$DLPREFIX + ;; +esac +case "$LIBPREFIX" in + :) libprefix= + ;; + "") libprefix=lib + ;; + *) libprefix=$LIBPREFIX + ;; +esac + +old_lib=${libprefix}${module}.a + +included_libs=.libs/$old_lib +shift +while [ $# -gt 0 -a ! "$1" = "--" ] +do + included_libs="$included_libs $1" + shift +done + +shift +dependency_libs="$@" + + +# update the archive with the dll and import lib name; fix install dir; remove relink command +# (${prefix}/lib is hard-coded here - edit it if necessary) +libdir=${prefix}/lib +if sed -e 's,^dlname='\'\'',dlname='\'${dlprefix}${module}.dll\'',' \ + -e 's,^library_names='\'\'',library_names='\'${libprefix}${module}.dll.a\'',' \ + -e 's,^libdir='\'\'',libdir='\'$libdir\'',' \ + -e 's,^relink_command=.*$,,' \ + .libs/$archive > .libs/${archive}.tmp +then cat .libs/${archive}.tmp > .libs/${archive} +fi +rm -f .libs/${archive}.tmp + +# update the install archive if it exists +if [ -f .libs/${archive}i ] ; then + if sed -e 's,^dlname='\'\'',dlname='\'${dldir}${dlprefix}${module}.dll\'',' \ + -e 's,^library_names='\'\'',library_names='\'${libprefix}${module}.dll.a\'',' \ + -e 's,^relink_command=.*$,,' \ + .libs/${archive}i > .libs/${archive}i.tmp + then cat .libs/${archive}i.tmp > .libs/${archive}i + fi + rm -f .libs/${archive}i.tmp +fi + + +# report the link command to stdout +eval echo $CC -shared -o .libs/${dlprefix}${module}.dll -Wl,--out-implib=.libs/${libprefix}${module}.dll.a \ +-Wl,--export-all-symbols -Wl,--whole-archive $included_libs -Wl,--no-whole-archive ${dependency_libs} + +# do the link command - if it fails, remove archive so make knows to re-build it +eval $CC -shared -o .libs/${dlprefix}${module}.dll -Wl,--out-implib=.libs/${libprefix}${module}.dll.a -Wl,--export-all-symbols \ +-Wl,--whole-archive $included_libs -Wl,--no-whole-archive ${dependency_libs} || { rm -f $archive; false; } +ret=$? + +# copy the .dll.a file to .dll.aT to keep libtool happy +rm -f .libs/${libprefix}${module}.dll.aT +ln .libs/${libprefix}${module}.dll.a .libs/${libprefix}${module}.dll.aT + +exit $ret diff -Naurp libgtop-1.0.13/src/daemon/Makefile.in libgtop-1.0.13-cygwin/src/daemon/Makefile.in --- libgtop-1.0.13/src/daemon/Makefile.in 2001-11-27 02:05:20.000000000 +0000 +++ libgtop-1.0.13-cygwin/src/daemon/Makefile.in 2002-07-28 14:24:24.000000000 +0100 @@ -216,7 +216,7 @@ PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I../.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ -lpopt X_CFLAGS = @X_CFLAGS@ X_LIBS = @X_LIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ diff -Naurp libgtop-1.0.13/src/daemon/gnuserv.c libgtop-1.0.13-cygwin/src/daemon/gnuserv.c --- libgtop-1.0.13/src/daemon/gnuserv.c 2001-11-26 22:37:59.000000000 +0000 +++ libgtop-1.0.13-cygwin/src/daemon/gnuserv.c 2002-07-28 14:24:24.000000000 +0100 @@ -529,6 +529,7 @@ main (int argc, char *argv []) syslog_message (LOG_DEBUG, "Parent ID: (%d, %d) - (%d, %d)", getuid (), geteuid (), getgid (), getegid ()); +#ifndef __CYGWIN__ if (geteuid () == 0) { changed_uid = 1; if (setregid (SERVER_GID, SERVER_GID)) { @@ -545,6 +546,24 @@ main (int argc, char *argv []) exit (1); } } +#else + if (geteuid () == 0) { + changed_uid = 1; + if (setgid (SERVER_GID)) { + syslog_io_message (LOG_ERR, "setgid (SERVER_GID)"); + exit (1); + } + if (setuid (SERVER_UID)) { + syslog_io_message (LOG_ERR, "setuid (SERVER_UID)"); + exit (1); + } + } else { + if (setuid (geteuid ())) { + syslog_io_message (LOG_ERR, "setuid (euid)"); + exit (1); + } + } +#endif if (enable_debug) syslog_message (LOG_DEBUG, "Parent ID: (%d, %d) - (%d, %d)", diff -Naurp libgtop-1.0.13/sysdeps/Makefile.in libgtop-1.0.13-cygwin/sysdeps/Makefile.in --- libgtop-1.0.13/sysdeps/Makefile.in 2001-11-27 02:04:53.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/Makefile.in 2002-07-28 14:25:03.000000000 +0100 @@ -182,7 +182,9 @@ sysdeps_suid_lib = @sysdeps_suid_lib@ @GUILE_TRUE@guile_SUBDIRS = guile @GUILE_FALSE@guile_SUBDIRS = -SUBDIRS = @sysdeps_dir@ common names $(guile_SUBDIRS) +SUBDIRS1 = @sysdeps_dir@ common $(guile_SUBDIRS) +SUBDIRS2 = names +SUBDIRS = $(SUBDIRS1) $(SUBDIRS2) DIST_SUBDIRS = common guile linux kernel names osf1 stub stub_suid sun4 freebsd solaris @@ -215,13 +217,17 @@ Makefile: $(srcdir)/Makefile.in $(top_b @SET_MAKE@ +names: + cd $@ && $(MAKE) $(AM_MAKEFLAGS) all + + all-recursive install-data-recursive install-exec-recursive \ installdirs-recursive install-recursive uninstall-recursive \ check-recursive installcheck-recursive info-recursive dvi-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ + list='$(SUBDIRS1)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ diff -Naurp libgtop-1.0.13/sysdeps/cygwin/Makefile.am libgtop-1.0.13-cygwin/sysdeps/cygwin/Makefile.am --- libgtop-1.0.13/sysdeps/cygwin/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/Makefile.am 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,18 @@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @INCLUDES@ + +lib_LTLIBRARIES = libgtop_sysdeps.la + +libgtop_sysdeps_la_SOURCES = 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 procargs.c procmap.c siglist.c \ + sysinfo.c netload.c ppp.c +libgtop_sysdeps_la_LIBADD = @GLIB_LIBS@ + +libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) + +libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h +libgtopincludedir = $(includedir)/libgtop-1.0 diff -Naurp libgtop-1.0.13/sysdeps/cygwin/Makefile.in libgtop-1.0.13-cygwin/sysdeps/cygwin/Makefile.in --- libgtop-1.0.13/sysdeps/cygwin/Makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/Makefile.in 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,562 @@ +# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +BUILD_GUILE = @BUILD_GUILE@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +DATADIRNAME = @DATADIRNAME@ +DLLTOOL = @DLLTOOL@ +DL_LIB = @DL_LIB@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ +GENCAT = @GENCAT@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_CONFIG = @GLIB_CONFIG@ +GLIB_LIBS = @GLIB_LIBS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GNOMEGNORBA_LIBS = @GNOMEGNORBA_LIBS@ +GNOMEUI_LIBS = @GNOMEUI_LIBS@ +GNOME_APPLETS_LIBS = @GNOME_APPLETS_LIBS@ +GNOME_CAPPLET_LIBS = @GNOME_CAPPLET_LIBS@ +GNOME_CONFIG = @GNOME_CONFIG@ +GNOME_INCLUDEDIR = @GNOME_INCLUDEDIR@ +GNOME_LIBDIR = @GNOME_LIBDIR@ +GNOME_LIBS = @GNOME_LIBS@ +GNORBA_CFLAGS = @GNORBA_CFLAGS@ +GNORBA_LIBS = @GNORBA_LIBS@ +GTKXMHTML_LIBS = @GTKXMHTML_LIBS@ +GT_NO = @GT_NO@ +GT_YES = @GT_YES@ +GUILE_INCS = @GUILE_INCS@ +GUILE_LIBS = @GUILE_LIBS@ +INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ +INSTOBJEXT = @INSTOBJEXT@ +INTLDEPS = @INTLDEPS@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +LIBGTOP_BINARY_AGE = @LIBGTOP_BINARY_AGE@ +LIBGTOP_BINDIR = @LIBGTOP_BINDIR@ +LIBGTOP_CONFIG = @LIBGTOP_CONFIG@ +LIBGTOP_EXTRA_LIBS = @LIBGTOP_EXTRA_LIBS@ +LIBGTOP_GUILE_INCS = @LIBGTOP_GUILE_INCS@ +LIBGTOP_GUILE_LIBS = @LIBGTOP_GUILE_LIBS@ +LIBGTOP_GUILE_NAMES_INCS = @LIBGTOP_GUILE_NAMES_INCS@ +LIBGTOP_GUILE_NAMES_LIBS = @LIBGTOP_GUILE_NAMES_LIBS@ +LIBGTOP_INCLUDEDIR = @LIBGTOP_INCLUDEDIR@ +LIBGTOP_INCS = @LIBGTOP_INCS@ +LIBGTOP_INTERFACE_AGE = @LIBGTOP_INTERFACE_AGE@ +LIBGTOP_LIBDIR = @LIBGTOP_LIBDIR@ +LIBGTOP_LIBS = @LIBGTOP_LIBS@ +LIBGTOP_MAJOR_VERSION = @LIBGTOP_MAJOR_VERSION@ +LIBGTOP_MICRO_VERSION = @LIBGTOP_MICRO_VERSION@ +LIBGTOP_MINOR_VERSION = @LIBGTOP_MINOR_VERSION@ +LIBGTOP_NAMES_INCS = @LIBGTOP_NAMES_INCS@ +LIBGTOP_NAMES_LIBS = @LIBGTOP_NAMES_LIBS@ +LIBGTOP_SERVER = @LIBGTOP_SERVER@ +LIBGTOP_SERVER_VERSION = @LIBGTOP_SERVER_VERSION@ +LIBGTOP_VERSION = @LIBGTOP_VERSION@ +LIBGTOP_VERSION_CODE = @LIBGTOP_VERSION_CODE@ +LIBGTOP_VERSION_SUFFIX = @LIBGTOP_VERSION_SUFFIX@ +LIBOBJS = @LIBOBJS@ +LIBSUPPORT = @LIBSUPPORT@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +LT_VERSION_INFO = @LT_VERSION_INFO@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +NM = @NM@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORBIT_CFLAGS = @ORBIT_CFLAGS@ +ORBIT_CONFIG = @ORBIT_CONFIG@ +ORBIT_IDL = @ORBIT_IDL@ +ORBIT_LIBS = @ORBIT_LIBS@ +PACKAGE = @PACKAGE@ +PERL = @PERL@ +POFILES = @POFILES@ +POSUB = @POSUB@ +QTTHREADS_LIB = @QTTHREADS_LIB@ +RANLIB = @RANLIB@ +READLINE_LIB = @READLINE_LIB@ +STRIP = @STRIP@ +SUPPORTINCS = @SUPPORTINCS@ +TERMCAP_LIB = @TERMCAP_LIB@ +USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +ZVT_LIBS = @ZVT_LIBS@ +ac_dc_found = @ac_dc_found@ +cflags_set = @cflags_set@ +cxxflags_set = @cxxflags_set@ +guile_examples = @guile_examples@ +guile_subdirs = @guile_subdirs@ +l = @l@ +libgtop_guile_found = @libgtop_guile_found@ +libgtop_have_sysinfo = @libgtop_have_sysinfo@ +libgtop_need_server = @libgtop_need_server@ +libgtop_postinstall = @libgtop_postinstall@ +libgtop_sysdeps_dir = @libgtop_sysdeps_dir@ +libgtop_top_builddir = @libgtop_top_builddir@ +libgtop_use_machine_h = @libgtop_use_machine_h@ +libs_xauth = @libs_xauth@ +machine_incs = @machine_incs@ +need_gnome_support = @need_gnome_support@ +server_programs = @server_programs@ +smp_examples = @smp_examples@ +static_targets = @static_targets@ +sysdeps_dir = @sysdeps_dir@ +sysdeps_suid_lib = @sysdeps_suid_lib@ + +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ + +INCLUDES = @INCLUDES@ + +lib_LTLIBRARIES = libgtop_sysdeps.la + +libgtop_sysdeps_la_SOURCES = 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 procargs.c procmap.c siglist.c sysinfo.c netload.c ppp.c +libgtop_sysdeps_la_LIBADD = @GLIB_LIBS@ + +libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) + +libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h +libgtopincludedir = $(includedir)/libgtop-1.0 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +libgtop_sysdeps_la_DEPENDENCIES = +libgtop_sysdeps_la_OBJECTS = open.lo close.lo cpu.lo mem.lo swap.lo \ +uptime.lo loadavg.lo shm_limits.lo msg_limits.lo sem_limits.lo \ +proclist.lo procstate.lo procuid.lo proctime.lo procmem.lo \ +procsignal.lo prockernel.lo procsegment.lo procargs.lo procmap.lo \ +siglist.lo sysinfo.lo netload.lo ppp.lo +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +HEADERS = $(libgtopinclude_HEADERS) + +DIST_COMMON = ChangeLog Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +SOURCES = $(libgtop_sysdeps_la_SOURCES) +OBJECTS = $(libgtop_sysdeps_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps sysdeps/cygwin/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +.c.o: + $(COMPILE) -c $< + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libgtop_sysdeps.la: $(libgtop_sysdeps_la_OBJECTS) $(libgtop_sysdeps_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libgtop_sysdeps_la_LDFLAGS) $(libgtop_sysdeps_la_OBJECTS) $(libgtop_sysdeps_la_LIBADD) $(LIBS) + +install-libgtopincludeHEADERS: $(libgtopinclude_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libgtopincludedir) + @list='$(libgtopinclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libgtopincludedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libgtopincludedir)/$$p; \ + done + +uninstall-libgtopincludeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(libgtopinclude_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libgtopincludedir)/$$p; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = sysdeps/cygwin + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +close.lo close.o : close.c ../../include/glibtop/close.h ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h +cpu.lo cpu.o : cpu.c ../../config.h ../../include/glibtop/error.h \ + ../../glibtop.h ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/cpu.h +loadavg.lo loadavg.o : loadavg.c ../../config.h \ + ../../include/glibtop/error.h ../../glibtop.h \ + ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/loadavg.h +mem.lo mem.o : mem.c ../../config.h ../../include/glibtop/error.h \ + ../../glibtop.h ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/mem.h +msg_limits.lo msg_limits.o : msg_limits.c \ + ../../include/glibtop/msg_limits.h ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h +netload.lo netload.o : netload.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/netload.h +open.lo open.o : open.c ../../glibtop.h ../../include/glibtop/global.h \ + ../../config.h glibtop_server.h ../../include/glibtop/types.h \ + ../../include/glibtop/sysdeps.h ../../include/glibtop/cpu.h \ + ../../include/glibtop/open.h ../../include/glibtop/read.h \ + ../../include/glibtop/error.h +ppp.lo ppp.o : ppp.c ../../glibtop.h ../../include/glibtop/global.h \ + ../../config.h glibtop_server.h ../../include/glibtop/types.h \ + ../../include/glibtop/sysdeps.h ../../include/glibtop/error.h \ + ../../include/glibtop/xmalloc.h ../../include/glibtop/ppp.h +procargs.lo procargs.o : procargs.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/xmalloc.h \ + ../../include/glibtop/procargs.h +prockernel.lo prockernel.o : prockernel.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h \ + ../../include/glibtop/prockernel.h +proclist.lo proclist.o : proclist.c ../../config.h \ + ../../include/glibtop/xmalloc.h ../../glibtop.h \ + ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/proclist.h \ + ../../include/glibtop/procuid.h \ + ../../include/glibtop/procstate.h +procmap.lo procmap.o : procmap.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/xmalloc.h \ + ../../include/glibtop/procmap.h +procmem.lo procmem.o : procmem.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/procmem.h +procsegment.lo procsegment.o : procsegment.c ../../config.h \ + ../../include/glibtop/error.h ../../glibtop.h \ + ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/procsegment.h +procsignal.lo procsignal.o : procsignal.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h \ + ../../include/glibtop/procsignal.h +procstate.lo procstate.o : procstate.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/procstate.h +proctime.lo proctime.o : proctime.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/proctime.h \ + ../../include/glibtop/cpu.h +procuid.lo procuid.o : procuid.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/error.h ../../include/glibtop/procuid.h +sem_limits.lo sem_limits.o : sem_limits.c \ + ../../include/glibtop/sem_limits.h ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h +shm_limits.lo shm_limits.o : shm_limits.c \ + ../../include/glibtop/shm_limits.h ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h +siglist.lo siglist.o : siglist.c ../../glibtop.h \ + ../../include/glibtop/global.h ../../config.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/signal.h +swap.lo swap.o : swap.c ../../config.h ../../include/glibtop/error.h \ + ../../glibtop.h ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/swap.h +sysinfo.lo sysinfo.o : sysinfo.c ../../config.h \ + ../../include/glibtop/cpu.h ../../glibtop.h \ + ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/sysinfo.h +uptime.lo uptime.o : uptime.c ../../config.h \ + ../../include/glibtop/error.h ../../glibtop.h \ + ../../include/glibtop/global.h glibtop_server.h \ + ../../include/glibtop/types.h ../../include/glibtop/sysdeps.h \ + ../../include/glibtop/uptime.h + +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-libLTLIBRARIES +install-exec: install-exec-am + +install-data-am: install-libgtopincludeHEADERS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libLTLIBRARIES uninstall-libgtopincludeHEADERS +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(libgtopincludedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-libLTLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-generic \ + clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool uninstall-libgtopincludeHEADERS \ +install-libgtopincludeHEADERS tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -Naurp libgtop-1.0.13/sysdeps/cygwin/close.c libgtop-1.0.13-cygwin/sysdeps/cygwin/close.c --- libgtop-1.0.13/sysdeps/cygwin/close.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/close.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,30 @@ +/* $Id: close.c,v 1.7 1999/02/23 11:44:52 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_s (glibtop *server) +{ } diff -Naurp libgtop-1.0.13/sysdeps/cygwin/cpu.c libgtop-1.0.13-cygwin/sysdeps/cygwin/cpu.c --- libgtop-1.0.13/sysdeps/cygwin/cpu.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/cpu.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,111 @@ +/* $Id: cpu.c,v 1.20.2.2 1999/09/16 21:05:33 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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 = +(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) + +(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) + +(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY); + +static const unsigned long _glibtop_sysdeps_cpu_smp = +(1L << GLIBTOP_XCPU_TOTAL) + (1L << GLIBTOP_XCPU_USER) + +(1L << GLIBTOP_XCPU_NICE) + (1L << GLIBTOP_XCPU_SYS) + +(1L << GLIBTOP_XCPU_IDLE); + +/* Init function. */ + +void +glibtop_init_cpu_s (glibtop *server) +{ + server->sysdeps.cpu = _glibtop_sysdeps_cpu; + + if (server->ncpu) + server->sysdeps.cpu |= _glibtop_sysdeps_cpu_smp; +} + +/* Provides information about cpu usage. */ + +#define FILENAME "/proc/stat" + +void +glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) +{ + char buffer [BUFSIZ], *p; + int fd, len, i; + u_int64_t total; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); + + memset (buf, 0, sizeof (glibtop_cpu)); + + fd = open (FILENAME, O_RDONLY); + if (fd < 0) + glibtop_error_io_r (server, "open (%s)", FILENAME); + + len = read (fd, buffer, BUFSIZ-1); + if (len < 0) + glibtop_error_io_r (server, "read (%s)", FILENAME); + + close (fd); + + buffer [len] = '\0'; + + p = skip_token (buffer); /* "cpu" */ + + buf->user = strtoul (p, &p, 0); + buf->nice = strtoul (p, &p, 0); + buf->sys = strtoul (p, &p, 0); + buf->idle = strtoul (p, &p, 0); + + total = buf->user; + total += buf->nice; + total += buf->sys; + total += buf->idle; + buf->total = total; + + buf->frequency = 100; + buf->flags = _glibtop_sysdeps_cpu; + + for (i = 0; i < server->ncpu; i++) { + if (strncmp (p+1, "cpu", 3) || !isdigit (p [4])) + break; + + p += 6; + buf->xcpu_user [i] = strtoul (p, &p, 0); + buf->xcpu_nice [i] = strtoul (p, &p, 0); + buf->xcpu_sys [i] = strtoul (p, &p, 0); + buf->xcpu_idle [i] = strtoul (p, &p, 0); + + total = buf->xcpu_user [i]; + total += buf->xcpu_nice [i]; + total += buf->xcpu_sys [i]; + total += buf->xcpu_idle [i]; + + buf->xcpu_total [i] = total; + } + + buf->flags |= _glibtop_sysdeps_cpu_smp; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/glibtop_machine.h libgtop-1.0.13-cygwin/sysdeps/cygwin/glibtop_machine.h --- libgtop-1.0.13/sysdeps/cygwin/glibtop_machine.h 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/glibtop_machine.h 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,58 @@ +/* $Id: glibtop_machine.h,v 1.5 1999/02/23 11:44:54 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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 +#include + +BEGIN_LIBGTOP_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 +{ + 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_LIBGTOP_DECLS + +#endif diff -Naurp libgtop-1.0.13/sysdeps/cygwin/glibtop_server.h libgtop-1.0.13-cygwin/sysdeps/cygwin/glibtop_server.h --- libgtop-1.0.13/sysdeps/cygwin/glibtop_server.h 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/glibtop_server.h 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,135 @@ +/* $Id: glibtop_server.h,v 1.9.2.1 2000/02/14 14:34:33 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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__ + +#include +#include + +BEGIN_LIBGTOP_DECLS + +#ifdef _IN_LIBGTOP + +static inline char * +skip_token (const char *p) +{ + while (isspace(*p)) p++; + while (*p && !isspace(*p)) p++; + return (char *)p; +} + +static inline char * +skip_multiple_token (const char *p, int count) +{ + int i; + + for (i = 0; i < count; i++) + p = skip_token (p); + + return (char *)p; +} + +static inline char * +skip_line (const char *p) +{ + while (*p != '\n') p++; + return (char *) ++p; +} + +static inline int +proc_file_to_buffer (char *buffer, const char *fmt, pid_t pid) +{ + char filename [BUFSIZ]; + int fd, len; + + sprintf (filename, fmt, pid); + + fd = open (filename, O_RDONLY); + if (fd < 0) return -1; + + len = read (fd, buffer, BUFSIZ-1); + close (fd); + + if (len < 0) + return -1; + + buffer [len] = '\0'; + + return 0; +} + +static inline int +proc_stat_to_buffer (char *buffer, pid_t pid) +{ + return proc_file_to_buffer (buffer, "/proc/%d/stat", pid); +} + +static inline int +proc_status_to_buffer (char *buffer, pid_t pid) +{ + return proc_file_to_buffer (buffer, "/proc/%d/status", pid); +} + +static inline int +proc_statm_to_buffer (char *buffer, pid_t pid) +{ + return proc_file_to_buffer (buffer, "/proc/%d/statm", pid); +} + +static inline char * +proc_stat_after_cmd (char *p) +{ + p = strrchr (p, ')'); + if (!p) return p; + + *p++ = '\0'; + return p; +} + +#endif + +#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 +#define GLIBTOP_SUID_PROC_ARGS 0 +#define GLIBTOP_SUID_PROC_MAP 0 +#define GLIBTOP_SUID_NETLOAD 0 +#define GLIBTOP_SUID_PPP 0 + +END_LIBGTOP_DECLS + +#endif diff -Naurp libgtop-1.0.13/sysdeps/cygwin/loadavg.c libgtop-1.0.13-cygwin/sysdeps/cygwin/loadavg.c --- libgtop-1.0.13/sysdeps/cygwin/loadavg.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/loadavg.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,94 @@ +/* $Id: loadavg.c,v 1.13.2.1 1999/05/27 19:24:13 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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 = +(1L << GLIBTOP_LOADAVG_LOADAVG); + +static const unsigned long _glibtop_sysdeps_loadavg_tasks = +(1L << GLIBTOP_LOADAVG_NR_RUNNING) + +(1L << GLIBTOP_LOADAVG_NR_TASKS) + +(1L << GLIBTOP_LOADAVG_LAST_PID); + +/* Init function. */ + +void +glibtop_init_loadavg_s (glibtop *server) +{ + server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; +} + +/* Provides load load averange. */ + +#define FILENAME "/proc/loadavg" + +void +glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) +{ + char buffer [BUFSIZ], *p, *old; + int fd, len; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); + + memset (buf, 0, sizeof (glibtop_loadavg)); + + fd = open (FILENAME, O_RDONLY); + if (fd < 0) + glibtop_error_io_r (server, "open (%s)", FILENAME); + + len = read (fd, buffer, BUFSIZ-1); + if (len < 0) + glibtop_error_io_r (server, "read (%s)", FILENAME); + + close (fd); + + buffer [len] = '\0'; + + buf->loadavg [0] = (float) strtod (buffer, &p); + buf->loadavg [1] = (float) strtod (p, &p); + buf->loadavg [2] = (float) strtod (p, &p); + + buf->flags = _glibtop_sysdeps_loadavg; + + while (isspace(*p)) p++; + + /* Older Linux versions don't have the nr_running/nr_tasks fields. */ + + old = p; + while (*p) { + if (*p == '/') + break; + if (!isdigit (*p)) + return; + p++; + } + + buf->nr_running = strtoul (old, &p, 0); p++; + buf->nr_tasks = strtoul (p, &p, 0); + buf->last_pid = strtoul (p, &p, 0); + + buf->flags |= _glibtop_sysdeps_loadavg_tasks; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/mem.c libgtop-1.0.13-cygwin/sysdeps/cygwin/mem.c --- libgtop-1.0.13/sysdeps/cygwin/mem.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/mem.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,81 @@ +/* $Id: mem.c,v 1.15.2.1 1999/05/27 19:24:14 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_mem = +(1L << GLIBTOP_MEM_TOTAL) + (1L << GLIBTOP_MEM_USED) + +(1L << GLIBTOP_MEM_FREE) + (1L << GLIBTOP_MEM_SHARED) + +(1L << GLIBTOP_MEM_BUFFER) + (1L << GLIBTOP_MEM_CACHED) + +(1L << GLIBTOP_MEM_USER); + +/* Init function. */ + +void +glibtop_init_mem_s (glibtop *server) +{ + server->sysdeps.mem = _glibtop_sysdeps_mem; +} + +/* Provides information about memory usage. */ + +#define FILENAME "/proc/meminfo" + +void +glibtop_get_mem_s (glibtop *server, glibtop_mem *buf) +{ + char buffer [BUFSIZ], *p; + int fd, len; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0); + + memset (buf, 0, sizeof (glibtop_mem)); + + fd = open (FILENAME, O_RDONLY); + if (fd < 0) + glibtop_error_io_r (server, "open (%s)", FILENAME); + + len = read (fd, buffer, BUFSIZ-1); + if (len < 0) + glibtop_error_io_r (server, "read (%s)", FILENAME); + + close (fd); + + buffer [len] = '\0'; + + p = skip_line (buffer); + p = skip_token (p); /* "Mem:" */ + + buf->total = strtoul (p, &p, 0); + buf->used = strtoul (p, &p, 0); + buf->free = strtoul (p, &p, 0); + buf->shared = strtoul (p, &p, 0); + buf->buffer = strtoul (p, &p, 0); + buf->cached = strtoul (p, &p, 0); + + buf->user = buf->total - buf->free - buf->shared - buf->buffer; + + buf->flags = _glibtop_sysdeps_mem; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/msg_limits.c libgtop-1.0.13-cygwin/sysdeps/cygwin/msg_limits.c --- libgtop-1.0.13/sysdeps/cygwin/msg_limits.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/msg_limits.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,106 @@ +/* $Id: msg_limits.c,v 1.8.2.1 1999/05/27 19:24:15 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#ifdef HAVE_SYSV_IPC + +#include +#include + +static const unsigned long _glibtop_sysdeps_msg_limits = +(1L << GLIBTOP_IPC_MSGPOOL) + (1L << GLIBTOP_IPC_MSGMAP) + +(1L << GLIBTOP_IPC_MSGMAX) + (1L << GLIBTOP_IPC_MSGMNB) + +(1L << GLIBTOP_IPC_MSGMNI) + (1L << GLIBTOP_IPC_MSGSSZ) + +(1L << GLIBTOP_IPC_MSGTQL); + +/* Init function. */ + +void +glibtop_init_msg_limits_s (glibtop *server) +{ + server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; +} + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) +{ + struct msginfo msginfo; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 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; +} + +#else + +static const unsigned long _glibtop_sysdeps_msg_limits = +(1L << GLIBTOP_IPC_MSGPOOL) + (1L << GLIBTOP_IPC_MSGMAP) + +(1L << GLIBTOP_IPC_MSGMAX) + (1L << GLIBTOP_IPC_MSGMNB) + +(1L << GLIBTOP_IPC_MSGMNI) + (1L << GLIBTOP_IPC_MSGSSZ) + +(1L << GLIBTOP_IPC_MSGTQL); + +/* Init function. */ + +void +glibtop_init_msg_limits_s (glibtop *server) +{ + server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; +} + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf) +{ + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); + + memset (buf, 0, sizeof (glibtop_msg_limits)); + + buf->flags = _glibtop_sysdeps_msg_limits; + + buf->msgpool = 0; + buf->msgmap = 0; + buf->msgmax = 0; + buf->msgmnb = 0; + buf->msgmni = 0; + buf->msgssz = 0; + buf->msgtql = 0; +} + +#endif diff -Naurp libgtop-1.0.13/sysdeps/cygwin/netload.c libgtop-1.0.13-cygwin/sysdeps/cygwin/netload.c --- libgtop-1.0.13/sysdeps/cygwin/netload.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/netload.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,366 @@ +/* $Id: netload.c,v 1.13.2.3 2000/02/14 14:34:33 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , October 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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 (__CYGWIN__) +#include +#include +#include +#elif !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 +/* GNU LibC */ +#include +#include +#include +#include +#include +#include +#include +#else /* Libc 5 */ +#include +#include +#include +#include +#include +#include +#endif + +#define _GLIBTOP_IP_FW_ACCTIN 0x1000 /* Account incoming packets only. */ +#define _GLIBTOP_IP_FW_ACCTOUT 0x2000 /* Account outgoing packets only. */ + +static const unsigned long _glibtop_sysdeps_netload = +(1L << GLIBTOP_NETLOAD_ERRORS_IN) + +(1L << GLIBTOP_NETLOAD_ERRORS_OUT) + +(1L << GLIBTOP_NETLOAD_COLLISIONS); + +static const unsigned long _glibtop_sysdeps_netload_data = +(1L << GLIBTOP_NETLOAD_ADDRESS) + +(1L << GLIBTOP_NETLOAD_SUBNET) + +(1L << GLIBTOP_NETLOAD_MTU); + +static const unsigned long _glibtop_sysdeps_netload_bytes = +(1L << GLIBTOP_NETLOAD_BYTES_IN) + +(1L << GLIBTOP_NETLOAD_BYTES_OUT) + +(1L << GLIBTOP_NETLOAD_BYTES_TOTAL); + +static const unsigned long _glibtop_sysdeps_netload_packets = +(1L << GLIBTOP_NETLOAD_PACKETS_IN) + +(1L << GLIBTOP_NETLOAD_PACKETS_OUT) + +(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL); + +static const unsigned long _glibtop_sysdeps_netload_total = +(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + +(1L << GLIBTOP_NETLOAD_BYTES_TOTAL); + +static const unsigned long _glibtop_sysdeps_netload_in = +(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + +(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) + +(1L << GLIBTOP_NETLOAD_PACKETS_IN) + +(1L << GLIBTOP_NETLOAD_BYTES_IN); + +static const unsigned long _glibtop_sysdeps_netload_out = +(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) + +(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) + +(1L << GLIBTOP_NETLOAD_PACKETS_OUT) + +(1L << GLIBTOP_NETLOAD_BYTES_OUT); + +/* Init function. */ + +void +glibtop_init_netload_s (glibtop *server) +{ + server->sysdeps.netload = _glibtop_sysdeps_netload | + _glibtop_sysdeps_netload_data | + _glibtop_sysdeps_netload_bytes | + _glibtop_sysdeps_netload_packets; +} + +/* Provides network statistics. */ + +void +glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, + const char *interface) +{ + char buffer [BUFSIZ], *p; + int have_bytes, fields, skfd; + FILE *f; + + memset (buf, 0, sizeof (glibtop_netload)); + + skfd = socket (AF_INET, SOCK_DGRAM, 0); + if (skfd) { + struct ifreq ifr; + unsigned flags; + + strcpy (ifr.ifr_name, interface); + if (!ioctl (skfd, SIOCGIFFLAGS, &ifr)) { + buf->flags |= (1L << GLIBTOP_NETLOAD_IF_FLAGS); + flags = ifr.ifr_flags; + } else + flags = 0; + + if (flags & IFF_UP) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP); + + if (flags & IFF_BROADCAST) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST); + +#ifndef __CYGWIN__ + if (flags & IFF_DEBUG) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG); +#endif + + if (flags & IFF_LOOPBACK) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK); + +#ifndef __CYGWIN__ + if (flags & IFF_POINTOPOINT) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT); +#endif + + if (flags & IFF_RUNNING) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING); + +#ifndef __CYGWIN__ + if (flags & IFF_NOARP) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP); +#endif + + if (flags & IFF_PROMISC) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC); + +#ifndef __CYGWIN__ + if (flags & IFF_ALLMULTI) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI); +#endif + + if (flags & IFF_MULTICAST) + buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST); + + strcpy (ifr.ifr_name, interface); + if (!ioctl (skfd, SIOCGIFADDR, &ifr)) { + struct sockaddr_in addr = + *(struct sockaddr_in *) &ifr.ifr_addr; + buf->address = addr.sin_addr.s_addr; + buf->flags |= (1L << GLIBTOP_NETLOAD_ADDRESS); + } + + strcpy (ifr.ifr_name, interface); + if (!ioctl (skfd, SIOCGIFNETMASK, &ifr)) { + struct sockaddr_in addr = + *(struct sockaddr_in *) &ifr.ifr_addr; + buf->subnet = addr.sin_addr.s_addr; + buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET); + } + + strcpy (ifr.ifr_name, interface); + if (!ioctl (skfd, SIOCGIFMTU, &ifr)) { + buf->mtu = ifr.ifr_mtu; + buf->flags |= (1L << GLIBTOP_NETLOAD_MTU); + } + + close (skfd); + } + + /* Linux 2.1.114 - don't know where exactly this was added, but + * recent kernels have byte count in /proc/net/dev so we don't + * need IP accounting. + */ + + if (server->os_version_code < 131442) { + + /* If IP accounting is enabled in the kernel and it is + * enabled for the requested interface, we use it to + * get the data. In this case, we don't use /proc/net/dev + * to get errors and collisions. + */ + + f = fopen ("/proc/net/ip_acct", "r"); + if (f) { + int success = 0; + + /* Skip over the header line. */ + fgets (buffer, BUFSIZ-1, f); + + while (fgets (buffer, BUFSIZ-1, f)) { + unsigned long flags, packets, bytes; + char *p, *dev; + + /* Skip over the network thing. */ + dev = skip_token (buffer) + 1; + p = skip_token (dev); + *p++ = 0; + + if (strcmp (dev, interface)) + continue; + + success = 1; + + p = skip_token (p); + + flags = strtoul (p, &p, 16); + + p = skip_multiple_token (p, 2); + + packets = strtoul (p, &p, 0); + bytes = strtoul (p, &p, 0); + + if (flags & _GLIBTOP_IP_FW_ACCTIN) { + /* Incoming packets only. */ + + buf->packets_total += packets; + buf->packets_in += packets; + + buf->bytes_total += bytes; + buf->bytes_in += bytes; + + buf->flags |= _glibtop_sysdeps_netload_in; + + } else if (flags & _GLIBTOP_IP_FW_ACCTOUT) { + /* Outgoing packets only. */ + + buf->packets_total += packets; + buf->packets_out += packets; + + buf->bytes_total += bytes; + buf->bytes_out += bytes; + + buf->flags |= _glibtop_sysdeps_netload_out; + + } else { + /* Only have total values. */ + + buf->packets_total += packets; + buf->bytes_total += bytes; + + buf->flags |= _glibtop_sysdeps_netload_total; + } + } + + fclose (f); + + if (success) return; + } + } + + /* Ok, either IP accounting is not enabled in the kernel or + * it was not enabled for the requested interface. */ + + f = fopen ("/proc/net/dev", "r"); + if (!f) return; + + /* Skip over the header line. */ + fgets (buffer, BUFSIZ-1, f); + fgets (buffer, BUFSIZ-1, f); + + /* Starting with 2.1.xx (don't know exactly which version) + * /proc/net/dev contains both byte and package counters. */ + + p = strchr (buffer, '|'); + if (!p) { + fclose (f); + return; + } + + /* Do we already have byte counters ? */ + have_bytes = strncmp (++p, "bytes", 5) == 0; + + /* Count remaining 'Receive' fields so we know where + * the first 'Transmit' field starts. */ + + fields = 0; + while (*p != '|') { + if (!isspace (*p++)) continue; + while (isspace (*p++)) ; + fields++; + } + + /* Should never happen. */ + if (fields < 2) { + fclose (f); + return; + } + fields--; + + while (fgets (buffer, BUFSIZ-1, f)) { + char *p, *dev; + + dev = buffer; + while (isspace (*dev)) dev++; + + p = strchr (dev, ':'); + if (!p) continue; + *p++ = 0; + + /* If it's not a digit, then it's most likely an error + * message like 'No statistics available'. */ + while (isspace (*p)) p++; + if (!isdigit (*p)) continue; + + if (strcmp (dev, interface)) + continue; + + /* Only read byte counts if we really have them. */ + + if (have_bytes) { + buf->bytes_in = strtoul (p, &p, 0); + fields--; + } + + buf->packets_in = strtoul (p, &p, 0); + buf->errors_in = strtoul (p, &p, 0); + + p = skip_multiple_token (p, fields); + + if (have_bytes) + buf->bytes_out = strtoul (p, &p, 0); + + buf->packets_out = strtoul (p, &p, 0); + buf->errors_out = strtoul (p, &p, 0); + + p = skip_multiple_token (p, 2); + + buf->collisions = strtoul (p, &p, 0); + + /* Compute total valules. */ + + buf->bytes_total = buf->bytes_in + buf->bytes_out; + buf->packets_total = buf->packets_in + buf->packets_out; + + /* And now the flags. */ + + buf->flags |= _glibtop_sysdeps_netload; + buf->flags |= _glibtop_sysdeps_netload_packets; + + if (have_bytes) + buf->flags |= _glibtop_sysdeps_netload_bytes; + } + + fclose (f); +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/open.c libgtop-1.0.13-cygwin/sysdeps/cygwin/open.c --- libgtop-1.0.13/sysdeps/cygwin/open.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/open.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,109 @@ +/* $Id: open.c,v 1.13.2.1 2001/02/13 12:31:57 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include +#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. */ + +#define FILENAME "/proc/stat" + +void +glibtop_open_s (glibtop *server, const char *program_name, + const unsigned long features, + const unsigned flags) +{ + char buffer [BUFSIZ], *p; + struct stat statb; + int fd, len, i; + + server->name = program_name; + + set_linux_version (); + server->os_version_code = (unsigned long) linux_version_code; + + server->ncpu = 0; + + /* On Linux 2.4.x, /proc/stat has "cpu" and "cpu0" entries even + * for non-SMP systems. Checking whether /proc//cpu exists + * is a much better way to detect SMP. */ + + if (stat ("/proc/1/cpu", &statb)) + return; + + fd = open (FILENAME, O_RDONLY); + if (fd < 0) + glibtop_error_io_r (server, "open (%s)", FILENAME); + + len = read (fd, buffer, BUFSIZ-1); + if (len < 0) + glibtop_error_io_r (server, "read (%s)", FILENAME); + + close (fd); + + buffer [len] = '\0'; + + p = skip_multiple_token (buffer, 5) + 1; + + for (i = 0; i < GLIBTOP_NCPU; i++) { + + if (strncmp (p, "cpu", 3) || !isdigit (p [3])) + break; + + server->ncpu++; + + p = skip_multiple_token (p, 5) + 1; + } + +#if DEBUG + printf ("\nThis machine has %d CPUs.\n\n", server->ncpu); +#endif +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/ppp.c libgtop-1.0.13-cygwin/sysdeps/cygwin/ppp.c --- libgtop-1.0.13/sysdeps/cygwin/ppp.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/ppp.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,230 @@ +/* $Id: ppp.c,v 1.4.2.2 1999/09/16 21:05:33 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , October 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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 + +#include + +#ifdef HAVE_PPP +#include + +static const unsigned long _glibtop_sysdeps_ppp = +(1L << GLIBTOP_PPP_STATE) + (1L << GLIBTOP_PPP_BYTES_IN) + +(1L << GLIBTOP_PPP_BYTES_OUT); + +/* Init function. */ + +void +glibtop_init_ppp_s (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +static int +get_ISDN_stats (glibtop *server, int *in, int *out) +{ + unsigned long *isdn_stats, *ptr; + int fd, i; + + *in = *out = 0; + + isdn_stats = glibtop_calloc_r (server, ISDN_MAX_CHANNELS * 2, + sizeof (unsigned long)); + + fd = open ("/dev/isdninfo", O_RDONLY); + if (fd < 0) { + glibtop_free_r (server, isdn_stats); + return FALSE; + } + + if ((ioctl (fd, IIOCGETCPS, isdn_stats) < 0) && (errno != 0)) { + glibtop_free_r (server, isdn_stats); + close (fd); + + return FALSE; + } + + for (i = 0, ptr = isdn_stats; i < ISDN_MAX_CHANNELS; i++) { + *in += *ptr++; *out += *ptr++; + } + + glibtop_free_r (server, isdn_stats); + close (fd); + + return TRUE; +} + +static int is_ISDN_on (glibtop *server, int *online) +{ + FILE *f = 0; + char buffer [BUFSIZ], *p; + int i; + + /* Perhaps I should try to explain this code a little bit. + * + * ------------------------------------------------------------ + * This is from the manpage of isdninfo(4): + * + * DESCRIPTION + * /dev/isdninfo is a character device with major number 45 + * and minor number 255. It delivers status information from + * the Linux ISDN subsystem to user level. + * + * DATA FORMAT + * When reading from this device, the current status of the + * Linux ISDN subsystem is delivered in 6 lines of text. Each + * line starts with a tag string followed by a colon and + * whitespace. After that the status values are appended sep- + * arated by whitespace. + * + * flags is the tag of line 5. In this line for every driver + * slot, it's B-Channel status is shown. If no driver + * is registered in a slot, a ? is shown. For every + * established B-Channel of the driver, a bit is set + * in the shown value. The driver's first channel is + * mapped to bit 0, the second channel to bit 1 and so + * on. + * ------------------------------------------------------------ + * + * So we open /dev/isdninfo, discard the first four lines of text + * and then check whether we have something that is not `0' or `?' + * in one of the flags fields. + * + * Sounds complicated, but I don't see any other way to check whether + * we are connected. Also, this is the method some other ISDN tools + * for Linux use. + * + * Martin + */ + + f = fopen ("/dev/isdninfo", "r"); + + if (!f) return FALSE; + + for (i = 0; i < 5; i++) { + if (fgets (buffer, BUFSIZ, f) == NULL) { + fclose (f); + return FALSE; + } + } + + if (strncmp (buffer, "flags:", 6)) { + fclose (f); + return FALSE; + } + + p = buffer+6; + + while (*p) { + char *end = p; + + if (isspace (*p)) { + p++; + continue; + } + + for (end = p; *end && !isspace (*end); end++) + ; + + if (*end == 0) + break; + else + *end = 0; + + if (!strcmp (p, "?") || !strcmp (p, "0")) { + p = end+1; + continue; + } + + fclose (f); + + *online = TRUE; + return TRUE; + } + + fclose (f); + + *online = FALSE; + return TRUE; +} + +/* Provides PPP/ISDN information. */ + +void +glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + int in, out, online; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0); + + memset (buf, 0, sizeof (glibtop_ppp)); + + if (is_ISDN_on (server, &online)) { + buf->state = online ? GLIBTOP_PPP_STATE_ONLINE : + GLIBTOP_PPP_STATE_HANGUP; + buf->flags |= (1L << GLIBTOP_PPP_STATE); + } + + if (get_ISDN_stats (server, &in, &out)) { + buf->bytes_in = in; + buf->bytes_out = out; + buf->flags |= (1L << GLIBTOP_PPP_BYTES_IN) | + (1L << GLIBTOP_PPP_BYTES_OUT); + } +} + +#else + +static const unsigned long _glibtop_sysdeps_ppp = +(1L << GLIBTOP_PPP_STATE) + (1L << GLIBTOP_PPP_BYTES_IN) + +(1L << GLIBTOP_PPP_BYTES_OUT); + +/* Init function. */ + +void +glibtop_init_ppp_s (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +void +glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + int in, out, online; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PPP, 0); + + memset (buf, 0, sizeof (glibtop_ppp)); + +} + +#endif diff -Naurp libgtop-1.0.13/sysdeps/cygwin/procargs.c libgtop-1.0.13-cygwin/sysdeps/cygwin/procargs.c --- libgtop-1.0.13/sysdeps/cygwin/procargs.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/procargs.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,101 @@ +/* $Id: procargs.c,v 1.3.2.3 2000/02/14 14:34:33 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_proc_args = +(1L << GLIBTOP_PROC_ARGS_SIZE); + +/* Init function. */ + +void +glibtop_init_proc_args_s (glibtop *server) +{ + server->sysdeps.proc_args = _glibtop_sysdeps_proc_args; +} + +/* Provides detailed information about a process. */ + +char * +glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf, + pid_t pid, unsigned max_len) +{ + char fn [BUFSIZ], buffer [BUFSIZ]; + int cmdline, len, total = 0; + char *retval = NULL; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_ARGS, 0); + + memset (buf, 0, sizeof (glibtop_proc_args)); + + sprintf (fn, "/proc/%d/cmdline", pid); + + cmdline = open (fn, O_RDONLY); + if (cmdline < 0) return NULL; + + if (max_len) { + retval = glibtop_malloc_r (server, max_len+1); + + len = read (cmdline, retval, max_len); + close (cmdline); + + if (len < 0) { + glibtop_free_r (server, retval); + return NULL; + } + + *(retval+len) = 0; + + buf->size = len; + buf->flags = _glibtop_sysdeps_proc_args; + + return retval; + } + + while (1) { + len = read (cmdline, buffer, BUFSIZ-1); + if (len < 0) { + close (cmdline); + glibtop_free_r (server, retval); + return NULL; + } + + if (len == 0) + break; + + retval = glibtop_realloc_r (server, retval, total+len+1); + memcpy (retval+total, buffer, len); + *(retval+total+len) = 0; + total += len; + } + + close (cmdline); + + buf->size = total; + buf->flags = _glibtop_sysdeps_proc_args; + + return retval; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/prockernel.c libgtop-1.0.13-cygwin/sysdeps/cygwin/prockernel.c --- libgtop-1.0.13/sysdeps/cygwin/prockernel.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/prockernel.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,77 @@ +/* $Id: prockernel.c,v 1.13.2.1 1999/05/27 19:24:19 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_kernel = +(1L << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1L << GLIBTOP_PROC_KERNEL_MIN_FLT) + +(1L << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1L << GLIBTOP_PROC_KERNEL_CMIN_FLT) + +(1L << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1L << GLIBTOP_PROC_KERNEL_KSTK_ESP) + +(1L << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1L << GLIBTOP_PROC_KERNEL_WCHAN); + +/* Init function. */ + +void +glibtop_init_proc_kernel_s (glibtop *server) +{ + server->sysdeps.proc_kernel = _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) +{ + char buffer [BUFSIZ], *p; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0); + + memset (buf, 0, sizeof (glibtop_proc_kernel)); + + if (proc_stat_to_buffer (buffer, pid)) + return; + + p = proc_stat_after_cmd (buffer); + if (!p) return; + + p = skip_multiple_token (p, 6); + + buf->k_flags = strtoul (p, &p, 0); + buf->min_flt = strtoul (p, &p, 0); + buf->cmin_flt = strtoul (p, &p, 0); + buf->maj_flt = strtoul (p, &p, 0); + buf->cmaj_flt = strtoul (p, &p, 0); + + p = skip_multiple_token (p, 15); + + buf->kstk_esp = strtoul (p, &p, 0); + buf->kstk_eip = strtoul (p, &p, 0); + + p = skip_multiple_token (p, 4); + + buf->nwchan = strtoul (p, &p, 0); + + buf->flags = _glibtop_sysdeps_proc_kernel; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/proclist.c libgtop-1.0.13-cygwin/sysdeps/cygwin/proclist.c --- libgtop-1.0.13/sysdeps/cygwin/proclist.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/proclist.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,233 @@ +/* $Id: proclist.c,v 1.11.2.1 1999/05/27 19:24:20 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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 +#include + +static const unsigned long _glibtop_sysdeps_proclist = +(1L << GLIBTOP_PROCLIST_TOTAL) + (1L << GLIBTOP_PROCLIST_NUMBER) + +(1L << GLIBTOP_PROCLIST_SIZE); + +/* Init function. */ + +void +glibtop_init_proclist_s (glibtop *server) +{ + server->sysdeps.proclist = _glibtop_sysdeps_proclist; +} + +#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, + int64_t which, int64_t arg) +{ + 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_proc_uid procuid; + glibtop_proc_state procstate; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROCLIST, 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; + + switch (which & GLIBTOP_KERN_PROC_MASK) { + case GLIBTOP_KERN_PROC_ALL: + break; + case GLIBTOP_KERN_PROC_PID: + if ((unsigned) arg != pid) + continue; + break; + case GLIBTOP_KERN_PROC_UID: + if ((uid_t) arg != statb.st_uid) + continue; + break; + case GLIBTOP_KERN_PROC_PGRP: + /* Do you really, really need this ? */ + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1L << GLIBTOP_PROC_UID_PGRP)) + if ((int) arg != procuid.pgrp) + continue; + break; + case GLIBTOP_KERN_PROC_SESSION: + /* Do you really, really need this ? */ + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1L << GLIBTOP_PROC_UID_SESSION)) + if ((int) arg != procuid.session) + continue; + break; + case GLIBTOP_KERN_PROC_TTY: + /* Do you really, really need this ? */ + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY)) + if ((int) arg != procuid.tty) + continue; + break; + case GLIBTOP_KERN_PROC_RUID: + /* Do you really, really need this ? */ + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1L << GLIBTOP_PROC_UID_EUID)) + if ((int) arg != procuid.euid) + continue; + break; + } + + if (which & GLIBTOP_EXCLUDE_NOTTY) { + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1L << GLIBTOP_PROC_UID_TTY)) + if (procuid.tty == -1) continue; + } + + if (which & GLIBTOP_EXCLUDE_IDLE) { + glibtop_get_proc_state_s (server, &procstate, pid); + if (procstate.flags & (1L << GLIBTOP_PROC_STATE_STATE)) + if (procstate.state != 'R') continue; + } + + if (which & GLIBTOP_EXCLUDE_SYSTEM) { + glibtop_get_proc_uid_s (server, &procuid, pid); + if (procuid.flags & (1L << GLIBTOP_PROC_UID_UID)) + if (procuid.uid == 0) 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 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 the `pids_chain'. */ + + buf->flags = _glibtop_sysdeps_proclist; + + buf->size = sizeof (unsigned); + buf->number = total; + + buf->total = total * sizeof (unsigned); + + return pids_chain; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/procmap.c libgtop-1.0.13-cygwin/sysdeps/cygwin/procmap.c --- libgtop-1.0.13/sysdeps/cygwin/procmap.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/procmap.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,138 @@ +/* $Id: procmap.c,v 1.4.2.2 1999/05/27 19:24:21 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_proc_map = +(1L << GLIBTOP_PROC_MAP_NUMBER) + (1L << GLIBTOP_PROC_MAP_TOTAL) + +(1L << GLIBTOP_PROC_MAP_SIZE); + +static const unsigned long _glibtop_sysdeps_map_entry = +(1L << GLIBTOP_MAP_ENTRY_START) + (1L << GLIBTOP_MAP_ENTRY_END) + +(1L << GLIBTOP_MAP_ENTRY_OFFSET) + (1L << GLIBTOP_MAP_ENTRY_PERM) + +(1L << GLIBTOP_MAP_ENTRY_INODE) + (1L << GLIBTOP_MAP_ENTRY_DEVICE) + +(1L << GLIBTOP_MAP_ENTRY_FILENAME); + +/* Init function. */ + +void +glibtop_init_proc_map_s (glibtop *server) +{ + server->sysdeps.proc_map = _glibtop_sysdeps_proc_map; +} + +/* Provides detailed information about a process. */ + +glibtop_map_entry * +glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) +{ + char fn [BUFSIZ]; + glibtop_map_entry *entry_list = NULL; + int rv, n = 0; + FILE *maps; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_MAP, 0); + + memset (buf, 0, sizeof (glibtop_proc_map)); + + sprintf (fn, "/proc/%d/maps", pid); + + maps = fopen (fn, "r"); + if (!maps) return NULL; + + do { + short dev_major, dev_minor; + unsigned long start, end, offset, inode, perm; + char flags [5], *format; + size_t size; + + if (sizeof (void*) == 8) + format = "%16lx-%16lx %4c\n %16lx %02hx:%02hx %ld"; + else + format = "%08lx-%08lx %4c\n %08lx %02hx:%02hx %ld"; + + rv = fscanf (maps, format, + &start, &end, flags, &offset, + &dev_major, &dev_minor, &inode); + + flags [4] = 0; + + /* Compute access permissions. */ + + perm = 0; + + if (flags [0] == 'r') + perm |= GLIBTOP_MAP_PERM_READ; + if (flags [1] == 'w') + perm |= GLIBTOP_MAP_PERM_WRITE; + if (flags [2] == 'x') + perm |= GLIBTOP_MAP_PERM_EXECUTE; + if (flags [3] == 's') + perm |= GLIBTOP_MAP_PERM_SHARED; + if (flags [3] == 'p') + perm |= GLIBTOP_MAP_PERM_PRIVATE; + + /* Read filename. */ + + fn [0] = fgetc (maps); + + if (fn [0] != '\n' && fn [0] != EOF) { + + fscanf (maps, "%*[ ]%[^\n]\n", fn); + + } else fn [0] = 0; + + size = (n+1) * sizeof (glibtop_map_entry); + + entry_list = glibtop_realloc_r (server, entry_list, size); + + memset (&(entry_list [n]), 0, sizeof (glibtop_map_entry)); + + entry_list [n].flags = _glibtop_sysdeps_map_entry; + + entry_list [n].start = (u_int64_t) start; + entry_list [n].end = (u_int64_t) end; + entry_list [n].offset = (u_int64_t) offset; + entry_list [n].perm = (u_int64_t) perm; + entry_list [n].device = (u_int64_t) (dev_major << 8) + + (u_int64_t) dev_minor; + entry_list [n].inode = (u_int64_t) inode; + + strncpy (entry_list [n].filename, fn, GLIBTOP_MAP_FILENAME_LEN); + entry_list [n].filename [GLIBTOP_MAP_FILENAME_LEN] = 0; + + n++; + + } while (rv != EOF && rv && fn [0] != EOF); + + fclose (maps); + + buf->number = n; + buf->size = sizeof (glibtop_map_entry); + buf->total = n * sizeof (glibtop_map_entry); + + return entry_list; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/procmem.c libgtop-1.0.13-cygwin/sysdeps/cygwin/procmem.c --- libgtop-1.0.13/sysdeps/cygwin/procmem.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/procmem.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,104 @@ +/* $Id: procmem.c,v 1.14.2.1 1999/05/27 19:24:22 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_mem = +(1L << GLIBTOP_PROC_MEM_VSIZE) + (1L << GLIBTOP_PROC_MEM_RSS) + +(1L << GLIBTOP_PROC_MEM_RSS_RLIM); + +static const unsigned long _glibtop_sysdeps_proc_mem_statm = +(1L << GLIBTOP_PROC_MEM_SIZE) + (1L << GLIBTOP_PROC_MEM_RESIDENT) + +(1L << GLIBTOP_PROC_MEM_SHARE); + +#ifndef LOG1024 +#define LOG1024 10 +#endif + +/* these are for getting the memory statistics */ +static int pageshift; /* log base 2 of the pagesize */ + +/* define pagetok in terms of pageshift */ +#define pagetok(size) ((size) << pageshift) + +/* Init function. */ + +void +glibtop_init_proc_mem_s (glibtop *server) +{ + register int pagesize; + + server->sysdeps.proc_mem = _glibtop_sysdeps_proc_mem | + _glibtop_sysdeps_proc_mem_statm; + + /* get the page size with "getpagesize" and calculate pageshift + * from it */ + pagesize = getpagesize (); + pageshift = 0; + while (pagesize > 1) { + pageshift++; + pagesize >>= 1; + } +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid) +{ + char buffer [BUFSIZ], *p; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0); + + memset (buf, 0, sizeof (glibtop_proc_mem)); + + if (proc_stat_to_buffer (buffer, pid)) + return; + + p = proc_stat_after_cmd (buffer); + if (!p) return; + + p = skip_multiple_token (p, 20); + + buf->vsize = strtoul (p, &p, 0); + buf->rss = strtoul (p, &p, 0); + buf->rss_rlim = strtoul (p, &p, 0); + + buf->flags = _glibtop_sysdeps_proc_mem; + + if (proc_statm_to_buffer (buffer, pid)) + return; + + buf->size = strtoul (buffer, &p, 0); + buf->resident = strtoul (p, &p, 0); + buf->share = strtoul (p, &p, 0); + + buf->size <<= pageshift; + buf->resident <<= pageshift; + buf->share <<= pageshift; + buf->rss <<= pageshift; + + buf->flags |= _glibtop_sysdeps_proc_mem_statm; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/procsegment.c libgtop-1.0.13-cygwin/sysdeps/cygwin/procsegment.c --- libgtop-1.0.13/sysdeps/cygwin/procsegment.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/procsegment.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,115 @@ +/* $Id: procsegment.c,v 1.14.2.1 1999/05/27 19:24:23 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_segment = +(1L << GLIBTOP_PROC_SEGMENT_START_CODE) + +(1L << GLIBTOP_PROC_SEGMENT_END_CODE) + +(1L << GLIBTOP_PROC_SEGMENT_START_STACK); + +static const unsigned long _glibtop_sysdeps_proc_segment_statm = +(1L << GLIBTOP_PROC_SEGMENT_TEXT_RSS) + +/* Disabled due to bug in the Linux Kernel. */ +/* (1L << GLIBTOP_PROC_SEGMENT_SHLIB_RSS) + */ +(1L << GLIBTOP_PROC_SEGMENT_DATA_RSS) + +(1L << GLIBTOP_PROC_SEGMENT_DIRTY_SIZE); + +#ifndef LOG1024 +#define LOG1024 10 +#endif + +/* these are for getting the memory statistics */ +static int pageshift; /* log base 2 of the pagesize */ + +/* define pagetok in terms of pageshift */ +#define pagetok(size) ((size) << pageshift) + +/* Init function. */ + +void +glibtop_init_proc_segment_s (glibtop *server) +{ + register int pagesize; + + server->sysdeps.proc_segment = _glibtop_sysdeps_proc_segment | + _glibtop_sysdeps_proc_segment_statm; + + /* get the page size with "getpagesize" and calculate pageshift + * from it */ + pagesize = getpagesize (); + pageshift = 0; + while (pagesize > 1) { + pageshift++; + pagesize >>= 1; + } +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf, + pid_t pid) +{ + char buffer [BUFSIZ], *p; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0); + + memset (buf, 0, sizeof (glibtop_proc_segment)); + + if (proc_stat_to_buffer (buffer, pid)) + return; + + p = proc_stat_after_cmd (buffer); + if (!p) return; + + p = skip_multiple_token (p, 23); + + buf->start_code = strtoul (p, &p, 0); + buf->end_code = strtoul (p, &p, 0); + buf->start_stack = strtoul (p, &p, 0); + + buf->flags = _glibtop_sysdeps_proc_segment; + + if (proc_statm_to_buffer (buffer, pid)) + return; + + p = skip_multiple_token (buffer, 3); + + /* This doesn't work very well due to a bug in the Linux kernel. + * I'll submit a patch to the kernel mailing list soon. */ + + buf->text_rss = strtoul (p, &p, 0); + buf->shlib_rss = strtoul (p, &p, 0); + buf->data_rss = strtoul (p, &p, 0); + buf->dirty_size = strtoul (p, &p, 0); + + buf->text_rss <<= pageshift; + buf->shlib_rss <<= pageshift; + buf->data_rss <<= pageshift; + buf->dirty_size <<= pageshift; + + buf->flags |= _glibtop_sysdeps_proc_segment_statm; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/procsignal.c libgtop-1.0.13-cygwin/sysdeps/cygwin/procsignal.c --- libgtop-1.0.13/sysdeps/cygwin/procsignal.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/procsignal.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,65 @@ +/* $Id: procsignal.c,v 1.14.2.1 1999/05/27 19:24:24 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_signal = +(1L << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1L << GLIBTOP_PROC_SIGNAL_BLOCKED) + +(1L << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1L << GLIBTOP_PROC_SIGNAL_SIGCATCH); + +/* Init function. */ + +void +glibtop_init_proc_signal_s (glibtop *server) +{ + server->sysdeps.proc_signal = _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) +{ + char buffer [BUFSIZ], *p; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); + + memset (buf, 0, sizeof (glibtop_proc_signal)); + + if (proc_stat_to_buffer (buffer, pid)) + return; + + p = proc_stat_after_cmd (buffer); + if (!p) return; + + p = skip_multiple_token (p, 28); + + buf->signal [0] = strtoul (p, &p, 0); + buf->blocked [0] = strtoul (p, &p, 0); + buf->sigignore [0] = strtoul (p, &p, 0); + buf->sigcatch [0] = strtoul (p, &p, 0); + + buf->flags = _glibtop_sysdeps_proc_signal; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/procstate.c libgtop-1.0.13-cygwin/sysdeps/cygwin/procstate.c --- libgtop-1.0.13/sysdeps/cygwin/procstate.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/procstate.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,93 @@ +/* $Id: procstate.c,v 1.14.4.2 1999/11/28 11:57:11 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_proc_state = +(1L << GLIBTOP_PROC_STATE_CMD) + (1L << GLIBTOP_PROC_STATE_STATE); + +static const unsigned long _glibtop_sysdeps_proc_state_uid = +(1L << GLIBTOP_PROC_STATE_UID) + (1L << GLIBTOP_PROC_STATE_GID); + +/* Init function. */ + +void +glibtop_init_proc_state_s (glibtop *server) +{ + server->sysdeps.proc_state = _glibtop_sysdeps_proc_state | + _glibtop_sysdeps_proc_state_uid; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid) +{ + char buffer [BUFSIZ], *p; + struct stat statb; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0); + + memset (buf, 0, sizeof (glibtop_proc_state)); + + /* 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 !!! */ + + sprintf (buffer, "/proc/%d", pid); + + if (stat (buffer, &statb)) + return; + + /* For security reasons we use stat () since it is + * more failsafe than parsing the file. */ + + buf->uid = statb.st_uid; + buf->gid = statb.st_gid; + + buf->flags = _glibtop_sysdeps_proc_state_uid; + + sprintf (buffer, "/proc/%d", pid); + + /* Now we read the remaining fields. */ + + if (proc_stat_to_buffer (buffer, pid)) + return; + + p = strrchr (buffer, ')'); *p = '\0'; + buf->state = p [2]; + + p = skip_token (buffer); p++; /* pid */ + if (*p++ != '(') + glibtop_error_r (server, "Bad data in /proc/%d/stat", pid); + + strncpy (buf->cmd, p, sizeof (buf->cmd)-1); + buf->cmd [sizeof (buf->cmd)-1] = 0; + + buf->flags |= _glibtop_sysdeps_proc_state; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/proctime.c libgtop-1.0.13-cygwin/sysdeps/cygwin/proctime.c --- libgtop-1.0.13/sysdeps/cygwin/proctime.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/proctime.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,103 @@ +/* $Id: proctime.c,v 1.17.2.2 1999/09/16 21:05:33 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_time = +(1L << GLIBTOP_PROC_TIME_UTIME) + (1L << GLIBTOP_PROC_TIME_CUTIME) + +(1L << GLIBTOP_PROC_TIME_STIME) + (1L << GLIBTOP_PROC_TIME_CSTIME) + +(1L << GLIBTOP_PROC_TIME_FREQUENCY) + (1L << GLIBTOP_PROC_TIME_TIMEOUT) + +(1L << GLIBTOP_PROC_TIME_IT_REAL_VALUE) + (1L << GLIBTOP_PROC_TIME_START_TIME); + +static const unsigned long _glibtop_sysdeps_proc_time_smp = +(1L << GLIBTOP_PROC_TIME_XCPU_UTIME) + (1L << GLIBTOP_PROC_TIME_XCPU_STIME); + +/* Init function. */ + +void +glibtop_init_proc_time_s (glibtop *server) +{ + server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; + + if (server->ncpu) + server->sysdeps.proc_time |= _glibtop_sysdeps_proc_time_smp; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) +{ + char buffer [BUFSIZ], *p; + int i; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0); + + memset (buf, 0, sizeof (glibtop_proc_time)); + + if (proc_stat_to_buffer (buffer, pid)) + return; + + p = proc_stat_after_cmd (buffer); + if (!p) return; + + p = skip_multiple_token (p, 11); + + buf->utime = strtoul (p, &p, 0); + buf->stime = strtoul (p, &p, 0); + buf->cutime = strtoul (p, &p, 0); + buf->cstime = strtoul (p, &p, 0); + + p = skip_multiple_token (p, 2); + + buf->timeout = strtoul (p, &p, 0); + buf->it_real_value = strtoul (p, &p, 0); + buf->start_time = strtoul (p, &p, 0); + + buf->frequency = 100; + + buf->flags = _glibtop_sysdeps_proc_time; + + if (!server->ncpu) + return; + + if (proc_file_to_buffer (buffer, "/proc/%d/cpu", pid)) + return; + + p = skip_token (buffer); + buf->utime = strtoul (p, &p, 0); + buf->stime = strtoul (p, &p, 0); + + for (i = 0; i < GLIBTOP_NCPU; i++) { + if (strncmp (p+1, "cpu", 3) || !isdigit (p [4])) + break; + + p += 6; + buf->xcpu_utime [i] = strtoul (p, &p, 0); + buf->xcpu_stime [i] = strtoul (p, &p, 0); + } + + buf->flags |= _glibtop_sysdeps_proc_time_smp; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/procuid.c libgtop-1.0.13-cygwin/sysdeps/cygwin/procuid.c --- libgtop-1.0.13/sysdeps/cygwin/procuid.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/procuid.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,126 @@ +/* $Id: procuid.c,v 1.12.2.1 1999/05/27 19:24:27 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_uid = +(1L << GLIBTOP_PROC_UID_UID) + (1L << GLIBTOP_PROC_UID_EUID) + +(1L << GLIBTOP_PROC_UID_GID) + (1L << GLIBTOP_PROC_UID_EGID); + +static const unsigned long _glibtop_sysdeps_proc_uid_stat = +(1L << GLIBTOP_PROC_UID_PID) + (1L << GLIBTOP_PROC_UID_PPID) + +(1L << GLIBTOP_PROC_UID_PGRP) + (1L << GLIBTOP_PROC_UID_SESSION) + +(1L << GLIBTOP_PROC_UID_TTY) + (1L << GLIBTOP_PROC_UID_TPGID) + +(1L << GLIBTOP_PROC_UID_PRIORITY) + (1L << GLIBTOP_PROC_UID_NICE); + +#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) + +/* Init function. */ + +void +glibtop_init_proc_uid_s (glibtop *server) +{ + server->sysdeps.proc_uid = _glibtop_sysdeps_proc_uid | + _glibtop_sysdeps_proc_uid_stat; +} + +/* Provides detailed information about a process. */ + +void +glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid) +{ + char buffer [BUFSIZ], *p; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_UID, 0); + + memset (buf, 0, sizeof (glibtop_proc_uid)); + + if (proc_status_to_buffer (buffer, pid)) + return; + + /* Search substring 'Pid:' */ + + p = strstr (buffer, "\nPid:"); + if (!p) return; + + p = skip_token (p); /* "Pid:" */ + buf->pid = strtoul (p, &p, 0); + + p = skip_token (p); /* "PPid:" */ + buf->ppid = strtoul (p, &p, 0); + + /* Maybe future Linux versions place something between + * "PPid" and "Uid", so we catch this here. */ + p = strstr (p, "\nUid:"); + if (!p) return; + + p = skip_token (p); /* "Uid:" */ + buf->uid = strtoul (p, &p, 0); + buf->euid = strtoul (p, &p, 0); + + /* We don't know how many entries on the "Uid:" line + * future Linux version will have, so we catch this here. */ + p = strstr (p, "\nGid:"); + if (!p) return; + + p = skip_token (p); /* "Gid:" */ + buf->gid = strtoul (p, &p, 0); + buf->egid = strtoul (p, &p, 0); + + buf->flags = _glibtop_sysdeps_proc_uid; + + if (proc_stat_to_buffer (buffer, pid)) + return; + + p = proc_stat_after_cmd (buffer); + if (!p) return; + + p = skip_multiple_token (p, 2); + + buf->pgrp = strtoul (p, &p, 0); + buf->session = strtoul (p, &p, 0); + buf->tty = strtoul (p, &p, 0); + buf->tpgid = strtoul (p, &p, 0); + + p = skip_multiple_token (p, 9); + + buf->priority = strtoul (p, &p, 0); + buf->nice = strtoul (p, &p, 0); + + 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_stat; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/sem_limits.c libgtop-1.0.13-cygwin/sysdeps/cygwin/sem_limits.c --- libgtop-1.0.13/sysdeps/cygwin/sem_limits.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/sem_limits.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,130 @@ +/* $Id: sem_limits.c,v 1.9.2.1 1999/05/27 19:24:28 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#ifdef HAVE_SYSV_IPC + +#include +#include + +#ifdef _SEM_SEMUN_UNDEFINED + +/* glibc 2.1 will no longer defines semun, instead it defines + * _SEM_SEMUN_UNDEFINED so users can define semun on their own. + * Thanks to Albert K T Hui . */ + +union semun +{ + int val; + struct semid_ds *buf; + unsigned short int *array; + struct seminfo *__buf; +}; +#endif + +static unsigned long _glibtop_sysdeps_sem_limits = +(1L << GLIBTOP_IPC_SEMMAP) + (1L << GLIBTOP_IPC_SEMMNI) + +(1L << GLIBTOP_IPC_SEMMNS) + (1L << GLIBTOP_IPC_SEMMNU) + +(1L << GLIBTOP_IPC_SEMMSL) + (1L << GLIBTOP_IPC_SEMOPM) + +(1L << GLIBTOP_IPC_SEMUME) + (1L << GLIBTOP_IPC_SEMUSZ) + +(1L << GLIBTOP_IPC_SEMVMX) + (1L << GLIBTOP_IPC_SEMAEM); + +/* Init function. */ + +void +glibtop_init_sem_limits_s (glibtop *server) +{ + server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; +} + +/* 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_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 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; +} + +#else +static unsigned long _glibtop_sysdeps_sem_limits = +(1L << GLIBTOP_IPC_SEMMAP) + (1L << GLIBTOP_IPC_SEMMNI) + +(1L << GLIBTOP_IPC_SEMMNS) + (1L << GLIBTOP_IPC_SEMMNU) + +(1L << GLIBTOP_IPC_SEMMSL) + (1L << GLIBTOP_IPC_SEMOPM) + +(1L << GLIBTOP_IPC_SEMUME) + (1L << GLIBTOP_IPC_SEMUSZ) + +(1L << GLIBTOP_IPC_SEMVMX) + (1L << GLIBTOP_IPC_SEMAEM); + +/* Init function. */ + +void +glibtop_init_sem_limits_s (glibtop *server) +{ + server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; +} + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf) +{ + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); + + memset (buf, 0, sizeof (glibtop_sem_limits)); + + buf->flags = _glibtop_sysdeps_sem_limits; + + buf->semmap = 0; + buf->semmni = 0; + buf->semmns = 0; + buf->semmnu = 0; + buf->semmsl = 0; + buf->semopm = 0; + buf->semume = 0; + buf->semusz = 0; + buf->semvmx = 0; + buf->semaem = 0; +} + +#endif diff -Naurp libgtop-1.0.13/sysdeps/cygwin/shm_limits.c libgtop-1.0.13-cygwin/sysdeps/cygwin/shm_limits.c --- libgtop-1.0.13/sysdeps/cygwin/shm_limits.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/shm_limits.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,97 @@ +/* $Id: shm_limits.c,v 1.8.2.1 1999/05/27 19:24:29 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#ifdef HAVE_SYSV_IPC + +#include +#include + +static unsigned long _glibtop_sysdeps_shm_limits = +(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) + +(1L << GLIBTOP_IPC_SHMMNI) + (1L << GLIBTOP_IPC_SHMSEG) + +(1L << GLIBTOP_IPC_SHMALL); + +/* Init function. */ + +void +glibtop_init_shm_limits_s (glibtop *server) +{ + server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; +} + +/* Provides information about sysv ipc limits. */ + +void +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) +{ + struct shminfo shminfo; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 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; +} + +#else + +static unsigned long _glibtop_sysdeps_shm_limits = +(1L << GLIBTOP_IPC_SHMMAX) + (1L << GLIBTOP_IPC_SHMMIN) + +(1L << GLIBTOP_IPC_SHMMNI) + (1L << GLIBTOP_IPC_SHMSEG) + +(1L << GLIBTOP_IPC_SHMALL); + +void +glibtop_init_shm_limits_s (glibtop *server) +{ + server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; +} + + +void +glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf) +{ + glibtop_init_s (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); + + memset (buf, 0, sizeof (glibtop_shm_limits)); + + buf->flags = _glibtop_sysdeps_shm_limits; + + buf->shmmax = 0; + buf->shmmin = 0; + buf->shmmni = 0; + buf->shmseg = 0; + buf->shmall = 0; +} + + +#endif \ No newline at end of file diff -Naurp libgtop-1.0.13/sysdeps/cygwin/siglist.c libgtop-1.0.13-cygwin/sysdeps/cygwin/siglist.c --- libgtop-1.0.13/sysdeps/cygwin/siglist.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/siglist.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,60 @@ +/* $Id: siglist.c,v 1.3 1999/02/23 11:45:15 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include + +const glibtop_signame glibtop_sys_siglist [] = +{ { 1, "SIGHUP", NULL }, /* Hangup (POSIX). */ + { 2, "SIGINT", NULL }, /* Interrupt (ANSI). */ + { 3, "SIGQUIT", NULL }, /* Quit (POSIX). */ + { 4, "SIGILL", NULL }, /* Illegal instruction (ANSI). */ + { 5, "SIGTRAP", NULL }, /* Trace trap (POSIX). */ + { 6, "SIGABRT", NULL }, /* Abort (ANSI). */ + { 7, "SIGBUS", NULL }, /* BUS error (4.2 BSD). */ + { 8, "SIGFPE", NULL }, /* Floating-point exception (ANSI). */ + { 9, "SIGKILL", NULL }, /* Kill, unblockable (POSIX). */ + { 10, "SIGUSR1", NULL }, /* User-defined signal 1 (POSIX). */ + { 11, "SIGSEGV", NULL }, /* Segmentation violation (ANSI). */ + { 12, "SIGUSR2", NULL }, /* User-defined signal 2 (POSIX). */ + { 13, "SIGPIPE", NULL }, /* Broken pipe (POSIX). */ + { 14, "SIGALRM", NULL }, /* Alarm clock (POSIX). */ + { 15, "SIGTERM", NULL }, /* Termination (ANSI). */ + { 16, "SIGSTKFLT", NULL }, /* ??? */ + { 17, "SIGCHLD", NULL }, /* Child status has changed (POSIX). */ + { 18, "SIGCONT", NULL }, /* Continue (POSIX). */ + { 19, "SIGSTOP", NULL }, /* Stop, unblockable (POSIX). */ + { 20, "SIGTSTP", NULL }, /* Keyboard stop (POSIX). */ + { 21, "SIGTTIN", NULL }, /* Background read from tty (POSIX). */ + { 22, "SIGTTOU", NULL }, /* Background write to tty (POSIX). */ + { 23, "SIGURG", NULL }, /* Urgent condition on socket (4.2 BSD). */ + { 24, "SIGXCPU", NULL }, /* CPU limit exceeded (4.2 BSD). */ + { 25, "SIGXFSZ", NULL }, /* File size limit exceeded (4.2 BSD). */ + { 26, "SIGVTALRM", NULL }, /* Virtual alarm clock (4.2 BSD). */ + { 27, "SIGPROF", NULL }, /* Profiling alarm clock (4.2 BSD). */ + { 28, "SIGWINCH", NULL }, /* Window size change (4.3 BSD, Sun). */ + { 29, "SIGIO", NULL }, /* I/O now possible (4.2 BSD). */ + { 30, "SIGPWR", NULL }, /* Power failure restart (System V). */ + { 31, "SIGUNUSED", NULL }, + { 0, NULL, NULL }, +}; diff -Naurp libgtop-1.0.13/sysdeps/cygwin/swap.c libgtop-1.0.13-cygwin/sysdeps/cygwin/swap.c --- libgtop-1.0.13/sysdeps/cygwin/swap.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/swap.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,104 @@ +/* $Id: swap.c,v 1.16.2.1 1999/05/27 19:24:30 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_swap = +(1L << GLIBTOP_SWAP_TOTAL) + (1L << GLIBTOP_SWAP_USED) + +(1L << GLIBTOP_SWAP_FREE); + +static unsigned long _glibtop_sysdeps_swap_paging = +(1L << GLIBTOP_SWAP_PAGEIN) + (1L << GLIBTOP_SWAP_PAGEOUT); + +/* Init function. */ + +void +glibtop_init_swap_s (glibtop *server) +{ + server->sysdeps.swap = _glibtop_sysdeps_swap | + _glibtop_sysdeps_swap_paging; +} + +/* Provides information about swap usage. */ + +#define MEMINFO "/proc/meminfo" +#define PROC_STAT "/proc/stat" + +void +glibtop_get_swap_s (glibtop *server, glibtop_swap *buf) +{ + char buffer [BUFSIZ], *p; + int fd, len; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_SWAP, 0); + + memset (buf, 0, sizeof (glibtop_swap)); + + fd = open (MEMINFO, O_RDONLY); + if (fd < 0) + glibtop_error_io_r (server, "open (%s)", MEMINFO); + + len = read (fd, buffer, BUFSIZ-1); + if (len < 0) + glibtop_error_io_r (server, "read (%s)", MEMINFO); + + close (fd); + + buffer [len] = '\0'; + + p = skip_line (buffer); + p = skip_line (p); + p = skip_token (p); /* "Swap:" */ + + buf->total = strtoul (p, &p, 0); + buf->used = strtoul (p, &p, 0); + buf->free = strtoul (p, &p, 0); + + buf->flags = _glibtop_sysdeps_swap; + + fd = open (PROC_STAT, O_RDONLY); + if (fd < 0) + glibtop_error_io_r (server, "open (%s)", PROC_STAT); + + len = read (fd, buffer, BUFSIZ-1); + if (len < 0) + glibtop_error_io_r (server, "read (%s)", PROC_STAT); + + close (fd); + + buffer [len] = '\0'; + + p = strstr (buffer, "\nswap"); + if (p == NULL) return; + + p = skip_token (p); + + buf->pagein = strtoul (p, &p, 0); + buf->pageout = strtoul (p, &p, 0); + + buf->flags |= _glibtop_sysdeps_swap_paging; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/sysinfo.c libgtop-1.0.13-cygwin/sysdeps/cygwin/sysinfo.c --- libgtop-1.0.13/sysdeps/cygwin/sysinfo.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/sysinfo.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,94 @@ +/* $Id: sysinfo.c,v 1.5.4.2 1999/05/27 19:24:31 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_sysinfo = +(1L << GLIBTOP_SYSINFO_CPUINFO); + +static glibtop_sysinfo sysinfo; + +static void +init_sysinfo (glibtop *server) +{ + char buffer [BUFSIZ]; + static int init = 0; + glibtop_entry *cpuinfo = NULL; + FILE *f; + + if (init) return; + + init = TRUE; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); + + memset (&sysinfo, 0, sizeof (glibtop_sysinfo)); + + g_return_if_fail (f = fopen ("/proc/cpuinfo", "r")); + + while (fgets (buffer, BUFSIZ, f)) { + char *p, *start, *key, *value; + + if (cpuinfo == NULL) { + cpuinfo = &sysinfo.cpuinfo [sysinfo.ncpu++]; + + cpuinfo->labels = g_ptr_array_new (); + + cpuinfo->values = g_hash_table_new (NULL, NULL); + + if (sysinfo.ncpu > GLIBTOP_NCPU) + sysinfo.ncpu = GLIBTOP_NCPU; + } + + p = strchr (buffer, ':'); + if (!p) continue; + + /* Remove leading spaces from `p'. */ + *p = '\0'; start = p; p++; + while (isspace (*p)) p++; + + /* Remove trailing spaces from `buffer'. */ + while ((start > buffer) && (*start) && isspace (*start)) + *start-- = '\0'; + + key = g_strdup (buffer); + value = g_strdup (p); + + g_ptr_array_add (cpuinfo->labels, key); + + g_hash_table_insert (cpuinfo->values, key, value); + } + + fclose (f); + + sysinfo.flags = _glibtop_sysdeps_sysinfo; +} + +glibtop_sysinfo * +glibtop_get_sysinfo_s (glibtop *server) +{ + init_sysinfo (server); + return &sysinfo; +} diff -Naurp libgtop-1.0.13/sysdeps/cygwin/uptime.c libgtop-1.0.13-cygwin/sysdeps/cygwin/uptime.c --- libgtop-1.0.13/sysdeps/cygwin/uptime.c 1970-01-01 00:00:00.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/cygwin/uptime.c 2002-07-28 14:24:24.000000000 +0100 @@ -0,0 +1,69 @@ +/* $Id: uptime.c,v 1.11.2.2 1999/10/19 00:16:29 martin Exp $ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , April 1998. + + LibGTop 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. + + LibGTop is distributed in the hope that 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 LibGTop; see the file COPYING. 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_uptime = +(1L << GLIBTOP_UPTIME_UPTIME) + (1L << GLIBTOP_UPTIME_IDLETIME); + +/* Init function. */ + +void +glibtop_init_uptime_s (glibtop *server) +{ + server->sysdeps.uptime = _glibtop_sysdeps_uptime; +} + +/* Provides uptime and idle time. */ + +#define FILENAME "/proc/uptime" + +void +glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) +{ + char buffer [BUFSIZ], *p; + int fd, len; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_UPTIME, 0); + + memset (buf, 0, sizeof (glibtop_uptime)); + + fd = open (FILENAME, O_RDONLY); + if (fd < 0) + glibtop_error_io_r (server, "open (%s)", FILENAME); + + len = read (fd, buffer, BUFSIZ-1); + if (len < 0) + glibtop_error_io_r (server, "read (%s)", FILENAME); + + close (fd); + + buffer [len] = '\0'; + + buf->uptime = strtod (buffer, &p); + buf->idletime = strtod (p, &p); + + buf->flags = _glibtop_sysdeps_uptime; +} diff -Naurp libgtop-1.0.13/sysdeps/names/Makefile.in libgtop-1.0.13-cygwin/sysdeps/names/Makefile.in --- libgtop-1.0.13/sysdeps/names/Makefile.in 2001-11-27 02:05:05.000000000 +0000 +++ libgtop-1.0.13-cygwin/sysdeps/names/Makefile.in 2002-07-28 14:24:24.000000000 +0100 @@ -305,7 +305,7 @@ maintainer-clean-libtool: libgtop_names.la: $(libgtop_names_la_OBJECTS) $(libgtop_names_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libgtop_names_la_LDFLAGS) $(libgtop_names_la_OBJECTS) $(libgtop_names_la_LIBADD) $(LIBS) - + PREFIX=$(prefix) sh $(top_srcdir)/mkdll.sh $@ -- $(top_builddir)/lib/.libs/libgtop.dll.a $$(glib-config --libs) -lintl tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP)