/*
 * Copyright (c) 1996-2007, OpenFWTK Development Group
 * All rights reserved. See LICENSE.
 */

#ifndef MAXNAME
#define	MAXNAME	32
#endif

extern long randomnumber();

char *randomname(len)
int len;

{
	static char garb[MAXNAME];
	int i;
	unsigned long rnd;
    const char *const
	base64="0123456789-abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    for (i = 0; i < sizeof(garb) - 1; i++) {
		if (i % (sizeof(rnd) * 8 / 8) == 0) rnd = randomnumber();
		garb[i] = base64[(rnd & 0xff) % 64];
		rnd >>= 8;
	}
	garb[len] = 0;
	
	return(garb);
}

