home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / pufferfish / source / wb2cli / wb2cli.h < prev    next >
C/C++ Source or Header  |  1994-03-26  |  5KB  |  142 lines

  1. /*
  2.  * $Id: wb2cli.h,v 1.7 92/02/11 12:24:34 mks Exp $
  3.  *
  4.  * $Log:    wb2cli.h,v $
  5.  * Revision 1.7  92/02/11  12:24:34  mks
  6.  * Slight wording change
  7.  * 
  8.  * Revision 1.6  92/02/11  12:14:19  mks
  9.  * Minor doc change
  10.  *
  11.  * Revision 1.5  91/12/30  18:22:28  mks
  12.  * Cleaned up the docs a bit...
  13.  *
  14.  * Revision 1.4  91/07/24  20:03:29  mks
  15.  * Autodoc cleanup
  16.  *
  17.  * Revision 1.2  91/07/24  18:58:42  mks
  18.  * Forgot to fix the example to use default stack.
  19.  *
  20.  * Revision 1.1  91/07/24  18:57:46  mks
  21.  * Added the defaultstack to the prototype and documentation.
  22.  *
  23.  * Revision 1.0  91/07/24  17:03:24  mks
  24.  * Initial revision
  25.  *
  26.  */
  27.  
  28. /*
  29.  * WB2CLI - By Michael Sinz
  30.  *             Operating System Development Group
  31.  *             Commodore-Amiga, Inc.
  32.  *
  33.  * This is the magic code needed to take a started workbench process
  34.  * and convert it into a CLI process with a copy of the workbench path.
  35.  *
  36.  * After that point, the process will look much like a background CLI.
  37.  */
  38.  
  39. /*
  40. ******* WB2CLI ***************************************************************
  41. *
  42. *   NAME
  43. *    WB2CLI                                (V37)
  44. *
  45. *   SYNOPSIS
  46. *    status = WB2CLI(wbmsg,defaultstack,dosbase)
  47. *      D0             A0    D0           A1
  48. *
  49. *    LONG WB2CLI(struct WBStartup *,ULONG,struct DosLibrary *)
  50. *
  51. *   FUNCTION
  52. *    This function will take a workbench started application and change
  53. *    it into a CLI-like application.  This will include a path as copied
  54. *    from the Workbench.  The CLI default stack is used to pick the stack
  55. *    size for the processes run as CLIs.  (This is in SYNC mode)
  56. *
  57. *    You would pass in the Workbench message pointer and a pointer
  58. *    to an open dos.library.  (The DosLibrary pointer is used to call
  59. *    dos.library without the need of globals.)
  60. *
  61. *    This *REQUIRES* V37 dos.library and exec.library.
  62. *
  63. *   NOTES
  64. *    Assembly language programmers:  This routine is _WB2CLI
  65. *
  66. *    If you call WB2CLI() and are already a CLI, it will return as if
  67. *    it worked even though it did nothing.  (After all, you were a CLI)
  68. *    For this reason, you do not need to check if you are a CLI
  69. *    started program before you call the function.
  70. *
  71. *    One word of interest:  Once you call this function, the pr_CLI
  72. *    field of your process will *NOT* be NULL.  This is by definition
  73. *    of what this program is trying to do, which is make you like a CLI.
  74. *    You will, however, still need to reply the workbench startup message
  75. *    that you passed to the WB2CLI routine.
  76. *
  77. *    You are, however, responsible for setting up any input or output
  78. *    file handles that you may needed.  Being workbench started means
  79. *    that you have no standard-in or standard-out.  (Just as before)
  80. *    (In other words, this function does not magically give you any
  81. *    I/O as you may already have done so or need a special form of it)
  82. *    These handles are pr_CIS, pr_COS, etc.  For example, many DOS
  83. *    calls may rely on these being valid.  RunCommand() under V37
  84. *    is one such creature.
  85. *
  86. *   EXAMPLE
  87. *    void main(int argc, char *argv[])
  88. *    {
  89. *    struct  DosLibrary  *DOSBase;
  90. *
  91. *        \* We need V37 to do this *\
  92. *        if (DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",37L))
  93. *        {
  94. *        \* Cute trick:  If you are a CLI, WB2CLI is a NO-OP *\
  95. *        \* Thus, you normally don't need to check *\
  96. *            \* NOTE:  Most of the time you will ignore the error *\
  97. *            if (WB2CLI((struct WBStartup *)argv,4000,DOSBase))
  98. *            {
  99. *                \* We now are workbench started CLI *\
  100. *                \* (Complete with path *\
  101. *            }
  102. *            else
  103. *            {
  104. *                \* We did not become a CLI but we still *\
  105. *                \* can run.  Just not as a CLI *\
  106. *            }
  107. *
  108. *            \* More stuff *\
  109. *
  110. *            CloseLibrary((struct Library *)DOSBase);
  111. *        }
  112. *    }
  113. *
  114. *   INPUTS
  115. *    wbmsg -- The Workbench message that you were started with.  If NULL
  116. *             this routine will do nothing...
  117. *
  118. *    defaultstack -- The size of the CLI default stack in bytes.
  119. *                    You *SHOULD* supply a value of at least 4000.
  120. *
  121. *    dosbase -- Pointer to dos.library (must be open)
  122. *
  123. *   RESULTS
  124. *    A magically transformed process that has a CLI structure added.
  125. *
  126. *    status -- Returns TRUE if it worked.  Usually can be ignored
  127. *              as your program will continue to work as if you did not
  128. *              call this function.
  129. *
  130. *   SEE ALSO
  131. *    None
  132. *
  133. *   BUGS
  134. *
  135. ******************************************************************************
  136. */
  137.  
  138. #include    <dos/dosextens.h>
  139. #include    <workbench/startup.h>
  140.  
  141. LONG __asm WB2CLI(register __a0 struct WBStartup *,register __d0 ULONG,register __a1 struct DosLibrary *);
  142.