commit 62ea89b06d106d5b0cdf7b419d2e109f58a8dc13
parent 29c8ad742e449de4c7d56f412790d30f2fc8b1c1
Author: Eduardo Fontana Lazzari <edufonlaz@gmail.com>
Date: Tue, 4 Feb 2025 12:33:06 +0100
Start implementation of sphin_volume parsing
Diffstat:
4 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
@@ -34,7 +34,7 @@ default: build_library
################################################################################
# Library building
################################################################################
-SRC = src/sphin.c src/sphin_config.c
+SRC = src/sphin.c src/sphin_config.c src/sphin_volume.c
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
diff --git a/src/sphin.h b/src/sphin.h
@@ -59,6 +59,8 @@ static const struct sphin_create_args SPHIN_CREATE_ARGS_DEFAULT = {
* must use the functions exposed by the library to manipulate this structure. */
struct sphin; /* Library handler */
struct sphin_config; /* Physical configuration */
+struct sphin_volume;
+// struct sphin_surface;
BEGIN_DECLS
@@ -99,6 +101,25 @@ SPHIN_API res_T
sphin_config_ref_put
(struct sphin_config* config);
+SPHIN_API res_T
+sphin_config_get_volume_count
+ (struct sphin_config* config,
+ size_t* nvolumes);
+
+SPHIN_API res_T
+sphin_config_get_volume
+ (struct sphin_config* config,
+ size_t ivolume,
+ struct sphin_volume** volume);
+
+SPHIN_API res_T
+sphin_volume_ref_get
+ (struct sphin_volume* volume);
+
+SPHIN_API res_T
+sphin_volume_ref_put
+ (struct sphin_volume* volume);
+
END_DECLS
#endif /* SPHIN_H */
diff --git a/src/sphin_config.c b/src/sphin_config.c
@@ -26,9 +26,9 @@
#include "sphin.h"
#include "sphin_c.h"
#include "sphin_config.h"
+#include "sphin_volume.h"
#include <rsys/cstr.h> /* res_to_cstr */
-#include <rsys/ref_count.h> /* ref_T */
#include <rsys/str.h> /* struct str */
#include <rsys/text_reader.h> /* struct txtrdr */
@@ -36,13 +36,6 @@
#include <stdio.h> /* fopen, fclose */
#include <string.h> /* strerror */
-struct sphin_config {
- /* Put the fun things here */
-
- struct sphin* sphin;
- ref_T ref;
-};
-
/*******************************************************************************
* Helper functions
******************************************************************************/
@@ -153,15 +146,15 @@ load_stream
if (0 == strcmp(keyword, "volume")){
if (RES_OK != (res = txtrdr_read_line(txtrdr))) goto error;
- // res = parse_volume(txtrdr, config, name) /* Not yet implemented */
+ res = parse_volume(config, txtrdr, name);
}
else if (0 == strcmp(keyword, "source")){
if (RES_OK != (res = txtrdr_read_line(txtrdr))) goto error;
- // res = parse_source(txtrdr, config, name) /* Not yet implemented */
+ // res = parse_source(txtrdr, config, name); /* Not yet implemented */
}
else if (0 == strcmp(keyword, "surface")){
if (RES_OK != (res = txtrdr_read_line(txtrdr))) goto error;
- // res = parse_surface(txtrdr, config, name) /* Not yet implemented */
+ // res = parse_surface(txtrdr, config, name); /* Not yet implemented */
}
else {
res = RES_BAD_ARG;
diff --git a/src/sphin_config.h b/src/sphin_config.h
@@ -25,8 +25,18 @@
#ifndef SPHIN_CONFIG_H
#define SPHIN_CONFIG_H
+#include <rsys/ref_count.h> /* ref_T */
#include <rsys/rsys.h>
+struct sphin;
+
+struct sphin_config {
+ /* Put the fun things here */
+
+ struct sphin* sphin;
+ ref_T ref;
+};
+
/* Trim leading and trailing spaces and tabs from the input string and return
* the first word. If the input string is empty or if it contains multiple
* words, returns NULL to indicate an error or unexpected format.