wok-current view liblrdf/stuff/raptor2.diff @ rev 23103
updated libssh and libssh-dev (0.8.7 -> 0.9.3)
author | Hans-G?nter Theisgen |
---|---|
date | Thu Mar 12 11:22:59 2020 +0100 (2020-03-12) |
parents | |
children |
line source
1 --- src/Makefile.am
2 +++ src/Makefile.am
3 @@ -4,5 +4,5 @@ lib_LTLIBRARIES = liblrdf.la
4 noinst_HEADERS = lrdf_md5.h md5_loc.h ladspa.h
6 liblrdf_la_SOURCES = lrdf.c lrdf_multi.c md5.c
7 -liblrdf_la_LIBADD = -lraptor
8 +liblrdf_la_LIBADD = -lraptor2
9 liblrdf_la_LDFLAGS = -version-info @LRDF_LIBTOOL_VERSION@
10 --- src/lrdf.c
11 +++ src/lrdf.c
12 @@ -18,6 +18,7 @@
13 static unsigned int lrdf_uid = 0; /* A unique(ish) id to append to genid's to
14 * avoid clashses */
16 +static raptor_world *world = NULL;
17 static lrdf_statement *triples = NULL;
18 static lrdf_statement *free_triples;
19 static lrdf_string_hash *resources_hash[LRDF_HASH_SIZE];
20 @@ -43,8 +44,7 @@ static void lrdf_remove_triple_hash(lrdf_triple_hash ** tbl,
21 lrdf_hash hash, lrdf_statement * s);
22 static void lrdf_add_closure_hash(lrdf_closure_hash ** tbl,
23 lrdf_hash subject, lrdf_hash object);
24 -static void lrdf_store(void *user_data,
25 - const raptor_statement * statement);
26 +static void lrdf_store(void *user_data, raptor_statement * statement);
27 void lrdf_free_statements(lrdf_statement * s);
28 void lrdf_copy_statement(lrdf_statement * from, lrdf_statement * to);
29 void lrdf_rebuild_taxonomic_closure(lrdf_closure_hash ** fwd_tbl,
30 @@ -71,7 +71,7 @@ void lrdf_init()
31 unsigned int i;
32 struct timeval tv;
34 - raptor_init();
35 + world = raptor_new_world();
36 lrdf_more_triples(256);
38 /* A UID to add to genids to make them safer */
39 @@ -112,7 +112,8 @@ void lrdf_more_triples(int count)
41 void lrdf_cleanup()
42 {
43 - raptor_finish();
44 + raptor_free_world(world);
45 + world = NULL;
47 lrdf_free_string_hash(resources_hash);
48 lrdf_free_string_hash(literals_hash);
49 @@ -232,26 +233,29 @@ void lrdf_remove_matches(lrdf_statement *pattern)
50 }
51 }
53 -static void lrdf_store(void *user_data, const raptor_statement * statement)
54 +static const char *lrdf_term_as_string(char *tmp, int tmp_len,
55 + const raptor_term *term)
56 +{
57 + switch (term->type) {
58 + case RAPTOR_TERM_TYPE_URI:
59 + return (const char *) raptor_uri_as_string(term->value.uri);
60 + case RAPTOR_TERM_TYPE_LITERAL:
61 + return (const char *) term->value.literal.string;
62 + case RAPTOR_TERM_TYPE_BLANK:
63 + snprintf(tmp, tmp_len, "_:%s.%x", term->value.blank.string, lrdf_uid);
64 + return tmp;
65 + default:
66 + return "(?)";
67 + }
68 +}
69 +
70 +static void lrdf_store(void *user_data, raptor_statement * statement)
71 {
72 lrdf_statement *s = lrdf_alloc_statement();
73 char tmps[128], tmpp[128], tmpo[128];
74 - char *subj = (char *) statement->subject,
75 - *pred = (char *) statement->predicate,
76 - *obj = (char *) statement->object;
77 -
78 - if (statement->subject_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) {
79 - snprintf(tmps, 127, "_:%s.%x", subj, lrdf_uid);
80 - subj = tmps;
81 - }
82 - if (statement->predicate_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) {
83 - snprintf(tmpp, 127, "_:%s.%x", pred, lrdf_uid);
84 - pred = tmpp;
85 - }
86 - if (statement->object_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) {
87 - snprintf(tmpo, 127, "_:%s.%x", obj, lrdf_uid);
88 - obj = tmpo;
89 - }
90 + const char *subj = lrdf_term_as_string(tmps, 128, statement->subject),
91 + *pred = lrdf_term_as_string(tmpp, 128, statement->predicate),
92 + *obj = lrdf_term_as_string(tmpo, 128, statement->object);
94 s->shash = lrdf_gen_hash(subj);
95 s->phash = lrdf_gen_hash(pred);
96 @@ -261,7 +265,7 @@ static void lrdf_store(void *user_data, const raptor_statement * statement)
98 s->subject = lrdf_check_hash(resources_hash, s->shash, subj);
99 s->predicate = lrdf_check_hash(resources_hash, s->phash, pred);
100 - if (statement->object_type == RAPTOR_IDENTIFIER_TYPE_LITERAL) {
101 + if (statement->object->type == RAPTOR_TERM_TYPE_LITERAL) {
102 s->object = lrdf_check_hash(literals_hash, s->ohash, obj);
103 s->object_type = lrdf_literal;
104 } else {
105 @@ -537,28 +541,22 @@ void lrdf_rebuild_taxonomic_closure(lrdf_closure_hash ** fwd_tbl,
106 free(pathto);
107 }
109 -static void lrdf_error_handler(void *data, raptor_locator * locator,
110 - const char *message);
111 +static void lrdf_log_handler(void *data, raptor_log_message *message);
113 -static void lrdf_error_handler(void *data, raptor_locator * locator,
114 - const char *message)
115 +static void lrdf_log_handler(void *data, raptor_log_message *message)
116 {
117 - fprintf(stderr, "liblrdf: error - ");
118 - raptor_print_locator(stderr, locator);
119 - fprintf(stderr, " - %s\n", message);
120 -
121 - raptor_parse_abort((raptor_parser*)data);
122 -}
123 + const char *severity = "error";
124 + if (message->level == RAPTOR_LOG_LEVEL_WARN) {
125 + severity = "warning";
126 + }
128 -static void lrdf_warning_handler(void *data, raptor_locator * locator,
129 - const char *message);
130 + fprintf(stderr, "liblrdf: %s - ", severity);
131 + raptor_locator_print(message->locator, stderr);
132 + fprintf(stderr, " - %s\n", message->text);
134 -static void lrdf_warning_handler(void *data, raptor_locator * locator,
135 - const char *message)
136 -{
137 - fprintf(stderr, "liblrdf: warning - ");
138 - raptor_print_locator(stderr, locator);
139 - fprintf(stderr, " - %s\n", message);
140 + if (message->level != RAPTOR_LOG_LEVEL_WARN) {
141 + raptor_parser_parse_abort((raptor_parser*)data);
142 + }
143 }
146 @@ -593,15 +591,15 @@ int lrdf_read_file_intl(const char *uri)
147 lrdf_hash source;
149 //printf("lrdf: reading %s\n", uri);
150 - ruri = raptor_new_uri(uri);
151 - furi = raptor_new_uri(uri);
152 + ruri = raptor_new_uri(world, (const unsigned char *) uri);
153 + furi = raptor_new_uri(world, (const unsigned char *) uri);
154 source = lrdf_gen_hash(uri);
155 lrdf_check_hash(resources_hash, source, uri);
157 if (strstr(uri, ".rdf")) {
158 - parser = raptor_new_parser("rdfxml");
159 + parser = raptor_new_parser(world, "rdfxml");
160 } else {
161 - parser = raptor_new_parser("ntriples");
162 + parser = raptor_new_parser(world, "ntriples");
163 }
164 if (!parser) {
165 fprintf(stderr, "liblrdf: failed to create parser\n");
166 @@ -609,12 +607,11 @@ int lrdf_read_file_intl(const char *uri)
167 return 1;
168 }
170 - raptor_set_error_handler(parser, parser, lrdf_error_handler);
171 - raptor_set_warning_handler(parser, NULL, lrdf_warning_handler);
172 - raptor_set_statement_handler(parser, &source, lrdf_store);
173 - raptor_set_default_generate_id_parameters(parser, NULL, ++lrdf_uid);
174 + raptor_world_set_log_handler(world, parser, lrdf_log_handler);
175 + raptor_parser_set_statement_handler(parser, &source, lrdf_store);
176 + raptor_world_set_generate_bnodeid_parameters(world, NULL, ++lrdf_uid);
178 - if (raptor_parse_file(parser, furi, ruri)) {
179 + if (raptor_parser_parse_file(parser, furi, ruri)) {
180 raptor_free_uri(furi);
181 raptor_free_uri(ruri);
182 raptor_free_parser(parser);
183 --- configure.ac
184 +++ configure.ac
185 @@ -18,7 +18,7 @@
186 AC_HEADER_STDC
187 AC_CHECK_HEADERS([errno.h limits.h stdlib.h string.h unistd.h])
189 -PKG_CHECK_MODULES(RAPTOR, raptor >= 0.9.11)
190 +PKG_CHECK_MODULES(RAPTOR, raptor2 >= 0.9.11)
192 # Checks for typedefs, structures, and compiler characteristics.
193 AC_C_CONST