Changeset 9 in Sophya for trunk/SophyaPI/PI/pidemo.cc
- Timestamp:
- Mar 6, 1996, 11:52:37 PM (30 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pidemo.cc
r8 r9 1 1 #include <stdlib.h> 2 2 #include <stdio.h> 3 #include <string.h> 4 #include <dlfcn.h> 3 5 4 6 #include "perrors.h" … … 6 8 7 9 #include "pidemo.h" 8 #include "pidemoup.h" 9 10 11 10 #include "piup.h" 11 12 13 /* Pour le link dynamique */ 14 typedef FitsImageR4 * (* UsPrFunc) (FitsImageR4 * myimg, int xp, int yp, 15 char * arg1, char * arg2); 16 static UsPrFunc userFunc[3] = { NULL, NULL, NULL }; 17 static void *dlhandle = NULL; 18 19 static char userlibname[256]; 20 21 static int DynLink(char *usln); 22 23 int DynLink(char *usln) 24 { 25 UsPrFunc uf; 26 int i, rc; 27 28 if (usln != NULL) strncpy(userlibname, usln, 255); userlibname[255] = '\0'; 29 30 printf("PIDemo_DynLink(): Relinking from %s \n", userlibname); 31 if (dlhandle != NULL) dlclose(dlhandle); 32 for(i=0; i<3; i++) userFunc[i] = NULL; 33 dlhandle = dlopen(userlibname, RTLD_NOW); 34 if (dlhandle == NULL) 35 { printf("PIDemo_DynLink(), Erreur d'ouverture UserShLib %s \n", userlibname); 36 return(100); } 37 rc = 0; 38 printf("PIDemo_DynLink(): Searching for PIUserProc_1 (Rc=%d) \n", rc); 39 uf = dlsym(dlhandle, "PIUserProc_1__FPt9FitsImage1ZfiiPcT3"); 40 if (uf != NULL) userFunc[0] = uf; 41 else rc += 2; 42 printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc); 43 uf = dlsym(dlhandle, "PIUserProc_2__FPt9FitsImage1ZfiiPcT3"); 44 if (uf != NULL) userFunc[1] = uf; 45 else rc += 4; 46 printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc); 47 uf = dlsym(dlhandle, "PIUserProc_3__FPt9FitsImage1ZfiiPcT3"); 48 if (uf != NULL) userFunc[2] = uf; 49 else rc += 8; 50 51 if (rc != 0) printf("PIDemo_DynLink() / Erreur, Rc = %d \n", rc); 52 return(rc); 53 } 12 54 13 55 /* ........................................................... */ … … 28 70 m[0]->AppendItem("Close", 10102); 29 71 m[0]->AppendItem("Save", 10103); 30 m[0]->AppendItem("Exit", 10104); 72 m[0]->AppendItem("Relink", 10104); 73 m[0]->AppendItem("Exit", 10105); 31 74 32 75 m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Image"); … … 188 231 189 232 case 10104: 233 SetBusy(); 234 DynLink(NULL); 235 SetReady(); 236 break; 237 238 case 10105: 190 239 Stop(); 191 240 break; … … 407 456 int n; 408 457 if ((n=GetNumCurrent()) < 0) return; 458 zoom->SetPixmap(NULL,0,0); 459 zoom->EraseWindow(); 460 labimg->SetLabel(""); 409 461 wpii[n]->Hide(); 410 462 delete pii[n]; 411 463 delete img[n]; 412 464 delete wpii[n]; 413 zoom->EraseWindow(); 414 labimg->SetLabel(""); 415 pii[n] = pii[mNimg]; 416 wpii[n] = wpii[mNimg]; 417 img[n] = img[mNimg]; 465 pii[n] = pii[mNimg-1]; 466 wpii[n] = wpii[mNimg-1]; 467 img[n] = img[mNimg-1]; 418 468 mNimg--; 419 469 mCur = NULL; … … 648 698 { 649 699 case 1 : 650 oimg = PIUserProc_1(mimg, xp, yp, 700 case 2 : 701 case 3 : 702 oimg = userFunc[mUpr-1] (mimg, xp, yp, 651 703 (char *) (mText[1]->GetText().c_str()), 652 704 (char *) (mText[2]->GetText().c_str())); 653 705 break; 654 706 /* 655 707 case 2 : 656 708 oimg = PIUserProc_2(mimg, xp, yp, … … 664 716 (char *) (mText[2]->GetText().c_str())); 665 717 break; 666 718 */ 667 719 } 668 720 if (oimg) dap->AddImage(oimg,mText[0]->GetText()); … … 680 732 681 733 char *path; 734 int rc; 682 735 683 736 if (narg > 1) path = arg[1]; 684 737 else path = NULL; 685 738 739 if (narg > 2) rc = DynLink(arg[2]); 740 else rc = DynLink("piup.so"); 741 if (rc != 0) 742 { 743 printf("PIApp:: Erreur d'ouverture UserProcFunc Shared-Object ... \n"); 744 exit(0); 745 } 746 686 747 PIDemoApp app(path); 687 748 688 749 app.Run(); 689 750 751 dlclose(dlhandle); 690 752 exit(0); 691 753 }
Note:
See TracChangeset
for help on using the changeset viewer.