Changeset 9 in Sophya for trunk/SophyaPI/PI/pidemo.cc


Ignore:
Timestamp:
Mar 6, 1996, 11:52:37 PM (30 years ago)
Author:
eros
Message:

Version debuggee avec SharedLibraries, et gestion correcte de fontes ds
pibwdgx.cc, Version MAc ramene de Saclay (6/3/96) - link dynamique ds
pidemo.cc (Reza)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pidemo.cc

    r8 r9  
    11#include <stdlib.h>
    22#include <stdio.h>
     3#include <string.h>
     4#include <dlfcn.h>
    35
    46#include "perrors.h"
     
    68
    79#include "pidemo.h"
    8 #include "pidemoup.h"
    9 
    10 
    11 
     10#include "piup.h"
     11
     12
     13/*  Pour le link dynamique  */
     14typedef FitsImageR4 * (* UsPrFunc) (FitsImageR4 * myimg, int xp, int yp,
     15                                    char * arg1, char * arg2);
     16static UsPrFunc  userFunc[3] = { NULL, NULL, NULL };
     17static void *dlhandle = NULL;
     18
     19static char userlibname[256];
     20
     21static int DynLink(char *usln);
     22
     23int DynLink(char *usln)
     24{
     25UsPrFunc uf;
     26int i, rc;
     27
     28if (usln != NULL)  strncpy(userlibname, usln, 255);  userlibname[255] = '\0';
     29
     30printf("PIDemo_DynLink(): Relinking from %s \n", userlibname);
     31if (dlhandle != NULL)  dlclose(dlhandle);
     32for(i=0; i<3; i++)  userFunc[i] = NULL;
     33dlhandle =  dlopen(userlibname, RTLD_NOW);
     34if (dlhandle == NULL) 
     35  { printf("PIDemo_DynLink(), Erreur d'ouverture UserShLib %s \n", userlibname);
     36  return(100); }
     37rc = 0;
     38printf("PIDemo_DynLink(): Searching for PIUserProc_1 (Rc=%d) \n", rc);
     39uf = dlsym(dlhandle, "PIUserProc_1__FPt9FitsImage1ZfiiPcT3");
     40if (uf != NULL)  userFunc[0] = uf;
     41else rc += 2;
     42printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc);
     43uf = dlsym(dlhandle, "PIUserProc_2__FPt9FitsImage1ZfiiPcT3");
     44if (uf != NULL)  userFunc[1] = uf;
     45else rc += 4;
     46printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc);
     47uf = dlsym(dlhandle, "PIUserProc_3__FPt9FitsImage1ZfiiPcT3");
     48if (uf != NULL)  userFunc[2] = uf;
     49else rc += 8;
     50
     51if (rc != 0)  printf("PIDemo_DynLink() / Erreur, Rc = %d \n", rc);
     52return(rc);
     53}
    1254
    1355/* ........................................................... */
     
    2870m[0]->AppendItem("Close", 10102);
    2971m[0]->AppendItem("Save", 10103);
    30 m[0]->AppendItem("Exit", 10104);
     72m[0]->AppendItem("Relink", 10104);
     73m[0]->AppendItem("Exit", 10105);
    3174
    3275m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Image");
     
    188231
    189232    case 10104:
     233      SetBusy();
     234      DynLink(NULL);
     235      SetReady();
     236      break;
     237
     238    case 10105:
    190239      Stop();
    191240      break;
     
    407456int n;
    408457if ((n=GetNumCurrent()) < 0)  return;
     458zoom->SetPixmap(NULL,0,0);
     459zoom->EraseWindow();
     460labimg->SetLabel("");
    409461wpii[n]->Hide();
    410462delete pii[n];
    411463delete img[n];
    412464delete wpii[n];
    413 zoom->EraseWindow();
    414 labimg->SetLabel("");
    415 pii[n] = pii[mNimg];
    416 wpii[n] = wpii[mNimg];
    417 img[n] = img[mNimg];
     465pii[n] = pii[mNimg-1];
     466wpii[n] = wpii[mNimg-1];
     467img[n] = img[mNimg-1];
    418468mNimg--;
    419469mCur = NULL;
     
    648698      {
    649699      case 1 :
    650         oimg = PIUserProc_1(mimg, xp, yp,
     700      case 2 :
     701      case 3 :
     702        oimg = userFunc[mUpr-1] (mimg, xp, yp,
    651703                            (char *) (mText[1]->GetText().c_str()),
    652704                            (char *) (mText[2]->GetText().c_str()));
    653705        break;
    654 
     706/*
    655707      case 2 :
    656708        oimg = PIUserProc_2(mimg, xp, yp,
     
    664716                            (char *) (mText[2]->GetText().c_str()));
    665717        break;
    666 
     718*/
    667719      }   
    668720    if (oimg)  dap->AddImage(oimg,mText[0]->GetText());
     
    680732
    681733char *path;
     734int rc;
    682735 
    683736if (narg > 1)  path = arg[1];
    684737else path = NULL;
    685738
     739if (narg > 2)  rc = DynLink(arg[2]);
     740else rc = DynLink("piup.so");
     741if (rc != 0)
     742  {
     743  printf("PIApp:: Erreur d'ouverture UserProcFunc Shared-Object ... \n");
     744  exit(0);
     745  }
     746
    686747PIDemoApp app(path);
    687748
    688749app.Run();
    689750
     751dlclose(dlhandle);
    690752exit(0);
    691753}
Note: See TracChangeset for help on using the changeset viewer.