]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
gnulib-local: New module 'fd-styled-ostream'.
authorBruno Haible <bruno@clisp.org>
Sat, 9 Feb 2019 18:16:53 +0000 (19:16 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 10 Feb 2019 19:41:26 +0000 (20:41 +0100)
* gnulib-local/lib/fd-styled-ostream.oo.h: New file.
* gnulib-local/lib/fd-styled-ostream.oo.c: New file.
* gnulib-local/modules/fd-styled-ostream: New file.
* gnulib-local/Makefile.am (EXTRA_DIST): Add them.

gnulib-local/Makefile.am
gnulib-local/lib/fd-styled-ostream.oo.c [new file with mode: 0644]
gnulib-local/lib/fd-styled-ostream.oo.h [new file with mode: 0644]
gnulib-local/modules/fd-styled-ostream [new file with mode: 0644]

index 45dab7856b4da19bfab5a297bab730a6fbbc2d15..ddab7032bce683fd35c08fb4f9ff721b708467ea 100644 (file)
@@ -37,6 +37,8 @@ lib/error-progname.h \
 lib/exitfail.h.diff \
 lib/fd-ostream.oo.c \
 lib/fd-ostream.oo.h \
+lib/fd-styled-ostream.oo.c \
+lib/fd-styled-ostream.oo.h \
 lib/file-ostream.oo.c \
 lib/file-ostream.oo.h \
 lib/fnmatch.c.diff \
@@ -268,6 +270,7 @@ modules/basename \
 modules/closeout \
 modules/error-progname \
 modules/fd-ostream \
+modules/fd-styled-ostream \
 modules/file-ostream \
 modules/fnmatch.diff \
 modules/gettext-runtime-misc \
diff --git a/gnulib-local/lib/fd-styled-ostream.oo.c b/gnulib-local/lib/fd-styled-ostream.oo.c
new file mode 100644 (file)
index 0000000..f709cfa
--- /dev/null
@@ -0,0 +1,83 @@
+/* Output stream with no-op styling, referring to a file descriptor.
+   Copyright (C) 2006, 2019 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2019.
+
+   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
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "fd-styled-ostream.h"
+
+#include "fd-ostream.h"
+
+#include "xalloc.h"
+
+
+struct fd_styled_ostream : struct styled_ostream
+{
+fields:
+  /* The destination stream.  */
+  fd_ostream_t destination;
+};
+
+/* Implementation of ostream_t methods.  */
+
+static void
+fd_styled_ostream::write_mem (fd_styled_ostream_t stream,
+                              const void *data, size_t len)
+{
+  fd_ostream_write_mem (stream->destination, data, len);
+}
+
+static void
+fd_styled_ostream::flush (fd_styled_ostream_t stream)
+{
+  fd_ostream_flush (stream->destination);
+}
+
+static void
+fd_styled_ostream::free (fd_styled_ostream_t stream)
+{
+  fd_ostream_free (stream->destination);
+  free (stream);
+}
+
+/* Implementation of styled_ostream_t methods.  */
+
+static void
+fd_styled_ostream::begin_use_class (fd_styled_ostream_t stream,
+                                    const char *classname)
+{
+}
+
+static void
+fd_styled_ostream::end_use_class (fd_styled_ostream_t stream,
+                                  const char *classname)
+{
+}
+
+/* Constructor.  */
+
+fd_styled_ostream_t
+fd_styled_ostream_create (int fd, const char *filename)
+{
+  fd_styled_ostream_t stream =
+    XMALLOC (struct fd_styled_ostream_representation);
+
+  stream->base.base.vtable = &fd_styled_ostream_vtable;
+  stream->destination = fd_ostream_create (fd, filename, true);
+
+  return stream;
+}
diff --git a/gnulib-local/lib/fd-styled-ostream.oo.h b/gnulib-local/lib/fd-styled-ostream.oo.h
new file mode 100644 (file)
index 0000000..04eaaff
--- /dev/null
@@ -0,0 +1,47 @@
+/* Output stream with no-op styling, referring to a file descriptor.
+   Copyright (C) 2006, 2019 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2019.
+
+   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
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#ifndef _FD_STYLED_OSTREAM_H
+#define _FD_STYLED_OSTREAM_H
+
+#include "styled-ostream.h"
+
+
+struct fd_styled_ostream : struct styled_ostream
+{
+methods:
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Create an output stream referring to the file descriptor FD, that supports
+   the styling operations as no-ops.
+   FILENAME is used only for error messages.
+   Note that the resulting stream must be closed before FD can be closed.  */
+extern fd_styled_ostream_t
+       fd_styled_ostream_create (int fd, const char *filename);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FD_STYLED_OSTREAM_H */
diff --git a/gnulib-local/modules/fd-styled-ostream b/gnulib-local/modules/fd-styled-ostream
new file mode 100644 (file)
index 0000000..022eaa4
--- /dev/null
@@ -0,0 +1,49 @@
+Description:
+Output stream with no-op styling, referring to a file descriptor.
+
+Files:
+lib/fd-styled-ostream.oo.h
+lib/fd-styled-ostream.oo.c
+
+Depends-on:
+styled-ostream
+fd-ostream
+xalloc
+
+configure.ac:
+
+Makefile.am:
+if !WOE32DLL
+lib_SOURCES += fd-styled-ostream.c
+else
+lib_SOURCES += ../woe32dll/c++fd-styled-ostream.cc
+endif
+# This is a Makefile rule that generates multiple files at once; see the
+# automake documentation, node "Multiple Outputs", for details.
+fd-styled-ostream.h : $(top_srcdir)/build-aux/moopp fd-styled-ostream.oo.h fd-styled-ostream.oo.c styled-ostream.oo.h ostream.oo.h
+       $(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/fd-styled-ostream.oo.c $(srcdir)/fd-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h
+fd-styled-ostream.c fd_styled_ostream.priv.h fd_styled_ostream.vt.h : fd-styled-ostream.h
+       @test -f $@ || { \
+         trap 'rm -rf fd-styled-ostream.lock' 1 2 13 15; \
+         if mkdir fd-styled-ostream.lock 2>/dev/null; then \
+           echo "$(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/fd-styled-ostream.oo.c $(srcdir)/fd-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h"; \
+           $(top_srcdir)/build-aux/moopp $(MOOPPFLAGS) $(srcdir)/fd-styled-ostream.oo.c $(srcdir)/fd-styled-ostream.oo.h $(srcdir)/styled-ostream.oo.h $(srcdir)/ostream.oo.h; \
+           result=$$?; rm -rf fd-styled-ostream.lock; exit $$result; \
+         else \
+           while test -d fd-styled-ostream.lock; do sleep 1; done; \
+           test -f $(srcdir)/fd-styled-ostream.h; \
+         fi; \
+       }
+BUILT_SOURCES += fd-styled-ostream.h fd-styled-ostream.c fd_styled_ostream.priv.h fd_styled_ostream.vt.h
+MAINTAINERCLEANFILES += fd-styled-ostream.h fd-styled-ostream.c fd_styled_ostream.priv.h fd_styled_ostream.vt.h
+EXTRA_DIST += fd-styled-ostream.h fd-styled-ostream.c fd_styled_ostream.priv.h fd_styled_ostream.vt.h
+
+Include:
+"fd-styled-ostream.h"
+
+License:
+GPL
+
+Maintainer:
+Bruno Haible
+