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

Comparing:
ircd-hybrid-7.2/src/numeric.c (file contents), Revision 34 by lusky, Sun Oct 2 21:05:51 2005 UTC vs.
ircd-hybrid/trunk/src/numeric.c (file contents), Revision 8923 by michael, Mon Apr 22 10:09:22 2019 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-2019 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 "common.h"     /* NULL cripes */
30 #include "memory.h"
31 #include "s_log.h"
32 #include "fileio.h"
33 #include "send.h"
34 #include "client.h"
35 #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!%s@%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 bchiklmnoprstuveCILMNORST 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 :%ju %ju %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 >  /* 227 */  [RPL_STATSPSEUDO] = "s %s %s %s@%s :%s",
64 >  /* 241 */  [RPL_STATSLLINE] = "%c %s * %s %u %s",
65 >  /* 242 */  [RPL_STATSUPTIME] = ":Server Up %s",
66 >  /* 243 */  [RPL_STATSOLINE] = "%c %s@%s * %s %s %s",
67 >  /* 244 */  [RPL_STATSHLINE] = "%c %s * %s %u %s",
68 >  /* 245 */  [RPL_STATSTLINE] = "T %s %s",
69 >  /* 246 */  [RPL_STATSSERVICE] = "S %s * %s %u %u",
70 >  /* 247 */  [RPL_STATSXLINE] = "%c %s :%s",
71 >  /* 248 */  [RPL_STATSULINE] = "U %s %s@%s %s",
72 >  /* 250 */  [RPL_STATSCONN] = ":Highest connection count: %u (%u clients) (%ju connections received)",
73 >  /* 251 */  [RPL_LUSERCLIENT] = ":There are %u users and %u invisible on %u servers",
74 >  /* 252 */  [RPL_LUSEROP] = "%u :IRC Operators online",
75 >  /* 253 */  [RPL_LUSERUNKNOWN] = "%u :unknown connection(s)",
76 >  /* 254 */  [RPL_LUSERCHANNELS] = "%u :channels formed",
77 >  /* 255 */  [RPL_LUSERME] = ":I have %u clients and %u servers",
78 >  /* 256 */  [RPL_ADMINME] = ":Administrative info about %s",
79 >  /* 257 */  [RPL_ADMINLOC1] = ":%s",
80 >  /* 258 */  [RPL_ADMINLOC2] = ":%s",
81 >  /* 259 */  [RPL_ADMINEMAIL] = ":%s",
82 >  /* 262 */  [RPL_TRACEEND] = "%s :End of TRACE",
83 >  /* 263 */  [RPL_LOAD2HI] = "%s :Server load is temporarily too heavy. Please wait a while and try again.",
84 >  /* 265 */  [RPL_LOCALUSERS] = ":Current local users: %u  Max: %u",
85 >  /* 266 */  [RPL_GLOBALUSERS] = ":Current global users: %u  Max: %u",
86 >  /* 276 */  [RPL_WHOISCERTFP] = "%s :has client certificate fingerprint %s",
87 >  /* 281 */  [RPL_ACCEPTLIST] = ":%s",
88 >  /* 282 */  [RPL_ENDOFACCEPT] = ":End of /ACCEPT list.",
89 >  /* 301 */  [RPL_AWAY] = "%s :%s",
90 >  /* 302 */  [RPL_USERHOST] = ":%s 302 %s :%s",
91 >  /* 303 */  [RPL_ISON] = ":%s 303 %s :",
92 >  /* 305 */  [RPL_UNAWAY] = ":You are no longer marked as being away",
93 >  /* 306 */  [RPL_NOWAWAY] = ":You have been marked as being away",
94 >  /* 307 */  [RPL_WHOISREGNICK] = "%s :has identified for this nick",
95 >  /* 311 */  [RPL_WHOISUSER] = "%s %s %s * :%s",
96 >  /* 312 */  [RPL_WHOISSERVER] = "%s %s :%s",
97 >  /* 313 */  [RPL_WHOISOPERATOR] = "%s :%s",
98 >  /* 314 */  [RPL_WHOWASUSER] = "%s %s %s * :%s",
99 >  /* 315 */  [RPL_ENDOFWHO] = "%s :End of /WHO list.",
100 >  /* 317 */  [RPL_WHOISIDLE] = "%s %u %ju :seconds idle, signon time",
101 >  /* 318 */  [RPL_ENDOFWHOIS] = "%s :End of /WHOIS list.",
102 >  /* 319 */  [RPL_WHOISCHANNELS] = ":%s 319 %s %s :%s",
103 >  /* 321 */  [RPL_LISTSTART] = "Channel :Users  Name",
104 >  /* 322 */  [RPL_LIST] = "%s %u :%s%s",
105 >  /* 323 */  [RPL_LISTEND] = ":End of /LIST",
106 >  /* 324 */  [RPL_CHANNELMODEIS] = "%s %s %s",
107 >  /* 329 */  [RPL_CREATIONTIME] = "%s %ju",
108 >  /* 330 */  [RPL_WHOISACCOUNT] = "%s %s :%s logged in as",
109 >  /* 331 */  [RPL_NOTOPIC] = "%s :No topic is set.",
110 >  /* 332 */  [RPL_TOPIC] = "%s :%s",
111 >  /* 333 */  [RPL_TOPICWHOTIME] = "%s %s %ju",
112 >  /* 335 */  [RPL_WHOISTEXT] = "%s :%s",
113 >  /* 336 */  [RPL_INVITELIST] = ":%s",
114 >  /* 337 */  [RPL_ENDOFINVITELIST] = ":End of /INVITE list.",
115 >  /* 338 */  [RPL_WHOISACTUALLY] = "%s %s@%s %s :Actual user@host, actual IP",
116 >  /* 341 */  [RPL_INVITING] = "%s %s",
117 >  /* 346 */  [RPL_INVEXLIST] = "%s %s!%s@%s %s %ju",
118 >  /* 347 */  [RPL_ENDOFINVEXLIST] = "%s :End of Channel Invite List",
119 >  /* 348 */  [RPL_EXCEPTLIST] = "%s %s!%s@%s %s %ju",
120 >  /* 349 */  [RPL_ENDOFEXCEPTLIST] = "%s :End of Channel Exception List",
121 >  /* 351 */  [RPL_VERSION] = "%s(%s). %s :%s",
122 >  /* 352 */  [RPL_WHOREPLY] = "%s %s %s %s %s %s :%u %s",
123 >  /* 353 */  [RPL_NAMREPLY] = ":%s 353 %s %s %s :",
124 >  /* 362 */  [RPL_CLOSING] = "%s :Closed. Status = %u",
125 >  /* 363 */  [RPL_CLOSEEND] = "%u: Connections closed",
126 >  /* 364 */  [RPL_LINKS] = "%s %s :%u %s",
127 >  /* 365 */  [RPL_ENDOFLINKS] = "%s :End of /LINKS list.",
128 >  /* 366 */  [RPL_ENDOFNAMES] = "%s :End of /NAMES list.",
129 >  /* 367 */  [RPL_BANLIST] = "%s %s!%s@%s %s %ju",
130 >  /* 368 */  [RPL_ENDOFBANLIST] = "%s :End of Channel Ban List",
131 >  /* 369 */  [RPL_ENDOFWHOWAS] = "%s :End of WHOWAS",
132 >  /* 371 */  [RPL_INFO] = ":%s",
133 >  /* 372 */  [RPL_MOTD] = ":- %s",
134 >  /* 373 */  [RPL_INFOSTART] = ":Server INFO",
135 >  /* 374 */  [RPL_ENDOFINFO] = ":End of /INFO list.",
136 >  /* 375 */  [RPL_MOTDSTART] = ":- %s Message of the Day - ",
137 >  /* 376 */  [RPL_ENDOFMOTD] = ":End of /MOTD command.",
138 >  /* 379 */  [RPL_WHOISMODES] = "%s :is using modes %s",
139 >  /* 381 */  [RPL_YOUREOPER] = ":You are now an IRC operator",
140 >  /* 382 */  [RPL_REHASHING] = "%s :Rehashing",
141 >  /* 391 */  [RPL_TIME] = "%s :%s",
142 >  /* 396 */  [RPL_VISIBLEHOST] = "%s :is now your visible host",
143 >  /* 401 */  [ERR_NOSUCHNICK] = "%s :No such nick/channel",
144 >  /* 402 */  [ERR_NOSUCHSERVER] = "%s :No such server",
145 >  /* 403 */  [ERR_NOSUCHCHANNEL] = "%s :No such channel",
146 >  /* 404 */  [ERR_CANNOTSENDTOCHAN] = "%s :Cannot send to channel",
147 >  /* 405 */  [ERR_TOOMANYCHANNELS] = "%s :You have joined too many channels",
148 >  /* 406 */  [ERR_WASNOSUCHNICK] = "%s :There was no such nickname",
149 >  /* 407 */  [ERR_TOOMANYTARGETS] = "%s :Too many recipients. Only %u processed",
150 >  /* 408 */  [ERR_NOCTRLSONCHAN] = "%s :You cannot use control codes on this channel. Not sent: %s",
151 >  /* 409 */  [ERR_NOORIGIN] = ":No origin specified",
152 >  /* 410 */  [ERR_INVALIDCAPCMD] = "%s :Invalid CAP subcommand",
153 >  /* 411 */  [ERR_NORECIPIENT] = ":No recipient given (%s)",
154 >  /* 412 */  [ERR_NOTEXTTOSEND] = ":No text to send",
155 >  /* 413 */  [ERR_NOTOPLEVEL] = "%s :No top-level domain specified",
156 >  /* 414 */  [ERR_WILDTOPLEVEL] = "%s :Wildcard in top-level domain",
157 >  /* 421 */  [ERR_UNKNOWNCOMMAND] = "%s :Unknown command",
158 >  /* 422 */  [ERR_NOMOTD] = ":MOTD File is missing",
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 >  /* 447 */  [ERR_NONICKCHANGE] = ":Cannot change nickname while on %s (+N)",
170 >  /* 451 */  [ERR_NOTREGISTERED] = ":You have not registered",
171 >  /* 456 */  [ERR_ACCEPTFULL] = ":Accept list is full",
172 >  /* 457 */  [ERR_ACCEPTEXIST] = "%s!%s@%s :is already on your accept list",
173 >  /* 458 */  [ERR_ACCEPTNOT] = "%s!%s@%s :is not on your accept list",
174 >  /* 461 */  [ERR_NEEDMOREPARAMS] = "%s :Not enough parameters",
175 >  /* 462 */  [ERR_ALREADYREGISTRED] = ":You may not reregister",
176 >  /* 464 */  [ERR_PASSWDMISMATCH] = ":Password incorrect",
177 >  /* 465 */  [ERR_YOUREBANNEDCREEP] = ":You are banned from this server- %s",
178 >  /* 468 */  [ERR_ONLYSERVERSCANCHANGE] = "%s :Only servers can change that mode",
179 >  /* 471 */  [ERR_CHANNELISFULL] = "%s :Cannot join channel (+l)",
180 >  /* 472 */  [ERR_UNKNOWNMODE] = "%c :is unknown mode char to me",
181 >  /* 473 */  [ERR_INVITEONLYCHAN] = "%s :Cannot join channel (+i)",
182 >  /* 474 */  [ERR_BANNEDFROMCHAN] = "%s :Cannot join channel (+b)",
183 >  /* 475 */  [ERR_BADCHANNELKEY] = "%s :Cannot join channel (+k)",
184 >  /* 477 */  [ERR_NEEDREGGEDNICK] = "%s :You need to identify to a registered nick to join or speak in that channel.",
185 >  /* 478 */  [ERR_BANLISTFULL] = "%s %s :Channel ban list is full",
186 >  /* 479 */  [ERR_BADCHANNAME] = "%s :Illegal channel name",
187 >  /* 481 */  [ERR_NOPRIVILEGES] = ":Permission denied - You are not an IRC operator",
188 >  /* 482 */  [ERR_CHANOPRIVSNEEDED] = "%s :You are not channel operator",
189 >  /* 483 */  [ERR_CANTKILLSERVER] = ":You cannot kill a server!",
190 >  /* 485 */  [ERR_CHANBANREASON] = "%s :Cannot join channel (%s)",
191 >  /* 486 */  [ERR_NONONREG] = "%s :You must identify to a registered nick to private message that person",
192 >  /* 489 */  [ERR_SSLONLYCHAN] = "%s :Cannot join channel (+S) - SSL/TLS required",
193 >  /* 491 */  [ERR_NOOPERHOST] = ":Only few of mere mortals may try to enter the twilight zone",
194 >  /* 492 */  [ERR_NOCTCP] = "%s :You cannot send CTCPs to this channel. Not sent: %s",
195 >  /* 501 */  [ERR_UMODEUNKNOWNFLAG] = ":Unknown MODE flag",
196 >  /* 502 */  [ERR_USERSDONTMATCH] = ":Cannot change mode for other users",
197 >  /* 504 */  [ERR_USERNOTONSERV] = "%s :User is not on this server",
198 >  /* 512 */  [ERR_TOOMANYWATCH] = "%s :Maximum size for WATCH-list is %u entries",
199 >  /* 513 */  [ERR_WRONGPONG] = ":To connect type /QUOTE PONG %u",
200 >  /* 520 */  [ERR_OPERONLYCHAN] = "%s :Cannot join channel (+O)",
201 >  /* 521 */  [ERR_LISTSYNTAX] = ":Bad list syntax, type /QUOTE HELP LIST",
202 >  /* 523 */  [ERR_WHOLIMEXCEED] = "%u :%s search limit exceeded.",
203 >  /* 524 */  [ERR_HELPNOTFOUND] = "%s :Help not found",
204 >  /* 600 */  [RPL_LOGON] = "%s %s %s %ju :logged online",
205 >  /* 601 */  [RPL_LOGOFF] = "%s %s %s %ju :logged offline",
206 >  /* 602 */  [RPL_WATCHOFF] = "%s %s %s %ju :stopped watching",
207 >  /* 603 */  [RPL_WATCHSTAT] = ":You have %u and are on %u WATCH entries",
208 >  /* 604 */  [RPL_NOWON] = "%s %s %s %ju :is online",
209 >  /* 605 */  [RPL_NOWOFF] = "%s %s %s %ju :is offline",
210 >  /* 606 */  [RPL_WATCHLIST] = ":%s",
211 >  /* 607 */  [RPL_ENDOFWATCHLIST] = ":End of WATCH %c",
212 >  /* 671 */  [RPL_WHOISSECURE] = "%s :is connected via SSL (secure link)",
213 >  /* 702 */  [RPL_MODLIST] = "%s %p %s %s",
214 >  /* 703 */  [RPL_ENDOFMODLIST] = ":End of /MODULE LIST.",
215 >  /* 704 */  [RPL_HELPSTART] = "%s :%s",
216 >  /* 705 */  [RPL_HELPTXT] = "%s :%s",
217 >  /* 706 */  [RPL_ENDOFHELP] = "%s :End of /HELP.",
218 >  /* 709 */  [RPL_ETRACE] = "%s %s %s %s %s %s :%s",
219 >  /* 710 */  [RPL_KNOCK] = "%s %s!%s@%s :has asked for an invite.",
220 >  /* 711 */  [RPL_KNOCKDLVR] = "%s :Your KNOCK has been delivered.",
221 >  /* 712 */  [ERR_TOOMANYKNOCK] = "%s :Too many KNOCKs (%s).",
222 >  /* 713 */  [ERR_CHANOPEN] = "%s :Channel is open.",
223 >  /* 714 */  [ERR_KNOCKONCHAN] = "%s :You are already on that channel.",
224 >  /* 715 */  [ERR_TOOMANYINVITE] = "%s :Too many INVITEs (%s).",
225 >  /* 716 */  [RPL_TARGUMODEG] = "%s :is in %s mode (%s)",
226 >  /* 717 */  [RPL_TARGNOTIFY] = "%s :has been informed that you messaged them.",
227 >  /* 718 */  [RPL_UMODEGMSG] = "%s %s@%s :is messaging you, and you are umode %s.",
228 >  /* 723 */  [ERR_NOPRIVS] = "%s :Insufficient oper privileges.",
229 >  /* 759 */  [RPL_ETRACEEND] = "%s :End of ETRACE",
230 >  /* 999 */  [ERR_LAST_ERR_MSG] = ":Last error message"
231 > };
232  
233   /*
234 < * form_str
234 > * numeric_form
235   *
236 < * inputs       - numeric
237 < * output       - corresponding string
238 < * side effects - NONE
236 > * inputs       - numeric
237 > * output       - corresponding string
238 > * side effects - NONE
239   */
240 < const char* form_str(int numeric)
240 > const char *
241 > numeric_form(enum irc_numerics numeric)
242   {
48  assert(-1 < numeric);
243    assert(numeric < ERR_LAST_ERR_MSG);
244  
245    if (numeric > ERR_LAST_ERR_MSG)
246      numeric = ERR_LAST_ERR_MSG;
53  if (numeric < 0)
54    numeric = ERR_LAST_ERR_MSG;
247  
248 <  assert(replies[numeric].standard != NULL);
57 <
58 <  return (replies[numeric].translated != NULL ? replies[numeric].translated :
59 <                                                replies[numeric].standard);
60 < }
248 >  assert(replies[numeric]);
249  
250 < /* Attempts to change a numeric with index "reply" to "new_reply".
63 < * Returns 1 if ok, 0 otherwise.
64 < */
65 < static int
66 < change_reply(const char *locale, int linecnt, int reply, char *new_reply)
67 < {
68 <  int found;
69 <  char *new = new_reply;
70 <  const char *old = replies[reply].standard;
71 <
72 <  for (; *new; new++)
73 <  {
74 <    if (*new == '%')
75 <    {
76 <      if (!*++new) break;
77 <      if (*new != '%')
78 <      {
79 <        /* We've just found a format symbol. Check if it is the next format
80 <         * symbol in the original reply.
81 <         */
82 <        for (; *new >= '0' && *new <= '9'; new++); /* skip size prefix */
83 <        found = 0;
84 <        for (; *old; old++)
85 <        {
86 <          if (*old == '%')
87 <          {
88 <            if (!*++old) break;  /* shouldn't happen */
89 <            if (*old != '%')
90 <            {
91 <              for (; *old >= '0' && *old <= '9'; old++); /* skip size prefix */
92 <              if (*new != *old++)
93 <              {
94 <                ilog(L_ERROR, "Incompatible format symbols (%s.lang, %d)",
95 <                              locale, linecnt);
96 <                return 0;
97 <              }
98 <              found = 1;
99 <              break;
100 <            }
101 <          }
102 <        }
103 <        if (!found)
104 <        {
105 <          ilog(L_ERROR, "Too many format symbols (%s.lang, %d)", locale, linecnt);
106 <          return(0);
107 <        }
108 <      }
109 <    }
110 <  }
111 <
112 <  MyFree(replies[reply].translated);
113 <  DupString(replies[reply].translated, new_reply);
114 <  return(1);
115 < }
116 <
117 < /* Loads a language file. Errors are logged into the log file. */
118 < void
119 < set_locale(const char *locale)
120 < {
121 <  int i, res = 1, linecnt = 0;
122 <  char buffer[IRCD_BUFSIZE + 1];
123 <  char *ident, *reply;
124 <  FBFILE *f;
125 <
126 <  /* Restore standard replies */
127 <  for (i = 0; i <= ERR_LAST_ERR_MSG; i++)   /* 0 isn't a magic number! ;> */
128 <  {
129 <    if (replies[i].translated != NULL)
130 <    {
131 <      MyFree(replies[i].translated);
132 <      replies[i].translated = NULL;
133 <    }
134 <  }
135 <
136 <  if (strchr(locale, '/') != NULL)
137 <  {
138 <    strlcpy(used_locale, "standard", sizeof(used_locale));  /* XXX paranoid */
139 <    return;
140 <  }
141 <
142 <  /* yes, I know - the slash isn't necessary. But I have to be sure
143 <   * that it'll work even if some lame admin won't put "/" at the end
144 <   * of MSGPATH.
145 <   */
146 <  snprintf(buffer, sizeof(buffer), "%s/%s.lang", MSGPATH, locale);
147 <  if ((f = fbopen(buffer, "r")) == NULL)
148 <  {
149 <    strlcpy(used_locale, "standard", sizeof(used_locale));  /* XXX */
150 <    return;
151 <  }
152 <
153 <  /* Process the language file */
154 <  while (fbgets(buffer, sizeof(buffer), f))
155 <  {
156 <    ++linecnt;
157 <    if (buffer[0] == ';')
158 <      continue;   /* that's a comment */
159 <
160 <    if ((ident = strpbrk(buffer, "\r\n")) != NULL)
161 <      *ident = '\0';
162 <
163 <    /* skip spaces if there are any */
164 <    for (ident = buffer; *ident == ' ' || *ident == '\t'; ident++)/* null */;
165 <    if (*ident == '\0')
166 <      continue;            /* empty line */
167 <
168 <    /* skip after the reply identificator */
169 <    for (reply = ident; *reply != ' ' && *reply != '\t' && *reply != ':';
170 <      reply++)
171 <      if (*reply == '\0') goto error;
172 <
173 <    if (*reply == ' ' || *reply == '\t')
174 <    {
175 <      for (*reply++ = '\0'; *reply == ' ' || *reply == '\t'; reply++);
176 <      if (*reply != ':')
177 <      {
178 <        error:
179 <        ilog(L_ERROR, "Invalid line in language file (%s.lang, %d)",
180 <                      locale, linecnt);
181 <        res = 0;
182 <        continue;
183 <      }
184 <    }
185 <    else
186 <      *reply++ = '\0';
187 <    if (*ident == '\0')
188 <      goto error;
189 <
190 <    /* skip to the beginning of reply */
191 <    while (*reply == ' ' || *reply == '\t') reply++;
192 <    if (*reply == '\0')
193 <      goto error;
194 <
195 <    for (i = 0; i <= ERR_LAST_ERR_MSG; i++)
196 <    {
197 <      if (replies[i].name != NULL)
198 <      {
199 <        if (irccmp(replies[i].name, ident) == 0)
200 <        {
201 <          if (!change_reply(locale, linecnt, i, reply)) res = 0;
202 <          i = -1;
203 <          break;
204 <        }
205 <      }
206 <    }
207 <    if (i != -1)
208 <    {
209 <      ilog(L_ERROR,
210 <           "Unknown numeric %s (%s.lang, %d)", ident, locale, linecnt);
211 <      res = 0;
212 <    }
213 <  }
214 <  fbclose(f);
215 <
216 <  strlcpy(used_locale, locale, sizeof(used_locale));
217 <  if (!res)
218 <    sendto_realops_flags(UMODE_ALL, L_ADMIN, "Language file [%s] contains "
219 <                         "errors, check server log file for more details",
220 <                         used_locale);
221 < }
222 <
223 < /* Returns the name of current locale. */
224 < const char *
225 < get_locale(void)
226 < {
227 <  return used_locale;
250 >  return replies[numeric];
251   }

Comparing:
ircd-hybrid-7.2/src/numeric.c (property svn:keywords), Revision 34 by lusky, Sun Oct 2 21:05:51 2005 UTC vs.
ircd-hybrid/trunk/src/numeric.c (property svn:keywords), Revision 8923 by michael, Mon Apr 22 10:09:22 2019 UTC

# Line 1 | Line 1
1 < Id Revision
1 > Id

Diff Legend

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