ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/ubase64.C
Revision: 1.4
Committed: Tue Aug 28 17:08:12 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +3 -3 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * ubase64.C: ircu base64 routines.
3 pippijn 1.2 * Rights to this code are documented in doc/pod/license.pod.
4 pippijn 1.1 *
5 pippijn 1.4 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 pippijn 1.1 */
7    
8 pippijn 1.4 static char const rcsid[] = "$Id: ubase64.C,v 1.3 2007-07-21 13:23:22 pippijn Exp $";
9 pippijn 1.1
10     #include "atheme.h"
11    
12     /*
13     * base64touint() written 01/20/06 by jilles, for getting IP addresses.
14     */
15    
16     static const char ub64_alphabet[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]";
17     #define __ '\377'
18     static const char ub64_lookuptab[256] = {
19     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, /* 0-15 */
20     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, /* 16-31 */
21     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, /* 32-47 */
22     52, 53, 54, 55, 56, 57, 58, 59, 60, 61, __, __, __, __, __, __, /* 48-63 */
23     __, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 64-79 */
24     15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 62, __, 63, __, __, /* 80-95 */
25     __, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 96-111 */
26     41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, __, __, __, __, __, /* 112-127 */
27     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
28     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
29     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
30     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
31     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
32     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
33     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
34     __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __
35     };
36    
37     #undef __
38    
39 pippijn 1.4 char const * const
40 pippijn 1.1 uinttobase64 (char *buf, uint64_t v, int64_t count)
41     {
42     buf[count] = '\0';
43    
44     while (count >= 0)
45     {
46     buf[--count] = ub64_alphabet[v & 63];
47     v >>= 6;
48     }
49    
50     return buf;
51     }
52    
53     unsigned int
54     base64touint (char *buf)
55     {
56     int bits;
57     unsigned int v = 0;
58     int count = 6;
59    
60     while (--count >= 0 && (bits = ub64_lookuptab[255 & *buf++]) != '\377')
61     v = v << 6 | bits;
62     return v;
63     }
64    
65     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
66     * vim:ts=8
67     * vim:sw=8
68     * vim:noexpandtab
69     */