/usr/include/modp_qsiter.h is in libmodpbase64-dev 3.10.3+git20160924-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #ifndef COM_MODP_QSITER
#define COM_MODP_QSITER
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \file modp_qsiter.h
* \brief URL Query string key-value pair iterator. Uses no heap, makes
* no copy, makes no modification of input. Think of this as a
* super-strtok_r.
*
* This also does not do query-string un-escaping.
*
* \code
* qsiiter_t qsi;
* const char* qs = "foo=bar&ding=bar";
* qsiter_reset(&qsi, qs, strlen(qs));
* while (qsiter_next(&qsi)) {
* // we only get start and length of key,value
* // up to you how to copy it or not, on heap or stack
* // with strcpy, strncpy, strndup, memcpy, mempcpy, strlcpy, whatever
* // callers job to alloc/free memory
*
* const char* key = (const char*) malloc(qsi.keylen + 1);
* strcpy(key, qsi->key, qsi->keylen);
* const char* val = (const char*) malloc(qsi.vallen + 1);
* strcpy(val, qsi->val, qsi->vallen);
* printf("key = %s, value = %s\n", key, val);
* free(key);
* free(value);
* }
* \endcode
*
*/
struct qsiter_t {
const char* s;
size_t pos;
size_t len;
const char* key;
size_t keylen;
const char* val;
size_t vallen;
};
/**
* Reset a qsiter to an initial start (constructor)
*
* This does not modifiy the original string, nor makes a copy.
*
* \param[out] qsi data struct used in iterator
* \param[in] s input string (does not need to be 0-terminated)
* \param[in] len input string length
*
*/
void qsiter_reset(struct qsiter_t* qsi, const char* s, size_t len);
/**
* Get next key/value pair in query string
*
* \param[out] qsi data struct
* \return 1 if found a key value pair, 0 if no more data
*/
int qsiter_next(struct qsiter_t* qsi);
#ifdef __cplusplus
}
#endif
#endif /* MODP_QSITER */
|