00001
00002
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005
00006
00007
00008
00009 #include "kernel/acis.hxx"
00010
00011
00012 #include "kernel/kernapi/api/api.hxx"
00013
00014
00015
00016
00017
00018
00019 #include "kernel/kernapi/api/kernapi.hxx"
00020
00021
00022 #include "kernel/kerndata/lists/lists.hxx"
00023
00024 #include "mytools.hxx"
00025
00026 outcome get_ent_from_file(char *modelfile, ENTITY_LIST &entities){
00027 FILE *fi;
00028 outcome result(0);
00029
00030 if ((fi = fopen(modelfile,"r")) == NULL) {
00031 pr_error("could't open input file");
00032 return outcome(API_FAILED);
00033 }
00034
00035 result = api_restore_entity_list(fi,TRUE,entities);
00036 fclose(fi);
00037
00038 return result;
00039 }
00040
00041 outcome save_ent_to_file(char *modelfile, ENTITY_LIST &entities){
00042 FILE *fi;
00043 outcome result(0);
00044
00045 if ((fi = fopen(modelfile,"w")) == NULL) {
00046 pr_error("could't open ouput file");
00047 return outcome(API_FAILED);
00048 }
00049
00050 result = api_save_entity_list(fi,TRUE,entities);
00051 fclose(fi);
00052
00053 return result;
00054 }
00055
00056 void show_errors(outcome result, char *mess)
00057 {
00058
00059 if (mess == NULL)
00060 mess = "unidentified routine";
00061
00062 if (!result.ok())
00063 {
00064 pr_errArgs((stderr,"Error in %s %d: %s", mess,
00065 result.error_number(),
00066 find_err_mess(result.error_number())));
00067 }
00068
00069
00070 err_mess_type *warnings;
00071
00072 int nwarn = get_warnings(warnings);
00073 for(int i = 0; i < nwarn; ++i)
00074 {
00075 pr_errArgs((stderr,"Warning in %s %d : %s\n", mess,
00076 warnings[i],
00077 find_err_mess(warnings[i])));
00078 }
00079
00080 }