home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / mnl-rpc++-2.3.1 / part01 / request.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-24  |  4.6 KB  |  181 lines

  1. // -*- c++ -*-
  2. /* 
  3. Copyright (C) 1991 Peter Bersen
  4.  
  5. This file is part of the rpc++ Library.  This library is free
  6. software; you can redistribute it and/or modify it under the terms of
  7. the GNU Library General Public License as published by the Free
  8. Software Foundation; either version 2 of the License, or (at your
  9. option) any later version.  This library is distributed in the hope
  10. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  11. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12. PURPOSE.  See the GNU Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  
  17. Modified and partially rewritten March 1992 by Michael N. Lipp,
  18. mnl@dtro.e-technik.th-darmstadt.de. The original copyright terms and
  19. conditions apply without change to any modified or new parts.
  20. */
  21.  
  22. static char _rpcpp_request_cc_[]
  23. = "request.cc,v 2.4 1992/08/08 13:11:40 mnl Exp";
  24.  
  25. // request.cc,v
  26. // Revision 2.4  1992/08/08  13:11:40  mnl
  27. // RpcRequest(const RpcRequest&) added, 'cause RpcRequest has pointers
  28. // to heap.
  29. //
  30. // Revision 2.3  1992/06/15  19:12:39  mnl
  31. // Fixed a few bugs, clarified interface.
  32. //
  33. // Revision 2.2  1992/06/13  14:27:01  mnl
  34. // Adapted to (patched) gcc-2.2. Fixed several bugs.
  35. //
  36. // Revision 2.1.1.1  1992/03/08  13:28:42  mnl
  37. // Initial mnl version.
  38. //
  39.  
  40. #ifdef __GNUG__
  41. #pragma implementation
  42. #endif
  43.  
  44. #include "rpc++/request.h"
  45.  
  46. #include <assert.h>
  47.  
  48. void RpcRequest::init (u_long req, int pars, int parsz,
  49.                const XdrInfo* out, const XdrInfo** in, int rt)
  50. {
  51.   params = pars;
  52.   parmsz = parsz;
  53.   reqnum = req;
  54.   ininfo = in;
  55.   ininfo[params] = (XdrInfo*)0;
  56.   outinfo = out;
  57.   reqtype = rt;
  58.   assert (rt == normal || outinfo->Proc () == 0);
  59. }
  60.  
  61. RpcRequest::RpcRequest (const RpcRequest& r)
  62. {
  63.   params = r.params;
  64.   parmsz = r.parmsz;
  65.   reqnum = r.reqnum;
  66.   ininfo = new XdrInfo*[params + 1];
  67.   memcpy (ininfo, r.ininfo, (params + 1) * sizeof (XdrInfo*));
  68.   outinfo = r.outinfo;
  69.   reqtype = r.reqtype;
  70. }
  71.   
  72. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, int t)
  73. {
  74.   init (req, 0, 0, out, new XdrInfo*[1], t);
  75. }
  76.  
  77. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo* in,
  78.                int t)
  79. {
  80.   const XdrInfo** a = new XdrInfo*[2];
  81.   a[0] = in;
  82.   init (req, 1, -1, out, a, t);
  83. }
  84.  
  85. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo* in0,
  86.                const XdrInfo* in1, int t)
  87. {
  88.   const XdrInfo** a = new XdrInfo*[3];
  89.   a[0] = in0;
  90.   a[1] = in1;
  91.   init (req, 2, -1, out, a, t);
  92. }
  93.  
  94. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo* in0,
  95.                const XdrInfo* in1, const XdrInfo* in2, int t)
  96. {
  97.   const XdrInfo** a = new XdrInfo*[4];
  98.   a[0] = in0;
  99.   a[1] = in1;
  100.   a[2] = in2;
  101.   init (req, 3, -1, out, a, t);
  102. }
  103.  
  104. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo* in0,
  105.                const XdrInfo* in1, const XdrInfo* in2,
  106.                const XdrInfo* in3, int t)
  107. {
  108.   const XdrInfo** a = new XdrInfo*[5];
  109.   a[0] = in0;
  110.   a[1] = in1;
  111.   a[2] = in2;
  112.   a[3] = in3;
  113.   init (req, 4, -1, out, a, t);
  114. }
  115.  
  116. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo* in0,
  117.                const XdrInfo* in1, const XdrInfo* in2,
  118.                const XdrInfo* in3, const XdrInfo* in4, int t)
  119. {
  120.   const XdrInfo** a = new XdrInfo*[6];
  121.   a[0] = in0;
  122.   a[1] = in1;
  123.   a[2] = in2;
  124.   a[3] = in3;
  125.   a[4] = in4;
  126.   init (req, 5, -1, out, a, t);
  127. }
  128.  
  129. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo* in0,
  130.                const XdrInfo* in1, const XdrInfo* in2,
  131.                const XdrInfo* in3, const XdrInfo* in4,
  132.                const XdrInfo* in5, int t)
  133. {
  134.   const XdrInfo** a = new XdrInfo*[7];
  135.   a[0] = in0;
  136.   a[1] = in1;
  137.   a[2] = in2;
  138.   a[3] = in3;
  139.   a[4] = in4;
  140.   a[5] = in5;
  141.   init (req, 6, -1, out, a, t);
  142. }
  143.  
  144. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo* in0,
  145.                const XdrInfo* in1, const XdrInfo* in2,
  146.                const XdrInfo* in3, const XdrInfo* in4,
  147.                const XdrInfo* in5, const XdrInfo *in6, int t)
  148. {
  149.   const XdrInfo** a = new XdrInfo*[8];
  150.   a[0] = in0;
  151.   a[1] = in1;
  152.   a[2] = in2;
  153.   a[3] = in3;
  154.   a[4] = in4;
  155.   a[5] = in5;
  156.   a[6] = in6;
  157.   init (req, 7, -1, out, a, t);
  158. }
  159.  
  160. RpcRequest::RpcRequest(u_long req, const XdrInfo* out, const XdrInfo** ins,
  161.                int t)
  162. {
  163.   int pars = 0;
  164.   for (XdrInfo** p = ins; *p; p++)
  165.     pars += 1;
  166.   const XdrInfo** a = new XdrInfo* [pars + 1];
  167.   memcpy (a, ins, (pars + 1) * sizeof (XdrInfo*));
  168.   init (req, pars, -1, out, a, t);
  169. }
  170.  
  171. int RpcRequest::ParamSize ()
  172. {
  173.   if (parmsz < 0) // not yet calculated
  174.     {
  175.       parmsz = 0;
  176.       for (XdrInfo** ip = ininfo; *ip; ip++)
  177.     parmsz += (*ip)->Size ();
  178.     }
  179.   return parmsz;
  180. }
  181.