home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXXBOOT.ZIP / REXXBOOT.C < prev    next >
C/C++ Source or Header  |  1993-04-12  |  3KB  |  103 lines

  1. /* rexxboot.c */
  2.  
  3. #define  INCL_REXXSAA
  4. #define  _DLL
  5. #define  _MT
  6. #define  INCL_DOS
  7. #define  INCL_NOPM
  8. #include <os2.h>
  9. #include <rexxsaa.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13.  
  14. RexxFunctionHandler SysReboot;
  15. RexxFunctionHandler SysSyncDisk;
  16.  
  17. /*********************************************************************/
  18. /* Numeric Return calls                                              */
  19. /*********************************************************************/
  20.  
  21. #define  INVALID_ROUTINE 40            /* Raise Rexx error           */
  22. #define  VALID_ROUTINE    0            /* Successful completion      */
  23.  
  24. /*********************************************************************/
  25. /* Some useful macros                                                */
  26. /*********************************************************************/
  27.  
  28. #define REXXRET(val) { \
  29.   itoa( val, prxRet->strptr, 10 ); \
  30.   prxRet->strlength = strlen( prxRet->strptr ); \
  31. }
  32.  
  33. #define REXXENTRY(f) \
  34. ULONG f( PSZ         pszName,    /* name func invoked as */ \
  35.          ULONG       cArgs,      /* number of arguments  */ \
  36.          RXSTRING    argv[],     /* argument array       */ \
  37.          PSZ         pszQueue,   /* name of current queue*/ \
  38.          PRXSTRING   prxRet )    /* string for func res  */
  39.  
  40. #define BUILDRXSTRING(t, s) { \
  41.   strcpy((t)->strptr,(s));\
  42.   (t)->strlength = strlen((s)); \
  43. }
  44.  
  45. /*************************************************************************
  46. * Function:  SysReboot                                                   *
  47. *                                                                        *
  48. * Syntax:                                                                *
  49. *                                                                        *
  50. * Return:                                                                *
  51. *************************************************************************/
  52.  
  53. REXXENTRY(SysReboot)
  54. {
  55.    HFILE  hf;
  56.    APIRET rc;
  57.    ULONG  dummy;
  58.  
  59.    if (cArgs)
  60.       return INVALID_ROUTINE;
  61.  
  62.    if (!(rc = DosOpen( "DOS$", &hf, &dummy, 0L, FILE_NORMAL, FILE_OPEN,
  63.                        OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYNONE |
  64.                        OPEN_FLAGS_FAIL_ON_ERROR, 0L )))
  65.    {
  66.       ULONG ulParmLength = 0;
  67.       ULONG ulDataLength = 0;
  68.  
  69.       DosShutdown( 0L );
  70. //    DosDevIOCtl( NULL, NULL, 0xab, 0xd5, hf );       /* 1.3 reboot */
  71.       DosDevIOCtl( hf, 0xd5, 0xab,                     /* 2.0 reboot */
  72.                    NULL, 0L, &ulParmLength,
  73.                    NULL, 0L, &ulDataLength );
  74.       DosClose( hf );
  75.    }
  76.  
  77.    REXXRET(rc);
  78.    return VALID_ROUTINE;
  79. }
  80.  
  81. /*************************************************************************
  82. * Function:  SysSyncDisk                                                 *
  83. *                                                                        *
  84. * Syntax:                                                                *
  85. *                                                                        *
  86. * Return:                                                                *
  87. *************************************************************************/
  88.  
  89. REXXENTRY(SysSyncDisk)
  90. {
  91.    if (cArgs)
  92.       return INVALID_ROUTINE;
  93.  
  94.    DosShutdown( 1L );
  95.  
  96.    REXXRET(0);
  97.    return VALID_ROUTINE;
  98. }
  99.  
  100. /* $Log$
  101.  */
  102.  
  103.