echo(): refactor and rename helper function -> fnwrite()

More often than not, the file to write to in sysfs changes rather than
the value.  This patch changes echo() into a fnwrite(), flipping what
is vsnprintf()'ed, and adds a stupid str() function that converts any
value (float/int/double/uint64_t) to a static string buffer.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-03-18 18:25:11 +01:00
1 parent 74d715243c
commit 6e24f2ff13
3 files changed
+41 -30

No files matched your search

+4 -1
View File
@@ -45,7 +45,10 @@ extern char *prognm;
#include <lite/conio.h>
char *progname (char *arg0);
int echo (char *file, int append, char *fmt, ...);
char *str (char *fmt, ...);
int fnwrite (char *value, char *fmt, ...);
int has_utmp (void);
int strtobytes (char *arg);
void do_sleep (unsigned int sec);