home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dax1.exe / DAP / DAPE / DAPSESS.C < prev    next >
Text File  |  1992-07-15  |  4KB  |  112 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      dapsess.c                                             ║
  4. //   ║ abstract:    This module contains session support for the engine.  ║
  5. //   ║                                                                    ║
  6. //   ║ environment: NetWare 3.x v3.11                                     ║
  7. //   ║              Network C for NLMs SDK                                ║
  8. //   ║              CLib v3.11                                            ║
  9. //   ║                                                                    ║
  10. //   ║  This software is provided as is and carries no warranty           ║
  11. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  12. //   ║  warranties of merchantability, title and fitness for a particular ║
  13. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  14. //   ║  your requirements or that the software is without defect or error ║
  15. //   ║  or that operation of the software will be uninterrupted.  You are ║
  16. //   ║  using the software at your risk.  The software is not a product   ║
  17. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  18. //   ║                                                                    ║
  19. //   ╟────────────────────────────────────────────────────────────────────╢
  20. //   ║ maintenance history:                                               ║
  21. //   ║ level    date      pi   description                                ║
  22. //   ╟────────────────────────────────────────────────────────────────────╢
  23. //   ║  001   03/03/92    kl   initial release.                           ║
  24. //   ╚════════════════════════════════════════════════════════════════════╝
  25.  
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include "dap/dapsys.h"
  29.  
  30. //
  31. //  maximumSessions holds the current size of the 'dapsessions' array.
  32. //  If you make this a pointer, you can dynamically grow and shrink the
  33. //  size of the array.
  34. //
  35.  
  36. STATIC  UINT32  maximumSessions = DEFMAXSESSIONS;
  37. STATIC  DAPDATA dapsessions[DEFMAXSESSIONS];
  38.  
  39. UINT32  DAPGetMaximumNumberOfSessions() { return maximumSessions; }
  40.  
  41. //
  42. //  Return a pointer to the array.
  43. //
  44.  
  45. DAPDATA *DAPGetClientArray()            { return dapsessions; }
  46.  
  47. //
  48. //  The following routine is called during startup, it could be
  49. //  used to allocate memory for a 'dynamic' session array
  50. //
  51.  
  52. T_RC    DAPInitializeSessLogic()        { return DAP_SUCCESS; }
  53.  
  54. //
  55. //  Called during shutdown procedure.
  56. //
  57.  
  58. void    DAPDeInitializeSessLogic()      {}
  59.  
  60. UINT32  DAPSeeIfActiveCPid(UINT32 CPid)
  61. {
  62.         int     i;
  63.  
  64.         for(i=0; i < maximumSessions; ++i){
  65.             if( DAPSlotInUse( &dapsessions[i] ) && dapsessions[i].CPid == CPid) {
  66.                 return i;
  67.             }
  68.         }
  69.         return -1;
  70. }
  71.  
  72. //
  73. //  Allocate a slot in the session array.  This API is called from
  74. //  DAPEnqueueServiceRequest() when it detects a new session is needed.
  75. //  This occurs when an invalid session id is passed in, normally 0,
  76. //  when the client is performing DAPAllocateSession().
  77. //
  78.  
  79. UINT32  DAPAllocateSlot()
  80. {
  81.         int i;
  82.  
  83.         for(i=0; i < maximumSessions; ++i){
  84.             if( !DAPSlotInUse( &dapsessions[i] ) ) {
  85.                 DAPStateON(&dapsessions[i],DAP_SLOTINUSE);
  86.                 DAPIncActiveSessions();
  87.                 return i;
  88.             }
  89.         }
  90.         return -1;
  91. }
  92.  
  93. void    DAPDeAllocateSlot(DAPDATA *DAPid)
  94. {
  95.  
  96.         if( DAPSlotInUse(DAPid) ){
  97.             DAPStateOFF(DAPid,DAP_SLOTINUSE);
  98.             //!!
  99.             //!!
  100.             //!!
  101.         #if 0
  102.             memset(DAPid,NULL,sizeof *DAPid);
  103.         #else
  104.             //
  105.             //  Got to reset this, or we'll have a synchronization problem.
  106.             //
  107.             DAPid->DAPState = DAPid->DAPFlags = 0;
  108.         #endif
  109.             DAPDecActiveSessions();
  110.         }
  111. }
  112.