#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LINE 255
void display_info()
{
fprintf(stderr, "\nMANEXT 1.03 Copyright (C) 1991-1996 Mark Hessling\n"
"All rights reserved.\n"
"MANEXT is distributed under the terms of the GNU\n"
"General Public License and comes with NO WARRANTY.\n"
"See the file COPYING for details.\n"
"\nUsage: manext sourcefile [...]\n\n");
}
int main(int argc, char **argv)
{
char s[MAX_LINE + 1];
int i;
FILE *fp;
#ifdef __EMX__
_wildcard(&argc, &argv);
#endif
if (strcmp(argv[1], "-h") == 0)
{
display_info();
exit(1);
}
for (i = 1; i < argc; i++)
{
if ((fp = fopen(argv[i], "r")) == NULL)
{
fprintf(stderr, "\nCould not open %s\n", argv[i]);
continue;
}
while (!feof(fp))
{
if (fgets(s, (int)sizeof(s), fp) == NULL)
{
if (ferror(fp) != 0)
{
fprintf(stderr, "*** Error reading %s. Exiting.\n",
argv[i]);
exit(1);
}
break;
}
if (strncmp(s, "/*man-start*", 12) != 0)
continue;
for (;;)
{
if (fgets(s, (int)sizeof(s), fp) == NULL)
{
if (ferror(fp) != 0)
{
fprintf(stderr, "*** Error reading %s. Exiting.\n",
argv[i]);
exit(1);
}
break;
}
if (strncmp(s, "**man-end", 9) == 0)
break;
printf("%s", s);
}
printf("\n\n-----------------------------------"
"---------------------------------------\n\n");
}
fclose(fp);
}
return 0;
}