18 int byte = fgetc(file);
20 return (
unsigned int)byte;
42 return fgetc(in_file);
51 assert (fclose(file) == 0);
70 double fraction = (double)1.0;
71 bool have_decimal_point = (bool)0;
72 bool negative = (bool)0;
73 double result = (double)0.0;
76 if (isdigit(character)) {
77 if (have_decimal_point) {
78 fraction /= (double)10.0;
79 result += fraction * (double)(character -
'0');
81 result = result * 10.0 + (double)(character -
'0');
83 }
else if (character ==
'"') {
85 }
else if (character ==
'.') {
86 have_decimal_point = (bool)1;
87 }
else if (character ==
'-') {
109 va_list variadic_arguments;
110 va_start(variadic_arguments, format);
113 unsigned int formatted_size = vfprintf(file, format, variadic_arguments);
132 float fraction = (float)1.0;
133 bool have_decimal_point = (bool)0;
134 bool negative = (bool)0;
135 float result = (float)0.0;
138 if (isdigit(character)) {
139 if (have_decimal_point) {
140 fraction /= (float)10.0;
141 result += fraction * (float)(character -
'0');
143 result = result * 10.0 + (float)(character -
'0');
145 }
else if (character ==
'"') {
147 }
else if (character ==
'.') {
148 have_decimal_point = (bool)1;
149 }
else if (character ==
'-') {
188 bool negative = (bool)0;
192 if (isdigit(character)) {
193 result = result * 10 + (character -
'0');
194 }
else if (character ==
'"') {
196 }
else if (character ==
'-') {
216 int low_byte = fgetc(file);
217 assert (low_byte >= 0);
218 int high_byte = fgetc(file);
219 assert (high_byte >= 0);
220 unsigned int result = ((
unsigned int)high_byte << 8) | (
unsigned int)low_byte;
232 fputc(xshort & 0xff, file);
233 fputc((xshort >> 8) & 0xff, file);
244 return fopen(file_name, flags);
259 assert(character == pattern[
index]);
275 if (character ==
'<') {
277 }
else if (character ==
' ') {
void File__byte_write(File file, unsigned int byte)
Write byte ot file.
void File__close(File file)
Closes file.
unsigned int File__little_endian_short_read(File file)
Read a little endian short (16-bits) from file.
double File__double_attribute_read(File in_file, String_Const attribute_name)
Reads in an XML attribute with a floating point value.
FILE * File
FILE is a file I/O object.
void File__string_match(File in_file, String_Const pattern)
Exactly matches pattern read from in_file.
void File__flush(File file)
Flushes file content out of internal buffers.
int File__integer_attribute_read(File in_file, String_Const attribute_name)
Reads in an XML attribute with a integer value.
void File__little_endian_short_write(File file, unsigned int xshort)
Write 16-bit xshort to file in little endian format.
void File__format(File file, String_Const format,...)
will write format out to file with all patterns that start with "%" replaced by formatted versions of...
unsigned int File__byte_read(File file)
Read a byte from file.
float File__float_attribute_read(File in_file, String_Const attribute_name)
Reads in an XML attribute with a floating point value.
File File__open(String_Const file_name, String_Const flags)
will open file_name using flags to specify read/write options.
int File__character_read(File in_file)
Return the next character read from in_file.
void File__tag_match(File in_file, String_Const tag_name)
Matchs and "XML" start tag.
const char * String_Const
unsigned int String__size(String_Const string)
Returns the size of string.