static char sccsid
[] = "%W% (Berkeley) %G%";
/* anlwrk 2.1 5/22/79 09:59:09 */
static char SiD
[] = "@(#)anlwrk 2.1";
* anlwrk(file, wvec) create a vector of command arguments
* 0 - no more work in this file
* positive number - number of arguments
if (fgets(str
, BUFSIZ
, fp
) == NULL
) {
return(getargs(str
, wvec
));
* iswrk(file, reqst, dir, pre)
* char *file, *reqst, *dir, *pre;
* iswrk - this routine will check the work list (list).
* If it is empty or the present work is exhausted, it
* will call gtwrk to generate a new list.
* The "reqst" field will be the string "chk" or "get" to
* check for work, or get the next work file respectively.
* 0 - no more work (or some error)
iswrk(file
, reqst
, dir
, pre
)
char *file
, *reqst
, *dir
, *pre
;
static char **listp
, *list
[LLEN
];
if (listp
== NULL
|| listp
>= &list
[LLEN
] || *listp
== NULL
|| !prefix(pre
, *listp
)) {
for (i
= 0, listp
= list
; i
< LLEN
; i
++) {
if (gtwrk(dir
, pre
, listp
= list
, LLEN
) != 0)
if (strcmp(reqst
, "get") == SAME
)
sprintf(file
, "%s/%s", dir
, *listp
++);
* gtwvec(file, dir, wkpre, wrkvec) get work vector
* char *file, *dir, *wkpre, **wrkvec;
* positive number - number of arguments
* 0 - no arguments - fail
gtwvec(file
, dir
, wkpre
, wrkvec
)
char *file
, *dir
, *wkpre
, **wrkvec
;
while ((nargs
= anlwrk(file
, wrkvec
)) == 0) {
if (!iswrk(file
, "get", dir
, wkpre
))
* gtwrk(dir, pre, list, llen)
* char *dir, *pre, **list;
* gtwrk - this routine will build a sorted list
* of files in a directory.
* "dir" is the directory name to search for file names
* beginning with the prefix (pre).
* "list" is the pointer to the list and "llen" is the
gtwrk(dir
, pre
, list
, llen
)
if ((pdir
= opendir(dir
)) == NULL
)
while ((dirp
= readdir(pdir
)) != NULL
&& (last
- first
) < llen
) {
if (!prefix(pre
, dirp
->d_name
))
if (strlen(dirp
->d_name
) - strlen(pre
) != 5)
if (stat(dirp
->d_name
, &s
) == -1)
if ((s
.st_mode
& ANYREAD
) == 0)
if ((p
= calloc(dirp
->d_namlen
+ 1, sizeof (char))) == NULL
)
qsort(first
, last
- first
, sizeof *last
, compar
);
* compar - this routine is used by qsort.
return(strcmp(*p1
, *p2
));