From 08a5f1f9485a5f34039e66cec5419c205881bd7a Mon Sep 17 00:00:00 2001 From: Valery Yatsko Date: Sun, 20 Apr 2008 09:03:39 +0400 Subject: [PATCH] myctime -> rb_ctime --- include/irc_string.h | 2 -- modules/m_info.c | 3 ++- modules/m_whowas.c | 3 ++- src/client.c | 3 ++- src/irc_string.c | 34 ---------------------------------- 5 files changed, 6 insertions(+), 39 deletions(-) diff --git a/include/irc_string.h b/include/irc_string.h index 3111897..9c93eda 100644 --- a/include/irc_string.h +++ b/include/irc_string.h @@ -95,8 +95,6 @@ char *strip_colour(char *string); */ char *strip_tabs(char *dest, const unsigned char *src, size_t len); -const char *myctime(time_t); - #define EmptyString(x) ((x) == NULL || *(x) == '\0') #define CheckEmpty(x) EmptyString(x) ? "" : x diff --git a/modules/m_info.c b/modules/m_info.c index 3916eae..470ded5 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -670,13 +670,14 @@ send_info_text(struct Client *source_p) static void send_birthdate_online_time(struct Client *source_p) { + char tbuf[26]; /* this needs to be 26 - see ctime_r manpage */ sendto_one(source_p, ":%s %d %s :Birth Date: %s, compile # %s", get_id(&me, source_p), RPL_INFO, get_id(source_p, source_p), creation, generation); sendto_one(source_p, ":%s %d %s :On-line since %s", get_id(&me, source_p), RPL_INFO, - get_id(source_p, source_p), myctime(startup_time)); + get_id(source_p, source_p), rb_ctime(startup_time, tbuf, sizeof(tbuf))); } /* diff --git a/modules/m_whowas.c b/modules/m_whowas.c index 807f84a..0728a80 100644 --- a/modules/m_whowas.c +++ b/modules/m_whowas.c @@ -64,6 +64,7 @@ m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char int max = -1, found = 0; char *p; const char *nick; + char tbuf[26]; static time_t last_used = 0L; @@ -118,7 +119,7 @@ m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char sendto_one_numeric(source_p, RPL_WHOISSERVER, form_str(RPL_WHOISSERVER), temp->name, temp->servername, - myctime(temp->logoff)); + rb_ctime(temp->logoff, tbuf, sizeof(tbuf))); cur++; found++; } diff --git a/src/client.c b/src/client.c index 497a7b6..903391d 100644 --- a/src/client.c +++ b/src/client.c @@ -1512,6 +1512,7 @@ exit_local_client(struct Client *client_p, struct Client *source_p, struct Clien const char *comment) { unsigned long on_for; + char tbuf[26]; exit_generic_client(client_p, source_p, from, comment); clear_monitor(source_p); @@ -1538,7 +1539,7 @@ exit_local_client(struct Client *client_p, struct Client *source_p, struct Clien on_for = rb_current_time() - source_p->localClient->firsttime; ilog(L_USER, "%s (%3lu:%02lu:%02lu): %s!%s@%s %d/%d", - myctime(rb_current_time()), on_for / 3600, + rb_ctime(rb_current_time(), tbuf, sizeof(tbuf)), on_for / 3600, (on_for % 3600) / 60, on_for % 60, source_p->name, source_p->username, source_p->host, source_p->localClient->sendK, source_p->localClient->receiveK); diff --git a/src/irc_string.c b/src/irc_string.c index d47147d..fecd3d1 100644 --- a/src/irc_string.c +++ b/src/irc_string.c @@ -30,43 +30,9 @@ #include "client.h" #include "setup.h" -#ifndef INADDRSZ -#define INADDRSZ 4 -#endif - -#ifdef RB_IPV6 -#ifndef IN6ADDRSZ -#define IN6ADDRSZ 16 -#endif -#endif - #ifndef INT16SZ #define INT16SZ 2 #endif -/* - * myctime - This is like standard ctime()-function, but it zaps away - * the newline from the end of that string. Also, it takes - * the time value as parameter, instead of pointer to it. - * Note that it is necessary to copy the string to alternate - * buffer (who knows how ctime() implements it, maybe it statically - * has newline there and never 'refreshes' it -- zapping that - * might break things in other places...) - * - * - * Thu Nov 24 18:22:48 1986 - */ -const char * -myctime(time_t value) -{ - static char buf[32]; - char *p; - - strcpy(buf, ctime(&value)); - if((p = strchr(buf, '\n')) != NULL) - *p = '\0'; - return buf; -} - /* * clean_string - clean up a string possibly containing garbage