fix header file include
This commit is contained in:
parent
5609fd5f9e
commit
f95cce7407
11 changed files with 62 additions and 45 deletions
34
include/r3.h
34
include/r3.h
|
@ -12,14 +12,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pcre.h>
|
#include <pcre.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "config.h"
|
|
||||||
#include "r3_define.h"
|
#include "r3_define.h"
|
||||||
#include "str_array.h"
|
#include "str_array.h"
|
||||||
#include "match_entry.h"
|
#include "match_entry.h"
|
||||||
|
|
||||||
#ifdef ENABLE_JSON
|
|
||||||
#include <json-c/json.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -108,7 +104,7 @@ 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, char *path, int path_len, int *prefix_len, 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);
|
||||||
|
|
||||||
|
@ -181,34 +177,6 @@ enum { NODE_COMPARE_STR, NODE_COMPARE_PCRE, NODE_COMPARE_OPCODE };
|
||||||
|
|
||||||
enum { OP_EXPECT_MORE_DIGITS = 1, OP_EXPECT_MORE_WORDS, OP_EXPECT_NOSLASH, OP_EXPECT_NODASH, OP_EXPECT_MORE_ALPHA };
|
enum { OP_EXPECT_MORE_DIGITS = 1, OP_EXPECT_MORE_WORDS, OP_EXPECT_NOSLASH, OP_EXPECT_NODASH, OP_EXPECT_MORE_ALPHA };
|
||||||
|
|
||||||
#ifdef ENABLE_JSON
|
|
||||||
json_object * r3_edge_to_json_object(const edge * e);
|
|
||||||
json_object * r3_node_to_json_object(const node * n);
|
|
||||||
json_object * r3_route_to_json_object(const route * r);
|
|
||||||
|
|
||||||
const char * r3_node_to_json_string_ext(const node * n, int options);
|
|
||||||
const char * r3_node_to_json_pretty_string(const node * n);
|
|
||||||
const char * r3_node_to_json_string(const node * n);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_GRAPHVIZ
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <gvc.h>
|
|
||||||
|
|
||||||
void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, const node * n, int node_cnt);
|
|
||||||
|
|
||||||
int r3_tree_render(const node * tree, const char *layout, const char * format, FILE *fp);
|
|
||||||
|
|
||||||
int r3_tree_render_dot(const node * tree, const char *layout, FILE *fp);
|
|
||||||
|
|
||||||
int r3_tree_render_file(const node * tree, const char * format, const char * filename);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
23
include/r3_gvc.h
Normal file
23
include/r3_gvc.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* r3_gvc.h
|
||||||
|
* Copyright (C) 2014 c9s <c9s@c9smba.local>
|
||||||
|
*
|
||||||
|
* Distributed under terms of the MIT license.
|
||||||
|
*/
|
||||||
|
#ifndef R3_GVC_H
|
||||||
|
#define R3_GVC_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <gvc.h>
|
||||||
|
#include "r3.h"
|
||||||
|
|
||||||
|
void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, const node * n, int node_cnt);
|
||||||
|
|
||||||
|
int r3_tree_render(const node * tree, const char *layout, const char * format, FILE *fp);
|
||||||
|
|
||||||
|
int r3_tree_render_dot(const node * tree, const char *layout, FILE *fp);
|
||||||
|
|
||||||
|
int r3_tree_render_file(const node * tree, const char * format, const char * filename);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !R3_GVC_H */
|
24
include/r3_json.h
Normal file
24
include/r3_json.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* r3_json.h
|
||||||
|
* Copyright (C) 2014 c9s <c9s@c9smba.local>
|
||||||
|
*
|
||||||
|
* Distributed under terms of the MIT license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef R3_JSON_H
|
||||||
|
#define R3_JSON_H
|
||||||
|
|
||||||
|
#include <json-c/json.h>
|
||||||
|
#include "r3.h"
|
||||||
|
|
||||||
|
json_object * r3_edge_to_json_object(const edge * e);
|
||||||
|
json_object * r3_node_to_json_object(const node * n);
|
||||||
|
json_object * r3_route_to_json_object(const route * r);
|
||||||
|
|
||||||
|
const char * r3_node_to_json_string_ext(const node * n, int options);
|
||||||
|
const char * r3_node_to_json_pretty_string(const node * n);
|
||||||
|
const char * r3_node_to_json_string(const node * n);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !R3_JSON_H */
|
|
@ -4,6 +4,7 @@
|
||||||
*
|
*
|
||||||
* Distributed under terms of the MIT license.
|
* Distributed under terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -17,8 +18,6 @@
|
||||||
|
|
||||||
// Judy array
|
// Judy array
|
||||||
// #include <Judy.h>
|
// #include <Judy.h>
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "r3.h"
|
#include "r3.h"
|
||||||
#include "r3_str.h"
|
#include "r3_str.h"
|
||||||
#include "slug.h"
|
#include "slug.h"
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
*
|
*
|
||||||
* Distributed under terms of the MIT license.
|
* Distributed under terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
#include "config.h"
|
||||||
#include <gvc.h>
|
#include <gvc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "r3.h"
|
#include "r3.h"
|
||||||
|
#include "r3_gvc.h"
|
||||||
#include "zmalloc.h"
|
#include "zmalloc.h"
|
||||||
|
|
||||||
void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, const node * n, int node_cnt) {
|
void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, const node * n, int node_cnt) {
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
*
|
*
|
||||||
* Distributed under terms of the MIT license.
|
* Distributed under terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
#include <json-c/json.h>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <json-c/json.h>
|
||||||
#include "r3.h"
|
#include "r3.h"
|
||||||
|
#include "r3_json.h"
|
||||||
|
|
||||||
json_object * r3_route_to_json_object(const route * r) {
|
json_object * r3_route_to_json_object(const route * r) {
|
||||||
json_object *obj;
|
json_object *obj;
|
||||||
|
|
|
@ -494,7 +494,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, char *path, int path_len, int *prefix_len, 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;
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
r3_slug_t * r3_slug_new(char * path, int path_len) {
|
r3_slug_t * r3_slug_new(const char * path, int path_len) {
|
||||||
r3_slug_t * s = zmalloc(sizeof(r3_slug_t));
|
r3_slug_t * s = zmalloc(sizeof(r3_slug_t));
|
||||||
if (!s)
|
if (!s)
|
||||||
return NULL;
|
return NULL;
|
||||||
s->path = path;
|
s->path = (char*) path;
|
||||||
s->path_len = path_len;
|
s->path_len = path_len;
|
||||||
|
|
||||||
s->begin = NULL;
|
s->begin = NULL;
|
||||||
|
@ -76,8 +76,8 @@ Return 1 => Slug found
|
||||||
Return -1 => Slug parsing error
|
Return -1 => Slug parsing error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int r3_slug_parse(r3_slug_t *s, char *needle, int needle_len, char *offset, char **errstr) {
|
int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, char *offset, char **errstr) {
|
||||||
s->path = needle;
|
s->path = (char*) needle;
|
||||||
s->path_len = needle_len;
|
s->path_len = needle_len;
|
||||||
|
|
||||||
if (offset == NULL) {
|
if (offset == NULL) {
|
||||||
|
|
|
@ -39,11 +39,11 @@ typedef struct {
|
||||||
} r3_slug_t;
|
} r3_slug_t;
|
||||||
|
|
||||||
|
|
||||||
r3_slug_t * r3_slug_new(char * path, int path_len);
|
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, char *needle, int needle_len, char *offset, char **errstr);
|
int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, char *offset, char **errstr);
|
||||||
|
|
||||||
char * r3_slug_to_str(const r3_slug_t *s);
|
char * r3_slug_to_str(const r3_slug_t *s);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "r3.h"
|
#include "r3.h"
|
||||||
|
#include "r3_gvc.h"
|
||||||
#include "r3_str.h"
|
#include "r3_str.h"
|
||||||
#include "bench.h"
|
#include "bench.h"
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <json-c/json.h>
|
#include <json-c/json.h>
|
||||||
#include "r3.h"
|
#include "r3.h"
|
||||||
#include "r3_str.h"
|
#include "r3_str.h"
|
||||||
|
#include "r3_json.h"
|
||||||
#include "zmalloc.h"
|
#include "zmalloc.h"
|
||||||
|
|
||||||
START_TEST (test_json_encode)
|
START_TEST (test_json_encode)
|
||||||
|
|
Loading…
Reference in a new issue