]> Dogcows Code - chaz/tar/commitdiff
Initial revision
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Sep 2001 00:27:39 +0000 (00:27 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 14 Sep 2001 00:27:39 +0000 (00:27 +0000)
lib/print-copyr.c [new file with mode: 0644]
lib/print-copyr.h [new file with mode: 0644]

diff --git a/lib/print-copyr.c b/lib/print-copyr.c
new file mode 100644 (file)
index 0000000..1ec02ef
--- /dev/null
@@ -0,0 +1,73 @@
+/* copysym.c -- Return a copyright symbol suitable for the current locale.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* Written by Paul Eggert.  */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if HAVE_ICONV
+# include <iconv.h>
+
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+
+#include "copysym.h"
+
+/* Store into BUF (of size BUFSIZE) a representation of the copyright
+   symbol (C-in-a-circle) that is a valid text string for the current
+   locale.  Return BUF if successful, and a pointer to some other
+   string otherwise.  */
+
+char const *
+copyright_symbol (char *buf, size_t bufsize)
+{
+#if HAVE_ICONV
+  char const *outcharset = getenv ("OUTPUT_CHARSET");
+
+  if (! (outcharset && *outcharset))
+    {
+      extern char const *locale_charset (void);
+      outcharset = locale_charset ();
+    }
+
+  if (*outcharset)
+    {
+      iconv_t conv = iconv_open (outcharset, "UTF-8");
+
+      if (conv != (iconv_t) -1)
+       {
+         static char const copyright_utf_8[] = "\302\251";
+         char ICONV_CONST *inptr = (char ICONV_CONST *) &copyright_utf_8;
+         size_t inleft = sizeof copyright_utf_8;
+         char *outptr = buf;
+         size_t chars = iconv (conv, &inptr, &inleft, &outptr, &bufsize);
+
+         iconv_close (conv);
+
+         if (chars != (size_t) -1)
+           return buf;
+       }
+    }
+#endif
+
+  /* "(C)" is the best we can do in ASCII.  */
+  return "(C)";
+}
diff --git a/lib/print-copyr.h b/lib/print-copyr.h
new file mode 100644 (file)
index 0000000..9334997
--- /dev/null
@@ -0,0 +1,9 @@
+# ifndef PARAMS
+#  if PROTOTYPES || (defined (__STDC__) && __STDC__)
+#   define PARAMS(args) args
+#  else
+#   define PARAMS(args) ()
+#  endif
+# endif
+
+char const *copyright_symbol PARAMS((char *, size_t));
This page took 0.023918 seconds and 4 git commands to generate.