/*
* This file is part of DisOrder
- * Copyright (C) 2004 Richard Kettlewell
+ * Copyright (C) 2004, 2007, 2008 Richard Kettlewell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* @brief Abstract output sink type
*/
-#include <config.h>
-#include "types.h"
+#include "common.h"
-#include <stdio.h>
#include <stdarg.h>
-#include <string.h>
#include <errno.h>
#include "mem.h"
return (struct sink *)s;
}
+/* discard sink **************************************************************/
+
+static int sink_discard_write(struct sink attribute((unused)) *s,
+ const void attribute((unused)) *buffer,
+ int nbytes) {
+ return nbytes;
+}
+
+/** @brief Return a sink which discards all output */
+struct sink *sink_discard(void) {
+ struct sink *s = xmalloc(sizeof *s);
+
+ s->write = sink_discard_write;
+ return s;
+}
+
+/* error sink **************************************************************/
+
+static int sink_error_write(struct sink attribute((unused)) *s,
+ const void attribute((unused)) *buffer,
+ int attribute((unused)) nbytes) {
+ return -1;
+}
+
+/** @brief Return a sink which discards all output */
+struct sink *sink_error(void) {
+ struct sink *s = xmalloc(sizeof *s);
+
+ s->write = sink_error_write;
+ return s;
+}
+
/*
Local Variables:
c-basic-offset:2