xref: /netbsd-src/external/bsd/bzip2/dist/spewG.c (revision c12ab3f1404d3e6320413d6099c78880423d6a49)
1*c12ab3f1Smaya /*	$NetBSD: spewG.c,v 1.1.1.3 2019/07/21 11:35:30 maya Exp $	*/
24f9a1459Swiz 
34f9a1459Swiz 
44f9a1459Swiz /* spew out a thoroughly gigantic file designed so that bzip2
54f9a1459Swiz    can compress it reasonably rapidly.  This is to help test
64f9a1459Swiz    support for large files (> 2GB) in a reasonable amount of time.
74f9a1459Swiz    I suggest you use the undocumented --exponential option to
84f9a1459Swiz    bzip2 when compressing the resulting file; this saves a bit of
94f9a1459Swiz    time.  Note: *don't* bother with --exponential when compressing
104f9a1459Swiz    Real Files; it'll just waste a lot of CPU time :-)
114f9a1459Swiz    (but is otherwise harmless).
124f9a1459Swiz */
134f9a1459Swiz 
144f9a1459Swiz /* ------------------------------------------------------------------
154f9a1459Swiz    This file is part of bzip2/libbzip2, a program and library for
164f9a1459Swiz    lossless, block-sorting data compression.
174f9a1459Swiz 
18*c12ab3f1Smaya    bzip2/libbzip2 version 1.0.8 of 13 July 2019
19*c12ab3f1Smaya    Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
204f9a1459Swiz 
214f9a1459Swiz    Please read the WARNING, DISCLAIMER and PATENTS sections in the
224f9a1459Swiz    README file.
234f9a1459Swiz 
244f9a1459Swiz    This program is released under the terms of the license contained
254f9a1459Swiz    in the file LICENSE.
264f9a1459Swiz 	 ------------------------------------------------------------------ */
274f9a1459Swiz 
284f9a1459Swiz 
294f9a1459Swiz #define _FILE_OFFSET_BITS 64
304f9a1459Swiz 
314f9a1459Swiz #include <stdio.h>
324f9a1459Swiz #include <stdlib.h>
334f9a1459Swiz 
344f9a1459Swiz /* The number of megabytes of junk to spew out (roughly) */
354f9a1459Swiz #define MEGABYTES 5000
364f9a1459Swiz 
374f9a1459Swiz #define N_BUF 1000000
384f9a1459Swiz char buf[N_BUF];
394f9a1459Swiz 
main(int argc,char ** argv)404f9a1459Swiz int main ( int argc, char** argv )
414f9a1459Swiz {
424f9a1459Swiz    int ii, kk, p;
434f9a1459Swiz    srandom(1);
444f9a1459Swiz    setbuffer ( stdout, buf, N_BUF );
454f9a1459Swiz    for (kk = 0; kk < MEGABYTES * 515; kk+=3) {
464f9a1459Swiz       p = 25+random()%50;
474f9a1459Swiz       for (ii = 0; ii < p; ii++)
484f9a1459Swiz          printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
494f9a1459Swiz       for (ii = 0; ii < p-1; ii++)
504f9a1459Swiz          printf ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" );
514f9a1459Swiz       for (ii = 0; ii < p+1; ii++)
524f9a1459Swiz          printf ( "ccccccccccccccccccccccccccccccccccccc" );
534f9a1459Swiz    }
544f9a1459Swiz    fflush(stdout);
554f9a1459Swiz    return 0;
564f9a1459Swiz }
57