mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
psycString init
This commit is contained in:
parent
fe79060f1c
commit
ab30ef650c
4 changed files with 18 additions and 14 deletions
|
@ -184,7 +184,8 @@ void psyc_setParseBuffer (psycParseState *state, psycString buffer)
|
||||||
static inline
|
static inline
|
||||||
void psyc_setParseBuffer2 (psycParseState *state, char *buffer, size_t length)
|
void psyc_setParseBuffer2 (psycParseState *state, char *buffer, size_t length)
|
||||||
{
|
{
|
||||||
psyc_setParseBuffer(state, psyc_newString(buffer, length));
|
psycString buf = {length, buffer};
|
||||||
|
psyc_setParseBuffer(state, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +212,8 @@ void psyc_setParseListBuffer (psycParseListState *state, psycString buffer)
|
||||||
static inline
|
static inline
|
||||||
void psyc_setParseListBuffer2 (psycParseListState *state, char *buffer, size_t length)
|
void psyc_setParseListBuffer2 (psycParseListState *state, char *buffer, size_t length)
|
||||||
{
|
{
|
||||||
psyc_setParseListBuffer(state, psyc_newString(buffer, length));
|
psycString buf = {length, buffer};
|
||||||
|
psyc_setParseListBuffer(state, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
|
|
@ -78,11 +78,12 @@ void psyc_initTextState (psycTextState *state,
|
||||||
char *template, size_t tlen,
|
char *template, size_t tlen,
|
||||||
char *buffer, size_t blen)
|
char *buffer, size_t blen)
|
||||||
{
|
{
|
||||||
state->cursor = state->written = 0;
|
state->cursor = 0;
|
||||||
state->template = psyc_newString(template, tlen);
|
state->written = 0;
|
||||||
state->buffer = psyc_newString(buffer, blen);
|
state->template = {tlen, template};
|
||||||
state->open = psyc_newString("[", 1);
|
state->buffer = {blen, buffer};
|
||||||
state->close = psyc_newString("]", 1);
|
state->open = {1, "["};
|
||||||
|
state->close = {1, "]"};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,10 +106,10 @@ void psyc_initTextState2 (psycTextState *state,
|
||||||
char *open, size_t openlen,
|
char *open, size_t openlen,
|
||||||
char *close, size_t closelen)
|
char *close, size_t closelen)
|
||||||
{
|
{
|
||||||
state->template = psyc_newString(template, tlen);
|
state->template = {tlen, template};
|
||||||
state->buffer = psyc_newString(buffer, blen);
|
state->buffer = {blen, buffer};
|
||||||
state->open = psyc_newString(open, openlen);
|
state->open = {openlen, open};
|
||||||
state->close = psyc_newString(close, closelen);
|
state->close = {closelen, close};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +129,8 @@ static inline
|
||||||
void psyc_setTextBuffer2 (psycTextState *state,
|
void psyc_setTextBuffer2 (psycTextState *state,
|
||||||
char *buffer, size_t length)
|
char *buffer, size_t length)
|
||||||
{
|
{
|
||||||
psyc_setTextBuffer(state, psyc_newString(buffer, length));
|
psycString buf = {length, buffer};
|
||||||
|
psyc_setTextBuffer(state, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
|
|
|
@ -33,7 +33,7 @@ int main (int argc, char **argv)
|
||||||
else
|
else
|
||||||
psyc_initParseState(&state);
|
psyc_initParseState(&state);
|
||||||
|
|
||||||
psyc_setParseBuffer(&state, psyc_newString(buffer, idx));
|
psyc_setParseBuffer2(&state, buffer, idx);
|
||||||
|
|
||||||
// try parsing that now
|
// try parsing that now
|
||||||
do
|
do
|
||||||
|
|
|
@ -234,7 +234,7 @@ int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
// we got some data from a client
|
// we got some data from a client
|
||||||
parsebuf = recvbuf - contbytes;
|
parsebuf = recvbuf - contbytes;
|
||||||
psyc_setParseBuffer(&parsers[i], psyc_newString(parsebuf, contbytes + nbytes));
|
psyc_setParseBuffer2(&parsers[i], parsebuf, contbytes + nbytes);
|
||||||
contbytes = 0;
|
contbytes = 0;
|
||||||
oper = 0;
|
oper = 0;
|
||||||
name.length = 0;
|
name.length = 0;
|
||||||
|
|
Loading…
Reference in a new issue