-/* $OpenBSD: aux.c,v 1.22 2004/09/15 22:21:40 deraadt Exp $ */
+/* $OpenBSD: aux.c,v 1.23 2008/07/15 19:23:26 martynas Exp $ */
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */
/*
#if 0
static const char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: aux.c,v 1.22 2004/09/15 22:21:40 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: aux.c,v 1.23 2008/07/15 19:23:26 martynas Exp $";
#endif
#endif /* not lint */
return(i);
}
-/*
- * Convert c to upper case
- */
-int
-chraise(int c)
-{
-
- if (islower(c))
- return(toupper(c));
- return(c);
-}
-
/*
* Copy s1 to s2, return pointer to null in s2.
*/
-/* $OpenBSD: extern.h,v 1.25 2006/05/02 05:28:07 hugh Exp $ */
+/* $OpenBSD: extern.h,v 1.26 2008/07/15 19:23:26 martynas Exp $ */
/* $NetBSD: extern.h,v 1.7 1997/07/09 05:22:00 mikel Exp $ */
/*-
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/20/95
- * $OpenBSD: extern.h,v 1.25 2006/05/02 05:28:07 hugh Exp $
+ * $OpenBSD: extern.h,v 1.26 2008/07/15 19:23:26 martynas Exp $
*/
struct name;
int pversion(void *);
int quit(void);
int quitcmd(void *);
-int chraise(int);
int readline(FILE *, char *, int, int *);
void register_file(FILE *, int, pid_t);
void regret(int);
-/* $OpenBSD: list.c,v 1.16 2005/07/11 14:08:23 millert Exp $ */
+/* $OpenBSD: list.c,v 1.17 2008/07/15 19:23:26 martynas Exp $ */
/* $NetBSD: list.c,v 1.7 1997/07/09 05:23:36 mikel Exp $ */
/*
#if 0
static const char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95";
#else
-static const char rcsid[] = "$OpenBSD: list.c,v 1.16 2005/07/11 14:08:23 millert Exp $";
+static const char rcsid[] = "$OpenBSD: list.c,v 1.17 2008/07/15 19:23:26 martynas Exp $";
#endif
#endif /* not lint */
int
matchsender(char *str, int mesg)
{
- char *cp, *cp2, *backup;
+ char *cp;
if (!*str) /* null string matches nothing instead of everything */
return(0);
- backup = cp2 = nameof(&message[mesg - 1], 0);
- cp = str;
- while (*cp2) {
- if (*cp == 0)
- return(1);
- if (chraise(*cp++) != chraise(*cp2++)) {
- cp2 = ++backup;
- cp = str;
- }
- }
- return(*cp == 0);
+ cp = nameof(&message[mesg - 1], 0);
+ return (strcasestr(cp, str) != NULL);
}
/*
matchto(char *str, int mesg)
{
struct message *mp;
- char *cp, *cp2, *backup, **to;
+ char *cp, **to;
str++;
mp = &message[mesg-1];
for (to = to_fields; *to; to++) {
- cp = str;
- cp2 = hfield(*to, mp);
- if (cp2 != NULL) {
- backup = cp2;
- while (*cp2) {
- if (*cp == 0)
- return(1);
- if (chraise(*cp++) != chraise(*cp2++)) {
- cp2 = ++backup;
- cp = str;
- }
- }
- if (*cp == 0)
- return(1);
- }
+ cp = hfield(*to, mp);
+ if (cp != NULL && strcasestr(cp, str) != NULL)
+ return(1);
}
return(0);
}
matchsubj(char *str, int mesg)
{
struct message *mp;
- char *cp, *cp2, *backup;
+ char *cp, *cp2;
str++;
if (*str == '\0')
*/
if (value("searchheaders") && (cp = strchr(str, ':'))) {
/* Check for special case "/To:" */
- if (chraise(str[0]) == 'T' && chraise(str[1]) == 'O' &&
- str[2] == ':')
+ if (strncasecmp(str, "to:", 3) == 0)
return(matchto(cp, mesg));
*cp++ = '\0';
cp2 = hfield(*str ? str : "subject", mp);
cp[-1] = ':';
str = cp;
+ cp = cp2;
} else {
- cp = str;
- cp2 = hfield("subject", mp);
+ cp = hfield("subject", mp);
}
- if (cp2 == NULL)
+ if (cp == NULL)
return(0);
- backup = cp2;
- while (*cp2) {
- if (*cp == 0)
- return(1);
- if (chraise(*cp++) != chraise(*cp2++)) {
- cp2 = ++backup;
- cp = str;
- }
- }
- return(*cp == 0);
+
+ return (strcasestr(cp, str) != NULL);
}
/*