xref: /freebsd/contrib/bzip2/spewG.c (revision f39bffc62c1395bde25d152c7f68fdf7cbaab414)
1 
2 /* spew out a thoroughly gigantic file designed so that bzip2
3    can compress it reasonably rapidly.  This is to help test
4    support for large files (> 2GB) in a reasonable amount of time.
5    I suggest you use the undocumented --exponential option to
6    bzip2 when compressing the resulting file; this saves a bit of
7    time.  Note: *don't* bother with --exponential when compressing
8    Real Files; it'll just waste a lot of CPU time :-)
9    (but is otherwise harmless).
10 */
11 
12 /* ------------------------------------------------------------------
13    This file is part of bzip2/libbzip2, a program and library for
14    lossless, block-sorting data compression.
15 
16    bzip2/libbzip2 version 1.0.6 of 6 September 2010
17    Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
18 
19    Please read the WARNING, DISCLAIMER and PATENTS sections in the
20    README file.
21 
22    This program is released under the terms of the license contained
23    in the file LICENSE.
24 	 ------------------------------------------------------------------ */
25 
26 
27 #define _FILE_OFFSET_BITS 64
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 
32 /* The number of megabytes of junk to spew out (roughly) */
33 #define MEGABYTES 5000
34 
35 #define N_BUF 1000000
36 char buf[N_BUF];
37 
38 int main ( int argc, char** argv )
39 {
40    int ii, kk, p;
41    srandom(1);
42    setbuffer ( stdout, buf, N_BUF );
43    for (kk = 0; kk < MEGABYTES * 515; kk+=3) {
44       p = 25+random()%50;
45       for (ii = 0; ii < p; ii++)
46          printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
47       for (ii = 0; ii < p-1; ii++)
48          printf ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" );
49       for (ii = 0; ii < p+1; ii++)
50          printf ( "ccccccccccccccccccccccccccccccccccccc" );
51    }
52    fflush(stdout);
53    return 0;
54 }
55