Skip to content

Commit

Permalink
refactor / add const qualifer / expose struct to fix inline compile p…
Browse files Browse the repository at this point in the history
…roblems
  • Loading branch information
radkesvat committed Apr 3, 2024
1 parent 5b9952c commit 3ed9553
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
6 changes: 1 addition & 5 deletions tunnels/client/preconnect/preconnect_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ static inline void upStream(tunnel_t *self, context_t *c)
preconnect_client_con_state_t *cstate = CSTATE(c);
switch (cstate->mode)
{
LOGF("PreConnectClient: invalid behaviour from behind node (no init)");
DISCARD_CONTEXT(c);
destroyContext(c);
break;


case connected_direct:
self->up->upStream(self->up, c);
break;
Expand Down
9 changes: 0 additions & 9 deletions ww/buffer_stream.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#include "buffer_stream.h"

#define i_TYPE queue, shift_buffer_t *
#include "stc/deq.h"
#define Q_CAP 25

struct buffer_stream_s
{
buffer_pool_t *pool;
queue q;
size_t size;
};

#undef max
#undef min
Expand Down
11 changes: 11 additions & 0 deletions ww/buffer_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

#include "buffer_pool.h"

#define i_TYPE queue, shift_buffer_t *
#include "stc/deq.h"
#define Q_CAP 25

struct buffer_stream_s
{
buffer_pool_t *pool;
queue q;
size_t size;
};

typedef struct buffer_stream_s buffer_stream_t;

buffer_stream_t *newBufferStream(buffer_pool_t *pool);
Expand Down
2 changes: 1 addition & 1 deletion ww/utils/fileutils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

char *readFile(const char *const path);
bool writeFile(const char *const path, char *data, size_t len);
bool writeFile(const char *const path,const char *data, size_t len);
17 changes: 7 additions & 10 deletions ww/utils/jsonutils.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#pragma once
#include "cJSON.h"
#include "basic_types.h"
#include "hv/hplatform.h" // for bool

#include "hv/hplatform.h" // for bool

// dest must be pre-allocated
bool getBoolFromJsonObject(bool *dest,const cJSON *json_obj, const char *key);
bool getIntFromJsonObject(int *dest,const cJSON *json_obj, const char *key);
bool getBoolFromJsonObject(bool *dest, const cJSON *json_obj, const char *key);
bool getIntFromJsonObject(int *dest, const cJSON *json_obj, const char *key);
// will allocate dest because it knows the string-len
bool getStringFromJsonObject(char **dest,const cJSON *json_obj, const char *key);
bool getStringFromJsonObjectOrDefault(char **dest,const cJSON *json_obj, const char *key, const char *def);


bool getStringFromJsonObject(char **dest, const cJSON *json_obj, const char *key);
bool getStringFromJsonObjectOrDefault(char **dest, const cJSON *json_obj, const char *key, const char *def);

dynamic_value_t parseDynamicStrValueFromJsonObject(const cJSON *json_obj, char *key, size_t matchers, ...);
dynamic_value_t parseDynamicNumericValueFromJsonObject(const cJSON *json_obj, char *key, size_t matchers, ...);
dynamic_value_t parseDynamicStrValueFromJsonObject(const cJSON *json_obj, const char *key, size_t matchers, ...);
dynamic_value_t parseDynamicNumericValueFromJsonObject(const cJSON *json_obj, const char *key, size_t matchers, ...);
6 changes: 3 additions & 3 deletions ww/utils/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ char *readFile(const char *const path)
return string;
}

bool writeFile(const char *const path, char *data, size_t len)
bool writeFile(const char *const path,const char *data, size_t len)
{
FILE *f = fopen(path, "wb");

Expand Down Expand Up @@ -240,7 +240,7 @@ struct user_s *parseUserFromJsonObject(const cJSON *user_json)
return user;
}

dynamic_value_t parseDynamicStrValueFromJsonObject(const cJSON *json_obj, char *key, size_t matchers, ...)
dynamic_value_t parseDynamicStrValueFromJsonObject(const cJSON *json_obj,const char *key, size_t matchers, ...)
{

dynamic_value_t result = {0};
Expand Down Expand Up @@ -273,7 +273,7 @@ dynamic_value_t parseDynamicStrValueFromJsonObject(const cJSON *json_obj, char *
}
return result;
}
dynamic_value_t parseDynamicNumericValueFromJsonObject(const cJSON *json_obj, char *key, size_t matchers, ...)
dynamic_value_t parseDynamicNumericValueFromJsonObject(const cJSON *json_obj,const char *key, size_t matchers, ...)
{

dynamic_value_t result = {0};
Expand Down

0 comments on commit 3ed9553

Please sign in to comment.