ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/numeric.c
(Generate patch)

Comparing:
ircd-hybrid/trunk/src/numeric.c (file contents), Revision 1618 by michael, Tue Oct 30 21:04:38 2012 UTC vs.
ircd-hybrid/branches/8.2.x/src/numeric.c (file contents), Revision 7376 by michael, Sun Feb 28 17:36:55 2016 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  numeric.c: Numeric handling functions.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2002 by the past and present ircd coders, and others.
4 > *  Copyright (c) 1997-2016 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 16 | Line 15
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program; if not, write to the Free Software
18 < *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 > *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19   *  USA
21 *
22 *  $Id$
20   */
21  
22 < #include "stdinc.h"
22 > /*! \file numeric.c
23 > * \brief Declarations of numeric replies.
24 > * \version $Id$
25 > */
26  
27 + #include "stdinc.h"
28   #include "numeric.h"
28 #include "irc_string.h"
29 #include "memory.h"
30 #include "log.h"
31 #include "send.h"
32 #include "client.h"
33 #include "messages.tab"
29  
30 < static char used_locale[LOCALE_LENGTH] = "standard";
30 >
31 > static const char *const replies[] =
32 > {
33 >  /* 001 */  [RPL_WELCOME] = ":Welcome to the %s Internet Relay Chat Network %s",
34 >  /* 002 */  [RPL_YOURHOST] = ":Your host is %s, running version %s",
35 >  /* 003 */  [RPL_CREATED] = ":This server was created %s",
36 >  /* 004 */  [RPL_MYINFO] = "%s %s %s bchiklmnoprstveCIMORST bkloveIh",
37 >  /* 005 */  [RPL_ISUPPORT] = "%s :are supported by this server",
38 >  /* 010 */  [RPL_REDIR] = "%s %u :Please use this Server/Port instead",
39 >  /* 015 */  [RPL_MAP] = ":%s%s",
40 >  /* 016 */  [RPL_MAPMORE] = ":%s%s --> *more*",
41 >  /* 017 */  [RPL_MAPEND] = ":End of /MAP",
42 >  /* 200 */  [RPL_TRACELINK] = "Link %s %s %s",
43 >  /* 201 */  [RPL_TRACECONNECTING] = "Try. %s %s",
44 >  /* 202 */  [RPL_TRACEHANDSHAKE] = "H.S. %s %s",
45 >  /* 203 */  [RPL_TRACEUNKNOWN] = "???? %s %s (%s) %ju",
46 >  /* 204 */  [RPL_TRACEOPERATOR] = "Oper %s %s (%s) %ju %u",
47 >  /* 205 */  [RPL_TRACEUSER] = "User %s %s (%s) %ju %u",
48 >  /* 206 */  [RPL_TRACESERVER] = "Serv %s %uS %uC %s %s!%s@%s %ju",
49 >  /* 208 */  [RPL_TRACENEWTYPE] = "<newtype> 0 %s",
50 >  /* 209 */  [RPL_TRACECLASS] = "Class %s %u",
51 >  /* 211 */  [RPL_STATSLINKINFO] = "%s %u %u %ju %u %ju :%u %u %s",
52 >  /* 212 */  [RPL_STATSCOMMANDS] = "%s %u %ju :%u",
53 >  /* 213 */  [RPL_STATSCLINE] = "%c %s %s %s %u %s",
54 >  /* 215 */  [RPL_STATSILINE] = "%c %s * %s@%s %u %s",
55 >  /* 216 */  [RPL_STATSKLINE] = "%c %s * %s :%s",
56 >  /* 217 */  [RPL_STATSQLINE] = "%c %s :%s",
57 >  /* 218 */  [RPL_STATSYLINE] = "%c %s %u %u %u %u %u %u %u/%u %u/%u %s",
58 >  /* 219 */  [RPL_ENDOFSTATS] = "%c :End of /STATS report",
59 >  /* 220 */  [RPL_STATSPLINE] = "%c %d %s %d %s :%s",
60 >  /* 221 */  [RPL_UMODEIS] = "%s",
61 >  /* 225 */  [RPL_STATSDLINE] = "%c %s :%s",
62 >  /* 226 */  [RPL_STATSALINE] = "%s",
63 >  /* 241 */  [RPL_STATSLLINE] = "%c %s * %s %u %s",
64 >  /* 242 */  [RPL_STATSUPTIME] = ":Server Up %s",
65 >  /* 243 */  [RPL_STATSOLINE] = "%c %s@%s * %s %s %s",
66 >  /* 244 */  [RPL_STATSHLINE] = "%c %s * %s %u %s",
67 >  /* 245 */  [RPL_STATSTLINE] = "T %s %s",
68 >  /* 246 */  [RPL_STATSSERVICE] = "%c %s * %s %u %u",
69 >  /* 247 */  [RPL_STATSXLINE] = "%c %s :%s",
70 >  /* 248 */  [RPL_STATSULINE] = "U %s %s@%s %s",
71 >  /* 250 */  [RPL_STATSCONN] = ":Highest connection count: %u (%u clients) (%ju connections received)",
72 >  /* 251 */  [RPL_LUSERCLIENT] = ":There are %u users and %u invisible on %u servers",
73 >  /* 252 */  [RPL_LUSEROP] = "%u :IRC Operators online",
74 >  /* 253 */  [RPL_LUSERUNKNOWN] = "%u :unknown connection(s)",
75 >  /* 254 */  [RPL_LUSERCHANNELS] = "%u :channels formed",
76 >  /* 255 */  [RPL_LUSERME] = ":I have %u clients and %u servers",
77 >  /* 256 */  [RPL_ADMINME] = ":Administrative info about %s",
78 >  /* 257 */  [RPL_ADMINLOC1] = ":%s",
79 >  /* 258 */  [RPL_ADMINLOC2] = ":%s",
80 >  /* 259 */  [RPL_ADMINEMAIL] = ":%s",
81 >  /* 262 */  [RPL_TRACEEND] = "%s :End of TRACE",
82 >  /* 263 */  [RPL_LOAD2HI] = "%s :Server load is temporarily too heavy. Please wait a while and try again.",
83 >  /* 265 */  [RPL_LOCALUSERS] = ":Current local users: %u  Max: %u",
84 >  /* 266 */  [RPL_GLOBALUSERS] = ":Current global users: %u  Max: %u",
85 >  /* 276 */  [RPL_WHOISCERTFP] = "%s :has client certificate fingerprint %s",
86 >  /* 281 */  [RPL_ACCEPTLIST] = ":%s",
87 >  /* 282 */  [RPL_ENDOFACCEPT] = ":End of /ACCEPT list.",
88 >  /* 301 */  [RPL_AWAY] = "%s :%s",
89 >  /* 302 */  [RPL_USERHOST] = ":%s 302 %s :%s",
90 >  /* 303 */  [RPL_ISON] = ":%s 303 %s :",
91 >  /* 305 */  [RPL_UNAWAY] = ":You are no longer marked as being away",
92 >  /* 306 */  [RPL_NOWAWAY] = ":You have been marked as being away",
93 >  /* 307 */  [RPL_WHOISREGNICK] = "%s :has identified for this nick",
94 >  /* 311 */  [RPL_WHOISUSER] = "%s %s %s * :%s",
95 >  /* 312 */  [RPL_WHOISSERVER] = "%s %s :%s",
96 >  /* 313 */  [RPL_WHOISOPERATOR] = "%s :%s",
97 >  /* 314 */  [RPL_WHOWASUSER] = "%s %s %s * :%s",
98 >  /* 315 */  [RPL_ENDOFWHO] = "%s :End of /WHO list.",
99 >  /* 317 */  [RPL_WHOISIDLE] = "%s %u %ju :seconds idle, signon time",
100 >  /* 318 */  [RPL_ENDOFWHOIS] = "%s :End of /WHOIS list.",
101 >  /* 319 */  [RPL_WHOISCHANNELS] = ":%s 319 %s %s :%s",
102 >  /* 321 */  [RPL_LISTSTART] = "Channel :Users  Name",
103 >  /* 322 */  [RPL_LIST] = "%s %u :%s%s",
104 >  /* 323 */  [RPL_LISTEND] = ":End of /LIST",
105 >  /* 324 */  [RPL_CHANNELMODEIS] = "%s %s %s",
106 >  /* 329 */  [RPL_CREATIONTIME] = "%s %ju",
107 >  /* 330 */  [RPL_WHOISACCOUNT] = "%s %s :%s logged in as",
108 >  /* 331 */  [RPL_NOTOPIC] = "%s :No topic is set.",
109 >  /* 332 */  [RPL_TOPIC] = "%s :%s",
110 >  /* 333 */  [RPL_TOPICWHOTIME] = "%s %s %ju",
111 >  /* 335 */  [RPL_WHOISTEXT] = "%s :%s",
112 >  /* 336 */  [RPL_INVITELIST] = ":%s",
113 >  /* 337 */  [RPL_ENDOFINVITELIST] = ":End of /INVITE list.",
114 >  /* 338 */  [RPL_WHOISACTUALLY] = "%s %s@%s %s :Actual user@host, actual IP",
115 >  /* 341 */  [RPL_INVITING] = "%s %s",
116 >  /* 346 */  [RPL_INVEXLIST] = "%s %s!%s@%s %s %ju",
117 >  /* 347 */  [RPL_ENDOFINVEXLIST] = "%s :End of Channel Invite List",
118 >  /* 348 */  [RPL_EXCEPTLIST] = "%s %s!%s@%s %s %ju",
119 >  /* 349 */  [RPL_ENDOFEXCEPTLIST] = "%s :End of Channel Exception List",
120 >  /* 351 */  [RPL_VERSION] = "%s(%s). %s :%s",
121 >  /* 352 */  [RPL_WHOREPLY] = "%s %s %s %s %s %s :%u %s",
122 >  /* 353 */  [RPL_NAMREPLY] = ":%s 353 %s %s %s :",
123 >  /* 362 */  [RPL_CLOSING] = "%s :Closed. Status = %u",
124 >  /* 363 */  [RPL_CLOSEEND] = "%u: Connections closed",
125 >  /* 364 */  [RPL_LINKS] = "%s %s :%u %s",
126 >  /* 365 */  [RPL_ENDOFLINKS] = "%s :End of /LINKS list.",
127 >  /* 366 */  [RPL_ENDOFNAMES] = "%s :End of /NAMES list.",
128 >  /* 367 */  [RPL_BANLIST] = "%s %s!%s@%s %s %ju",
129 >  /* 368 */  [RPL_ENDOFBANLIST] = "%s :End of Channel Ban List",
130 >  /* 369 */  [RPL_ENDOFWHOWAS] = "%s :End of WHOWAS",
131 >  /* 371 */  [RPL_INFO] = ":%s",
132 >  /* 372 */  [RPL_MOTD] = ":- %s",
133 >  /* 373 */  [RPL_INFOSTART] = ":Server INFO",
134 >  /* 374 */  [RPL_ENDOFINFO] = ":End of /INFO list.",
135 >  /* 375 */  [RPL_MOTDSTART] = ":- %s Message of the Day - ",
136 >  /* 376 */  [RPL_ENDOFMOTD] = ":End of /MOTD command.",
137 >  /* 379 */  [RPL_WHOISMODES] = "%s :is using modes %s",
138 >  /* 381 */  [RPL_YOUREOPER] = ":You are now an IRC operator",
139 >  /* 382 */  [RPL_REHASHING] = "%s :Rehashing",
140 >  /* 391 */  [RPL_TIME] = "%s :%s",
141 >  /* 396 */  [RPL_VISIBLEHOST] = "%s :is now your visible host",
142 >  /* 401 */  [ERR_NOSUCHNICK] = "%s :No such nick/channel",
143 >  /* 402 */  [ERR_NOSUCHSERVER] = "%s :No such server",
144 >  /* 403 */  [ERR_NOSUCHCHANNEL] = "%s :No such channel",
145 >  /* 404 */  [ERR_CANNOTSENDTOCHAN] = "%s :Cannot send to channel",
146 >  /* 405 */  [ERR_TOOMANYCHANNELS] = "%s :You have joined too many channels",
147 >  /* 406 */  [ERR_WASNOSUCHNICK] = "%s :There was no such nickname",
148 >  /* 407 */  [ERR_TOOMANYTARGETS] = "%s :Too many recipients. Only %u processed",
149 >  /* 408 */  [ERR_NOCTRLSONCHAN] = "%s :You cannot use control codes on this channel. Not sent: %s",
150 >  /* 409 */  [ERR_NOORIGIN] = ":No origin specified",
151 >  /* 410 */  [ERR_INVALIDCAPCMD] = "%s :Invalid CAP subcommand",
152 >  /* 411 */  [ERR_NORECIPIENT] = ":No recipient given (%s)",
153 >  /* 412 */  [ERR_NOTEXTTOSEND] = ":No text to send",
154 >  /* 413 */  [ERR_NOTOPLEVEL] = "%s :No top-level domain specified",
155 >  /* 414 */  [ERR_WILDTOPLEVEL] = "%s :Wildcard in top-level domain",
156 >  /* 421 */  [ERR_UNKNOWNCOMMAND] = "%s :Unknown command",
157 >  /* 422 */  [ERR_NOMOTD] = ":MOTD File is missing",
158 >  /* 423 */  [ERR_NOADMININFO] = "%s :No administrative info available",
159 >  /* 429 */  [ERR_TOOMANYAWAY] = ":Too many aways - Flood protection activated",
160 >  /* 431 */  [ERR_NONICKNAMEGIVEN] = ":No nickname given",
161 >  /* 432 */  [ERR_ERRONEUSNICKNAME] = "%s :%s",
162 >  /* 433 */  [ERR_NICKNAMEINUSE] = "%s :Nickname is already in use.",
163 >  /* 436 */  [ERR_NICKCOLLISION] = "%s :Nickname collision KILL",
164 >  /* 438 */  [ERR_NICKTOOFAST] = "%s :Nick change too fast. Please wait %u seconds.",
165 >  /* 440 */  [ERR_SERVICESDOWN] = "%s :Services are currently unavailable.",
166 >  /* 441 */  [ERR_USERNOTINCHANNEL] = "%s %s :They aren't on that channel",
167 >  /* 442 */  [ERR_NOTONCHANNEL] = "%s :You are not on that channel",
168 >  /* 443 */  [ERR_USERONCHANNEL] = "%s %s :is already on channel",
169 >  /* 451 */  [ERR_NOTREGISTERED] = ":You have not registered",
170 >  /* 456 */  [ERR_ACCEPTFULL] = ":Accept list is full",
171 >  /* 457 */  [ERR_ACCEPTEXIST] = "%s!%s@%s :is already on your accept list",
172 >  /* 458 */  [ERR_ACCEPTNOT] = "%s!%s@%s :is not on your accept list",
173 >  /* 461 */  [ERR_NEEDMOREPARAMS] = "%s :Not enough parameters",
174 >  /* 462 */  [ERR_ALREADYREGISTRED] = ":You may not reregister",
175 >  /* 464 */  [ERR_PASSWDMISMATCH] = ":Password incorrect",
176 >  /* 465 */  [ERR_YOUREBANNEDCREEP] = ":You are banned from this server- %s",
177 >  /* 468 */  [ERR_ONLYSERVERSCANCHANGE] = "%s :Only servers can change that mode",
178 >  /* 471 */  [ERR_CHANNELISFULL] = "%s :Cannot join channel (+l)",
179 >  /* 472 */  [ERR_UNKNOWNMODE] = "%c :is unknown mode char to me",
180 >  /* 473 */  [ERR_INVITEONLYCHAN] = "%s :Cannot join channel (+i)",
181 >  /* 474 */  [ERR_BANNEDFROMCHAN] = "%s :Cannot join channel (+b)",
182 >  /* 475 */  [ERR_BADCHANNELKEY] = "%s :Cannot join channel (+k)",
183 >  /* 477 */  [ERR_NEEDREGGEDNICK] = "%s :You need to identify to a registered nick to join or speak in that channel.",
184 >  /* 478 */  [ERR_BANLISTFULL] = "%s %s :Channel ban list is full",
185 >  /* 479 */  [ERR_BADCHANNAME] = "%s :Illegal channel name",
186 >  /* 481 */  [ERR_NOPRIVILEGES] = ":Permission denied - You are not an IRC operator",
187 >  /* 482 */  [ERR_CHANOPRIVSNEEDED] = "%s :You are not channel operator",
188 >  /* 483 */  [ERR_CANTKILLSERVER] = ":You cannot kill a server!",
189 >  /* 485 */  [ERR_CHANBANREASON] = "%s :Cannot join channel (%s)",
190 >  /* 486 */  [ERR_NONONREG] = "%s :You must identify to a registered nick to private message that person",
191 >  /* 489 */  [ERR_SSLONLYCHAN] = "%s :Cannot join channel (+S)",
192 >  /* 491 */  [ERR_NOOPERHOST] = ":Only few of mere mortals may try to enter the twilight zone",
193 >  /* 492 */  [ERR_NOCTCP] = "%s :You cannot send CTCPs to this channel. Not sent: %s",
194 >  /* 501 */  [ERR_UMODEUNKNOWNFLAG] = ":Unknown MODE flag",
195 >  /* 502 */  [ERR_USERSDONTMATCH] = ":Cannot change mode for other users",
196 >  /* 504 */  [ERR_USERNOTONSERV] = "%s :User is not on this server",
197 >  /* 512 */  [ERR_TOOMANYWATCH] = "%s :Maximum size for WATCH-list is %u entries",
198 >  /* 513 */  [ERR_WRONGPONG] = ":To connect type /QUOTE PONG %u",
199 >  /* 520 */  [ERR_OPERONLYCHAN] = "%s :Cannot join channel (+O)",
200 >  /* 521 */  [ERR_LISTSYNTAX] = ":Bad list syntax, type /QUOTE HELP LIST",
201 >  /* 523 */  [ERR_WHOLIMEXCEED] = "%u :%s search limit exceeded.",
202 >  /* 524 */  [ERR_HELPNOTFOUND] = "%s :Help not found",
203 >  /* 600 */  [RPL_LOGON] = "%s %s %s %ju :logged online",
204 >  /* 601 */  [RPL_LOGOFF] = "%s %s %s %ju :logged offline",
205 >  /* 602 */  [RPL_WATCHOFF] = "%s %s %s %ju :stopped watching",
206 >  /* 603 */  [RPL_WATCHSTAT] = ":You have %u and are on %u WATCH entries",
207 >  /* 604 */  [RPL_NOWON] = "%s %s %s %ju :is online",
208 >  /* 605 */  [RPL_NOWOFF] = "%s %s %s %ju :is offline",
209 >  /* 606 */  [RPL_WATCHLIST] = ":%s",
210 >  /* 607 */  [RPL_ENDOFWATCHLIST] = ":End of WATCH %c",
211 >  /* 671 */  [RPL_WHOISSECURE] = "%s :is connected via SSL (secure link)",
212 >  /* 702 */  [RPL_MODLIST] = "%s %p %s %s",
213 >  /* 703 */  [RPL_ENDOFMODLIST] = ":End of /MODULE LIST.",
214 >  /* 704 */  [RPL_HELPSTART] = "%s :%s",
215 >  /* 705 */  [RPL_HELPTXT] = "%s :%s",
216 >  /* 706 */  [RPL_ENDOFHELP] = "%s :End of /HELP.",
217 >  /* 709 */  [RPL_ETRACE] = "%s %s %s %s %s %s :%s",
218 >  /* 710 */  [RPL_KNOCK] = "%s %s!%s@%s :has asked for an invite.",
219 >  /* 711 */  [RPL_KNOCKDLVR] = "%s :Your KNOCK has been delivered.",
220 >  /* 712 */  [ERR_TOOMANYKNOCK] = "%s :Too many KNOCKs (%s).",
221 >  /* 713 */  [ERR_CHANOPEN] = "%s :Channel is open.",
222 >  /* 714 */  [ERR_KNOCKONCHAN] = "%s :You are already on that channel.",
223 >  /* 715 */  [ERR_TOOMANYINVITE] = "%s :Too many INVITEs (%s).",
224 >  /* 716 */  [RPL_TARGUMODEG] = "%s :is in %s mode (%s)",
225 >  /* 717 */  [RPL_TARGNOTIFY] = "%s :has been informed that you messaged them.",
226 >  /* 718 */  [RPL_UMODEGMSG] = "%s %s@%s :is messaging you, and you are umode %s.",
227 >  /* 723 */  [ERR_NOPRIVS] = "%s :Insufficient oper privileges.",
228 >  /* 999 */  [ERR_LAST_ERR_MSG] = ":Last error message"
229 > };
230  
231   /*
232 < * form_str
232 > * numeric_form
233   *
234 < * inputs       - numeric
235 < * output       - corresponding string
236 < * side effects - NONE
234 > * inputs       - numeric
235 > * output       - corresponding string
236 > * side effects - NONE
237   */
238 < const char* form_str(int numeric)
238 > const char *
239 > numeric_form(enum irc_numerics numeric)
240   {
46  assert(-1 < numeric);
241    assert(numeric < ERR_LAST_ERR_MSG);
242  
243    if (numeric > ERR_LAST_ERR_MSG)
244      numeric = ERR_LAST_ERR_MSG;
51  if (numeric < 0)
52    numeric = ERR_LAST_ERR_MSG;
245  
246 <  assert(replies[numeric].standard != NULL);
55 <
56 <  return (replies[numeric].translated != NULL ? replies[numeric].translated :
57 <                                                replies[numeric].standard);
58 < }
246 >  assert(replies[numeric]);
247  
248 < /* Attempts to change a numeric with index "reply" to "new_reply".
61 < * Returns 1 if ok, 0 otherwise.
62 < */
63 < static int
64 < change_reply(const char *locale, int linecnt, int reply, char *new_reply)
65 < {
66 <  int found;
67 <  char *new = new_reply;
68 <  const char *old = replies[reply].standard;
69 <
70 <  for (; *new; new++)
71 <  {
72 <    if (*new == '%')
73 <    {
74 <      if (!*++new) break;
75 <      if (*new != '%')
76 <      {
77 <        /* We've just found a format symbol. Check if it is the next format
78 <         * symbol in the original reply.
79 <         */
80 <        for (; *new >= '0' && *new <= '9'; new++); /* skip size prefix */
81 <        found = 0;
82 <        for (; *old; old++)
83 <        {
84 <          if (*old == '%')
85 <          {
86 <            if (!*++old) break;  /* shouldn't happen */
87 <            if (*old != '%')
88 <            {
89 <              for (; *old >= '0' && *old <= '9'; old++); /* skip size prefix */
90 <              if (*new != *old++)
91 <              {
92 <                ilog(LOG_TYPE_IRCD, "Incompatible format symbols (%s.lang, %d)",
93 <                     locale, linecnt);
94 <                return 0;
95 <              }
96 <              found = 1;
97 <              break;
98 <            }
99 <          }
100 <        }
101 <        if (!found)
102 <        {
103 <          ilog(LOG_TYPE_IRCD, "Too many format symbols (%s.lang, %d)", locale, linecnt);
104 <          return(0);
105 <        }
106 <      }
107 <    }
108 <  }
109 <
110 <  MyFree(replies[reply].translated);
111 <  DupString(replies[reply].translated, new_reply);
112 <  return(1);
113 < }
114 <
115 < /* Loads a language file. Errors are logged into the log file. */
116 < void
117 < set_locale(const char *locale)
118 < {
119 <  int i, res = 1, linecnt = 0;
120 <  char buffer[IRCD_BUFSIZE + 1];
121 <  char *ident, *reply;
122 <  FILE *f;
123 <
124 <  /* Restore standard replies */
125 <  for (i = 0; i <= ERR_LAST_ERR_MSG; i++)   /* 0 isn't a magic number! ;> */
126 <  {
127 <    if (replies[i].translated != NULL)
128 <    {
129 <      MyFree(replies[i].translated);
130 <      replies[i].translated = NULL;
131 <    }
132 <  }
133 <
134 <  if (strchr(locale, '/') != NULL)
135 <  {
136 <    strlcpy(used_locale, "standard", sizeof(used_locale));  /* XXX paranoid */
137 <    return;
138 <  }
139 <
140 <  /* yes, I know - the slash isn't necessary. But I have to be sure
141 <   * that it'll work even if some lame admin won't put "/" at the end
142 <   * of MSGPATH.
143 <   */
144 <  snprintf(buffer, sizeof(buffer), "%s/%s.lang", MSGPATH, locale);
145 <  if ((f = fopen(buffer, "r")) == NULL)
146 <  {
147 <    strlcpy(used_locale, "standard", sizeof(used_locale));  /* XXX */
148 <    return;
149 <  }
150 <
151 <  /* Process the language file */
152 <  while (fgets(buffer, sizeof(buffer), f))
153 <  {
154 <    ++linecnt;
155 <    if (buffer[0] == ';')
156 <      continue;   /* that's a comment */
157 <
158 <    if ((ident = strpbrk(buffer, "\r\n")) != NULL)
159 <      *ident = '\0';
160 <
161 <    /* skip spaces if there are any */
162 <    for (ident = buffer; *ident == ' ' || *ident == '\t'; ident++)/* null */;
163 <    if (*ident == '\0')
164 <      continue;            /* empty line */
165 <
166 <    /* skip after the reply identificator */
167 <    for (reply = ident; *reply != ' ' && *reply != '\t' && *reply != ':';
168 <      reply++)
169 <      if (*reply == '\0') goto error;
170 <
171 <    if (*reply == ' ' || *reply == '\t')
172 <    {
173 <      for (*reply++ = '\0'; *reply == ' ' || *reply == '\t'; reply++);
174 <      if (*reply != ':')
175 <      {
176 <        error:
177 <        ilog(LOG_TYPE_IRCD, "Invalid line in language file (%s.lang, %d)",
178 <             locale, linecnt);
179 <        res = 0;
180 <        continue;
181 <      }
182 <    }
183 <    else
184 <      *reply++ = '\0';
185 <    if (*ident == '\0')
186 <      goto error;
187 <
188 <    /* skip to the beginning of reply */
189 <    while (*reply == ' ' || *reply == '\t') reply++;
190 <    if (*reply == '\0')
191 <      goto error;
192 <
193 <    for (i = 0; i <= ERR_LAST_ERR_MSG; i++)
194 <    {
195 <      if (replies[i].name != NULL)
196 <      {
197 <        if (irccmp(replies[i].name, ident) == 0)
198 <        {
199 <          if (!change_reply(locale, linecnt, i, reply)) res = 0;
200 <          i = -1;
201 <          break;
202 <        }
203 <      }
204 <    }
205 <    if (i != -1)
206 <    {
207 <      ilog(LOG_TYPE_IRCD,
208 <           "Unknown numeric %s (%s.lang, %d)", ident, locale, linecnt);
209 <      res = 0;
210 <    }
211 <  }
212 <  fclose(f);
213 <
214 <  strlcpy(used_locale, locale, sizeof(used_locale));
215 <  if (!res)
216 <    sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
217 <                         "Language file [%s] contains "
218 <                         "errors, check server log file for more details",
219 <                         used_locale);
220 < }
221 <
222 < /* Returns the name of current locale. */
223 < const char *
224 < get_locale(void)
225 < {
226 <  return used_locale;
248 >  return replies[numeric];
249   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)