WIP: cleaning, simplifying, organizing #include parsing
This commit is contained in:
parent
45cecfe805
commit
f143664a5b
6
Makefile
6
Makefile
|
@ -5,13 +5,11 @@
|
|||
NTHREADS= $(shell nproc)
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=`pkg-config --cflags gtk4 gl glib-2.0`
|
||||
LDFLAGS=`pkg-config --libs gtk4 gl glib-2.0`
|
||||
CFLAGS=`pkg-config --cflags gtk4 gl glib-2.0 libxml-2.0`
|
||||
LDFLAGS=`pkg-config --libs gtk4 gl glib-2.0 libxml-2.0` -lGL -lGLU -lm -lepoxy -lX11 -lGLEW
|
||||
WARNINGS = -Wall
|
||||
DEBUG = -ggdb -fno-omit-frame-pointer #-fdiagnostics-color=always -fsanitize=bounds -fstack-check
|
||||
OPTIMIZE = -O3
|
||||
INCLUDE= $(shell pkg-config --cflags glib-2.0 libxml-2.0 gtk4)
|
||||
LIBS= $(shell pkg-config --libs glib-2.0 libxml-2.0 gtk4) -lGL -lGLU -lm -lepoxy -lX11 -lGLEW
|
||||
|
||||
BINDIR=bin
|
||||
BUILDDIR=build
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <libxml/xmlreader.h> // http://xmlsoft.org/examples/#parse1.c
|
||||
// https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/general.html
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#define READ_SITE 1 << 0
|
||||
#define READ_WEIGHT 1 << 1
|
||||
#define READ_X 1 << 2
|
||||
|
@ -125,8 +127,7 @@ static inline xmlChar* getFirstTag(xmlChar *path)
|
|||
path = (xmlChar *)xmlStrchr(path, '/');
|
||||
path = xmlStrsub (path, 1, xmlStrlen(path));
|
||||
|
||||
//printf("%s = %s + / + %s\n", preop,\
|
||||
xmlStrsub (preop, 0, xmlStrlen(preop) - xmlStrlen(path) - 1), path);
|
||||
//printf("%s = %s + / + %s\n", preop, xmlStrsub (preop, 0, xmlStrlen(preop) - xmlStrlen(path) - 1), path);
|
||||
|
||||
return xmlStrsub (preop, 0, xmlStrlen(preop) - xmlStrlen(path) - 1);
|
||||
}
|
||||
|
@ -146,7 +147,7 @@ static xmlNodePtr model_get_node(xmlChar *path)
|
|||
{
|
||||
xmlNodePtr node;
|
||||
xmlChar *extrait;
|
||||
xmlChar *reste, *last, *affich;
|
||||
xmlChar *reste, *last;
|
||||
|
||||
// Lookup for node from path in hash table
|
||||
node = xmlHashLookup(model_hashtable, path);
|
||||
|
@ -158,7 +159,6 @@ static xmlNodePtr model_get_node(xmlChar *path)
|
|||
// no node found in hash table
|
||||
} else {
|
||||
reste = path;
|
||||
affich = reste;
|
||||
last = getLastTag(reste);
|
||||
node = xmlDocGetRootElement(model);
|
||||
|
||||
|
@ -220,7 +220,7 @@ static inline bool model_get_node_str_attrib(xmlNodePtr node,
|
|||
while(attribute && attribute->name && attribute->children) {
|
||||
if (!xmlStrcmp(attribute->name, (const xmlChar *)id)) {
|
||||
value = xmlNodeListGetString(node->doc, attribute->children, 1);
|
||||
strcpy(dest, value);
|
||||
strcpy(dest, (char *)value);
|
||||
xmlFree(value);
|
||||
return true;
|
||||
}
|
||||
|
@ -234,8 +234,8 @@ static inline bool model_get_node_str_attrib(xmlNodePtr node,
|
|||
|
||||
char model_get_dim(void)
|
||||
{
|
||||
xmlAttr *attribute;
|
||||
xmlChar* value;
|
||||
// xmlAttr *attribute;
|
||||
// xmlChar* value;
|
||||
xmlNodePtr node = model_get_node(
|
||||
(xmlChar *)"parameters/space-param/dimension");
|
||||
|
||||
|
@ -247,19 +247,19 @@ char model_get_dim(void)
|
|||
|
||||
long model_get_dim_value(const char *axis)
|
||||
{
|
||||
xmlAttr *attribute;
|
||||
xmlChar *value;
|
||||
long ret_value;
|
||||
// xmlAttr *attribute;
|
||||
// xmlChar *value;
|
||||
// long ret_value;
|
||||
xmlNodePtr node = model_get_node(
|
||||
(xmlChar *)"parameters/space-param/dimension");
|
||||
|
||||
return model_get_node_long_attrib(node, axis);
|
||||
return model_get_node_long_attrib(node, (char *)axis);
|
||||
}
|
||||
|
||||
char model_get_multiplicity(void)
|
||||
{
|
||||
xmlAttr *attribute;
|
||||
xmlChar* value;
|
||||
// xmlAttr *attribute;
|
||||
// xmlChar* value;
|
||||
xmlNodePtr node = model_get_node(
|
||||
(xmlChar *)"parameters/space-param/site_multiplicity");
|
||||
|
||||
|
@ -273,8 +273,8 @@ char model_get_multiplicity(void)
|
|||
bool model_get_next_state(char *new_state_id)
|
||||
{
|
||||
static xmlNodePtr cur_node = NULL;
|
||||
xmlAttr *attribute;
|
||||
xmlChar *value;
|
||||
// xmlAttr *attribute;
|
||||
// xmlChar *value;
|
||||
|
||||
if (cur_node == NULL) {
|
||||
// Get first state
|
||||
|
@ -299,11 +299,11 @@ bool model_get_next_state(char *new_state_id)
|
|||
long model_get_state_arrows_count(const char *state_id)
|
||||
{
|
||||
xmlNodePtr cur_node = NULL;
|
||||
xmlAttr *attribute;
|
||||
// xmlAttr *attribute;
|
||||
long value = 0;
|
||||
bool found = false;
|
||||
char temp_char[25];
|
||||
uint check = 0; // bit field checker
|
||||
// uint check = 0; // bit field checker
|
||||
|
||||
//printf("NEW CALL : cur_node = %p\n", cur_node);
|
||||
|
||||
|
@ -314,11 +314,11 @@ long model_get_state_arrows_count(const char *state_id)
|
|||
|
||||
// Lookup in properties
|
||||
while (cur_node && cur_node->properties) {
|
||||
attribute = cur_node->properties;
|
||||
// attribute = cur_node->properties; < usage ?
|
||||
|
||||
// Look for the id attribute
|
||||
if (model_get_node_str_attrib(cur_node, "id", &temp_char)) {
|
||||
if (!xmlStrcmp(temp_char, (const xmlChar *)state_id)) {
|
||||
if (model_get_node_str_attrib(cur_node, "id", (char *)&temp_char)) {
|
||||
if (!xmlStrcmp((const xmlChar *)temp_char, (const xmlChar *)state_id)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -372,8 +372,8 @@ bool model_get_next_arrow(struct arrow_t *new_arrow,
|
|||
attribute = cur_node->properties;
|
||||
|
||||
// Look for the id attribute
|
||||
if (model_get_node_str_attrib(cur_node, "id", &temp_char)) {
|
||||
if (!xmlStrcmp(temp_char, (const xmlChar *)state_id)) {
|
||||
if (model_get_node_str_attrib(cur_node, "id", (char *)&temp_char)) {
|
||||
if (!xmlStrcmp((xmlChar *)temp_char, (const xmlChar *)state_id)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#pragma once
|
||||
#include <unistd.h>
|
||||
#include "base.h"
|
||||
|
||||
bool model_init(const char *content, size_t length, const char *basename);
|
||||
bool model_shutdown(void);
|
Loading…
Reference in New Issue