|
|
BSD 4.3
#include "parms.h"
#include "structs.h"
#ifdef RCSIDENT
static char rcsid[] = "$Header: /var/lib/cvsd/repos/CSRG/43BSD/contrib/notes/src/pattern.c,v 1.1.1.1 2018/04/24 16:12:54 root Exp $";
#endif RCSIDENT
/*
* dopat - matches notesfile names and calls the desired routine with
* each matched arguement!
*
* Ray Essick Feb 25, 1982
*/
FILE * popen (); /* declare the function! */
dopat (p, what)
char *p; /* the pattern to match */
int (*what) (); /* routine to be called */
{
char cmd[CMDLEN];
int c,
i;
FILE * zfile;
sprintf (cmd, "(cd %s;echo %s)", Mstdir, p);
zfile = popen (cmd, "r"); /* read the output */
if (zfile == (FILE *) NULL)
return (0); /* failed somewhere */
/* pseudo-failure */
do
{
i = 0;
while ((c = getc (zfile)) != ' ' && (c != '\n') && (c != EOF))
cmd[i++] = c;
if (i == 0)
break;
cmd[i++] = '\0';
i = (*what) (cmd); /* call his routine for him */
} while ((c != EOF) && (i != QUITFAST) && (i != QUITUPD));
pclose (zfile); /* close that pipe! */
return i; /* return the return code */
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.