X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/838a6a51785f045ea6bdf6cf3eb70e3ac3d1930c..45c0fd363937c6e9b05da04a9167e9912c05ca0c:/rand.c diff --git a/rand.c b/rand.c index c50e10a..b004b3f 100644 --- a/rand.c +++ b/rand.c @@ -7,7 +7,7 @@ * (c) 1998 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,12 +15,12 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -213,9 +213,9 @@ void rand_add(rand_pool *r, const void *p, size_t sz, unsigned goodbits) /* --- @rand_goodbits@ --- * * - * Arguments: @rand_pool *r@ = pointer to a randomness pool + * Arguments: @rand_pool *r@ = pointer to a randomness pool * - * Returns: Estimate of the number of good bits remaining in the pool. + * Returns: Estimate of the number of good bits remaining in the pool. */ unsigned rand_goodbits(rand_pool *r) @@ -466,6 +466,7 @@ static int gmisc(grand *r, unsigned op, ...) case RAND_SEED: case RAND_TIMER: case RAND_GOODBITS: + case RAND_ADD: rc = 1; break; default: @@ -515,6 +516,12 @@ static int gmisc(grand *r, unsigned op, ...) case RAND_GOODBITS: rc = rand_goodbits(&g->p); break; + case RAND_ADD: { + const void *p = va_arg(ap, const void *); + size_t sz = va_arg(ap, size_t); + unsigned goodbits = va_arg(ap, unsigned); + rand_add(&g->p, p, sz, goodbits); + } break; default: GRAND_BADOP; break;