[libgepub/wip/cosimoc/api-rework: 10/13] Const-ify API methods that take strings



commit ebea3534bfe24d25b183ed770379ace9aa649823
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Jun 18 13:09:43 2016 -0700

    Const-ify API methods that take strings

 libgepub/gepub-doc.c   |   14 +++++++-------
 libgepub/gepub-doc.h   |   14 +++++++-------
 libgepub/gepub-utils.c |    8 ++++----
 libgepub/gepub-utils.h |    6 +++---
 4 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/libgepub/gepub-doc.c b/libgepub/gepub-doc.c
index 9778a2e..5e2d2cc 100644
--- a/libgepub/gepub-doc.c
+++ b/libgepub/gepub-doc.c
@@ -302,7 +302,7 @@ gepub_doc_get_content (GepubDoc *doc)
  * Returns: (transfer full): metadata string
  */
 gchar *
-gepub_doc_get_metadata (GepubDoc *doc, gchar *mdata)
+gepub_doc_get_metadata (GepubDoc *doc, const gchar *mdata)
 {
     xmlDoc *xdoc = NULL;
     xmlNode *root_element = NULL;
@@ -348,7 +348,7 @@ gepub_doc_get_resources (GepubDoc *doc)
  * Returns: (transfer full): the resource content
  */
 GBytes *
-gepub_doc_get_resource_by_id (GepubDoc *doc, gchar *id)
+gepub_doc_get_resource_by_id (GepubDoc *doc, const gchar *id)
 {
     GepubResource *gres = g_hash_table_lookup (doc->resources, id);
     if (!gres) {
@@ -367,7 +367,7 @@ gepub_doc_get_resource_by_id (GepubDoc *doc, gchar *id)
  * Returns: (transfer full): the resource content
  */
 GBytes *
-gepub_doc_get_resource (GepubDoc *doc, gchar *path)
+gepub_doc_get_resource (GepubDoc *doc, const gchar *path)
 {
     return gepub_archive_read_entry (doc->archive, path);
 }
@@ -380,7 +380,7 @@ gepub_doc_get_resource (GepubDoc *doc, gchar *path)
  * Returns: (transfer full): the resource content
  */
 gchar *
-gepub_doc_get_resource_mime_by_id (GepubDoc *doc, gchar *id)
+gepub_doc_get_resource_mime_by_id (GepubDoc *doc, const gchar *id)
 {
     GepubResource *gres;
 
@@ -403,7 +403,7 @@ gepub_doc_get_resource_mime_by_id (GepubDoc *doc, gchar *id)
  * Returns: (transfer full): the resource mime
  */
 gchar *
-gepub_doc_get_resource_mime (GepubDoc *doc, gchar *path)
+gepub_doc_get_resource_mime (GepubDoc *doc, const gchar *path)
 {
     GepubResource *gres;
     GList *keys = g_hash_table_get_keys (doc->resources);
@@ -521,7 +521,7 @@ gepub_doc_get_text (GepubDoc *doc)
  * Returns: (element-type Gepub.TextChunk) (transfer full): the list of text in the current chapter.
  */
 GList *
-gepub_doc_get_text_by_id (GepubDoc *doc, gchar *id)
+gepub_doc_get_text_by_id (GepubDoc *doc, const gchar *id)
 {
     xmlDoc *xdoc = NULL;
     xmlNode *root_element = NULL;
@@ -620,7 +620,7 @@ gepub_doc_get_cover (GepubDoc *doc)
  * Returns: (transfer full): the resource path
  */
 gchar *
-gepub_doc_get_resource_path (GepubDoc *doc, gchar *id)
+gepub_doc_get_resource_path (GepubDoc *doc, const gchar *id)
 {
     GepubResource *gres = g_hash_table_lookup (doc->resources, id);
     if (!gres) {
diff --git a/libgepub/gepub-doc.h b/libgepub/gepub-doc.h
index 304ec91..5030afb 100644
--- a/libgepub/gepub-doc.h
+++ b/libgepub/gepub-doc.h
@@ -46,22 +46,22 @@ GType             gepub_doc_get_type                        (void) G_GNUC_CONST;
 
 GepubDoc         *gepub_doc_new                             (const gchar *path);
 GBytes           *gepub_doc_get_content                     (GepubDoc *doc);
-gchar            *gepub_doc_get_metadata                    (GepubDoc *doc, gchar *mdata);
-GBytes           *gepub_doc_get_resource                    (GepubDoc *doc, gchar *path);
-GBytes           *gepub_doc_get_resource_by_id              (GepubDoc *doc, gchar *id);
+gchar            *gepub_doc_get_metadata                    (GepubDoc *doc, const gchar *mdata);
+GBytes           *gepub_doc_get_resource                    (GepubDoc *doc, const gchar *path);
+GBytes           *gepub_doc_get_resource_by_id              (GepubDoc *doc, const gchar *id);
 GHashTable       *gepub_doc_get_resources                   (GepubDoc *doc);
-gchar            *gepub_doc_get_resource_mime               (GepubDoc *doc, gchar *path);
-gchar            *gepub_doc_get_resource_mime_by_id         (GepubDoc *doc, gchar *id);
+gchar            *gepub_doc_get_resource_mime               (GepubDoc *doc, const gchar *path);
+gchar            *gepub_doc_get_resource_mime_by_id         (GepubDoc *doc, const gchar *id);
 gchar            *gepub_doc_get_current_mime                (GepubDoc *doc);
 GList            *gepub_doc_get_spine                       (GepubDoc *doc);
 GList            *gepub_doc_get_text                        (GepubDoc *doc);
-GList            *gepub_doc_get_text_by_id                  (GepubDoc *doc, gchar *id);
+GList            *gepub_doc_get_text_by_id                  (GepubDoc *doc, const gchar *id);
 GBytes           *gepub_doc_get_current                     (GepubDoc *doc);
 GBytes           *gepub_doc_get_current_with_epub_uris      (GepubDoc *doc);
 gboolean          gepub_doc_go_next                         (GepubDoc *doc);
 gboolean          gepub_doc_go_prev                         (GepubDoc *doc);
 gchar            *gepub_doc_get_cover                       (GepubDoc *doc);
-gchar            *gepub_doc_get_resource_path               (GepubDoc *doc, gchar *id);
+gchar            *gepub_doc_get_resource_path               (GepubDoc *doc, const gchar *id);
 gchar            *gepub_doc_get_current_path                (GepubDoc *doc);
 
 G_END_DECLS
diff --git a/libgepub/gepub-utils.c b/libgepub/gepub-utils.c
index f907e05..2f81f33 100644
--- a/libgepub/gepub-utils.c
+++ b/libgepub/gepub-utils.c
@@ -31,7 +31,7 @@
  * function also makes the resource absolute based on the epub root
  */
 static void
-set_epub_uri (xmlNode *node, gchar *path, gchar *tagname, gchar *attr)
+set_epub_uri (xmlNode *node, const gchar *path, const gchar *tagname, const gchar *attr)
 {
     xmlNode *cur_node = NULL;
     xmlChar *text = NULL;
@@ -108,7 +108,7 @@ gepub_utils_has_parent_tag (xmlNode *node, gchar *name, ...)
  * Returns: the tag matching @name.
  */
 xmlNode *
-gepub_utils_get_element_by_tag (xmlNode *node, gchar *name)
+gepub_utils_get_element_by_tag (xmlNode *node, const gchar *name)
 {
     xmlNode *cur_node = NULL;
     xmlNode *ret = NULL;
@@ -135,7 +135,7 @@ gepub_utils_get_element_by_tag (xmlNode *node, gchar *name)
  * Returns: the element matching @attr and @value.
  */
 xmlNode *
-gepub_utils_get_element_by_attr (xmlNode *node, gchar *attr, gchar *value)
+gepub_utils_get_element_by_attr (xmlNode *node, const gchar *attr, const gchar *value)
 {
     xmlNode *cur_node = NULL;
     xmlNode *ret = NULL;
@@ -221,7 +221,7 @@ gepub_utils_get_text_elements (xmlNode *node)
  * able to provide these files to webkit from the epub file
  */
 GBytes *
-gepub_utils_replace_resources (GBytes *content, gchar *path)
+gepub_utils_replace_resources (GBytes *content, const gchar *path)
 {
     xmlDoc *doc = NULL;
     xmlNode *root_element = NULL;
diff --git a/libgepub/gepub-utils.h b/libgepub/gepub-utils.h
index 4fc548b..1dbf388 100644
--- a/libgepub/gepub-utils.h
+++ b/libgepub/gepub-utils.h
@@ -22,9 +22,9 @@
 #include <glib.h>
 #include <libxml/tree.h>
 
-xmlNode * gepub_utils_get_element_by_tag  (xmlNode *node, gchar *name);
-xmlNode * gepub_utils_get_element_by_attr (xmlNode *node, gchar *attr, gchar *value);
+xmlNode * gepub_utils_get_element_by_tag  (xmlNode *node, const gchar *name);
+xmlNode * gepub_utils_get_element_by_attr (xmlNode *node, const gchar *attr, const gchar *value);
 GList *   gepub_utils_get_text_elements   (xmlNode *node);
-GBytes *  gepub_utils_replace_resources   (GBytes *content, gchar *path);
+GBytes *  gepub_utils_replace_resources   (GBytes *content, const gchar *path);
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]