2007-01-27 16:06:13 +00:00
|
|
|
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
|
2007-12-20 05:59:34 +00:00
|
|
|
It is considered beerware. Prost. Skol. Cheers or whatever.
|
2008-10-28 01:27:22 +00:00
|
|
|
|
2007-12-20 05:59:34 +00:00
|
|
|
$id$ */
|
2008-10-28 01:27:22 +00:00
|
|
|
|
2006-12-09 12:50:42 +00:00
|
|
|
#ifndef __SCAN_URLENCODED_QUERY_H__
|
2006-12-08 19:20:51 +00:00
|
|
|
#define __SCAN_URLENCODED_QUERY_H__
|
|
|
|
|
2008-12-05 21:28:40 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2009-01-05 18:05:39 +00:00
|
|
|
typedef struct {
|
|
|
|
char *key;
|
|
|
|
int value;
|
|
|
|
} ot_keywords;
|
|
|
|
|
2007-10-18 23:33:07 +00:00
|
|
|
typedef enum {
|
|
|
|
SCAN_PATH = 1,
|
|
|
|
SCAN_SEARCHPATH_PARAM = 2,
|
|
|
|
SCAN_SEARCHPATH_VALUE = 4,
|
|
|
|
SCAN_SEARCHPATH_TERMINATOR = 8
|
|
|
|
} SCAN_SEARCHPATH_FLAG;
|
2006-12-08 19:20:51 +00:00
|
|
|
|
2007-12-17 13:23:27 +00:00
|
|
|
/* string in: pointer to source
|
|
|
|
out: pointer to next scan position
|
2007-01-11 01:06:10 +00:00
|
|
|
deststring pointer to destination
|
|
|
|
flags determines, what to parse
|
|
|
|
returns number of valid converted characters in deststring
|
|
|
|
or -1 for parse error
|
2009-01-05 18:05:39 +00:00
|
|
|
or -2 for terminator found
|
2007-01-11 01:06:10 +00:00
|
|
|
*/
|
2007-10-18 23:33:07 +00:00
|
|
|
ssize_t scan_urlencoded_query(char **string, char *deststring, SCAN_SEARCHPATH_FLAG flags);
|
|
|
|
|
2009-01-05 18:05:39 +00:00
|
|
|
/* string in: pointer to source
|
|
|
|
out: pointer to next scan position
|
|
|
|
flags determines, what to parse
|
|
|
|
returns value for matched keyword
|
|
|
|
or -1 for parse error
|
|
|
|
or -2 for terminator found
|
|
|
|
or -3 for no keyword matched
|
|
|
|
*/
|
|
|
|
int scan_find_keywords( const ot_keywords * keywords, char **string, SCAN_SEARCHPATH_FLAG flags);
|
|
|
|
|
2007-12-17 13:23:27 +00:00
|
|
|
/* string in: pointer to value of a param=value pair to skip
|
|
|
|
out: pointer to next scan position on return
|
2007-10-18 23:33:07 +00:00
|
|
|
*/
|
|
|
|
void scan_urlencoded_skipvalue( char **string );
|
2006-12-08 19:20:51 +00:00
|
|
|
|
2007-01-11 01:06:10 +00:00
|
|
|
/* data pointer to len chars of string
|
2009-01-13 22:41:17 +00:00
|
|
|
len length of chars in data to parse
|
|
|
|
number number to receive result
|
|
|
|
returns number of bytes not parsed, mostly !=0 means fail
|
|
|
|
*/
|
2007-01-31 09:50:46 +00:00
|
|
|
ssize_t scan_fixed_int( char *data, size_t len, int *number );
|
2006-12-14 02:44:50 +00:00
|
|
|
|
2006-12-08 19:20:51 +00:00
|
|
|
#endif
|