stardis-parsing.h (2028B)
1 /* Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com) 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 #ifndef STARDIS_PARSING_H 17 #define STARDIS_PARSING_H 18 19 #include <sdis.h> 20 21 #include <rsys/rsys.h> 22 #include <rsys/dynamic_array_str.h> 23 24 #include <star/sstl.h> 25 26 struct logger; 27 struct stardis; 28 29 /* Utility macros */ 30 #define CHK_ARG(Idx, Name) {\ 31 if(pwordexp->we_wordc <= (Idx)) {\ 32 logger_print(stardis->logger, LOG_ERROR,\ 33 "Invalid data (missing token '" Name "')\n");\ 34 arg = "(missing)";\ 35 res = RES_BAD_ARG;\ 36 goto error;\ 37 } else {\ 38 arg = pwordexp->we_wordv[(Idx)++];\ 39 if(!arg) {\ 40 arg = "(inconsistant wordexp)";\ 41 goto error; /* to silent a gcc-11 */\ 42 }\ 43 }\ 44 }(void)0 45 46 /* Same ctx used for both media and interface add (some unused parts) */ 47 struct add_geom_ctx { 48 struct sstl_desc stl_desc; 49 unsigned properties[3]; 50 void* custom; 51 }; 52 53 /* Possible callbacks for sg3d_geometry_add calls 54 * when void* context is a struct add_geom_ctx */ 55 void 56 add_geom_ctx_indices 57 (const unsigned itri, 58 unsigned ids[3], 59 void* context); 60 61 void 62 add_geom_ctx_position 63 (const unsigned ivert, 64 double pos[3], 65 void* context); 66 67 res_T 68 get_dummy_solid_id 69 (struct stardis* stardis, 70 unsigned* id); 71 72 res_T 73 get_dummy_fluid_id 74 (struct stardis* stardis, 75 unsigned* id); 76 77 res_T 78 read_model 79 (const struct darray_str* model_files, 80 struct stardis* stardis); 81 82 #endif /*ARGS_H*/