Exemplo n.º 1
0
void
raptor_rss_common_terminate(raptor_world* world) {
  int i;
  if(--world->rss_common_initialised)
    return;

  if(world->rss_types_info_uris) {
    for(i = 0; i< RAPTOR_RSS_COMMON_SIZE; i++) {
      if(world->rss_types_info_uris[i])
        raptor_free_uri(world->rss_types_info_uris[i]);
    }
    RAPTOR_FREE(raptor_uri* array, world->rss_types_info_uris);
    world->rss_types_info_uris = NULL;
  }

  if(world->rss_fields_info_uris) {
    for(i = 0; i< RAPTOR_RSS_FIELDS_SIZE; i++) {
      if(world->rss_fields_info_uris[i])
        raptor_free_uri(world->rss_fields_info_uris[i]);
    }
    RAPTOR_FREE(raptor_uri* array, world->rss_fields_info_uris);
    world->rss_fields_info_uris = NULL;
  }

  if(world->rss_namespaces_info_uris) {
    for(i = 0; i < RAPTOR_RSS_NAMESPACES_SIZE;i++) {
      if(world->rss_namespaces_info_uris[i])
        raptor_free_uri(world->rss_namespaces_info_uris[i]);
    }
    RAPTOR_FREE(raptor_uri* array, world->rss_namespaces_info_uris);
    world->rss_namespaces_info_uris = NULL;
  }
}
Exemplo n.º 2
0
/*****
** Lee el archivo que contiene las tripletas RDF
** y hace el llamado a la funcion save_triple() para guardarlos
*****/
void rdf_database_read_file(rdf_database db, const char *file)
{
    raptor_world *world = NULL;
    unsigned char *uri_string;
    raptor_uri *uri, *base_uri;

    // parser
    world = raptor_new_world();
    rdf_parser = raptor_new_parser(world, "rdfxml");

    // seteo funcion handler para cada nodo
    raptor_parser_set_statement_handler(rdf_parser, (void*)db, save_triple);

    uri_string = raptor_uri_filename_to_uri_string(file);
    uri = raptor_new_uri(world, uri_string);
    base_uri = raptor_uri_copy(uri);

    // empieza parseo y guardado en memoria
    raptor_parser_parse_file(rdf_parser, uri, base_uri);

    // liberar ram
    raptor_free_parser(rdf_parser);
    raptor_free_uri(base_uri);
    raptor_free_uri(uri);
    raptor_free_memory(uri_string);
    raptor_free_world(world);
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
#ifdef HAVE_RAPTOR
  raptor_world *world = NULL;
  raptor_parser* rdf_parser = NULL;
  unsigned char *uri_string;
  raptor_uri *uri, *base_uri;

  world = raptor_new_world();

  rdf_parser = raptor_new_parser(world, "ntriples");

  raptor_parser_set_statement_handler(rdf_parser, NULL, print_triple);

  uri_string = raptor_uri_filename_to_uri_string(argv[1]);
  uri = raptor_new_uri(world, uri_string);
  base_uri = raptor_uri_copy(uri);

  raptor_parser_parse_file(rdf_parser, uri, base_uri);

  raptor_free_parser(rdf_parser);

  raptor_free_uri(base_uri);
  raptor_free_uri(uri);
  raptor_free_memory(uri_string);

  raptor_free_world(world);
#endif

  return EXIT_SUCCESS;
}
Exemplo n.º 4
0
DllExport int call_conv load_nquad_file(CTXTdecl)
{
	char *filename = p2c_string(reg_term(CTXTdecl 1));

	unsigned char *uri_string;
	raptor_uri *uri, *base_uri;

	world = raptor_new_world();

	rdf_parser = raptor_new_parser(world, "nquads");

	raptor_parser_set_statement_handler(rdf_parser, NULL, handle_term);

	uri_string = raptor_uri_filename_to_uri_string(filename);
	uri = raptor_new_uri(world, uri_string);
	base_uri = raptor_uri_copy(uri);

	raptor_parser_parse_file(rdf_parser, uri, base_uri);

	raptor_free_parser(rdf_parser);

	raptor_free_uri(base_uri);
	raptor_free_uri(uri);
	raptor_free_memory(uri_string);

	raptor_free_world(world);

	return 1;
}
Exemplo n.º 5
0
static int
assert_uri_to_relative(const char *base, const char *uri, const char *relative)
{
  unsigned char *output;
  int result;
  raptor_uri* base_uri=NULL;
  raptor_uri* reference_uri=raptor_new_uri((const unsigned char*)uri);
  size_t length=0;

  if(base)
    base_uri=raptor_new_uri((const unsigned char*)base);
  
  output=raptor_uri_to_relative_counted_uri_string(base_uri, reference_uri, 
                                                   &length);
  result=strcmp(relative, (const char*)output);
  if (result) {
    fprintf(stderr,
            "%s: raptor_uri_string_to_relative_uri_string FAILED: base='%s', uri='%s', expected='%s', got='%s'\n",
            program, base, uri, relative, output);
    RAPTOR_FREE(cstring, output);
    return 1;
  }
  RAPTOR_FREE(cstring, output);
  raptor_free_uri(base_uri);
  raptor_free_uri(reference_uri);
  return 0;
}
Exemplo n.º 6
0
/**
 * raptor_free_www: 
 * @www: WWW object.
 * 
 * Destructor - destroy a #raptor_www object.
 **/
