home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
archivers
/
arcppc
/
src
/
rcs
/
arcmatch.c,v
< prev
next >
Wrap
Text File
|
1998-04-23
|
5KB
|
300 lines
head 1.6;
branch ;
access ;
symbols patch1:1.6;
locks ; strict;
comment @ * @;
1.6
date 88.07.31.18.50.18; author hyc; state Exp;
branches ;
next 1.5;
1.5
date 88.06.01.19.41.08; author hyc; state Exp;
branches ;
next 1.4;
1.4
date 88.06.01.15.53.59; author hyc; state Exp;
branches ;
next 1.3;
1.3
date 88.06.01.15.51.54; author hyc; state Exp;
branches ;
next 1.2;
1.2
date 88.04.11.18.20.43; author hyc; state Exp;
branches ;
next 1.1;
1.1
date 88.04.11.18.12.56; author hyc; state Exp;
branches ;
next ;
desc
@@
1.6
log
@Allow "*.*" to mean '*' for GEMDOS wildcard
@
text
@/*
* $Header: arcmatch.c,v 1.5 88/06/01 19:41:08 hyc Locked $
*/
/*
* ARC - Archive utility - ARCMATCH
*
* Version 2.17, created on 12/17/85 at 20:32:18
*
* (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
*
* By: Thom Henderson
*
* Description: This file contains service routines needed to maintain an
* archive.
*
* Language: Computer Innovations Optimizing C86
*/
#include <stdio.h>
#include "arc.h"
int strcmp(), strlen();
void abort();
char *strcpy();
int
match(n, t) /* test name against template */
char *n; /* name to test */
char *t; /* template to test against */
{
#if MTS
fortran patbuild(), patmatch(), patfree();
static int patlen = (-1);
static int patwork = 0;
static int patswch = 0;
char patccid[4];
static char patchar[2] = "?";
static char oldtemp[16] = 0;
int namlen, RETCODE;
if (strcmp(t, oldtemp)) {
if (patwork)
patfree(&patwork);
strcpy(oldtemp, t);
patlen = strlen(oldtemp);
patbuild(oldtemp, &patlen, &patwork, &patswch, patccid, patchar, _retcode RETCODE);
if (RETCODE > 8) {
printf("MTS: patbuild returned %d\n", RETCODE);
abort("bad wildcard in filename");
}
}
namlen = strlen(n);
patmatch(n, &namlen, &patwork, _retcode RETCODE);
switch (RETCODE) {
case 0:
return (1);
case 4:
return (0);
default:
abort("wildcard pattern match failed");
}
}
#else
#if !UNIX
upper(n);
upper(t); /* avoid case problems */
#endif /* UNIX */
#if GEMDOS
char *strstr(), *i; /* allow "*.*" to mean '*' */
if (i=strstr(t,"*.*")) {
i++;
*i='\0';
}
return(pnmatch(n, t, 0));
#else
/* first match name part */
while ((*n && *n != '.') || (*t && *t != '.')) {
if (*n != *t && *t != '?') { /* match fail? */
if (*t != '*') /* wildcard fail? */
return 0; /* then no match */
else { /* else jump over wildcard */
while (*n && *n != '.')
n++;
while (*t && *t != '.')
t++;
break; /* name part matches wildcard */
}
} else { /* match good for this char */
n++; /* advance to next char */
t++;
}
}
if (*n && *n == '.')
n++; /* skip extension delimiters */
if (*t && *t == '.')
t++;
/* now match name part */
while (*n || *t) {
if (*n != *t && *t != '?') { /* match fail? */
if (*t != '*') /* wildcard fail? */
return 0; /* then no match */
else
return 1; /* else good enough */
} else { /* match good for this char */
n++; /* advance to next char */
t++;
}
}
return 1; /* match worked */
#endif /* GEMDOS */
}
#endif
void
rempath(nargs, arg) /* remove paths from filenames */
int nargs; /* number of names */
char *arg[]; /* pointers to names */
{
char *i, *rindex(); /* string index, reverse indexer */
int n; /* index */
for (n = 0; n < nargs; n++) { /* for each supplied name */
if (!(i = rindex(arg[n], '\\'))) /* search for end of
* path */
if (!(i = rindex(arg[n], '/')))
i = rindex(arg[n], ':');
if (i) /* if path was found */
arg[n] = i + 1; /* then skip it */
}
}
@
1.5
log
@Changed compilation conditionals
@
text
@d2 1
a2 1
* $Header: arcmatch.c,v 1.4 88/06/01 15:53:59 hyc Locked $
d70 5
@
1.4
log
@Merge Atari ST code
@
text
@d2 1
a2 1
* $Header: arcmatch.c,v 1.3 88/06/01 15:51:54 hyc Locked $
d31 1
a31 1
#ifdef MTS
d65 1
a65 1
#ifndef BSD
d68 2
a69 2
#endif /* BSD */
#ifdef GEMDOS
@
1.3
log
@Fix declarations
@
text
@d2 1
a2 1
* $Header: arcmatch.c,v 1.4 88/04/19 01:40:01 hyc Exp $
d69 3
a71 1
d111 1
@
1.2
log
@fixup pattern matching for BSD...
@
text
@d2 1
a2 16
* $Log: arcmatch.c,v $
* Revision 1.1 88/04/11 18:12:56 hyc
* Initial revision
*
* Revision 1.2 87/12/19 04:39:35 hyc
* Don't convert names to upper case for BSD...
*
* Revision 1.1 87/12/19 04:39:06 hyc
* Initial revision
*
* Revision 1.3 87/08/13 17:05:01 hyc
* Run thru indent, fixed some signed vs. unsigned problems
* with bp <-> buf, and inbuf and localbuf...
* Revision 1.2 87/07/21 08:48:16 hyc ***
* empty log message ***
*
d22 5
a26 1
INT
d68 1
a93 2
#endif /* BSD */
d112 1
a112 1
INT
d114 1
a114 1
INT nargs; /* number of names */
d118 1
a118 1
INT n; /* index */
@
1.1
log
@Initial revision
@
text
@d3 3
d50 1
a50 1
int namlen;
d57 1
a57 1
patbuild(oldtemp, &patlen, &patwork, &patswch, patccid, patchar);
d64 1
a64 1
patmatch(n, &namlen, &patwork);
a78 1
#endif
d104 2
d133 1
a133 1
if (!(i = rindex(arg[n], '\\'))) /* search for end of *
@