Changeset - fc615c13faaa
[Not reviewed]
default
2 1 2
Nathan Brink (binki) - 17 years ago 2009-02-22 21:00:46
ohnobinki@ohnopublishing.net
renamed remoteio to execio, added to execio api
3 files changed with 29 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/common/Makefile.am
Show inline comments
 
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@
src/common/execio.c
Show inline comments
 
file renamed from src/common/remoteio.c to src/common/execio.c
 
@@ -14,22 +14,22 @@
 
  GNU Affero General Public License for more details.
 

	
 
  You should have received a copy of the GNU Affero General Public License
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include "remoteio.h"
 
#include "execio.h"
 

	
 
#include <unistd.h>
 
#include <sys/types.h>
 
#include <sys/wait.h>
 
#include <signal.h>
 
#include <malloc.h>
 
#include <stdio.h>
 

	
 
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];
 
  /* pipe used to read from child */
 
  int pipe_read[2];
 

	
 
@@ -63,14 +63,14 @@ int remoteio_open(const char *spec, stru
 
  if(child)
 
    {
 
      /* close sides of pipe we won't use */
 
      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! */
 
	  close(pipe_write[1]);
 
	  close(pipe_read[0]);
 
	  /* we should probably pass of the wait() call to a thread that just does boring things like that. Especially for when the server tries to connect to other servers... */
 
@@ -120,25 +120,25 @@ int remoteio_open(const char *spec, stru
 

	
 
      return 1; /* this line should never be reached because we exec*/
 
    }
 
}
 

	
 

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

	
src/common/execio.h
Show inline comments
 
file renamed from src/common/remoteio.h to src/common/execio.h
 
@@ -14,35 +14,47 @@
 
  GNU Affero General Public License for more details.
 

	
 
  You should have received a copy of the GNU Affero General Public License
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#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 <unistd.h>
 

	
 
struct remoteio
 
enum execio_state
 
  {
 
    EXECIO_STATE_ERROR,
 
    EXECIO_STATE_EOF
 
  };
 
  
 

	
 
struct execio
 
{
 
  int pipe_write;
 
  int pipe_read;
 
  
 
  pid_t child;
 
};
 

	
 
/* 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
 

	
0 comments (0 inline, 0 general)