mco_lews_strcmp

Prototype

    int mco_lews_strcmp(const char *str, const char *buf, mco_uint2 start_pos, mco_uint2 buf_size);

Arguments

str
Null-terminated string to compare against the buffer.
buf
Pointer to the data buffer being examined.
start_pos
Starting offset within buf where comparison begins.
buf_size
Total size (in bytes) of the buffer pointed to by buf.

Description

This function compares the null-terminated string str with a segment of the buffer buf, starting at offset start_pos and spanning exactly mco_strlen(str) bytes—provided that the buffer has sufficient remaining length (i.e., start_pos + strlen(str) <= buf_size).

The comparison is case-sensitive and stops as soon as a mismatch is found or the entire string is matched.

    ...
    const char *uri = "/api/perf?hello=12&word=42 HTTP/1.1\r\n";
    ...
    int res = mco_lews_strcmp("api", uri, 1, 4);
    ASSERT_EQ(1, res);
    ...

Return Value

1
The string str matches the contents of buf starting at start_pos.
0
The strings do not match, or the buffer is too short to contain str at the specified position.

Files

Header file:
mcoewslite.h
Source file:
mcoewslite.c
Library:
mcoewslite.a