![]() |
Crossfire Server, Trunk
1.75.0
|
Include dependency graph for bufferreader.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| BufferReader * | bufferreader_create () |
| Create a new BufferReader. More... | |
| size_t | bufferreader_current_line (BufferReader *br) |
| Return the index of the last line returned by bufferreader_next_line(). More... | |
| char * | bufferreader_data (BufferReader *br) |
| Get the whole buffer, independently of the calls to bufferreader_next_line(). More... | |
| size_t | bufferreader_data_length (BufferReader *br) |
| Return the length of the buffer data. More... | |
| void | bufferreader_destroy (BufferReader *br) |
| Destroy a BufferReader. More... | |
| char * | bufferreader_get_line (BufferReader *br, char *buffer, size_t length) |
| Copy the next line in the buffer, keeping the newline. More... | |
| BufferReader * | bufferreader_init_from_file (BufferReader *br, const char *filepath, const char *failureMessage, LogLevel failureLevel) |
| Initialize or create a BufferReader from a file path. More... | |
| BufferReader * | bufferreader_init_from_memory (BufferReader *br, const char *data, size_t length) |
| Initialize or create a BufferReader from a memory block. More... | |
| void | bufferreader_init_from_tar_file (BufferReader *br, mtar_t *tar, mtar_header_t *h) |
| Initialize a BufferReader from a tar file entry. More... | |
| char * | bufferreader_next_line (BufferReader *br) |
| Return the next line in the buffer, as separated by a newline. More... | |
Implements a buffer reader.
Usage is: BufferReader *reader = bufferreader_create(); bufferreader_init_from_file(reader, opened_file); char *buf: while ((buf = bufferreader_next_line(reader)) != NULL) { (...) } bufferreader_destroy(reader);
Alternative is to access the buffer's full data through bufferreader_data() and bufferreader_data_length().
Buffer may and should be reused to avoid allocating/freeing memory all the time.
No function ever fails. In case not enough memory is available, {} is called.
Definition in file bufferreader.h.
| BufferReader* bufferreader_create | ( | ) |
Create a new BufferReader.
Definition at line 31 of file bufferreader.cpp.
References buffer, fatal(), and OUT_OF_MEMORY.
Referenced by AssetCollector::AssetCollector(), bufferreader_init_from_file(), bufferreader_init_from_memory(), and TarLoader::TarLoader().
Here is the call graph for this function:
Here is the caller graph for this function:| size_t bufferreader_current_line | ( | BufferReader * | br | ) |
Return the index of the last line returned by bufferreader_next_line().
| br | buffer to get the line index of. |
Definition at line 140 of file bufferreader.cpp.
References BufferReader::line_index.
Referenced by init_config_vals(), init_formulae(), init_weather_replace(), init_weatheravoid(), ArtifactLoader::load(), MessageLoader::load(), TreasureLoader::load(), QuestLoader::load(), load_bells(), load_citylife(), and TreasureLoader::loadTreasure().
Here is the caller graph for this function:| char* bufferreader_data | ( | BufferReader * | br | ) |
Get the whole buffer, independently of the calls to bufferreader_next_line().
| br | buffer. |
Definition at line 148 of file bufferreader.cpp.
References BufferReader::buf.
Referenced by PngLoader::load(), read_elevmap(), read_forestrymap(), read_gulfstreammap(), read_humidmap(), read_pressuremap(), read_rainfallmap(), read_temperaturemap(), read_watermap(), read_weatherposition(), read_winddirmap(), read_windspeedmap(), and tar_read().
Here is the caller graph for this function:| size_t bufferreader_data_length | ( | BufferReader * | br | ) |
Return the length of the buffer data.
| br | buffer. |
Definition at line 144 of file bufferreader.cpp.
References BufferReader::buffer_length.
Referenced by PngLoader::load(), and tar_read().
Here is the caller graph for this function:| void bufferreader_destroy | ( | BufferReader * | br | ) |
Destroy a BufferReader.
| br | buffer to destroy, pointer becomes invalid after the call. |
Definition at line 40 of file bufferreader.cpp.
References BufferReader::buf.
Referenced by accounts_load(), display_help_file(), i18n_init(), init_config_vals(), init_weather_replace(), init_weatheravoid(), read_elevmap(), read_forestrymap(), read_gulfstreammap(), read_humidmap(), read_pressuremap(), read_rainfallmap(), read_temperaturemap(), read_watermap(), read_weatherposition(), read_winddirmap(), read_windspeedmap(), AssetCollector::~AssetCollector(), and TarLoader::~TarLoader().
Here is the caller graph for this function:| char* bufferreader_get_line | ( | BufferReader * | br, |
| char * | buffer, | ||
| size_t | length | ||
| ) |
Copy the next line in the buffer, keeping the newline.
| br | buffer to get the line from. |
| buffer | where to put the line. |
| length | maximum length of buffer. |
Definition at line 119 of file bufferreader.cpp.
References buffer, BufferReader::current_line, BufferReader::line_index, and MIN.
Referenced by load_object_from_reader().
Here is the caller graph for this function:| BufferReader* bufferreader_init_from_file | ( | BufferReader * | br, |
| const char * | filepath, | ||
| const char * | failureMessage, | ||
| LogLevel | failureLevel | ||
| ) |
Initialize or create a BufferReader from a file path.
The whole file is read into memory.
| br | buffer to initialize, if NULL then a new BufferReader is created. |
| filepath | path of the file to read. |
| failureMessage | message to LOG() in case of open failure. Must contain 2 placeholders 's' for the filepath and the error message. |
| failureLevel | log level to use in case of failure. |
Definition at line 65 of file bufferreader.cpp.
References BufferReader::buf, BufferReader::buffer_length, bufferreader_create(), bufferreader_init_for_length(), llevError, and LOG().
Referenced by accounts_load(), display_help_file(), i18n_init(), init_config_vals(), init_weather_replace(), init_weatheravoid(), AssetCollector::processFiles(), read_elevmap(), read_forestrymap(), read_gulfstreammap(), read_humidmap(), read_pressuremap(), read_rainfallmap(), read_temperaturemap(), read_watermap(), read_weatherposition(), read_winddirmap(), and read_windspeedmap().
Here is the call graph for this function:
Here is the caller graph for this function:| BufferReader* bufferreader_init_from_memory | ( | BufferReader * | br, |
| const char * | data, | ||
| size_t | length | ||
| ) |
Initialize or create a BufferReader from a memory block.
| br | buffer to initialize, if NULL then a new BufferReader is created. |
| data | data to initialize the reader to. |
| length | length of data. |
Definition at line 93 of file bufferreader.cpp.
References BufferReader::buf, bufferreader_create(), and bufferreader_init_for_length().
Here is the call graph for this function:| void bufferreader_init_from_tar_file | ( | BufferReader * | br, |
| mtar_t * | tar, | ||
| mtar_header_t * | h | ||
| ) |
Initialize a BufferReader from a tar file entry.
| br | buffer to initialize. |
| tar | tar file pointer. |
| h | header in the tar file to initialize for. |
Definition at line 88 of file bufferreader.cpp.
References BufferReader::buf, bufferreader_init_for_length(), mtar_read_data(), and mtar_header_t::size.
Referenced by TarLoader::load().
Here is the call graph for this function:
Here is the caller graph for this function:| char* bufferreader_next_line | ( | BufferReader * | br | ) |
Return the next line in the buffer, as separated by a newline.
| br | buffer to get the line from. |
Definition at line 102 of file bufferreader.cpp.
References BufferReader::current_line, and BufferReader::line_index.
Referenced by accounts_load(), display_help_file(), i18n_init(), init_attackmess(), init_config_vals(), init_formulae(), init_regions(), init_weather_replace(), init_weatheravoid(), ArtifactLoader::load(), FacesetLoader::load(), MessageLoader::load(), FaceLoader::load(), TreasureLoader::load(), QuestLoader::load(), load_bells(), load_citylife(), load_materials(), load_races(), FaceLoader::loadAnimationBlock(), and TreasureLoader::loadTreasure().
Here is the caller graph for this function: