1 /* 2 * Copyright (c) 1983 Eric P. Allman 3 * Copyright (c) 1988, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * %sccs.include.redist.c% 7 */ 8 9 #ifndef lint 10 static char sccsid[] = "@(#)util.c 8.1 (Berkeley) 06/27/93"; 11 #endif /* not lint */ 12 13 # include "sendmail.h" 14 # include <sysexits.h> 15 /* 16 ** STRIPQUOTES -- Strip quotes & quote bits from a string. 17 ** 18 ** Runs through a string and strips off unquoted quote 19 ** characters and quote bits. This is done in place. 20 ** 21 ** Parameters: 22 ** s -- the string to strip. 23 ** 24 ** Returns: 25 ** none. 26 ** 27 ** Side Effects: 28 ** none. 29 ** 30 ** Called By: 31 ** deliver 32 */ 33 34 stripquotes(s) 35 char *s; 36 { 37 register char *p; 38 register char *q; 39 register char c; 40 41 if (s == NULL) 42 return; 43 44 p = q = s; 45 do 46 { 47 c = *p++; 48 if (c == '\\') 49 c = *p++; 50 else if (c == '"') 51 continue; 52 *q++ = c; 53 } while (c != '\0'); 54 } 55 /* 56 ** XALLOC -- Allocate memory and bitch wildly on failure. 57 ** 58 ** THIS IS A CLUDGE. This should be made to give a proper 59 ** error -- but after all, what can we do? 60 ** 61 ** Parameters: 62 ** sz -- size of area to allocate. 63 ** 64 ** Returns: 65 ** pointer to data region. 66 ** 67 ** Side Effects: 68 ** Memory is allocated. 69 */ 70 71 char * 72 xalloc(sz) 73 register int sz; 74 { 75 register char *p; 76 77 p = malloc((unsigned) sz); 78 if (p == NULL) 79 { 80 syserr("Out of memory!!"); 81 abort(); 82 /* exit(EX_UNAVAILABLE); */ 83 } 84 return (p); 85 } 86 /* 87 ** COPYPLIST -- copy list of pointers. 88 ** 89 ** This routine is the equivalent of newstr for lists of 90 ** pointers. 91 ** 92 ** Parameters: 93 ** list -- list of pointers to copy. 94 ** Must be NULL terminated. 95 ** copycont -- if TRUE, copy the contents of the vector 96 ** (which must be a string) also. 97 ** 98 ** Returns: 99 ** a copy of 'list'. 100 ** 101 ** Side Effects: 102 ** none. 103 */ 104 105 char ** 106 copyplist(list, copycont) 107 char **list; 108 bool copycont; 109 { 110 register char **vp; 111 register char **newvp; 112 113 for (vp = list; *vp != NULL; vp++) 114 continue; 115 116 vp++; 117 118 newvp = (char **) xalloc((int) (vp - list) * sizeof *vp); 119 bcopy((char *) list, (char *) newvp, (int) (vp - list) * sizeof *vp); 120 121 if (copycont) 122 { 123 for (vp = newvp; *vp != NULL; vp++) 124 *vp = newstr(*vp); 125 } 126 127 return (newvp); 128 } 129 /* 130 ** COPYQUEUE -- copy address queue. 131 ** 132 ** This routine is the equivalent of newstr for address queues 133 ** addresses marked with QDONTSEND aren't copied 134 ** 135 ** Parameters: 136 ** addr -- list of address structures to copy. 137 ** 138 ** Returns: 139 ** a copy of 'addr'. 140 ** 141 ** Side Effects: 142 ** none. 143 */ 144 145 ADDRESS * 146 copyqueue(addr) 147 ADDRESS *addr; 148 { 149 register ADDRESS *newaddr; 150 ADDRESS *ret; 151 register ADDRESS **tail = &ret; 152 153 while (addr != NULL) 154 { 155 if (!bitset(QDONTSEND, addr->q_flags)) 156 { 157 newaddr = (ADDRESS *) xalloc(sizeof(ADDRESS)); 158 STRUCTCOPY(*addr, *newaddr); 159 *tail = newaddr; 160 tail = &newaddr->q_next; 161 } 162 addr = addr->q_next; 163 } 164 *tail = NULL; 165 166 return ret; 167 } 168 /* 169 ** PRINTAV -- print argument vector. 170 ** 171 ** Parameters: 172 ** av -- argument vector. 173 ** 174 ** Returns: 175 ** none. 176 ** 177 ** Side Effects: 178 ** prints av. 179 */ 180 181 printav(av) 182 register char **av; 183 { 184 while (*av != NULL) 185 { 186 if (tTd(0, 44)) 187 printf("\n\t%08x=", *av); 188 else 189 (void) putchar(' '); 190 xputs(*av++); 191 } 192 (void) putchar('\n'); 193 } 194 /* 195 ** LOWER -- turn letter into lower case. 196 ** 197 ** Parameters: 198 ** c -- character to turn into lower case. 199 ** 200 ** Returns: 201 ** c, in lower case. 202 ** 203 ** Side Effects: 204 ** none. 205 */ 206 207 char 208 lower(c) 209 register char c; 210 { 211 return((isascii(c) && isupper(c)) ? tolower(c) : c); 212 } 213 /* 214 ** XPUTS -- put string doing control escapes. 215 ** 216 ** Parameters: 217 ** s -- string to put. 218 ** 219 ** Returns: 220 ** none. 221 ** 222 ** Side Effects: 223 ** output to stdout 224 */ 225 226 xputs(s) 227 register char *s; 228 { 229 register int c; 230 register struct metamac *mp; 231 extern struct metamac MetaMacros[]; 232 233 if (s == NULL) 234 { 235 printf("<null>"); 236 return; 237 } 238 while ((c = (*s++ & 0377)) != '\0') 239 { 240 if (!isascii(c)) 241 { 242 if (c == MATCHREPL || c == MACROEXPAND) 243 { 244 putchar('$'); 245 continue; 246 } 247 for (mp = MetaMacros; mp->metaname != '\0'; mp++) 248 { 249 if ((mp->metaval & 0377) == c) 250 { 251 printf("$%c", mp->metaname); 252 break; 253 } 254 } 255 if (mp->metaname != '\0') 256 continue; 257 (void) putchar('\\'); 258 c &= 0177; 259 } 260 if (isprint(c)) 261 { 262 putchar(c); 263 continue; 264 } 265 266 /* wasn't a meta-macro -- find another way to print it */ 267 switch (c) 268 { 269 case '\0': 270 continue; 271 272 case '\n': 273 c = 'n'; 274 break; 275 276 case '\r': 277 c = 'r'; 278 break; 279 280 case '\t': 281 c = 't'; 282 break; 283 284 default: 285 (void) putchar('^'); 286 (void) putchar(c ^ 0100); 287 continue; 288 } 289 } 290 (void) fflush(stdout); 291 } 292 /* 293 ** MAKELOWER -- Translate a line into lower case 294 ** 295 ** Parameters: 296 ** p -- the string to translate. If NULL, return is 297 ** immediate. 298 ** 299 ** Returns: 300 ** none. 301 ** 302 ** Side Effects: 303 ** String pointed to by p is translated to lower case. 304 ** 305 ** Called By: 306 ** parse 307 */ 308 309 makelower(p) 310 register char *p; 311 { 312 register char c; 313 314 if (p == NULL) 315 return; 316 for (; (c = *p) != '\0'; p++) 317 if (isascii(c) && isupper(c)) 318 *p = tolower(c); 319 } 320 /* 321 ** BUILDFNAME -- build full name from gecos style entry. 322 ** 323 ** This routine interprets the strange entry that would appear 324 ** in the GECOS field of the password file. 325 ** 326 ** Parameters: 327 ** p -- name to build. 328 ** login -- the login name of this user (for &). 329 ** buf -- place to put the result. 330 ** 331 ** Returns: 332 ** none. 333 ** 334 ** Side Effects: 335 ** none. 336 */ 337 338 buildfname(gecos, login, buf) 339 register char *gecos; 340 char *login; 341 char *buf; 342 { 343 register char *p; 344 register char *bp = buf; 345 int l; 346 347 if (*gecos == '*') 348 gecos++; 349 350 /* find length of final string */ 351 l = 0; 352 for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++) 353 { 354 if (*p == '&') 355 l += strlen(login); 356 else 357 l++; 358 } 359 360 /* now fill in buf */ 361 for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++) 362 { 363 if (*p == '&') 364 { 365 (void) strcpy(bp, login); 366 *bp = toupper(*bp); 367 while (*bp != '\0') 368 bp++; 369 } 370 else 371 *bp++ = *p; 372 } 373 *bp = '\0'; 374 } 375 /* 376 ** SAFEFILE -- return true if a file exists and is safe for a user. 377 ** 378 ** Parameters: 379 ** fn -- filename to check. 380 ** uid -- uid to compare against. 381 ** mode -- mode bits that must match. 382 ** 383 ** Returns: 384 ** 0 if fn exists, is owned by uid, and matches mode. 385 ** An errno otherwise. The actual errno is cleared. 386 ** 387 ** Side Effects: 388 ** none. 389 */ 390 391 #ifndef S_IXOTH 392 # define S_IXOTH (S_IEXEC >> 6) 393 #endif 394 395 int 396 safefile(fn, uid, mode) 397 char *fn; 398 uid_t uid; 399 int mode; 400 { 401 register char *p; 402 struct stat stbuf; 403 404 if (tTd(54, 4)) 405 printf("safefile(%s, %d, %o): ", fn, uid, mode); 406 errno = 0; 407 408 for (p = fn; (p = strchr(++p, '/')) != NULL; *p = '/') 409 { 410 *p = '\0'; 411 if (stat(fn, &stbuf) < 0 || !bitset(S_IXOTH, stbuf.st_mode)) 412 { 413 int ret = errno; 414 415 if (ret == 0) 416 ret = EACCES; 417 if (tTd(54, 4)) 418 printf("[dir %s] %s\n", fn, errstring(ret)); 419 *p = '/'; 420 return ret; 421 } 422 } 423 424 if (stat(fn, &stbuf) < 0) 425 { 426 int ret = errno; 427 428 if (tTd(54, 4)) 429 printf("%s\n", errstring(ret)); 430 431 errno = 0; 432 return ret; 433 } 434 if (stbuf.st_uid != uid && uid == 0) 435 mode >>= 6; 436 if (tTd(54, 4)) 437 printf("[uid %d, stat %o] ", stbuf.st_uid, stbuf.st_mode); 438 if ((stbuf.st_uid == uid || uid == 0) && 439 (stbuf.st_mode & mode) == mode) 440 { 441 if (tTd(54, 4)) 442 printf("OK\n"); 443 return 0; 444 } 445 if (tTd(54, 4)) 446 printf("EACCES\n"); 447 return EACCES; 448 } 449 /* 450 ** FIXCRLF -- fix <CR><LF> in line. 451 ** 452 ** Looks for the <CR><LF> combination and turns it into the 453 ** UNIX canonical <NL> character. It only takes one line, 454 ** i.e., it is assumed that the first <NL> found is the end 455 ** of the line. 456 ** 457 ** Parameters: 458 ** line -- the line to fix. 459 ** stripnl -- if true, strip the newline also. 460 ** 461 ** Returns: 462 ** none. 463 ** 464 ** Side Effects: 465 ** line is changed in place. 466 */ 467 468 fixcrlf(line, stripnl) 469 char *line; 470 bool stripnl; 471 { 472 register char *p; 473 474 p = strchr(line, '\n'); 475 if (p == NULL) 476 return; 477 if (p > line && p[-1] == '\r') 478 p--; 479 if (!stripnl) 480 *p++ = '\n'; 481 *p = '\0'; 482 } 483 /* 484 ** DFOPEN -- determined file open 485 ** 486 ** This routine has the semantics of fopen, except that it will 487 ** keep trying a few times to make this happen. The idea is that 488 ** on very loaded systems, we may run out of resources (inodes, 489 ** whatever), so this tries to get around it. 490 */ 491 492 struct omodes 493 { 494 int mask; 495 int mode; 496 char *farg; 497 } OpenModes[] = 498 { 499 O_ACCMODE, O_RDONLY, "r", 500 O_ACCMODE|O_APPEND, O_WRONLY, "w", 501 O_ACCMODE|O_APPEND, O_WRONLY|O_APPEND, "a", 502 O_TRUNC, 0, "w+", 503 O_APPEND, O_APPEND, "a+", 504 0, 0, "r+", 505 }; 506 507 FILE * 508 dfopen(filename, omode, cmode) 509 char *filename; 510 int omode; 511 int cmode; 512 { 513 register int tries; 514 int fd; 515 register struct omodes *om; 516 struct stat st; 517 518 for (om = OpenModes; om->mask != 0; om++) 519 if ((omode & om->mask) == om->mode) 520 break; 521 522 for (tries = 0; tries < 10; tries++) 523 { 524 sleep((unsigned) (10 * tries)); 525 errno = 0; 526 fd = open(filename, omode, cmode); 527 if (fd >= 0) 528 break; 529 if (errno != ENFILE && errno != EINTR) 530 break; 531 } 532 if (fd >= 0 && fstat(fd, &st) >= 0 && S_ISREG(st.st_mode)) 533 { 534 int locktype; 535 536 /* lock the file to avoid accidental conflicts */ 537 if ((omode & O_ACCMODE) != O_RDONLY) 538 locktype = LOCK_EX; 539 else 540 locktype = LOCK_SH; 541 (void) lockfile(fd, filename, locktype); 542 errno = 0; 543 } 544 return fdopen(fd, om->farg); 545 } 546 /* 547 ** PUTLINE -- put a line like fputs obeying SMTP conventions 548 ** 549 ** This routine always guarantees outputing a newline (or CRLF, 550 ** as appropriate) at the end of the string. 551 ** 552 ** Parameters: 553 ** l -- line to put. 554 ** fp -- file to put it onto. 555 ** m -- the mailer used to control output. 556 ** 557 ** Returns: 558 ** none 559 ** 560 ** Side Effects: 561 ** output of l to fp. 562 */ 563 564 putline(l, fp, m) 565 register char *l; 566 FILE *fp; 567 MAILER *m; 568 { 569 register char *p; 570 register char svchar; 571 572 /* strip out 0200 bits -- these can look like TELNET protocol */ 573 if (bitnset(M_7BITS, m->m_flags)) 574 { 575 for (p = l; (svchar = *p) != '\0'; ++p) 576 if (bitset(0200, svchar)) 577 *p = svchar &~ 0200; 578 } 579 580 do 581 { 582 /* find the end of the line */ 583 p = strchr(l, '\n'); 584 if (p == NULL) 585 p = &l[strlen(l)]; 586 587 /* check for line overflow */ 588 while (m->m_linelimit > 0 && (p - l) > m->m_linelimit) 589 { 590 register char *q = &l[m->m_linelimit - 1]; 591 592 svchar = *q; 593 *q = '\0'; 594 if (l[0] == '.' && bitnset(M_XDOT, m->m_flags)) 595 (void) putc('.', fp); 596 fputs(l, fp); 597 (void) putc('!', fp); 598 fputs(m->m_eol, fp); 599 *q = svchar; 600 l = q; 601 } 602 603 /* output last part */ 604 if (l[0] == '.' && bitnset(M_XDOT, m->m_flags)) 605 (void) putc('.', fp); 606 for ( ; l < p; ++l) 607 (void) putc(*l, fp); 608 fputs(m->m_eol, fp); 609 if (*l == '\n') 610 ++l; 611 } while (l[0] != '\0'); 612 } 613 /* 614 ** XUNLINK -- unlink a file, doing logging as appropriate. 615 ** 616 ** Parameters: 617 ** f -- name of file to unlink. 618 ** 619 ** Returns: 620 ** none. 621 ** 622 ** Side Effects: 623 ** f is unlinked. 624 */ 625 626 xunlink(f) 627 char *f; 628 { 629 register int i; 630 631 # ifdef LOG 632 if (LogLevel > 98) 633 syslog(LOG_DEBUG, "%s: unlink %s", CurEnv->e_id, f); 634 # endif /* LOG */ 635 636 i = unlink(f); 637 # ifdef LOG 638 if (i < 0 && LogLevel > 97) 639 syslog(LOG_DEBUG, "%s: unlink-fail %d", f, errno); 640 # endif /* LOG */ 641 } 642 /* 643 ** XFCLOSE -- close a file, doing logging as appropriate. 644 ** 645 ** Parameters: 646 ** fp -- file pointer for the file to close 647 ** a, b -- miscellaneous crud to print for debugging 648 ** 649 ** Returns: 650 ** none. 651 ** 652 ** Side Effects: 653 ** fp is closed. 654 */ 655 656 xfclose(fp, a, b) 657 FILE *fp; 658 char *a, *b; 659 { 660 if (tTd(53, 99)) 661 printf("xfclose(%x) %s %s\n", fp, a, b); 662 if (fclose(fp) < 0 && tTd(53, 99)) 663 printf("xfclose FAILURE: %s\n", errstring(errno)); 664 } 665 /* 666 ** SFGETS -- "safe" fgets -- times out and ignores random interrupts. 667 ** 668 ** Parameters: 669 ** buf -- place to put the input line. 670 ** siz -- size of buf. 671 ** fp -- file to read from. 672 ** timeout -- the timeout before error occurs. 673 ** during -- what we are trying to read (for error messages). 674 ** 675 ** Returns: 676 ** NULL on error (including timeout). This will also leave 677 ** buf containing a null string. 678 ** buf otherwise. 679 ** 680 ** Side Effects: 681 ** none. 682 */ 683 684 static jmp_buf CtxReadTimeout; 685 686 char * 687 sfgets(buf, siz, fp, timeout, during) 688 char *buf; 689 int siz; 690 FILE *fp; 691 time_t timeout; 692 char *during; 693 { 694 register EVENT *ev = NULL; 695 register char *p; 696 static int readtimeout(); 697 698 /* set the timeout */ 699 if (timeout != 0) 700 { 701 if (setjmp(CtxReadTimeout) != 0) 702 { 703 # ifdef LOG 704 syslog(LOG_NOTICE, 705 "timeout waiting for input from %s during %s\n", 706 CurHostName? CurHostName: "local", during); 707 # endif 708 errno = 0; 709 usrerr("451 timeout waiting for input during %s", 710 during); 711 buf[0] = '\0'; 712 return (NULL); 713 } 714 ev = setevent(timeout, readtimeout, 0); 715 } 716 717 /* try to read */ 718 p = NULL; 719 while (p == NULL && !feof(fp) && !ferror(fp)) 720 { 721 errno = 0; 722 p = fgets(buf, siz, fp); 723 if (errno == EINTR) 724 clearerr(fp); 725 } 726 727 /* clear the event if it has not sprung */ 728 clrevent(ev); 729 730 /* clean up the books and exit */ 731 LineNumber++; 732 if (p == NULL) 733 { 734 buf[0] = '\0'; 735 return (NULL); 736 } 737 if (SevenBit) 738 for (p = buf; *p != '\0'; p++) 739 *p &= ~0200; 740 return (buf); 741 } 742 743 static 744 readtimeout() 745 { 746 longjmp(CtxReadTimeout, 1); 747 } 748 /* 749 ** FGETFOLDED -- like fgets, but know about folded lines. 750 ** 751 ** Parameters: 752 ** buf -- place to put result. 753 ** n -- bytes available. 754 ** f -- file to read from. 755 ** 756 ** Returns: 757 ** input line(s) on success, NULL on error or EOF. 758 ** This will normally be buf -- unless the line is too 759 ** long, when it will be xalloc()ed. 760 ** 761 ** Side Effects: 762 ** buf gets lines from f, with continuation lines (lines 763 ** with leading white space) appended. CRLF's are mapped 764 ** into single newlines. Any trailing NL is stripped. 765 */ 766 767 char * 768 fgetfolded(buf, n, f) 769 char *buf; 770 register int n; 771 FILE *f; 772 { 773 register char *p = buf; 774 char *bp = buf; 775 register int i; 776 777 n--; 778 while ((i = getc(f)) != EOF) 779 { 780 if (i == '\r') 781 { 782 i = getc(f); 783 if (i != '\n') 784 { 785 if (i != EOF) 786 (void) ungetc(i, f); 787 i = '\r'; 788 } 789 } 790 if (--n <= 0) 791 { 792 /* allocate new space */ 793 char *nbp; 794 int nn; 795 796 nn = (p - bp); 797 if (nn < MEMCHUNKSIZE) 798 nn *= 2; 799 else 800 nn += MEMCHUNKSIZE; 801 nbp = xalloc(nn); 802 bcopy(bp, nbp, p - bp); 803 p = &nbp[p - bp]; 804 if (bp != buf) 805 free(bp); 806 bp = nbp; 807 n = nn - (p - bp); 808 } 809 *p++ = i; 810 if (i == '\n') 811 { 812 LineNumber++; 813 i = getc(f); 814 if (i != EOF) 815 (void) ungetc(i, f); 816 if (i != ' ' && i != '\t') 817 break; 818 } 819 } 820 if (p == bp) 821 return (NULL); 822 *--p = '\0'; 823 return (bp); 824 } 825 /* 826 ** CURTIME -- return current time. 827 ** 828 ** Parameters: 829 ** none. 830 ** 831 ** Returns: 832 ** the current time. 833 ** 834 ** Side Effects: 835 ** none. 836 */ 837 838 time_t 839 curtime() 840 { 841 auto time_t t; 842 843 (void) time(&t); 844 return (t); 845 } 846 /* 847 ** ATOBOOL -- convert a string representation to boolean. 848 ** 849 ** Defaults to "TRUE" 850 ** 851 ** Parameters: 852 ** s -- string to convert. Takes "tTyY" as true, 853 ** others as false. 854 ** 855 ** Returns: 856 ** A boolean representation of the string. 857 ** 858 ** Side Effects: 859 ** none. 860 */ 861 862 bool 863 atobool(s) 864 register char *s; 865 { 866 if (*s == '\0' || strchr("tTyY", *s) != NULL) 867 return (TRUE); 868 return (FALSE); 869 } 870 /* 871 ** ATOOCT -- convert a string representation to octal. 872 ** 873 ** Parameters: 874 ** s -- string to convert. 875 ** 876 ** Returns: 877 ** An integer representing the string interpreted as an 878 ** octal number. 879 ** 880 ** Side Effects: 881 ** none. 882 */ 883 884 atooct(s) 885 register char *s; 886 { 887 register int i = 0; 888 889 while (*s >= '0' && *s <= '7') 890 i = (i << 3) | (*s++ - '0'); 891 return (i); 892 } 893 /* 894 ** WAITFOR -- wait for a particular process id. 895 ** 896 ** Parameters: 897 ** pid -- process id to wait for. 898 ** 899 ** Returns: 900 ** status of pid. 901 ** -1 if pid never shows up. 902 ** 903 ** Side Effects: 904 ** none. 905 */ 906 907 waitfor(pid) 908 int pid; 909 { 910 auto int st; 911 int i; 912 913 do 914 { 915 errno = 0; 916 i = wait(&st); 917 } while ((i >= 0 || errno == EINTR) && i != pid); 918 if (i < 0) 919 st = -1; 920 return (st); 921 } 922 /* 923 ** BITINTERSECT -- tell if two bitmaps intersect 924 ** 925 ** Parameters: 926 ** a, b -- the bitmaps in question 927 ** 928 ** Returns: 929 ** TRUE if they have a non-null intersection 930 ** FALSE otherwise 931 ** 932 ** Side Effects: 933 ** none. 934 */ 935 936 bool 937 bitintersect(a, b) 938 BITMAP a; 939 BITMAP b; 940 { 941 int i; 942 943 for (i = BITMAPBYTES / sizeof (int); --i >= 0; ) 944 if ((a[i] & b[i]) != 0) 945 return (TRUE); 946 return (FALSE); 947 } 948 /* 949 ** BITZEROP -- tell if a bitmap is all zero 950 ** 951 ** Parameters: 952 ** map -- the bit map to check 953 ** 954 ** Returns: 955 ** TRUE if map is all zero. 956 ** FALSE if there are any bits set in map. 957 ** 958 ** Side Effects: 959 ** none. 960 */ 961 962 bool 963 bitzerop(map) 964 BITMAP map; 965 { 966 int i; 967 968 for (i = BITMAPBYTES / sizeof (int); --i >= 0; ) 969 if (map[i] != 0) 970 return (FALSE); 971 return (TRUE); 972 } 973 /* 974 ** STRCONTAINEDIN -- tell if one string is contained in another 975 ** 976 ** Parameters: 977 ** a -- possible substring. 978 ** b -- possible superstring. 979 ** 980 ** Returns: 981 ** TRUE if a is contained in b. 982 ** FALSE otherwise. 983 */ 984 985 bool 986 strcontainedin(a, b) 987 register char *a; 988 register char *b; 989 { 990 int l; 991 992 l = strlen(a); 993 for (;;) 994 { 995 b = strchr(b, a[0]); 996 if (b == NULL) 997 return FALSE; 998 if (strncmp(a, b, l) == 0) 999 return TRUE; 1000 b++; 1001 } 1002 } 1003