home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / source / PToFront / PToFront.c < prev   
C/C++ Source or Header  |  1991-08-06  |  2KB  |  82 lines

  1. /* PToFront                        */
  2. /*                            */
  3. /* Hilfsprogramm fuer PasTeX 1.3.            */
  4. /*                            */
  5. /* Unter 2.0 kann ein Argument, ein Public-Screen Name,    */
  6. /* uebergeben werden.                    */
  7. /* Unter 1.3 wird immer der WB-Screen nach vorne    */
  8. /* geholt.                        */
  9. /*                            */
  10. /* Return-Codes:                    */
  11. /*  FAIL (20) - Intuition kann nicht geoeffnet werden.    */
  12. /*  WARN (5)  - Screen kann nicht gefunden werden.    */
  13. /*                            */
  14. /*    Georg Heßmann        27.07.91        */
  15.  
  16. #include <stdlib.h>
  17. #include <string.h>
  18.  
  19. #include <exec/types.h>
  20. #include <exec/execbase.h>
  21. #include <intuition/intuitionbase.h>
  22. #include <intuition/screens.h>
  23.  
  24. #include <clib/exec_protos.h>
  25. #include <clib/dos_protos.h>
  26. #include <clib/intuition_protos.h>
  27.  
  28. #include <pragmas/exec_pragmas.h>
  29. #include <pragmas/dos_pragmas.h>
  30. #include <pragmas/intuition_pragmas.h>
  31.  
  32.  
  33. static struct IntuitionBase    *IntuitionBase;
  34. extern struct ExecBase        *SysBase;
  35. extern struct Library        *DOSBase;
  36.  
  37.  
  38. static const char VersionID[]="$VER: PToFront 1.0 ("__DATE__")";
  39.  
  40.  
  41. void _main(char *arg)
  42. {
  43.   register struct Screen *scr;
  44.   long ret = RETURN_OK;
  45.  
  46.   IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
  47.   if (IntuitionBase == NULL) _exit(RETURN_FAIL);
  48.  
  49.   if (SysBase->LibNode.lib_Version >= 36L) {
  50.     register char *ptr;
  51.     char PubName[MAXPUBSCREENNAME+1];
  52.  
  53.     if (arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = '\0';
  54.  
  55.     ptr = strchr(arg+1, '\"');    /* Suche Ende des Programmnamens */
  56.     if (ptr != NULL) {
  57.       ptr += 2;
  58.     }
  59.     if (ptr == NULL || *ptr == '\0') {
  60.       /* kein Argument angegeben, suche den default PubScreen */
  61.       GetDefaultPubScreen(PubName);
  62.       ptr = &(PubName[0]);
  63.     }
  64.  
  65.     scr = LockPubScreen(ptr);
  66.     if (scr != NULL) {
  67.       ScreenToFront(scr);
  68.       UnlockPubScreen(ptr, NULL);
  69.     }
  70.     else {
  71.       Write(Output(), "Screen not found!\n", 18);
  72.       ret = RETURN_WARN;
  73.     }
  74.   }
  75.   else {
  76.     /* unter 1.3 wird nur der WB Screen nach vorne geholt */
  77.     (void)WBenchToFront();
  78.   }
  79.   _exit(ret);
  80. }
  81.  
  82.