diff options
author | Martin Baulig <martin@src.gnome.org> | 1999-12-26 14:05:32 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 1999-12-26 14:05:32 +0000 |
commit | f1a6e1ead8fde4b03f3fcb9ea1e1635185bc7d10 (patch) | |
tree | 6d9b7ef9252e719fbb49368a10542eb7af09089d /src/daemon/io.c | |
parent | d7f088bef0e858550e5ae6890082e962fc5697ad (diff) | |
download | libgtop-f1a6e1ead8fde4b03f3fcb9ea1e1635185bc7d10.tar.gz |
The indentation in LibGTop was done with the following command:
find . -name \*.[ch] | xargs -i emacs -batch {} \
-l /gnome/compile/libgtop/misc/format.el -f save-buffer
December 26, 1999
Martin
Diffstat (limited to 'src/daemon/io.c')
-rw-r--r-- | src/daemon/io.c | 116 |
1 files changed, 59 insertions, 57 deletions
diff --git a/src/daemon/io.c b/src/daemon/io.c index 1d6c56e0..9c51de27 100644 --- a/src/daemon/io.c +++ b/src/daemon/io.c @@ -1,3 +1,5 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + /* $Id$ */ /* Copyright (C) 1998-99 Martin Baulig @@ -28,80 +30,80 @@ do_output (int s, glibtop_response *resp, off_t offset, size_t data_size, const void *data, int retval) { #ifdef REAL_DEBUG - fprintf (stderr, "Really writing %d bytes at offset %lu.\n", - sizeof (glibtop_response), offset); + fprintf (stderr, "Really writing %d bytes at offset %lu.\n", + sizeof (glibtop_response), offset); #endif - resp->offset = offset; - resp->data_size = data_size; + resp->offset = offset; + resp->data_size = data_size; - if (s == 0) { - if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0) - glibtop_warn_io ("write"); - } else { - if (send (s, (const void *) resp, sizeof (glibtop_response), 0) < 0) - glibtop_warn_io ("send"); - } + if (s == 0) { + if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0) + glibtop_warn_io ("write"); + } else { + if (send (s, (const void *) resp, sizeof (glibtop_response), 0) < 0) + glibtop_warn_io ("send"); + } - if (s == 0) { - if (write (1, &retval, sizeof (int)) < 0) - glibtop_warn_io ("write retval"); - } else { - if (send (s, &retval, sizeof (int), 0) < 0) - glibtop_warn_io ("send retval"); - } + if (s == 0) { + if (write (1, &retval, sizeof (int)) < 0) + glibtop_warn_io ("write retval"); + } else { + if (send (s, &retval, sizeof (int), 0) < 0) + glibtop_warn_io ("send retval"); + } - if (resp->data_size) { + if (resp->data_size) { #ifdef REAL_DEBUG - fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size); + fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size); #endif - if (s == 0) { - if (write (1, data, resp->data_size) < 0) - glibtop_warn_io ("write"); - } else { - if (send (s, data, resp->data_size, 0) < 0) - glibtop_warn_io ("send"); - } + if (s == 0) { + if (write (1, data, resp->data_size) < 0) + glibtop_warn_io ("write"); + } else { + if (send (s, data, resp->data_size, 0) < 0) + glibtop_warn_io ("send"); } + } } int do_read (int s, void *ptr, size_t total_size) { - int nread; - char *tmp_ptr; - size_t already_read = 0, remaining = total_size; - - while (already_read < total_size) { - if (s) - nread = recv (s, ptr, remaining, 0); - else - nread = read (0, ptr, remaining); - - if ((already_read == 0) && (nread == 0)) { - glibtop_warn ("pid %d received eof.", getpid ()); - return 0; - } - - if (nread <= 0) { - glibtop_warn_io ("recv"); - return 0; - } - - already_read += nread; - remaining -= nread; - /* (char *) ptr += nread; */ - tmp_ptr = ptr; - tmp_ptr += nread; - ptr = tmp_ptr; + int nread; + char *tmp_ptr; + size_t already_read = 0, remaining = total_size; + + while (already_read < total_size) { + if (s) + nread = recv (s, ptr, remaining, 0); + else + nread = read (0, ptr, remaining); + + if ((already_read == 0) && (nread == 0)) { + glibtop_warn ("pid %d received eof.", getpid ()); + return 0; + } + + if (nread <= 0) { + glibtop_warn_io ("recv"); + return 0; + } + + already_read += nread; + remaining -= nread; + /* (char *) ptr += nread; */ + tmp_ptr = ptr; + tmp_ptr += nread; + ptr = tmp_ptr; #ifdef REAL_DEBUG - fprintf (stderr, "READ (%d): %d - %d - %d\n", - nread, already_read, remaining, total_size); + fprintf (stderr, "READ (%d): %d - %d - %d\n", + nread, already_read, remaining, total_size); #endif - } + } - return already_read; + return already_read; } |