compiles again

This commit is contained in:
Gabor Adam Toth 2011-04-22 20:33:22 +02:00
parent 83e18a5f4a
commit 0e54f3f76a
7 changed files with 66 additions and 50 deletions

View File

@ -120,11 +120,14 @@ typedef struct
*
* @return An instance of the PSYC_Array struct.
*/
inline PSYC_Array PSYC_createArray (const char* memory, size_t length)
{
PSYC_Array arr = {length, memory};
return arr;
}
inline PSYC_Array PSYC_createArray (const char* memory, size_t length);
/**
* Initiates the state struct.
*
* @param state Pointer to the state struct that should be initiated.
*/
inline void PSYC_initParseState (PSYC_ParseState* state);
/**
* Initiates the state struct with flags.
@ -132,48 +135,20 @@ inline PSYC_Array PSYC_createArray (const char* memory, size_t length)
* @param state Pointer to the state struct that should be initiated.
* @param flags Flags to be set for the parser, see PSYC_ParseFlag.
*/
inline void PSYC_initParseState2 (PSYC_ParseState* state, uint8_t flags)
{
memset(state, 0, sizeof(PSYC_ParseState));
state->flags = flags;
}
/**
* Initiates the state struct.
*
* @param state Pointer to the state struct that should be initiated.
*/
inline void PSYC_initParseState (PSYC_ParseState* state)
{
memset(state, 0, sizeof(PSYC_ParseState));
}
inline void PSYC_initParseState2 (PSYC_ParseState* state, uint8_t flags);
/**
* Initiates the list state struct.
*
* @param state Pointer to the list state struct that should be initiated.
*/
inline void PSYC_initParseListState (PSYC_ParseListState* state)
{
memset(state, 0, sizeof(PSYC_ParseListState));
}
inline void PSYC_initParseListState (PSYC_ParseListState* state);
inline void PSYC_nextParseBuffer (PSYC_ParseState* state, PSYC_Array newBuf)
{
state->buffer = newBuf;
state->cursor = 0;
}
inline void PSYC_nextParseBuffer (PSYC_ParseState* state, PSYC_Array newBuf);
inline void PSYC_nextParseListBuffer (PSYC_ParseListState* state, PSYC_Array newBuf)
{
state->buffer = newBuf;
state->cursor = 0;
}
inline void PSYC_nextParseListBuffer (PSYC_ParseListState* state, PSYC_Array newBuf);
inline size_t PSYC_getContentLength (PSYC_ParseState* s)
{
return s->contentLength;
}
inline size_t PSYC_getContentLength (PSYC_ParseState* s);
/**
* Parse PSYC packets.

View File

@ -42,10 +42,7 @@ typedef struct
*
* @param state Pointer to the state struct that should be initiated.
*/
inline void PSYC_initRenderState (PSYC_RenderState* state)
{
memset(state, 0, sizeof(PSYC_RenderState));
}
inline void PSYC_initRenderState (PSYC_RenderState* state);
int PSYC_renderVar(PSYC_RenderState* render,
const char* name, size_t nlength,

View File

@ -15,6 +15,45 @@
return ret; \
}
inline PSYC_Array PSYC_createArray (const char* memory, size_t length)
{
PSYC_Array arr = {length, memory};
return arr;
}
inline void PSYC_initParseState (PSYC_ParseState* state)
{
memset(state, 0, sizeof(PSYC_ParseState));
}
inline void PSYC_initParseState2 (PSYC_ParseState* state, uint8_t flags)
{
memset(state, 0, sizeof(PSYC_ParseState));
state->flags = flags;
}
inline void PSYC_initParseListState (PSYC_ParseListState* state)
{
memset(state, 0, sizeof(PSYC_ParseListState));
}
inline void PSYC_nextParseBuffer (PSYC_ParseState* state, PSYC_Array newBuf)
{
state->buffer = newBuf;
state->cursor = 0;
}
inline void PSYC_nextParseListBuffer (PSYC_ParseListState* state, PSYC_Array newBuf)
{
state->buffer = newBuf;
state->cursor = 0;
}
inline size_t PSYC_getContentLength (PSYC_ParseState* s)
{
return s->contentLength;
}
/**
* Determines if the argument is a glyph.
* Glyphs are: : = + - ? !

View File

@ -1,6 +1,11 @@
#include "psyc/lib.h"
#include "psyc/render.h"
inline void PSYC_initRenderState (PSYC_RenderState* state)
{
memset(state, 0, sizeof(PSYC_RenderState));
}
PSYC_RenderRC PSYC_renderVar(PSYC_RenderState* state,
const char* name, size_t nlength,
const char* value, size_t vlength,

View File

@ -1,7 +1,7 @@
#include <psyc.h>
#include <stdint.h>
const PSYC_Array PSYC_routingVars[] =
const PSYC_Array PSYC_routingVars[] = /// Routing variables in alphabetical order.
{
{17, "_amount_fragments"},
{ 8, "_context"},

View File

@ -7,7 +7,7 @@
int main(int argc, char** argv)
{
int index, ret;
uint8_t buffer[2048], modifier;
char buffer[2048], modifier;
PSYC_Array name, value, elem;
PSYC_ParseState state;
PSYC_ParseListState listState;

View File

@ -19,13 +19,13 @@ int writePresence(const char *avail, int availlen, const char *desc, int desclen
}
// if (PSYC_initBuffer(pb, WHATEVER)) die("PSYC_initBuffer hates me");
(void) PSYC_renderHeader(pb, "_context", 0,
myUNI, sizeof(myUNI), PSYC_FLAG_ROUTING, 0);
(void) PSYC_renderVar(pb, "_context", 0,
myUNI, sizeof(myUNI), PSYC_RENDER_ROUTING, 0);
// the first call to PSYC_renderHeader() without PSYC_FLAG_ROUTING adds the
// extra newline to the buffer. later vars with PSYC_FLAG_ROUTING cause an error.
(void) PSYC_renderHeader(pb, "_degree_availability", 0, avail, availlen, 0, C_GLYPH_MODIFIER_ASSIGN);
(void) PSYC_renderHeader(pb, "_description_presence", 0, desc, desclen, 0, C_GLYPH_MODIFIER_ASSIGN);
// the first call to PSYC_renderHeader() without PSYC_RENDER_ROUTING adds the
// extra newline to the buffer. later vars with PSYC_RENDER_ROUTING cause an error.
(void) PSYC_renderVar(pb, "_degree_availability", 0, avail, availlen, 0, C_GLYPH_MODIFIER_ASSIGN);
(void) PSYC_renderVar(pb, "_description_presence", 0, desc, desclen, 0, C_GLYPH_MODIFIER_ASSIGN);
// presence is to be assigned permanently in distributed state
(void) PSYC_renderBody(pb, "_notice_presence", 0,