wok-current annotate liblrdf/stuff/raptor2.diff @ rev 14243

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