summaryrefslogtreecommitdiffstats
path: root/src/lib9/fmt/fmtnull.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-05-22 14:54:34 +0000
committerrsc <devnull@localhost>2006-05-22 14:54:34 +0000
commite17e1a71c2923717723f7038d6e123b6452e0b13 (patch)
treead086b35c4d054b75d17fb621e322d7b6b883c98 /src/lib9/fmt/fmtnull.c
parentf8955f181efa175573ccecc71a19464fdba50ef5 (diff)
downloadplan9port-e17e1a71c2923717723f7038d6e123b6452e0b13.tar.gz
plan9port-e17e1a71c2923717723f7038d6e123b6452e0b13.zip
incorporate changes from Google
Diffstat (limited to 'src/lib9/fmt/fmtnull.c')
-rw-r--r--src/lib9/fmt/fmtnull.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib9/fmt/fmtnull.c b/src/lib9/fmt/fmtnull.c
new file mode 100644
index 00000000..a2f808ee
--- /dev/null
+++ b/src/lib9/fmt/fmtnull.c
@@ -0,0 +1,33 @@
+/* Copyright (c) 2004 Google Inc.; see LICENSE */
+#include <stdarg.h>
+#include <string.h>
+#include "plan9.h"
+#include "fmt.h"
+#include "fmtdef.h"
+
+/*
+ * Absorb output without using resources.
+ */
+static Rune nullbuf[32];
+
+static int
+__fmtnullflush(Fmt *f)
+{
+ f->to = nullbuf;
+ f->nfmt = 0;
+ return 0;
+}
+
+int
+fmtnullinit(Fmt *f)
+{
+ memset(&f, 0, sizeof *f);
+ f->runes = 1;
+ f->start = nullbuf;
+ f->to = nullbuf;
+ f->stop = nullbuf+nelem(nullbuf);
+ f->flush = __fmtnullflush;
+ fmtlocaleinit(f, nil, nil, nil);
+ return 0;
+}
+