summaryrefslogtreecommitdiff
path: root/cups/langprintf.c
diff options
context:
space:
mode:
authorjlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be>2006-01-13 01:51:53 +0000
committerjlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be>2006-01-13 01:51:53 +0000
commitef416fc25c4af449e930416117bedb12fc9924ba (patch)
tree11f8aa8c5d3565a17d4a6d5121d3edba22e2a21e /cups/langprintf.c
parent9ec11526e139aeacf6a052799a6aa22cbbe6ebb2 (diff)
Load cups into easysw/current.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@2 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/langprintf.c')
-rw-r--r--cups/langprintf.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/cups/langprintf.c b/cups/langprintf.c
new file mode 100644
index 000000000..5f0b40b84
--- /dev/null
+++ b/cups/langprintf.c
@@ -0,0 +1,140 @@
+/*
+ * "$Id: langprintf.c 4898 2006-01-08 23:13:20Z mike $"
+ *
+ * Localized printf/puts functions for the Common UNIX Printing
+ * System (CUPS).
+ *
+ * Copyright 2002 by Easy Software Products.
+ *
+ * These coded instructions, statements, and computer programs are the
+ * property of Easy Software Products and are protected by Federal
+ * copyright law. Distribution and use rights are outlined in the file
+ * "LICENSE.txt" which should have been included with this file. If this
+ * file is missing or damaged please contact Easy Software Products
+ * at:
+ *
+ * Attn: CUPS Licensing Information
+ * Easy Software Products
+ * 44141 Airport View Drive, Suite 204
+ * Hollywood, Maryland 20636 USA
+ *
+ * Voice: (301) 373-9600
+ * EMail: cups-info@cups.org
+ * WWW: http://www.cups.org
+ *
+ * This file is subject to the Apple OS-Developed Software exception.
+ *
+ * Contents:
+ *
+ * _cupsLangPrintf() - Print a formatted message string to a file.
+ * _cupsLangPuts() - Print a static message string to a file.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include <stdio.h>
+#include "string.h"
+#include "i18n.h"
+#include "transcode.h"
+
+
+/*
+ * '_cupsLangPrintf()' - Print a formatted message string to a file.
+ */
+
+int /* O - Number of bytes written */
+_cupsLangPrintf(FILE *fp, /* I - File to write to */
+ cups_lang_t *language, /* I - Language to use */
+ const char *message, /* I - Message string to use */
+ ...) /* I - Additional arguments as needed */
+{
+ int bytes; /* Number of bytes formatted */
+ char buffer[2048], /* Message buffer */
+ output[8192]; /* Output buffer */
+ va_list ap; /* Pointer to additional arguments */
+
+
+ /*
+ * Range check...
+ */
+
+ if (!fp || !message)
+ return (-1);
+
+ if (!language)
+ language = cupsLangDefault();
+
+ /*
+ * Format the string...
+ */
+
+ va_start(ap, message);
+ bytes = vsnprintf(buffer, sizeof(buffer),
+ _cupsLangString(language, message), ap);
+ va_end(ap);
+
+ /*
+ * Transcode to the destination charset...
+ */
+
+ bytes = cupsUTF8ToCharset(output, (cups_utf8_t *)buffer, sizeof(output),
+ language->encoding);
+
+ /*
+ * Write the string and return the number of bytes written...
+ */
+
+ if (bytes > 0)
+ return (fwrite(output, 1, bytes, fp));
+ else
+ return (bytes);
+}
+
+
+/*
+ * '_cupsLangPuts()' - Print a static message string to a file.
+ */
+
+int /* O - Number of bytes written */
+_cupsLangPuts(FILE *fp, /* I - File to write to */
+ cups_lang_t *language, /* I - Language to use */
+ const char *message) /* I - Message string to use */
+{
+ int bytes; /* Number of bytes formatted */
+ char output[2048]; /* Message buffer */
+
+
+ /*
+ * Range check...
+ */
+
+ if (!fp || !message)
+ return (-1);
+
+ if (!language)
+ language = cupsLangDefault();
+
+ /*
+ * Transcode to the destination charset...
+ */
+
+ bytes = cupsUTF8ToCharset(output,
+ (cups_utf8_t *)_cupsLangString(language, message),
+ sizeof(output), language->encoding);
+
+ /*
+ * Write the string and return the number of bytes written...
+ */
+
+ if (bytes > 0)
+ return (fwrite(output, 1, bytes, fp));
+ else
+ return (bytes);
+}
+
+
+/*
+ * End of "$Id: langprintf.c 4898 2006-01-08 23:13:20Z mike $".
+ */