1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ 27 /* LINTLIBRARY */ 28 29 # include <string.h> 30 31 static char _lp_hextable[17] = "0123456789ABCDEF"; 32 33 #if defined(__STDC__) 34 char * ltos ( char * s, unsigned long l) 35 #else 36 char * ltos (s, l) 37 char *s; 38 unsigned long l; 39 #endif 40 { 41 int i = 7; 42 43 while (i >= 0) 44 { 45 s[i--] = _lp_hextable[l % 16]; 46 l /= 16; 47 } 48 s += 8; 49 return(s); 50 } 51 52 #if defined(__STDC__) 53 char * htos ( char * s, unsigned short h) 54 #else 55 char * htos (s, h) 56 char *s; 57 unsigned short h; 58 #endif 59 { 60 int i = 3; 61 62 while (i >= 0) 63 { 64 s[i--] = _lp_hextable[(long)h % 16]; 65 h = (long) h / 16; 66 } 67 s += 4; 68 return(s); 69 } 70 71 #if defined(__STDC__) 72 unsigned long stol ( char * s ) 73 #else 74 unsigned long stol (s) 75 char *s; 76 #endif 77 { 78 int i = 0; 79 unsigned long l = 0; 80 81 while (i < 8) 82 { 83 l <<= 4; 84 l += strchr(_lp_hextable, s[i++]) - _lp_hextable; 85 } 86 return(l); 87 } 88 89 #if defined(__STDC__) 90 unsigned short stoh ( char * s ) 91 #else 92 unsigned short stoh (s) 93 char *s; 94 #endif 95 { 96 int i = 0; 97 unsigned short h = 0; 98 99 while (i < 4) 100 { 101 h <<= 4; 102 h += strchr(_lp_hextable, s[i++]) - _lp_hextable; 103 } 104 return(h); 105 } 106