Changeset 171 in Sophya for trunk/SophyaPI/PIext/piacmd.cc


Ignore:
Timestamp:
Dec 21, 1998, 9:49:55 AM (27 years ago)
Author:
ercodmgr
Message:

Adaptation a PDynLinkMgr Reza 21/12/98

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piacmd.cc

    r165 r171  
    22#include <stdlib.h>
    33#include <math.h>
    4 
    5 #include <dlfcn.h>
    64
    75#include <iostream.h>
     
    4240else { mObjMgr = new NamedObjMgr;  mOmg = true; }
    4341mImgApp = app;
    44 char* varenv;
    45 TmpDir = "";
    46 if ( (varenv=getenv("PEIDA_TMP")) != NULL )  TmpDir = varenv;
    47 else if ( (varenv=getenv("TMPDIR")) != NULL )  TmpDir = varenv;
    48 int l = TmpDir.length();
    49 if ( (l>0) && (TmpDir[l-1] != '/') )  TmpDir += '/';
    5042system("cp history.pic hisold.pic");
    5143hist.open("history.pic");
    5244trace = false;   timing = false;
    5345gltimer = NULL;
    54 dlhandle = NULL;
     46dynlink = NULL;
    5547}
    5648
     
    605597                          string& func4, string& func5)
    606598{
    607 string fnamesol = TmpDir + "spiup.so";
    608599string cmd;
    609600int rc;
    610601
    611 if (dlhandle) dlclose(dlhandle);    dlhandle = NULL;
     602if (dynlink) delete dynlink;    dynlink = NULL;
    612603usfmap.clear();
    613 cmd = "cp " + fnameso + " " + fnamesol;
    614 rc = system(cmd.c_str());
    615 if (rc != 0)  { cerr << "PIACmd::LinkUserFuncs() Error system(" << cmd << ") Rc= " << rc << endl; return(1); }
    616 
    617 dlhandle =  dlopen(fnamesol.c_str(), RTLD_NOW);
    618 if (dlhandle == NULL) {
    619   string sn = fnamesol;
     604
     605dynlink = new PDynLinkMgr(fnameso, true);
     606if (dynlink == NULL) {
     607  string sn = fnameso;
    620608  cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
    621609  sn = dlerror();
     
    630618if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin;
    631619// f = (DlUserProcFunction)  dlsym(dlhandle, func1.c_str());
    632 f = (DlFunction)  dlsym(dlhandle, func1.c_str());
     620f = dynlink->GetFunction(func1);
    633621if (f) { nok++;  usfmap[func1] = f; }
    634622else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
     
    636624if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin;
    637625// f = (DlUserProcFunction)  dlsym(dlhandle, func2.c_str());
    638 f = (DlFunction)  dlsym(dlhandle, func2.c_str());
     626f = dynlink->GetFunction(func2);
    639627if (f) { nok++;  usfmap[func2] = f; }
    640628else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
     
    642630if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin;
    643631// f = (DlUserProcFunction)  dlsym(dlhandle, func3.c_str());
    644 f = (DlFunction)  dlsym(dlhandle, func3.c_str());
     632f = dynlink->GetFunction(func3);
    645633if (f) { nok++;  usfmap[func3] = f; }
    646634else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
     
    648636if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") )  goto fin;
    649637// f = (DlUserProcFunction)  dlsym(dlhandle, func4.c_str());
    650 f = (DlFunction)  dlsym(dlhandle, func4.c_str());
     638f = dynlink->GetFunction(func4);
    651639if (f) { nok++;  usfmap[func4] = f; }
    652640else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
     
    654642if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") )  goto fin;
    655643// f = (DlUserProcFunction)  dlsym(dlhandle, func5.c_str());
    656 f = (DlFunction)  dlsym(dlhandle, func5.c_str());
     644f = dynlink->GetFunction(func5);
    657645if (f) { nok++;  usfmap[func5] = f; }
    658646else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
    659647
    660648fin:
    661 if (nok < 1) { dlclose(dlhandle);    dlhandle = NULL; return(3); }
     649if (nok < 1) { if (dynlink) delete dynlink;    dynlink = NULL; return(3); }
    662650else return(0);
    663651}
Note: See TracChangeset for help on using the changeset viewer.