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

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      dap001.c                                              ║
  4. //   ║ abstract:    This module contains the locate server API.           ║
  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/24/92    kl   initial release.                           ║
  26. //   ║  002   07/14/92    kl   windows port.                              ║
  27. //   ╚════════════════════════════════════════════════════════════════════╝
  28.  
  29. #include <stdio.h>
  30. #include <string.h>
  31. #include <malloc.h>
  32. #if defined(WINCLIENT)
  33.     #include <windows.h>
  34. #endif
  35. #include "cp/cpapi.h"
  36. #include "dap/dapsys.h"
  37.  
  38. DAPDATA *DAPInitialize(char *serverName, WORD serverType)
  39. {
  40.         long    oid = -1L;
  41.         char    x;
  42.         WORD    type;
  43.     #if !defined(DYNAMICMEM)
  44.         static  DAPDATA __dapData;
  45.         DAPDATA *DAPid = &__dapData;
  46.     #else
  47.         DAPDATA *DAPid;
  48.         if( (DAPid = (DAPDATA *)calloc(1,sizeof *DAPid)) == NULL )
  49.             return NULL;
  50.     #endif
  51.  
  52.         if( ScanBinderyObject(serverName,serverType,&oid,DAPid->serverName,&type,&x,&x,&x) )
  53.             return NULL;
  54.         else if( (DAPid->CPid = CPInitialize(DAPid->serverName,serverType)) == NULL)
  55.             return NULL;
  56.         //
  57.         //  Initialize the retry counts and delay variables to be used
  58.         //  as the default for this session.
  59.         //
  60.         DAPid->retryCount    = DEFRETRYCOUNT;        // 2
  61.         DAPid->responseDelay = DEFRESPONSEDELAY;     // 18
  62.         DAPid->nextSequence  = DEFSEQUENCENUMBER;    // 0
  63.  
  64.         return DAPid;
  65. }
  66.  
  67. void    DAPDeInitialize(DAPDATA *DAPid)
  68. {
  69.         CPDeInitialize(DAPid->CPid);
  70.         memset(DAPid,NULL,sizeof *DAPid);
  71.     #if defined(DYNAMICMEM)
  72.         free(DAPid);
  73.     #endif
  74. }
  75.  
  76. UINT16  DAPGetNumRetries(DAPDATA *DAPid){ return DAPid->timesTried; }
  77. UINT16  DAPGetNumSendErr(DAPDATA *DAPid){ return DAPid->sendFailed; }
  78.  
  79. #if defined(DEBUG)
  80.  
  81. //
  82. //  The following API is used to debug the client.  It will save out the
  83. //  current state of both the DAP and CP Layers to a file.
  84. //
  85.  
  86. void    DAPDisplaySessionData(DAPDATA *DAPid)
  87. {
  88.         FILE    *f;
  89.         char    name[20];
  90.  
  91.         sprintf(name,"DIAG%03d.DAP",GetConnectionNumber());
  92.         if((f=fopen(name,"wt")) == NULL) return;
  93.  
  94.         if( !DAPid ) return;
  95.         fprintf(f,"\n\tDAPid is (%p)\n",DAPid);
  96.         fprintf(f,"\t\tsessionID is %lx\n",DAPid->sessionID);
  97.         fprintf(f,"\t\tretryCount is %x\n",DAPid->retryCount);
  98.         fprintf(f,"\t\tresponseDelay is %x\n",DAPid->responseDelay);
  99.         fprintf(f,"\t\tServer name is '%s'\n",DAPid->serverName);
  100.         fprintf(f,"\t\tNext sequence number is %lx\n",DAPid->nextSequence);
  101.         fprintf(f,"\n\t\tDAPRequest\n");
  102.         fprintf(f,"\t\t\tpacketType is %x\n",DAPid->dapRequest.packetType);
  103.         fprintf(f,"\t\t\tsequence is %lx\n",DAPid->dapRequest.sequence);
  104.         fprintf(f,"\t\t\tsessionID is %lx\n",DAPid->dapRequest.sessionID);
  105.         fprintf(f,"\t\t\trequestCode is %x\n",DAPid->dapRequest.requestCode);
  106.         fprintf(f,"\n\t\tDAPReply\n");
  107.         fprintf(f,"\t\t\tpacketType is %x\n",DAPid->dapReply.packetType);
  108.         fprintf(f,"\t\t\tsequence is %lx\n",DAPid->dapReply.sequence);
  109.         fprintf(f,"\t\t\treturn code is %x\n",DAPid->dapReply.returnCode);
  110.         CPDisplaySessionData(f,DAPid->CPid);
  111. }
  112.  
  113. #endif  //  defined(DEBUG)
  114.