annotate intl/log.c @ 1780:be1de1dd7262 trunk

[svn] - implement [skin.hints:mainwinVisWidth] property.
author nenolod
date Wed, 04 Oct 2006 03:39:41 -0700
parents 705d4c089fce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* Log file output.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 Copyright (C) 2003 Free Software Foundation, Inc.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify it
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 under the terms of the GNU Library General Public License as published
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 by the Free Software Foundation; either version 2, or (at your option)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 Library General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 You should have received a copy of the GNU Library General Public
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 License along with this program; if not, write to the Free Software
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 USA. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 /* Written by Bruno Haible <bruno@clisp.org>. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 # include <config.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 /* Print an ASCII string with quotes and escape sequences where needed. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 print_escaped (stream, str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 FILE *stream;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 const char *str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 putc ('"', stream);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 for (; *str != '\0'; str++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 if (*str == '\n')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 fputs ("\\n\"", stream);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 if (str[1] == '\0')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 fputs ("\n\"", stream);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 if (*str == '"' || *str == '\\')
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 putc ('\\', stream);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 putc (*str, stream);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 putc ('"', stream);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 /* Add to the log file an entry denoting a failed translation. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 _nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 const char *logfilename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 const char *domainname;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 const char *msgid1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 const char *msgid2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 int plural;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 static char *last_logfilename = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 static FILE *last_logfile = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 FILE *logfile;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 /* Can we reuse the last opened logfile? */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 if (last_logfilename == NULL || strcmp (logfilename, last_logfilename) != 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 /* Close the last used logfile. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 if (last_logfilename != NULL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 if (last_logfile != NULL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 fclose (last_logfile);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 last_logfile = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 free (last_logfilename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 last_logfilename = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 /* Open the logfile. */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 last_logfilename = (char *) malloc (strlen (logfilename) + 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 if (last_logfilename == NULL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 strcpy (last_logfilename, logfilename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 last_logfile = fopen (logfilename, "a");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 if (last_logfile == NULL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 logfile = last_logfile;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 fprintf (logfile, "domain ");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 print_escaped (logfile, domainname);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 fprintf (logfile, "\nmsgid ");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 print_escaped (logfile, msgid1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 if (plural)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 fprintf (logfile, "\nmsgid_plural ");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 print_escaped (logfile, msgid2);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 fprintf (logfile, "\nmsgstr[0] \"\"\n");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 fprintf (logfile, "\nmsgstr \"\"\n");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 putc ('\n', logfile);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 }