From 4885e8fea8f76d6ec4ba791bce56d70c4a5ded01 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 29 Oct 2019 22:26:48 -0700 Subject: rfkill: remove get_line(). --- toys/net/rfkill.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'toys/net') 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"); -- cgit v1.2.3