monitor: move to tools 05/174405/1
authorBoram Park <boram1288.park@samsung.com>
Mon, 2 Apr 2018 03:59:08 +0000 (12:59 +0900)
committerBoram Park <boram1288.park@samsung.com>
Mon, 2 Apr 2018 03:59:08 +0000 (12:59 +0900)
Change-Id: I251df596f253a71293ad16b76b280e1a0372c129

client/Makefile.am
client/tdm_monitor.c [deleted file]
tools/Makefile.am
tools/tdm_monitor.c [new file with mode: 0644]

index 859e2d32f68499e012e953f304d151615284a5ec..d50c6b2b50652086bff026d403a67ca8572fdde4 100644 (file)
@@ -26,24 +26,3 @@ libtdm_client_la_SOURCES = \
        $(top_srcdir)/protocol/tdm-protocol.c \
        tdm_client.c
 
-##########################################################################
-### tdm-monitor
-##########################################################################
-bin_PROGRAMS = \
-       tdm-monitor
-
-#tdm-monitor
-tdm_monitor_SOURCES = \
-       $(top_srcdir)/protocol/tdm-protocol.c \
-       tdm_monitor.c
-tdm_monitor_LDFLAGS = \
-       -pie \
-       ${LDFLAGS}
-tdm_monitor_LDADD = $(TDM_CLIENT_LIBS) ../common/libtdm-common.la
-tdm_monitor_CFLAGS = \
-       -fPIE \
-       $(CFLAGS) \
-       $(TDM_CFLAGS) \
-       -I$(top_srcdir)/include \
-       -I$(top_srcdir)/protocol \
-       -I$(top_srcdir)/src
diff --git a/client/tdm_monitor.c b/client/tdm_monitor.c
deleted file mode 100644 (file)
index b4ab390..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/**************************************************************************
- *
- * libtdm
- *
- * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
- *
- * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
- *          JinYoung Jeon <jy0.jeon@samsung.com>,
- *          Taeheon Kim <th908.kim@samsung.com>,
- *          YoungJun Cho <yj44.cho@samsung.com>,
- *          SooChan Lim <sc1.lim@samsung.com>,
- *          Boram Park <boram1288.park@samsung.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
-**************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "tdm_log.h"
-#include "tdm_macro.h"
-#include "tdm_list.h"
-#include "tdm-client-protocol.h"
-
-#undef exit_if_fail
-#define exit_if_fail(cond) { \
-       if (!(cond)) { \
-               printf("'%s' failed. (line:%d)\n", #cond, __LINE__); \
-               exit(0); \
-       } \
-}
-
-typedef struct _tdm_monitor_info {
-       struct wl_display *display;
-       struct wl_registry *registry;
-       struct wl_tdm *tdm;
-
-       struct {
-               int   done;
-               char  message[TDM_SERVER_REPLY_MSG_LEN];
-               char *m;
-               int   len;
-               int  *l;
-       } debug;
-} tdm_monitor_info;
-
-static tdm_monitor_info td_info;
-
-static void
-_tdm_monitor_cb_debug_message(void *data, struct wl_tdm *wl_tdm, const char *message)
-{
-       tdm_monitor_info *info = data;
-       TDM_SNPRINTF(info->debug.m, info->debug.l, "%s", message);
-}
-
-static void
-_tdm_monitor_cb_debug_done(void *data, struct wl_tdm *wl_tdm)
-{
-       tdm_monitor_info *info = data;
-       info->debug.done = 1;
-       *(info->debug.m) = '\0';
-       printf("%s", info->debug.message);
-}
-
-static const struct wl_tdm_listener  tdm_monitor_listener = {
-       _tdm_monitor_cb_debug_message,
-       _tdm_monitor_cb_debug_done,
-};
-
-static void
-_tdm_monitor_cb_global(void *data, struct wl_registry *registry,
-                                          uint32_t name, const char *interface,
-                                          uint32_t version)
-{
-       tdm_monitor_info *info = data;
-
-       if (strncmp(interface, "wl_tdm", 6) == 0) {
-               info->tdm = wl_registry_bind(registry, name, &wl_tdm_interface, version);
-               exit_if_fail(info->tdm != NULL);
-               wl_tdm_add_listener(info->tdm, &tdm_monitor_listener, info);
-               wl_display_flush(info->display);
-       }
-}
-
-static void
-_tdm_monitor_cb_global_remove(void *data, struct wl_registry *registry, uint32_t name)
-{
-}
-
-static const struct wl_registry_listener tdm_monitor_registry_listener = {
-       _tdm_monitor_cb_global,
-       _tdm_monitor_cb_global_remove
-};
-
-int
-main(int argc, char ** argv)
-{
-       tdm_monitor_info *info = &td_info;
-       int i, ret = 0;
-       char cwd[1024];
-       char options[1024];
-       int bufsize = sizeof(options);
-       char *str_buf = options;
-       int *len_buf = &bufsize;
-       const char *xdg;
-
-       xdg = (const char*)getenv("XDG_RUNTIME_DIR");
-       if (!xdg) {
-               char buf[32];
-               snprintf(buf, sizeof(buf), "/run");
-
-               ret = setenv("XDG_RUNTIME_DIR", (const char*)buf, 1);
-               exit_if_fail(ret == 0);
-       }
-
-       info->display = wl_display_connect("tdm-socket");
-       exit_if_fail(info->display != NULL);
-
-       info->registry = wl_display_get_registry(info->display);
-       exit_if_fail(info->registry != NULL);
-
-       wl_registry_add_listener(info->registry,
-                                                        &tdm_monitor_registry_listener, info);
-       wl_display_roundtrip(info->display);
-       exit_if_fail(info->tdm != NULL);
-
-       TDM_SNPRINTF(str_buf, len_buf, "%d ", getpid());
-
-       if (!getcwd(cwd, sizeof(cwd)))
-               snprintf(cwd, sizeof(cwd), "/tmp");
-       TDM_SNPRINTF(str_buf, len_buf, "%s ", cwd);
-
-       for (i = 0; i < argc; i++)
-               TDM_SNPRINTF(str_buf, len_buf, "%s ", argv[i]);
-
-       info->debug.done = 0;
-       info->debug.message[0] = '\0';
-       info->debug.len = sizeof(info->debug.message);
-       info->debug.m = info->debug.message;
-       info->debug.l = &info->debug.len;
-
-       wl_tdm_debug(info->tdm, options);
-
-       while (!info->debug.done && ret >= 0)
-               ret = wl_display_dispatch(info->display);
-
-       wl_tdm_destroy(info->tdm);
-       wl_registry_destroy(info->registry);
-       wl_display_disconnect(info->display);
-
-       return 0;
-}
index d19e5e68e65d0b3850b4af8e0016f7308d14f425..2f072364c6ad5040db2097a4f35961461cc3da50 100644 (file)
@@ -1,6 +1,7 @@
 bin_PROGRAMS = \
        tdm-test-server \
-       tdm-test-client
+       tdm-test-client \
+       tdm-monitor
 
 #tdm-test-server
 tdm_test_server_SOURCES = \
@@ -33,3 +34,19 @@ tdm_test_client_CFLAGS = \
 tdm_test_client_LDADD = \
        $(TDM_LIBS) \
        $(top_builddir)/client/libtdm-client.la
+
+#tdm-monitor
+tdm_monitor_SOURCES = \
+       $(top_srcdir)/protocol/tdm-protocol.c \
+       tdm_monitor.c
+tdm_monitor_LDFLAGS = \
+       -pie \
+       ${LDFLAGS}
+tdm_monitor_LDADD = $(TDM_CLIENT_LIBS) ../common/libtdm-common.la
+tdm_monitor_CFLAGS = \
+       -fPIE \
+       $(CFLAGS) \
+       $(TDM_CFLAGS) \
+       -I$(top_srcdir)/include \
+       -I$(top_srcdir)/protocol \
+       -I$(top_srcdir)/src
diff --git a/tools/tdm_monitor.c b/tools/tdm_monitor.c
new file mode 100644 (file)
index 0000000..b4ab390
--- /dev/null
@@ -0,0 +1,172 @@
+/**************************************************************************
+ *
+ * libtdm
+ *
+ * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
+ *          JinYoung Jeon <jy0.jeon@samsung.com>,
+ *          Taeheon Kim <th908.kim@samsung.com>,
+ *          YoungJun Cho <yj44.cho@samsung.com>,
+ *          SooChan Lim <sc1.lim@samsung.com>,
+ *          Boram Park <boram1288.park@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+**************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "tdm_log.h"
+#include "tdm_macro.h"
+#include "tdm_list.h"
+#include "tdm-client-protocol.h"
+
+#undef exit_if_fail
+#define exit_if_fail(cond) { \
+       if (!(cond)) { \
+               printf("'%s' failed. (line:%d)\n", #cond, __LINE__); \
+               exit(0); \
+       } \
+}
+
+typedef struct _tdm_monitor_info {
+       struct wl_display *display;
+       struct wl_registry *registry;
+       struct wl_tdm *tdm;
+
+       struct {
+               int   done;
+               char  message[TDM_SERVER_REPLY_MSG_LEN];
+               char *m;
+               int   len;
+               int  *l;
+       } debug;
+} tdm_monitor_info;
+
+static tdm_monitor_info td_info;
+
+static void
+_tdm_monitor_cb_debug_message(void *data, struct wl_tdm *wl_tdm, const char *message)
+{
+       tdm_monitor_info *info = data;
+       TDM_SNPRINTF(info->debug.m, info->debug.l, "%s", message);
+}
+
+static void
+_tdm_monitor_cb_debug_done(void *data, struct wl_tdm *wl_tdm)
+{
+       tdm_monitor_info *info = data;
+       info->debug.done = 1;
+       *(info->debug.m) = '\0';
+       printf("%s", info->debug.message);
+}
+
+static const struct wl_tdm_listener  tdm_monitor_listener = {
+       _tdm_monitor_cb_debug_message,
+       _tdm_monitor_cb_debug_done,
+};
+
+static void
+_tdm_monitor_cb_global(void *data, struct wl_registry *registry,
+                                          uint32_t name, const char *interface,
+                                          uint32_t version)
+{
+       tdm_monitor_info *info = data;
+
+       if (strncmp(interface, "wl_tdm", 6) == 0) {
+               info->tdm = wl_registry_bind(registry, name, &wl_tdm_interface, version);
+               exit_if_fail(info->tdm != NULL);
+               wl_tdm_add_listener(info->tdm, &tdm_monitor_listener, info);
+               wl_display_flush(info->display);
+       }
+}
+
+static void
+_tdm_monitor_cb_global_remove(void *data, struct wl_registry *registry, uint32_t name)
+{
+}
+
+static const struct wl_registry_listener tdm_monitor_registry_listener = {
+       _tdm_monitor_cb_global,
+       _tdm_monitor_cb_global_remove
+};
+
+int
+main(int argc, char ** argv)
+{
+       tdm_monitor_info *info = &td_info;
+       int i, ret = 0;
+       char cwd[1024];
+       char options[1024];
+       int bufsize = sizeof(options);
+       char *str_buf = options;
+       int *len_buf = &bufsize;
+       const char *xdg;
+
+       xdg = (const char*)getenv("XDG_RUNTIME_DIR");
+       if (!xdg) {
+               char buf[32];
+               snprintf(buf, sizeof(buf), "/run");
+
+               ret = setenv("XDG_RUNTIME_DIR", (const char*)buf, 1);
+               exit_if_fail(ret == 0);
+       }
+
+       info->display = wl_display_connect("tdm-socket");
+       exit_if_fail(info->display != NULL);
+
+       info->registry = wl_display_get_registry(info->display);
+       exit_if_fail(info->registry != NULL);
+
+       wl_registry_add_listener(info->registry,
+                                                        &tdm_monitor_registry_listener, info);
+       wl_display_roundtrip(info->display);
+       exit_if_fail(info->tdm != NULL);
+
+       TDM_SNPRINTF(str_buf, len_buf, "%d ", getpid());
+
+       if (!getcwd(cwd, sizeof(cwd)))
+               snprintf(cwd, sizeof(cwd), "/tmp");
+       TDM_SNPRINTF(str_buf, len_buf, "%s ", cwd);
+
+       for (i = 0; i < argc; i++)
+               TDM_SNPRINTF(str_buf, len_buf, "%s ", argv[i]);
+
+       info->debug.done = 0;
+       info->debug.message[0] = '\0';
+       info->debug.len = sizeof(info->debug.message);
+       info->debug.m = info->debug.message;
+       info->debug.l = &info->debug.len;
+
+       wl_tdm_debug(info->tdm, options);
+
+       while (!info->debug.done && ret >= 0)
+               ret = wl_display_dispatch(info->display);
+
+       wl_tdm_destroy(info->tdm);
+       wl_registry_destroy(info->registry);
+       wl_display_disconnect(info->display);
+
+       return 0;
+}