server/src/util/order_parser.c

52 lines
1 KiB
C
Raw Normal View History

2018-09-29 18:13:32 +02:00
#ifdef _MSC_VER
#include <platform.h>
#endif
#include "order_parser.h"
#include <stdlib.h>
struct OrderParserStruct {
void *m_userData;
char *m_buffer;
char *m_bufferPtr;
const char *m_bufferEnd;
OP_FactionHandler m_factionHandler;
OP_UnitHandler m_unitHandler;
OP_OrderHandler m_orderHandler;
2018-09-30 13:45:19 +02:00
enum OP_Error m_errorCode;
2018-09-29 18:13:32 +02:00
int m_lineNumber;
};
void OP_SetUnitHandler(OP_Parser op, OP_UnitHandler handler)
{
op->m_unitHandler = handler;
}
void OP_SetFactionHandler(OP_Parser op, OP_FactionHandler handler) {
op->m_factionHandler = handler;
}
void OP_SetOrderHandler(OP_Parser op, OP_OrderHandler handler) {
op->m_orderHandler = handler;
}
void OP_SetUserData(OP_Parser op, void *userData) {
op->m_userData = userData;
}
2018-09-29 18:13:32 +02:00
OP_Parser OP_ParserCreate(void)
{
OP_Parser parser = calloc(1, sizeof(struct OrderParserStruct));
return parser;
2018-09-29 18:13:32 +02:00
}
void OP_ParserFree(OP_Parser op) {
free(op);
}
enum OP_Status OP_Parse(OP_Parser op, const char *s, int len, int isFinal)
{
return OP_STATUS_OK;
}