diff options
author | Benoît Dejean <bdejean@src.gnome.org> | 2004-11-13 00:53:20 +0000 |
---|---|---|
committer | Benoît Dejean <bdejean@src.gnome.org> | 2004-11-13 00:53:20 +0000 |
commit | 7e5ccec8bf8df4187c161f1e2dab600a434cf515 (patch) | |
tree | 9c382033a8dbae93a52efa937710164d7fefdad9 | |
parent | fdf313cdf618ab7ef971b73cecc0fd1162ef162b (diff) | |
download | libgtop-7e5ccec8bf8df4187c161f1e2dab600a434cf515.tar.gz |
Bumped to 2.9.0
* configure.in: Bumped to 2.9.0
* configure.in:
* examples/.cvsignore:
* examples/Makefile.am:
* examples/netlist.c: (main):
* features.def:
* include/glibtop/Makefile.am:
* include/glibtop/command.h:
* include/glibtop/netlist.h:
* include/glibtop/sysdeps.h:
* include/glibtop/union.h:
* include/glibtop/version.h:
* src/daemon/version.c:
* sysdeps/linux/Makefile.am:
* sysdeps/linux/netlist.c: (glibtop_init_netlist_s),
(glibtop_get_netlist_s):
* sysdeps/names/Makefile.am:
* sysdeps/names/netlist.c:
* sysdeps/solaris/Makefile.am:
* sysdeps/solaris/netlist.c: (glibtop_init_netlist_s),
(glibtop_get_netlist_s): Added new function glibtop_get_netlist().
Implemented for linux and solaris. Doc needed.
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | configure.in | 8 | ||||
-rw-r--r-- | examples/.cvsignore | 2 | ||||
-rw-r--r-- | examples/Makefile.am | 13 | ||||
-rw-r--r-- | examples/netlist.c | 46 | ||||
-rw-r--r-- | features.def | 2 | ||||
-rw-r--r-- | include/glibtop/Makefile.am | 2 | ||||
-rw-r--r-- | include/glibtop/command.h | 3 | ||||
-rw-r--r-- | include/glibtop/netlist.h | 71 | ||||
-rw-r--r-- | include/glibtop/sysdeps.h | 4 | ||||
-rw-r--r-- | include/glibtop/union.h | 2 | ||||
-rw-r--r-- | include/glibtop/version.h | 3 | ||||
-rw-r--r-- | src/daemon/version.c | 3 | ||||
-rw-r--r-- | sysdeps/linux/Makefile.am | 2 | ||||
-rw-r--r-- | sysdeps/linux/netlist.c | 84 | ||||
-rw-r--r-- | sysdeps/names/Makefile.am | 2 | ||||
-rw-r--r-- | sysdeps/names/netlist.c | 42 | ||||
-rw-r--r-- | sysdeps/solaris/Makefile.am | 2 | ||||
-rw-r--r-- | sysdeps/solaris/netlist.c | 68 |
19 files changed, 370 insertions, 15 deletions
@@ -1,3 +1,29 @@ +2004-11-13 Benoît Dejean <tazforever@dlfp.org> + + * configure.in: Bumped to 2.9.0 + + * configure.in: + * examples/.cvsignore: + * examples/Makefile.am: + * examples/netlist.c: (main): + * features.def: + * include/glibtop/Makefile.am: + * include/glibtop/command.h: + * include/glibtop/netlist.h: + * include/glibtop/sysdeps.h: + * include/glibtop/union.h: + * include/glibtop/version.h: + * src/daemon/version.c: + * sysdeps/linux/Makefile.am: + * sysdeps/linux/netlist.c: (glibtop_init_netlist_s), + (glibtop_get_netlist_s): + * sysdeps/names/Makefile.am: + * sysdeps/names/netlist.c: + * sysdeps/solaris/Makefile.am: + * sysdeps/solaris/netlist.c: (glibtop_init_netlist_s), + (glibtop_get_netlist_s): Added new function glibtop_get_netlist(). + Implemented for linux and solaris. Doc needed. + 2004-10-11 Benoît Dejean <tazforever@dlfp.org> * NEWS: Released 2.8.1. diff --git a/configure.in b/configure.in index a1bd6572..7a52582e 100644 --- a/configure.in +++ b/configure.in @@ -7,8 +7,8 @@ AM_CONFIG_HEADER(config.h) AC_CANONICAL_SYSTEM LIBGTOP_MAJOR_VERSION=2 -LIBGTOP_MINOR_VERSION=8 -LIBGTOP_MICRO_VERSION=1 +LIBGTOP_MINOR_VERSION=9 +LIBGTOP_MICRO_VERSION=0 LIBGTOP_VERSION=$LIBGTOP_MAJOR_VERSION.$LIBGTOP_MINOR_VERSION.$LIBGTOP_MICRO_VERSION AM_INIT_AUTOMAKE(libgtop, $LIBGTOP_VERSION) @@ -22,7 +22,7 @@ LIBGTOP_REVISION=0 dnl increment if any interfaces have been added; set to 0 dnl if any interfaces have been removed. removal has dnl precedence over adding, so set to 0 if both happened. -LIBGTOP_AGE=0 +LIBGTOP_AGE=1 # you can set this to `-snap' for instance to create # a `libgtop-1.x.y-snap.tar.gz' tarball. @@ -123,7 +123,7 @@ else fi if test "x$enable_static" != xno; then - static_targets="first_static second_static mountlist_static procmap_static netload_static sysdeps_static timings_static $smp_static_examples pprint_static procargs_static df_static" + static_targets="first_static second_static mountlist_static procmap_static netload_static sysdeps_static timings_static $smp_static_examples pprint_static procargs_static df_static netlist netlist_static" else static_targets="" fi diff --git a/examples/.cvsignore b/examples/.cvsignore index eb80d17f..f7ec2055 100644 --- a/examples/.cvsignore +++ b/examples/.cvsignore @@ -20,4 +20,6 @@ procargs procargs_static df df_static +netlist +netlist_static diff --git a/examples/Makefile.am b/examples/Makefile.am index b68175c0..45f261cb 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -6,7 +6,7 @@ INCLUDES = @INCLUDES@ DEFS = @DEFS@ -noinst_PROGRAMS = first second pprint procargs df \ +noinst_PROGRAMS = first second pprint procargs df netlist \ mountlist procmap netload sysdeps timings \ @static_targets@ @smp_examples@ @@ -15,7 +15,7 @@ EXTRA_PROGRAMS = first_static second_static \ third third_static smp smp_static \ netload_static sysdeps_static \ timings_static pprint_static procargs_static \ - df_static + df_static netlist_static first_SOURCES = first.c first_LDADD = $(top_builddir)/lib/libgtop-2.0.la @@ -109,3 +109,12 @@ df_static_SOURCES = $(df_SOURCES) df_static_LDADD = $(df_LDADD) df_static_LDFLAGS = -static + +netlist_SOURCES = netlist.c +netlist_LDADD = $(top_builddir)/lib/libgtop-2.0.la + +netlist_static_SOURCES = $(netlist_SOURCES) +netlist_static_LDADD = $(netlist_LDADD) +netlist_static_LDFLAGS = -static + + diff --git a/examples/netlist.c b/examples/netlist.c new file mode 100644 index 00000000..686d733a --- /dev/null +++ b/examples/netlist.c @@ -0,0 +1,46 @@ +/* Copyright (C) 2004 Benoît Dejean + This file is part of LibGTop 2.0. + + + 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 <stdio.h> + +#include <glibtop.h> +#include <glibtop/netlist.h> + + +int main(int argc, char *argv []) +{ + glibtop_netlist buf; + char **devices; + guint32 i; + + glibtop_init(); + + devices = glibtop_get_netlist(&buf); + + for(i = 0; i < buf.number; ++i) + { + printf("net device '%s'\n", devices[i]); + } + + g_strfreev(devices); + + glibtop_close(); + return 0; +} diff --git a/features.def b/features.def index eedaf73a..7cf18500 100644 --- a/features.def +++ b/features.def @@ -20,3 +20,5 @@ glibtop_mountentry *|@mountlist|ulong(number,size,total)|int(all_fs) void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir void|netload|ulong(if_flags,mtu,subnet,address,packets_in,packets_out,packets_total,bytes_in,bytes_out,bytes_total,errors_in,errors_out,errors_total,collisions)|string|interface void|ppp|ulong(state,bytes_in,bytes_out)|ushort(device) +char **|netlist|unsigned(number) + diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am index 43735148..ba0b59c6 100644 --- a/include/glibtop/Makefile.am +++ b/include/glibtop/Makefile.am @@ -7,4 +7,4 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \ procsegment.h read.h sysdeps.h global.h \ procsignal.h read_data.h union.h types.h gnuserv.h \ parameter.h mountlist.h fsusage.h procmap.h signal.h \ - inodedb.h sysinfo.h ppp.h procargs.h netload.h + inodedb.h sysinfo.h ppp.h procargs.h netload.h netlist.h diff --git a/include/glibtop/command.h b/include/glibtop/command.h index 87688eb2..aa940ddc 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -57,8 +57,9 @@ G_BEGIN_DECLS #define GLIBTOP_CMND_FSUSAGE 21 #define GLIBTOP_CMND_NETLOAD 22 #define GLIBTOP_CMND_PPP 23 +#define GLIBTOP_CMND_NETLIST 24 -#define GLIBTOP_MAX_CMND 24 +#define GLIBTOP_MAX_CMND 25 #define _GLIBTOP_PARAM_SIZE 16 diff --git a/include/glibtop/netlist.h b/include/glibtop/netlist.h new file mode 100644 index 00000000..e296f09f --- /dev/null +++ b/include/glibtop/netlist.h @@ -0,0 +1,71 @@ +/* Copyright (C) 2004 Benoît Dejean + This file is part of LibGTop 2.0. + + 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_NETLIST_H__ +#define __GLIBTOP_NETLIST_H__ + +#include <glibtop.h> +#include <glibtop/global.h> + +G_BEGIN_DECLS + +#define GLIBTOP_NETLIST_NUMBER 0 + +#define GLIBTOP_MAX_NETLIST 1 + +typedef struct _glibtop_netlist glibtop_netlist; + +struct _glibtop_netlist +{ + guint64 flags; + guint32 number; +}; + +#define glibtop_get_netlist(netlist) glibtop_get_netlist_l(glibtop_global_server, netlist) + +#if GLIBTOP_SUID_NETLIST +#define glibtop_get_netlist_r glibtop_get_netlist_p +#else +#define glibtop_get_netlist_r glibtop_get_netlist_s +#endif + +char** glibtop_get_netlist_l (glibtop *server, glibtop_netlist *buf); + +#if GLIBTOP_SUID_NETLIST +void glibtop_init_netlist_p (glibtop *server); +char** glibtop_get_netlist_p (glibtop *server, glibtop_netlist *buf); +#else +void glibtop_init_netlist_s (glibtop *server); +char** glibtop_get_netlist_s (glibtop *server, glibtop_netlist *buf); +#endif + +#ifdef GLIBTOP_NAMES + +/* You need to link with -lgtop_names to get this stuff here. */ + +extern const char *glibtop_names_netlist []; +extern const unsigned glibtop_types_netlist []; +extern const char *glibtop_labels_netlist []; +extern const char *glibtop_descriptions_netlist []; + +#endif + +G_END_DECLS + +#endif diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index 11d2f9c3..7eb39313 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -51,8 +51,9 @@ G_BEGIN_DECLS #define GLIBTOP_SYSDEPS_FSUSAGE 20 #define GLIBTOP_SYSDEPS_NETLOAD 21 #define GLIBTOP_SYSDEPS_PPP 22 +#define GLIBTOP_SYSDEPS_NETLIST 23 -#define GLIBTOP_MAX_SYSDEPS 23 +#define GLIBTOP_MAX_SYSDEPS 24 #define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1) @@ -86,6 +87,7 @@ struct _glibtop_sysdeps proc_map, /* glibtop_proc_map */ mountlist, /* glibtop_mountlist */ fsusage, /* glibtop_fsusage */ + netlist, /* glibtop_netlist */ netload, /* glibtop_netload */ ppp; /* glibtop_ppp */ }; diff --git a/include/glibtop/union.h b/include/glibtop/union.h index db1cc203..ed462468 100644 --- a/include/glibtop/union.h +++ b/include/glibtop/union.h @@ -48,6 +48,7 @@ #include <glibtop/fsusage.h> #include <glibtop/netload.h> +#include <glibtop/netlist.h> #include <glibtop/ppp.h> G_BEGIN_DECLS @@ -76,6 +77,7 @@ union _glibtop_union glibtop_proc_map proc_map; glibtop_mountlist mountlist; glibtop_fsusage fsusage; + glibtop_netlist netlist; glibtop_netload netload; glibtop_ppp ppp; }; diff --git a/include/glibtop/version.h b/include/glibtop/version.h index 67d9ab10..90ba06df 100644 --- a/include/glibtop/version.h +++ b/include/glibtop/version.h @@ -23,9 +23,6 @@ #define __GLIBTOP_VERSION_H__ #include <glibtop.h> -#include <glibtop/union.h> -#include <glibtop/sysdeps.h> -#include <glibtop/command.h> #define LIBGTOP_VERSION_STRING "Libgtop %s server version %s (%u,%u,%u,%u)." diff --git a/src/daemon/version.c b/src/daemon/version.c index 4c121ffa..113c0170 100644 --- a/src/daemon/version.c +++ b/src/daemon/version.c @@ -24,6 +24,9 @@ #include <glibtop.h> #include <glibtop/error.h> #include <glibtop/version.h> +#include <glibtop/union.h> +#include <glibtop/command.h> + void glibtop_send_version (glibtop *server, int fd) diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index bceb2d36..00124fa6 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -9,7 +9,7 @@ libgtop_sysdeps_2_0_la_SOURCES = open.c close.c cpu.c mem.c swap.c \ proctime.c procmem.c procsignal.c prockernel.c \ procsegment.c procargs.c procmap.c siglist.c \ sysinfo.c netload.c ppp.c glibtop_server.c \ - fsusage.c + fsusage.c netlist.c libgtop_sysdeps_2_0_la_LIBADD = @GLIB_LIBS@ diff --git a/sysdeps/linux/netlist.c b/sysdeps/linux/netlist.c new file mode 100644 index 00000000..966c7729 --- /dev/null +++ b/sysdeps/linux/netlist.c @@ -0,0 +1,84 @@ +/* $Id$ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig <martin@home-of-linux.org>, 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 <config.h> +#include <glibtop/netlist.h> +#include <glibtop/error.h> + +#include <stdio.h> + + +static const unsigned long _glibtop_sysdeps_netlist = (1 << GLIBTOP_NETLIST_NUMBER); + +/* Init function. */ + +void +glibtop_init_netlist_s (glibtop *server) +{ + server->sysdeps.netlist = _glibtop_sysdeps_netlist; +} + + +char** +glibtop_get_netlist_s (glibtop *server, glibtop_netlist *buf) +{ + char line[1024]; + FILE *f; + GPtrArray *devices; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_NETLIST, 0); + + memset (buf, 0, sizeof (glibtop_netlist)); + + f = fopen("/proc/net/dev", "r"); + + if(!f) + { + glibtop_warn_io_r (server, "cannot open \"/proc/net/dev\""); + return NULL; + } + + devices = g_ptr_array_new(); + + while(fgets(line, sizeof line, f)) + { + char *sep = strchr(line, ':'); + + if(!sep) continue; + + *sep = '\0'; /* truncate : we only need the name */ + + g_strstrip(line); + g_ptr_array_add(devices, g_strdup(line)); + buf->number++; + } + + fclose(f); + + buf->flags = _glibtop_sysdeps_netlist; + + g_ptr_array_add(devices, NULL); + + return g_ptr_array_free(devices, FALSE); +} + diff --git a/sysdeps/names/Makefile.am b/sysdeps/names/Makefile.am index 8cbc4501..86c37786 100644 --- a/sysdeps/names/Makefile.am +++ b/sysdeps/names/Makefile.am @@ -9,7 +9,7 @@ libgtop_names_2_0_la_SOURCES = cpu.c mem.c swap.c uptime.c loadavg.c \ proctime.c procmem.c procsignal.c \ prockernel.c procsegment.c fsusage.c \ mountlist.c procargs.c procmap.c netload.c \ - ppp.c + ppp.c netlist.c libgtop_names_2_0_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/names/netlist.c b/sysdeps/names/netlist.c new file mode 100644 index 00000000..5aefaaef --- /dev/null +++ b/sysdeps/names/netlist.c @@ -0,0 +1,42 @@ +/* Copyright (C) 2004 Benoît Dejean + This file is part of LibGTop 2.0. + + 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 <glibtop/netlist.h> +#include "libgtop-i18n.h" + +const char *glibtop_names_netlist [GLIBTOP_MAX_NETLIST] = +{ + "number" +}; + +const unsigned glibtop_types_netlist [GLIBTOP_MAX_NETLIST] = +{ + GLIBTOP_TYPE_ULONG +}; + +const char *glibtop_labels_netlist [GLIBTOP_MAX_NETLIST] = +{ + N_("Number"), +}; + +const char *glibtop_descriptions_netlist [GLIBTOP_MAX_NETLIST] = +{ + N_("Number of network devices found"), +}; + diff --git a/sysdeps/solaris/Makefile.am b/sysdeps/solaris/Makefile.am index f65247fb..181111f5 100644 --- a/sysdeps/solaris/Makefile.am +++ b/sysdeps/solaris/Makefile.am @@ -8,7 +8,7 @@ libgtop_sysdeps_2_0_la_SOURCES = open.c close.c siglist.c cpu.c mem.c \ proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c \ prockernel.c procsegment.c procargs.c \ - procmap.c netload.c ppp.c procdata.c + procmap.c netload.c ppp.c procdata.c netlist.c libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/solaris/netlist.c b/sysdeps/solaris/netlist.c new file mode 100644 index 00000000..6276a9a8 --- /dev/null +++ b/sysdeps/solaris/netlist.c @@ -0,0 +1,68 @@ +/* Copyright (C) 1998-99 Benoît Dejean + This file is part of LibGTop 2.0. + + 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 <string.h> +#include <kstat.h> + +#include <glibtop/netlist.h> + + + +static const unsigned long _glibtop_sysdeps_netlist = (1 << GLIBTOP_NETLIST_NUMBER); + +/* Init function. */ + +void +glibtop_init_netlist_s (glibtop *server) +{ + server->sysdeps.netlist = _glibtop_sysdeps_netlist; +} + + +char** +glibtop_get_netlist_s (glibtop *server, glibtop_netlist *buf) +{ + GPtrArray *devices; + kstat_t *ksp; + kstat_ctl_t *kc; + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_NETLIST, 0); + + memset (buf, 0, sizeof (glibtop_netlist)); + + devices = g_ptr_array_new(); + + kc = kstat_open(); + + for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) + { + if (strcmp(ksp->ks_class, "net") != 0) + continue; + + g_ptr_array_add(devices, g_strdup(ksp->ks_name)); + } + + kstat_close(kc); + + buf->flags = _glibtop_sysdeps_netlist; + + g_ptr_array_add(devices, NULL); + + return (char**) g_ptr_array_free(devices, FALSE); +} |