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
|
||||
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
|
||||
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
|
||||
|
|
|
@ -78,11 +78,12 @@ void psyc_initTextState (psycTextState *state,
|
|||
char *template, size_t tlen,
|
||||
char *buffer, size_t blen)
|
||||
{
|
||||
state->cursor = state->written = 0;
|
||||
state->template = psyc_newString(template, tlen);
|
||||
state->buffer = psyc_newString(buffer, blen);
|
||||
state->open = psyc_newString("[", 1);
|
||||
state->close = psyc_newString("]", 1);
|
||||
state->cursor = 0;
|
||||
state->written = 0;
|
||||
state->template = {tlen, template};
|
||||
state->buffer = {blen, buffer};
|
||||
state->open = {1, "["};
|
||||
state->close = {1, "]"};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,10 +106,10 @@ void psyc_initTextState2 (psycTextState *state,
|
|||
char *open, size_t openlen,
|
||||
char *close, size_t closelen)
|
||||
{
|
||||
state->template = psyc_newString(template, tlen);
|
||||
state->buffer = psyc_newString(buffer, blen);
|
||||
state->open = psyc_newString(open, openlen);
|
||||
state->close = psyc_newString(close, closelen);
|
||||
state->template = {tlen, template};
|
||||
state->buffer = {blen, buffer};
|
||||
state->open = {openlen, open};
|
||||
state->close = {closelen, close};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,7 +129,8 @@ static inline
|
|||
void psyc_setTextBuffer2 (psycTextState *state,
|
||||
char *buffer, size_t length)
|
||||
{
|
||||
psyc_setTextBuffer(state, psyc_newString(buffer, length));
|
||||
psycString buf = {length, buffer};
|
||||
psyc_setTextBuffer(state, buf);
|
||||
}
|
||||
|
||||
static inline
|
||||
|
|
|
@ -33,7 +33,7 @@ int main (int argc, char **argv)
|
|||
else
|
||||
psyc_initParseState(&state);
|
||||
|
||||
psyc_setParseBuffer(&state, psyc_newString(buffer, idx));
|
||||
psyc_setParseBuffer2(&state, buffer, idx);
|
||||
|
||||
// try parsing that now
|
||||
do
|
||||
|
|
|
@ -234,7 +234,7 @@ int main (int argc, char **argv)
|
|||
{
|
||||
// we got some data from a client
|
||||
parsebuf = recvbuf - contbytes;
|
||||
psyc_setParseBuffer(&parsers[i], psyc_newString(parsebuf, contbytes + nbytes));
|
||||
psyc_setParseBuffer2(&parsers[i], parsebuf, contbytes + nbytes);
|
||||
contbytes = 0;
|
||||
oper = 0;
|
||||
name.length = 0;
|
||||
|
|
Loading…
Reference in a new issue