home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / STATETBL.C < prev    next >
C/C++ Source or Header  |  1990-05-14  |  5KB  |  96 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-90, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                  This module was written by Bob Hartman                  */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                 BinkleyTerm General State Machine Driver                 */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.240.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:132/491, 1:141/491  */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n132.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46.  
  47. /* System include files */
  48. #include <fcntl.h>
  49. #include <stdio.h>
  50.  
  51. /* Local include files */
  52. #include "defines.h"
  53. #include "com.h"
  54. #include "xfer.h"
  55. #include "zmodem.h"
  56. #include "keybd.h"
  57. #include "sbuf.h"
  58. #include "sched.h"
  59. #include "externs.h"
  60. #include "prototyp.h"
  61.  
  62. #define DEBUG 1
  63.  
  64. int state_machine (machine, passed_struct, start_state)
  65. STATEP machine;
  66. void *passed_struct;
  67. int start_state;
  68. {
  69.    int cur_state;
  70.  
  71. #if DEBUG
  72.    status_line (">Entering State Machine with state %d", start_state);
  73. #endif
  74.    cur_state = (*(machine[0].state_func)) (passed_struct, start_state);
  75. #if DEBUG
  76.    status_line (">State after init = %d", cur_state);
  77. #endif
  78.    while (cur_state > 0)
  79.       {
  80. #if DEBUG
  81.       status_line (">State: %s", machine[cur_state].state_name);
  82. #endif
  83.       cur_state = (*(machine[cur_state].state_func)) (passed_struct);
  84.       }
  85.  
  86. #if DEBUG
  87.    status_line (">Out of state machine with state = %d", cur_state);
  88. #endif
  89.    cur_state = (*(machine[1].state_func)) (passed_struct, cur_state);
  90. #if DEBUG
  91.    status_line (">Exiting after state end with state = %d", cur_state);
  92. #endif
  93.    return (cur_state);
  94. }
  95.  
  96.