Files
@ 92659c5651ef
Branch filter:
Location: DistRen/src/common/libremoteio.h
92659c5651ef
3.7 KiB
text/plain
Reformed buildsystem.
- replace malloc.h with stdlib.h
- use AC_CONFIG_HEADERS for cleaner compile output
- clean out some useless AC_* macros and add useful AC_TYPE_UINT* macros
- replace malloc.h with stdlib.h
- use AC_CONFIG_HEADERS for cleaner compile output
- clean out some useless AC_* macros and add useful AC_TYPE_UINT* macros
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | /*
Copyright 2010 Nathan Phillip Brink
This file is a part of DistRen.
DistRen is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DistRen is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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_LIBREMOTEIO_H
#define _DISTREN_LIBREMOTEIO_H
#include "common/multiio.h"
#include "common/remoteio.h"
#include <confuse.h>
#include <list.h>
#include <queue.h>
/**
private declarations for remoteio, to be included by options.c and remoteio.c
*/
enum remoteio_method
{
REMOTEIO_METHOD_SSH = 0,
#ifndef WINDOWS
REMOTEIO_METHOD_UNIX = 1,
#endif
REMOTEIO_METHOD_TCP = 2,
/* REMOETIO_METHOD_XMLRPC */ /*< maybe someday */
/** method for the remoteio_open_socket() function, where we don't call open() ourselves: */
REMOTEIO_METHOD_SOCKET = 3,
REMOTEIO_METHOD_MAX = 4 /*< This is a number used to check the consitency of remoteio_server structs */
};
struct remoteio_server
{
char *name; /*< The friendly named passed to remoteio_open() */
char *hostname;
char *username;
enum remoteio_method method;
unsigned int types; /*< See ``Server types'' in protocol.h */
};
struct remoteio_opts
{
char *ssh_command;
list_t servers; /* type: (struct remoteio_server *) */
/* store the multiio context for general use */
multiio_context_t multiio;
/* store remoteio's socket_type */
multiio_socket_type_t socket_type;
/* an argument for the remoteio_read_handle_func_t */
void *generic_handler_data;
};
/**
* Used to describe the nature of the data stored in the
* outbound and message queues that power remoteio_write()
* and remoteio_read() (?).
*/
struct remoteio_packet
{
size_t len;
char *data;
};
struct remoteio
{
enum remoteio_method method;
struct remoteio_opts *opts;
struct execio *execio;
#ifndef WINDOWS
int sock;
#endif
remoteio_read_handle_func_t read_handler;
/* for the read_handler */
void *read_handler_data;
/* so that read_handler_data can be cleaned up */
remoteio_close_handle_func_t close_handler;
/**
* Store a buffer of data waiting to be processed.
*/
struct remoteio_packet inbuf;
/**
* Provide the asynchronosity abstraction by queuing outgoing messages.
*/
queue_t outmsgs;
/**
* This is disappointingly hacky. If this variable is 0, then
* remoteio_close() will act normal. If set to 1, then
* remoteio_close() will not actually free this struct but instead
* increment this variable to 2. This is so that read_handler can
* call remoteio_close() without segfaulting us.
*/
short careful_free;
};
/* 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_close_func_t(struct remoteio *rem);
struct remoteio_method_funcmap
{
enum remoteio_method method;
remoteio_open_func_t *open_func;
remoteio_read_func_t *read_func;
remoteio_write_func_t *write_func;
remoteio_close_func_t *close_func;
char *name; /*< used for error messages */
};
int remoteio_config(cfg_t *cfg, struct remoteio_opts *opts);
#endif
|