* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
+#include "helpfile.h"
#include "log.h"
#include "nickserv.h"
#include "recdb.h"
int argc = 0;
int n;
while (*line && (argc < argv_size)) {
- while (*line == ' ') *line++ = 0;
+ while (*line == ' ')
+ *line++ = 0;
if (*line == ':' && irc_colon && argc > 0) {
/* the rest is a single parameter */
argv[argc++] = line + 1;
argv[argc++] = line;
if (argc >= argv_size)
break;
- while (*line != ' ' && *line) line++;
+ while (*line != ' ' && *line)
+ line++;
}
#ifdef NDEBUG
n = 0;
#else
- for (n=argc; n<argv_size; n++) {
+ for (n=argc; n<argv_size; n++)
argv[n] = (char*)0xFEEDBEEF;
- }
#endif
return argc;
}
return match_ircglob(inet_ntoa(user->ip), glob);
} else {
/* The host part of the mask isn't IP-based */
+ if (IsFakeHost(user) && match_ircglob(user->fakehost, glob))
+ return 1;
if (hidden_host_suffix && user->handle_info) {
char hidden_host[HOSTLEN+1];
snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix);
}
char *
-intervalString2(char *output, time_t interval, int brief)
+intervalString(char *output, time_t interval, struct handle_info *hi)
{
static const struct {
- const char *name;
+ const char *msg_single;
+ const char *msg_plural;
long length;
} unit[] = {
- { "year", 365 * 24 * 60 * 60 },
- { "week", 7 * 24 * 60 * 60 },
- { "day", 24 * 60 * 60 },
- { "hour", 60 * 60 },
- { "minute", 60 },
- { "second", 1 }
+ { "MSG_YEAR", "MSG_YEARS", 365 * 24 * 60 * 60 },
+ { "MSG_WEEK", "MSG_WEEKS", 7 * 24 * 60 * 60 },
+ { "MSG_DAY", "MSG_DAYS", 24 * 60 * 60 },
+ { "MSG_HOUR", "MSG_HOURS", 60 * 60 },
+ { "MSG_MINUTE", "MSG_MINUTES", 60 },
+ { "MSG_SECOND", "MSG_SECONDS", 1 }
};
+ struct language *lang;
+ const char *msg;
unsigned int type, words, pos, count;
+ lang = hi ? hi->language : lang_C;
if(!interval)
{
- strcpy(output, brief ? "0s" : "0 seconds");
- return output;
+ msg = language_find_message(lang, "MSG_0_SECONDS");
+ return strcpy(output, msg);
}
for (type = 0, words = pos = 0;
count = interval / unit[type].length;
interval = interval % unit[type].length;
- if (brief)
- pos += sprintf(output + pos, "%d%c", count, unit[type].name[0]);
- else if (words == 1)
- pos += sprintf(output + pos, " and %d %s", count, unit[type].name);
+ if (words++ == 1) {
+ msg = language_find_message(lang, "MSG_AND");
+ pos += sprintf(output + pos, " %s ", msg);
+ }
+ if (count == 1)
+ msg = language_find_message(lang, unit[type].msg_single);
else
- pos += sprintf(output + pos, "%d %s", count, unit[type].name);
- if (count != 1)
- output[pos++] = 's';
- words++;
+ msg = language_find_message(lang, unit[type].msg_plural);
+ pos += sprintf(output + pos, "%d %s", count, msg);
}
output[pos] = 0;
/* pre-C99 behavior; double buffer size until it is big enough */
va_end(working);
VA_COPY(working, args);
- while ((ret = vsnprintf(buf->list + buf->used, buf->size, fmt, working)) == -1) {
+ while ((ret = vsnprintf(buf->list + buf->used, buf->size - buf->used, fmt, working)) <= 0) {
buf->size += len;
buf->list = realloc(buf->list, buf->size);
va_end(working);