#include "nbrpc_call.h"
extern char* alloc_new_str(char *);
extern char *alloc_new_str_s(char *, size_t);
rpc_call_request* rpc_call_req_new(char *method, char *params, int id)
{
rpc_call_request *ret = NULL;
if (!method)
{
return NULL;
}
if (!params)
{
return NULL;
}
ret = malloc(sizeof(rpc_call_request));
if (!ret)
{
return NULL;
}
ret->id = id;
ret->method = alloc_new_str(method);
ret->params = alloc_new_str(params);
ret->user = NULL;
ret->mask = NULL;
ret->server = NULL;
return ret;
}
rpc_call_response* rpc_call_resp_new(char *result, char *error, int id)
{
rpc_call_response *ret = NULL;
ret = malloc(sizeof(rpc_call_response));
if (!ret)
{
return NULL;
}
PRINT("resp->id %d\n", id);
ret->id = id;
ret->result = alloc_new_str(result);
ret->error = alloc_new_str(error);
ret->user = NULL;
ret->mask = NULL;
ret->server = NULL;
return ret;
}