]>
git.saurik.com Git - apple/libinfo.git/blob - dns.subproj/nsap_addr.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
24 #if defined(LIBC_SCCS) && !defined(lint)
25 static char rcsid
[] = "$Id: nsap_addr.c,v 1.3 2003/02/18 17:29:24 majka Exp $";
26 #endif /* LIBC_SCCS and not lint */
28 #include <sys/param.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
33 #include "nameser8_compat.h"
34 #include "resolv8_compat.h"
35 #include "portability.h"
37 #if !defined(isxdigit) /* XXX - could be a function */
42 return ((c
>= '0') && (c
<= '9')) || ((c
>= 'A') && (c
<= 'F'));
50 return (c
- (((c
>= '0') && (c
<= '9')) ? '0' : '7'));
54 inet_nsap_addr(ascii
, binary
, maxlen
)
59 register u_char c
, nib
;
62 while ((c
= *ascii
++) != '\0' && len
< maxlen
) {
63 if (c
== '.' || c
== '+' || c
== '/')
74 *binary
++ = (nib
<< 4) | xtob(c
);
89 inet_nsap_ntoa(binlen
, binary
, ascii
)
91 register const u_char
*binary
;
96 static char tmpbuf
[255*3];
109 for (i
= 0; i
< binlen
; i
++) {
111 *ascii
++ = nib
+ (nib
< 10 ? '0' : '7');
112 nib
= *binary
++ & 0x0f;
113 *ascii
++ = nib
+ (nib
< 10 ? '0' : '7');
114 if (((i
% 2) == 0 && (i
+ 1) < binlen
))