Updated the german translation
[gnupg.git] / tools / mk-tdata.c
blob9328dc12a06a54b5bc50714d761f9223426aad7d
1 /* mk-tdata.c - Create some simple random testdata
2 * Copyright (C) 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
4 * This file is free software; as a special exception the author gives
5 * unlimited permission to copy and/or distribute it, with or without
6 * modifications, as long as this notice is preserved.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 #ifdef HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <unistd.h>
22 #ifndef RAND_MAX /* for SunOS */
23 #define RAND_MAX 32767
24 #endif
26 int
27 main(int argc, char **argv)
29 int i, c = 0;
30 int limit =0;
31 int char_mode = 0;
33 if (argc)
35 argc--;
36 argv++;
39 /* Check for option --char N */
40 if (argc > 1 && !strcmp (argv[0], "--char"))
42 char_mode = 1;
43 c = strtol (argv[1], NULL, 0);
44 argc -= 2;
45 argv += 2;
48 limit = argc ? atoi(argv[0]) : 0;
50 srand(getpid());
52 for (i=0; !limit || i < limit; i++ )
54 if (char_mode)
56 putchar (c);
58 else
60 #ifdef HAVE_RAND
61 c = ((unsigned)(1 + (int) (256.0*rand()/(RAND_MAX+1.0)))-1);
62 #else
63 c = ((unsigned)(1 + (int) (256.0*random()/(RAND_MAX+1.0)))-1);
64 #endif
65 putchar (c);
68 return 0;