home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d09xx / d0912.lha / Yak / Source / Source.lha / WB2CLI.h < prev    next >
C/C++ Source or Header  |  1993-07-31  |  5KB  |  145 lines

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