Changeset - 73f6134ccb23
[Not reviewed]
default
0 5 0
Nathan Brink (binki) - 15 years ago 2010-07-29 21:20:27
ohnobinki@ohnopublishing.net
Add some consts to remoteio's callbacks.
5 files changed with 22 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/common/execio.c
Show inline comments
 
@@ -165,7 +165,7 @@ int _execio_checkpid(struct execio *eio)
 
}
 

	
 

	
 
int execio_read(struct execio *eio, void *buf, size_t len, size_t *bytesread)
 
int execio_read(struct execio *eio, const void *buf, size_t len, size_t *bytesread)
 
{
 
  ssize_t ret;
 
  /*
 
@@ -203,7 +203,7 @@ int execio_read(struct execio *eio, void
 
  return 0;
 
}
 

	
 
int execio_write(struct execio *eio, void *buf, size_t len, size_t *bytesread)
 
int execio_write(struct execio *eio, const void *buf, size_t len, size_t *bytesread)
 
{
 
  errno = 0;
 
  (*bytesread) = write(eio->pipe_write, buf, len);
src/common/execio.h
Show inline comments
 
@@ -54,8 +54,8 @@ int execio_open(struct execio **eio, con
 
   doesn't block,
 
   returns 0 on success, 1 on failure
 
*/
 
int execio_read(struct execio *eio, void *buf, size_t len, size_t *bytesread);
 
int execio_write(struct execio *eio, void *buf, size_t len, size_t *byteswritten);
 
int execio_read(struct execio *eio, const void *buf, size_t len, size_t *bytesread);
 
int execio_write(struct execio *eio, const void *buf, size_t len, size_t *byteswritten);
 

	
 
/**
 
  use this function to determine if the using program should keep trying to read/write
src/common/libremoteio.h
Show inline comments
 
@@ -117,7 +117,7 @@ struct remoteio
 
/* lookup table */
 
typedef int remoteio_open_func_t(struct remoteio *rem, struct remoteio_server *server);
 
typedef int remoteio_read_func_t(struct remoteio *rem, void *buf, size_t len, size_t *bytesread);
 
typedef int remoteio_write_func_t(struct remoteio *rem, void *buf, size_t len, size_t *bytesread);
 
typedef int remoteio_write_func_t(struct remoteio *rem, const void *buf, size_t len, size_t *bytesread);
 
typedef int remoteio_close_func_t(struct remoteio *rem);
 

	
 
struct remoteio_method_funcmap
src/common/remoteio.c
Show inline comments
 
@@ -65,7 +65,7 @@ int _remoteio_handle_read(multiio_contex
 

	
 
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_write(struct remoteio *rem, const void *buf, size_t len, size_t *byteswritten);
 
int _remoteio_ssh_close(struct remoteio *rem);
 

	
 
/**
 
@@ -76,7 +76,7 @@ int _remoteio_sock_open(struct remoteio 
 
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_write(struct remoteio *rem, const void *buf, size_t len, size_t *byteswritten);
 

	
 
/**
 
   These borrow from _remoteio_sock_read() and _remoteio_sock_write().
 
@@ -361,7 +361,8 @@ int remoteio_write(struct remoteio *rem,
 
{
 
  struct remoteio_packet *packet;
 
  struct pollfd pollfd;
 
  ssize_t bytes_written;
 
  size_t bytes_written;
 
  int err;
 

	
 
  /**
 
   * This is probably about the only optimization that exists in
 
@@ -378,7 +379,7 @@ int remoteio_write(struct remoteio *rem,
 
      poll(&pollfd, 1, 0);
 
      if(pollfd.events & POLLOUT)
 
	{
 
	  bytes_written = write(rem->sock, buf, len);
 
	  err = funcmap[rem->method].write_func(rem, buf, len, &bytes_written);
 
	  if(bytes_written > 0)
 
	    {
 
	      len -= bytes_written;
 
@@ -544,8 +545,10 @@ struct remoteio_server *remoteio_getserv
 
  return (struct remoteio_server *)NULL;
 
}
 

	
 

	
 

	
 
size_t remoteio_sendq_len(const struct remoteio *rem)
 
{
 
  return (size_t)q_size(rem->outmsgs);
 
}
 

	
 
/**
 
   different remoteio methods' implementations:
 
@@ -585,7 +588,7 @@ int _remoteio_ssh_read(struct remoteio *
 
  return execio_read(rem->execio, buf, len, bytesread);
 
}
 

	
 
int _remoteio_ssh_write(struct remoteio *rem, void *buf, size_t len, size_t *byteswritten)
 
int _remoteio_ssh_write(struct remoteio *rem, const void *buf, size_t len, size_t *byteswritten)
 
{
 
  return execio_write(rem->execio, buf, len, byteswritten);
 
}
 
@@ -695,7 +698,7 @@ int _remoteio_sock_read(struct remoteio 
 
  return 0;
 
}
 

	
 
int _remoteio_sock_write(struct remoteio *rem, void *buf, size_t len, size_t *byteswritten)
 
int _remoteio_sock_write(struct remoteio *rem, const void *buf, size_t len, size_t *byteswritten)
 
{
 
  ssize_t writertn;
 

	
src/common/remoteio.h
Show inline comments
 
@@ -129,4 +129,10 @@ int remoteio_write(struct remoteio *rem,
 
*/
 
int remoteio_close(struct remoteio *rem);
 

	
 
/**
 
 * Returns the number of unfulfilled remoteio_write() calls pending on
 
 * a remoteio handle.
 
 */
 
size_t remoteio_sendq_len(const struct remoteio *rem);
 

	
 
#endif
0 comments (0 inline, 0 general)