static char sccsid
[] = "@(#)gnsys.c 5.4 (Berkeley) 6/20/85";
#define LSIZE 128 /* number of systems to store */
#define WSUFSIZE 6 /* work file name suffix size */
* this routine will return the next system name which has work to be done.
* "sname" is a string of size DIRSIZ - WSUFSIZE.
* "pre" is the prefix for work files.
* "dir" is the directory to search.
* 1 - name returned in sname
* SUCCESS - no more names
register char *s
, *p1
, *p2
;
static char *list
[LSIZE
];
static int nitem
=0, n
=0, base
=0;
char systname
[NAMESIZE
], filename
[NAMESIZE
];
/* get list of systems with work */
dirp
= opendir(subdir(dir
,pre
));
ASSERT(dirp
!= NULL
, "BAD DIRECTORY", dir
, 0);
for (i
= base
; i
< LSIZE
; i
++)
while (gnamef(dirp
, filename
) != 0) {
if (!prefix(px
, filename
))
p2
= filename
+ strlen(filename
)
p1
= filename
+ strlen(px
);
for(s
= systname
; p1
<= p2
; p1
++)
nitem
= srchst(systname
, list
, nitem
);
if (LSIZE
<= nitem
) break;
for (n
= 0; n
< nitem
; n
++)
/* We only have at most a SYSNSIZE character site name encoded
* in the file. However, we would like to use the full sitename
* if possible. If the number of chars in list[n] is < SYSNSIZE
* then the sitename could not have been truncated and
* we don't bother to check. Otherwise, we scan SYSFILE
* looking for the fullname and return it if we find it
strcpy(sname
, list
[n
++]);
if (strlen(sname
) >= SYSNSIZE
) {
fp
= fopen(SYSFILE
, "r");
ASSERT(fp
!= NULL
, CANTOPEN
, SYSFILE
, 0);
while (cfgets(line
, sizeof(line
), fp
) != NULL
) {
if (strncmp(sname
, line
, SYSNSIZE
) == SAME
) {
strncpy(sname
, line
, MAXBASENAME
);
* this routine will do a linear search of list (list) to find name (name).
* If the name is not found, it is added to the list.
* The number of items in the list (n) is returned (incremented if a
* n - the number of items in the list
if (strcmp(name
, list
[i
]) == 0)
if ((p
= calloc((unsigned)strlen(name
) + 1, sizeof (char)))