Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSearch / raima / dbswab.h
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 librararies 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 /*
24  *   COMPONENT_NAME: austext
25  *
26  *   FUNCTIONS: HTONL
27  *              HTONS
28  *              NTOHL
29  *              NTOHS
30  *              SWABDIR
31  *              htonl
32  *              htons
33  *              ntohl
34  *              ntohs
35  *
36  *   ORIGINS: 27
37  *
38  *
39  *   (C) COPYRIGHT International Business Machines Corp. 1996
40  *   All Rights Reserved
41  *   Licensed Materials - Property of IBM
42  *   US Government Users Restricted Rights - Use, duplication or
43  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
44  */
45 /********************* DBSWAB.H **********************************
46  * $XConsortium: dbswab.h /main/2 1996/10/28 14:00:06 drk $
47  * July 1996.
48  * Header file for all internal vista byte swap modifications.
49  * The mods byte swap vista cache pages, dbd tables, etc,
50  * to ensure that database files are maintained in a canonical
51  * format no matter what machine they are used on.
52  * The DtSearch data records are byte swapped in code at the
53  * DtSearch level (dtsrswab.c, defns in SearchP.h).
54  * Byte swap is performed with the standard htonl, htons, ntohl,
55  * and ntohs network conversion functions for byte order neutrality.
56  * Canonical integer length is enforced with the typedefs
57  * LONG and INT in vista.h
58  * The external database files are in big-endian ("network") order.
59  * So that they can be defined as "null" macros on big endian machines,
60  * new functions (1) always byte swap in place, and (2) always succeed.
61  *
62  * An #include "vista.h" and #include "dbtype.h" must precede this include.
63  *
64  * $Log$
65  */
66 #ifndef _H_DBSWAB
67 #define _H_DBSWAB
68
69 #include <sys/types.h>
70 #include <netinet/in.h>
71
72 /* Record number for OR_MISCREC DtSearch record */
73 #define MISCREC_RECNO   3
74
75 /* Direction of io to indicate correct byte swap function.
76  * HTON is host to network, internal RAM to external database file.
77  * NTOH is network to host, file to RAM.
78  */
79 typedef enum {HTON=1, NTOH} SWABDIR;
80
81 extern void     swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction);
82
83 #ifdef BYTE_SWAP  /* ie (BYTE_ORDER != BIG_ENDIAN) */
84
85 #define HTONL(x)        x = htonl(x)
86 #define HTONS(x)        x = htons(x)
87 #define NTOHL(x)        x = ntohl(x)
88 #define NTOHS(x)        x = ntohs(x)
89
90 #else   /* !BYTE_SWAP, ie (BYTE_ORDER == BIG_ENDIAN) */
91
92 #define HTONL(x)
93 #define HTONS(x)
94 #define NTOHL(x)
95 #define NTOHS(x)
96
97 #endif  /* BYTE_SWAP */
98
99 /******** debug stuff *******/
100 extern char     *debug_keyslot_ptr;
101 extern void     snap_dump (char *label, void *ptr, int len);
102
103 /********************* DBSWAB.H **********************************/
104 #endif  /* _H_DBSWAB */