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

Function main

freebsd/contrib/zstd/zlibWrapper/examples/minigzip.c:549–640  ·  view source on GitHub ↗
(argc, argv)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

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