home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / bwbasic-2.10.sit / bwbasic-2.10 / bwb_par.c < prev    next >
Text File  |  1993-11-09  |  3KB  |  110 lines

  1. /***************************************************************
  2.  
  3.         bwb_par.c       Parallel Action (Multitasking) Routines
  4.                         for Bywater BASIC Interpreter
  5.  
  6.             Currently UNDER CONSTRUCTION
  7.  
  8.                         Copyright (c) 1993, Ted A. Campbell
  9.                         Bywater Software
  10.  
  11.                         email: tcamp@delphi.com
  12.  
  13.         Copyright and Permissions Information:
  14.  
  15.         All U.S. and international rights are claimed by the author,
  16.         Ted A. Campbell.
  17.  
  18.     This software is released under the terms of the GNU General
  19.     Public License (GPL), which is distributed with this software
  20.     in the file "COPYING".  The GPL specifies the terms under
  21.     which users may copy and use the software in this distribution.
  22.  
  23.     A separate license is available for commercial distribution,
  24.     for information on which you should contact the author.
  25.  
  26. ***************************************************************/
  27.  
  28. #include <stdio.h>
  29.  
  30. #include "bwbasic.h"
  31. #include "bwb_mes.h"
  32.  
  33. #if PARACT            /* this whole file ignored if FALSE */
  34.  
  35. /***************************************************************
  36.  
  37.         FUNCTION:       bwb_newtask()
  38.  
  39.         DESCRIPTION:    This C function allocates and initializes
  40.                 memory for a new task.
  41.  
  42. ***************************************************************/
  43.  
  44. #if ANSI_C
  45. int
  46. bwb_newtask( int task_requested )
  47. #else
  48. int
  49. bwb_newtask( task_requested )
  50.    int task_requested;
  51. #endif
  52.    {
  53.    static char start_buf[] = "¥0";
  54.    static char end_buf[] = "¥0";
  55.    register int c;
  56.  
  57.    /* find if requested task slot is available */ 
  58.  
  59.    if ( bwb_tasks[ task_requested ] != NULL )
  60.       {
  61. #if PROG_ERRORS
  62.       sprintf( bwb_ebuf, "in bwb_newtask(): Slot requested is already in use" );
  63.       bwb_error( bwb_ebuf );
  64. #else
  65.       bwb_error( err_overflow );
  66.       return -1;
  67. #endif
  68.       }
  69.  
  70.    /* get memory for task structure */
  71.  
  72.    if ( ( bwb_tasks[ task_requested ] = calloc( 1, sizeof( struct bwb_task ) ) )
  73.       == NULL )
  74.       {
  75. #if PROG_ERRORS
  76.       bwb_error( "in bwb_newtask(): failed to find memory for task structure" );
  77. #else
  78.       bwb_error( err_getmem );
  79. #endif
  80.       }
  81.  
  82.    /* set some initial variables */
  83.  
  84.    bwb_tasks[ task_requested ]->bwb_start.number = 0;
  85.    bwb_tasks[ task_requested ]->bwb_start.next = &bwb_tasks[ task_requested ]->bwb_end;
  86.    bwb_tasks[ task_requested ]->bwb_end.number = MAXLINENO + 1;
  87.    bwb_tasks[ task_requested ]->bwb_end.next = &bwb_tasks[ task_requested ]->bwb_end;
  88.    bwb_tasks[ task_requested ]->bwb_start.buffer = start_buf;
  89.    bwb_tasks[ task_requested ]->bwb_end.buffer = end_buf;
  90.    bwb_tasks[ task_requested ]->data_line = &bwb_tasks[ task_requested ]->bwb_start;
  91.    bwb_tasks[ task_requested ]->data_pos = 0;
  92.    bwb_tasks[ task_requested ]->rescan = TRUE;
  93.    bwb_tasks[ task_requested ]->exsc = -1;
  94.    bwb_tasks[ task_requested ]->expsc = 0;
  95.    bwb_tasks[ task_requested ]->xtxtsc = 0;
  96.  
  97.    /* Variable and function table initializations */
  98.  
  99.    var_init( task_requested );             /* initialize variable chain */
  100.    fnc_init( task_requested );             /* initialize function chain */
  101.    fslt_init( task_requested );        /* initialize funtion-sub  chain */
  102.  
  103.    return task_requested;
  104.  
  105.    }
  106.  
  107. #endif
  108.  
  109.  
  110.