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.
This commit is contained in:
Benoît Dejean
2004-11-13 00:53:20 +00:00
parent fdf313cdf6
commit 7e5ccec8bf
19 changed files with 370 additions and 15 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -20,4 +20,6 @@ procargs
procargs_static
df
df_static
netlist
netlist_static

View File

@@ -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

46
examples/netlist.c Normal file
View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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

View File

@@ -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

71
include/glibtop/netlist.h Normal file
View File

@@ -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

View File

@@ -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 */
};

View File

@@ -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;
};

View File

@@ -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)."

View File

@@ -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)

View File

@@ -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@

84
sysdeps/linux/netlist.c Normal file
View File

@@ -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);
}

View File

@@ -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)

42
sysdeps/names/netlist.c Normal file
View File

@@ -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"),
};

View File

@@ -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)

68
sysdeps/solaris/netlist.c Normal file
View File

@@ -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);
}