/*
 * strstr() - find a String within a buffer (string).
 *
 * Made by Kasper B. Graversen (c) 1996
 *
 * This is freeware - use at own risc.
 *
 * Converted to Small C+ 1/3/99 djm
 *
 * This routine was obtained from the vbcc archive
 *
 */

/*
 *      This little bit of trickery should allow us to have this
 *      function defined without the smc prefix!
 */


#pragma proto HDRPRTYPE

extern char *strstr();
extern int strlen();

#pragma unproto HDRPRTYPE

/*
 *      Because we're compiling this we -no-header, we have to tell
 *      the compiler, whats what...
 */

#asm
        LIB     strlen
#endasm



#define size_t int
#define const


strstr(unsigned char *buf, unsigned char *str)
{
    size_t len_s;
    unsigned char *t;
    unsigned char c;
    size_t done;

    len_s = strlen(str);

    do
    {
        if(*str == *buf)
        {
            done = len_s;

            t = str + 1;
            buf++;

            while((--done) && (*t == *buf))
            {
                t++;
                buf++;
            }

            if(!done)
            {
                buf -= len_s;
                return(buf);
            }
            else
                buf--;
        }

    } while((c = *buf++) != 0);

    /* nothing found */
    return(0);
}



