/contrib/ntp/libntp/strstr.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 52 lines · 15 code · 6 blank · 31 comment · 3 complexity · 82390e108dcb8c537c39860b1e27f5f1 MD5 · raw file

  1. #include <config.h>
  2. #if !HAVE_STRSTR
  3. /*
  4. * Amanda, The Advanced Maryland Automatic Network Disk Archiver
  5. * Copyright (c) 1991-1998 University of Maryland at College Park
  6. * All Rights Reserved.
  7. *
  8. * Permission to use, copy, modify, distribute, and sell this software and its
  9. * documentation for any purpose is hereby granted without fee, provided that
  10. * the above copyright notice appear in all copies and that both that
  11. * copyright notice and this permission notice appear in supporting
  12. * documentation, and that the name of U.M. not be used in advertising or
  13. * publicity pertaining to distribution of the software without specific,
  14. * written prior permission. U.M. makes no representations about the
  15. * suitability of this software for any purpose. It is provided "as is"
  16. * without express or implied warranty.
  17. *
  18. * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
  20. * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  22. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  23. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  24. *
  25. * Author: James da Silva, Systems Design and Analysis Group
  26. * Computer Science Department
  27. * University of Maryland at College Park
  28. */
  29. /*
  30. * $Id$
  31. *
  32. * replacement for missing ANSI-C strstr function
  33. */
  34. char *strstr(a, b)
  35. char *a, *b;
  36. {
  37. int alen, blen, i;
  38. alen = strlen(a);
  39. blen = strlen(b);
  40. for(i=0; i <= alen-blen; i++, a++)
  41. if(strncmp(a, b, blen) == 0) return a;
  42. return NULL;
  43. }
  44. #else
  45. int strstr_bs;
  46. #endif