Commit 090a2c76 authored by Mikolas-MBPro's avatar Mikolas-MBPro
Browse files

Project cleaning

parent 8348c800
......@@ -67,7 +67,7 @@ parsing_error_t get_decimal_number(json_t *source, const char * name,
}
parsing_error_t get_string(json_t *source, char * name,
char **destination){
char * * destination){
if (source == NULL){
return PARSING_SOUCE_NOT_AN_OBJECT;
}
......@@ -93,7 +93,7 @@ parsing_error_t get_string(json_t *source, char * name,
return PARSING_PROPERTY_TYPE_MISMATCH;
}
*destination = json_string_value(property);
(*destination) = json_string_value(property);
return PARSING_NO_ERROR;
}
......
......@@ -56,7 +56,7 @@ parsing_error_t get_decimal_number(json_t *source, const char * name,
@return error code, PARSING_NO_ERROR on success.
*/
parsing_error_t get_string(json_t *source, char * name,
char **destination);
char ** destination);
/**
Parses boolean from from json object.
......
This diff is collapsed.
......@@ -30,35 +30,35 @@
*/
const struct rpc_method_description * RPC_METHODS[] = {
#define kPLACE_NEW_ORDER_METHOD_INDEX 0
&mPLACE_NEW_ORDER,
&mPLACE_NEW_ORDER,
#define kORDER_LIST_METHOD_INDEX 1
&mORDER_LIST,
&mORDER_LIST,
#define kCANCEL_ORDER_METHOD_INDEX 2
&mCANCEL_ORDER,
&mCANCEL_ORDER,
#define kGET_MARKET_VIEW_METHOD_INDEX 3
&mGET_MARKET_VIEW,
&mGET_MARKET_VIEW,
#define kACCEPT_ORDER_METHOD_INDEX 4
&mACCEPT_ORDER,
&mACCEPT_ORDER,
#define kGET_TRADE_LIST_METHOD_INDEX 5
&mGET_TRADE_LIST,
&mGET_TRADE_LIST,
#define kGET_PEER_LIST_METHOD_INDEX 6
&mGET_PEER_LIST,
&mGET_PEER_LIST,
#define kINSERT_NEW_PEER_METHOD_INDEX 7
&mINSERT_NEW_PEER,
&mINSERT_NEW_PEER,
#define kGET_BLACK_LIST_METHOD_INDEX 8
&mGET_BLACK_LIST,
&mGET_BLACK_LIST,
#define kBAN_PEER_METHOD_INDEX 9
&mBAN_PEER,
&mBAN_PEER,
#define kUNBAN_PEER_METHOD_INDEX 10
&mUNBAN_PEER,
&mUNBAN_PEER,
#define kWALLET_LIST_METHOD_INDEX 11
&mWALLET_LIST,
&mWALLET_LIST,
#define kGET_WALLET_STATUS_METHOD_INDEX 12
&mGET_WALLET_STATUS,
&mGET_WALLET_STATUS,
#define kRELOAD_CONFIG_METHOD_INDEX 13
&mRELOAD_CONFIG,
&mRELOAD_CONFIG,
#define kSHUT_DOWN_METHOD_INDEX 14
&mSHUT_DOWN
&mSHUT_DOWN
};
/**
......@@ -67,29 +67,30 @@ const struct rpc_method_description * RPC_METHODS[] = {
same looking copy of this structure.
*/
struct rpc_event {
const struct rpc_method_description * method;
void * parameters;
void * result;
enum rpc_error error;
int64_t tag;
const struct rpc_method_description * method;
void * parameters;
void * result;
enum rpc_error error;
int64_t tag;
};
// Server API
/**
This method is used to parse recieved JSON RPC string. You may parsed any
kind of string. In case, that string does not contain request, no callback is
called and method ends with false.
@param json_string recieved JSON encoded string
@param retain_event rpc_event is discarded in case of passing NULL. Otherwise,
rpc_event is not freed and is filled into provided pointer insted.
@param response_string NULL on error, otherwise stores response string.
@return true if request is resolved (callback is called), false otherwise
Accepts rpc request as json string. Decodes that string and creates rpc event
container. Then calls method specific callbacks which are supposed to fill
event continer with response or error state. This method then creates json
string response.
@param json_string NONNULL input json string
@param retain_event NULLABLE pointer to poiner - if nonnull pointer is passes,
this method does't destory rpc event after resolving the request but provides
reference to event contianer in this pointer.
@param response_string NONNULL pointer to response string container
@return true on success
*/
bool resolve_rpc_request(char * json_string,
struct rpc_event ** retain_event,
char ** response_string);
bool resolve_rpc_request(char * json_string, struct rpc_event **retain_event,
char **response_string);
// Client API
......@@ -98,35 +99,38 @@ bool resolve_rpc_request(char * json_string,
method_args for given method_name. If user does not so, runtime error may or
may not happen. New event is then stored in request_store and provided as
a pointer if user passes non NULL value into new_event argument.
@param new_event pointer to rpc_event created by this method
@param new_event NULLABLE pointer to rpc_event created by this method
@param tag number that client uses to connect request to response, user is
required to provide different number each time.
@param method rpc method description found in corresponding rpc method module
@param method_args arguments for given method
@param request_string provided pointer will contain json serialized string, if
user does not provide pointer, method is aborted.
@param method NONNULL rpc method description found in corresponding rpc method
@param method_args NONNULL arguments for given method (use method specific
initializer)
@param request_string NONNULL provided pointer will contain json serialized
string, if user does not provide pointer, method is aborted.
@return true if request string was created, false on error
*/
bool create_rpc_request(struct rpc_event ** new_event,
int64_t tag,
struct rpc_method_description * method,
void * method_args,
char ** request_string);
int64_t tag,
struct rpc_method_description * method,
void * method_args,
char ** request_string);
/**
Parses string provided as argument as RPC response and calls corresponding
callback. Callback is not called if request is not found in request_store.
@param json_string json string containing response
@param retain_event if user passes non NULL parameter, rpc_event is removed
from request_store but not freed. Event pointer is instead returned in the
provided pointer.
@return true if callback was called, false on error.
Use to pass incoming json string as reponse to request made by it's owner.
This method parses rpc event tag from json string and then searches request
store for a rpc event with same tag. If corresponsing event is found, it uses
it's method description to call callback with filles erguments and response.
Then rpc event is removed from store and destoryed if user does not want to
retain the instance.
@param json_string NONNULL json string
@param retain_event NULLABLE pointer to rpc event pointer
@return true on success
*/
bool resolve_rpc_response(char * json_string,
struct rpc_event ** retain_event);
struct rpc_event ** retain_event);
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment