00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef lint
00040 static const char libbu_htond_RCSid[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/libbu/htonf.c,v 14.13 2006/09/03 15:14:07 lbutler Exp $ (BRL)";
00041 #endif
00042
00043 #include "common.h"
00044
00045
00046 #include <stdio.h>
00047 #include "machine.h"
00048 #include "bu.h"
00049
00050 #ifdef HAVE_MEMORY_H
00051 # include <memory.h>
00052 #endif
00053 #include <stdio.h>
00054
00055
00056
00057
00058
00059
00060 void
00061 htonf(register unsigned char *out, register const unsigned char *in, int count)
00062 {
00063 #if defined(NATURAL_IEEE)
00064
00065
00066
00067
00068
00069 # ifdef HAVE_MEMORY_H
00070 memcpy( out, in, count*SIZEOF_NETWORK_FLOAT );
00071 # else
00072 bcopy( in, out, count*SIZEOF_NETWORK_FLOAT );
00073 # endif
00074 return;
00075 # define HTONF yes1
00076 #endif
00077
00078 #if defined(REVERSE_IEEE)
00079
00080 register int i;
00081 for( i=count-1; i >= 0; i-- ) {
00082 *out++ = in[3];
00083 *out++ = in[2];
00084 *out++ = in[1];
00085 *out++ = in[0];
00086 in += SIZEOF_NETWORK_FLOAT;
00087 }
00088 return;
00089 # define HTONF yes2
00090 #endif
00091
00092
00093
00094 #ifndef HTONF
00095 # include "ntohf.c: ERROR, no NtoHD conversion for this machine type"
00096 #endif
00097 }
00098
00099
00100
00101
00102
00103
00104
00105 void
00106 ntohf(register unsigned char *out, register const unsigned char *in, int count)
00107 {
00108 #ifdef NATURAL_IEEE
00109
00110
00111
00112
00113
00114 if( sizeof(float) != SIZEOF_NETWORK_FLOAT )
00115 bu_bomb("ntohf: sizeof(float) != SIZEOF_NETWORK_FLOAT\n");
00116 # ifdef HAVE_MEMORY_H
00117 memcpy( out, in, count*SIZEOF_NETWORK_FLOAT );
00118 # else
00119 bcopy( in, out, count*SIZEOF_NETWORK_FLOAT );
00120 # endif
00121 return;
00122 # define NTOHF yes1
00123 #endif
00124 #if defined(REVERSE_IEEE)
00125
00126 register int i;
00127 for( i=count-1; i >= 0; i-- ) {
00128 *out++ = in[3];
00129 *out++ = in[2];
00130 *out++ = in[1];
00131 *out++ = in[0];
00132 in += SIZEOF_NETWORK_FLOAT;
00133 }
00134 return;
00135 # define NTOHF yes2
00136 #endif
00137
00138 #ifndef NTOHF
00139 # include "ntohf.c: ERROR, no NtoHD conversion for this machine type"
00140 #endif
00141 }
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151