remove const from errstr

This commit is contained in:
c9s 2014-06-04 13:45:28 +08:00
parent 15ad4b5890
commit 4d68ae6841
4 changed files with 11 additions and 11 deletions

View file

@ -122,13 +122,13 @@ edge * r3_node_find_edge(const node * n, const char * pat, int pat_len);
void r3_node_append_edge(node *n, edge *child); void r3_node_append_edge(node *n, edge *child);
edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, const char **errstr); edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, char **errstr);
node * r3_tree_insert_pathl(node *tree, const char *path, int path_len, void * data); node * r3_tree_insert_pathl(node *tree, const char *path, int path_len, void * data);
route * r3_tree_insert_routel(node *tree, int method, const char *path, int path_len, void *data); route * r3_tree_insert_routel(node *tree, int method, const char *path, int path_len, void *data);
route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, const char **errstr); route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, char **errstr);
#define r3_tree_insert_routel(n, method, path, path_len, data) r3_tree_insert_routel_ex(n, method, path, path_len, data, NULL) #define r3_tree_insert_routel(n, method, path, path_len, data) r3_tree_insert_routel_ex(n, method, path, path_len, data, NULL)
@ -140,7 +140,7 @@ route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int p
/** /**
* The private API to insert a path * The private API to insert a path
*/ */
node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, const char ** errstr); node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, char ** errstr);
void r3_tree_dump(const node * n, int level); void r3_tree_dump(const node * n, int level);

View file

@ -473,7 +473,7 @@ route * r3_route_createl(const char * path, int path_len) {
* *
* method (int): METHOD_GET, METHOD_POST, METHOD_PUT, METHOD_DELETE ... * method (int): METHOD_GET, METHOD_POST, METHOD_PUT, METHOD_DELETE ...
*/ */
route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, const char **errstr) { route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, char **errstr) {
route *r = r3_route_createl(path, path_len); route *r = r3_route_createl(path, path_len);
CHECK_PTR(r); CHECK_PTR(r);
r->request_method = method; // ALLOW GET OR POST METHOD r->request_method = method; // ALLOW GET OR POST METHOD
@ -506,7 +506,7 @@ node * r3_tree_insert_pathl(node *tree, const char *path, int path_len, void * d
* 4. "aaa{slug:xxx}/hate" vs "aab{slug:yyy}/bar" => common prefix = "aa" * 4. "aaa{slug:xxx}/hate" vs "aab{slug:yyy}/bar" => common prefix = "aa"
* 5. "/foo/{slug}/hate" vs "/fo{slug}/bar" => common prefix = "/fo" * 5. "/foo/{slug}/hate" vs "/fo{slug}/bar" => common prefix = "/fo"
*/ */
edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, const char **errstr) { edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, char **errstr) {
int i = 0; int i = 0;
int prefix = 0; int prefix = 0;
*prefix_len = 0; *prefix_len = 0;
@ -567,7 +567,7 @@ edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *
/** /**
* Return the last inserted node. * Return the last inserted node.
*/ */
node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, const char **errstr) node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, char **errstr)
{ {
node * n = tree; node * n = tree;
@ -578,7 +578,7 @@ node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route
/* length of common prefix */ /* length of common prefix */
int prefix_len = 0; int prefix_len = 0;
const char *err = NULL; char *err = NULL;
e = r3_node_find_common_prefix(tree, path, path_len, &prefix_len, &err); e = r3_node_find_common_prefix(tree, path, path_len, &prefix_len, &err);
if (err) { if (err) {
// copy the error message pointer // copy the error message pointer

View file

@ -76,7 +76,7 @@ Return 1 => Slug found
Return -1 => Slug parsing error Return -1 => Slug parsing error
*/ */
int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, const char **errstr) { int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, char **errstr) {
s->path = (char*) needle; s->path = (char*) needle;
s->path_len = needle_len; s->path_len = needle_len;
@ -152,7 +152,7 @@ int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *
/** /**
* provide a quick way to count slugs, simply search for '{' * provide a quick way to count slugs, simply search for '{'
*/ */
int slug_count(const char * needle, int len, const char **errstr) { int slug_count(const char * needle, int len, char **errstr) {
int cnt = 0; int cnt = 0;
int state = 0; int state = 0;
char * p = (char*) needle; char * p = (char*) needle;

View file

@ -43,13 +43,13 @@ r3_slug_t * r3_slug_new(const char * path, int path_len);
int r3_slug_check(r3_slug_t *s); int r3_slug_check(r3_slug_t *s);
int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, const char **errstr); int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, char **errstr);
char * r3_slug_to_str(const r3_slug_t *s); char * r3_slug_to_str(const r3_slug_t *s);
void r3_slug_free(r3_slug_t * s); void r3_slug_free(r3_slug_t * s);
int slug_count(const char * needle, int len, const char **errstr); int slug_count(const char * needle, int len, char **errstr);
static inline int r3_path_contains_slug_char(const char * str) { static inline int r3_path_contains_slug_char(const char * str) {
return strchr(str, '{') != NULL ? 1 : 0; return strchr(str, '{') != NULL ? 1 : 0;