FreeWRL/FreeX3D
3.0.0
Main Page
Related Pages
Data Structures
Files
File List
InputFunctions.c
1
/*
2
3
FreeWRL support library.
4
Input functions (EAI, mouse, keyboard, ...).
5
6
*/
7
8
/****************************************************************************
9
This file is part of the FreeWRL/FreeX3D Distribution.
10
11
Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12
13
FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14
it under the terms of the GNU Lesser Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25
****************************************************************************/
26
27
28
29
#include <config.h>
30
#include <system.h>
31
#include <display.h>
32
#include <internal.h>
33
#include <pthread.h>
34
35
#include <libFreeWRL.h>
36
37
#include <io_files.h>
38
#include <threads.h>
39
40
#include "../vrml_parser/Structs.h"
41
#include "../main/headers.h"
42
#include "../scenegraph/Vector.h"
43
44
#include "InputFunctions.h"
45
46
#define DJ_KEEP_COMPILER_WARNING 0
47
#if DJ_KEEP_COMPILER_WARNING
48
#define READSIZE 2048
49
#endif
50
51
char
* stripLocalFileName (
char
* origName)
52
{
53
if
(!origName)
54
return
NULL;
55
56
/* remove whitespace, etc */
57
while
((*origName !=
'\0'
) && (*origName <=
' '
)) origName++;
58
59
#if defined (_MSC_VER)
60
if
((strncmp(origName,
"file:///"
, strlen(
"file:///"
))== 0))
// MS windows: file:///C:/source2/freewrl/freex3d/projectfiles_vc9/testAx/1.x3d
61
origName += strlen (
"file:///"
);
62
#endif //_MSC_VER
63
64
65
if
((strncmp(origName,
"file://"
, strlen(
"file://"
))== 0) ||
66
(strncmp(origName,
"FILE://"
, strlen(
"FILE://"
))== 0)) {
67
origName += strlen (
"FILE://"
);
68
return
origName;
69
}
70
return
origName;
71
}
72
73
#if !defined(_ANDROID)
74
char
* makeFontDirectory()
75
{
76
char
*tmp;
77
78
/* If environment variable is defined
79
then it prevails */
80
tmp = getenv(
"FREEWRL_FONTS_DIR"
);
81
82
/* Get dir from configuration */
83
if
(!tmp) {
84
tmp = FONTS_DIR;
85
}
86
87
/* Check if dir exists */
88
if
(do_dir_exists(tmp)) {
89
/* do not return directory the string
90
as it may be static, but make a copy */
91
return
STRDUP(tmp);
92
}
93
94
/* No directory found */
95
return
NULL;
96
}
97
#endif //ANDROID
98
99
/* sscanf replacements */
100
void
scanUnsignedIntoValue(
char
*sp,
size_t
*rv) {
101
*rv = 0;
102
103
/* skip leading spaces, if there are any */
104
while
((*sp <=
' '
) && (*sp !=
'\0'
)) sp++;
105
while
((*sp >=
'0'
) && (*sp <=
'9'
)) {
106
*rv *= 10; *rv += (int) (*sp -
'0'
); sp++;
107
}
108
}
109
src
lib
input
InputFunctions.c
Generated on Thu Dec 14 2017 12:14:40 for FreeWRL/FreeX3D by
1.8.6