sipo finished

This commit is contained in:
2018-02-16 23:01:47 +01:00
parent 9cff75554b
commit 003ae692e6
10 changed files with 50 additions and 31 deletions
+2 -1
View File
@@ -119,9 +119,10 @@ void iw_entry(IniWriter *iw, const char *key, const char *format, ...)
iw_newline(iw); // one newline after entry
}
uint32_t iw_measure_total(void (*handler)(IniWriter *))
uint32_t iw_measure_total(void (*handler)(IniWriter *), uint32_t tag)
{
IniWriter iw = iw_init(NULL, 0xFFFFFFFF, 1);
iw.tag = tag;
iw_begin();
handler(&iw);
iw_end();
+3 -2
View File
@@ -18,6 +18,7 @@ typedef struct iniwriter_ {
char *ptr;
uint32_t skip;
uint32_t count;
uint32_t tag; // general purpose field (used to identify for which purpose is the file being read)
} IniWriter;
/**
@@ -43,7 +44,7 @@ void iw_end(void);
* @param count - number of bytes to write, truncate rest
* @return structure initializer
*/
#define iw_init(buffer, skip, count) (IniWriter){buffer, skip, count}
#define iw_init(xbuffer, xskip, xcount) (IniWriter){.ptr=(xbuffer), .skip=(xskip), .count=(xcount)}
/**
* Try to write a buffer to the file
@@ -131,6 +132,6 @@ void iw_entry(IniWriter *iw, const char *key, const char *format, ...)
* @param handler - function that normally writes to the writer
* @return byte count
*/
uint32_t iw_measure_total(void (*handler)(IniWriter *));
uint32_t iw_measure_total(void (*handler)(IniWriter *), uint32_t tag);
#endif //INIWRITER_H