AcouSTO  version 2.0

◆ readconfig()

int readconfig ( char *  datfile,
int  check_dir 
)
22  {
23 
24  /* &config creation */
25  config_init(&config);
26 
27  /* load file */
28  if (!datfile) {
29  logger(LOG_ERROR, "An input file must be specified with option -f <input file>\n");
30  return -1;
31  }
32  rundetails->cfg_filename = calloc(strlen(datfile)+1,sizeof(char));
33  strcpy(rundetails->cfg_filename, datfile); // saving filename for report
34 
35  rundetails->cfg_filepath = getcwd(NULL,0);
36  //getcwd(rundetails->cfg_filepath, strlen(rundetails->cfg_filepath)); // saving filepath for report
37  logger(LOG_DEBUG,"Working directory:[%s\n]",rundetails->cfg_filepath);
38 
39  // Loading and parsing file
40  /* file read */
41  if (config_read_file(&config, datfile) != CONFIG_TRUE) {
42  logger(LOG_ERROR, "Error reading file %s\n", datfile);
43  logger(LOG_ERROR, "%d:%s\n", config_error_line(&config), config_error_text(&config));
44  return -1;
45  }
46 
47 
48  // INITIALIZING FILE POINTERS
49  fileinfo->nodes_file = NULL;
50  fileinfo->chief_file = NULL;
51  fileinfo->mics_file = NULL;
52  fileinfo->sources_file = NULL;
53  fileinfo->imped_file = NULL;
54  fileinfo->radiants_file = NULL;
55  fileinfo->planw_file = NULL;
56  fileinfo->dipoles_file = NULL;
57  fileinfo->bc_lambda_file = NULL;
58  fileinfo->bc_gamma_file = NULL;
59  fileinfo->bc_func_file = NULL;
60  fileinfo->bc_g_file = NULL;
61 
62 
63  if( -1 == read_runinfo(check_dir)) return -1;
64  if( -1 == read_modgeom() ) return -1;
65  if( -1 == read_modsol() ) return -1;
66 #ifdef _MYSQL_
67  if( -1 == read_mysql() ) return -1;
68 #endif
69 
70  return 0;
71 
72 }
int read_modgeom()
Definition: modgeom.c:22
const char * bc_gamma_file
Definition: structs.h:422
char * cfg_filename
Definition: structs.h:137
int read_modsol()
Definition: modsol.c:22
char * cfg_filepath
Definition: structs.h:139
struct file_info * fileinfo
Definition: globals.h:32
const char * dipoles_file
Definition: structs.h:418
const char * planw_file
Definition: structs.h:415
#define LOG_ERROR
Definition: logger.h:24
int read_runinfo(int check_dir)
Definition: runinfo.c:21
int read_mysql()
Definition: mysql.c:22
const char * chief_file
Definition: structs.h:405
struct config_t config
Definition: config.h:61
const char * nodes_file
Definition: structs.h:403
const char * bc_g_file
Definition: structs.h:424
#define LOG_DEBUG
Definition: logger.h:27
const char * bc_func_file
Definition: structs.h:423
char * datfile
Definition: globals.h:29
const char * mics_file
Definition: structs.h:407
struct run_details * rundetails
Definition: globals.h:36
const char * imped_file
Definition: structs.h:411
const char * bc_lambda_file
Definition: structs.h:421
const char * radiants_file
Definition: structs.h:413
const char * sources_file
Definition: structs.h:409
void logger(int level, char *msg,...)
Definition: logger.c:56
#define calloc(n, size)
Definition: allocation.h:37