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

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      dap015.c                                              ║
  4. //   ║ abstract:    This module contains DAP request 1015                 ║
  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   02/21/92    kl   initial release.                           ║
  26. //   ╚════════════════════════════════════════════════════════════════════╝
  27.  
  28. #include    "dap/dapsys.h"
  29.  
  30. //
  31. //  The following are the request/reply structures for the divOperands
  32. //  DAP.
  33. //
  34.  
  35. typedef struct{                         // div operands request pkt
  36.         SINT32      operand1;           // operand1
  37.         SINT32      operand2;           // operand2
  38. }DORequest;
  39.  
  40. typedef struct{                         // div operands reply pkt
  41.         SINT32      result;             // the result
  42. }DOReply;
  43.  
  44. #if !defined(ENGINE)
  45.  
  46. //
  47. //  Following is the Client-Side API for divOperands
  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. //      op1       - the first operand to div
  53. //      op2       - the second operand to div
  54. //
  55.  
  56. T_RC    DAPDivideOperands(DAPDATA *DAPid,long op1, long op2, long *result)
  57. {
  58.         T_RC        rc;
  59.         DORequest   *request = (DORequest *)DAPid->dapRequest.data;
  60.         DOReply     *reply   = (DOReply *)DAPid->dapReply.data;
  61.         //
  62.         //  fill in the request structure
  63.         //
  64.         request->operand1 = op1;
  65.         request->operand2 = op2;
  66.         //
  67.         //  Send the request
  68.         //
  69.         if( (rc = DAPSendRequest(DAPid,DAPDIVIDEOPERANDS)) == 0){
  70.             //
  71.             //  Copy result 
  72.             //
  73.             *result = reply->result;
  74.         }
  75.         return rc;
  76. }
  77.  
  78. #else   // !defined(ENGINE)
  79.  
  80. //
  81. //  Following is the Server-Side API for divOperands
  82. //
  83.  
  84. void    DAPDivideOperands(DAPDATA *DAPid)
  85. {
  86.         DORequest *request = (DORequest *)DAPid->dapRequest.data;
  87.         DOReply *reply = (DOReply *)DAPid->dapReply.data;
  88.  
  89.         DIAG4("Inside DivideOperands DAP");
  90.         //
  91.         //  Do the work
  92.         //
  93.         if( request->operand2 != 0 ){
  94.             reply->result = request->operand1 / request->operand2;
  95.             DAPid->dapReply.returnCode = DAP_SUCCESS;
  96.         }
  97.         else{
  98.             reply->result = 0;
  99.             DAPid->dapReply.returnCode = DAP_DIVIDE_BY_ZERO;
  100.         }
  101.         //
  102.         //  Now send the result to the client
  103.         //
  104.         DAPEnqueueServiceReply(DAPid);
  105. }
  106.  
  107. #endif  // !defined(ENGINE)
  108.