home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / bsrc_260.arj / SRC.ZIP / statetbl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-23  |  4.2 KB  |  82 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*              (C) Copyright 1987-96, Bit Bucket Software Co.              */
  11. /*                                                                          */
  12. /*                  This module was written by Bob Hartman                  */
  13. /*                                                                          */
  14. /*                 BinkleyTerm General State Machine Driver                 */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*    For complete  details  of the licensing restrictions, please refer    */
  18. /*    to the License  agreement,  which  is published in its entirety in    */
  19. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.260.    */
  20. /*                                                                          */
  21. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  22. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  23. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  24. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  25. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  26. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  27. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  28. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  29. /*                                                                          */
  30. /*                                                                          */
  31. /* You can contact Bit Bucket Software Co. at any one of the following      */
  32. /* addresses:                                                               */
  33. /*                                                                          */
  34. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  35. /* P.O. Box 460398                AlterNet 7:42/1491                        */
  36. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  37. /*                                Internet f491.n343.z1.fidonet.org         */
  38. /*                                                                          */
  39. /* Please feel free to contact us at any time to share your comments about  */
  40. /* our software and/or licensing policies.                                  */
  41. /*                                                                          */
  42. /*--------------------------------------------------------------------------*/
  43.  
  44. /* Include this file before any other includes or defines! */
  45.  
  46. #include "includes.h"
  47.  
  48. #define DEBUG 1
  49.  
  50. int 
  51. state_machine (STATEP machine, void *passed_struct, int start_state)
  52. {
  53.     int cur_state;
  54.  
  55.     ((STATEBASEP) passed_struct)->control = start_state;
  56.  
  57. #if DEBUG
  58.     status_line (">Entering State Machine with state %d", start_state);
  59. #endif
  60.     cur_state = (*(machine[0].state_func)) (passed_struct);
  61. #if DEBUG
  62.     status_line (">State after init = %d", cur_state);
  63. #endif
  64.     while (cur_state > 0)
  65.     {
  66. #if DEBUG
  67.         status_line (">State: %s", machine[cur_state].state_name);
  68. #endif
  69.         cur_state = (*(machine[cur_state].state_func)) (passed_struct);
  70.     }
  71.  
  72. #if DEBUG
  73.     status_line (">Out of state machine with state = %d", cur_state);
  74. #endif
  75.     ((STATEBASEP) passed_struct)->control = cur_state;
  76.     cur_state = (*(machine[1].state_func)) (passed_struct);
  77. #if DEBUG
  78.     status_line (">Exiting after state end with state = %d", cur_state);
  79. #endif
  80.     return (cur_state);
  81. }
  82.