aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-10-29 22:26:48 -0700
committerRob Landley <rob@landley.net>2019-10-30 18:03:58 -0500
commit4885e8fea8f76d6ec4ba791bce56d70c4a5ded01 (patch)
treea488e71d50c369ff63d2853685fe76c02f8c7f51
parent0b2cfcb8fdea9673f3c2e0940f1b16d5825e16ea (diff)
downloadtoybox-4885e8fea8f76d6ec4ba791bce56d70c4a5ded01.tar.gz
rfkill: remove get_line().
-rw-r--r--toys/net/rfkill.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/toys/net/rfkill.c b/toys/net/rfkill.c
index 26879e92..47e7ab28 100644
--- a/toys/net/rfkill.c
+++ b/toys/net/rfkill.c
@@ -73,23 +73,26 @@ void rfkill_main(void)
} else {
// show list.
while (sizeof(rfevent) == readall(fd, &rfevent, sizeof(rfevent))) {
- char *line, *name = 0, *type = 0;
+ char *line = 0, *name = 0, *type = 0;
+ FILE *fp;
+ size_t l = 0;
+ ssize_t len;
// filter list items
if ((tid > 0 && tid != rfevent.type) || (idx != -1 && idx != rfevent.idx))
continue;
sprintf(toybuf, "/sys/class/rfkill/rfkill%u/uevent", rfevent.idx);
- tvar = xopenro(toybuf);
- while ((line = get_line(tvar))) {
+ fp = xfopen(toybuf, "r");
+ while ((len = getline(&line, &l, fp)) > 0) {
char *s = line;
+ line[len-1] = 0;
if (strstart(&s, "RFKILL_NAME=")) name = xstrdup(s);
else if (strstart(&s, "RFKILL_TYPE=")) type = xstrdup(s);
-
- free(line);
}
- xclose(tvar);
+ free(line);
+ fclose(fp);
xprintf("%u: %s: %s\n", rfevent.idx, name, type);
xprintf("\tSoft blocked: %s\n", rfevent.soft ? "yes" : "no");