00001 00005 #include <sys/types.h> 00006 #include <sys/stat.h> 00007 #include <fcntl.h> 00008 #include <unistd.h> 00009 #include <stdlib.h> 00010 #include <stdio.h> 00011 #include <string.h> 00012 00013 #include <inttypes.h> 00014 #include <strings.h> 00015 #include <stringsearch.h> 00016 00017 int 00018 main(int argc, char **argv) 00019 { 00020 size_t haylen; 00021 size_t needlen; 00022 char *fnd; 00023 00024 if (argc < 3) { 00025 printf("usage: %s <haystack> <needle>\n", argv[0]); 00026 return (1); 00027 } 00028 haylen = strlen(argv[1]); 00029 needlen = strlen(argv[2]); 00030 00031 if (haylen < needlen) { 00032 printf("Needle is bigger than haystack!\n"); 00033 return (3); 00034 } 00035 fnd = inMem(argv[1], haylen, argv[2], needlen); 00036 if (fnd != NULL) { 00037 printf("found: %ld\n", (long)(fnd - argv[1])); 00038 } 00039 return (0); 00040 }