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 |
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" |
53 |
|
}; |
54 |
|
|
55 |
|
const char * |
56 |
< |
date(time_t lclock) |
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 |
+ |
|
66 |
|
gm = gmtime(&lclock); |
67 |
|
memcpy(&gmbuf, gm, sizeof(gmbuf)); |
68 |
|
gm = &gmbuf; |
106 |
|
|
107 |
|
gm = gmtime(&lclock); |
108 |
|
memcpy(&gmbuf, gm, sizeof(gmbuf)); |
109 |
< |
gm = &gmbuf; |
109 |
> |
gm = &gmbuf; |
110 |
|
lt = localtime(&lclock); |
111 |
< |
|
111 |
> |
|
112 |
|
snprintf(buf, sizeof(buf), "%d/%d/%d %02d.%02d", |
113 |
|
lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, |
114 |
|
lt->tm_hour, lt->tm_min); |
116 |
|
return buf; |
117 |
|
} |
118 |
|
|
119 |
+ |
/* |
120 |
+ |
* myctime - This is like standard ctime()-function, but it zaps away |
121 |
+ |
* the newline from the end of that string. Also, it takes |
122 |
+ |
* the time value as parameter, instead of pointer to it. |
123 |
+ |
* Note that it is necessary to copy the string to alternate |
124 |
+ |
* buffer (who knows how ctime() implements it, maybe it statically |
125 |
+ |
* has newline there and never 'refreshes' it -- zapping that |
126 |
+ |
* might break things in other places...) |
127 |
+ |
* |
128 |
+ |
* |
129 |
+ |
* Thu Nov 24 18:22:48 1986 |
130 |
+ |
*/ |
131 |
+ |
const char * |
132 |
+ |
myctime(time_t value) |
133 |
+ |
{ |
134 |
+ |
static char buf[32]; |
135 |
+ |
char *p; |
136 |
+ |
|
137 |
+ |
strlcpy(buf, ctime(&value), sizeof(buf)); |
138 |
+ |
|
139 |
+ |
if ((p = strchr(buf, '\n'))) |
140 |
+ |
*p = '\0'; |
141 |
+ |
return buf; |
142 |
+ |
} |
143 |
+ |
|
144 |
|
#ifdef HAVE_LIBCRYPTO |
145 |
|
const char * |
146 |
|
ssl_get_cipher(const SSL *ssl) |
152 |
|
|
153 |
|
snprintf(buffer, sizeof(buffer), "%s %s-%d", SSL_get_version(ssl), |
154 |
|
SSL_get_cipher(ssl), bits); |
127 |
– |
|
155 |
|
return buffer; |
156 |
|
} |
157 |
|
#endif |