#include "pp.h" char *GEN_DIR = getenv("GEN_DIR"); char topname[256]; extern void summaryWarning(); extern int _demeter_hash(const char* classname); int greeting = _demeter_hash("Greeting"); int main( int argc, char *argv[] ,char*envp[]) { char buf[MAXDIRLEN+1]; int i; assert( GEN_DIR != NULL ); if ((argc > 1) && strcmp(argv[1],"-i") && strcmp(argv[1],"-i")) { strcpy(topname,argv[1]); argc--; argv++; } else { strcpy(topname, strrchr(getcwd(NULL,1024),'/')+1); } if ( (argc > 1) && (strcmp(argv[1],"-i") == 0) ) { inter_flag = 1; argc--; argv++; } if ( (argc > 1) && (strcmp(argv[1],"-c") != 0) ) abort_with_help(); else { argc--; argv++; if (argc == 1) abort_with_help(); } int needtodo = 0; if (checkingDirTimeStamp(".")) needtodo = 1; else { for (i = 1; i < argc; i++) { if (checkingDirTimeStamp(argv[i])) continue; else { needtodo = 1; break; } } } if (!needtodo) { cout << toolname << ": There is no need to propagate." << endl; return (0); } cwd = getcwd(NULL,MAXDIRLEN+1); if (mkdir(tmpdir,0755) && (errno != EEXIST)) { cerr << toolname << ": unable to create " << tmpdir << " for holding temporary files." << endl; perror(tmpdir); exit(-1); } if (access(tmpdir, X_OK | R_OK | W_OK )) { cerr << toolname << ": unable to have access to " << cwd << "/" << tmpdir << " for holding temporary files." << endl; perror(tmpdir); exit(-1); } ///////////////////////////////////////////////////////////////// // create schema object ///////////////////////////////////////////////////////////////// cout << toolname << ": reading " << user_schema << " ...\n" << endl; if (access(user_schema, R_OK) != 0) { sprintf(buf,"%s : %s",toolname,user_schema); perror(buf); exit(-1); } Cd_graph *iCd_graph = new Cd_graph(); iCd_graph = (Cd_graph *) iCd_graph->g_parse((char*)user_schema); if (iCd_graph == NULL) { cout << toolname << ": failed to parse " << user_schema << "." << endl; exit(-1); } iCd_graph->addReverseAltEdges(); ////////////////////////////////////////////////////////////////// // search inst_meta ////////////////////////////////////////////////////////////////// Meta_def_input * inst_meta_obj = new Meta_def_input(); int permission = access(inst_meta, R_OK); if (permission == 0) { cout << toolname << ": reading " << inst_meta << endl; inst_meta_obj = (Meta_def_input *)inst_meta_obj->g_parse((char*)inst_meta); if (inst_meta_obj == NULL) { cerr << toolname << ": failed to parse " << inst_meta << endl; exit(-1); } } else if (errno == ENOENT) inst_meta_obj->set_metas(new Meta_def_List()); else { cerr << toolname << ": unable to read " << inst_meta << endl; perror(inst_meta); exit(-1); } cout << "\n\n"; ////////////////////////////////////////////////////////////// // propagate all the .pp files in U-1 dir ////////////////////////////////////////////////////////////// cout << toolname << ": searching propagation pattern files in ./ ...\n" << endl; propagate(".",inst_meta_obj,iCd_graph); cout << "\n\n"; ////////////////////////////////////////////////////////////// // propagate all the .pp file in each component dirs ////////////////////////////////////////////////////////////// for (i = 1; i < argc; i++) { cout << toolname << ": searching propagation pattern files in " << argv[i] << "/ ...\n" << endl; propagate(argv[i],inst_meta_obj,iCd_graph); cout << "\n\n"; } summaryWarning(); return (0); }