It's not safe to assume that
string data contained in marshal buffers (such as URLs and MIME
fields) is stored in null-terminated string copies. Therefore,
your plugins should always use the length parameter when retrieving or
manipulating these strings. You cannot pass in NULL
for
string-length return values; string values returned from marshall
buffers are not null-terminated. If you need a null-terminated value,
then use INKstrndup
to automatically null-terminate a
string. The strings that come back and are not null-terminated
cannot be passed into the common
str*()
routines
![]() |
Note |
---|---|
Values returned from a marshall buffer can be
For example (from the char *host_string; int host_length; host_string = INKUrlHostGet (bufp, url_loc, &host_length); for (i = 0; i < nsites; i++) { if (strncmp (host_string, sites[i], host_length) == 0) { ... } See the sample plugins for additional examples. |