mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-05 06:10:13 -05:00
Even more faster write of content files.
This commit is contained in:
parent
98fc24c195
commit
a7c41fa3ae
3 changed files with 94 additions and 86 deletions
37
util.h
37
util.h
|
|
@ -18,19 +18,6 @@
|
|||
#ifndef __UTIL_H
|
||||
#define __UTIL_H
|
||||
|
||||
/****************************************************************************/
|
||||
/* string */
|
||||
|
||||
/**
|
||||
* Encodes to hex.
|
||||
*/
|
||||
void strenchex(char* str, const void* void_data, unsigned data_len);
|
||||
|
||||
/**
|
||||
* Decodes from hex.
|
||||
*/
|
||||
char* strdechex(void* void_data, unsigned data_len, char* str);
|
||||
|
||||
/****************************************************************************/
|
||||
/* stream */
|
||||
|
||||
|
|
@ -252,7 +239,7 @@ int sgethex(STREAM* f, void* data, int size);
|
|||
|
||||
/**
|
||||
* Writes a char. Like fputc().
|
||||
* Returns 0 on succes or -1 on error.
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
static inline int sputc(int c, STREAM* s)
|
||||
{
|
||||
|
|
@ -266,7 +253,7 @@ static inline int sputc(int c, STREAM* s)
|
|||
|
||||
/**
|
||||
* Writes a end of line.
|
||||
* Returns 0 on succes or -1 on error.
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
static inline int sputeol(STREAM* s)
|
||||
{
|
||||
|
|
@ -279,25 +266,37 @@ static inline int sputeol(STREAM* s)
|
|||
|
||||
/**
|
||||
* Writes a string.
|
||||
* Returns 0 on succes or -1 on error.
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
int sputs(const char* str, STREAM* f);
|
||||
|
||||
/**
|
||||
* Write a sized string.
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
int swrite(const void* data, unsigned size, STREAM* f);
|
||||
|
||||
/**
|
||||
* Write a string literal (constant string).
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
#define sputsl(str, f) swrite(str, sizeof(str) - 1, f)
|
||||
|
||||
/**
|
||||
* Writes a 32 bit number.
|
||||
* Returns 0 on succes or -1 on error.
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
int sputu32(uint32_t value, STREAM* s);
|
||||
|
||||
/**
|
||||
* Writes a 64 bit number.
|
||||
* Returns 0 on succes or -1 on error.
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
int sputu64(uint64_t value, STREAM* s);
|
||||
|
||||
/**
|
||||
* Writes a hexadecimal string of fixed length.
|
||||
* Returns 0 on succes or -1 on error.
|
||||
* Returns 0 on success or -1 on error.
|
||||
*/
|
||||
int sputhex(const void* void_data, int size, STREAM* s);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue