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

Comparing:
ircd-hybrid/trunk/src/s_misc.c (file contents), Revision 2301 by michael, Wed Jun 19 12:21:28 2013 UTC vs.
ircd-hybrid/trunk/src/misc.c (file contents), Revision 5347 by michael, Sun Jan 11 12:42:20 2015 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  s_misc.c: Yet another miscellaneous functions file.
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-2015 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
20 < *
21 < *  $Id$
20 > */
21 >
22 > /*! \file s_misc.c
23 > * \brief Yet another miscellaneous functions file.
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
28 < #include "s_misc.h"
27 < #include "client.h"
28 > #include "misc.h"
29   #include "irc_string.h"
30   #include "ircd.h"
30 #include "numeric.h"
31 #include "irc_res.h"
32 #include "fdlist.h"
33 #include "s_bsd.h"
34 #include "conf.h"
35 #include "s_serv.h"
36 #include "send.h"
37 #include "memory.h"
31  
32  
33   static const char *const months[] =
# Line 51 | Line 44 | static const char *const weekdays[] =
44   };
45  
46   const char *
47 < date(time_t lclock)
47 > date(time_t lclock)
48   {
49    static char buf[80], plus;
50    struct tm *lt, *gm;
51    struct tm gmbuf;
52    int minswest;
53  
54 <  if (!lclock)
54 >  if (!lclock)
55      lclock = CurrentTime;
56 +
57    gm = gmtime(&lclock);
58    memcpy(&gmbuf, gm, sizeof(gmbuf));
59    gm = &gmbuf;
# Line 103 | Line 97 | smalldate(time_t lclock)
97  
98    gm = gmtime(&lclock);
99    memcpy(&gmbuf, gm, sizeof(gmbuf));
100 <  gm = &gmbuf;
100 >  gm = &gmbuf;
101    lt = localtime(&lclock);
102 <  
102 >
103    snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
104             lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
105             lt->tm_hour, lt->tm_min);
# Line 113 | Line 107 | smalldate(time_t lclock)
107    return buf;
108   }
109  
110 + /*
111 + * myctime - This is like standard ctime()-function, but it zaps away
112 + *   the newline from the end of that string. Also, it takes
113 + *   the time value as parameter, instead of pointer to it.
114 + *   Note that it is necessary to copy the string to alternate
115 + *   buffer (who knows how ctime() implements it, maybe it statically
116 + *   has newline there and never 'refreshes' it -- zapping that
117 + *   might break things in other places...)
118 + *
119 + *
120 + * Thu Nov 24 18:22:48 1986
121 + */
122 + const char *
123 + myctime(time_t value)
124 + {
125 +  static char buf[32];
126 +  char *p;
127 +
128 +  strlcpy(buf, ctime(&value), sizeof(buf));
129 +
130 +  if ((p = strchr(buf, '\n')))
131 +    *p = '\0';
132 +  return buf;
133 + }
134 +
135   #ifdef HAVE_LIBCRYPTO
136   const char *
137   ssl_get_cipher(const SSL *ssl)
138   {
139 <  static char buffer[IRCD_BUFSIZE / 4];
139 >  static char buffer[IRCD_BUFSIZE];
140    int bits = 0;
141  
142    SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), &bits);
143  
144 <  snprintf(buffer, sizeof(buffer), "%s %s-%d", SSL_get_version(ssl),
144 >  snprintf(buffer, sizeof(buffer), "%s-%s-%d", SSL_get_version(ssl),
145             SSL_get_cipher(ssl), bits);
127  
146    return buffer;
147   }
148   #endif

Diff Legend

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