Commit 36936595 authored by Sébastien Timmermans's avatar Sébastien Timmermans
Browse files

[ErrMsg][load] xml and binder and path + module loading -900

parent 1af2629d
......@@ -4,7 +4,7 @@
#include "mbs_path.h"
#include "mbs_message.h"
#include "mbs_check.h"
#include "mbs_errors_names.h"
#include <string.h>
......@@ -61,7 +61,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
mbs_infos = mbs_info_reader(mbs_filename);
if (!mbs_infos){
mbs_msg(">>LOAD>> unable to create MbsInfo.\n");
mbs_error_msg("[%d] in mbs_load_with_loader !! \n", -909);
mbs_error_msg("[%d] in mbs_load_with_loader !! \n", _MBS_ERR_MOD_LOAD + _MBS_ERR_LOW_FILES);
return NULL;
}
}
......@@ -83,7 +83,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
{
mbs_msg(">>LOAD>> build_path is not defined \n");
mbs_msg("\n>>LOAD>> Check your files names and paths \n\n");
mbs_error_msg("[%d] in mbs_load_with_loader !! \n", -910);
mbs_error_msg("[%d] in mbs_load_with_loader !! \n", _MBS_ERR_MOD_LOAD +_MBS_ERR_LOW_FILES);
free(symbolicLib_name);
free(symbolicLib_path);
free(userfctLib_name);
......@@ -154,7 +154,22 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
mbs_data = mbs_new_data();
mbs_data->project_path = (char*)malloc(sizeof(char)*(strlen(mbs_filename) + 100));
find_project_path(mbs_filename, mbs_data->project_path);
err = find_project_path(mbs_filename, mbs_data->project_path);
if (err <0)
{
free(symbolicLib_name);
free(symbolicLib_path);
free(userfctLib_name);
free(userfctLib_path);
if (!custom_mbs_info) {
mbs_delete_infos(mbs_infos);
}
mbs_msg("\n>>LOAD>> find_project_path \n\n");
mbs_error_msg("[%d] in mbs_load_with_loader !! \n", _MBS_ERR_MOD_LOAD + err);
return NULL;
}
// if we call project and user function pointer, init them
#ifdef PRJ_FCT_PTR
......@@ -204,6 +219,21 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
#endif
mbs_data = mbs_info_to_data(mbs_infos, mbs_data);
if (mbs_data == NULL)
{
free(symbolicLib_name);
free(symbolicLib_path);
free(userfctLib_name);
free(userfctLib_path);
if (!custom_mbs_info) {
mbs_delete_infos(mbs_infos);
}
mbs_msg("\n>>LOAD>> mbs_info_to_data \n\n");
mbs_error_msg("[%d] in mbs_load_with_loader !! \n", _MBS_ERR_MOD_LOAD + _MBS_ERR_LOW_FILES);
return NULL;
}
mbs_data->mbs_filename = (char*)malloc(1 + strlen(mbs_filename));
strcpy(mbs_data->mbs_filename, mbs_filename);
......@@ -710,8 +740,8 @@ MbsData* mbs_info_to_data(MbsInfos* mbs_infos, MbsData* s)
{
mbs_msg(">>LOAD>> Error while fetching user_model number \n");
mbs_msg("\n>>LOAD>> Please Re-generated your user_model Files !!! \n\n");
mbs_error_msg("[%d] in mbs_load_with_loader \n", -900);
exit(1);
mbs_error_msg("[%d] in mbs_load_with_loader \n", _MBS_ERR_MOD_LOAD);
return NULL;
}
free_ivec_1(user_model_list_c);
free_ivec_1(user_model_list_mbs);
......@@ -762,8 +792,8 @@ MbsData* mbs_info_to_data(MbsInfos* mbs_infos, MbsData* s)
{
mbs_msg(">>LOAD>> Error while fetching user_IO number \n");
mbs_msg("\n>>LOAD>> Please Re-generated your user_IO Files !!! \n\n");
mbs_error_msg("[%d] in mbs_load_with_loader \n", -900);
exit(1);
mbs_msg("[%d] in mbs_load_with_loader \n", _MBS_ERR_MOD_LOAD);
return NULL;
}
if (s->n_user_IO) {
......
......@@ -2,6 +2,8 @@
#include "mbs_xml_binder_private.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
/////////////////////////////////////////
/// GET functions ///////////////////////
......@@ -1398,9 +1400,8 @@ int mbs_info_mbsDescR7_binder(MbsInfos *mbs_infos, xmlNodePtr node, int mission)
mbs_msg(">>LOAD>> Error during xmlParseFile function \n");
mbs_msg(">>LOAD>> MDS_mbs_reader : Empty XML document\n");
mbs_msg(">>LOAD>> Check your files names and paths \n\n");
mbs_error_msg("[%d] in MDS_mbs_reader !! \n", -909);
exit(1);
return 0;
mbs_msg("[%d] in MDS_mbs_reader !! \n", _MBS_ERR_LOW_FILES);
return _MBS_ERR_LOW_FILES;
}
cur_node = node->children;
......@@ -1686,6 +1687,7 @@ int mbs_info_init_and_binder(MbsInfos *mbs_infos, const char *mbs_xml_name, int
{
xmlDocPtr doc;
xmlNodePtr root;
int err = 0;
// xml document opening
xmlKeepBlanksDefault(0); // Ignore les noeuds texte composant la mise en forme
......@@ -1694,22 +1696,29 @@ int mbs_info_init_and_binder(MbsInfos *mbs_infos, const char *mbs_xml_name, int
mbs_msg(">>LOAD>> Error during xmlParseFile function \n");
mbs_msg(">>LOAD>> mbs_info_init_and_binder : Invalid XML document\n");
mbs_msg(">>LOAD>> Check your files names and paths \n\n");
mbs_error_msg("[%d] in mbs_info_init_and_binder !! \n", -909);
return -1;
mbs_msg("[%d] in mbs_info_init_and_binder !! \n", _MBS_ERR_LOW_FILES);
return _MBS_ERR_LOW_FILES;
}
// getting the root
root = xmlDocGetRootElement(doc);
if (root == NULL) {
xmlFreeDoc(doc);
mbs_msg(">>LOAD>> Error during xmlParseFile function \n");
mbs_msg(">>LOAD>> mbs_info_init_and_binder : Empty XML document\n");
mbs_msg(">>LOAD>> Check your files names and paths \n\n");
mbs_error_msg("[%d] in mbs_info_init_and_binder !! \n", -909);
return -1;
mbs_msg("[%d] in mbs_info_init_and_binder !! \n", _MBS_ERR_LOW_FILES);
xmlFreeDoc(doc);
xmlCleanupParser();
return _MBS_ERR_LOW_FILES;
}
mbs_info_mbsDescR7_binder(mbs_infos, root, mission);
err = mbs_info_mbsDescR7_binder(mbs_infos, root, mission);
if (err < 0)
{
mbs_msg(">>LOAD>> Error during mbs_info_mbsDescR7_binder function \n");
xmlFreeDoc(doc);
xmlCleanupParser();
return err;
}
if (mission == MBS_INFO_UPDATER)
{
xmlSaveFormatFile("updated_prject.mbs", doc, 1);
......@@ -1749,7 +1758,7 @@ int mbs_info_updater(MbsInfos *mbs_infos, const char *mbs_xml_name)
err = mbs_info_init_and_binder(mbs_infos, mbs_xml_name, MBS_INFO_UPDATER);
if (err < 0){
mbs_msg(">>LOAD>> Error during function mbs_info_updater.\n");
return -1;
return err;
}
return MBS_INFO_SUCCESS;
......
......@@ -66,6 +66,11 @@ extern "C" {
*/
#define _MBS_ERR_MOD_INV_DYN -600
/** @brief Module error number
* module: Loading = -900
*/
#define _MBS_ERR_MOD_LOAD -900
/************************
* Middle Level *
************************/
......
......@@ -5,18 +5,19 @@
#include "mbs_path.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
char* find_user_path(const char* mbsfile) {
char *prjpath, *userpath;
int err = 0;
// allocate space for the path to the project folder
prjpath = (char*)malloc(sizeof(char)*(strlen(mbsfile) + 50));
// allocate space for the path to the user folder
userpath = (char*)malloc(sizeof(char)*(strlen(mbsfile) + 50));
find_project_path(mbsfile, prjpath);
err = find_project_path(mbsfile, prjpath);
sprintf(userpath, "%s/userfctR/", prjpath);
......@@ -27,10 +28,10 @@ char* find_user_path(const char* mbsfile) {
return userpath;
}
void find_project_path(const char* mbsfile, char* prjpath) {
int find_project_path(const char* mbsfile, char* prjpath) {
char *ptr;
char* c;
int err = 0;
// copy path to the *.mbs file
sprintf(prjpath, "%s", mbsfile);
......@@ -57,9 +58,10 @@ void find_project_path(const char* mbsfile, char* prjpath) {
else { // Error management
mbs_msg(">>LOAD>> the *.mbs file must be in the dataR folder. \n");
mbs_msg("\n>>LOAD>> Check your files names and paths \n\n");
mbs_error_msg("[%d] in find_project_path !! \n", -909);
exit(1);
mbs_msg("[%d] in find_project_path !! \n", _MBS_ERR_LOW_FILES);
return _MBS_ERR_LOW_FILES;
}
return err;
}
char* mbs_basename(const char* path){
......
......@@ -19,8 +19,9 @@ 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
* \return err <0 if error occurs
*/
void find_project_path(const char* mbsfile, char* prjpath);
int find_project_path(const char* mbsfile, char* prjpath);
/**
* \brief mbs_basename return sthe trailing part of the path (UNIX and MAC).
......
Supports Markdown
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