aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/salticidae/conn.h3
-rw-r--r--include/salticidae/event.h12
-rw-r--r--include/salticidae/msg.h19
-rw-r--r--include/salticidae/netaddr.h14
-rw-r--r--include/salticidae/network.h18
-rw-r--r--include/salticidae/stream.h20
-rw-r--r--include/salticidae/type.h16
-rw-r--r--include/salticidae/util.h4
8 files changed, 78 insertions, 28 deletions
diff --git a/include/salticidae/conn.h b/include/salticidae/conn.h
index 201e574..92fc5a6 100644
--- a/include/salticidae/conn.h
+++ b/include/salticidae/conn.h
@@ -25,6 +25,7 @@
#ifndef _SALTICIDAE_CONN_H
#define _SALTICIDAE_CONN_H
+#ifdef __cplusplus
#include <cassert>
#include <cstdint>
#include <arpa/inet.h>
@@ -426,3 +427,5 @@ class ConnPool {
}
#endif
+
+#endif
diff --git a/include/salticidae/event.h b/include/salticidae/event.h
index 27d081a..cc739f2 100644
--- a/include/salticidae/event.h
+++ b/include/salticidae/event.h
@@ -25,6 +25,7 @@
#ifndef _SALTICIDAE_EVENT_H
#define _SALTICIDAE_EVENT_H
+#ifdef __cplusplus
#include <condition_variable>
#include <unistd.h>
#include <uv.h>
@@ -35,7 +36,6 @@
#include "salticidae/util.h"
#include "salticidae/ref.h"
-#ifdef __cplusplus
namespace salticidae {
struct _event_context_deleter {
@@ -651,16 +651,18 @@ using sigev_t = salticidae::SigEvent;
#endif
#else
-
+#include "config.h"
#ifdef SALTICIDAE_CBINDINGS
-typedef struct eventcontext_t;
-typedef struct sigevent_t;
+typedef struct eventcontext_t eventcontext_t;
+typedef struct sigev_t sigev_t;
#endif
#endif
#ifdef SALTICIDAE_CBINDINGS
+#ifdef __cplusplus
extern "C" {
+#endif
eventcontext_t *eventcontext_new();
void eventcontext_dispatch(eventcontext_t *self);
@@ -672,7 +674,9 @@ 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);
+#ifdef __cplusplus
}
#endif
+#endif
#endif
diff --git a/include/salticidae/msg.h b/include/salticidae/msg.h
index 6964ab2..c88d70b 100644
--- a/include/salticidae/msg.h
+++ b/include/salticidae/msg.h
@@ -25,16 +25,17 @@
#ifndef _SALTICIDAE_MSG_H
#define _SALTICIDAE_MSG_H
-#include <cstdint>
-#include <cstring>
-#include <string>
-#include <vector>
-
#include "salticidae/type.h"
#include "salticidae/stream.h"
#include "salticidae/netaddr.h"
#ifdef __cplusplus
+
+#include <cstdint>
+#include <cstring>
+#include <string>
+#include <vector>
+
namespace salticidae {
template<typename OpcodeType>
@@ -280,14 +281,18 @@ typedef struct msg_t msg_t;
#endif
#ifdef SALTICIDAE_CBINDINGS
+#ifdef __cplusplus
extern "C" {
+#endif
msg_t *msg_new(_opcode_t opcode, bytearray_t *_moved_payload);
-datastream_t *msg_get_payload(msg_t *msg);
-const _opcode_t &msg_get_opcode(const msg_t *msg);
+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);
+#ifdef __cplusplus
}
#endif
+#endif
#endif
diff --git a/include/salticidae/netaddr.h b/include/salticidae/netaddr.h
index 917c498..d3c34fe 100644
--- a/include/salticidae/netaddr.h
+++ b/include/salticidae/netaddr.h
@@ -25,16 +25,16 @@
#ifndef _SALTICIDAE_NETADDR_H
#define _SALTICIDAE_NETADDR_H
+#include "salticidae/util.h"
+#include "salticidae/stream.h"
+
+#ifdef __cplusplus
#include <string>
#include <cstring>
#include <cstdint>
#include <arpa/inet.h>
#include <netdb.h>
-#include "salticidae/util.h"
-#include "salticidae/stream.h"
-
-#ifdef __cplusplus
namespace salticidae {
/* TODO: IPv6 support */
@@ -129,7 +129,10 @@ using netaddr_t = salticidae::NetAddr;
typedef struct netaddr_t netaddr_t;
#endif
+#ifdef SALTICIDAE_CBINDINGS
+#ifdef __cplusplus
extern "C" {
+#endif
netaddr_t *netaddr_new();
netaddr_t *netaddr_new_from_ip_port(uint32_t ip, uint16_t port);
@@ -138,6 +141,9 @@ netaddr_t *netaddr_new_from_sipport(const char *ip_port_addr);
bool netaddr_is_eq(const netaddr_t *a, const netaddr_t *b);
bool netaddr_is_null(const netaddr_t *self);
+#ifdef __cplusplus
}
+#endif
+#endif
#endif
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index b176b65..f6bd6fe 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -791,16 +791,22 @@ using msgnetwork_conn_t = msgnetwork_t::conn_t;
#else
#ifdef SALTICIDAE_CBINDINGS
-typedef struct msg_t;
-typedef struct msgnetwork_t;
-typedef struct msgnetwork_config_t;
-typedef struct msgnetwork_conn_t;
+typedef struct msgnetwork_t msgnetwork_t;
+typedef struct msgnetwork_config_t msgnetwork_config_t;
+typedef struct msgnetwork_conn_t msgnetwork_conn_t;
+typedef enum msgnetwork_conn_mode_t {
+ CONN_MODE_ACTIVE,
+ CONN_MODE_PASSIVE,
+ CONN_MODE_DEAD
+} msgnetwork_conn_mode_t;
#endif
#endif
#ifdef SALTICIDAE_CBINDINGS
+#ifdef __cplusplus
extern "C" {
+#endif
void salticidae_injected_msg_callback(const msg_t *msg, msgnetwork_conn_t *conn);
@@ -825,8 +831,12 @@ 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);
+#ifdef __cplusplus
}
#endif
+#endif
#endif
diff --git a/include/salticidae/stream.h b/include/salticidae/stream.h
index e146273..3f768b3 100644
--- a/include/salticidae/stream.h
+++ b/include/salticidae/stream.h
@@ -25,11 +25,11 @@
#ifndef _SALTICIDAE_STREAM_H
#define _SALTICIDAE_STREAM_H
+#ifdef __cplusplus
#include "salticidae/type.h"
#include "salticidae/ref.h"
#include "salticidae/crypto.h"
-#ifdef __cplusplus
namespace salticidae {
template<size_t N, typename T> class Blob;
@@ -474,15 +474,23 @@ using datastream_t = salticidae::DataStream;
#else
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "config.h"
+#include "type.h"
+
#ifdef SALTICIDAE_CBINDINGS
-typedef struct datastream_t;
-typedef struct uint256_t;
+typedef struct datastream_t datastream_t;
+typedef struct uint256_t uint256_t;
#endif
#endif
#ifdef SALTICIDAE_CBINDINGS
+#ifdef __cplusplus
extern "C" {
+#endif
uint256_t *uint256_new();
uint256_t *uint256_new_from_bytes(const uint8_t *arr);
@@ -505,7 +513,7 @@ 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_data(datastream_t *self,
- uint8_t *begin, uint8_t *end);
+ const uint8_t *begin, const uint8_t *end);
uint8_t datastream_get_u8(datastream_t *self);
uint16_t datastream_get_u16(datastream_t *self);
@@ -515,8 +523,12 @@ int16_t datastream_get_i16(datastream_t *self);
int32_t datastream_get_i32(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);
+#ifdef __cplusplus
}
#endif
+#endif
#endif
diff --git a/include/salticidae/type.h b/include/salticidae/type.h
index 0ebcce7..b3da4c2 100644
--- a/include/salticidae/type.h
+++ b/include/salticidae/type.h
@@ -25,6 +25,9 @@
#ifndef _SALTICIDAE_TYPE_H
#define _SALTICIDAE_TYPE_H
+#include "config.h"
+
+#ifdef __cplusplus
#include <vector>
#include <string>
#include <cstring>
@@ -35,9 +38,6 @@
#include <functional>
#include <mutex>
-#include "config.h"
-
-#ifdef __cplusplus
namespace salticidae {
const auto _1 = std::placeholders::_1;
@@ -98,6 +98,7 @@ using bytearray_t = salticidae::bytearray_t;
#else
+#include <stdint.h>
#ifdef SALTICIDAE_CBINDINGS
typedef struct bytearray_t bytearray_t;
#endif
@@ -105,19 +106,24 @@ typedef struct bytearray_t bytearray_t;
#endif
#ifdef SALTICIDAE_CBINDINGS_STR_OP
-using _opcode_t = char *;
+typedef char * _opcode_t;
#else
-using _opcode_t = uint8_t;
+typedef uint8_t _opcode_t;
#endif
#ifdef SALTICIDAE_CBINDINGS
+#ifdef __cplusplus
extern "C" {
+#endif
+bytearray_t *bytearray_new();
uint8_t *bytearray_data(bytearray_t *arr);
size_t bytearray_size(bytearray_t *arr);
void bytearray_free();
+#ifdef __cplusplus
}
#endif
+#endif
#endif
diff --git a/include/salticidae/util.h b/include/salticidae/util.h
index a843fbd..19779b0 100644
--- a/include/salticidae/util.h
+++ b/include/salticidae/util.h
@@ -25,6 +25,8 @@
#ifndef _SALTICIDAE_COMMON_H
#define _SALTICIDAE_COMMON_H
+#ifdef __cplusplus
+
#include <string>
#include <exception>
#include <cstdarg>
@@ -326,3 +328,5 @@ class Config {
}
#endif
+
+#endif