home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
canada-remote-systems
/
cpower
/
globcp.arc
/
GLOB.C
< prev
next >
Wrap
Text File
|
2019-04-13
|
2KB
|
84 lines
/*
* ├OPYRIGHT (├) ┴DRIAN ╨EPPER, 1989
*
* ┬UT ╔ (┴DRIAN ╨EPPER) CONSIDER THIS
* MATERIAL TO BE IN THE ╨UBLIC ─OMAIN.
*/
/*
* GLOB.C - EXPAND WILDCARD FILENAMES
*/
#INCLUDE <STDIO.H>
/*
* SELECT - DOUBLE CHECK NAMES MATCHED
* BY 1541(ETC.) DOS
*/
CHAR *GLOBAFTER = ╬╒╠╠;
CHAR *SAVEPAT = ╬╒╠╠;
STATIC SELECT(NAME)
CHAR *NAME;
█
IF (GLOBAFTER)
IF (WILDMATCH(GLOBAFTER, NAME))
GLOBAFTER = ╬╒╠╠;
ELSE
RETURN 0;
RETURN WILDMATCH(SAVEPAT, NAME);
▌
/*
* GLOB - EXECUTE GIVEN FUNCTION FOR EACH
* FILE ON THE WORK DEVICE MATCHING
* THE GIVEN PATTERN
*/
GLOB(PAT,FUNC) /* RETURN QUIT/CONTINUE STATUS */
CHAR *PAT; /* FILENAME PATTERN TO EXPAND */
INT (*FUNC)(); /* FUNCTION TO CALL ON MATCHES */
█
INT SELECT();
EXTERN INT SPRINTF();
EXTERN CHAR *MALLOC();
CHAR *DISKPAT;
CHAR *P;
CHAR *CLASS; /* FLAG IF CHAR CLASS ([XYZ]) */
UNSIGNED INBASIC; /* FLAG IF WE ARE LINKED AS BASIC PROGRAM */
UNSIGNED DEV;
DISKPAT = STRDUP(PAT);
IF (GLOBAFTER) /* MUST CHECK ALL PATTERNS */
DISKPAT = STRDUP("*");
/* FIRST TURN ANY CLASS AND SUFFIX TO '*' */
CLASS = INDEX(DISKPAT, '[');
IF (CLASS)
STRCPY(CLASS,"*");
/* ALSO TURN EVERYTHING AFTER '*' TO STAR */
/* WILL ALWAYS SUCCEED IF WE HAD '[' ABOVE */
CLASS = INDEX(DISKPAT, '*');
IF (CLASS)
STRCPY(CLASS,"*");
#DEFINE WRKDEV (*(CHAR *)0X17FC)
/* DEVICE SET BY SHELL WORK COMMAND */
#DEFINE KRNDEV (*(CHAR *)0XBA)
/* DEVICE LAST USED FOR KERNAL ╧╨┼╬ */
DEV = WRKDEV;
/* ┴╙╙┼╥╘: SPRINTF NEEDED BY DEVGLOB */
INBASIC = &SPRINTF > 0X880;
IF (INBASIC) DEV = KRNDEV;
/* MAKE PAT ACCESSIBLE TO SELECT */
IF (PAT[0] == ':') /* FILE NAMES WON'T CONTAIN DRIVE */
P = PAT+1;
ELSE IF (PAT[1] == ':')
P = PAT+2;
ELSE
P = PAT;
SAVEPAT = STRDUP(P);
/* REMOVE =TYP FROM END OF PATTERN */
/* SINCE IT WON'T APPEAR EITHER */
P = RINDEX(SAVEPAT, '=');
IF (P >= SAVEPAT+STRLEN(SAVEPAT)-4 ) █
IF (CLASS) /* MUST ADD BACK TO DISK PATTERN */
STRCAT(DISKPAT,P);
*P = '\0';
▌
RETURN DEVGLOB(DEV, DISKPAT, FUNC, &SELECT);
▌