diff --git a/debian/var/models/example_II.xml b/debian/var/models/example_II.xml
index 502f83a..14acf41 100644
--- a/debian/var/models/example_II.xml
+++ b/debian/var/models/example_II.xml
@@ -6,8 +6,9 @@
- Modèle de test
-
+ Model created for testing purposes
+
+ Jean Sirmai
2
1629830000
1.0
@@ -15,14 +16,14 @@
-
+
-
+
@@ -31,13 +32,13 @@
-
+
-
-
+
@@ -63,15 +64,15 @@
-
-
+
+
-
-
+
+
@@ -94,7 +95,11 @@
- [https://www.a-lec.org]
- Quote
+ [
+ https://www.a-lec.org
+ ]
+
+ This is a quote.
+
diff --git a/include/cmds.h b/include/cmds.h
index a4280d6..720c583 100644
--- a/include/cmds.h
+++ b/include/cmds.h
@@ -26,6 +26,11 @@
/* -------------------------------------------------------------------------- */
+#define LINE_LENGTH 80
+#define LINE_NUMBER 24
+
+/* -------------------------------------------------------------------------- */
+
struct Command_t {
const char *name;
char* (*execute)(char*, char**, Server_t*);
@@ -42,10 +47,3 @@ char *CmdShutdown(char*, char**, Server_t*);
char *CmdHelp(char*, char**, Server_t*);
/* -------------------------------------------------------------------------- */
-
-Command_t cmdList[] =
-{
- {"help", CmdHelp, "Help command"},
- {"model", CmdModel, "Model command"},
- {"shutdown", CmdShutdown, "Shutdown command"},
-};
diff --git a/include/model.h b/include/model.h
index 02b23af..9e1666d 100644
--- a/include/model.h
+++ b/include/model.h
@@ -24,9 +24,12 @@
#include "../include/base.h"
#endif
+#include
+#include
+
/* -------------------------------------------------------------------------- */
-#define MODEL_STRING_SIZE 48
+#define MODEL_STRING_SIZE 64
#define MAX_MODEL_NUMBER 1
#define ARROW_NUMBER 6
diff --git a/include/parsing.h b/include/parsing.h
index 3e28962..6fe8bf6 100644
--- a/include/parsing.h
+++ b/include/parsing.h
@@ -24,8 +24,46 @@
#include "../include/base.h"
#endif
+#include
+#include
+#include
+
/* -------------------------------------------------------------------------- */
+#define NO_DESTINATION NULL
+
+/* -------------------------------------------------------------------------- */
+
+struct ModelParserTableXML_t;
+
+struct ParserTableXML_t
+{
+ const xmlChar *tag;
+ int (*parse) (xmlDoc*,
+ struct ModelParserTableXML_t*,
+ int currentParser,
+ xmlNode*);
+ void *destination;
+} typedef ParserTableXML_t;
+
+struct ModelParserTableXML_t
+{
+ size_t len;
+ ParserTableXML_t *table;
+} typedef ModelParserTableXML_t;
+
+/* -------------------------------------------------------------------------- */
+
+int parseParentFieldXML(xmlDocPtr,
+ ModelParserTableXML_t*,
+ int,
+ xmlNodePtr);
+
+int parseTextField(xmlDocPtr,
+ ModelParserTableXML_t*,
+ int,
+ xmlNodePtr);
+
int ParseModelXML(Model_t*);
/* -------------------------------------------------------------------------- */
diff --git a/include/scheduler.h b/include/scheduler.h
index adc07b8..eeec788 100644
--- a/include/scheduler.h
+++ b/include/scheduler.h
@@ -24,6 +24,8 @@
#include "../include/base.h"
#endif
+#include
+
/* -------------------------------------------------------------------------- */
// -------------------------------------------------------------------------- //
diff --git a/include/server.h b/include/server.h
index 8110fb0..f03d624 100644
--- a/include/server.h
+++ b/include/server.h
@@ -24,6 +24,13 @@
#include "../include/base.h"
#endif
+#include
+#include
+#include
+#include
+#include
+#include
+
/* -------------------------------------------------------------------------- */
// -------------------------------------------------------------------------- //
diff --git a/src/centers.c b/src/centers.c
index 6a3d0d5..0984b87 100644
--- a/src/centers.c
+++ b/src/centers.c
@@ -19,7 +19,7 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/centers.h"
/* -------------------------------------------------------------------------- */
diff --git a/src/cmds.c b/src/cmds.c
index 7dbff48..e6557c2 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -19,15 +19,12 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/cmds.h"
#include "../include/scheduler.h"
#include "../include/model.h"
#include
-#define LINE_LENGTH 80
-#define LINE_NUMBER 24
-
/* -------------------------------------------------------------------------- */
char *CmdModel(char *buf, char **argv, Server_t *args)
diff --git a/src/model.c b/src/model.c
index 8265f16..e5b4ae0 100644
--- a/src/model.c
+++ b/src/model.c
@@ -19,14 +19,10 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/model.h"
#include "../include/parsing.h"
#include "../include/arrows.h"
#include "../include/scheduler.h"
-#include "../include/model.h"
-
-#include
-#include
static Model_t **loadedModel;
static int loadedModelSize; // begins to 1
@@ -37,8 +33,6 @@ static int knownModelSize; // begins to 1
Model_t *lastModel;
Model_t **lastModelAddr;
-void ModelSystemDestroy(void);
-
/* -------------------------------------------------------------------------- */
void printModels(char *buf)
diff --git a/src/parsing.c b/src/parsing.c
index 105f052..9d15443 100644
--- a/src/parsing.c
+++ b/src/parsing.c
@@ -19,51 +19,9 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/parsing.h"
#include "../include/model.h"
-#include
-#include
-#include
-
-/* -------------------------------------------------------------------------- */
-
-#define NO_DESTINATION NULL
-
-/* -------------------------------------------------------------------------- */
-
-struct ModelParserTableXML_t;
-
-struct ParserTableXML_t
-{
- const xmlChar *tag;
- int (*parse) (xmlDoc*,
- struct ModelParserTableXML_t*,
- int currentParser,
- xmlNode*);
- void *destination;
-} typedef ParserTableXML_t;
-
-struct ModelParserTableXML_t
-{
- size_t len;
- ParserTableXML_t *table;
-} typedef ModelParserTableXML_t;
-
-/* -------------------------------------------------------------------------- */
-
-int parseParentFieldXML(xmlDocPtr,
- ModelParserTableXML_t*,
- int,
- xmlNodePtr);
-
-int parseTextField(xmlDocPtr,
- ModelParserTableXML_t*,
- int,
- xmlNodePtr);
-
-/* -------------------------------------------------------------------------- */
-
// -------------------------------------------------------------------------- //
// Parsing NOTHING (but yeah that prints) //
// -------------------------------------------------------------------------- //
@@ -85,11 +43,12 @@ int parseStubFieldXML (xmlDocPtr doc,
// Detect children
if (currentNode->xmlChildrenNode) {
- printLog("%s has children\n", ModelTable->table[currentParser].tag);
+ printLog("%s (stub) has children\n",
+ ModelTable->table[currentParser].tag);
}
}
- printLog("%s: %s\n", ModelTable->table[currentParser].tag,
+ printLog("%s (stub): %s\n", ModelTable->table[currentParser].tag,
content);
if (!content) {
@@ -198,10 +157,48 @@ int parseParentFieldXML (xmlDocPtr doc,
int currentParser,
xmlNodePtr currentNode)
{
+ printLog("%s parsed\n",
+ ModelTable->table[currentParser].tag);
+
+ // Getting children content
currentNode = currentNode->xmlChildrenNode;
+ while (currentNode != NULL) {
+ for (int i = 0; i < ModelTable->len; i++) {
+ if ((!xmlStrcmp(currentNode->name,
+ ModelTable->table[i].tag))) {
+ ModelTable->table[i].parse(doc,
+ ModelTable,
+ i,
+ currentNode);
+ break;
+ }
+ }
+ currentNode = currentNode->next;
+ }
+ return 0;
+}
- printLog("%s parsed\n", ModelTable->table[currentParser].tag);
+// -------------------------------------------------------------------------- //
+// Parsing a field that contains children fields with props //
+// -------------------------------------------------------------------------- //
+int parseParentFieldPropsXML (xmlDocPtr doc,
+ ModelParserTableXML_t *ModelTable,
+ int currentParser,
+ xmlNodePtr currentNode)
+{
+ xmlChar *id, *date, *author;
+ // (truc*)destination = (truc*)ModelTable->table[currentParser].destination;
+ // Getting field identity
+ id = xmlGetProp(currentNode, (xmlChar*)"id");
+ date = xmlGetProp(currentNode, (xmlChar*)"date");
+ author = xmlGetProp(currentNode, (xmlChar*)"author");
+
+ printLog("%s parsed (id=%s, date=%s, author=%s)\n",
+ ModelTable->table[currentParser].tag, id, date, author);
+
+ // Getting children content
+ currentNode = currentNode->xmlChildrenNode;
while (currentNode != NULL) {
for (int i = 0; i < ModelTable->len; i++) {
if ((!xmlStrcmp(currentNode->name,
@@ -226,24 +223,24 @@ int ParseModelXML(Model_t *model)
ParserTableXML_t table[] =
{
// IDENTITY
- {(const xmlChar *)"identity", parseParentFieldXML,model},
- {(const xmlChar *)"name", parseTextFieldXML, model->name},
- {(const xmlChar *)"owner", parseTextFieldXML, model->owner},
+ {(const xmlChar *)"identity", parseParentFieldXML, model},
+ {(const xmlChar *)"name", parseTextFieldXML, model->name},
+ {(const xmlChar *)"owner", parseTextFieldXML, model->owner},
// TODO lacking implementation (model side)
- {(const xmlChar *)"owner_id", parseStubFieldXML, model->owner_id},
+ {(const xmlChar *)"owner_id", parseStubFieldXML, model->owner_id},
- {(const xmlChar *)"date", parseIntFieldXML, &model->date},
- {(const xmlChar *)"version", parseTextFieldXML, model->version},
+ {(const xmlChar *)"date", parseIntFieldXML, &model->date},
+ {(const xmlChar *)"version", parseTextFieldXML, model->version},
// PARAMETERS
- {(const xmlChar *)"parameters", parseParentFieldXML, model},
+ {(const xmlChar *)"parameters", parseParentFieldPropsXML, model},
// MODELIZATION
{(const xmlChar *)"modelization", parseParentFieldXML, model},
{(const xmlChar *)"max_thread", parseStubFieldXML, model},
{(const xmlChar *)"max_cycles", parseStubFieldXML, model},
// SPACE
- {(const xmlChar *)"space", parseParentFieldXML, model},
+ {(const xmlChar *)"space_param", parseParentFieldXML, model},
{(const xmlChar *)"dimension", parseStubFieldXML, model},
{(const xmlChar *)"size", parseStubFieldXML, model},
{(const xmlChar *)"site_multiplicity", parseStubFieldXML, model},
@@ -253,19 +250,19 @@ int ParseModelXML(Model_t *model)
// OBJECTS
{(const xmlChar *)"objects", parseParentFieldXML, model},
- {(const xmlChar *)"object", parseParentFieldXML, model},
+ {(const xmlChar *)"object", parseParentFieldPropsXML, model},
// SPACE
- {(const xmlChar *)"space", parseParentFieldXML, model},
+ {(const xmlChar *)"space", parseParentFieldPropsXML, model},
// SAVESTATES
- {(const xmlChar *)"savestates", parseParentFieldXML, model},
+ {(const xmlChar *)"savestates", parseParentFieldPropsXML, model},
// TRANSITIONS
- {(const xmlChar *)"transitions", parseParentFieldXML, model},
+ {(const xmlChar *)"transitions", parseParentFieldPropsXML, model},
// TRANSITION
// TODO probability
- {(const xmlChar *)"transition", parseParentFieldXML, model},
+ {(const xmlChar *)"transition", parseParentFieldPropsXML, model},
{(const xmlChar *)"if", parseParentFieldXML, model},
{(const xmlChar *)"then", parseParentFieldXML, model},
diff --git a/src/scheduler.c b/src/scheduler.c
index ecb3f37..c159bf4 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -19,7 +19,7 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/scheduler.h"
#include "../include/centers.h"
#include "../include/worker.h"
#include "../include/arrows.h"
diff --git a/src/server.c b/src/server.c
index 494f548..f9986b4 100644
--- a/src/server.c
+++ b/src/server.c
@@ -19,18 +19,18 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/server.h"
#include "../include/cmds.h"
-#include
-#include
-#include
-#include
-#include
-#include
-
/* -------------------------------------------------------------------------- */
+static Command_t cmdList[] =
+{
+ {"help", CmdHelp, "Help command"},
+ {"model", CmdModel, "Model command"},
+ {"shutdown", CmdShutdown, "Shutdown command"},
+};
+
static void *serverMain(void *server);
/* -------------------------------------------------------------------------- */
diff --git a/src/supervisor.c b/src/supervisor.c
index 385647d..9849f8b 100644
--- a/src/supervisor.c
+++ b/src/supervisor.c
@@ -19,7 +19,7 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/supervisor.h"
/* -------------------------------------------------------------------------- */
diff --git a/src/worker.c b/src/worker.c
index 356c103..a943360 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -19,7 +19,7 @@
// along with this program. If not, see . //
//=-------------------------------------------------------------------------=//
-#include "../include/base.h"
+#include "../include/worker.h"
/* -------------------------------------------------------------------------- */