home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / f2c / f77lib / s_paus.c~ < prev    next >
Text File  |  2000-05-21  |  4KB  |  146 lines

  1. #ifdef _AMIGA
  2. #include <string.h>
  3. #include <signal.h>
  4. #include <stdlib.h>
  5. #include <exec/types.h>
  6. #include <intuition/intuition.h>
  7. #include <libraries/dosextens.h>
  8. #include <proto/exec.h>
  9. #include <proto/dos.h>
  10. #include <proto/intuition.h>
  11. #include "f2c.h"
  12. #else /* AMIGA */
  13. #include "stdio.h"
  14. #include "f2c.h"
  15. #define PAUSESIG 15
  16. #endif /* AMIGA */
  17.  
  18. #ifndef _AMIGA
  19. #ifdef KR_headers
  20. #define Void /* void */
  21. #define Int /* int */
  22. #else
  23. #define Void void
  24. #define Int int
  25. #undef abs
  26. #include "stdlib.h"
  27. #include "signal.h"
  28. extern int getpid(void), isatty(int), pause(void);
  29. #endif
  30. #else /* AMIGA */
  31. #define Void void
  32. #define Int int
  33. #endif /* AMIGA */
  34.  
  35. #ifdef __cplusplus
  36. extern "C" void f_exit(void);
  37. #else
  38. extern VOID f_exit(Void);
  39. #endif
  40.  
  41. static VOID waitpause(Int n)
  42. {
  43. return;
  44. }
  45.  
  46. #ifdef KR_headers
  47. VOID s_paus(s, n) char *s; ftnlen n;
  48. #else
  49. void s_paus(char *s, ftnlen n)
  50. #endif
  51. {
  52. #ifdef _AMIGA
  53. static struct IntuiText Text2 = {
  54.            -1, -1,                           /* pen numbers */
  55.            0,                                /* draw mode */
  56.            14, 14,                           /* starting offsets */
  57.            NULL,                             /* text attribute pointer */
  58.            "Pause statement executed",
  59.            NULL
  60. };
  61.  
  62. static struct IntuiText BodyText = {
  63.            -1, -1,                           /* pen numbers */
  64.            0,                                /* draw mode */
  65.            4, 4,                             /* starting offsets */
  66.            NULL,                             /* text attribute pointer */
  67.            NULL,
  68.            &Text2
  69. };
  70.  
  71. static struct IntuiText ContinueText = {
  72.            -1, -1,                           /* pen numbers */
  73.            0,                                /* draw mode */
  74.            4, 4,                             /* starting offsets */
  75.            NULL,                             /* text attribute pointer */
  76.            "CONTINUE",
  77.            NULL
  78. };
  79.  
  80. static struct IntuiText AbortText = {
  81.            -1, -1,                           /* pen numbers */
  82.            0,                                /* draw mode */
  83.            4, 4,                             /* starting offsets */
  84.            NULL,                             /* text attribute pointer */
  85.            "ABORT",
  86.            NULL
  87. };
  88.  
  89.     char   temp[81];
  90.     struct IntuitionBase         *IntuitionBase;
  91.  
  92.     if (n > 79)
  93.         n = 79;
  94.     memcpy(temp, s, n);
  95.     temp[n+1] = '\0';
  96.  
  97.     IntuitionBase = (struct IntuitionBase *)
  98.                            OpenLibrary("intuition.library",0);
  99.     if (IntuitionBase == NULL) {
  100.     f_exit();
  101.     exit(0);
  102.     }
  103.  
  104.     BodyText.IText = temp;
  105.  
  106.     if (AutoRequest(NULL, &BodyText, &ContinueText, &AbortText,
  107.                                   0L, 0L, 250L, 60L) != TRUE) {
  108.     CloseLibrary(IntuitionBase);
  109.     f_exit();
  110.     exit(0);
  111.     } else {
  112.     CloseLibrary(IntuitionBase);
  113.     return;
  114.     }
  115.  
  116. #else /* AMIGA */
  117. int i;
  118.  
  119. fprintf(stderr, "PAUSE ");
  120. if(n > 0)
  121.     for(i = 0; i<n ; ++i)
  122.         putc(*s++, stderr);
  123. fprintf(stderr, " statement executed\n");
  124. if( isatty(fileno(stdin)) )
  125.     {
  126.     fprintf(stderr, "To resume execution, type go.  Any other input will terminate job.\n");
  127.     fflush(stderr);
  128.     if( getchar()!='g' || getchar()!='o' || getchar()!='\n' )
  129.         {
  130.         fprintf(stderr, "STOP\n");
  131.         f_exit();
  132.         exit(0);
  133.         }
  134.     }
  135. else
  136.     {
  137.     fprintf(stderr, "To resume execution, execute a   kill -%d %d   command\n",
  138.         PAUSESIG, getpid() );
  139.     signal(PAUSESIG, waitpause);
  140.     fflush(stderr);
  141.     pause();
  142.     }
  143. fprintf(stderr, "Execution resumes after PAUSE.\n");
  144. #endif /* AMIGA */
  145. }
  146.