~ubuntu-branches/ubuntu/maverick/conglomerate/maverick

« back to all changes in this revision

Viewing changes to src/cong-util.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-08 05:07:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051108050706-bcg60nwqf1z3w0d6
Tags: 0.9.1-1ubuntu1
* Resynchronise with Debian (Closes: #4397).
  - Thanks, Jordan Mantha.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
gboolean 
63
63
cong_util_is_docbook (CongDocument *doc) 
64
64
{
65
 
        const CongXMLChar* dtd_public_id;
 
65
        const gchar* dtd_public_id;
66
66
 
67
67
        g_return_val_if_fail(doc, FALSE);
68
68
 
120
120
 * Returns: a freshly-allocated string, with all tabs and carriage returns turned into their printf equivalents
121
121
 */
122
122
gchar* 
123
 
cong_util_cleanup_text (const xmlChar *src_text) 
 
123
cong_util_cleanup_text (const gchar *src_text) 
124
124
{
125
125
#if 0
126
126
        gchar *buffer;
174
174
 * Returns: a freshly-allocated string, cleaned up as described above
175
175
 */
176
176
gchar* 
177
 
cong_util_text_header (const xmlChar *text,
 
177
cong_util_text_header (const gchar *text,
178
178
                       guint truncation_length)
179
179
{
180
180
        CongTextCache* text_cache;
390
390
 */ 
391
391
xmlDtdPtr
392
392
cong_util_make_dtd (xmlDocPtr xml_doc,
393
 
                    const xmlChar *root_element,
394
 
                    const xmlChar *ExternalID, 
395
 
                    const xmlChar *SystemID)
 
393
                    const gchar *root_element,
 
394
                    const gchar *ExternalID, 
 
395
                    const gchar *SystemID)
396
396
{
397
397
#if 1
398
398
        xmlDtdPtr  dtd_ptr;
399
399
 
400
 
        g_message ("Trying to load DTD with PUBLIC \"%s\" SYSTEM \"%s\"", ExternalID, SystemID);
 
400
        /* g_message ("Trying to load DTD with PUBLIC \"%s\" SYSTEM \"%s\"", ExternalID, SystemID); */
401
401
 
402
 
        dtd_ptr = xmlParseDTD (ExternalID, 
403
 
                               SystemID);
 
402
        dtd_ptr = xmlParseDTD ((const xmlChar*)ExternalID, 
 
403
                               (const xmlChar*)SystemID);
404
404
        
405
405
        if (dtd_ptr) {
406
 
                g_message ("Succeeded");
 
406
                /* g_message ("Succeeded"); */
407
407
 
408
408
                /* Then set the document and the root_element: */
409
409
                cong_node_recursive_set_doc ((CongNodePtr)dtd_ptr, 
412
412
                if (dtd_ptr->name) {
413
413
                        xmlFree ((char*)dtd_ptr->name);
414
414
                }
415
 
                dtd_ptr->name = xmlStrdup(root_element);
 
415
                dtd_ptr->name = xmlStrdup((const xmlChar*)root_element);
416
416
 
417
417
                /* Set up ptr within the xml_doc: */
418
418
                xml_doc->extSubset = dtd_ptr;
423
423
 
424
424
                return dtd_ptr;
425
425
        } else {
426
 
                g_message ("Failed");
 
426
                /* g_message ("Failed"); */
427
427
 
428
428
                return NULL;
429
429
        }
453
453
 */
454
454
xmlDtdPtr 
455
455
cong_util_add_external_dtd (xmlDocPtr xml_doc, 
456
 
                            const xmlChar *root_element,
457
 
                            const xmlChar *ExternalID, 
458
 
                            const xmlChar *SystemID)
 
456
                            const gchar *root_element,
 
457
                            const gchar *ExternalID, 
 
458
                            const gchar *SystemID)
459
459
{
460
460
        xmlDtdPtr xml_dtd;
461
461
 
589
589
        if (xml_ns1 == NULL || xml_ns2 == NULL)
590
590
                return FALSE;
591
591
 
592
 
        return cong_util_ns_uri_equality (xml_ns1->href, 
593
 
                                          xml_ns2->href);
 
592
        return cong_util_ns_uri_equality ((const gchar*)xml_ns1->href, 
 
593
                                          (const gchar*)xml_ns2->href);
594
594
}
595
595
 
596
596
/**
720
720
        g_return_val_if_fail (node->type == XML_ELEMENT_NODE, NULL);
721
721
 
722
722
        if (node->ns) {
723
 
                return cong_element_description_new (node->ns->href,
724
 
                                                     node->name);
 
723
                return cong_element_description_new ((const gchar*)node->ns->href,
 
724
                                                     (const gchar*)node->name);
725
725
        } else {
726
726
                return cong_element_description_new (NULL,
727
 
                                                     node->name);
 
727
                                                     (const gchar*)node->name);
728
728
        }
729
729
}
730
730
                                
819
819
                return FALSE;
820
820
        }
821
821
 
822
 
        if (0!=strcmp(node->name, element_desc->local_name)) {
 
822
        if (0!=strcmp((const char*)node->name, element_desc->local_name)) {
823
823
                return FALSE;
824
824
        }
825
825
 
826
826
        if (node->ns) {
827
 
                return cong_util_ns_uri_equality (node->ns->href, element_desc->ns_uri);
 
827
                return cong_util_ns_uri_equality ((const gchar*)node->ns->href, element_desc->ns_uri);
828
828
        } else {
829
829
                return (NULL == element_desc->ns_uri);
830
830
        }
1522
1522
 */
1523
1523
char *
1524
1524
cong_util_get_qualified_attribute_name(const xmlNs *namespace,
1525
 
                                       const xmlChar *local_attribute_name)
 
1525
                                       const gchar *local_attribute_name)
1526
1526
{
1527
1527
        g_return_val_if_fail(local_attribute_name != NULL, NULL);
1528
1528
 
1636
1636
                                                                _("Associate with DTD"),
1637
1637
                                                                NULL);
1638
1638
                cong_command_add_set_external_dtd (cmd,
1639
 
                                                   cong_document_get_root_element (doc)->name,
 
1639
                                                   (const gchar*)cong_document_get_root_element (doc)->name,
1640
1640
                                                   NULL,
1641
1641
                                                   dtd_filename);
1642
1642
                cong_document_end_command (doc,
1794
1794
        return (a==b);
1795
1795
}
1796
1796
 
 
1797
/**
 
1798
 * cong_util_dup_and_free_xml_string
 
1799
 * @xml_string:
 
1800
 *
 
1801
 * Returns: makes a copy of the string using the GLib allocator, and frees the input using the libxml2 deallocator
 
1802
 */
 
1803
gchar*
 
1804
cong_util_dup_and_free_xml_string (xmlChar *xml_string)
 
1805
{
 
1806
        gchar *result = g_strdup ((const gchar*)xml_string);
 
1807
        xmlFree (xml_string);
 
1808
        return result;
 
1809
}
 
1810
 
 
1811
xmlDocPtr
 
1812
cong_util_new_xml_doc (void)
 
1813
{
 
1814
        return xmlNewDoc((const xmlChar*)"1.0");
 
1815
}
 
1816
 
 
1817
xmlNodePtr
 
1818
cong_util_new_xml_element (xmlDocPtr xml_doc, const gchar* local_name)
 
1819
{
 
1820
        g_return_val_if_fail (xml_doc, NULL);
 
1821
        g_return_val_if_fail (local_name, NULL);
 
1822
 
 
1823
        return xmlNewDocNode(xml_doc,
 
1824
                             NULL, /* xmlNsPtr ns, */
 
1825
                             (const xmlChar*)local_name,
 
1826
                             NULL);
 
1827
}
 
1828
 
 
1829
void
 
1830
cong_util_set_attribute_bool (xmlNodePtr xml_node, const gchar* name, gboolean value)
 
1831
{
 
1832
        g_return_if_fail (xml_node);
 
1833
        g_return_if_fail (name);
 
1834
 
 
1835
        xmlSetProp (xml_node, (const xmlChar*)name, (const xmlChar*)cong_util_bool_to_string (value));
 
1836
 
 
1837
}
 
1838
 
 
1839
void
 
1840
cong_util_set_attribute_int (xmlNodePtr xml_node, const gchar* name, int value)
 
1841
{
 
1842
        gchar *textual_value;
 
1843
 
 
1844
        g_return_if_fail (xml_node);
 
1845
        g_return_if_fail (name);
 
1846
 
 
1847
        textual_value = g_strdup_printf("%i", value);
 
1848
        xmlSetProp (xml_node, (const xmlChar*)name, (const xmlChar*)textual_value);
 
1849
        g_free(textual_value);
 
1850
}