goto error;
/* let's check that we can parse the request */
- rpc_state->request = rpc->request_new();
+ rpc_state->request = rpc->request_new(rpc->request_new_arg);
if (rpc_state->request == NULL)
goto error;
/* at this point, we have a well formed request, prepare the reply */
- rpc_state->reply = rpc->reply_new();
+ rpc_state->reply = rpc->reply_new(rpc->reply_new_arg);
if (rpc_state->reply == NULL)
goto error;
/** Takes a request object and fills it in with the right magic */
static struct evrpc *
evrpc_register_object(const char *name,
- void *(*req_new)(void), void (*req_free)(void *),
+ void *(*req_new)(void*), void *req_new_arg, void (*req_free)(void *),
int (*req_unmarshal)(void *, struct evbuffer *),
- void *(*rpl_new)(void), void (*rpl_free)(void *),
+ void *(*rpl_new)(void*), void *rpl_new_arg, void (*rpl_free)(void *),
int (*rpl_complete)(void *),
void (*rpl_marshal)(struct evbuffer *, void *))
{
return (NULL);
}
rpc->request_new = req_new;
+ rpc->request_new_arg = req_new_arg;
rpc->request_free = req_free;
rpc->request_unmarshal = req_unmarshal;
rpc->reply_new = rpl_new;
+ rpc->reply_new_arg = rpl_new_arg;
rpc->reply_free = rpl_free;
rpc->reply_complete = rpl_complete;
rpc->reply_marshal = rpl_marshal;
int
evrpc_register_generic(struct evrpc_base *base, const char *name,
void (*callback)(struct evrpc_req_generic *, void *), void *cbarg,
- void *(*req_new)(void), void (*req_free)(void *),
+ void *(*req_new)(void *), void *req_new_arg, void (*req_free)(void *),
int (*req_unmarshal)(void *, struct evbuffer *),
- void *(*rpl_new)(void), void (*rpl_free)(void *),
+ void *(*rpl_new)(void *), void *rpl_new_arg, void (*rpl_free)(void *),
int (*rpl_complete)(void *),
void (*rpl_marshal)(struct evbuffer *, void *))
{
struct evrpc* rpc =
- evrpc_register_object(name, req_new, req_free, req_unmarshal,
- rpl_new, rpl_free, rpl_complete, rpl_marshal);
+ evrpc_register_object(name, req_new, req_new_arg, req_free, req_unmarshal,
+ rpl_new, rpl_new_arg, rpl_free, rpl_complete, rpl_marshal);
if (rpc == NULL)
return (-1);
evrpc_register_rpc(base, rpc,
#define EVRPC_REGISTER(base, name, request, reply, callback, cbarg) \
evrpc_register_generic(base, #name, \
(void (*)(struct evrpc_req_generic *, void *))callback, cbarg, \
- (void *(*)(void))request##_new, \
+ (void *(*)(void *))request##_new, NULL, \
(void (*)(void *))request##_free, \
(int (*)(void *, struct evbuffer *))request##_unmarshal, \
- (void *(*)(void))reply##_new, \
+ (void *(*)(void *))reply##_new, NULL, \
(void (*)(void *))reply##_free, \
(int (*)(void *))reply##_complete, \
(void (*)(struct evbuffer *, void *))reply##_marshal)
int
evrpc_register_generic(struct evrpc_base *base, const char *name,
void (*callback)(struct evrpc_req_generic *, void *), void *cbarg,
- void *(*req_new)(void), void (*req_free)(void *),
+ void *(*req_new)(void *), void *req_new_arg, void (*req_free)(void *),
int (*req_unmarshal)(void *, struct evbuffer *),
- void *(*rpl_new)(void), void (*rpl_free)(void *),
+ void *(*rpl_new)(void *), void *rpl_new_arg, void (*rpl_free)(void *),
int (*rpl_complete)(void *),
void (*rpl_marshal)(struct evbuffer *, void *));
const char* uri;
/* creates a new request structure */
- void *(*request_new)(void);
+ void *(*request_new)(void *);
+ void *request_new_arg;
/* frees the request structure */
void (*request_free)(void *);
int (*request_unmarshal)(void *, struct evbuffer *);
/* creates a new reply structure */
- void *(*reply_new)(void);
+ void *(*reply_new)(void *);
+ void *reply_new_arg;
- /* creates a new reply structure */
+ /* frees the reply structure */
void (*reply_free)(void *);
/* verifies that the reply is valid */