Changeset - 8dabe557e169
[Not reviewed]
default
0 3 0
Nathan Brink (binki) - 16 years ago 2009-11-16 23:40:30
ohnobinki@ohnopublishing.net
prepare remoteio for TCP, stubs
3 files changed with 29 insertions and 12 deletions:
0 comments (0 inline, 0 general)
configure.ac
Show inline comments
 
@@ -13,13 +13,13 @@
 
# 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/>.
 

	
 
AC_PREREQ(2.61)
 
AC_INIT([distren],[0.0],[ohnobinki@ohnopublishing.net])
 
AC_INIT([distren],[0.0],[http://bugs.ohnopub.net/])
 
AC_CONFIG_SRCDIR([src/server/distrend.c])
 

	
 
AC_PROG_CC
 
AC_PROG_LIBTOOL
 
#AC_PROG_RANLIB #don't add this even if autoscan says to, because AC_PROG_LIBTOOL is enough
 

	
src/common/libremoteio.h
Show inline comments
 
@@ -30,15 +30,15 @@
 
enum remoteio_method
 
  {
 
    REMOTEIO_METHOD_SSH = 0,
 
#ifndef WINDOWS
 
    REMOTEIO_METHOD_UNIX = 1,
 
#endif
 
    /*    REMOTEIO_METHOD_TCP */ /*< someday, maybe */
 
    /*    REMOETIO_METHOD_XMLRPC */ /*< again, maybe someday */
 
    REMOTEIO_METHOD_MAX = 2 /*< This is a number used to check the consitency of remoteio_server structs */
 
    REMOTEIO_METHOD_TCP = 2,
 
    /*    REMOETIO_METHOD_XMLRPC */ /*< maybe someday */
 
    REMOTEIO_METHOD_MAX = 3 /*< This is a number used to check the consitency of remoteio_server structs */
 
  };
 

	
 
struct remoteio_server
 
{
 
  struct remoteio_server *next;
 
  char *name; /*< The friendly named passed to remoteio_open() */
src/common/remoteio.c
Show inline comments
 
@@ -36,19 +36,20 @@
 
int _remoteio_ssh_open(struct remoteio *rem, struct remoteio_server *server);
 
int _remoteio_ssh_read(struct remoteio *rem, void *buf, size_t len, size_t *bytesread);
 
int _remoteio_ssh_write(struct remoteio *rem, void *buf, size_t len, size_t *byteswritten);
 
int _remoteio_ssh_close(struct remoteio *rem);
 

	
 
#ifndef WINDOWS
 

	
 
int _remoteio_sock_open(struct remoteio *rem, struct remoteio_server *server);
 
int _remoteio_sock_close(struct remoteio *rem);
 
#endif
 
int _remoteio_sock_read(struct remoteio *rem, void *buf, size_t len, size_t *bytesread);
 
int _remoteio_sock_write(struct remoteio *rem, void *buf, size_t len, size_t *byteswritten);
 
int _remoteio_sock_close(struct remoteio *rem);
 

	
 
#endif
 
int _remoteio_tcp_open(struct remoteio *rem, struct remoteio_server *server);
 
int _remoteio_tcp_close(struct remoteio *rem);
 

	
 
/**
 
  lookup table for different methods of remoteio:
 
  the enum remoteio_method is the index of the entry to use for that method. 
 
  Regardless, a NULL terminator is required because the configuration function
 
  searches through this table for the method specified in the config file.
 
@@ -57,12 +58,13 @@ struct remoteio_method_funcmap funcmap[]
 
  {
 
    /* [REMOTEIO_METHOD_SSH] */
 
    {REMOTEIO_METHOD_SSH, &_remoteio_ssh_open, &_remoteio_ssh_read, &_remoteio_ssh_write, &_remoteio_ssh_close, "ssh"},
 
#ifndef WINDOWS
 
    {REMOTEIO_METHOD_UNIX, &_remoteio_sock_open, &_remoteio_sock_read, &_remoteio_sock_write, &_remoteio_sock_close, "unix"},
 
#endif
 
    {REMOTEIO_METHOD_TCP, &_remoteio_tcp_open, &_remoteio_sock_read, &_remoteio_sock_write, &_remoteio_tcp_close, "tcp"},
 
    {REMOTEIO_METHOD_MAX, NULL, NULL, NULL, NULL, NULL}
 
  };
 

	
 
struct remoteio_server *remoteio_getserver(const struct remoteio_opts *opts, const char *servername);
 

	
 
int remoteio_config(cfg_t *cfg, struct remoteio_opts *opts)
 
@@ -309,12 +311,21 @@ int _remoteio_sock_open(struct remoteio 
 

	
 
  rem->sock = sock;
 

	
 
  return 0;
 
}
 

	
 
int _remoteio_sock_close(struct remoteio *rem)
 
{
 
  close(rem->sock);
 

	
 
  return 0;
 
}
 

	
 
#endif
 

	
 
int _remoteio_sock_read(struct remoteio *rem, void *buf, size_t len, size_t *bytesread)
 
{
 
  ssize_t readrtn;
 

	
 
  readrtn = read(rem->sock, buf, len);
 
  /*
 
@@ -380,14 +391,20 @@ int _remoteio_sock_write(struct remoteio
 
      return 1;
 
    }
 

	
 
  return 0;
 
}
 

	
 
int _remoteio_sock_close(struct remoteio *rem)
 
/**
 
   TCP, taking advantage of the two generic socks read/write functions:
 
 */
 
int _remoteio_tcp_open(struct remoteio *rem, struct remoteio_server *server)
 
{
 
  close(rem->sock);
 

	
 
  return 0;
 
  
 
  return 1;
 
}
 

	
 
#endif
 
int _remoteio_tcp_close(struct remoteio *rem)
 
{
 

	
 
  return 1;
 
}
0 comments (0 inline, 0 general)