GPAK  1.0.0
A general-purpose archive library
gpak_helper.h
1 #ifndef GPAK_HELPER_H
2 #define GPAK_HELPER_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8  #include "gpak_export.h"
9  #include "gpak_data.h"
10 
11  /**
12  * @brief Sets the error code for the specified G-PAK archive.
13  *
14  * This function sets the error code for the specified G-PAK archive and calls the error handler, if one has been set.
15  *
16  * @param _pak A pointer to the gpak_t.
17  * @param _error_code The error code to set.
18  * @return The error code that was set.
19  */
20  GPAK_API int _gpak_make_error(gpak_t* _pak, int _error_code);
21 
22  /**
23  * @brief Notifies the progress handler for the specified G-PAK archive.
24  *
25  * This function notifies the progress handler for the specified G-PAK archive, if one has been set, with the current progress information.
26  *
27  * @param _pak A pointer to the gpak_t.
28  * @param _done The number of bytes processed.
29  * @param _total The total number of bytes to be processed.
30  * @param _stage The current stage of the operation (e.g., compression, decompression).
31  */
32  GPAK_API void _gpak_pass_progress(gpak_t* _pak, size_t _done, size_t _total, int32_t _stage);
33 
34  /**
35  * @brief Writes binary data to a file.
36  *
37  * This function writes binary data from the specified buffer to the given file. It is an internal utility function used by the G-PAK library.
38  *
39  * @param _data A pointer to the buffer containing the data to write.
40  * @param _elemSize The size of each element in bytes.
41  * @param _elemCount The number of elements to write.
42  * @param _file A pointer to the FILE to write to.
43  * @return The number of elements successfully written to the file.
44  */
45  GPAK_API size_t _fwriteb(const void* _data, size_t _elemSize, size_t _elemCount, FILE* _file);
46 
47  /**
48  * @brief Reads binary data from a file.
49  *
50  * This function reads binary data from the specified file into the given buffer. It is an internal utility function used by the G-PAK library.
51  *
52  * @param _data A pointer to the buffer to store the read data.
53  * @param _elemSize The size of each element in bytes.
54  * @param _elemCount The number of elements to read.
55  * @param _file A pointer to the FILE to read from.
56  * @return The number of elements successfully read from the file.
57  */
58  GPAK_API size_t _freadb(void* _data, size_t _elemSize, size_t _elemCount, FILE* _file);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 
64 #endif // GPAK_HELPER_H