File:  [MW Coherent from dump] / coherent / d / usr / src / examples / fgets.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:38 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

#include <stdio.h>
#define MAXLINE 128

void fatal();
char buf[MAXLINE];

main(argc, argv)
int argc; 
char *argv[];
{
	if (argc != 2 && argc != 3)
		fatal("Usage: fgets pattern [ file ]");

	if (argc==3 && freopen(argv[2], "r", stdin) == NULL)
		fatal("cannot open input file");

	while (fgets(buf, MAXLINE, stdin) != NULL) {
		if (pnmatch(buf, argv[1], 1))
			printf("%s", buf);
	}
	exit(0);
}

void fatal(s) char *s;
{
	fprintf(stderr, "fgets: %s\n", s);
	exit(1);
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.