# HG changeset patch # User Binki # Date 2009-02-22 21:00:46 # Node ID fc615c13faaa0a07e3c3b5477b954fab3bc77d5c # Parent 3e1c191605ceeb03befb2aa76ec49683e0551138 renamed remoteio to execio, added to execio api diff --git a/src/common/Makefile.am b/src/common/Makefile.am --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -1,6 +1,6 @@ pkglib_LTLIBRARIES = libdistren.la -libdistren_la_SOURCES = options.c options.h remoteio.h remoteio.c +libdistren_la_SOURCES = options.c options.h execio.h execio.c #evidently the following should not be LDADD, but LDFLAGS because automake doesn't like the idea of LDADD for libraries for some reason... or I am very confused libdistren_la_LIBADD = @DISTLIBS_LIBS@ libdistren_la_CXXFLAGS = @DISTLIBS_CFLAGS@ diff --git a/src/common/remoteio.c b/src/common/execio.c rename from src/common/remoteio.c rename to src/common/execio.c --- a/src/common/remoteio.c +++ b/src/common/execio.c @@ -17,7 +17,7 @@ along with DistRen. If not, see . */ -#include "remoteio.h" +#include "execio.h" #include #include @@ -26,7 +26,7 @@ #include #include -int remoteio_open(const char *spec, struct remoteio **rem) +int execio_open(const char *progname, struct execio **rem) { /* pipe used to write to child */ int pipe_write[2]; @@ -66,8 +66,8 @@ int remoteio_open(const char *spec, stru close(pipe_write[0]); close(pipe_read[1]); - /* setup remoteio struct */ - (*rem) = malloc(sizeof(struct remoteio)); + /* setup execio struct */ + (*rem) = malloc(sizeof(struct execio)); if(!(*rem)) { /* we should tell the child we're dead - use wait and close our end of the pipes! */ @@ -123,20 +123,20 @@ int remoteio_open(const char *spec, stru } -size_t remoteio_read(struct remoteio *rem, void *buf, size_t len) +size_t execio_read(struct execio *eio, void *buf, size_t len) { return 0; } -size_t remoteio_write(struct remoteio *rem, void *buf, size_t len) +size_t execio_write(struct execio *eio, void *buf, size_t len) { return 0; } -int remoteio_close(struct remoteio *rem) +int execio_close(struct execio *eio) { return 0; diff --git a/src/common/remoteio.h b/src/common/execio.h rename from src/common/remoteio.h rename to src/common/execio.h --- a/src/common/remoteio.h +++ b/src/common/execio.h @@ -17,16 +17,23 @@ along with DistRen. If not, see . */ -#ifndef _DISTREN_REMOTEIO_H -#define _DISTREN_REMOTEIO_H +#ifndef _DISTREN_EXECIO_H +#define _DISTREN_EXECIO_H /* - This file tries to abstract away getting a socket/fd that talks to a remote service + This file tries to abstract away getting a socket/fd that talks to a spawned program */ #include -struct remoteio +enum execio_state + { + EXECIO_STATE_ERROR, + EXECIO_STATE_EOF + }; + + +struct execio { int pipe_write; int pipe_read; @@ -35,14 +42,19 @@ struct remoteio }; /* nonzsero return on error */ -int remoteio_open(const char *spec, struct remoteio **rem); +int execio_open(const char *spec, struct execio **eio); -/* blocks, returns 0 if len is 0 or on error */ -size_t remoteio_read(struct remoteio *rem, void *buf, size_t len); -size_t remoteio_write(struct remoteio *rem, void *buf, size_t len); +/* + blocks, + returns 0 if len is 0. Otherwise, only returns 0 on error/EOF: use execio_state() to determine +*/ +size_t execio_read(struct execio *eio, void *buf, size_t len); +size_t execio_write(struct execio *eio, void *buf, size_t len); + +enum execio_state execio_state(struct execio *eio); /* nonzero return on error */ -int remoteio_close(struct remoteio *rem); +int execio_close(struct execio *eio); #endif