void
raptor_free_www(raptor_www* www)
{
  /* free context */
  if(www->type) {
    if(www->free_type)
      RAPTOR_FREE(cstring, www->type);
    www->type = NULL;
  }
  
  if(www->user_agent) {
    RAPTOR_FREE(cstring, www->user_agent);
    www->user_agent = NULL;
  }

  if(www->cache_control) {
    RAPTOR_FREE(cstring, www->cache_control);
    www->cache_control = NULL;
  }

  if(www->proxy) {
    RAPTOR_FREE(cstring, www->proxy);
    www->proxy = NULL;
  }

  if(www->http_accept) {
    RAPTOR_FREE(cstring, www->http_accept);
    www->http_accept = NULL;
  }

#ifdef RAPTOR_WWW_LIBCURL
  raptor_www_curl_free(www);
#endif
#ifdef RAPTOR_WWW_LIBXML
  raptor_www_libxml_free(www);
#endif
#ifdef RAPTOR_WWW_LIBFETCH
  raptor_www_libfetch_free(www);
#endif

  if(www->uri)
    raptor_free_uri(www->uri);

  if(www->final_uri)
    raptor_free_uri(www->final_uri);

  RAPTOR_FREE(www, www);
}
Exemplo n.º 7
0
/**
 * raptor_free_term:
 * @term: #raptor_term object
 *
 * Destructor - destroy a raptor_term object.
 *
 **/
void
raptor_free_term(raptor_term *term)
{
  if(!term)
    return;
  
  if(--term->usage)
    return;
  
  switch(term->type) {
    case RAPTOR_TERM_TYPE_URI:
      if(term->value.uri) {
        raptor_free_uri(term->value.uri);
        term->value.uri = NULL;
      }
      break;

    case RAPTOR_TERM_TYPE_BLANK:
      if(term->value.blank.string) {
        RAPTOR_FREE(cstring, (void*)term->value.blank.string);
        term->value.blank.string = NULL;
      }
      break;
      
    case RAPTOR_TERM_TYPE_LITERAL:
      if(term->value.literal.string) {
        RAPTOR_FREE(cstring, (void*)term->value.literal.string);
        term->value.literal.string = NULL;
      }

      if(term->value.literal.datatype) {
        raptor_free_uri(term->value.literal.datatype);
        term->value.literal.datatype = NULL;
      }
      
      if(term->value.literal.language) {
        RAPTOR_FREE(cstring, (void*)term->value.literal.language);
        term->value.literal.language = NULL;
      }
      break;
      
    case RAPTOR_TERM_TYPE_UNKNOWN:
    default:
      break;
  }

  RAPTOR_FREE(term, (void*)term);
}
Exemplo n.º 8
0
/**
 * raptor_free_sax2:
 * @sax2: SAX2 object
 *
 * Destructor - destroy a SAX2 object
 */
void
raptor_free_sax2(raptor_sax2 *sax2)
{
  raptor_xml_element *xml_element;

  if(!sax2)
    return;

#ifdef RAPTOR_XML_LIBXML
  if(sax2->xc) {
    raptor_libxml_free(sax2->xc);
    sax2->xc = NULL;
  }
#endif

  while( (xml_element = raptor_xml_element_pop(sax2)) )
    raptor_free_xml_element(xml_element);

  raptor_namespaces_clear(&sax2->namespaces);

  if(sax2->base_uri)
    raptor_free_uri(sax2->base_uri);

  raptor_object_options_clear(&sax2->options);
  
  RAPTOR_FREE(raptor_sax2, sax2);
}
Exemplo n.º 9
0
int main(int argc, char *argv[]) {
	fsp_link *link;
	fs_query_state *qs;
	fs_query *qr;
	raptor_uri *bu;
	int i;

#ifdef LINUX
	mtrace();
#endif

	link = fsp_open_link("ukgov_finances_cra", NULL, FS_OPEN_HINT_RW);
	raptor_init();
	fs_hash_init(fsp_hash_type(link));
	bu = raptor_new_uri((unsigned char *)"local:");
	fsp_no_op(link, 0);

	qs = fs_query_init(link);
	for (i=0;i<atoi(argv[1]);i++) {
		//printf("--------- %d ----------\n", i);
		qr = fs_query_execute(qs, link, bu, QUERY, 0, 3, 0);
		fs_query_free(qr);
		fs_query_cache_flush(qs, 0);
	}

	fs_query_fini(qs);
	raptor_free_uri(bu);
	raptor_finish();
	fsp_close_link(link);

#ifdef LINUX
	muntrace();
#endif
}
Exemplo n.º 10
0
/**
 * raptor_serializer_start_to_string:
 * @rdf_serializer:  the #raptor_serializer
 * @uri: base URI or NULL if no base URI is required
 * @string_p: pointer to location to hold string
 * @length_p: pointer to location to hold length of string (or NULL)
 *
 * Start serializing to a string.
 * 
 * Return value: non-0 on failure.
 **/
int
raptor_serializer_start_to_string(raptor_serializer *rdf_serializer,
                                  raptor_uri *uri,
                                  void **string_p, size_t *length_p) 
{
  if(rdf_serializer->base_uri)
    raptor_free_uri(rdf_serializer->base_uri);

  if(uri)
    rdf_serializer->base_uri = raptor_uri_copy(uri);
  else
    rdf_serializer->base_uri = NULL;
  rdf_serializer->locator.uri = rdf_serializer->base_uri;
  rdf_serializer->locator.line = rdf_serializer->locator.column = 0;


  rdf_serializer->iostream = raptor_new_iostream_to_string(rdf_serializer->world,
                                                           string_p, length_p, 
                                                           NULL);
  if(!rdf_serializer->iostream)
    return 1;

  rdf_serializer->free_iostream_on_end = 1;

  if(rdf_serializer->factory->serialize_start)
    return rdf_serializer->factory->serialize_start(rdf_serializer);
  return 0;
}
Exemplo n.º 11
0
/**
 * raptor_free_xml_element:
 * @element: XML Element
 * 
 * Destructor - destroy a raptor_xml_element object.
 **/
void
raptor_free_xml_element(raptor_xml_element *element)
{
  unsigned int i;

  if(!element)
    return;

  for(i = 0; i < element->attribute_count; i++)
    if(element->attributes[i])
      raptor_free_qname(element->attributes[i]);

  if(element->attributes)
    RAPTOR_FREE(raptor_qname_array, element->attributes);

  if(element->content_cdata_sb)
    raptor_free_stringbuffer(element->content_cdata_sb);

  if(element->base_uri)
    raptor_free_uri(element->base_uri);

  if(element->xml_language)
    RAPTOR_FREE(char*, element->xml_language);

  raptor_free_qname(element->name);

  if(element->declared_nspaces)
    raptor_free_sequence(element->declared_nspaces);

  RAPTOR_FREE(raptor_element, element);
}
Exemplo n.º 12
0
/**
 * raptor_serializer_start_to_filename:
 * @rdf_serializer:  the #raptor_serializer
 * @filename:  filename to serialize to
 *
 * Start serializing to a filename.
 * 
 * Return value: non-0 on failure.
 **/
int
raptor_serializer_start_to_filename(raptor_serializer *rdf_serializer,
                                    const char *filename)
{
  unsigned char *uri_string = raptor_uri_filename_to_uri_string(filename);
  if(!uri_string)
    return 1;

  if(rdf_serializer->base_uri)
    raptor_free_uri(rdf_serializer->base_uri);

  rdf_serializer->base_uri = raptor_new_uri(rdf_serializer->world, uri_string);
  rdf_serializer->locator.uri = rdf_serializer->base_uri;
  rdf_serializer->locator.line = rdf_serializer->locator.column = 0;

  RAPTOR_FREE(char*, uri_string);

  rdf_serializer->iostream = raptor_new_iostream_to_filename(rdf_serializer->world,
                                                             filename);
  if(!rdf_serializer->iostream)
    return 1;

  rdf_serializer->free_iostream_on_end = 1;

  if(rdf_serializer->factory->serialize_start)
    return rdf_serializer->factory->serialize_start(rdf_serializer);
  return 0;
}
Exemplo n.º 13
0
void
raptor_rss_model_clear(raptor_rss_model* rss_model)
{
  int i;
  raptor_rss_item* item;
  
  for(i = 0; i< RAPTOR_RSS_COMMON_SIZE; i++) {
    item = rss_model->common[i];
    while(item) {
      raptor_rss_item *next = item->next;
      raptor_free_rss_item(item);
      item = next;
    }
  }

  item = rss_model->items;
  while(item) {
    raptor_rss_item *next = item->next;

    raptor_free_rss_item(item);
    item = next;
  }
  rss_model->last = rss_model->items = NULL;

  for(i = 0; i< RAPTOR_RSS_N_CONCEPTS; i++) {
    raptor_uri* concept_uri = rss_model->concepts[i];
    if(concept_uri) {
      raptor_free_uri(concept_uri);
      rss_model->concepts[i] = NULL;
    }
  }
}
Exemplo n.º 14
0
/**
 * raptor_serializer_start_to_iostream:
 * @rdf_serializer:  the #raptor_serializer
 * @uri: base URI or NULL if no base URI is required
 * @iostream: #raptor_iostream to write serialization to
 * 
 * Start serialization to an iostream with given base URI
 *
 * The passed in @iostream does not become owned by the serializer
 * and can be used by the caller after serializing is done.  It
 * must be destroyed by the caller.
 *
 * Return value: non-0 on failure.
 **/
int
raptor_serializer_start_to_iostream(raptor_serializer *rdf_serializer,
                                    raptor_uri *uri, raptor_iostream *iostream) 
{
  if(rdf_serializer->base_uri)
    raptor_free_uri(rdf_serializer->base_uri);

  if(!iostream)
    return 1;
  
  if(uri)
    uri = raptor_uri_copy(uri);
  
  rdf_serializer->base_uri = uri;
  rdf_serializer->locator.uri = uri;
  rdf_serializer->locator.line = rdf_serializer->locator.column = 0;

  rdf_serializer->iostream = iostream;

  rdf_serializer->free_iostream_on_end = 0;

  if(rdf_serializer->factory->serialize_start)
    return rdf_serializer->factory->serialize_start(rdf_serializer);
  return 0;
}
Exemplo n.º 15
0
static void
ser_emit_triple(void* user_data,
                const char* subject, int subject_type,
                const char* predicate_nspace, const char* predicate_name,
                const char *object, int object_type,
                const char *datatype_uri)
{
  raptor_serializer* serializer = (raptor_serializer*)user_data;
  raptor_statement s; /* static */
  raptor_uri* predicate_ns_uri;
  raptor_uri* predicate_uri;
  
  raptor_statement_init(&s, rworld);
  
  if(subject_type == FLICKCURL_TERM_TYPE_RESOURCE)
    s.subject = raptor_new_term_from_uri_string(rworld, (const unsigned char*)subject);
  else /* blank node */
    s.subject = raptor_new_term_from_blank(rworld, (const unsigned char*)subject);

  predicate_ns_uri = raptor_new_uri(rworld, (const unsigned char*)predicate_nspace);
  predicate_uri = raptor_new_uri_from_uri_local_name(rworld, predicate_ns_uri,
                                                     (const unsigned char*)predicate_name);
  s.predicate = raptor_new_term_from_uri(rworld, predicate_uri);
  raptor_free_uri(predicate_uri);
  raptor_free_uri(predicate_ns_uri);

  if(object_type == FLICKCURL_TERM_TYPE_RESOURCE)
    s.object = (void*)raptor_new_term_from_uri_string(rworld, (const unsigned char*)object);
  else if(object_type == FLICKCURL_TERM_TYPE_BLANK)
    s.object = raptor_new_term_from_blank(rworld, (const unsigned char*)subject);
  else {
    /* literal */
    raptor_uri* raptor_datatype_uri = NULL;

    if(datatype_uri)
      raptor_datatype_uri = raptor_new_uri(rworld, (const unsigned char*)datatype_uri);

    s.object = raptor_new_term_from_literal(rworld, (const unsigned char*)object, raptor_datatype_uri, NULL /* language */);

    raptor_free_uri(raptor_datatype_uri);
  }

  raptor_serializer_serialize_statement(serializer, &s);

raptor_statement_clear(&s);

}
Exemplo n.º 16
0
/**
 * librdf_free_uri:
 * @uri: #librdf_uri object
 *
 * Destructor - destroy a #librdf_uri object.
 * 
 **/
void
librdf_free_uri(librdf_uri* uri) 
{
  if(!uri)
    return;
  
  raptor_free_uri(uri);
}
Exemplo n.º 17
0
int main (int argc, char *argv[]) 
{
  const char *program = raptor_basename(argv[0]);
  raptor_world *world;
  const char *uri_string;
  raptor_www *www;
  const char *user_agent = "raptor_www_test/0.1";
  raptor_uri *uri;
  void *string = NULL;
  size_t string_length = 0;
  
  if(argc > 1)
    uri_string = argv[1];
  else
    uri_string = "http://librdf.org/";

  world = raptor_new_world();
  if(!world || raptor_world_open(world))
    exit(1);

  uri = raptor_new_uri(world, (const unsigned char*)uri_string);
  if(!uri) {
    fprintf(stderr, "%s: Failed to create Raptor URI for %s\n",
            program, uri_string);
    exit(1);
  }
  
  www = raptor_new_www(world);

  raptor_www_set_content_type_handler(www, write_content_type, (void*)stderr);
  raptor_www_set_user_agent(www, user_agent);

  /* start retrieval (always a GET) */
  
  if(raptor_www_fetch_to_string(www, uri,
                                &string, &string_length, malloc)) {
    fprintf(stderr, "%s: WWW fetch failed\n", program);
  } else {
#if defined(RAPTOR_DEBUG) && RAPTOR_DEBUG > 1    
    fprintf(stderr, "%s: HTTP response status %d\n",
            program, www->status_code);
    
    fprintf(stderr, "%s: Returned %d bytes of content\n",
            program, (int)string_length);
#endif
  }
  if(string)
    free(string);
  
  raptor_free_www(www);

  raptor_free_uri(uri);

  raptor_free_world(world);
  
  return 0;
}
Exemplo n.º 18
0
static void
rasqal_finish_datatypes(void) {
  int i;
  
  for(i = 0; i< RASQAL_XSD_DATATYPES_SIZE; i++)
    if(rasqal_xsd_datatypes[i].uri)
      raptor_free_uri(rasqal_xsd_datatypes[i].uri);

  for(i = 0; i< RASQAL_XSD_DATATYPE_FNS_SIZE; i++)
    if(rasqal_xsd_datatype_fns[i].uri)
      raptor_free_uri(rasqal_xsd_datatype_fns[i].uri);

  if(raptor_xpfo_base_uri)
    raptor_free_uri(raptor_xpfo_base_uri);

  if(rasqal_sparql_op_namespace_uri)
    raptor_free_uri(rasqal_sparql_op_namespace_uri);
}
Exemplo n.º 19
0
/**
 * raptor_free_base_id_set:
 * @set: #raptor_base_id_set
 *
 * INTERNAL - Destructor - Free a Base ID Set.
 *
 **/
static void
raptor_free_base_id_set(raptor_base_id_set *base) 
{
  if(base->tree)
    raptor_free_avltree(base->tree);
  if(base->uri)
    raptor_free_uri(base->uri);
  RAPTOR_FREE(raptor_base_id_set, base);
}
Exemplo n.º 20
0
fs_metadata *fs_metadata_open(const char *kb)
{
    fs_metadata *m = calloc(1, sizeof(fs_metadata));
    gchar *fs_md_file_uri_format;
    fs_md_file_uri_format = g_strconcat("file://",
					fs_get_md_file_format(),
					NULL);
    m->size = 16;
    m->length = 0;
    m->entries = calloc(m->size, sizeof(struct m_entry));
    m->uri = g_strdup_printf(fs_md_file_uri_format, kb);
    g_free(fs_md_file_uri_format);

    int fd;
    if ((fd = open(m->uri + 7, FS_O_NOATIME | O_CREAT, FS_FILE_MODE)) == -1) {
        fs_error(LOG_CRIT, "failed to touch metadata file %s: %s",
            m->uri, strerror(errno));
        free(m);
        return NULL;
    }
    close(fd);
    m->rw = raptor_new_world();
    if (!m->rw) {
        fs_error(LOG_CRIT, "failed to initialise raptor");
        free(m);
        return NULL;
    }
    raptor_parser *rdf_parser = raptor_new_parser(m->rw, "turtle");
    raptor_parser_set_statement_handler(rdf_parser, m, parse_stmt);
    char *uri = strdup(m->uri);
    raptor_uri *ruri = raptor_new_uri(m->rw, (unsigned char *) uri);
    raptor_uri *muri = raptor_new_uri(m->rw, (unsigned char *) uri);
    free(uri);
    if (raptor_parser_parse_uri(rdf_parser, ruri, muri)) {
        fs_error(LOG_ERR, "failed to parse metadata file “%s”", m->uri);

        return NULL;
    }
    raptor_free_parser(rdf_parser);
    raptor_free_uri(ruri);
    raptor_free_uri(muri);

    return m;
}
Exemplo n.º 21
0
/*
 * rasqal_free_update_operation:
 * @update: update operation
 *
 * INTERNAL - Destructor - Free update operation
 *
 */
void
rasqal_free_update_operation(rasqal_update_operation *update)
{
  if(!update)
    return;
  
  if(update->graph_uri)
    raptor_free_uri(update->graph_uri);
  if(update->document_uri)
    raptor_free_uri(update->document_uri);
  if(update->insert_templates)
    raptor_free_sequence(update->insert_templates);
  if(update->delete_templates)
    raptor_free_sequence(update->delete_templates);
  if(update->where)
    rasqal_free_graph_pattern(update->where);

  RASQAL_FREE(update_operation, update);
}
Exemplo n.º 22
0
Arquivo: rdf_uri.c Projeto: njh/librdf
/**
 * librdf_free_uri:
 * @uri: #librdf_uri object
 *
 * Destructor - destroy a #librdf_uri object.
 * 
 **/
void
librdf_free_uri(librdf_uri* uri) 
{
#ifdef LIBRDF_USE_RAPTOR_URI
  if(!uri)
    return;
  
  raptor_free_uri(uri);
#else
  librdf_hash_datum key; /* on stack */
#ifdef WITH_THREADS
  librdf_world *world;
#endif

  if(!uri)
    return;
  
#ifdef WITH_THREADS
  world = uri->world;
  pthread_mutex_lock(world->mutex);
#endif

  uri->usage--;
  
#if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1
  LIBRDF_DEBUG3("URI %s usage count now %d\n", uri->string, uri->usage);
#endif

  /* decrement usage, don't free if not 0 yet*/
  if(uri->usage) {
#ifdef WITH_THREADS
    pthread_mutex_unlock(world->mutex);
#endif
    return;
  }

#if defined(LIBRDF_DEBUG) && LIBRDF_DEBUG > 1
  LIBRDF_DEBUG3("Deleting URI %s from hash, max usage was %d\n", uri->string, uri->max_usage);
#endif

  key.data=uri->string;
  key.size=uri->string_length;
  /* Hash deletion fails only if the key is not found.
     This is not a fatal error so do not check for return value. */
  librdf_hash_delete_all(uri->world->uris_hash, &key);

  if(uri->string)
    LIBRDF_FREE(cstring, uri->string);
  LIBRDF_FREE(librdf_uri, uri);

#ifdef WITH_THREADS
  pthread_mutex_unlock(world->mutex);
#endif
#endif /* !LIBRDF_USE_RAPTOR_URI */
}
Exemplo n.º 23
0
void
rasqal_xsd_finish(rasqal_world* world) 
{
  if(world->xsd_datatype_uris) {
    int i;
    
    for(i = RASQAL_LITERAL_FIRST_XSD; i < SPARQL_XSD_NAMES_COUNT; i++) {
      if(world->xsd_datatype_uris[i])
        raptor_free_uri(world->xsd_datatype_uris[i]);
    }

    RASQAL_FREE(table, world->xsd_datatype_uris);
    world->xsd_datatype_uris = NULL;
  }

  if(world->xsd_namespace_uri) {
    raptor_free_uri(world->xsd_namespace_uri);
    world->xsd_namespace_uri = NULL;
  }
}
Exemplo n.º 24
0
void
rasqal_uri_finish(rasqal_world* world) 
{
  if(world->rdf_first_uri) {
    raptor_free_uri(world->rdf_first_uri);
    world->rdf_first_uri=NULL;
  }
  if(world->rdf_rest_uri) {
    raptor_free_uri(world->rdf_rest_uri);
    world->rdf_rest_uri=NULL;
  }
  if(world->rdf_nil_uri) {
    raptor_free_uri(world->rdf_nil_uri);
    world->rdf_nil_uri=NULL;
  }
  if(world->rdf_namespace_uri) {
    raptor_free_uri(world->rdf_namespace_uri);
    world->rdf_namespace_uri=NULL;
  }
}
Exemplo n.º 25
0
/**
 * raptor_free_turtle_writer:
 * @turtle_writer: Turtle writer object
 *
 * Destructor - Free Turtle Writer
 * 
 **/
void
raptor_free_turtle_writer(raptor_turtle_writer* turtle_writer)
{
  if(!turtle_writer)
    return;

  if(turtle_writer->nstack && turtle_writer->my_nstack)
    raptor_free_namespaces(turtle_writer->nstack);

  if(turtle_writer->xsd_boolean_uri)
    raptor_free_uri(turtle_writer->xsd_boolean_uri);
  if(turtle_writer->xsd_decimal_uri)
    raptor_free_uri(turtle_writer->xsd_decimal_uri);
  if(turtle_writer->xsd_double_uri)
    raptor_free_uri(turtle_writer->xsd_double_uri);
  if(turtle_writer->xsd_integer_uri)
    raptor_free_uri(turtle_writer->xsd_integer_uri);

  RAPTOR_FREE(raptor_turtle_writer, turtle_writer);
}
Exemplo n.º 26
0
void
raptor_rss_field_free(raptor_rss_field* field)
{
    if(field->value)
        RAPTOR_FREE(cstring, field->value);
    if(field->uri)
        raptor_free_uri(field->uri);
    if(field->next)
        raptor_rss_field_free(field->next);
    RAPTOR_FREE(raptor_rss_field, field);
}
Exemplo n.º 27
0
void
raptor_free_abbrev_node(raptor_abbrev_node* node)
{
  if(!node)
    return;

  if(--node->ref_count)
    return;
  
  switch (node->type) {
      case RAPTOR_IDENTIFIER_TYPE_RESOURCE:
      case RAPTOR_IDENTIFIER_TYPE_PREDICATE:
        raptor_free_uri(node->value.resource.uri);
        break;
          
      case RAPTOR_IDENTIFIER_TYPE_ANONYMOUS:
        RAPTOR_FREE(blank, node->value.blank.string);
        break;
          
      case RAPTOR_IDENTIFIER_TYPE_LITERAL:
      case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL:
        RAPTOR_FREE(literal, node->value.literal.string);

        if(node->value.literal.datatype)
          raptor_free_uri(node->value.literal.datatype);

        if(node->value.literal.language)
          RAPTOR_FREE(language, node->value.literal.language);

        break;
          
      case RAPTOR_IDENTIFIER_TYPE_ORDINAL:
      case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: 
      default:
        /* Nothing to do */
        break;
  }

  RAPTOR_FREE(raptor_abbrev_node, node);
}
Exemplo n.º 28
0
static void
raptor_rss_parse_terminate(raptor_parser *rdf_parser) {
  raptor_rss_parser_context *rss_parser=(raptor_rss_parser_context*)rdf_parser->context;
  int i;
  
  if(rss_parser->reader)
    xmlFreeTextReader(rss_parser->reader);

  if(rss_parser->input)
    xmlFreeParserInputBuffer(rss_parser->input);

  raptor_rss_items_free(rss_parser);

  for(i=0; i< RAPTOR_RSS_COMMON_SIZE; i++)
    raptor_item_free(&rss_parser->common[i]);

  for(i=0; i<RSS_NAMESPACES_SIZE;i++) {
    if(rss_parser->namespace_uris[i])
      raptor_free_uri(rss_parser->namespace_uris[i]);
  }

  for(i=0; i< RAPTOR_RSS_N_CONCEPTS; i++) {
    raptor_uri* concept_uri=rss_parser->concepts[i];
    if(concept_uri) {
      raptor_free_uri(concept_uri);
      rss_parser->concepts[i]=NULL;
    }
  }

  for(i=0; i< RAPTOR_RSS_COMMON_SIZE; i++) {
    if(raptor_rss_types_info[i].uri)
      raptor_free_uri(raptor_rss_types_info[i].uri);
  }

  for(i=0; i< RAPTOR_RSS_FIELDS_SIZE; i++) {
    if(raptor_rss_fields_info[i].uri)
      raptor_free_uri(raptor_rss_fields_info[i].uri);
  }

}
Exemplo n.º 29
0
static void
ser_emit_namespace(void* user_data,
                   const char *prefix, size_t prefix_len,
                   const char* uri, size_t uri_len)
{
  raptor_serializer* serializer = (raptor_serializer*)user_data;
  raptor_uri *ns_uri = NULL;

  ns_uri = raptor_new_uri(rworld, (const unsigned char*)uri);
  raptor_serializer_set_namespace(serializer, ns_uri, 
                                 (const unsigned char*)prefix);
  raptor_free_uri(ns_uri);
}
Exemplo n.º 30
0
int
main (int argc, char *argv[])
{
    raptor_parser* rdf_parser;
    raptor_uri* uri;
    my_data* me;
    const char *program;
    int rc;

    program=argv[0];

    if(argc != 2) {
        fprintf(stderr, "%s: USAGE [RDF-XML content URI]\n", program);
        exit(1);
    }

    raptor_init();

    me=(my_data*)malloc(sizeof(my_data));
    if(!me) {
        fprintf(stderr, "%s: Out of memory\n", program);
        exit(1);
    }

    me->stream=stderr;
    me->count=0;
    me->max=5;

    uri=raptor_new_uri((const unsigned char*)argv[1]);
    rdf_parser=raptor_new_parser("rdfxml");

    me->parser=rdf_parser;

    raptor_set_statement_handler(rdf_parser, me, handle_statements);

    me->stopped=0;
    rc=raptor_parse_uri(rdf_parser, uri, NULL);

    fprintf(stderr, "%s: Parser returned status %d, stopped? %s\n", program, rc,
            (me->stopped ? "yes" : "no"));

    free(me);

    raptor_free_parser(rdf_parser);

    raptor_free_uri(uri);

    raptor_finish();

    return 0;
}