Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/factor Provide a BN_dec2bn() shim for the non-openssl ...



details:   https://anonhg.NetBSD.org/src/rev/de500459e166
branches:  trunk
changeset: 533009:de500459e166
user:      simonb <simonb%NetBSD.org@localhost>
date:      Tue Jun 18 23:07:36 2002 +0000

description:
Provide a BN_dec2bn() shim for the non-openssl case that reports an error
if strtoul() fails.

diffstat:

 games/factor/factor.c |  24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diffs (53 lines):

diff -r 789cbc5f3fb3 -r de500459e166 games/factor/factor.c
--- a/games/factor/factor.c     Tue Jun 18 22:58:30 2002 +0000
+++ b/games/factor/factor.c     Tue Jun 18 23:07:36 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: factor.c,v 1.12 2002/06/17 15:43:52 simonb Exp $       */
+/*     $NetBSD: factor.c,v 1.13 2002/06/18 23:07:36 simonb Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)factor.c   8.4 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: factor.c,v 1.12 2002/06/17 15:43:52 simonb Exp $");
+__RCSID("$NetBSD: factor.c,v 1.13 2002/06/18 23:07:36 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -82,8 +82,11 @@
 #else
 typedef long   BIGNUM;
 typedef u_long BN_ULONG;
+int    BN_dec2bn(BIGNUM **a, const char *str);
 #define BN_new()               ((BIGNUM *)calloc(sizeof(BIGNUM), 1))
-#define BN_dec2bn(pp, str)     (**(pp) = atol(str))
+#define BN_is_zero(v)          (*(v) == 0)
+#define BN_is_one(v)           (*(v) == 1)
+#define BN_new()               ((BIGNUM *)calloc(sizeof(BIGNUM), 1))
 #define BN_is_zero(v)          (*(v) == 0)
 #define BN_is_one(v)           (*(v) == 1)
 #define BN_mod_word(a, b)      (*(a) % (b))
@@ -117,6 +120,21 @@
 BN_ULONG BN_div_word(BIGNUM *, BN_ULONG);
 #endif
 
+
+#ifndef HAVE_OPENSSL
+int
+BN_dec2bn(BIGNUM **a, const char *str)
+{
+       char *p;
+
+       errno = 0;
+       **a = strtoul(str, &p, 10);
+       if (errno)
+               err(1, "%s", str);
+       return (*p == '\n' || *p == '\0');
+}
+#endif
+
 int
 main(int argc, char *argv[])
 {



Home | Main Index | Thread Index | Old Index