1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

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. * @return An instance of the PSYC_Array struct.
*/ */
inline PSYC_Array PSYC_createArray (const char* memory, size_t length) inline PSYC_Array PSYC_createArray (const char* memory, size_t length);
{
PSYC_Array arr = {length, memory}; /**
return arr; * 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. * 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 state Pointer to the state struct that should be initiated.
* @param flags Flags to be set for the parser, see PSYC_ParseFlag. * @param flags Flags to be set for the parser, see PSYC_ParseFlag.
*/ */
inline void PSYC_initParseState2 (PSYC_ParseState* state, uint8_t flags) 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));
}
/** /**
* Initiates the list state struct. * Initiates the list state struct.
* *
* @param state Pointer to the list state struct that should be initiated. * @param state Pointer to the list state struct that should be initiated.
*/ */
inline void PSYC_initParseListState (PSYC_ParseListState* state) inline void PSYC_initParseListState (PSYC_ParseListState* state);
{
memset(state, 0, sizeof(PSYC_ParseListState));
}
inline void PSYC_nextParseBuffer (PSYC_ParseState* state, PSYC_Array newBuf) 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) inline void PSYC_nextParseListBuffer (PSYC_ParseListState* state, PSYC_Array newBuf);
{
state->buffer = newBuf;
state->cursor = 0;
}
inline size_t PSYC_getContentLength (PSYC_ParseState* s) inline size_t PSYC_getContentLength (PSYC_ParseState* s);
{
return s->contentLength;
}
/** /**
* Parse PSYC packets. * Parse PSYC packets.

View file

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

View file

@ -15,6 +15,45 @@
return ret; \ 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. * Determines if the argument is a glyph.
* Glyphs are: : = + - ? ! * Glyphs are: : = + - ? !

View file

@ -1,6 +1,11 @@
#include "psyc/lib.h" #include "psyc/lib.h"
#include "psyc/render.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, PSYC_RenderRC PSYC_renderVar(PSYC_RenderState* state,
const char* name, size_t nlength, const char* name, size_t nlength,
const char* value, size_t vlength, const char* value, size_t vlength,

View file

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

View file

@ -7,7 +7,7 @@
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int index, ret; int index, ret;
uint8_t buffer[2048], modifier; char buffer[2048], modifier;
PSYC_Array name, value, elem; PSYC_Array name, value, elem;
PSYC_ParseState state; PSYC_ParseState state;
PSYC_ParseListState listState; 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"); // if (PSYC_initBuffer(pb, WHATEVER)) die("PSYC_initBuffer hates me");
(void) PSYC_renderHeader(pb, "_context", 0, (void) PSYC_renderVar(pb, "_context", 0,
myUNI, sizeof(myUNI), PSYC_FLAG_ROUTING, 0); myUNI, sizeof(myUNI), PSYC_RENDER_ROUTING, 0);
// the first call to PSYC_renderHeader() without PSYC_FLAG_ROUTING adds the // the first call to PSYC_renderHeader() without PSYC_RENDER_ROUTING adds the
// extra newline to the buffer. later vars with PSYC_FLAG_ROUTING cause an error. // extra newline to the buffer. later vars with PSYC_RENDER_ROUTING cause an error.
(void) PSYC_renderHeader(pb, "_degree_availability", 0, avail, availlen, 0, C_GLYPH_MODIFIER_ASSIGN); (void) PSYC_renderVar(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); (void) PSYC_renderVar(pb, "_description_presence", 0, desc, desclen, 0, C_GLYPH_MODIFIER_ASSIGN);
// presence is to be assigned permanently in distributed state // presence is to be assigned permanently in distributed state
(void) PSYC_renderBody(pb, "_notice_presence", 0, (void) PSYC_renderBody(pb, "_notice_presence", 0,