Mercurial > hg > th-libs
changeset 63:5ab4c28b85cd
Add th_{read,write}_byte() convenience functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 02 Nov 2012 22:16:20 +0200 |
parents | 36286f2561e1 |
children | 40b6e8dca885 |
files | th_endian.c th_endian.h |
diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/th_endian.c Thu Sep 20 00:00:16 2012 +0300 +++ b/th_endian.c Fri Nov 02 22:16:20 2012 +0200 @@ -20,6 +20,18 @@ } +BOOL th_read_byte(FILE *f, uint8_t *s) +{ + return (fread(s, sizeof(uint8_t), 1, f) == l); +} + + +BOOL th_write_byte(FILE * f, uint8_t * s) +{ + return (fwrite(s, sizeof(uint8_t), 1, f) == l); +} + + /* File routines for endian-dependant data */ #define TH_DEFINE_FUNC(xname, xtype, xmacro) \
--- a/th_endian.h Thu Sep 20 00:00:16 2012 +0300 +++ b/th_endian.h Fri Nov 02 22:16:20 2012 +0200 @@ -103,6 +103,8 @@ */ BOOL th_read_str(FILE *f, uint8_t *s, size_t l); BOOL th_write_str(FILE *f, uint8_t *s, size_t l); +BOOL th_read_byte(FILE *f, uint8_t *b); +BOOL th_write_byte(FILE *f, uint8_t b); #define TH_DEFINE_HEADER(xname, xtype) \ BOOL th_read_ ## xname (FILE *f, xtype *v); \