home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 230.lha / PopCli_IV / termproc.c < prev   
C/C++ Source or Header  |  1989-04-06  |  2KB  |  68 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2. /* |_o_o|\\ Copyright (c) 1986 The Software Distillery.  All Rights Reserved */
  3. /* |. o.| || This program may not be distributed without the permission of   */
  4. /* | .  | || the authors.                                                    */
  5. /* | o  | ||    Dave Baker     Ed Burnette  Stan Chow    Jay Denebeim        */
  6. /* |  . |//     Gordon Keener  Jack Rouse   John Toebes  Doug Walker         */
  7. /* ======          BBS:(919)-471-6436      VOICE:(919)-469-4210              */ 
  8. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  9. /*
  10.  * VERY loosely based on the input.device example by Rob Peck, 12/1/85
  11.  */
  12.  
  13. /*
  14.  * termproc() frees all of the stuff which copyproc() allocated for its
  15.  * functionality.
  16.  */
  17.  
  18. #include "popcli.h"
  19.  
  20. static void DosFree( GLOBAL_DATA *, char * );
  21.  
  22. void termproc( gptr, bye )
  23. GLOBAL_DATA *gptr;
  24. register struct Process *bye;
  25. {
  26.    register struct CDIR                   *current, *next;
  27.    register struct CommandLineInterface   *byecli;
  28.  
  29.    /* Free the path chain, the CLI structure block, then unlock the       */
  30.    /* current directory.                                                  */
  31.  
  32.    byecli = (struct CommandLineInterface *)(bye->pr_CLI << 2);
  33.    if (byecli)
  34.    {
  35.       for (current = (struct CDIR *)(byecli->cli_CommandDir << 2);
  36.            current != NULL;
  37.            current = next)
  38.       {
  39.          next = (struct CDIR *)(current->next << 2);
  40.          UnLock( current->lock );
  41.          DosFree( gptr, (char *)current );
  42.       }
  43.  
  44.       DosFree( gptr, (char *)byecli );
  45.       bye->pr_CLI = NULL;
  46.    }
  47.  
  48.    UnLock( bye->pr_CurrentDir );
  49.    bye->pr_CurrentDir = NULL;
  50. }
  51.  
  52. /*
  53.  * Back up 4 bytes, get the length, and free that much
  54.  * Block should have been allocated with DosAlloc, in copyproc.c
  55.  */
  56.  
  57. static void DosFree( gptr, mem )
  58. struct GLOBAL_DATA *gptr;
  59. char *mem;
  60. {
  61.    register long    *old;
  62.  
  63.    old = (long *)(mem - 4);
  64.  
  65.    FreeMem( (char *)old, *old );
  66. }
  67.  
  68.