star-phor-input

File format for describing photoreactor configurations
git clone https://www.edstar.cnrs.fr/git/star-phor-input.git
Log | Files | Refs | README | LICENSE

sphin_config.h (3269B)


      1 /* Copyright (C) 2024-2026 Centre National de la Recherche Scientifique
      2  * Copyright (C) 2024-2026 Clermont Auvergne INP
      3  * Copyright (C) 2024-2026 INSA Lyon
      4  * Copyright (C) 2024-2026 Institut Mines Télécom Albi-Carmaux
      5  * Copyright (C) 2024-2026 Institut National Polytechnique de Toulouse
      6  * Copyright (C) 2024-2026 |Méso|Star> (contact@meso-star.com)
      7  * Copyright (C) 2024-2026 PhotonLyX (info@photonlyx.com)
      8  * Copyright (C) 2024-2026 Université de Lorraine
      9  * Copyright (C) 2024-2026 Université Paul Sabatier
     10  * Copyright (C) 2024-2026 Université Toulouse - Jean Jaurès
     11  *
     12  * This program is free software: you can redistribute it and/or modify
     13  * it under the terms of the GNU General Public License as published by
     14  * the Free Software Foundation, either version 3 of the License, or
     15  * (at your option) any later version.
     16  *
     17  * This program is distributed in the hope that it will be useful,
     18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     20  * GNU General Public License for more details.
     21  *
     22  * You should have received a copy of the GNU General Public License
     23  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     24 
     25 #ifndef SPHIN_CONFIG_H
     26 #define SPHIN_CONFIG_H
     27 
     28 #include "sphin_surface.h"
     29 #include "sphin_volume.h"
     30 
     31 #include <rsys/ref_count.h> /* ref_T */
     32 #include <rsys/rsys.h>
     33 
     34 struct sphin;
     35 
     36 struct sphin_config {
     37   /* Put the fun things here */
     38   struct darray_sphin_surface_ptr surfaces;
     39   struct darray_sphin_volume_ptr volumes;
     40   struct sphin* sphin;
     41   ref_T ref;
     42 };
     43 
     44 /* Trim leading and trailing spaces and tabs from the input string and return
     45  * the first word. If the input string is empty or if it contains multiple
     46  * words, returns NULL to indicate an error or unexpected format.
     47  */
     48 extern LOCAL_SYM char*
     49 trim_keyword
     50   (char* str);
     51 
     52 /* Trim spaces, tabs and double quotes (") of a string according to several
     53  * rules:
     54  * 1. The string starts and ends with quotes (although tabs and spaces are
     55  * allowed outside the quotes)
     56  * 2. There should be exactly two quotes in the string: the one that delimits
     57  * its beginning and the one that delimits its end. Quotes in the middle of the
     58  * string are expected to cause undefined behavior of the function.
     59  * 3. No character other than spaces and tabs are allowed outside the quotes.
     60  * However, any characters inside the quotes are allowed (including spaces and
     61  * tabs).
     62  *
     63  * If one of these conditions are not respected, the function returns NULL,
     64  * otherwise, * it returns a pointer to the beginning of the trimmed string
     65  * (just after the first quote).
     66  * Examples of allowed strings:
     67  *   -'   "mon volume"   ' -> 'mon volume'
     68  *   - '"\t   mon volume   \t "' -> '\t   mon volume   \t '
     69  *
     70  * Examples of forbidden strings:
     71  *   - 'mon volume'             // No quotes
     72  *   - '"mon volume'            // Quote not closed
     73  *   - '"mon""volume"'          // Multiple quotes (undefined behavior)
     74  *   - '"mon volume" salut'     // Content after the last quote is not
     75  * whitespace or tabs
     76  *   - '"mon volum"e'           // Misplaced closing quote
     77  *   - '""'                     // Empty string
     78  *
     79  */
     80 extern LOCAL_SYM char*
     81 trim_string
     82   (char* str);
     83 
     84 #endif /* SPHIN_CONFIG_H */