/* * CDE - Common Desktop Environment * * Copyright (c) 1993-2012, The Open Group. All rights reserved. * * These libraries and programs are free software; you can * redistribute them and/or modify them under the terms of the GNU * Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * any later version. * * These libraries and programs are distributed in the hope that * they will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public * License along with these librararies and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ // $XConsortium: random_gen.C /main/6 1996/08/21 15:56:48 drk $ #include #include #include "object/random_gen.h" random_gen::~random_gen() { } random_gen::random_gen() { #ifdef __uxp__ int seed; struct tms tp; if ((seed = (int)times(&tp)) < 0) seed = 19; #else struct timeval tp; struct timezone tzp; int seed = ( gettimeofday(&tp, &tzp) == 0 ) ? int(tp.tv_sec) : 19; #endif #ifdef CONTROLLED_SEED if ( getenv("SEED") ) seed = atoi(getenv("SEED")); cerr << "seed=" << seed << "\n"; #endif rand_gen.seed(seed); } static char char_set[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '.', '_', '+', '|', '=', '\\', '~' }; void random_gen::random_string(ostream& out, int len) { out << len << "\t"; for ( int i=0; i