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/src/s_misc.c (file contents), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid/trunk/src/s_misc.c (file contents), Revision 2970 by michael, Fri Jan 31 11:23:46 2014 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-2014 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 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
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"
29   #include "client.h"
28 – #include "common.h"
30   #include "irc_string.h"
30 – #include "sprintf_irc.h"
31   #include "ircd.h"
32   #include "numeric.h"
33   #include "irc_res.h"
34   #include "fdlist.h"
35   #include "s_bsd.h"
36 < #include "s_conf.h"
36 > #include "conf.h"
37   #include "s_serv.h"
38   #include "send.h"
39   #include "memory.h"
40  
41  
42 < static const char *months[] =
42 > static const char *const months[] =
43   {
44    "January",   "February", "March",   "April",
45    "May",       "June",     "July",    "August",
46    "September", "October",  "November","December"
47   };
48  
49 < static const char *weekdays[] =
49 > static const char *const weekdays[] =
50   {
51    "Sunday",   "Monday", "Tuesday", "Wednesday",
52    "Thursday", "Friday", "Saturday"
53   };
54  
55 < char *
56 < date(time_t lclock)
55 > const char *
56 > date(time_t lclock)
57   {
58    static char buf[80], plus;
59    struct tm *lt, *gm;
60    struct tm gmbuf;
61    int minswest;
62  
63 <  if (!lclock)
63 >  if (!lclock)
64      lclock = CurrentTime;
65    gm = gmtime(&lclock);
66    memcpy(&gmbuf, gm, sizeof(gmbuf));
# Line 86 | Line 86 | date(time_t lclock)
86    if (minswest < 0)
87      minswest = -minswest;
88  
89 <  ircsprintf(buf, "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",
90 <             weekdays[lt->tm_wday], months[lt->tm_mon],lt->tm_mday,
91 <             lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,
92 <             plus, minswest/60, minswest%60);
89 >  snprintf(buf, sizeof(buf), "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",
90 >           weekdays[lt->tm_wday], months[lt->tm_mon],lt->tm_mday,
91 >           lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,
92 >           plus, minswest/60, minswest%60);
93    return buf;
94   }
95  
# Line 105 | Line 105 | smalldate(time_t lclock)
105  
106    gm = gmtime(&lclock);
107    memcpy(&gmbuf, gm, sizeof(gmbuf));
108 <  gm = &gmbuf;
108 >  gm = &gmbuf;
109    lt = localtime(&lclock);
110 <  
111 <  ircsprintf(buf, "%d/%d/%d %02d.%02d",
112 <             lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
113 <             lt->tm_hour, lt->tm_min);
110 >
111 >  snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d",
112 >           lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
113 >           lt->tm_hour, lt->tm_min);
114  
115    return buf;
116   }
117  
118 < /* small_file_date()
119 < * Make a small YYYYMMDD formatted string suitable for a
120 < * dated file stamp.
118 > /*
119 > * myctime - This is like standard ctime()-function, but it zaps away
120 > *   the newline from the end of that string. Also, it takes
121 > *   the time value as parameter, instead of pointer to it.
122 > *   Note that it is necessary to copy the string to alternate
123 > *   buffer (who knows how ctime() implements it, maybe it statically
124 > *   has newline there and never 'refreshes' it -- zapping that
125 > *   might break things in other places...)
126 > *
127 > *
128 > * Thu Nov 24 18:22:48 1986
129   */
130 < char *
131 < small_file_date(time_t lclock)
130 > const char *
131 > myctime(time_t value)
132   {
133 <  static char timebuffer[MAX_DATE_STRING];
134 <  struct tm *tmptr;
127 <
128 <  if (!lclock)
129 <    time(&lclock);
133 >  static char buf[32];
134 >  char *p;
135  
136 <  tmptr = localtime(&lclock);
132 <  strftime(timebuffer, MAX_DATE_STRING, "%Y%m%d", tmptr);
136 >  strlcpy(buf, ctime(&value), sizeof(buf));
137  
138 <  return timebuffer;
138 >  if ((p = strchr(buf, '\n')) != NULL)
139 >    *p = '\0';
140 >  return buf;
141   }
142  
143   #ifdef HAVE_LIBCRYPTO
144 < char *
145 < ssl_get_cipher(SSL *ssl)
144 > const char *
145 > ssl_get_cipher(const SSL *ssl)
146   {
147 <  static char buffer[128];
148 <  const char *name = NULL;
143 <  int bits;
144 <
145 <  switch (ssl->session->ssl_version)
146 <  {
147 <    case SSL2_VERSION:
148 <      name = "SSLv2";
149 <      break;
150 <
151 <    case SSL3_VERSION:
152 <      name = "SSLv3";
153 <      break;
154 <
155 <    case TLS1_VERSION:
156 <      name = "TLSv1";
157 <      break;
158 <
159 <    default:
160 <      name = "UNKNOWN";
161 <  }
147 >  static char buffer[IRCD_BUFSIZE / 4];
148 >  int bits = 0;
149  
150    SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), &bits);
151  
152 <  snprintf(buffer, sizeof(buffer), "%s %s-%d",
153 <           name, SSL_get_cipher(ssl), bits);
167 <  
152 >  snprintf(buffer, sizeof(buffer), "%s %s-%d", SSL_get_version(ssl),
153 >           SSL_get_cipher(ssl), bits);
154    return buffer;
155   }
156   #endif

Comparing:
ircd-hybrid/src/s_misc.c (property svn:keywords), Revision 31 by knight, Sun Oct 2 20:34:05 2005 UTC vs.
ircd-hybrid/trunk/src/s_misc.c (property svn:keywords), Revision 2970 by michael, Fri Jan 31 11:23:46 2014 UTC

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

Diff Legend

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