# HG changeset patch # User Matti Hamalainen # Date 1455205955 -7200 # Node ID 5c7de25666e7d51b3c5667e47534e3f6ee300bf8 # Parent a16e8272bddaaf9036f14cc8750f6824bdb57083 Move th_{fread,fwrite}_{str,byte}() functions to th_file module. diff -r a16e8272bdda -r 5c7de25666e7 th_endian.c --- a/th_endian.c Thu Feb 11 16:42:43 2016 +0200 +++ b/th_endian.c Thu Feb 11 17:52:35 2016 +0200 @@ -8,30 +8,6 @@ #include "th_endian.h" -BOOL th_fread_str(FILE *f, uint8_t *s, size_t l) -{ - return (fread(s, sizeof(uint8_t), l, f) == l); -} - - -BOOL th_fwrite_str(FILE * f, uint8_t * s, size_t l) -{ - return (fwrite(s, sizeof(uint8_t), l, f) == l); -} - - -BOOL th_fread_byte(FILE *f, uint8_t *v) -{ - return (fread(v, sizeof(uint8_t), 1, f) == 1); -} - - -BOOL th_fwrite_byte(FILE * f, uint8_t v) -{ - return (fputc(v, f) != EOF); -} - - /* File routines for endian-dependant data */ #define TH_DEFINE_FUNC(xname, xtype, xmacro) \ diff -r a16e8272bdda -r 5c7de25666e7 th_endian.h --- a/th_endian.h Thu Feb 11 16:42:43 2016 +0200 +++ b/th_endian.h Thu Feb 11 17:52:35 2016 +0200 @@ -101,11 +101,6 @@ /* Endian-handling file read/write routines */ -BOOL th_fread_str(FILE *f, uint8_t *s, size_t l); -BOOL th_fwrite_str(FILE *f, uint8_t *s, size_t l); -BOOL th_fread_byte(FILE *f, uint8_t *b); -BOOL th_fwrite_byte(FILE *f, uint8_t b); - #define TH_DEFINE_HEADER(xname, xtype) \ BOOL th_fread_ ## xname (FILE *f, xtype *v); \ BOOL th_fwrite_ ## xname (FILE *f, xtype v); diff -r a16e8272bdda -r 5c7de25666e7 th_file.c --- a/th_file.c Thu Feb 11 16:42:43 2016 +0200 +++ b/th_file.c Thu Feb 11 17:52:35 2016 +0200 @@ -141,3 +141,29 @@ th_free(path); return res; } + + +BOOL th_fread_str(FILE *f, uint8_t *s, size_t l) +{ + return (fread(s, sizeof(uint8_t), l, f) == l); +} + + +BOOL th_fwrite_str(FILE * f, uint8_t * s, size_t l) +{ + return (fwrite(s, sizeof(uint8_t), l, f) == l); +} + + +BOOL th_fread_byte(FILE *f, uint8_t *v) +{ + return (fread(v, sizeof(uint8_t), 1, f) == 1); +} + + +BOOL th_fwrite_byte(FILE * f, uint8_t v) +{ + return (fputc(v, f) != EOF); +} + + diff -r a16e8272bdda -r 5c7de25666e7 th_file.h --- a/th_file.h Thu Feb 11 16:42:43 2016 +0200 +++ b/th_file.h Thu Feb 11 17:52:35 2016 +0200 @@ -40,6 +40,10 @@ BOOL th_stat_path(const char *path, int *flags); BOOL th_mkdir_path(const char *cpath, int mode); +BOOL th_fread_str(FILE *f, uint8_t *s, size_t l); +BOOL th_fwrite_str(FILE *f, uint8_t *s, size_t l); +BOOL th_fread_byte(FILE *f, uint8_t *b); +BOOL th_fwrite_byte(FILE *f, uint8_t b); #ifdef __cplusplus }