[hackers] [libixp] Add append command to ixpc. || sqweek

From: <hg_AT_suckless.org>
Date: Sun, 21 Sep 2008 03:40:54 +0000 (UTC)

changeset: 101:459ad13e78bd
user: sqweek <sqweek_AT_gmail.com>
date: Sat Sep 20 10:17:37 2008 +0800
files: cmd/ixpc.c
description:
Add append command to ixpc.

diff -r cfe082aa6f7f -r 459ad13e78bd cmd/ixpc.c
--- a/cmd/ixpc.c Sat Aug 30 17:51:27 2008 -0400
+++ b/cmd/ixpc.c Sat Sep 20 10:17:37 2008 +0800
@@ -18,7 +18,7 @@
 static void
 usage(void) {
         fprintf(stderr,
- "usage: %1$s [-a <address>] {create | read | ls [-ld] | remove | write} <file>\n"
+ "usage: %1$s [-a <address>] {create | read | ls [-ld] | remove | write | append} <file>\n"
                    " %1$s [-a <address>] xwrite <file> <data>\n"
                    " %1$s -v\n", argv0);
         exit(1);
@@ -97,6 +97,30 @@
 }
 
 /* Service Functions */
+static int
+xappend(int argc, char *argv[]) {
+ IxpCFid *fid;
+ IxpStat *stat;
+ char *file;
+
+ ARGBEGIN{
+ default:
+ usage();
+ }ARGEND;
+
+ file = EARGF(usage());
+ fid = ixp_open(client, file, P9_OWRITE);
+ if(fid == nil)
+ fatal("Can't open file '%s': %s\n", file, ixp_errbuf());
+
+ stat = ixp_stat(client, file);
+ fid->offset = stat->length;
+ ixp_freestat(stat);
+ free(stat);
+ write_data(fid, file);
+ return 0;
+}
+
 static int
 xwrite(int argc, char *argv[]) {
         IxpCFid *fid;
@@ -285,6 +309,7 @@
         char *cmd;
         int (*fn)(int, char**);
 } etab[] = {
+ {"append", xappend},
         {"write", xwrite},
         {"xwrite", xawrite},
         {"read", xread},
Received on Sun Sep 21 2008 - 03:40:54 UTC

This archive was generated by hypermail 2.2.0 : Sun Sep 21 2008 - 03:48:03 UTC