Patchwork [BUG:1643,1/4] core: Introduce string representation of GF_EVENTS

login
register
Submitter Shehjar Tikoo
Date 2010-09-22 09:02:14
Message ID <1285146137-2648-1-git-send-email-shehjart@gluster.com>
Download mbox | patch
Permalink /patch/4918/
State Accepted
Headers show

Comments

Shehjar Tikoo - 2010-09-22 09:02:14
From: Shehjar Tikoo <shehjart@gluster.com>


Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
---
 libglusterfs/src/globals.c   |   23 +++++++++++++++++++++++
 libglusterfs/src/glusterfs.h |    7 +++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

Patch

diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c
index e845b3d..fcb2f9f 100644
--- a/libglusterfs/src/globals.c
+++ b/libglusterfs/src/globals.c
@@ -334,3 +334,26 @@  glusterfs_globals_init ()
 out:
         return ret;
 }
+
+
+char eventstring[GF_EVENT_MAXVAL][64] = {
+        "Invalid event",
+        "Parent Up",
+        "Poll In",
+        "Poll Out",
+        "Poll Err",
+        "Child Up",
+        "Child Down",
+        "Child Connecting",
+        "Transport Cleanup",
+        "Transport Connected",
+        "Volfile Modified",
+};
+
+/* Copy the string ptr contents if needed for yourself */
+char *
+glusterfs_strevent (glusterfs_event_t ev)
+{
+        return eventstring[ev];
+}
+
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 669bbfa..f484520 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -288,6 +288,9 @@  struct _glusterfs_ctx {
 typedef struct _glusterfs_ctx glusterfs_ctx_t;
 
 
+/* If you edit this structure then, make a corresponding change in
+ * globals.c in the eventstring.
+ */
 typedef enum {
         GF_EVENT_PARENT_UP = 1,
         GF_EVENT_POLLIN,
@@ -300,8 +303,11 @@  typedef enum {
         GF_EVENT_TRANSPORT_CONNECTED,
         GF_EVENT_VOLFILE_MODIFIED,
         GF_EVENT_GRAPH_NEW,
+        GF_EVENT_MAXVAL,
 } glusterfs_event_t;
 
+extern char *
+glusterfs_strevent (glusterfs_event_t ev);
 
 #define GF_MUST_CHECK __attribute__((warn_unused_result))
 
@@ -312,4 +318,5 @@  glusterfs_graph_t *glusterfs_graph_construct (FILE *fp);
 glusterfs_graph_t *glusterfs_graph_new ();
 int glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph,
                                   glusterfs_graph_t *newgraph);
+
 #endif /* _GLUSTERFS_H */