octet.c revision 4870e0a7381ec2ec57437062574e6ddc3dd48d7f
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1996-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* LINTLIBRARY */
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#endif /* _BOOT && _KERNEL */
(((c) >= 'A') && ((c) <= 'F')))
#endif /* _BOOT || _KERNEL */
/*
* Converts an octet string into an ASCII string. The string returned is
* NULL-terminated, and the length recorded in blen does *not* include the
* null terminator (in other words, octet_to_hexascii() returns the length a'la
* strlen()).
*
* Returns 0 for Success, errno otherwise.
*/
int
{
int i;
char *bp;
static char ascii_conv[] = "0123456789ABCDEF";
return (EINVAL);
*blen = 0;
return (E2BIG);
}
}
*bp = '\0';
*blen = i * 2;
return (0);
}
/*
* Converts an ASCII string into an octet string.
*
* Returns 0 for success, errno otherwise.
*/
int
{
int i, j, k;
const char *tp;
return (EINVAL);
return (E2BIG);
/* one nibble at a time */
else
return (EINVAL);
if ((j % 2) == 0)
*u_tp <<= 4;
}
}
*blen = k;
return (0);
}