FreeWRL / FreeX3D 4.3.0
EAI_C.h
1
2/****************************************************************************
3 This file is part of the FreeWRL/FreeX3D Distribution.
4
5 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
6
7 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
19****************************************************************************/
20
21
22
23#ifndef __EAI_C_HEADERS__
24#define __EAI_C_HEADERS__
25
26#ifdef WIN32
27 #ifndef WIN32_LEAN_AND_MEAN
28 #define WIN32_LEAN_AND_MEAN
29 #endif
30 #define strdup _strdup
31 #include <winsock2.h>
32 #include <ws2tcpip.h> /* for TCPIP - are we using tcp? */
33 #include <windows.h>
34 #define snprintf _snprintf
35 //#define sscanf sscanf_s
36 #define STRTOK_S strtok_s
37#else
38 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <netdb.h>
41 #define STRTOK_S strtok_r
42#endif
43
44/* copied from ../CFuncs/ */
45typedef size_t indexT;
46#define ARR_SIZE(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
47
48#include "EAIHeaders.h"
49#include "SCKHeaders.h"
50
51#ifdef HAVE_UNISTD_H
52 #include <unistd.h>
53#endif
54#include <stdio.h>
55
56#ifdef HAVE_STRINGS_H
57 #include <strings.h>
58#endif
59
60#include <string.h>
61#include <stdlib.h>
62#include <ctype.h>
63
64#include <math.h>
65#include <stddef.h>
66
67#include "X3DNode.h"
68
69#include "GeneratedHeaders.h"
70
71#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
72#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
73
74/* Table of built-in fieldIds */
75extern const char *FIELDTYPES[];
76extern const indexT FIELDTYPES_COUNT;
77
78
79/* definitions to help scanning values in from a string */
80#define SCANTONUMBER(value) while ((*value==' ') || (*value==',')) value++;
81#define SCANTOSTRING(value) while ((*value==' ') || (*value==',')) value++;
82#define SCANPASTFLOATNUMBER(value) while (isdigit(*value) \
83 || (*value == '.') || \
84 (*value == 'E') || (*value == 'e') || (*value == '-')) value++;
85#define SCANPASTINTNUMBER(value) if (isdigit(*value) || (*value == '-')) value++; \
86 while (isdigit(*value) || \
87 (*value == 'x') || (*value == 'X') ||\
88 ((*value >='a') && (*value <='f')) || \
89 ((*value >='A') && (*value <='F')) || \
90 (*value == '-')) value++;
91
92/*cstruct*/
93struct Multi_Float { size_t n; float *p; };
94struct SFRotation { float r[4]; };
95struct Multi_Rotation { size_t n; struct SFRotation *p; };
96
97struct Multi_Vec3f { size_t n; struct SFColor *p; };
98/*cstruct*/
99struct Multi_Bool { size_t n; int *p; };
100/*cstruct*/
101struct Multi_Int32 { size_t n; int *p; };
102
103struct Multi_Node { size_t n; void * *p; };
104struct SFColor { float c[3]; };
105struct Multi_Color { size_t n; struct SFColor *p; };
106struct SFColorRGBA { float r[4]; };
107struct Multi_ColorRGBA { size_t n; struct SFColorRGBA *p; };
108/*cstruct*/
109struct Multi_Time { size_t n; double *p; };
110/*cstruct*/
111struct Multi_String { size_t n; struct Uni_String * *p; };
112struct SFVec2f { float c[2]; };
113struct Multi_Vec2f { size_t n; struct SFVec2f *p; };
114/*cstruct*/
115/*cstruct*/
116struct SFVec3d { double c[3]; };
117struct Multi_Vec3d { size_t n; struct SFVec3d *p; };
118/*cstruct*/
119struct Multi_Double { size_t n; double *p; };
120struct SFMatrix3f { float c[9]; };
121struct Multi_Matrix3f { size_t n; struct SFMatrix3f *p; };
122struct SFMatrix3d { double c[9]; };
123struct Multi_Matrix3d { size_t n; struct SFMatrix3d *p; };
124struct SFMatrix4f { float c[16]; };
125struct Multi_Matrix4f { size_t n; struct SFMatrix4f *p; };
126struct SFMatrix4d { double c[16]; };
127struct Multi_Matrix4d { size_t n; struct SFMatrix4d *p; };
128struct SFVec2d { double c[2]; };
129struct Multi_Vec2d { size_t n; struct SFVec2d *p; };
130struct SFVec4f { float c[4]; };
131struct Multi_Vec4f { size_t n; struct SFVec4f *p; };
132struct SFVec4d { double c[4]; };
133struct Multi_Vec4d { size_t n; struct SFVec4d *p; };
134
135/*cstruct*/
136/*cstruct*/
137
138struct Uni_String {
139 size_t len;
140 char * strptr;
141 int touched;
142};
143
144
145#define FREE_IF_NZ(a) if(a) {free(a); a = 0;}
146#endif