FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
fstr_ctrl_util.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
11 #ifndef fstr_ctrl_utilH
12 #define fstr_ctrl_utilH
13 
14 #include <assert.h>
15 #include <stdarg.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <string.h>
19 #include <ctype.h>
20 #include <hecmw_config.h>
21 
22 #ifndef HECMW_SERIAL
23 #include <hecmw_comm.h>
24 #endif
25 
26 #define FSTR_CTRL_RCODE_PARAM_SUCCESS 0
27 #define FSTR_CTRL_RCODE_PARAM_ERROR -1
28 #define FSTR_CTRL_RCODE_PARAM_TYPE_ERROR -2
29 #define FSTR_CTRL_RCODE_PARAM_RANGE_ERROR -3
30 #define FSTR_CTRL_RCODE_PARAM_NOTHING 1
31 #define FSTR_CTRL_RCODE_PARAM_VALUE_NOTHING 2
32 
33 #define FSTR_CTRL_RCODE_DATA_SUCCESS 0
34 #define FSTR_CTRL_RCODE_DATA_ERROR -1
35 #define FSTR_CTRL_RCODE_DATA_TYPE_ERROR -2
36 #define FSTR_CTRL_RCODE_DATA_RANGE_ERROR -3
37 #define FSTR_CTRL_RCODE_DATA_NOTHING 1
38 #define FSTR_CTRL_RCODE_DATA_LINE_NOTHING 2
39 
40 typedef struct st_ctrl_rec {
41  int line_no;
42  char* line;
43 } ctrl_rec;
44 
45 typedef struct st_fstr_ctrl_data {
47  int rec_n;
48  int* header_pos;
49  int header_n;
53 
54 /* ctrl list for fortran interface */
55 #define ctrl_list_size 20
56 #ifdef fstr_ctrl_util_MAIN
58 #else
60 #endif
61 
62 /* =================================================================================
63  */
69 void c_fstr_ctrl_get_err_msg(char* buff);
70 
71 /* =================================================================================
72  */
79 fstr_ctrl_data* c_fstr_ctrl_open(const char* filename);
80 
81 /* =================================================================================
82  */
90 
91 /* =================================================================================
92  */
101 int c_fstr_ctrl_get_line(fstr_ctrl_data* ctrl, int rec_no, char* buff);
102 
103 /* =================================================================================
104  */
114 int c_fstr_ctrl_seek_header(fstr_ctrl_data* ctrl, const char* header_name);
115 
116 /* =================================================================================
117  */
125 
126 /* =================================================================================
127  */
136  char* header_name);
137 
138 /* =================================================================================
139  */
147 
148 /* =================================================================================
149  */
157 
158 /* =================================================================================
159  */
175 int c_fstr_ctrl_get_param(fstr_ctrl_data* ctrl, const char* param_name,
176  const char* value_list, char type, void* val);
177 
178 /* =================================================================================
179  */
197 int c_fstr_ctrl_get_param_ex(fstr_ctrl_data* ctrl, const char* param_name,
198  const char* value_list, int necessity, char type,
199  void* val);
200 
201 /* =================================================================================
202  */
210 
211 /* =================================================================================
212  */
213 /* JP-0 */
214 
216  char* data_line);
217 
218 /* =================================================================================
219  */
220 /* JP-1 */
221 
223  const char* delim);
224 
225 /* =================================================================================
226  */
233 
235 
236 /* =================================================================================
237  */
238 /* JP-2 */
239 
240 int c_fstr_ctrl_get_data(fstr_ctrl_data* ctrl, int line_no, const char* format,
241  ...);
243  const char* format, va_list va);
245  const char* format, ...);
246 
247 int c_fstr_ctrl_get_data_array(fstr_ctrl_data* ctrl, const char* format, ...);
248 int c_fstr_ctrl_get_data_array_v(fstr_ctrl_data* ctrl, const char* format,
249  va_list va);
250 int c_fstr_ctrl_get_data_array_ex(fstr_ctrl_data* ctrl, const char* format,
251  ...);
252 
253 /* =================================================================================
254  */
262 
263 #endif
c_fstr_ctrl_get_data_error_pos
int c_fstr_ctrl_get_data_error_pos(void)
Definition: fstr_ctrl_util.c:794
st_fstr_ctrl_data::rec_n
int rec_n
Definition: fstr_ctrl_util.h:47
c_fstr_ctrl_seek_next_header
int c_fstr_ctrl_seek_next_header(fstr_ctrl_data *ctrl)
Definition: fstr_ctrl_util.c:400
line_no
int line_no
Definition: fstr_ctrl_util.c:93
st_fstr_ctrl_data::header_n
int header_n
Definition: fstr_ctrl_util.h:49
c_fstr_ctrl_get_data_v
int c_fstr_ctrl_get_data_v(fstr_ctrl_data *ctrl, int line_no, const char *format, va_list va)
Definition: fstr_ctrl_util.c:828
fstr_ctrl_data
struct st_fstr_ctrl_data fstr_ctrl_data
ctrl_rec
struct st_ctrl_rec ctrl_rec
hecmw_comm.h
st_ctrl_rec
Definition: fstr_ctrl_util.h:40
st_ctrl_rec::line_no
int line_no
Definition: fstr_ctrl_util.h:41
c_fstr_ctrl_get_line
int c_fstr_ctrl_get_line(fstr_ctrl_data *ctrl, int rec_no, char *buff)
Definition: fstr_ctrl_util.c:344
ctrl_list
fstr_ctrl_data * ctrl_list[ctrl_list_size]
st_ctrl_rec::line
char * line
Definition: fstr_ctrl_util.h:42
c_fstr_ctrl_get_param_ex
int c_fstr_ctrl_get_param_ex(fstr_ctrl_data *ctrl, const char *param_name, const char *value_list, int necessity, char type, void *val)
Definition: fstr_ctrl_util.c:674
st_fstr_ctrl_data::header_pos
int * header_pos
Definition: fstr_ctrl_util.h:48
c_fstr_ctrl_get_rec_number
int c_fstr_ctrl_get_rec_number(fstr_ctrl_data *ctrl)
Definition: fstr_ctrl_util.c:333
hecmw_config.h
c_fstr_ctrl_get_data_array_v
int c_fstr_ctrl_get_data_array_v(fstr_ctrl_data *ctrl, const char *format, va_list va)
Definition: fstr_ctrl_util.c:936
c_fstr_ctrl_open
fstr_ctrl_data * c_fstr_ctrl_open(const char *filename)
Definition: fstr_ctrl_util.c:250
st_fstr_ctrl_data::rec
ctrl_rec * rec
Definition: fstr_ctrl_util.h:46
c_fstr_ctrl_get_data_array
int c_fstr_ctrl_get_data_array(fstr_ctrl_data *ctrl, const char *format,...)
Definition: fstr_ctrl_util.c:1021
c_fstr_ctrl_seek_header
int c_fstr_ctrl_seek_header(fstr_ctrl_data *ctrl, const char *header_name)
Definition: fstr_ctrl_util.c:360
c_fstr_ctrl_get_current_header_pos
int c_fstr_ctrl_get_current_header_pos(fstr_ctrl_data *ctrl)
Definition: fstr_ctrl_util.c:461
c_fstr_ctrl_close
int c_fstr_ctrl_close(fstr_ctrl_data *ctrl)
Definition: fstr_ctrl_util.c:1050
c_fstr_ctrl_get_data_n_in_line
int c_fstr_ctrl_get_data_n_in_line(fstr_ctrl_data *ctrl, int line_no, const char *delim)
Definition: fstr_ctrl_util.c:765
c_fstr_ctrl_get_err_msg
void c_fstr_ctrl_get_err_msg(char *buff)
Definition: fstr_ctrl_util.c:22
st_fstr_ctrl_data::current_header_index
int current_header_index
Definition: fstr_ctrl_util.h:51
c_fstr_ctrl_get_current_header_line_no
int c_fstr_ctrl_get_current_header_line_no(fstr_ctrl_data *ctrl)
Definition: fstr_ctrl_util.c:446
ctrl_list_size
#define ctrl_list_size
Definition: fstr_ctrl_util.h:55
c_fstr_ctrl_get_data
int c_fstr_ctrl_get_data(fstr_ctrl_data *ctrl, int line_no, const char *format,...)
Definition: fstr_ctrl_util.c:802
c_fstr_ctrl_get_data_line_n
int c_fstr_ctrl_get_data_line_n(fstr_ctrl_data *ctrl)
Definition: fstr_ctrl_util.c:724
c_fstr_ctrl_get_current_header_name
int c_fstr_ctrl_get_current_header_name(fstr_ctrl_data *ctrl, char *header_name)
Definition: fstr_ctrl_util.c:418
c_fstr_ctrl_get_data_error_line
int c_fstr_ctrl_get_data_error_line(void)
Definition: fstr_ctrl_util.c:798
st_fstr_ctrl_data::data_line_n
int * data_line_n
Definition: fstr_ctrl_util.h:50
c_fstr_ctrl_get_param
int c_fstr_ctrl_get_param(fstr_ctrl_data *ctrl, const char *param_name, const char *value_list, char type, void *val)
Definition: fstr_ctrl_util.c:581
st_fstr_ctrl_data
Definition: fstr_ctrl_util.h:45
c_fstr_ctrl_get_data_array_ex
int c_fstr_ctrl_get_data_array_ex(fstr_ctrl_data *ctrl, const char *format,...)
Definition: fstr_ctrl_util.c:1030
c_fstr_ctrl_copy_data_line
int c_fstr_ctrl_copy_data_line(fstr_ctrl_data *ctrl, int line_no, char *data_line)
Definition: fstr_ctrl_util.c:744
c_fstr_ctrl_get_data_ex
int c_fstr_ctrl_get_data_ex(fstr_ctrl_data *ctrl, int line_no, const char *format,...)
Definition: fstr_ctrl_util.c:812