Skip to content

Commit

Permalink
fixup! Adapt control API from NFLua
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusNtg committed Sep 4, 2020
1 parent 11108c6 commit 125e47a
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions lib/lunatik.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,38 @@
#include "../lunatik_conf.h"

enum callback_result {
CB_SUCCESS,
CB_ERROR,
CB_EMPTY_RESULT,
CB_LIST_EMPTY,
CB_STATE_NOT_FOUND,
CB_SUCCESS,
CB_ERROR,
CB_EMPTY_RESULT,
CB_LIST_EMPTY,
CB_STATE_NOT_FOUND,
};

enum session_status {
SESSION_FREE,
SESSION_RECEIVING,
SESSION_FREE,
SESSION_RECEIVING,
};

struct data_buffer {
char *buffer;
int size;
char *buffer;
int size;
};

struct lunatik_nl_state {
struct lunatik_session *session;
struct nl_sock *send_datasock;
struct nl_sock *recv_datasock;
struct nl_sock *control_sock;
struct data_buffer data_buffer;
enum callback_result cb_result;
uint32_t maxalloc;
uint32_t curralloc;
char name[LUNATIK_NAME_MAXSIZE];
struct lunatik_session *session;
struct nl_sock *send_datasock;
struct nl_sock *recv_datasock;
struct nl_sock *control_sock;
struct data_buffer data_buffer;
enum callback_result cb_result;
uint32_t maxalloc;
uint32_t curralloc;
char name[LUNATIK_NAME_MAXSIZE];
};

struct states_list {
struct lunatik_nl_state *states;
size_t list_size;
struct lunatik_nl_state *states;
size_t list_size;
};

struct received_buffer {
Expand All @@ -67,26 +67,26 @@ struct received_buffer {
};

struct lunatik_session {
struct nl_sock *control_sock;
struct states_list states_list;
struct received_buffer recv_buffer;
struct lunatik_nl_state state_holder;
enum session_status status;
enum callback_result cb_result;
int family;
int control_fd;
int data_fd;
uint32_t pid;
struct nl_sock *control_sock;
struct states_list states_list;
struct received_buffer recv_buffer;
struct lunatik_nl_state state_holder;
enum session_status status;
enum callback_result cb_result;
int family;
int control_fd;
int data_fd;
uint32_t pid;
};

static inline int lunatikS_getfd(const struct lunatik_session *session)
{
return session->control_fd;
return session->control_fd;
}

static inline int lunatikS_isopen(const struct lunatik_session *session)
{
return session->control_fd >= 0;
return session->control_fd >= 0;
}

int lunatikS_init(struct lunatik_session *session);
Expand All @@ -98,7 +98,7 @@ int lunatikS_newstate(struct lunatik_session *session, struct lunatik_nl_state *
int lunatik_closestate(struct lunatik_nl_state *state);

int lunatik_dostring(struct lunatik_nl_state *state,
const char *script, const char *script_name, size_t total_code_size);
const char *script, const char *script_name, size_t total_code_size);

int lunatikS_list(struct lunatik_session *session);

Expand All @@ -109,7 +109,7 @@ int lunatik_initstate(struct lunatik_nl_state *state);
struct lunatik_nl_state *lunatikS_getstate(struct lunatik_session *session, const char *name);

int lunatik_datasend(struct lunatik_nl_state *state,
const char *payload, size_t len);
const char *payload, size_t len);

int lunatik_getcurralloc(struct lunatik_nl_state *state);

Expand Down

0 comments on commit 125e47a

Please sign in to comment.