brian@hfh.edu (Brian A. Wolfe) (08/17/89)
Hi there, I'm trying to install sendmail 5.61 on a Vax running Ultrix 2.2, I managed to provide several of the files that are missing with Ultrix 2.2 (resolv.h, nameser.h, a few changes in netdb.h) but now I'm down to just one routine that I can't seem to track down. The routine is 'strcasecmp', which is called by at least 5 routines in sendmail 5.61. I can find no mention of it in any of the unix doc's I have (Sun, DEC, ATT Sys V), if I knew what it was for I would write it myself. Can anyone shed any light on this? Thanks, Brian. -- Brian Wolfe Internet: brian@hfh.edu BITNET: USERW18Y@UMICHUM Systems Analyst UUCP: {rutgers,itivax,uunet}!sharkey!hfhrv!baw Henry Ford Hospital Voice: (313)-876-7461 Detroit MI 48202 FAX: (313)-875-0315
lear@NET.BIO.NET (Eliot Lear) (08/17/89)
strcasecmp is a case insensitive string compare which is almost certainly available in the Tahoe release, and definitely available on uunet in bsd-sources/src/lib/libc/gen/strcasecmp.c. -- Eliot Lear [lear@net.bio.net]
dah@esfenn.UUCP (Darrin Hyrup) (08/19/89)
strcasecmp() is a case insensitive string compare function. Not usually bundled with many default libraries. Here is a version of the function for ya... int cstrcmp(s1, s2) /* also known as strcasecmp() */ register char *s1, *s2; { while(tolower(*s1) == tolower(*s2++)) if(*s1++ == '\0') return(0); return(tolower(*s1) - tolower(*--s2)); } int cstrncmp(s1, s2, n) /* also known as strncasecmp() */ register char *s1, *s2; register int n; { while(--n >= 0 && tolower(*s1) == tolower(*s2++)) if(*s1++ == '\0') return(0); return(n < 0 ? 0 : tolower(*s1) - tolower(*--s2)); } Hope that helps! Darrin Hyrup dah@esfenn.UUCP
dell@amelia.nas.nasa.gov (Thomas E. Dell) (08/21/89)
In article <475@esfenn.UUCP> dah@.UUCP (Darrin Hyrup) writes: >int cstrcmp(s1, s2) /* also known as strcasecmp() */ >register char *s1, *s2; >{ > while(tolower(*s1) == tolower(*s2++)) > if(*s1++ == '\0') > return(0); > return(tolower(*s1) - tolower(*--s2)); >} Not quite.. a number of versions of Unix have the result of tolower(c) undefined (read: wrong) if c is not uppercase. This is because #define tolower(c) ((c) + ' ') or something similar is used. If you #define your own, remember you can only have ONE (c) in the definition or you will have side effects problems, s2 being incremented twice or whatnot. I've also seen tolower() and toupper() done as functions in the C library. If this is the case, you have the overhead of two procedure calls for each character in the string. Poor. You're better off hacking up a cstrcmp the hard way.. -- Tom dell@amelia.nas.nasa.gov