BRL-CAD
endian.h
Go to the documentation of this file.
1 /* E N D I A N . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2024 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #ifndef BU_ENDIAN_H
22 #define BU_ENDIAN_H
23 
24 #include "common.h"
25 #include "bu/defines.h"
26 
27 __BEGIN_DECLS
28 
29 /** @addtogroup bu_endian
30  * @brief
31  * Run-time byte order detection.
32  *
33  */
34 /** @{ */
35 /** @file bu/endian.h */
36 
37 
38 typedef enum {
39  BU_LITTLE_ENDIAN = 1234, /**< LSB first: i386, VAX order */
40  BU_BIG_ENDIAN = 4321, /**< MSB first: 68000, IBM, network order */
41  BU_PDP_ENDIAN = 3412 /**< LSB first in word, MSW first in long */
43 
44 
45 /**
46  * returns the platform byte ordering (e.g., big-/little-endian)
47  */
48 BU_EXPORT extern bu_endian_t bu_byteorder(void);
49 
50 /** @} */
51 
52 
53 /**
54  * Get the current operating host's name. This is usually also the
55  * network name of the current host. The name is written into the
56  * provided hostname buffer of at least len size. The hostname is
57  * always null-terminated and should be sized accordingly.
58  */
59 BU_EXPORT extern int bu_gethostname(char *hostname, size_t len);
60 
61 
62 __END_DECLS
63 
64 #endif /* BU_ENDIAN_H */
65 
66 /*
67  * Local Variables:
68  * mode: C
69  * tab-width: 8
70  * indent-tabs-mode: t
71  * c-file-style: "stroustrup"
72  * End:
73  * ex: shiftwidth=4 tabstop=8
74  */
Header file for the BRL-CAD common definitions.
int bu_gethostname(char *hostname, size_t len)
bu_endian_t
Definition: endian.h:38
bu_endian_t bu_byteorder(void)
@ BU_LITTLE_ENDIAN
Definition: endian.h:39
@ BU_PDP_ENDIAN
Definition: endian.h:41
@ BU_BIG_ENDIAN
Definition: endian.h:40