[ADD/WIP] Create and use basic command parser

Still need to write the router.
This commit is contained in:
LDA 2024-06-28 22:34:28 +02:00
commit c4b7d1b92a
6 changed files with 220 additions and 12 deletions

21
src/include/Command.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef PARSEE_COMMAND_H
#define PARSEE_COMMAND_H
#include <Cytoplasm/HashMap.h>
typedef struct Command {
char *command;
HashMap *arguments;
} Command;
typedef struct CommandRouter CommandRouter;
typedef void (*CommandRoute)(Command *cmd, void *data);
extern CommandRouter * CommandCreateRouter(void);
extern void CommandAddCommand(CommandRouter *rter, char *c, CommandRoute rte);
extern void RouteCommand(CommandRouter *rter, Command *cmd, void *data);
extern void CommandFreeRouter(CommandRouter *rter);
extern Command * CommandParse(char *cmd);
extern void CommandFree(Command *command);
#endif

View file

@ -9,6 +9,7 @@
#include <pthread.h>
#include <Command.h>
#include <XMPP.h>
typedef struct ParseeConfig {
@ -43,6 +44,7 @@ typedef struct ParseeConfig {
typedef struct ParseeData {
const ParseeConfig *config;
HttpRouter *router;
CommandRouter *handler;
XMPPComponent *jabber;