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