summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin@home-of-linux.org>1999-12-19 15:07:13 +0000
committerMartin Baulig <martin@src.gnome.org>1999-12-19 15:07:13 +0000
commitd4b712db86c22ec44926fba76a418e98778b4e4e (patch)
treeb5b73a62e3cfa265f7b8d6a4ab21107c3d92f778
parent339e1f4557a89739e56ef2e4bf81ad22fcaadd35 (diff)
downloadlibgtop-d4b712db86c22ec44926fba76a418e98778b4e4e.tar.gz
New file. This is a private header file which defines `struct
1999-12-19 Martin Baulig <martin@home-of-linux.org> * glibtop-server-private.h: New file. This is a private header file which defines `struct _glibtop_server_private'. * glibtop.h (glibtop): Added `glibtop_server_private *_priv' field and moved some private fields there.
-rw-r--r--ChangeLog8
-rw-r--r--Makefile.am2
-rw-r--r--glibtop-server-private.h42
-rw-r--r--glibtop.h39
-rw-r--r--lib/close.c8
-rw-r--r--lib/open.c28
-rw-r--r--lib/read.c6
-rw-r--r--lib/read_data.c14
-rw-r--r--lib/write.c6
9 files changed, 96 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index c132ab91..75253ca4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+1999-12-19 Martin Baulig <martin@home-of-linux.org>
+
+ * glibtop-server-private.h: New file. This is a private header
+ file which defines `struct _glibtop_server_private'.
+
+ * glibtop.h (glibtop): Added `glibtop_server_private *_priv' field
+ and moved some private fields there.
+
1999-12-12 Martin Baulig <martin@home-of-linux.org>
* include/glibtop/procargs.h (glibtop_proc_args): Removed.
diff --git a/Makefile.am b/Makefile.am
index bebdf246..82a4fc3e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,6 +10,8 @@ SUBDIRS = po intl $(support) macros misc include sysdeps lib src doc \
include_HEADERS = glibtop.h
configincludedir = $(pkglibdir)/include
+noinst_HEADERS = glibtop-server-private.h
+
EXTRA_DIST = autogen.sh libgtop.spec.in copyright.txt libgtopConf.sh.in \
LIBGTOP-VERSION features.def structures.def libgtop-config.in \
RELNOTES-0.25 RELNOTES-1.0 RELNOTES-1.1.x libgtop-sysdeps.m4 README \
diff --git a/glibtop-server-private.h b/glibtop-server-private.h
new file mode 100644
index 00000000..129a6800
--- /dev/null
+++ b/glibtop-server-private.h
@@ -0,0 +1,42 @@
+/* $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.
+*/
+
+#ifndef __GLIBTOP_SERVER_PRIVATE_H__
+#define __GLIBTOP_SERVER_PRIVATE_H__
+
+#ifdef HAVE_GLIBTOP_MACHINE_H
+#include <glibtop_machine.h>
+#endif
+
+struct _glibtop_server_private
+{
+#ifdef HAVE_GLIBTOP_MACHINE_H
+ glibtop_machine machine; /* Machine dependent data */
+#endif
+ int input [2]; /* Pipe client <- server */
+ int output [2]; /* Pipe client -> server */
+ int socket; /* Accepted connection of a socket */
+ pid_t pid; /* PID of the server */
+};
+
+#endif
diff --git a/glibtop.h b/glibtop.h
index 1ff0006d..39e5b11f 100644
--- a/glibtop.h
+++ b/glibtop.h
@@ -34,27 +34,24 @@
#include <glibtop_server.h>
#include <glibtop/types.h>
-#ifdef HAVE_GLIBTOP_MACHINE_H
-#include <glibtop_machine.h>
-#endif
+BEGIN_LIBGTOP_DECLS
-typedef struct _glibtop glibtop;
+typedef struct _glibtop glibtop;
+typedef struct _glibtop_server_private glibtop_server_private;
#include <glibtop/sysdeps.h>
#include <glibtop/errors.h>
+#ifdef _IN_LIBGTOP
+#include <glibtop-server-private.h>
+#endif
+
struct _glibtop
{
int refcount; /* Reference count */
unsigned flags;
unsigned method; /* Server Method */
unsigned error_method; /* Error Method */
-#ifdef HAVE_GLIBTOP_MACHINE_H
- glibtop_machine machine; /* Machine dependent data */
-#endif
- int input [2]; /* Pipe client <- server */
- int output [2]; /* Pipe client -> server */
- int socket; /* Accepted connection of a socket */
int ncpu; /* Number of CPUs, zero if single-processor */
unsigned long os_version_code; /* Version code of the operating system */
const char *name; /* Program name for error messages */
@@ -67,7 +64,7 @@ struct _glibtop
glibtop_sysdeps sysdeps; /* Detailed feature list */
glibtop_sysdeps required; /* Required feature list */
glibtop_sysdeps wanted; /* We only want this features */
- pid_t pid; /* PID of the server */
+ glibtop_server_private *_priv; /* Private data */
};
extern glibtop *glibtop_global_server;
@@ -94,24 +91,6 @@ glibtop_server_ref (glibtop *server);
void
glibtop_server_unref (glibtop *server);
-#ifdef GLIBTOP_GUILE
-
-/* You need to link with -lgtop_guile to get this stuff here. */
-
-void glibtop_boot_guile (void);
-
-#endif
-
-#ifdef GLIBTOP_GUILE_NAMES
-
-/* You need to link with -lgtop_guile_names to get this stuff here. */
-
-void glibtop_boot_guile_names (void);
-
-#ifndef GLIBTOP_NAMES
-#define GLIBTOP_NAMES
-#endif
-
-#endif
+END_LIBGTOP_DECLS
#endif
diff --git a/lib/close.c b/lib/close.c
index a0c3b619..4fe47088 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -37,14 +37,14 @@ glibtop_close_r (glibtop *server)
glibtop_call_l (server, GLIBTOP_CMND_QUIT,
0, NULL, 0, NULL, NULL);
- if (close (server->socket))
+ if (close (server->_priv->socket))
glibtop_warn_io ("close");
break;
case GLIBTOP_METHOD_PIPE:
- kill (server->pid, SIGKILL);
- close (server->input [0]);
- close (server->output [1]);
+ kill (server->_priv->pid, SIGKILL);
+ close (server->_priv->input [0]);
+ close (server->_priv->output [1]);
break;
}
}
diff --git a/lib/open.c b/lib/open.c
index e6046a74..e53c9be3 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -38,6 +38,10 @@ glibtop_open_l (glibtop *server, const char *program_name,
{
int connect_type;
+ if (!server->_priv)
+ server->_priv = glibtop_calloc_r
+ (server, 1, sizeof (glibtop_server_private));
+
server->name = program_name;
/* It is important to set _GLIBTOP_INIT_STATE_OPEN here when we
@@ -66,7 +70,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
connect_type = glibtop_make_connection
(server->server_host, server->server_port,
- &server->socket);
+ &server->_priv->socket);
#ifdef DEBUG
fprintf (stderr, "Connect Type is %d.\n", connect_type);
@@ -82,7 +86,7 @@ glibtop_open_l (glibtop *server, const char *program_name,
#endif
connect_type = glibtop_make_connection
- ("unix", 0, &server->socket);
+ ("unix", 0, &server->_priv->socket);
#ifdef DEBUG
fprintf (stderr, "Connect Type is %d.\n", connect_type);
@@ -98,26 +102,28 @@ glibtop_open_l (glibtop *server, const char *program_name,
LIBGTOP_SERVER);
#endif
- if (pipe (server->input) || pipe (server->output))
+ if (pipe (server->_priv->input) ||
+ pipe (server->_priv->output))
glibtop_error_io_r (server, "cannot make a pipe");
- server->pid = fork ();
+ server->_priv->pid = fork ();
- if (server->pid < 0) {
+ if (server->_priv->pid < 0) {
glibtop_error_io_r (server, "fork failed");
- } else if (server->pid == 0) {
+ } else if (server->_priv->pid == 0) {
close (0); close (1);
- close (server->input [0]); close (server->output [1]);
- dup2 (server->input [1], 1);
- dup2 (server->output [0], 0);
+ close (server->_priv->input [0]);
+ close (server->_priv->output [1]);
+ dup2 (server->_priv->input [1], 1);
+ dup2 (server->_priv->output [0], 0);
execl (LIBGTOP_SERVER, "libgtop-server", NULL);
glibtop_error_io_r (server, "execl (%s)",
LIBGTOP_SERVER);
_exit (2);
}
- close (server->input [1]);
- close (server->output [0]);
+ close (server->_priv->input [1]);
+ close (server->_priv->output [0]);
server->flags |= _GLIBTOP_INIT_STATE_SERVER;
diff --git a/lib/read.c b/lib/read.c
index dd6af726..6e0a0094 100644
--- a/lib/read.c
+++ b/lib/read.c
@@ -65,10 +65,10 @@ glibtop_read_l (glibtop *server, size_t size, void *buf)
fprintf (stderr, "LIBRARY: really reading %d bytes.\n", size);
#endif
- if (server->socket) {
- do_read (server->socket, buf, size);
+ if (server->_priv->socket) {
+ do_read (server->_priv->socket, buf, size);
} else {
- ret = read (server->input [0], buf, size);
+ ret = read (server->_priv->input [0], buf, size);
}
if (ret < 0)
diff --git a/lib/read_data.c b/lib/read_data.c
index 8c1bc416..57e87729 100644
--- a/lib/read_data.c
+++ b/lib/read_data.c
@@ -39,10 +39,12 @@ glibtop_read_data_l (glibtop *server)
fprintf (stderr, "LIBRARY: reading %d data bytes.\n", sizeof (size_t));
#endif
- if (server->socket) {
- ret = recv (server->socket, (void *)&size, sizeof (size_t), 0);
+ if (server->_priv->socket) {
+ ret = recv (server->_priv->socket, (void *)&size,
+ sizeof (size_t), 0);
} else {
- ret = read (server->input [0], (void *)&size, sizeof (size_t));
+ ret = read (server->_priv->input [0], (void *)&size,
+ sizeof (size_t));
}
if (ret < 0)
@@ -56,10 +58,10 @@ glibtop_read_data_l (glibtop *server)
ptr = glibtop_malloc_r (server, size);
- if (server->socket) {
- ret = recv (server->socket, ptr, size, 0);
+ if (server->_priv->socket) {
+ ret = recv (server->_priv->socket, ptr, size, 0);
} else {
- ret = read (server->input [0], ptr, size);
+ ret = read (server->_priv->input [0], ptr, size);
}
if (ret < 0)
diff --git a/lib/write.c b/lib/write.c
index 591badd2..faa6ce2a 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -38,10 +38,10 @@ glibtop_write_l (glibtop *server, size_t size, void *buf)
fprintf (stderr, "LIBRARY: really writing %d bytes.\n", size);
#endif
- if (server->socket) {
- ret = send (server->socket, buf, size, 0);
+ if (server->_priv->socket) {
+ ret = send (server->_priv->socket, buf, size, 0);
} else {
- ret = write (server->output [1], buf, size);
+ ret = write (server->_priv->output [1], buf, size);
}
if (ret < 0)