changeset 196:5c7de25666e7

Move th_{fread,fwrite}_{str,byte}() functions to th_file module.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 11 Feb 2016 17:52:35 +0200
parents a16e8272bdda
children 88986d0b56ef
files th_endian.c th_endian.h th_file.c th_file.h
diffstat 4 files changed, 30 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- 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)        \
--- 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);
--- 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);
+}
+
+
--- 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
 }