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

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      dap010.c                                              ║
  4. //   ║ abstract:    This module contains DAP Request 1010                 ║
  5. //   ║                                                                    ║
  6. //   ║ environment: NetWare 3.x v3.11                                     ║
  7. //   ║              Network C for NLMs SDK                                ║
  8. //   ║              CLib v3.11                                            ║
  9. //   ║              Network C for DOS v2.0                                ║
  10. //   ║              NetWare C Interface DOS v1.2                          ║
  11. //   ║                                                                    ║
  12. //   ║  This software is provided as is and carries no warranty           ║
  13. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  14. //   ║  warranties of merchantability, title and fitness for a particular ║
  15. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  16. //   ║  your requirements or that the software is without defect or error ║
  17. //   ║  or that operation of the software will be uninterrupted.  You are ║
  18. //   ║  using the software at your risk.  The software is not a product   ║
  19. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  20. //   ║                                                                    ║
  21. //   ╟────────────────────────────────────────────────────────────────────╢
  22. //   ║ maintenance history:                                               ║
  23. //   ║ level    date      pi   description                                ║
  24. //   ╟────────────────────────────────────────────────────────────────────╢
  25. //   ║  001   01/15/92    kl   initial release.                           ║
  26. //   ╚════════════════════════════════════════════════════════════════════╝
  27.  
  28. #include    <string.h>
  29. #include    "dap/dapsys.h"
  30. #include    "cp/cpapi.h"
  31.  
  32. //
  33. //  The following are the request/reply structures for the AllocateSession
  34. //  DAP.
  35. //
  36. typedef struct{                         // allocate session request pkt
  37.         UINT32      dummy;
  38. }ASRequest;
  39.  
  40. typedef struct{                         // allocate session reply pkt
  41.         UINT32      sessionID;          // session number assigned
  42. }ASReply;
  43.  
  44. #if !defined(ENGINE)
  45.  
  46. //
  47. //  Following is the Client-Side API for AllocateSession
  48. //
  49. //      DAPid     - this is obtained from DAPInitialize.  It is
  50. //                  normally a pointer to some sort of structure
  51. //                  containing info needed to connect to the server.
  52. //
  53.  
  54. T_RC    DAPAllocateSession(DAPDATA *DAPid)
  55. {
  56.         T_RC        rc;
  57.         ASReply     *reply   = (ASReply *)DAPid->dapReply.data;
  58.  
  59.         if( CPConnectToServer(DAPid->CPid) ) return DAP_CANT_CONNECT;
  60.  
  61.         memset(&DAPid->dapRequest,'\0',sizeof DAPid->dapRequest);
  62.         memset(&DAPid->dapReply,'\0',sizeof DAPid->dapReply);
  63.         //
  64.         //  Set the sessionID field in the DAPid structure to 0.
  65.         //  This signals the engine to allocate a new session for
  66.         //  this client.
  67.         //
  68.         DAPid->sessionID = 0;
  69.         //
  70.         //  Send the request to the application server
  71.         //
  72.         rc = DAPSendRequest(DAPid,DAPALLOCATESESSION);
  73.         //
  74.         //  Extract and save the sessionID for subsequent requests...
  75.         //
  76.         DAPid->sessionID = reply->sessionID;
  77.         return rc;
  78. }
  79.  
  80. #else   // !defined(ENGINE)
  81.  
  82. //
  83. //  Following is the Server-Side API for AllocateSession
  84. //
  85.  
  86. void    DAPAllocateSession(DAPDATA *DAPid)
  87. {
  88.         ASReply *reply = (ASReply *)DAPid->dapReply.data;
  89.         DIAG4("Inside AllocateSession DAP");
  90.         //
  91.         //  Initialize the application control structure
  92.         //
  93.         memset(DAPGetApplDataAreaPtr(DAPid),'\0',sizeof DAPGetApplDataStructure(DAPid));
  94.         //
  95.         //  The DAPEnqueueServiceRequest updates the sessionID in the
  96.         //  request packet when a new slot is allocated.  We need to 
  97.         //  give this to the client for subsequent requests.
  98.         //
  99.         reply->sessionID = DAPid->dapRequest.sessionID;
  100.         //
  101.         //  Set the DAP return code
  102.         //
  103.         DAPid->dapReply.returnCode = 0;
  104.         //
  105.         //  Update the TotalLoginRequests Statistic, but only if the client
  106.         //  has not previously logged in successfully.  This keeps us from
  107.         //  recounting a retry, if the client never received our reply to 
  108.         //  the first request.
  109.         //
  110.         if( !DAPStateActive(DAPid,DAP_CLIENTLOGIN) ){
  111.             DAPStateON(DAPid,DAP_CLIENTLOGIN);
  112.             DAPIncLoginRequests();
  113.         }
  114.         //
  115.         //  Now send the result to the client
  116.         //
  117.         DAPEnqueueServiceReply(DAPid);
  118. }
  119.  
  120. #endif  // !defined(ENGINE)
  121.