1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #include "FEATURE/uwin"
23 
24 #if !_UWIN || _lib_a64l
25 
_STUB_a64l()26 void _STUB_a64l(){}
27 
28 #else
29 
30 #define a64l	______a64l
31 #define l64a	______l64a
32 
33 #include	<stdlib.h>
34 #include	<string.h>
35 
36 #undef	a64l
37 #undef	l64a
38 
39 #if defined(__EXPORT__)
40 #define extern		__EXPORT__
41 #endif
42 
43 static char letter[65] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
44 
a64l(const char * str)45 extern long a64l(const char *str)
46 {
47 	register unsigned long ul = 0;
48 	register int n = 6;
49 	register int c;
50 	register char *cp;
51 	for(n=0; n <6; n++)
52 	{
53 		if((c= *str++)==0)
54 			break;
55 		if(!(cp=strchr(letter,c)))
56 			break;
57 		ul |= (cp-letter)<< (6*n);
58 	}
59 	return((long)ul);
60 }
61 
l64a(long l)62 extern char *l64a(long l)
63 {
64 	static char buff[7];
65 	unsigned ul = ((unsigned long)l & 0xffffffff);
66 	register char *cp = buff;
67 	while(ul>0)
68 	{
69 		*cp++ = letter[ul&077];
70 		ul >>= 6;
71 	}
72 	*cp = 0;
73 	return(buff);
74 }
75 
76 #endif
77