[phodav/wip/lantw/libphodav-rename-Lock-enums] libphodav: rename Lock* enums



commit d73861f2a35215e60e47ce235a46c44efb3ea25a
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Sun Mar 8 20:49:33 2020 +0800

    libphodav: rename Lock* enums
    
    The name 'LOCK_WRITE' is already taken by Linux. If a system header
    including 'asm-generic/fcntl.h' is included, it causes compilation error
    because the '#define' in the Linux header makes it a syntax error. This
    is known to happen on Android. To avoid the problem, rename all Lock*
    types to DAVLock*.
    
    Fixes: https://gitlab.gnome.org/GNOME/phodav/issues/2

 libphodav/phodav-lock.c        | 12 ++++++------
 libphodav/phodav-lock.h        |  2 +-
 libphodav/phodav-method-lock.c | 30 +++++++++++++++---------------
 libphodav/phodav-priv.h        | 32 ++++++++++++++++----------------
 4 files changed, 38 insertions(+), 38 deletions(-)
---
diff --git a/libphodav/phodav-lock.c b/libphodav/phodav-lock.c
index e6d8222..d6ada40 100644
--- a/libphodav/phodav-lock.c
+++ b/libphodav/phodav-lock.c
@@ -31,7 +31,7 @@ dav_lock_refresh_timeout (DAVLock *lock, guint timeout)
 
 DAVLock *
 dav_lock_new (Path *path, const gchar *token,
-              LockScopeType scope, LockType type,
+              DAVLockScopeType scope, DAVLockType type,
               DepthType depth, const xmlNodePtr owner,
               guint timeout)
 {
@@ -69,20 +69,20 @@ dav_lock_free (DAVLock *lock)
 }
 
 static const gchar *
-locktype_to_string (LockType type)
+locktype_to_string (DAVLockType type)
 {
-  if (type == LOCK_WRITE)
+  if (type == DAV_LOCK_WRITE)
     return "write";
 
   g_return_val_if_reached (NULL);
 }
 
 static const gchar *
-lockscope_to_string (LockScopeType type)
+lockscope_to_string (DAVLockScopeType type)
 {
-  if (type == LOCK_SCOPE_EXCLUSIVE)
+  if (type == DAV_LOCK_SCOPE_EXCLUSIVE)
     return "exclusive";
-  else if (type == LOCK_SCOPE_SHARED)
+  else if (type == DAV_LOCK_SCOPE_SHARED)
     return "shared";
 
   g_return_val_if_reached (NULL);
diff --git a/libphodav/phodav-lock.h b/libphodav/phodav-lock.h
index d197003..ec93b8c 100644
--- a/libphodav/phodav-lock.h
+++ b/libphodav/phodav-lock.h
@@ -29,7 +29,7 @@ typedef struct _LockSubmitted
 } LockSubmitted;
 
 DAVLock *        dav_lock_new             (Path *path, const gchar *token,
-                                           LockScopeType scope, LockType type,
+                                           DAVLockScopeType scope, DAVLockType type,
                                            DepthType depth, const xmlNodePtr owner,
                                            guint timeout);
 
diff --git a/libphodav/phodav-method-lock.c b/libphodav/phodav-method-lock.c
index 01ce238..35d01f9 100644
--- a/libphodav/phodav-method-lock.c
+++ b/libphodav/phodav-method-lock.c
@@ -34,11 +34,11 @@ check_lock (const gchar *key, Path *path, gpointer data)
   for (l = path->locks; l; l = l->next)
     {
       other = l->data;
-      if (other->scope == LOCK_SCOPE_EXCLUSIVE)
+      if (other->scope == DAV_LOCK_SCOPE_EXCLUSIVE)
         return FALSE;
     }
 
-  if (other && lock->scope == LOCK_SCOPE_EXCLUSIVE)
+  if (other && lock->scope == DAV_LOCK_SCOPE_EXCLUSIVE)
     return FALSE;
 
   return TRUE;
@@ -85,7 +85,7 @@ lock_ensure_file (PathHandler *handler, const char *path,
   return created;
 }
 
