23 #include "xabsl_tools.h" 25 #include <core/exception.h> 26 #include <utils/logging/logger.h> 62 __logger->
log_info(
"XABSL",
"%s", text);
76 __filename = strdup(filename);
96 __f = fopen(__filename,
"r");
105 if ( __f ) fclose(__f);
117 if (read_from_file(buf,
sizeof(buf)-1)) {
135 return read_from_file(buf, buf_length);
141 XabslFileInputSource::omit_comment()
143 while ( !feof(__f) ) {
145 if (fread(&c, 1, 1, __f)) {
146 if ( c ==
'\n')
return;
158 XabslFileInputSource::read_and_omit_whitespace(
bool omit_whitespace)
160 while ( ! feof(__f) ) {
162 if (fread(&c, 1, 1, __f)) {
167 if ( (c !=
' ') && (c !=
'\n') && (c !=
'\r') && (c !=
'\t') ) {
169 }
else if ( ! omit_whitespace ) {
173 throw fawkes::Exception (
"XabslFileInputSource: omit_whitespace() fread failed");
188 XabslFileInputSource::read_from_file(
char *buf,
size_t buf_length)
190 if ( ! __f || feof(__f) )
return false;
192 memset(buf, 0, buf_length);
193 size_t cur_length = 0;
194 bool is_first =
true;
195 while (! feof(__f) && (cur_length < buf_length)) {
196 char c = read_and_omit_whitespace(is_first);
199 buf[cur_length++] = c;
202 return (cur_length > 0);
206 return (cur_length > 0);
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
virtual void printError(const char *text)
Print error message.
virtual void printMessage(const char *text)
Print info message.
Base class for exceptions in Fawkes.
XabslLoggingErrorHandler(fawkes::Logger *logger)
Constructor.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.