aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-04 23:00:55 -0400
committerDeterminant <[email protected]>2019-06-04 23:00:55 -0400
commitfad6446ce15bcd1303fdd162d6938ab30046467e (patch)
tree524e713d3574042176c1021bbfd610a885e950a2 /include
parentdab48a1825aed9c810ce83ea8054fa435ecb41be (diff)
finish the minimal working example
Diffstat (limited to 'include')
-rw-r--r--include/salticidae/event.h4
-rw-r--r--include/salticidae/msg.h4
-rw-r--r--include/salticidae/netaddr.h1
-rw-r--r--include/salticidae/network.h22
-rw-r--r--include/salticidae/stream.h15
-rw-r--r--include/salticidae/type.h2
6 files changed, 26 insertions, 22 deletions
diff --git a/include/salticidae/event.h b/include/salticidae/event.h
index 1dcd49d..ae46e78 100644
--- a/include/salticidae/event.h
+++ b/include/salticidae/event.h
@@ -665,14 +665,14 @@ extern "C" {
#endif
eventcontext_t *eventcontext_new();
+void eventcontext_free(eventcontext_t *self);
void eventcontext_dispatch(eventcontext_t *self);
void eventcontext_stop(eventcontext_t *self);
-void eventcontext_free(eventcontext_t *self);
typedef void (*sigev_callback_t)(int events);
sigev_t *sigev_new(const eventcontext_t *self, sigev_callback_t cb);
-void sigev_add(sigev_t *self, int sig);
void sigev_free(sigev_t *self);
+void sigev_add(sigev_t *self, int sig);
#ifdef __cplusplus
}
diff --git a/include/salticidae/msg.h b/include/salticidae/msg.h
index c88d70b..7e8032b 100644
--- a/include/salticidae/msg.h
+++ b/include/salticidae/msg.h
@@ -286,9 +286,9 @@ extern "C" {
#endif
msg_t *msg_new(_opcode_t opcode, bytearray_t *_moved_payload);
-datastream_t *msg_get_payload(const msg_t *msg);
-const _opcode_t msg_get_opcode(const msg_t *msg);
void msg_free(msg_t *msg);
+datastream_t *msg_get_payload(const msg_t *msg);
+_opcode_t msg_get_opcode(const msg_t *msg);
#ifdef __cplusplus
}
diff --git a/include/salticidae/netaddr.h b/include/salticidae/netaddr.h
index d3c34fe..4edf926 100644
--- a/include/salticidae/netaddr.h
+++ b/include/salticidae/netaddr.h
@@ -135,6 +135,7 @@ extern "C" {
#endif
netaddr_t *netaddr_new();
+void netaddr_free(const netaddr_t *self);
netaddr_t *netaddr_new_from_ip_port(uint32_t ip, uint16_t port);
netaddr_t *netaddr_new_from_sip_port(const char *ip, uint16_t port);
netaddr_t *netaddr_new_from_sipport(const char *ip_port_addr);
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index 6800632..60f08e6 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -144,7 +144,7 @@ class MsgNetwork: public ConnPool {
}
};
- ~MsgNetwork() { stop_workers(); }
+ virtual ~MsgNetwork() { stop_workers(); }
MsgNetwork(const EventContext &ec, const Config &config):
ConnPool(ec, config) {
@@ -811,33 +811,25 @@ extern "C" {
void salticidae_injected_msg_callback(const msg_t *msg, msgnetwork_conn_t *conn);
-msgnetwork_t *msgnetwork_new(const eventcontext_t *ec, const msgnetwork_config_t *config);
+msgnetwork_config_t *msgnetwork_config_new();
+void msgnetwork_config_free(const msgnetwork_config_t *self);
+msgnetwork_t *msgnetwork_new(const eventcontext_t *ec, const msgnetwork_config_t *config);
+void msgnetwork_free(const msgnetwork_t *self);
bool msgnetwork_send_msg(msgnetwork_t *self, const msg_t *msg, const msgnetwork_conn_t *conn);
-
msgnetwork_conn_t *msgnetwork_connect(msgnetwork_t *self, const netaddr_t *addr);
-
void msgnetwork_listen(msgnetwork_t *self, const netaddr_t *listen_addr);
+void msgnetwork_start(msgnetwork_t *self);
typedef void (*msgnetwork_msg_callback_t)(const msg_t *, const msgnetwork_conn_t *);
-
-#ifdef SALTICIDAE_CBINDINGS_STR_OP
-void msgnetwork_reg_handler(msgnetwork_t *self, const char *opcode, msgnetwork_msg_callback_t cb);
-#else
-void msgnetwork_reg_handler(msgnetwork_t *self, uint8_t opcode, msgnetwork_msg_callback_t cb);
-#endif
+void msgnetwork_reg_handler(msgnetwork_t *self, _opcode_t opcode, msgnetwork_msg_callback_t cb);
typedef void (*msgnetwork_conn_callback_t)(const msgnetwork_conn_t *, bool);
-
void msgnetwork_reg_conn_handler(msgnetwork_t *self, msgnetwork_conn_callback_t cb);
msgnetwork_t *msgnetwork_conn_get_net(const msgnetwork_conn_t *conn);
msgnetwork_conn_mode_t msgnetwork_conn_get_mode(const msgnetwork_conn_t *conn);
netaddr_t *msgnetwork_conn_get_addr(const msgnetwork_conn_t *conn);
-msgnetwork_config_t *msgnetwork_config_new();
-void msgnetwork_config_free(msgnetwork_config_t *self);
-void msgnetwork_listen(msgnetwork_t *self, const netaddr_t *listen_addr);
-void msgnetwork_start(msgnetwork_t *self);
#ifdef __cplusplus
}
diff --git a/include/salticidae/stream.h b/include/salticidae/stream.h
index 3f768b3..95c2ccb 100644
--- a/include/salticidae/stream.h
+++ b/include/salticidae/stream.h
@@ -494,6 +494,8 @@ extern "C" {
uint256_t *uint256_new();
uint256_t *uint256_new_from_bytes(const uint8_t *arr);
+void uint256_free(const uint256_t *self);
+
bool uint256_is_null(const uint256_t *self);
bool uint256_is_eq(const uint256_t *a, const uint256_t *b);
void uint256_serialize(const uint256_t *self, datastream_t *s);
@@ -501,30 +503,39 @@ void uint256_unserialize(uint256_t *self, datastream_t *s);
datastream_t *datastream_new();
datastream_t *datastream_new_from_bytes(const uint8_t *begin, const uint8_t *end);
+void datastream_free(const datastream_t *self);
+
void datastream_assign_by_copy(datastream_t *dst, const datastream_t *src);
void datastream_assign_by_move(datastream_t *dst, datastream_t *src);
uint8_t *datastream_data(datastream_t *self);
void datastream_clear(datastream_t *self);
size_t datastream_size(const datastream_t *self);
+
void datastream_put_u8(datastream_t *self, uint8_t val);
void datastream_put_u16(datastream_t *self, uint16_t val);
void datastream_put_u32(datastream_t *self, uint32_t val);
+void datastream_put_u64(datastream_t *self, uint64_t val);
+
void datastream_put_i8(datastream_t *self, int8_t val);
void datastream_put_i16(datastream_t *self, int16_t val);
void datastream_put_i32(datastream_t *self, int32_t val);
+void datastream_put_i64(datastream_t *self, int64_t val);
void datastream_put_data(datastream_t *self,
const uint8_t *begin, const uint8_t *end);
uint8_t datastream_get_u8(datastream_t *self);
uint16_t datastream_get_u16(datastream_t *self);
uint32_t datastream_get_u32(datastream_t *self);
+uint64_t datastream_get_u64(datastream_t *self);
+
int8_t datastream_get_i8(datastream_t *self);
int16_t datastream_get_i16(datastream_t *self);
int32_t datastream_get_i32(datastream_t *self);
+int64_t datastream_get_i64(datastream_t *self);
+
const uint8_t *datastream_get_data_inplace(datastream_t *self, size_t len);
uint256_t *datastream_get_hash(const datastream_t *self);
-void datastream_free(const datastream_t *self);
-bytearray_t *datastream_to_bytearray(datastream_t *self);
+bytearray_t *datastream_to_bytearray(datastream_t *_moved_self);
#ifdef __cplusplus
}
diff --git a/include/salticidae/type.h b/include/salticidae/type.h
index 0bc2ae0..c62272d 100644
--- a/include/salticidae/type.h
+++ b/include/salticidae/type.h
@@ -106,7 +106,7 @@ typedef struct bytearray_t bytearray_t;
#endif
#ifdef SALTICIDAE_CBINDINGS_STR_OP
-typedef char * _opcode_t;
+typedef const char * _opcode_t;
#else
typedef uint8_t _opcode_t;
#endif