Reuse, not rework

License Awareness

Highly Reusable Software

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Integer, Floating point, Matrix, Statistics, Boolean, ...

Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


librock_memistr - locate a string in a counted string or block of memory. Ignore case.
#License - #Source code - #Example Use -


#include <librock/parse.h>

char librock_PTR *librock_memistr(const char librock_PTR *pMem,
                                  const char librock_PTR *pszFind,
                                  int cbMem)


Returns a pointer to the first occurrence of all characters of pszFind in the memory block at pMem. The comparison is done with strncasecmp, and the tolower and toupper macros from <ctype.h> are used.

Typical use is wherever strstr is needed, but a memory block needs to be searched, not a NUL terminated string.

#ifdef librock_TYPICAL_USE_memistr
    const char buffer[] = "In the \0beginning.";
    const char *ptr;
    ptr = librock_memistr(buffer,"BEGIN",sizeof(buffer));
    if (ptr) {


  memchr() toupper() tolower()


  Copyright 1998-2002 Forrest J. Cavalier III,
  Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block.
  License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45

Source Code

./text/compsearch/memistr.c (implementation, plus source of this manual page)

Tests and Supported Platform Types

This is a representative sample. Librock code is highly portable. For a particular platform not reported here, request paid support

librock_memistr passed tests in tmemistr (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_memistr passed tests in tmemistr (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)

This software is part of Librock

Rapid reuse, without rework. Details
This page copyright (C) 2002-2003 Forrest J. Cavalier III, d-b-a Mib Software, Saylorsburg PA 18353, USA

Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)

Want to help? We welcome comments, patches. -- Need help? Request paid support.