changeset: 2678:e5503b8254b0
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Sun May 30 15:29:30 2010 -0400
files: cmd/wmiir.c
description:
[wmiir] Use buffered IO.
diff -r 49c7824cf9b0 -r e5503b8254b0 cmd/wmiir.c
--- a/cmd/wmiir.c Sun May 30 15:18:15 2010 -0400
+++ b/cmd/wmiir.c Sun May 30 15:29:30 2010 -0400
@@ -11,9 +11,11 @@
#include <unistd.h>
#include <ixp.h>
#include <stuff/util.h>
+#include <bio.h>
#include <fmt.h>
static IxpClient *client;
+static Biobuf *outbuf;
static void
usage(void) {
@@ -99,14 +101,14 @@
file = "";
if(lflag)
- print("%s %s %s %5llud %s %s%s%s\n",
+ Bprint(outbuf, "%s %s %s %5llud %s %s%s%s\n",
modestr(s->mode), s->uid, s->gid, s->length,
timestr(s->mtime), file, slash, s->name);
else {
if((s->mode&P9_DMDIR) && strcmp(s->name, "/"))
- print("%s%s%s/\n", file, slash, s->name);
+ Bprint(outbuf, "%s%s%s/\n", file, slash, s->name);
else
- print("%s%s%s\n", file, slash, s->name);
+ Bprint(outbuf, "%s%s%s\n", file, slash, s->name);
}
}
@@ -325,7 +327,7 @@
path = ixp_namespace();
if(path == nil)
fatal("can't find namespace: %r\n");
- print("%s\n", path);
+ Bprint(outbuf, "%s\n", path);
return 0;
}
@@ -346,7 +348,7 @@
if((d = opendir(dir))) {
while((de = readdir(d)))
if(access(de->d_name, X_OK))
- print("%q\n", de->d_name);
+ Bprint(outbuf, "%q\n", de->d_name);
closedir(d);
}
@@ -435,9 +437,13 @@
if(argc < 1)
usage();
+ outbuf = Bfdopen(1, OWRITE);
+
for(tab=utiltab; tab->cmd; tab++)
- if(!strcmp(*argv, tab->cmd))
- return tab->fn(argc, argv);
+ if(!strcmp(*argv, tab->cmd)) {
+ ret = tab->fn(argc, argv);
+ goto done;
+ }
if(address && *address)
client = ixp_mount(address);
@@ -456,6 +462,8 @@
ret = tab->fn(argc, argv);
ixp_unmount(client);
+done:
+ Bterm(outbuf);
return ret;
}
Received on Sun May 30 2010 - 19:29:37 UTC
This archive was generated by hypermail 2.2.0 : Sun May 30 2010 - 19:36:05 UTC