home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / STK.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  67 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. ** stk.h - Stack manager (stk.c) header file.
  5. **
  6. ** By Dustin Puryear (dpuryear@intersurf.com), placed into Public Domain.
  7. */
  8.  
  9. #ifndef STK__H
  10. #define STK__H
  11.  
  12. typedef struct stknode
  13. {
  14.       void           *pdata;
  15.       struct stknode *pprev;
  16. } StkNode;
  17.  
  18. typedef struct stk
  19. {
  20.       StkNode        *ptop;
  21.       unsigned       vcount;
  22. } Stk;
  23.  
  24. /*
  25. ** stkInit()
  26. **
  27. ** Precondition   - pstack points to a stk type variable.
  28. ** Postcondition  - Stack pointed to by pstack is initialized.
  29. ** Returns        - None.
  30. */
  31.  
  32. extern void stkInit(Stk *pstack);
  33.  
  34. /*
  35. ** stkPush()
  36. **
  37. ** Precondition   - pstack points to an initialized stack.
  38. **                  pdata points to data to be stored in stack.
  39. ** Postcondition  - Data contained in pdata is pushed onto the stack.
  40. ** Returns        - Non-zero if success, 0 if error.
  41. */
  42.  
  43. extern int stkPush(Stk *pstack, void *pdata);
  44.  
  45. /*
  46. ** stkPop()
  47. **
  48. ** Precondition   - ppdata points to a pointer to contain data.
  49. **                  pstack points to initialized stack.
  50. ** Postcondition  - Top of stack is pushed into ppdata (pointer).
  51. ** Returns        - Non-zero if success, 0 if error.
  52. */
  53.  
  54. extern int stkPop(void **ppdata, Stk *pstack);
  55.  
  56. /*
  57. ** stkCount()
  58. **
  59. ** Precondition   - pstack points to an initialized stack.
  60. ** Postcondition  - None.
  61. ** Returns        - Number of items on stack.
  62. */
  63.  
  64. extern unsigned stkCount(Stk *pstack);
  65.  
  66. #endif /* STK__H */
  67.