a64l.c revision 1.1
11.1Sjtc/*
21.1Sjtc * Copyright (c) 1993 Winning Strategies, Inc.
31.1Sjtc * All rights reserved.
41.1Sjtc *
51.1Sjtc * Redistribution and use in source and binary forms, with or without
61.1Sjtc * modification, are permitted provided that the following conditions
71.1Sjtc * are met:
81.1Sjtc * 1. Redistributions of source code must retain the above copyright
91.1Sjtc *    notice, this list of conditions and the following disclaimer.
101.1Sjtc * 2. Redistributions in binary form must reproduce the above copyright
111.1Sjtc *    notice, this list of conditions and the following disclaimer in the
121.1Sjtc *    documentation and/or other materials provided with the distribution.
131.1Sjtc * 3. All advertising materials mentioning features or use of this software
141.1Sjtc *    must display the following acknowledgement:
151.1Sjtc *      This product includes software developed by Winning Strategies, Inc.
161.1Sjtc * 4. The name of the author may not be used to endorse or promote products
171.1Sjtc *    derived from this software withough specific prior written permission
181.1Sjtc *
191.1Sjtc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
201.1Sjtc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
211.1Sjtc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
221.1Sjtc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
231.1Sjtc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
241.1Sjtc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
251.1Sjtc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
261.1Sjtc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271.1Sjtc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
281.1Sjtc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
291.1Sjtc */
301.1Sjtc
311.1Sjtc#if defined(LIBC_SCCS) && !defined(lint)
321.1Sjtcstatic char *rcsid = "$Id: a64l.c,v 1.1 1993/10/22 17:26:44 jtc Exp $";
331.1Sjtc#endif
341.1Sjtc
351.1Sjtclong
361.1Sjtca64l(s)
371.1Sjtc	const char *s;
381.1Sjtc{
391.1Sjtc	long value, digit, shift;
401.1Sjtc	int i;
411.1Sjtc
421.1Sjtc	value = 0;
431.1Sjtc	shift = 0;
441.1Sjtc	for (i = 0; *s && i < 6; i++, s++) {
451.1Sjtc		if (*s <= '/')
461.1Sjtc			digit = *s - '.';
471.1Sjtc		else if (*s <= '9')
481.1Sjtc			digit = *s - '0' + 2;
491.1Sjtc		else if (*s <= 'Z')
501.1Sjtc			digit = *s - 'A' + 12;
511.1Sjtc		else
521.1Sjtc			digit = *s - 'a' + 38;
531.1Sjtc
541.1Sjtc		value |= digit << shift;
551.1Sjtc		shift += 6;
561.1Sjtc	}
571.1Sjtc
581.1Sjtc	return (long) value;
591.1Sjtc}
60