annotate intl/bindtextdom.c @ 523:023c3851db0a

[gaim-migrate @ 533] fixed some html stuff committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 25 Jul 2000 05:09:14 +0000
parents d64101dc5c7e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
347
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* Implementation of the bindtextdomain(3) function
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 the Free Software Foundation; either version 2, or (at your option)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 any later version.
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 GNU General Public License for more details.
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 along with this program; if not, write to the Free Software Foundation,
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 #ifdef HAVE_CONFIG_H
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 # include <config.h>
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #if defined STDC_HEADERS || defined _LIBC
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 # include <stdlib.h>
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 # ifdef HAVE_MALLOC_H
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 # include <malloc.h>
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 # else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 void free ();
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 # endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #if defined HAVE_STRING_H || defined _LIBC
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 # include <string.h>
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 # include <strings.h>
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 # ifndef memcpy
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 # define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 # endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #ifdef _LIBC
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 # include <libintl.h>
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 # include "libgettext.h"
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include "gettext.h"
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include "gettextP.h"
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 /* @@ end of prolog @@ */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 /* Contains the default location of the message catalogs. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 extern const char _nl_default_dirname[];
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 /* List with bindings of specific domains. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 extern struct binding *_nl_domain_bindings;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 /* Names for the libintl functions are a problem. They must not clash
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 with existing names and they should follow ANSI C. But this source
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 code is also used in GNU C Library where the names have a __
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 prefix. So we have to make a difference here. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 #ifdef _LIBC
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 # define BINDTEXTDOMAIN __bindtextdomain
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 # ifndef strdup
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 # define strdup(str) __strdup (str)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 # endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 #else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 # define BINDTEXTDOMAIN bindtextdomain__
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 /* Specify that the DOMAINNAME message catalog will be found
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 in DIRNAME rather than in the system locale data base. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 char *
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 BINDTEXTDOMAIN (domainname, dirname)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 const char *domainname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 const char *dirname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 struct binding *binding;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 /* Some sanity checks. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 if (domainname == NULL || domainname[0] == '\0')
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 int compare = strcmp (domainname, binding->domainname);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 if (compare == 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 /* We found it! */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 break;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 if (compare < 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 /* It is not in the list. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 binding = NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 break;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 if (dirname == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 /* The current binding has be to returned. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 return binding == NULL ? (char *) _nl_default_dirname : binding->dirname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 if (binding != NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 /* The domain is already bound. If the new value and the old
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 one are equal we simply do nothing. Otherwise replace the
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 old binding. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 if (strcmp (dirname, binding->dirname) != 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 char *new_dirname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 if (strcmp (dirname, _nl_default_dirname) == 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 new_dirname = (char *) _nl_default_dirname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 #if defined _LIBC || defined HAVE_STRDUP
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 new_dirname = strdup (dirname);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 if (new_dirname == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 #else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 size_t len = strlen (dirname) + 1;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 new_dirname = (char *) malloc (len);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 if (new_dirname == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 memcpy (new_dirname, dirname, len);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 if (binding->dirname != _nl_default_dirname)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 free (binding->dirname);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 binding->dirname = new_dirname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 /* We have to create a new binding. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 #if !defined _LIBC && !defined HAVE_STRDUP
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 size_t len;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 struct binding *new_binding =
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 (struct binding *) malloc (sizeof (*new_binding));
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 if (new_binding == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 #if defined _LIBC || defined HAVE_STRDUP
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 new_binding->domainname = strdup (domainname);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 if (new_binding->domainname == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 #else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 len = strlen (domainname) + 1;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 new_binding->domainname = (char *) malloc (len);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 if (new_binding->domainname == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 memcpy (new_binding->domainname, domainname, len);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 if (strcmp (dirname, _nl_default_dirname) == 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 new_binding->dirname = (char *) _nl_default_dirname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 #if defined _LIBC || defined HAVE_STRDUP
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 new_binding->dirname = strdup (dirname);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 if (new_binding->dirname == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 #else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 len = strlen (dirname) + 1;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 new_binding->dirname = (char *) malloc (len);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 if (new_binding->dirname == NULL)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 return NULL;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 memcpy (new_binding->dirname, dirname, len);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 #endif
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 /* Now enqueue it. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 if (_nl_domain_bindings == NULL
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 || strcmp (domainname, _nl_domain_bindings->domainname) < 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 new_binding->next = _nl_domain_bindings;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 _nl_domain_bindings = new_binding;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 else
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 {
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 binding = _nl_domain_bindings;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 while (binding->next != NULL
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 && strcmp (domainname, binding->next->domainname) > 0)
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 binding = binding->next;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 new_binding->next = binding->next;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 binding->next = new_binding;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 binding = new_binding;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 return binding->dirname;
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 }
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 #ifdef _LIBC
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 /* Alias for function name in GNU C Library. */
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 weak_alias (__bindtextdomain, bindtextdomain);
d64101dc5c7e [gaim-migrate @ 357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 #endif