commit cbe5b2bd9d843800f426e134543211b225c0b214
parent f0c80eb1129eca6c06ee2c622f8b90057f5346fe
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 27 Jan 2026 15:21:31 +0100
Rename the sphin tool to sphin-lint
Its C file, as well as its manual pages (and references to them) are
renamed accordingly.
Diffstat:
7 files changed, 234 insertions(+), 233 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -12,8 +12,8 @@ spectral_property.txt
source_spec.txt
tags
star-phor-input.5
-sphin.1
-sphin
+sphin-lint.1
+sphin-lint
test_sphin
test_sphin_load_geometry
test_sphin_load_prop_rad
diff --git a/Makefile b/Makefile
@@ -83,7 +83,7 @@ $(LIBNAME): $(OBJ)
################################################################################
# Executable building
################################################################################
-SRC_TOOL = src/sphin_main.c
+SRC_TOOL = src/sphin_lint.c
OBJ_TOOL = $(SRC_TOOL:.c=.o)
DEP_TOOL = $(SRC_TOOL:.c=.d)
@@ -96,9 +96,10 @@ CFLAGS_TOOL = -std=c99 $(CFLAGS_EXE) $(INCS_TOOL)
LDFLAGS_TOOL = $(LDFLAGS_EXE) $(LIBS_TOOL)
tool: $(DEP_TOOL)
- @$(MAKE) -fMakefile $$(for i in $(DEP_TOOL); do echo -f $${i}; done) sphin
+ @$(MAKE) -fMakefile $$(for i in $(DEP_TOOL); do echo -f $${i}; done) \
+ sphin-lint
-sphin: .config $(OBJ_TOOL) sphin-local.pc
+sphin-lint: .config $(OBJ_TOOL) sphin-local.pc
$(CC) $(CFLAGS_EXE) -o $@ $(OBJ_TOOL) $(LDFLAGS_TOOL)
$(DEP_TOOL) $(OBJ_TOOL): .config sphin-local.pc
@@ -110,7 +111,7 @@ $(OBJ_TOOL):
$(CC) $(CFLAGS_TOOL) -c $(@:.o=.c) -o $@
clean_tool:
- rm -f $(DEP_TOOL) $(OBJ_TOOL) sphin
+ rm -f $(DEP_TOOL) $(OBJ_TOOL) sphin-lint
################################################################################
# Installation
@@ -122,10 +123,10 @@ pkg:
-e 's#@SSTL_VERSION@#$(SSTL_VERSION)#g'\
sphin.pc.in > sphin.pc
-sphin.1: doc/sphin.1.scd
+sphin-lint.1: doc/sphin-lint.1.scd
star-phor-input.5: doc/star-phor-input.5.scd
-sphin.1 star-phor-input.5:
+sphin-lint.1 star-phor-input.5:
scdoc < doc/$@.scd > $@
sphin-local.pc: sphin.pc.in
@@ -137,17 +138,17 @@ sphin-local.pc: sphin.pc.in
-e 's#@SSTL_VERSION@#$(SSTL_VERSION)#g'\
sphin.pc.in > $@
-install: library tool pkg star-phor-input.5 sphin.1
+install: library tool pkg star-phor-input.5 sphin-lint.1
install() { mode="$$1"; prefix="$$2"; shift 2; \
mkdir -p "$${prefix}"; \
cp "$$@" "$${prefix}"; \
chmod "$${mode}" "$$@"; \
}; \
install 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \
- install 755 "$(DESTDIR)$(BINPREFIX)" sphin; \
+ install 755 "$(DESTDIR)$(BINPREFIX)" sphin-lint; \
install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" sphin.pc; \
install 644 "$(DESTDIR)$(INCPREFIX)/star" src/sphin.h; \
- install 644 "$(DESTDIR)$(MANPREFIX)/man1" sphin.1; \
+ install 644 "$(DESTDIR)$(MANPREFIX)/man1" sphin-lint.1; \
install 644 "$(DESTDIR)$(MANPREFIX)/man5" star-phor-input.5; \
install 644 "$(DESTDIR)$(PREFIX)/share/doc/star-phor-input" COPYING; \
install 644 "$(DESTDIR)$(PREFIX)/share/doc/star-phor-input" README.md
@@ -155,16 +156,16 @@ install: library tool pkg star-phor-input.5 sphin.1
uninstall:
rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)"
rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/sphin.pc"
- rm -f "$(DESTDIR)$(BINPREFIX)/sphin"
+ rm -f "$(DESTDIR)$(BINPREFIX)/sphin-lint"
rm -f "$(DESTDIR)$(INCPREFIX)/star/sphin.h"
rm -f "$(DESTDIR)$(MANPREFIX)/man5/star-phor-input.5"
- rm -f "$(DESTDIR)$(MANPREFIX)/man1/sphin.1"
+ rm -f "$(DESTDIR)$(MANPREFIX)/man1/sphin-lint.1"
rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-phor-input/COPYING"
rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-phor-input/README.md"
clean: clean_test clean_tool
rm -f $(DEP) $(OBJ) $(LIBNAME)
- rm -f .config sphin-local.pc sphin.pc star-phor-input.5 sphin.1
+ rm -f .config sphin-local.pc sphin.pc star-phor-input.5 sphin-lint.1
################################################################################
# Tests
diff --git a/doc/sphin-lint.1.scd b/doc/sphin-lint.1.scd
@@ -0,0 +1,74 @@
+sphin-lint(1) "UNIX"
+
+; Copyright (C) 2024-2026 Centre National de la Recherche Scientifique
+; Copyright (C) 2024-2026 Clermont Auvergne INP
+; Copyright (C) 2024-2026 INSA Lyon
+; Copyright (C) 2024-2026 Institut Mines Télécom Albi-Carmaux
+; Copyright (C) 2024-2026 Institut National Polytechnique de Toulouse
+; Copyright (C) 2024-2026 |Méso|Star> (contact@meso-star.com)
+; Copyright (C) 2024-2026 PhotonLyX (info@photonlyx.com)
+; Copyright (C) 2024-2026 Université de Lorraine
+; Copyright (C) 2024-2026 Université Paul Sabatier
+; Copyright (C) 2024-2026 Université Toulouse - Jean Jaurès
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, either version 3 of the License, or
+; (at your option) any later version.
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# NAME
+
+sphin-lint - tool for analysing a photoreactive configuration
+
+# SYNOPSIS
+
+*sphin-lint* [*-hv*]
+
+# DESCRIPTION
+
+*sphin-lint* is an utility that verifies the numerical consistency of a given
+_star-phor-input_(5) file.
+
+The options are as follows:
+
+*-h*
+ Display short help and exit.
+
+*-v*
+ Make sphin verbose. Multiple *-v* options increase the verbosity.
+ The maximum is 3.
+
+# EXAMPLES
+
+Load a photoreactive system description from a local file:
+
+```
+sphin-lint photoreactive_description_file.txt
+```
+
+Load a photoreactive system description from the standard input:
+
+```
+cat photoreactive_description_file.txt | sphin-lint
+```
+
+# ERRORS
+
+The sphin-lint utility exits 0 on success, and >0 if an error occurs.
+
+# SEE ALSO
+
+_star-phor-input_(5)
+
+# HISTORY
+
+*sphin-lint* has been developed thanks to the funding of the ECOCHEM project
+(ProjetIA-22-PESP-0006) belonging to the *PEPR SPLEEN*.
diff --git a/doc/sphin.1.scd b/doc/sphin.1.scd
@@ -1,74 +0,0 @@
-sphin(1) "UNIX"
-
-; Copyright (C) 2024-2026 Centre National de la Recherche Scientifique
-; Copyright (C) 2024-2026 Clermont Auvergne INP
-; Copyright (C) 2024-2026 INSA Lyon
-; Copyright (C) 2024-2026 Institut Mines Télécom Albi-Carmaux
-; Copyright (C) 2024-2026 Institut National Polytechnique de Toulouse
-; Copyright (C) 2024-2026 |Méso|Star> (contact@meso-star.com)
-; Copyright (C) 2024-2026 PhotonLyX (info@photonlyx.com)
-; Copyright (C) 2024-2026 Université de Lorraine
-; Copyright (C) 2024-2026 Université Paul Sabatier
-; Copyright (C) 2024-2026 Université Toulouse - Jean Jaurès
-;
-; This program is free software: you can redistribute it and/or modify
-; it under the terms of the GNU General Public License as published by
-; the Free Software Foundation, either version 3 of the License, or
-; (at your option) any later version.
-;
-; This program is distributed in the hope that it will be useful,
-; but WITHOUT ANY WARRANTY; without even the implied warranty of
-; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-; GNU General Public License for more details.
-;
-; You should have received a copy of the GNU General Public License
-; along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# NAME
-
-sphin - numerical consistency utility for photoreactive system description files
-
-# SYNOPSIS
-
-*sphin* [*-hv*]
-
-# DESCRIPTION
-
-*sphin* is an utility that verifies the numerical consistency of a given
-_star-phor-input_(5) file.
-
-The options are as follows:
-
-*-h*
- Display short help and exit.
-
-*-v*
- Make sphin verbose. Multiple -v options increase the verbosity.
- The maximum is 3.
-
-# EXAMPLES
-
-Load a photoreactive system description from a local file:
-
-```
-sphin photoreactive_description_file.txt
-```
-
-Load a photoreactive system description from the standard input:
-
-```
-cat photoreactive_description_file.txt | sphin
-```
-
-# ERRORS
-
-The sphin utility exits 0 on success, and >0 if an error occurs.
-
-# SEE ALSO
-
-_star-phor-input_(5)
-
-# HISTORY
-
-*star-phor-input* has been developed thanks to the funding of the ECOCHEM
-project (ProjetIA-22-PESP-0006) belonging to the *PEPR SPLEEN*.
diff --git a/doc/star-phor-input.5.scd b/doc/star-phor-input.5.scd
@@ -304,7 +304,7 @@ surface: "light source back"
# SEE ALSO
-_sphin_(1)
+_sphin-lint_(1)
https://en.wikipedia.org/wiki/Backus-Naur_form
diff --git a/src/sphin_lint.c b/src/sphin_lint.c
@@ -0,0 +1,144 @@
+/* Copyright (C) 2024-2026 Centre National de la Recherche Scientifique
+ * Copyright (C) 2024-2026 Clermont Auvergne INP
+ * Copyright (C) 2024-2026 INSA Lyon
+ * Copyright (C) 2024-2026 Institut Mines Télécom Albi-Carmaux
+ * Copyright (C) 2024-2026 Institut National Polytechnique de Toulouse
+ * Copyright (C) 2024-2026 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2024-2026 PhotonLyX (info@photonlyx.com)
+ * Copyright (C) 2024-2026 Université de Lorraine
+ * Copyright (C) 2024-2026 Université Paul Sabatier
+ * Copyright (C) 2024-2026 Université Toulouse - Jean Jaurès
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#define _POSIX_C_SOURCE 200112L /* for getopt support */
+
+#include "sphin.h"
+
+#include <rsys/cstr.h>
+#include <rsys/mem_allocator.h>
+#include <rsys/rsys.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+struct args {
+ int verbose; /* Verbosity level. Bigger values => more verbosity */
+ int quit;
+ char* filename; /* NULL => use stdin */
+};
+
+#define ARGS_DEFAULT__ {0, 0, NULL}
+static const struct args ARGS_DEFAULT = ARGS_DEFAULT__;
+
+static void
+usage
+ (FILE* stream)
+{
+ ASSERT(NULL != stream);
+ fprintf(stream, "Usage: sphin-lint [-hv] [file]\n");
+}
+
+static res_T
+parse_args
+ (struct args* args, int argc, char** argv)
+{
+ int opt = 0;
+ res_T res = RES_OK;
+
+ ASSERT(NULL != args);
+ ASSERT(NULL != argv);
+ ASSERT(argc > 0);
+
+ *args = ARGS_DEFAULT;
+
+ while((opt = getopt(argc, argv, "hv")) != -1) {
+ switch(opt) {
+ case 'v':
+ /* Increase the verbosity level counter for each 'v' entered, up to a
+ * maximum of 3. We use the boolean value of (3 > args->verbose): if
+ * the condition is true, it evaluates to 1, increasing the counter.
+ * Otherwise, it evaluates to 0, leaving the counter unchanged. */
+ args->verbose += (3 > args->verbose);
+ break;
+ case 'h':
+ usage(stdout);
+ args->quit = 1;
+ break;
+ default:
+ res = RES_BAD_ARG;
+ goto error;
+ }
+ if (RES_OK != res) { goto error; }
+ }
+
+ /* opting is a global variable that indexes the next argv to be processed */
+ if (optind < argc) { /* True if not all the args have been processed */
+ args->filename = argv[optind];
+ }
+
+exit:
+ return res;
+error:
+ usage(stderr);
+ goto exit;
+}
+
+int
+main(int argc, char** argv)
+{
+ struct sphin* sphin = NULL;
+ struct sphin_config* config = NULL;
+ struct args args = ARGS_DEFAULT; /* Command line args */
+ struct sphin_create_args sphin_args = SPHIN_CREATE_ARGS_DEFAULT;
+ size_t sz = 0;
+ int err = EXIT_SUCCESS;
+ res_T res = RES_OK;
+
+ /* Process command line args */
+ res = parse_args(&args, argc, argv);
+ if (RES_OK != res) { goto error; }
+ if (1 == args.quit) { goto exit; }
+
+ /* Initialize sphin */
+ sphin_args.verbose = args.verbose;
+ sphin_create(&sphin_args, &sphin);
+
+ /* Load stream */
+ if (NULL != args.filename) {
+ res = sphin_load(sphin, args.filename, &config);
+ }
+ else {
+ res = sphin_load_stream(sphin, stdin, "stdin", &config);
+ }
+ if (RES_OK != res) { goto error; }
+
+exit:
+ if (NULL != sphin) { SPHIN(ref_put(sphin)); }
+ if (NULL != config) { SPHIN(config_ref_put(config)); }
+ sz = mem_allocated_size();
+ if (sz != 0) {
+ char buffer[64] = {0}; /* Initialize all fields to 0 */
+ size_to_cstr(sz, SIZE_ALL, NULL, buffer, sizeof(buffer));
+ fprintf(stderr, "Memory leaks: %s\n", buffer);
+ err = EXIT_FAILURE;
+ }
+
+ return err;
+
+error:
+ err = EXIT_FAILURE;
+ goto exit;
+}
diff --git a/src/sphin_main.c b/src/sphin_main.c
@@ -1,144 +0,0 @@
-/* Copyright (C) 2024-2026 Centre National de la Recherche Scientifique
- * Copyright (C) 2024-2026 Clermont Auvergne INP
- * Copyright (C) 2024-2026 INSA Lyon
- * Copyright (C) 2024-2026 Institut Mines Télécom Albi-Carmaux
- * Copyright (C) 2024-2026 Institut National Polytechnique de Toulouse
- * Copyright (C) 2024-2026 |Méso|Star> (contact@meso-star.com)
- * Copyright (C) 2024-2026 PhotonLyX (info@photonlyx.com)
- * Copyright (C) 2024-2026 Université de Lorraine
- * Copyright (C) 2024-2026 Université Paul Sabatier
- * Copyright (C) 2024-2026 Université Toulouse - Jean Jaurès
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#define _POSIX_C_SOURCE 200112L /* for getopt support */
-
-#include "sphin.h"
-
-#include <rsys/cstr.h>
-#include <rsys/mem_allocator.h>
-#include <rsys/rsys.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-struct args {
- int verbose; /* Verbosity level. Bigger values => more verbosity */
- int quit;
- char* filename; /* NULL => use stdin */
-};
-
-#define ARGS_DEFAULT__ {0, 0, NULL}
-static const struct args ARGS_DEFAULT = ARGS_DEFAULT__;
-
-static void
-usage
- (FILE* stream)
-{
- ASSERT(NULL != stream);
- fprintf(stream, "Usage: sphin [-hv] [file]\n");
-}
-
-static res_T
-parse_args
- (struct args* args, int argc, char** argv)
-{
- int opt = 0;
- res_T res = RES_OK;
-
- ASSERT(NULL != args);
- ASSERT(NULL != argv);
- ASSERT(argc > 0);
-
- *args = ARGS_DEFAULT;
-
- while((opt = getopt(argc, argv, "hv")) != -1) {
- switch(opt) {
- case 'v':
- /* Increase the verbosity level counter for each 'v' entered, up to a
- * maximum of 3. We use the boolean value of (3 > args->verbose): if
- * the condition is true, it evaluates to 1, increasing the counter.
- * Otherwise, it evaluates to 0, leaving the counter unchanged. */
- args->verbose += (3 > args->verbose);
- break;
- case 'h':
- usage(stdout);
- args->quit = 1;
- break;
- default:
- res = RES_BAD_ARG;
- goto error;
- }
- if (RES_OK != res) { goto error; }
- }
-
- /* opting is a global variable that indexes the next argv to be processed */
- if (optind < argc) { /* True if not all the args have been processed */
- args->filename = argv[optind];
- }
-
-exit:
- return res;
-error:
- usage(stderr);
- goto exit;
-}
-
-int
-main(int argc, char** argv)
-{
- struct sphin* sphin = NULL;
- struct sphin_config* config = NULL;
- struct args args = ARGS_DEFAULT; /* Command line args */
- struct sphin_create_args sphin_args = SPHIN_CREATE_ARGS_DEFAULT;
- size_t sz = 0;
- int err = EXIT_SUCCESS;
- res_T res = RES_OK;
-
- /* Process command line args */
- res = parse_args(&args, argc, argv);
- if (RES_OK != res) { goto error; }
- if (1 == args.quit) { goto exit; }
-
- /* Initialize sphin */
- sphin_args.verbose = args.verbose;
- sphin_create(&sphin_args, &sphin);
-
- /* Load stream */
- if (NULL != args.filename) {
- res = sphin_load(sphin, args.filename, &config);
- }
- else {
- res = sphin_load_stream(sphin, stdin, "stdin", &config);
- }
- if (RES_OK != res) { goto error; }
-
-exit:
- if (NULL != sphin) { SPHIN(ref_put(sphin)); }
- if (NULL != config) { SPHIN(config_ref_put(config)); }
- sz = mem_allocated_size();
- if (sz != 0) {
- char buffer[64] = {0}; /* Initialize all fields to 0 */
- size_to_cstr(sz, SIZE_ALL, NULL, buffer, sizeof(buffer));
- fprintf(stderr, "Memory leaks: %s\n", buffer);
- err = EXIT_FAILURE;
- }
-
- return err;
-
-error:
- err = EXIT_FAILURE;
- goto exit;
-}