2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
24 * COMPONENT_NAME: austext
26 * FUNCTIONS: swab_dbrec
31 * (C) COPYRIGHT International Business Machines Corp. 1996
33 * Licensed Materials - Property of IBM
34 * US Government Users Restricted Rights - Use, duplication or
35 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
37 /********************* DTSRSWAB.C **********************************
38 * $XConsortium: dtsrswab.c /main/2 1996/10/28 13:58:11 drk $
40 * These functions byte swap and other manipulations on
41 * DtSearch or_... structures to ensure that database records
42 * are maintained in a canonical format no matter what machine
44 * The functions use the standard htonl, htons, ntohl, and ntohs
45 * network conversion functions for byte order neutrality.
46 * They use the DtSrINT16 and DtSrINT32 typedefs in Search.h
47 * to control integer size.
48 * The external database records are in the canonical,
49 * big-endian "network" order.
50 * So that they can be defined as "null" macros on big endian machines,
51 * the functions (1) always byte swap in place and (2) always succeed.
57 /********************************/
61 /********************************/
62 void swab_objrec (struct or_objrec *rec, SWABDIR direction)
67 if (direction == NTOH) {
68 NTOHL (rec->or_objflags);
69 NTOHL (rec->or_objuflags);
70 NTOHL (rec->or_objsize);
71 NTOHL (rec->or_objdate);
72 NTOHL (rec->or_objsecmask);
74 NTOHS (rec->or_objaccess);
75 NTOHS (rec->or_objtype);
76 NTOHS (rec->or_objcost);
77 NTOHS (rec->or_objhdroffset);
78 NTOHS (rec->or_objeureka);
80 else { /* going the other direction */
81 HTONL (rec->or_objflags);
82 HTONL (rec->or_objuflags);
83 HTONL (rec->or_objsize);
84 HTONL (rec->or_objdate);
85 HTONL (rec->or_objsecmask);
87 HTONS (rec->or_objaccess);
88 HTONS (rec->or_objtype);
89 HTONS (rec->or_objcost);
90 HTONS (rec->or_objhdroffset);
91 HTONS (rec->or_objeureka);
94 #endif /* BYTE_SWAP */
98 /********************************/
102 /********************************/
103 void swab_dbrec (struct or_dbrec *rec, SWABDIR direction)
108 if (direction == NTOH) {
109 NTOHL (rec->or_dbflags);
110 NTOHL (rec->or_dbuflags);
111 NTOHL (rec->or_reccount);
112 NTOHL (rec->or_maxdba);
113 NTOHL (rec->or_availd99);
114 NTOHL (rec->or_unavaild99);
115 NTOHL (rec->or_hufid);
116 NTOHL (rec->or_dbsecmask);
118 NTOHS (rec->or_dbotype);
119 NTOHS (rec->or_compflags);
120 NTOHS (rec->or_dbaccess);
121 NTOHS (rec->or_minwordsz);
122 NTOHS (rec->or_maxwordsz);
123 NTOHS (rec->or_recslots);
124 NTOHS (rec->or_fzkeysz);
125 NTOHS (rec->or_abstrsz);
126 NTOHS (rec->or_language);
129 else { /* going the other direction */
130 HTONL (rec->or_dbflags);
131 HTONL (rec->or_dbuflags);
132 HTONL (rec->or_reccount);
133 HTONL (rec->or_maxdba);
134 HTONL (rec->or_availd99);
135 HTONL (rec->or_unavaild99);
136 HTONL (rec->or_hufid);
137 HTONL (rec->or_dbsecmask);
139 HTONS (rec->or_dbotype);
140 HTONS (rec->or_compflags);
141 HTONS (rec->or_dbaccess);
142 HTONS (rec->or_minwordsz);
143 HTONS (rec->or_maxwordsz);
144 HTONS (rec->or_recslots);
145 HTONS (rec->or_fzkeysz);
146 HTONS (rec->or_abstrsz);
147 HTONS (rec->or_language);
150 #endif /* BYTE_SWAP */
153 /********************* DTSRSWAB.C **********************************/