/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/* Portions Copyright(c) 1988, Sun Microsystems Inc. */
/* All Rights Reserved */
/*
* Copyright (c) 1997, by Sun Microsystems, Inc.
* All rights reserved.
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
/* LINTLIBRARY */
#include <stdio.h>
#include <mp.h>
#include "libmp.h"
#include <stdlib.h>
#include <unistd.h>
void
{
int i, j;
_mp_xfree(b);
if ((i = a->len) < 0) {
i = -i;
}
if (i == 0) {
return;
}
for (j = 0; j < i; j++) {
}
}
/* ARGSUSED */
/* VARARGS */
short *
{
short *i;
#ifdef DEBUG
#endif
if (i == NULL) {
_mp_fatal("mp: no free space");
}
return (i);
}
void
_mp_fatal(char *s)
{
(void) sleep(2);
abort();
}
void
{
#ifdef DBG
#endif
if (c->len != 0) {
c->len = 0;
}
}
void
{
int i, j;
if ((i = a->len) == 0) {
return;
}
if (i < 0) {
i = -i;
}
for (j = i; j > 0 && a->val[j-1] == 0; j--)
;
if (j == i) {
return;
}
if (j == 0) {
_mp_xfree(a);
return;
}
if (a->len > 0) {
a->len = j;
} else {
a->len = -j;
}
}
MINT *
mp_itom(short n)
{
MINT *a;
if (n > 0) {
a->len = 1;
*a->val = n;
} else if (n < 0) {
a->len = -1;
*a->val = -n;
} else {
a->len = 0;
}
return (a);
}
int
{
MINT c;
int res;
_mp_mcan(a);
_mp_mcan(b);
}
c.len = 0;
mp_msub(a, b, &c);
_mp_xfree(&c);
return (res);
}
/*
* Convert hex digit to binary value
*/
static short
xtoi(char c)
{
if (c >= '0' && c <= '9') {
return (c - '0');
} else if (c >= 'a' && c <= 'f') {
return (c - 'a' + 10);
} else if (c >= 'A' && c <= 'F') {
return (c - 'A' + 10);
} else {
return (-1);
}
}
/*
* Convert hex key to MINT key
*/
MINT *
{
short digit;
MINT *d;
if (digit < 0) {
return (NULL);
}
mp_madd(m, d, m);
mp_mfree(d);
}
return (m);
}
static char
itox(short d)
{
d &= 15;
if (d < 10) {
return ('0' + d);
} else {
return ('a' - 10 + d);
}
}
/*
* Convert MINT key to hex key
*/
char *
{
short r;
char *p;
char c;
char *s;
char *hex;
int size;
} else {
}
return (NULL);
}
p = hex;
do {
mp_sdiv(m, 16, m, &r);
*p++ = itox(r);
mp_mfree(m);
*p = 0;
for (p--, s = hex; s < p; s++, p--) {
c = *p;
*p = *s;
*s = c;
}
return (hex);
}
/*
* Deallocate a multiple precision integer
*/
void
{
_mp_xfree(a);
free(a);
}