ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/tools.h
(Generate patch)

Comparing ermyth/include/tools.h (file contents):
Revision 1.9 by pippijn, Sun Sep 16 18:54:42 2007 UTC vs.
Revision 1.10 by pippijn, Sat Sep 22 14:27:26 2007 UTC

8 * Portions of this file were derived from sources bearing the following license: 8 * Portions of this file were derived from sources bearing the following license:
9 * Copyright © 2003-2004 E. Will et al. 9 * Copyright © 2003-2004 E. Will et al.
10 * Copyright © 2005-2006 Atheme Development Group 10 * Copyright © 2005-2006 Atheme Development Group
11 * Rights to this code are as documented in doc/pod/license.pod. 11 * Rights to this code are as documented in doc/pod/license.pod.
12 * 12 *
13 * $Id: tools.h,v 1.9 2007/09/16 18:54:42 pippijn Exp $ 13 * $Id: tools.h,v 1.10 2007/09/22 14:27:26 pippijn Exp $
14 */ 14 */
15 15
16#ifndef _TOOLS_H 16#ifndef _TOOLS_H
17#define _TOOLS_H 17#define _TOOLS_H
18 18
98/* misc string stuff */ 98/* misc string stuff */
99E char *gen_pw (int sz); 99E char *gen_pw (int sz);
100E void tb2sp (char *line); 100E void tb2sp (char *line);
101E char *replace (char *s, int size, char const * const oldstr, char const * const newstr); 101E char *replace (char *s, int size, char const * const oldstr, char const * const newstr);
102 102
103/* reverse of atoi() */
104template<typename T>
105static inline char *
106itoa (T num)
107{
108 static char ret[32];
109 itoa (num, ret);
110 return ret;
111}
112
113E int validemail (char *email); 103E int validemail (char *email);
114E bool validhostmask (char *host); 104E bool validhostmask (char *host);
115E char const *sbytes (float x); 105E char const *sbytes (float x);
116E float bytes (float x); 106E float bytes (float x);
117 107
118E unsigned long makekey (void); 108E unsigned long makekey (void);
119
120/* time stuff */
121#if HAVE_GETTIMEOFDAY
122E void s_time (struct timeval *sttime);
123E void e_time (struct timeval sttime, struct timeval *ttime);
124E int tv2ms (struct timeval *tv);
125#endif
126E char *time_ago (time_t event);
127E char *timediff (time_t seconds);
128
129#ifdef timersub
130#undef timersub
131inline void
132timersub (timeval *tvp, timeval *uvp, timeval *vvp)
133{
134 vvp->tv_sec = tvp->tv_sec - uvp->tv_sec;
135 vvp->tv_usec = tvp->tv_usec - uvp->tv_usec;
136 if (vvp->tv_usec < 0)
137 {
138 vvp->tv_sec--;
139 vvp->tv_usec += 1000000;
140 }
141}
142#endif
143 109
144/* tokenize.c */ 110/* tokenize.c */
145E int sjtoken (char *message, char delimiter, char **parv, int limit = 256); 111E int sjtoken (char *message, char delimiter, char **parv, int limit = 256);
146E int tokenize (char *message, char **parv); 112E int tokenize (char *message, char **parv);
147 113

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines