MCPcopy Create free account
hub / github.com/F-Stack/f-stack / main

Function main

freebsd/contrib/zlib/test/minigzip.c:556–651  ·  view source on GitHub ↗
(argc, argv)

Source from the content-addressed store, hash-verified

554 */
555
556int main(argc, argv)
557 int argc;
558 char *argv[];
559{
560 int copyout = 0;
561 int uncompr = 0;
562 gzFile file;
563 char *bname, outmode[20];
564
565#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
566 snprintf(outmode, sizeof(outmode), "%s", "wb6 ");
567#else
568 strcpy(outmode, "wb6 ");
569#endif
570
571 prog = argv[0];
572 bname = strrchr(argv[0], '/');
573 if (bname)
574 bname++;
575 else
576 bname = argv[0];
577 argc--, argv++;
578
579 if (!strcmp(bname, "gunzip"))
580 uncompr = 1;
581 else if (!strcmp(bname, "zcat"))
582 copyout = uncompr = 1;
583
584 while (argc > 0) {
585 if (strcmp(*argv, "-c") == 0)
586 copyout = 1;
587 else if (strcmp(*argv, "-d") == 0)
588 uncompr = 1;
589 else if (strcmp(*argv, "-f") == 0)
590 outmode[3] = 'f';
591 else if (strcmp(*argv, "-h") == 0)
592 outmode[3] = 'h';
593 else if (strcmp(*argv, "-r") == 0)
594 outmode[3] = 'R';
595 else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
596 (*argv)[2] == 0)
597 outmode[2] = (*argv)[1];
598 else
599 break;
600 argc--, argv++;
601 }
602 if (outmode[3] == ' ')
603 outmode[3] = 0;
604 if (argc == 0) {
605 SET_BINARY_MODE(stdin);
606 SET_BINARY_MODE(stdout);
607 if (uncompr) {
608 file = gzdopen(fileno(stdin), "rb");
609 if (file == NULL) error("can't gzdopen stdin");
610 gz_uncompress(file, stdout);
611 } else {
612 file = gzdopen(fileno(stdout), outmode);
613 if (file == NULL) error("can't gzdopen stdout");

Callers

nothing calls this directly

Calls 10

snprintfFunction · 0.85
strrchrFunction · 0.85
strcmpFunction · 0.85
gzdopenFunction · 0.70
errorFunction · 0.70
gz_uncompressFunction · 0.70
gz_compressFunction · 0.70
gzopenFunction · 0.70
file_uncompressFunction · 0.70
file_compressFunction · 0.70

Tested by

no test coverage detected