2507a4f6a3a0a546a0e1ae5352439889e14269c4
[oweals/cde.git] / cde / lib / tt / lib / util / tt_int_rec.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 //%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                  
24 //%%  (c) Copyright 1993, 1994 International Business Machines Corp.    
25 //%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                   
26 //%%  (c) Copyright 1993, 1994 Novell, Inc.                             
27 //%%  $XConsortium: tt_int_rec.C /main/3 1995/10/23 10:40:21 rswiston $                                                         
28 /*
29  *
30  * tt_int_rec.cc
31  *
32  * Copyright (c) 1990 by Sun Microsystems, Inc.
33  */
34 #include "util/tt_int_rec.h"
35 #include "util/tt_iostream.h"
36 #if defined(ultrix)
37 #include <rpc/types.h>
38 #endif
39
40 _Tt_int_rec::
41 _Tt_int_rec()
42 {
43         val = 0;
44 }
45
46
47 _Tt_int_rec::
48 _Tt_int_rec(int v)
49 {
50         val = v;
51 }
52
53
54 _Tt_int_rec::
55 ~_Tt_int_rec()
56 {
57 }
58
59
60
61 void _Tt_int_rec::
62 print(const _Tt_ostream &os) const
63 {
64         os << val;
65 }
66
67
68 bool_t _Tt_int_rec::
69 xdr(XDR *xdrs)
70 {
71         return(xdr_int(xdrs, &val));
72 }
73
74 implement_list_of(_Tt_int_rec)
75
76 _Tt_pid_t_rec::
77 _Tt_pid_t_rec()
78 {
79         val = 0;
80 }
81
82
83 _Tt_pid_t_rec::
84 _Tt_pid_t_rec(pid_t v)
85 {
86         val = v;
87 }
88
89
90 _Tt_pid_t_rec::
91 ~_Tt_pid_t_rec()
92 {
93 }
94
95
96
97 void _Tt_pid_t_rec::
98 print(const _Tt_ostream &os) const
99 {
100         os << val;
101 }
102
103
104 bool_t _Tt_pid_t_rec::
105 xdr(XDR *xdrs)
106 {
107         long tv;
108         bool_t result;
109
110         // Some systems have pid_t an int, some have it a long, probably
111         // some have it a short.  We XDR them all as longs.  I don't even
112         // want to think about 64-bit pid_ts...
113
114         if (xdrs->x_op == XDR_ENCODE) {
115                 tv = (long)val;
116         }
117         if (!(result = xdr_long(xdrs, &tv))) {
118                 return result;
119         }
120         if (xdrs->x_op == XDR_DECODE) {
121                 val = (pid_t)tv;
122         }
123         return result;
124 }
125
126 implement_list_of(_Tt_pid_t_rec)