-static LockScopeType
+static DAVLockScopeType
 parse_lockscope (xmlNodePtr rt)
 {
   xmlNodePtr node;
@@ -95,17 +95,17 @@ parse_lockscope (xmlNodePtr rt)
       break;
 
   if (node == NULL)
-    return LOCK_SCOPE_NONE;
+    return DAV_LOCK_SCOPE_NONE;
 
   if (!g_strcmp0 ((char *) node->name, "exclusive"))
-    return LOCK_SCOPE_EXCLUSIVE;
+    return DAV_LOCK_SCOPE_EXCLUSIVE;
   else if (!g_strcmp0 ((char *) node->name, "shared"))
-    return LOCK_SCOPE_SHARED;
+    return DAV_LOCK_SCOPE_SHARED;
   else
-    return LOCK_SCOPE_NONE;
+    return DAV_LOCK_SCOPE_NONE;
 }
 
-static LockType
+static DAVLockType
 parse_locktype (xmlNodePtr rt)
 {
   xmlNodePtr node;
@@ -115,12 +115,12 @@ parse_locktype (xmlNodePtr rt)
       break;
 
   if (node == NULL)
-    return LOCK_NONE;
+    return DAV_LOCK_NONE;
 
   if (!g_strcmp0 ((char *) node->name, "write"))
-    return LOCK_WRITE;
+    return DAV_LOCK_WRITE;
   else
-    return LOCK_NONE;
+    return DAV_LOCK_NONE;
 }
 
 gint
@@ -134,8 +134,8 @@ phodav_method_lock (PathHandler *handler, SoupMessage *msg,
   DavDoc doc = {0, };
   xmlNodePtr node = NULL, owner = NULL, root = NULL;
   xmlNsPtr ns = NULL;
-  LockScopeType scope = LOCK_SCOPE_SHARED;
-  LockType type;
+  DAVLockScopeType scope = DAV_LOCK_SCOPE_SHARED;
+  DAVLockType type;
   DepthType depth;
   guint timeout;
   gchar *ltoken = NULL, *uuid = NULL, *token = NULL;
@@ -182,13 +182,13 @@ phodav_method_lock (PathHandler *handler, SoupMessage *msg,
       if (xml_node_has_name (node, "lockscope"))
         {
           scope = parse_lockscope (node);
-          if (scope == LOCK_SCOPE_NONE)
+          if (scope == DAV_LOCK_SCOPE_NONE)
             break;
         }
       else if (xml_node_has_name (node, "locktype"))
         {
           type = parse_locktype (node);
-          if (type == LOCK_NONE)
+          if (type == DAV_LOCK_NONE)
             break;
         }
       else if (xml_node_has_name (node, "owner"))
diff --git a/libphodav/phodav-priv.h b/libphodav/phodav-priv.h
index eb369a0..460ae83 100644
--- a/libphodav/phodav-priv.h
+++ b/libphodav/phodav-priv.h
@@ -36,16 +36,16 @@ typedef struct _DAVLock DAVLock;
 typedef struct _Path    Path;
 typedef struct _PathHandler PathHandler;
 
-typedef enum _LockScopeType {
-  LOCK_SCOPE_NONE,
-  LOCK_SCOPE_EXCLUSIVE,
-  LOCK_SCOPE_SHARED,
-} LockScopeType;
+typedef enum _DAVLockScopeType {
+  DAV_LOCK_SCOPE_NONE,
+  DAV_LOCK_SCOPE_EXCLUSIVE,
+  DAV_LOCK_SCOPE_SHARED,
+} DAVLockScopeType;
 
-typedef enum _LockType {
-  LOCK_NONE,
-  LOCK_WRITE,
-} LockType;
+typedef enum _DAVLockType {
+  DAV_LOCK_NONE,
+  DAV_LOCK_WRITE,
+} DAVLockType;
 
 typedef enum _DepthType {
   DEPTH_ZERO,
@@ -61,13 +61,13 @@ typedef enum _PropFindType {
 
 struct _DAVLock
 {
-  Path         *path;
-  gchar         token[45];
-  LockScopeType scope;
-  LockType      type;
-  DepthType     depth;
-  xmlNodePtr    owner;
-  guint64       timeout;
+  Path            *path;
+  gchar            token[45];
+  DAVLockScopeType scope;
+  DAVLockType      type;
+  DepthType        depth;
+  xmlNodePtr       owner;
+  guint64          timeout;
 };
 
 typedef gboolean (* PathCb) (const gchar *key,


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