Commit cad3c8e9 authored by Sebastien Timmermans's avatar Sebastien Timmermans 🎹

[Fix] coming back to before error mngmt in mbs_load

parent 4c1646c1
Pipeline #4333 passed with stage
in 9 minutes and 5 seconds
......@@ -31,13 +31,7 @@ MbsData* mbs_load(const char* mbs_filename, const char* build_path)
MbsLoader *loader;
loader = mbs_new_loader();
int err = 0;
mbs_data = mbs_load_with_loader(mbs_filename, build_path, loader, &err);
if (err < 0)
{
mbs_msg(">>LOAD>> Check your file names and paths \n");
mbs_error_msg(" [-0%d] in mbs_run_part !! \n", -err);
}
mbs_data = mbs_load_with_loader(mbs_filename, build_path, loader);
mbs_delete_loader(loader);
return mbs_data;
......@@ -45,7 +39,7 @@ MbsData* mbs_load(const char* mbs_filename, const char* build_path)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path, MbsLoader *mbs_loader, int *err)
MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path, MbsLoader *mbs_loader)
{
MDS_gen_strct *mds;
MbsData *mbs_data;
......@@ -58,12 +52,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
if (mbs_loader->mds == NULL)
{
custom_mds = 0;
mds = MDS_mbs_reader(mbs_filename, err);
if (*err < 0)
{
*err -= 90;
return NULL;
}
mds= MDS_mbs_reader(mbs_filename);
}
else
{
......@@ -81,9 +70,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
// 0. build
if (build_path == NULL)
{
mbs_msg(">>LOAD>> build_path is not defined \n");
*err = -80;
return NULL;
mbs_error_msg(">>LOAD>> build_path is not defined \n");
}
// 1. symbolic Library name (without extension)
......@@ -139,16 +126,11 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
}
//-------------------------------------------------------------------------
mbs_data = (MbsData*)malloc(sizeof(MbsData));
mbs_data->project_path = (char*)malloc(sizeof(char)*(strlen(mbs_filename) + 100));
*err = find_project_path(mbs_filename, mbs_data->project_path);
if (err < 0)
{
mbs_msg(">>LOAD>> project path not found \n");
*err = -89;
return NULL;
}
find_project_path(mbs_filename, mbs_data->project_path);
// if we call project and user function pointer, init them
#ifdef PRJ_FCT_PTR
mbs_load_symbolic_functions(mbs_data,symbolicLib_path,symbolicLib_name);
......@@ -169,6 +151,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
free(userfctLib_name);
free(userfctLib_path);
if (custom_mds == 0)
{
free_MDS_gen_strct(mds);
......@@ -178,6 +161,8 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
// do nothing as the loader->mds memory could be re-used.
}
return mbs_data;
}
......
......@@ -24,9 +24,8 @@ MbsData* mbs_load(const char* mbs_filename, const char* build_name);
* \param mbs_filename, path to the file to load including filename and extension.
* \param build_path, path to the build folder (including build) of MBsysC libraries
* \param mbs_load_opts, options for loading (mainly a collection of paths and names)
* \param err return error code if problem during loading
*/
MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path, MbsLoader *mbs_loader, int *err);
MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path, MbsLoader *mbs_loader);
/**
* \brief Create a new structure with options for the loading.
......
......@@ -1512,7 +1512,7 @@ void MDS_structurer(MDS_gen_strct* mds_gen_strct)
}
MDS_gen_strct* MDS_mbs_reader(const char* mbs_xml_name, int *err)
MDS_gen_strct* MDS_mbs_reader(const char* mbs_xml_name)
{
xmlDocPtr doc;
xmlNodePtr root;
......@@ -1523,15 +1523,13 @@ MDS_gen_strct* MDS_mbs_reader(const char* mbs_xml_name, int *err)
doc = xmlParseFile(mbs_xml_name);
if (doc == NULL) {
//fprintf(stderr, "MDS_mbs_reader : Invalid XML document\n");
mbs_msg("\n>>LOAD>> MDS_mbs_reader : Impossible to read file %s \n", mbs_xml_name);
*err = -9;
mbs_error_msg("MDS_mbs_reader : Impossible to read file %s\n", mbs_xml_name);
return NULL;
}
// getting the root
root = xmlDocGetRootElement(doc);
if (root == NULL) {
mbs_msg(">>LOAD>> MDS_mbs_reader : Empty XML document\n");
*err = -9;
fprintf(stderr, "MDS_mbs_reader : Empty XML document\n");
xmlFreeDoc(doc);
return NULL;
}
......
......@@ -427,7 +427,9 @@ MDS_gen_strct* init_MDS_gen_strct(void);
void free_MDS_gen_strct(MDS_gen_strct *mds_gen_strct);
MDS_gen_strct* MDS_mbs_reader(const char* mbs_xml_name, int *err);
MDS_gen_strct* MDS_mbs_reader(const char* mbs_xml_name);
#ifdef GEN_MDS
......
......@@ -27,7 +27,7 @@ char* find_user_path(const char* mbsfile){
return userpath;
}
int find_project_path(const char* mbsfile, char* prjpath){
void find_project_path(const char* mbsfile, char* prjpath){
char *ptr;
char* c;
......@@ -55,8 +55,7 @@ int find_project_path(const char* mbsfile, char* prjpath){
}
else{
mbs_msg("\n >>LOAD>> the *.mbs file must be in the dataR folder. \n");
return -9;
mbs_error_msg("the *.mbs file must be in the dataR folder. \n");
exit(1);
}
return 0;
}
......@@ -20,6 +20,6 @@ char* find_user_path(const char* mbsfile);
* \param[in] mbsfile the path and filename to the .mbs file
* \param[out] prjpath the path to the root of the mbs project
*/
int find_project_path(const char* mbsfile, char* prjpath);
void find_project_path(const char* mbsfile, char* prjpath);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment