~ubuntu-branches/ubuntu/natty/raptor/natty-updates

« back to all changes in this revision

Viewing changes to src/raptor_rss.c

  • Committer: Bazaar Package Importer
  • Author(s): Dave Beckett
  • Date: 2006-10-22 21:15:07 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20061022211507-c93p7f5mhapszeom
Tags: 1.4.13-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
  raptor_rss_parser *rss_parser=(raptor_rss_parser*)rdf_parser->context;
214
214
  int n;
215
215
  
216
 
  if(!rdf_parser->failed) {
217
 
    /* turn strings into URIs, move things around if needed */
218
 
    raptor_rss_insert_identifiers(rdf_parser);
219
 
    
220
 
    /* add some new fields  */
221
 
    raptor_rss_uplift_items(rdf_parser);
222
 
    
223
 
    /* generate the triples */
224
 
    raptor_rss_emit(rdf_parser);
225
 
  }
226
 
 
227
216
  if(rss_parser->sax2)
228
217
    raptor_free_sax2(rss_parser->sax2);
229
218
 
252
241
  if(!uri)
253
242
    return 1;
254
243
 
 
244
  /* Optionally forbid network requests in the XML parser */
 
245
  raptor_sax2_set_feature(rss_parser->sax2, 
 
246
                          RAPTOR_FEATURE_NO_NET,
 
247
                          rdf_parser->features[RAPTOR_FEATURE_NO_NET]);
 
248
  
255
249
  raptor_sax2_parse_start(rss_parser->sax2, uri);
256
250
 
257
251
  return 0;
306
300
       !strcmp((const char*)name, "RDF")) {
307
301
      /* rss */
308
302
      goto check_attributes;
309
 
    } else if(!strcasecmp((const char*)name, "channel")) {
 
303
    } else if(!raptor_strcasecmp((const char*)name, "channel")) {
310
304
      /* rss or atom 0.3 channel */
311
305
      rss_parser->current_type=RAPTOR_RSS_CHANNEL;
312
306
    } else if(!strcmp((const char*)name, "feed")) {
530
524
            rss_element->xml_writer=raptor_new_xml_writer(NULL,
531
525
                                                          uri_handler, uri_context,
532
526
                                                          rss_element->iostream,
533
 
                                                          raptor_parser_simple_error, rdf_parser,
 
527
                                                          (raptor_simple_message_handler)raptor_parser_simple_error, rdf_parser,
534
528
                                                          1);
535
529
            raptor_xml_writer_set_feature(rss_element->xml_writer, 
536
530
                                          RAPTOR_FEATURE_WRITER_XML_DECLARATION, 0);
541
535
          }
542
536
        }
543
537
      } else if (!strcmp((const char*)attrName, "version")) {
544
 
        if(!strcasecmp((const char*)name, "feed")) {
 
538
        if(!raptor_strcasecmp((const char*)name, "feed")) {
545
539
          if(!strcmp((const char*)attrValue, "0.3"))
546
540
            rss_parser->is_atom=1;
547
541
        }
557
551
{
558
552
  raptor_parser* rdf_parser;
559
553
  raptor_rss_parser* rss_parser;
 
554
#ifdef RAPTOR_DEBUG
560
555
  const unsigned char* name=raptor_xml_element_get_name(xml_element)->local_name;
 
556
#endif
561
557
  raptor_rss_element* rss_element;
562
 
  size_t cdata_len;
 
558
  size_t cdata_len=0;
563
559
  unsigned char* cdata=NULL;
564
560
 
565
561
  rss_element=(raptor_rss_element*)xml_element->user_data;
723
719
{
724
720
  raptor_rss_element* rss_element;
725
721
 
 
722
  if(!xml_element)
 
723
    return;
 
724
  
726
725
  rss_element=(raptor_rss_element*)xml_element->user_data;
727
726
 
728
727
  if(rss_element->xml_writer) {
1218
1217
                       int is_end)
1219
1218
{
1220
1219
  raptor_rss_parser* rss_parser=(raptor_rss_parser*)rdf_parser->context;
1221
 
  if(rdf_parser->failed)
1222
 
    return 1;
1223
 
 
1224
 
  return raptor_sax2_parse_chunk(rss_parser->sax2, s, len, is_end);
 
1220
  
 
1221
  if(rdf_parser->failed)
 
1222
    return 1;
 
1223
 
 
1224
  raptor_sax2_parse_chunk(rss_parser->sax2, s, len, is_end);
 
1225
 
 
1226
  if(!is_end)
 
1227
    return 0;
 
1228
 
 
1229
  if(rdf_parser->failed)
 
1230
    return 1;
 
1231
 
 
1232
  /* turn strings into URIs, move things around if needed */
 
1233
  raptor_rss_insert_identifiers(rdf_parser);
 
1234
  
 
1235
  /* add some new fields  */
 
1236
  raptor_rss_uplift_items(rdf_parser);
 
1237
  
 
1238
  /* generate the triples */
 
1239
  raptor_rss_emit(rdf_parser);
 
1240
 
 
1241
  return 0;
1225
1242
}
1226
1243
 
1227
1244
 
1274
1291
{
1275
1292
  factory->context_length     = sizeof(raptor_rss_parser);
1276
1293
  
 
1294
  factory->need_base_uri = 1;
 
1295
  
1277
1296
  factory->init      = raptor_rss_parse_init;
1278
1297
  factory->terminate = raptor_rss_parse_terminate;
1279
1298
  factory->start     = raptor_rss_parse_start;
1280
1299
  factory->chunk     = raptor_rss_parse_chunk;
1281
1300
  factory->recognise_syntax = raptor_rss_parse_recognise_syntax;
1282
 
}
1283
 
 
1284
 
 
1285
 
void
1286
 
raptor_init_parser_rss(void)
1287
 
{
1288
 
  raptor_parser_factory* factory;
1289
 
  factory=raptor_parser_register_factory("rss-tag-soup",  "RSS Tag Soup",
1290
 
                                         NULL,
1291
 
                                         NULL,
1292
 
                                         &raptor_rss_parser_register_factory);
 
1301
 
1293
1302
  raptor_parser_factory_add_mime_type(factory, "application/rss", 10);
1294
1303
  raptor_parser_factory_add_mime_type(factory, "application/rss+xml", 10);
1295
1304
  raptor_parser_factory_add_mime_type(factory, "text/rss", 8);
1297
1306
  raptor_parser_factory_add_mime_type(factory, "application/xml", 3);
1298
1307
  raptor_parser_factory_add_mime_type(factory, "text/xml", 3);
1299
1308
}
 
1309
 
 
1310
 
 
1311
void
 
1312
raptor_init_parser_rss(void)
 
1313
{
 
1314
  raptor_parser_register_factory("rss-tag-soup",  "RSS Tag Soup",
 
1315
                                 &raptor_rss_parser_register_factory);
 
1316
}