summaryrefslogtreecommitdiff
path: root/lib/unistdio
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unistdio')
-rw-r--r--lib/unistdio/u-asnprintf.h27
-rw-r--r--lib/unistdio/u-asprintf.h27
-rw-r--r--lib/unistdio/u-printf-args.c22
-rw-r--r--lib/unistdio/u-printf-args.h27
-rw-r--r--lib/unistdio/u-printf-parse.h27
-rw-r--r--lib/unistdio/u-snprintf.h27
-rw-r--r--lib/unistdio/u-sprintf.h27
-rw-r--r--lib/unistdio/u-vasprintf.h35
-rw-r--r--lib/unistdio/u-vsnprintf.h52
-rw-r--r--lib/unistdio/u-vsprintf.h58
-rw-r--r--lib/unistdio/u16-asnprintf.c28
-rw-r--r--lib/unistdio/u16-asprintf.c28
-rw-r--r--lib/unistdio/u16-printf-parse.c26
-rw-r--r--lib/unistdio/u16-snprintf.c28
-rw-r--r--lib/unistdio/u16-sprintf.c28
-rw-r--r--lib/unistdio/u16-u16-asnprintf.c28
-rw-r--r--lib/unistdio/u16-u16-asprintf.c28
-rw-r--r--lib/unistdio/u16-u16-snprintf.c28
-rw-r--r--lib/unistdio/u16-u16-sprintf.c28
-rw-r--r--lib/unistdio/u16-u16-vasnprintf.c49
-rw-r--r--lib/unistdio/u16-u16-vasprintf.c30
-rw-r--r--lib/unistdio/u16-u16-vsnprintf.c33
-rw-r--r--lib/unistdio/u16-u16-vsprintf.c32
-rw-r--r--lib/unistdio/u16-vasnprintf.c50
-rw-r--r--lib/unistdio/u16-vasprintf.c30
-rw-r--r--lib/unistdio/u16-vsnprintf.c33
-rw-r--r--lib/unistdio/u16-vsprintf.c32
-rw-r--r--lib/unistdio/u32-asnprintf.c28
-rw-r--r--lib/unistdio/u32-asprintf.c28
-rw-r--r--lib/unistdio/u32-printf-parse.c26
-rw-r--r--lib/unistdio/u32-snprintf.c28
-rw-r--r--lib/unistdio/u32-sprintf.c28
-rw-r--r--lib/unistdio/u32-u32-asnprintf.c28
-rw-r--r--lib/unistdio/u32-u32-asprintf.c28
-rw-r--r--lib/unistdio/u32-u32-snprintf.c28
-rw-r--r--lib/unistdio/u32-u32-sprintf.c28
-rw-r--r--lib/unistdio/u32-u32-vasnprintf.c49
-rw-r--r--lib/unistdio/u32-u32-vasprintf.c30
-rw-r--r--lib/unistdio/u32-u32-vsnprintf.c33
-rw-r--r--lib/unistdio/u32-u32-vsprintf.c32
-rw-r--r--lib/unistdio/u32-vasnprintf.c50
-rw-r--r--lib/unistdio/u32-vasprintf.c30
-rw-r--r--lib/unistdio/u32-vsnprintf.c33
-rw-r--r--lib/unistdio/u32-vsprintf.c32
-rw-r--r--lib/unistdio/u8-asnprintf.c28
-rw-r--r--lib/unistdio/u8-asprintf.c28
-rw-r--r--lib/unistdio/u8-printf-parse.c26
-rw-r--r--lib/unistdio/u8-snprintf.c28
-rw-r--r--lib/unistdio/u8-sprintf.c28
-rw-r--r--lib/unistdio/u8-u8-asnprintf.c28
-rw-r--r--lib/unistdio/u8-u8-asprintf.c28
-rw-r--r--lib/unistdio/u8-u8-snprintf.c28
-rw-r--r--lib/unistdio/u8-u8-sprintf.c28
-rw-r--r--lib/unistdio/u8-u8-vasnprintf.c49
-rw-r--r--lib/unistdio/u8-u8-vasprintf.c30
-rw-r--r--lib/unistdio/u8-u8-vsnprintf.c33
-rw-r--r--lib/unistdio/u8-u8-vsprintf.c32
-rw-r--r--lib/unistdio/u8-vasnprintf.c50
-rw-r--r--lib/unistdio/u8-vasprintf.c30
-rw-r--r--lib/unistdio/u8-vsnprintf.c33
-rw-r--r--lib/unistdio/u8-vsprintf.c32
-rw-r--r--lib/unistdio/ulc-asnprintf.c28
-rw-r--r--lib/unistdio/ulc-asprintf.c28
-rw-r--r--lib/unistdio/ulc-fprintf.c74
-rw-r--r--lib/unistdio/ulc-printf-parse.c27
-rw-r--r--lib/unistdio/ulc-snprintf.c28
-rw-r--r--lib/unistdio/ulc-sprintf.c28
-rw-r--r--lib/unistdio/ulc-vasnprintf.c46
-rw-r--r--lib/unistdio/ulc-vasprintf.c30
-rw-r--r--lib/unistdio/ulc-vfprintf.c71
-rw-r--r--lib/unistdio/ulc-vsnprintf.c33
-rw-r--r--lib/unistdio/ulc-vsprintf.c32
72 files changed, 2371 insertions, 0 deletions
diff --git a/lib/unistdio/u-asnprintf.h b/lib/unistdio/u-asnprintf.h
new file mode 100644
index 00000000..8fd08d7f
--- /dev/null
+++ b/lib/unistdio/u-asnprintf.h
@@ -0,0 +1,27 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+DCHAR_T *
+ASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const FCHAR_T *format, ...)
+{
+ va_list args;
+ DCHAR_T *result;
+
+ va_start (args, format);
+ result = VASNPRINTF (resultbuf, lengthp, format, args);
+ va_end (args);
+ return result;
+}
diff --git a/lib/unistdio/u-asprintf.h b/lib/unistdio/u-asprintf.h
new file mode 100644
index 00000000..ba82faba
--- /dev/null
+++ b/lib/unistdio/u-asprintf.h
@@ -0,0 +1,27 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+ASPRINTF (DCHAR_T **resultp, const FCHAR_T *format, ...)
+{
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = VASPRINTF (resultp, format, args);
+ va_end (args);
+ return result;
+}
diff --git a/lib/unistdio/u-printf-args.c b/lib/unistdio/u-printf-args.c
new file mode 100644
index 00000000..22fbc088
--- /dev/null
+++ b/lib/unistdio/u-printf-args.c
@@ -0,0 +1,22 @@
+/* Decomposed printf argument list.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-args.h"
+
+#include "printf-args.c"
diff --git a/lib/unistdio/u-printf-args.h b/lib/unistdio/u-printf-args.h
new file mode 100644
index 00000000..7b2255a2
--- /dev/null
+++ b/lib/unistdio/u-printf-args.h
@@ -0,0 +1,27 @@
+/* Decomposed printf argument list.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _U_PRINTF_ARGS_H
+#define _U_PRINTF_ARGS_H
+
+#include "unitypes.h"
+
+/* Parametrization of printf-args.h. */
+#define ENABLE_UNISTDIO 1
+#define PRINTF_FETCHARGS u_printf_fetchargs
+#include "printf-args.h"
+
+#endif /* _U_PRINTF_ARGS_H */
diff --git a/lib/unistdio/u-printf-parse.h b/lib/unistdio/u-printf-parse.h
new file mode 100644
index 00000000..11a953f9
--- /dev/null
+++ b/lib/unistdio/u-printf-parse.h
@@ -0,0 +1,27 @@
+/* Parse printf format string.
+ Copyright (C) 1999, 2002, 2005, 2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _U_PRINTF_PARSE_H
+#define _U_PRINTF_PARSE_H
+
+#include "unistdio/u-printf-args.h"
+
+/* Parametrization of printf-parse.h. */
+#undef ENABLE_UNISTDIO
+#define ENABLE_UNISTDIO 1
+#include "printf-parse.h"
+
+#endif /* _U_PRINTF_PARSE_H */
diff --git a/lib/unistdio/u-snprintf.h b/lib/unistdio/u-snprintf.h
new file mode 100644
index 00000000..1665bc23
--- /dev/null
+++ b/lib/unistdio/u-snprintf.h
@@ -0,0 +1,27 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+SNPRINTF (DCHAR_T *buf, size_t size, const FCHAR_T *format, ...)
+{
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = VSNPRINTF (buf, size, format, args);
+ va_end (args);
+ return result;
+}
diff --git a/lib/unistdio/u-sprintf.h b/lib/unistdio/u-sprintf.h
new file mode 100644
index 00000000..8a1b5544
--- /dev/null
+++ b/lib/unistdio/u-sprintf.h
@@ -0,0 +1,27 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+SPRINTF (DCHAR_T *buf, const FCHAR_T *format, ...)
+{
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = VSPRINTF (buf, format, args);
+ va_end (args);
+ return result;
+}
diff --git a/lib/unistdio/u-vasprintf.h b/lib/unistdio/u-vasprintf.h
new file mode 100644
index 00000000..965bfbf5
--- /dev/null
+++ b/lib/unistdio/u-vasprintf.h
@@ -0,0 +1,35 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+VASPRINTF (DCHAR_T **resultp, const FCHAR_T *format, va_list args)
+{
+ size_t length;
+ DCHAR_T *result = VASNPRINTF (NULL, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ if (length > INT_MAX)
+ {
+ free (result);
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ *resultp = result;
+ /* Return the number of resulting units, excluding the trailing NUL. */
+ return length;
+}
diff --git a/lib/unistdio/u-vsnprintf.h b/lib/unistdio/u-vsnprintf.h
new file mode 100644
index 00000000..481a22f0
--- /dev/null
+++ b/lib/unistdio/u-vsnprintf.h
@@ -0,0 +1,52 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+VSNPRINTF (DCHAR_T *buf, size_t size, const FCHAR_T *format, va_list args)
+{
+ size_t length;
+ DCHAR_T *result;
+
+ if (size == 0)
+ buf = NULL;
+ else
+ length = size;
+ result = VASNPRINTF (buf, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ if (result != buf)
+ {
+ if (size != 0)
+ {
+ /* The result did not fit into the buffer. Copy the initial segment
+ into the buffer, truncating it if necessary. */
+ size_t n = (length < size ? length : size - 1);
+ DCHAR_CPY (buf, result, n);
+ buf[n] = '\0';
+ }
+ free (result);
+ }
+
+ if (length > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ /* Return the number of resulting units, excluding the trailing NUL. */
+ return length;
+}
diff --git a/lib/unistdio/u-vsprintf.h b/lib/unistdio/u-vsprintf.h
new file mode 100644
index 00000000..36ebd9fa
--- /dev/null
+++ b/lib/unistdio/u-vsprintf.h
@@ -0,0 +1,58 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+int
+VSPRINTF (DCHAR_T *buf, const FCHAR_T *format, va_list args)
+{
+ /* Pass an infinite length. But note that *vasnprintf may fail if the buffer
+ argument is larger than INT_MAX (if that fits into a 'size_t' at all).
+ Also note that glibc's iconv fails with E2BIG when we pass a length that
+ is so large that buf + length wraps around, i.e.
+ (uintptr_t) (buf + length) < (uintptr_t) buf. */
+ size_t length;
+ DCHAR_T *result;
+
+ /* Set length = min (SIZE_MAX, INT_MAX, - (uintptr_t) buf - 1). */
+ length = (SIZE_MAX < INT_MAX ? SIZE_MAX : INT_MAX);
+ if (length > (~ (uintptr_t) buf) / sizeof (DCHAR_T))
+ length = (~ (uintptr_t) buf) / sizeof (DCHAR_T);
+
+ result = VASNPRINTF (buf, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ /* The infinite buffer size guarantees that the result is not malloc()ed. */
+ if (result != buf)
+ {
+ /* length is near SIZE_MAX. */
+ free (result);
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ if (length > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+ /* Return the number of resulting units, excluding the trailing NUL. */
+ return length;
+}
diff --git a/lib/unistdio/u16-asnprintf.c b/lib/unistdio/u16-asnprintf.c
new file mode 100644
index 00000000..bbe4bacb
--- /dev/null
+++ b/lib/unistdio/u16-asnprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u16_asnprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-asnprintf.h"
diff --git a/lib/unistdio/u16-asprintf.c b/lib/unistdio/u16-asprintf.c
new file mode 100644
index 00000000..79f3969c
--- /dev/null
+++ b/lib/unistdio/u16-asprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u16_asprintf
+#define VASPRINTF u16_vasprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-asprintf.h"
diff --git a/lib/unistdio/u16-printf-parse.c b/lib/unistdio/u16-printf-parse.c
new file mode 100644
index 00000000..3a8acd32
--- /dev/null
+++ b/lib/unistdio/u16-printf-parse.c
@@ -0,0 +1,26 @@
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE u16_printf_parse
+#define CHAR_T uint16_t
+#define DIRECTIVE u16_directive
+#define DIRECTIVES u16_directives
+#include "printf-parse.c"
diff --git a/lib/unistdio/u16-snprintf.c b/lib/unistdio/u16-snprintf.c
new file mode 100644
index 00000000..afed8a7e
--- /dev/null
+++ b/lib/unistdio/u16-snprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u16_snprintf
+#define VSNPRINTF u16_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-snprintf.h"
diff --git a/lib/unistdio/u16-sprintf.c b/lib/unistdio/u16-sprintf.c
new file mode 100644
index 00000000..48603652
--- /dev/null
+++ b/lib/unistdio/u16-sprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u16_sprintf
+#define VSPRINTF u16_vsprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-sprintf.h"
diff --git a/lib/unistdio/u16-u16-asnprintf.c b/lib/unistdio/u16-u16-asnprintf.c
new file mode 100644
index 00000000..64c257c2
--- /dev/null
+++ b/lib/unistdio/u16-u16-asnprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u16_u16_asnprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-asnprintf.h"
diff --git a/lib/unistdio/u16-u16-asprintf.c b/lib/unistdio/u16-u16-asprintf.c
new file mode 100644
index 00000000..38469c6e
--- /dev/null
+++ b/lib/unistdio/u16-u16-asprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u16_u16_asprintf
+#define VASPRINTF u16_u16_vasprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-asprintf.h"
diff --git a/lib/unistdio/u16-u16-snprintf.c b/lib/unistdio/u16-u16-snprintf.c
new file mode 100644
index 00000000..7229add1
--- /dev/null
+++ b/lib/unistdio/u16-u16-snprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u16_u16_snprintf
+#define VSNPRINTF u16_u16_vsnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-snprintf.h"
diff --git a/lib/unistdio/u16-u16-sprintf.c b/lib/unistdio/u16-u16-sprintf.c
new file mode 100644
index 00000000..1c517c36
--- /dev/null
+++ b/lib/unistdio/u16-u16-sprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u16_u16_sprintf
+#define VSPRINTF u16_u16_vsprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-sprintf.h"
diff --git a/lib/unistdio/u16-u16-vasnprintf.c b/lib/unistdio/u16-u16-vasnprintf.c
new file mode 100644
index 00000000..e33851e2
--- /dev/null
+++ b/lib/unistdio/u16-u16-vasnprintf.c
@@ -0,0 +1,49 @@
+/* Formatted output to UTF-16 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DIRECTIVE u16_directive
+#define DIRECTIVES u16_directives
+#define PRINTF_PARSE u16_printf_parse
+#define DCHAR_T uint16_t
+#define DCHAR_T_IS_UINT16_T 1
+#define DCHAR_CPY u16_cpy
+#define DCHAR_SET u16_set
+#define DCHAR_MBSNLEN u16_mbsnlen
+#define DCHAR_IS_UINT16_T 1
+#define U8_TO_DCHAR u8_to_u16
+#define U32_TO_DCHAR u32_to_u16
+#define DCHAR_CONV_FROM_ENCODING u16_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
diff --git a/lib/unistdio/u16-u16-vasprintf.c b/lib/unistdio/u16-u16-vasprintf.c
new file mode 100644
index 00000000..3d8fc508
--- /dev/null
+++ b/lib/unistdio/u16-u16-vasprintf.c
@@ -0,0 +1,30 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u16_u16_vasprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-vasprintf.h"
diff --git a/lib/unistdio/u16-u16-vsnprintf.c b/lib/unistdio/u16-u16-vsnprintf.c
new file mode 100644
index 00000000..6bbf8251
--- /dev/null
+++ b/lib/unistdio/u16-u16-vsnprintf.c
@@ -0,0 +1,33 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u16_u16_vsnprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#define DCHAR_CPY u16_cpy
+#include "u-vsnprintf.h"
diff --git a/lib/unistdio/u16-u16-vsprintf.c b/lib/unistdio/u16-u16-vsprintf.c
new file mode 100644
index 00000000..1a7e93c2
--- /dev/null
+++ b/lib/unistdio/u16-u16-vsprintf.c
@@ -0,0 +1,32 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u16_u16_vsprintf
+#define VASNPRINTF u16_u16_vasnprintf
+#define FCHAR_T uint16_t
+#define DCHAR_T uint16_t
+#include "u-vsprintf.h"
diff --git a/lib/unistdio/u16-vasnprintf.c b/lib/unistdio/u16-vasnprintf.c
new file mode 100644
index 00000000..3ce19d42
--- /dev/null
+++ b/lib/unistdio/u16-vasnprintf.c
@@ -0,0 +1,50 @@
+/* Formatted output to UTF-16 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define ASCII_ONLY 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T uint16_t
+#define DCHAR_T_IS_UINT16_T 1
+#define DCHAR_CPY u16_cpy
+#define DCHAR_SET u16_set
+#define DCHAR_MBSNLEN u16_mbsnlen
+#define DCHAR_IS_UINT16_T 1
+#define U8_TO_DCHAR u8_to_u16
+#define U32_TO_DCHAR u32_to_u16
+#define DCHAR_CONV_FROM_ENCODING u16_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
diff --git a/lib/unistdio/u16-vasprintf.c b/lib/unistdio/u16-vasprintf.c
new file mode 100644
index 00000000..b63dd183
--- /dev/null
+++ b/lib/unistdio/u16-vasprintf.c
@@ -0,0 +1,30 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u16_vasprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-vasprintf.h"
diff --git a/lib/unistdio/u16-vsnprintf.c b/lib/unistdio/u16-vsnprintf.c
new file mode 100644
index 00000000..b06ca094
--- /dev/null
+++ b/lib/unistdio/u16-vsnprintf.c
@@ -0,0 +1,33 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u16_vsnprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#define DCHAR_CPY u16_cpy
+#include "u-vsnprintf.h"
diff --git a/lib/unistdio/u16-vsprintf.c b/lib/unistdio/u16-vsprintf.c
new file mode 100644
index 00000000..4811bc15
--- /dev/null
+++ b/lib/unistdio/u16-vsprintf.c
@@ -0,0 +1,32 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u16_vsprintf
+#define VASNPRINTF u16_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint16_t
+#include "u-vsprintf.h"
diff --git a/lib/unistdio/u32-asnprintf.c b/lib/unistdio/u32-asnprintf.c
new file mode 100644
index 00000000..dad1ae49
--- /dev/null
+++ b/lib/unistdio/u32-asnprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u32_asnprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-asnprintf.h"
diff --git a/lib/unistdio/u32-asprintf.c b/lib/unistdio/u32-asprintf.c
new file mode 100644
index 00000000..11e23f01
--- /dev/null
+++ b/lib/unistdio/u32-asprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u32_asprintf
+#define VASPRINTF u32_vasprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-asprintf.h"
diff --git a/lib/unistdio/u32-printf-parse.c b/lib/unistdio/u32-printf-parse.c
new file mode 100644
index 00000000..a5772566
--- /dev/null
+++ b/lib/unistdio/u32-printf-parse.c
@@ -0,0 +1,26 @@
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE u32_printf_parse
+#define CHAR_T uint32_t
+#define DIRECTIVE u32_directive
+#define DIRECTIVES u32_directives
+#include "printf-parse.c"
diff --git a/lib/unistdio/u32-snprintf.c b/lib/unistdio/u32-snprintf.c
new file mode 100644
index 00000000..7d670171
--- /dev/null
+++ b/lib/unistdio/u32-snprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u32_snprintf
+#define VSNPRINTF u32_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-snprintf.h"
diff --git a/lib/unistdio/u32-sprintf.c b/lib/unistdio/u32-sprintf.c
new file mode 100644
index 00000000..6f930d09
--- /dev/null
+++ b/lib/unistdio/u32-sprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u32_sprintf
+#define VSPRINTF u32_vsprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-sprintf.h"
diff --git a/lib/unistdio/u32-u32-asnprintf.c b/lib/unistdio/u32-u32-asnprintf.c
new file mode 100644
index 00000000..b3a02745
--- /dev/null
+++ b/lib/unistdio/u32-u32-asnprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u32_u32_asnprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-asnprintf.h"
diff --git a/lib/unistdio/u32-u32-asprintf.c b/lib/unistdio/u32-u32-asprintf.c
new file mode 100644
index 00000000..91a96fc4
--- /dev/null
+++ b/lib/unistdio/u32-u32-asprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u32_u32_asprintf
+#define VASPRINTF u32_u32_vasprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-asprintf.h"
diff --git a/lib/unistdio/u32-u32-snprintf.c b/lib/unistdio/u32-u32-snprintf.c
new file mode 100644
index 00000000..cf88529c
--- /dev/null
+++ b/lib/unistdio/u32-u32-snprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u32_u32_snprintf
+#define VSNPRINTF u32_u32_vsnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-snprintf.h"
diff --git a/lib/unistdio/u32-u32-sprintf.c b/lib/unistdio/u32-u32-sprintf.c
new file mode 100644
index 00000000..ccf6d028
--- /dev/null
+++ b/lib/unistdio/u32-u32-sprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u32_u32_sprintf
+#define VSPRINTF u32_u32_vsprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-sprintf.h"
diff --git a/lib/unistdio/u32-u32-vasnprintf.c b/lib/unistdio/u32-u32-vasnprintf.c
new file mode 100644
index 00000000..b272af33
--- /dev/null
+++ b/lib/unistdio/u32-u32-vasnprintf.c
@@ -0,0 +1,49 @@
+/* Formatted output to UTF-32 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DIRECTIVE u32_directive
+#define DIRECTIVES u32_directives
+#define PRINTF_PARSE u32_printf_parse
+#define DCHAR_T uint32_t
+#define DCHAR_T_IS_UINT32_T 1
+#define DCHAR_CPY u32_cpy
+#define DCHAR_SET u32_set
+#define DCHAR_MBSNLEN u32_mbsnlen
+#define DCHAR_IS_UINT32_T 1
+#define U8_TO_DCHAR u8_to_u32
+#define U16_TO_DCHAR u16_to_u32
+#define DCHAR_CONV_FROM_ENCODING u32_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
diff --git a/lib/unistdio/u32-u32-vasprintf.c b/lib/unistdio/u32-u32-vasprintf.c
new file mode 100644
index 00000000..bacc7c1b
--- /dev/null
+++ b/lib/unistdio/u32-u32-vasprintf.c
@@ -0,0 +1,30 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u32_u32_vasprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-vasprintf.h"
diff --git a/lib/unistdio/u32-u32-vsnprintf.c b/lib/unistdio/u32-u32-vsnprintf.c
new file mode 100644
index 00000000..7f436236
--- /dev/null
+++ b/lib/unistdio/u32-u32-vsnprintf.c
@@ -0,0 +1,33 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u32_u32_vsnprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#define DCHAR_CPY u32_cpy
+#include "u-vsnprintf.h"
diff --git a/lib/unistdio/u32-u32-vsprintf.c b/lib/unistdio/u32-u32-vsprintf.c
new file mode 100644
index 00000000..46d299ac
--- /dev/null
+++ b/lib/unistdio/u32-u32-vsprintf.c
@@ -0,0 +1,32 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u32_u32_vsprintf
+#define VASNPRINTF u32_u32_vasnprintf
+#define FCHAR_T uint32_t
+#define DCHAR_T uint32_t
+#include "u-vsprintf.h"
diff --git a/lib/unistdio/u32-vasnprintf.c b/lib/unistdio/u32-vasnprintf.c
new file mode 100644
index 00000000..6aac6235
--- /dev/null
+++ b/lib/unistdio/u32-vasnprintf.c
@@ -0,0 +1,50 @@
+/* Formatted output to UTF-32 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define ASCII_ONLY 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T uint32_t
+#define DCHAR_T_IS_UINT32_T 1
+#define DCHAR_CPY u32_cpy
+#define DCHAR_SET u32_set
+#define DCHAR_MBSNLEN u32_mbsnlen
+#define DCHAR_IS_UINT32_T 1
+#define U8_TO_DCHAR u8_to_u32
+#define U16_TO_DCHAR u16_to_u32
+#define DCHAR_CONV_FROM_ENCODING u32_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
diff --git a/lib/unistdio/u32-vasprintf.c b/lib/unistdio/u32-vasprintf.c
new file mode 100644
index 00000000..e6883e31
--- /dev/null
+++ b/lib/unistdio/u32-vasprintf.c
@@ -0,0 +1,30 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u32_vasprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-vasprintf.h"
diff --git a/lib/unistdio/u32-vsnprintf.c b/lib/unistdio/u32-vsnprintf.c
new file mode 100644
index 00000000..a55e1c76
--- /dev/null
+++ b/lib/unistdio/u32-vsnprintf.c
@@ -0,0 +1,33 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u32_vsnprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#define DCHAR_CPY u32_cpy
+#include "u-vsnprintf.h"
diff --git a/lib/unistdio/u32-vsprintf.c b/lib/unistdio/u32-vsprintf.c
new file mode 100644
index 00000000..a850e45f
--- /dev/null
+++ b/lib/unistdio/u32-vsprintf.c
@@ -0,0 +1,32 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u32_vsprintf
+#define VASNPRINTF u32_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint32_t
+#include "u-vsprintf.h"
diff --git a/lib/unistdio/u8-asnprintf.c b/lib/unistdio/u8-asnprintf.c
new file mode 100644
index 00000000..b8e7a276
--- /dev/null
+++ b/lib/unistdio/u8-asnprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u8_asnprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-asnprintf.h"
diff --git a/lib/unistdio/u8-asprintf.c b/lib/unistdio/u8-asprintf.c
new file mode 100644
index 00000000..22b01705
--- /dev/null
+++ b/lib/unistdio/u8-asprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u8_asprintf
+#define VASPRINTF u8_vasprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-asprintf.h"
diff --git a/lib/unistdio/u8-printf-parse.c b/lib/unistdio/u8-printf-parse.c
new file mode 100644
index 00000000..a3555481
--- /dev/null
+++ b/lib/unistdio/u8-printf-parse.c
@@ -0,0 +1,26 @@
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE u8_printf_parse
+#define CHAR_T uint8_t
+#define DIRECTIVE u8_directive
+#define DIRECTIVES u8_directives
+#include "printf-parse.c"
diff --git a/lib/unistdio/u8-snprintf.c b/lib/unistdio/u8-snprintf.c
new file mode 100644
index 00000000..87290541
--- /dev/null
+++ b/lib/unistdio/u8-snprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u8_snprintf
+#define VSNPRINTF u8_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-snprintf.h"
diff --git a/lib/unistdio/u8-sprintf.c b/lib/unistdio/u8-sprintf.c
new file mode 100644
index 00000000..330feaee
--- /dev/null
+++ b/lib/unistdio/u8-sprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u8_sprintf
+#define VSPRINTF u8_vsprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-sprintf.h"
diff --git a/lib/unistdio/u8-u8-asnprintf.c b/lib/unistdio/u8-u8-asnprintf.c
new file mode 100644
index 00000000..9379c72a
--- /dev/null
+++ b/lib/unistdio/u8-u8-asnprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF u8_u8_asnprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-asnprintf.h"
diff --git a/lib/unistdio/u8-u8-asprintf.c b/lib/unistdio/u8-u8-asprintf.c
new file mode 100644
index 00000000..59745278
--- /dev/null
+++ b/lib/unistdio/u8-u8-asprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF u8_u8_asprintf
+#define VASPRINTF u8_u8_vasprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-asprintf.h"
diff --git a/lib/unistdio/u8-u8-snprintf.c b/lib/unistdio/u8-u8-snprintf.c
new file mode 100644
index 00000000..26dfac0e
--- /dev/null
+++ b/lib/unistdio/u8-u8-snprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF u8_u8_snprintf
+#define VSNPRINTF u8_u8_vsnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-snprintf.h"
diff --git a/lib/unistdio/u8-u8-sprintf.c b/lib/unistdio/u8-u8-sprintf.c
new file mode 100644
index 00000000..53b3c96b
--- /dev/null
+++ b/lib/unistdio/u8-u8-sprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF u8_u8_sprintf
+#define VSPRINTF u8_u8_vsprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-sprintf.h"
diff --git a/lib/unistdio/u8-u8-vasnprintf.c b/lib/unistdio/u8-u8-vasnprintf.c
new file mode 100644
index 00000000..7535d4ca
--- /dev/null
+++ b/lib/unistdio/u8-u8-vasnprintf.c
@@ -0,0 +1,49 @@
+/* Formatted output to UTF-8 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DIRECTIVE u8_directive
+#define DIRECTIVES u8_directives
+#define PRINTF_PARSE u8_printf_parse
+#define DCHAR_T uint8_t
+#define DCHAR_T_IS_UINT8_T 1
+#define DCHAR_CPY u8_cpy
+#define DCHAR_SET u8_set
+#define DCHAR_MBSNLEN u8_mbsnlen
+#define DCHAR_IS_UINT8_T 1
+#define U16_TO_DCHAR u16_to_u8
+#define U32_TO_DCHAR u32_to_u8
+#define DCHAR_CONV_FROM_ENCODING u8_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
diff --git a/lib/unistdio/u8-u8-vasprintf.c b/lib/unistdio/u8-u8-vasprintf.c
new file mode 100644
index 00000000..bb28dc5f
--- /dev/null
+++ b/lib/unistdio/u8-u8-vasprintf.c
@@ -0,0 +1,30 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u8_u8_vasprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-vasprintf.h"
diff --git a/lib/unistdio/u8-u8-vsnprintf.c b/lib/unistdio/u8-u8-vsnprintf.c
new file mode 100644
index 00000000..f9e99223
--- /dev/null
+++ b/lib/unistdio/u8-u8-vsnprintf.c
@@ -0,0 +1,33 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u8_u8_vsnprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#define DCHAR_CPY u8_cpy
+#include "u-vsnprintf.h"
diff --git a/lib/unistdio/u8-u8-vsprintf.c b/lib/unistdio/u8-u8-vsprintf.c
new file mode 100644
index 00000000..9e66018a
--- /dev/null
+++ b/lib/unistdio/u8-u8-vsprintf.c
@@ -0,0 +1,32 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u8_u8_vsprintf
+#define VASNPRINTF u8_u8_vasnprintf
+#define FCHAR_T uint8_t
+#define DCHAR_T uint8_t
+#include "u-vsprintf.h"
diff --git a/lib/unistdio/u8-vasnprintf.c b/lib/unistdio/u8-vasnprintf.c
new file mode 100644
index 00000000..0067e6ce
--- /dev/null
+++ b/lib/unistdio/u8-vasnprintf.c
@@ -0,0 +1,50 @@
+/* Formatted output to UTF-8 strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define ASCII_ONLY 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T uint8_t
+#define DCHAR_T_IS_UINT8_T 1
+#define DCHAR_CPY u8_cpy
+#define DCHAR_SET u8_set
+#define DCHAR_MBSNLEN u8_mbsnlen
+#define DCHAR_IS_UINT8_T 1
+#define U16_TO_DCHAR u16_to_u8
+#define U32_TO_DCHAR u32_to_u8
+#define DCHAR_CONV_FROM_ENCODING u8_conv_from_encoding
+#define TCHAR_T char
+#include "vasnprintf.c"
diff --git a/lib/unistdio/u8-vasprintf.c b/lib/unistdio/u8-vasprintf.c
new file mode 100644
index 00000000..304d4965
--- /dev/null
+++ b/lib/unistdio/u8-vasprintf.c
@@ -0,0 +1,30 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF u8_vasprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-vasprintf.h"
diff --git a/lib/unistdio/u8-vsnprintf.c b/lib/unistdio/u8-vsnprintf.c
new file mode 100644
index 00000000..87388e29
--- /dev/null
+++ b/lib/unistdio/u8-vsnprintf.c
@@ -0,0 +1,33 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include "unistr.h"
+
+#define VSNPRINTF u8_vsnprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#define DCHAR_CPY u8_cpy
+#include "u-vsnprintf.h"
diff --git a/lib/unistdio/u8-vsprintf.c b/lib/unistdio/u8-vsprintf.c
new file mode 100644
index 00000000..aa0b52d2
--- /dev/null
+++ b/lib/unistdio/u8-vsprintf.c
@@ -0,0 +1,32 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF u8_vsprintf
+#define VASNPRINTF u8_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T uint8_t
+#include "u-vsprintf.h"
diff --git a/lib/unistdio/ulc-asnprintf.c b/lib/unistdio/ulc-asnprintf.c
new file mode 100644
index 00000000..31d3f220
--- /dev/null
+++ b/lib/unistdio/ulc-asnprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASNPRINTF ulc_asnprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-asnprintf.h"
diff --git a/lib/unistdio/ulc-asprintf.c b/lib/unistdio/ulc-asprintf.c
new file mode 100644
index 00000000..4f760e1d
--- /dev/null
+++ b/lib/unistdio/ulc-asprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define ASPRINTF ulc_asprintf
+#define VASPRINTF ulc_vasprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-asprintf.h"
diff --git a/lib/unistdio/ulc-fprintf.c b/lib/unistdio/ulc-fprintf.c
new file mode 100644
index 00000000..ac8ab6fe
--- /dev/null
+++ b/lib/unistdio/ulc-fprintf.c
@@ -0,0 +1,74 @@
+/* Formatted output to a stream.
+ Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "fseterr.h"
+
+/* Print formatted output to the stream FP.
+ Return string length of formatted string. On error, return a negative
+ value. */
+int
+ulc_fprintf (FILE *fp, const char *format, ...)
+{
+ char buf[2000];
+ char *output;
+ size_t len;
+ size_t lenbuf = sizeof (buf);
+ va_list args;
+
+ va_start (args, format);
+ output = ulc_vasnprintf (buf, &lenbuf, format, args);
+ len = lenbuf;
+ va_end (args);
+
+ if (!output)
+ {
+ fseterr (fp);
+ return -1;
+ }
+
+ if (fwrite (output, 1, len, fp) < len)
+ {
+ if (output != buf)
+ {
+ int saved_errno = errno;
+ free (output);
+ errno = saved_errno;
+ }
+ return -1;
+ }
+
+ if (len > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ fseterr (fp);
+ return -1;
+ }
+
+ return len;
+}
diff --git a/lib/unistdio/ulc-printf-parse.c b/lib/unistdio/ulc-printf-parse.c
new file mode 100644
index 00000000..81af3690
--- /dev/null
+++ b/lib/unistdio/ulc-printf-parse.c
@@ -0,0 +1,27 @@
+/* Formatted output to strings.
+ Copyright (C) 1999-2000, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio/u-printf-parse.h"
+
+#define PRINTF_PARSE ulc_printf_parse
+#define CHAR_T char
+#define CHAR_T_ONLY_ASCII 1
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#include "printf-parse.c"
diff --git a/lib/unistdio/ulc-snprintf.c b/lib/unistdio/ulc-snprintf.c
new file mode 100644
index 00000000..f774ac04
--- /dev/null
+++ b/lib/unistdio/ulc-snprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SNPRINTF ulc_snprintf
+#define VSNPRINTF ulc_vsnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-snprintf.h"
diff --git a/lib/unistdio/ulc-sprintf.c b/lib/unistdio/ulc-sprintf.c
new file mode 100644
index 00000000..466ffb40
--- /dev/null
+++ b/lib/unistdio/ulc-sprintf.c
@@ -0,0 +1,28 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2005-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <stdarg.h>
+
+#define SPRINTF ulc_sprintf
+#define VSPRINTF ulc_vsprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-sprintf.h"
diff --git a/lib/unistdio/ulc-vasnprintf.c b/lib/unistdio/ulc-vasnprintf.c
new file mode 100644
index 00000000..e89b7fff
--- /dev/null
+++ b/lib/unistdio/ulc-vasnprintf.c
@@ -0,0 +1,46 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include "uniconv.h"
+#include "unistr.h"
+#include "unistdio/u-printf-parse.h"
+
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DIRECTIVE char_directive
+#define DIRECTIVES char_directives
+#define FCHAR_T_ONLY_ASCII 1
+#define PRINTF_PARSE ulc_printf_parse
+#define DCHAR_T char
+#define DCHAR_CPY memcpy
+#define DCHAR_SET memset
+#define DCHAR_MBSNLEN mbsnlen
+#define TCHAR_T char
+#define DCHAR_IS_TCHAR 1
+#include "vasnprintf.c"
diff --git a/lib/unistdio/ulc-vasprintf.c b/lib/unistdio/ulc-vasprintf.c
new file mode 100644
index 00000000..8773ab46
--- /dev/null
+++ b/lib/unistdio/ulc-vasprintf.c
@@ -0,0 +1,30 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define VASPRINTF ulc_vasprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-vasprintf.h"
diff --git a/lib/unistdio/ulc-vfprintf.c b/lib/unistdio/ulc-vfprintf.c
new file mode 100644
index 00000000..586fe13a
--- /dev/null
+++ b/lib/unistdio/ulc-vfprintf.c
@@ -0,0 +1,71 @@
+/* Formatted output to a stream.
+ Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "fseterr.h"
+
+/* Print formatted output to the stream FP.
+ Return string length of formatted string. On error, return a negative
+ value. */
+int
+ulc_vfprintf (FILE *fp, const char *format, va_list args)
+{
+ char buf[2000];
+ char *output;
+ size_t len;
+ size_t lenbuf = sizeof (buf);
+
+ output = ulc_vasnprintf (buf, &lenbuf, format, args);
+ len = lenbuf;
+
+ if (!output)
+ {
+ fseterr (fp);
+ return -1;
+ }
+
+ if (fwrite (output, 1, len, fp) < len)
+ {
+ if (output != buf)
+ {
+ int saved_errno = errno;
+ free (output);
+ errno = saved_errno;
+ }
+ return -1;
+ }
+
+ if (len > INT_MAX)
+ {
+ errno = EOVERFLOW;
+ fseterr (fp);
+ return -1;
+ }
+
+ return len;
+}
diff --git a/lib/unistdio/ulc-vsnprintf.c b/lib/unistdio/ulc-vsnprintf.c
new file mode 100644
index 00000000..c1665359
--- /dev/null
+++ b/lib/unistdio/ulc-vsnprintf.c
@@ -0,0 +1,33 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define VSNPRINTF ulc_vsnprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#define DCHAR_CPY memcpy
+#include "u-vsnprintf.h"
diff --git a/lib/unistdio/ulc-vsprintf.c b/lib/unistdio/ulc-vsprintf.c
new file mode 100644
index 00000000..0cccc05d
--- /dev/null
+++ b/lib/unistdio/ulc-vsprintf.c
@@ -0,0 +1,32 @@
+/* Formatted output to strings.
+ Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistdio.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#define VSPRINTF ulc_vsprintf
+#define VASNPRINTF ulc_vasnprintf
+#define FCHAR_T char
+#define DCHAR_T char
+#include "u-vsprintf.h"