JNR
Main Page
Modules
Class List
File List
utils.h
1
/*
2
3
Jump'n'Run Engine
4
http://www.atanaslaskov.com/jnr/
5
6
BSD LICENSE
7
Copyright (c) 2007-2013, Atanas Laskov
8
All rights reserved.
9
10
Redistribution and use in source and binary forms, with or without
11
modification, are permitted provided that the following conditions are met:
12
1. Redistributions of source code must retain the above copyright notice,
13
this list of conditions and the following disclaimer.
14
2. Redistributions in binary form must reproduce the above copyright notice,
15
this list of conditions and the following disclaimer in the documentation
16
and/or other materials provided with the distribution.
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
*/
29
31
32
34
35
#ifndef UTILS_H
36
#define UTILS_H
37
38
inline
void
Utline
(FILE* f,
char
*s)
39
{
40
int
c;
41
unsigned
i=0;
42
do
{
43
c = getc(f);
44
s[i++] = c;
45
}
while
( (c!=10) && (c!=13) );
46
s[i-1] =
'\0'
;
47
}
48
49
inline
void
UtGetStrUntil(FILE* f,
char
*s,
char
bc)
50
{
51
int
c;
52
unsigned
i=0;
53
do
{
54
c = getc(f);
55
s[i++] = c;
56
}
while
(c!=bc);
57
s[i-1] =
'\0'
;
58
}
59
60
inline
int
UtFlush(FILE* f)
61
{
62
int
c;
63
do
{
64
c = getc(f);
65
if
(c==EOF)
return
EOF;
66
}
while
( (c==10) || (c==13) || (c==
' '
) );
67
return
c;
68
}
69
70
inline
void
UtGetStrUntil2(FILE* f,
char
*s,
char
bc)
71
{
72
s[0] = UtFlush(f);
73
UtGetStrUntil(f,s+1,bc);
74
}
75
76
inline
int
UtGetIntUntil(FILE* f,
char
bc)
77
{
78
char
s[32];
79
int
d;
80
81
UtGetStrUntil2(f,s,bc);
82
sscanf(s,
"%d"
, &d);
83
84
return
d;
85
}
86
87
inline
float
UtGetFloatUntil(FILE* f,
char
bc)
88
{
89
char
s[32];
90
float
d;
91
92
UtGetStrUntil2(f,s,bc);
93
sscanf(s,
"%f"
, &d);
94
95
return
d;
96
}
97
98
#endif
99
Utline
void Utline(FILE *f, char *s)
File utility functions used in the UI classes.
Definition:
utils.h:38
Source
GUI
utils.h
Generated by
1.8.9.1