forked from I2P_Developers/i2p.i2p
I removed those dumb platform specific makefiles. They weren't doing what they ought anyway. If there are platform specific issues, someone please tell me and I'll provide support for it here. Or patch it yourself.
And this is the big "Fix the Parser" patch. It turns the sam_parse function in src/parse.c into something that actually works. Generating the argument list from an incoming SAM thingy is a bit memory churn-y; perhaps when I have time I'll replace all those strdups with structures that simply track the (start,end) indices. Oh and also I moved i2p-ping to the new system. Which required 0 change in code. All I did was fix the Makefile, and add shared library libtool support. Anyway, so enjoy folks. It's rare I'm this productive - polecat
This commit is contained in:
24
apps/sam/c/inc/parse.h
Normal file
24
apps/sam/c/inc/parse.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _PARSE_HEADER_FEEP
|
||||
#define _PARSE_HEADER_FEEP
|
||||
|
||||
#include "tinystring.h"
|
||||
|
||||
typedef struct arg_s {
|
||||
string_t name;
|
||||
string_t value;
|
||||
// int pos;
|
||||
} arg_t;
|
||||
|
||||
typedef struct {
|
||||
arg_t* arg;
|
||||
int num;
|
||||
} args_t;
|
||||
|
||||
args_t arg_parse(const char*);
|
||||
void arg_done(args_t);
|
||||
arg_t* arg_get(args_t,int);
|
||||
arg_t* arg_find(args_t,string_t);
|
||||
|
||||
#define AG(a,b) arg_get(a,b)
|
||||
|
||||
#endif /* _PARSE_HEADER_FEEP */
|
@@ -121,9 +121,9 @@ bool sam_read_buffer(sam_sess_t *session);
|
||||
const char *sam_strerror(samerr_t code);
|
||||
/* SAM controls - callbacks */
|
||||
void (*sam_diedback)(sam_sess_t *session);
|
||||
void (*sam_logback)(char *str);
|
||||
void (*sam_namingback)(sam_sess_t *session, char *name,
|
||||
sam_pubkey_t pubkey, samerr_t result);
|
||||
void (*sam_logback)(const char *str);
|
||||
void (*sam_namingback)(sam_sess_t *session, const char *name,
|
||||
sam_pubkey_t pubkey, samerr_t result, const char* message);
|
||||
|
||||
/* Stream commands */
|
||||
void sam_stream_close(sam_sess_t *session, sam_sid_t stream_id);
|
||||
@@ -131,14 +131,15 @@ sam_sid_t sam_stream_connect(sam_sess_t *session, const sam_pubkey_t dest);
|
||||
samerr_t sam_stream_send(sam_sess_t *session, sam_sid_t stream_id,
|
||||
const void *data, size_t size);
|
||||
/* Stream commands - callbacks */
|
||||
void (*sam_closeback)(sam_sess_t *session, sam_sid_t stream_id,
|
||||
samerr_t reason);
|
||||
void (*sam_closeback)(sam_sess_t *session, sam_sid_t stream_id,
|
||||
samerr_t reason, const char* message);
|
||||
|
||||
void (*sam_connectback)(sam_sess_t *session, sam_sid_t stream_id,
|
||||
sam_pubkey_t dest);
|
||||
void (*sam_databack)(sam_sess_t *session, sam_sid_t stream_id,
|
||||
sam_pubkey_t dest);
|
||||
void (*sam_databack)(sam_sess_t *session, sam_sid_t stream_id,
|
||||
void *data, size_t size);
|
||||
void (*sam_statusback)(sam_sess_t *session, sam_sid_t stream_id,
|
||||
samerr_t result);
|
||||
void (*sam_statusback)(sam_sess_t *session, sam_sid_t stream_id,
|
||||
samerr_t result, const char* message);
|
||||
|
||||
/* Stream send queue (experimental) */
|
||||
void sam_sendq_add(sam_sess_t *session, sam_sid_t stream_id,
|
||||
|
48
apps/sam/c/inc/tinystring.h
Normal file
48
apps/sam/c/inc/tinystring.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef TINYSTRING_HEADER
|
||||
#define TINYSTRING_HEADER
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef bool
|
||||
#define bool short int
|
||||
#endif
|
||||
|
||||
struct string_s;
|
||||
#define string_t struct string_s*
|
||||
//Mysteeeerious *waggles mysteriously*
|
||||
|
||||
/*{
|
||||
char* data;
|
||||
long int size;
|
||||
} *string_t;
|
||||
*/
|
||||
|
||||
string_t string_create(const char*);
|
||||
string_t string_ncreate(const char* cstr,long int length);
|
||||
|
||||
string_t string_wrap(const char*);
|
||||
//Does not malloc, do NOT pass to string_free
|
||||
|
||||
string_t string_fmt(const char* fmt, ...);
|
||||
string_t string_cat(string_t,string_t);
|
||||
|
||||
/* Source Dest */
|
||||
void string_copy(string_t,string_t);
|
||||
void string_copy_raw(string_t,void*,size_t);
|
||||
|
||||
const char* string_data(string_t);
|
||||
long int string_size(string_t);
|
||||
|
||||
void string_free(string_t);
|
||||
|
||||
bool string_equal(string_t,string_t);
|
||||
bool string_equali(string_t,string_t);
|
||||
int string_cmp(string_t,string_t);
|
||||
int string_cmpi(string_t,string_t);
|
||||
|
||||
#define _sw(a) string_wrap(a)
|
||||
#define _scr(a,b,c) string_copy_raw(a,b,c)
|
||||
|
||||
#define string_is(a,b) (! strncmp(string_data(a),(b),string_size(a)))
|
||||
|
||||
#endif /* TINYSTRING_HEADER */
|
Reference in New Issue
Block a user