change Copyright headers, change line endings to Unix format
[platform/core/system/swap-probe.git] / include / binproto.h
index 8e150fb..f2852db 100644 (file)
@@ -1,3 +1,32 @@
+/*
+ *  DA probe
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ *
+ * Nikita Kalyazin <n.kalyazin@samsung.com>
+ * Anastasia Lyupa <a.lyupa@samsung.com>
+ * 
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Contributors:
+ * - Samsung RnD Institute Russia
+ * 
+ */
+
 #ifndef __BIN_PROTO_H__
 #define __BIN_PROTO_H__
 
@@ -20,6 +49,9 @@
 
 #include <sys/time.h>
 
+#include <sys/socket.h>
+#include "dahelper.h"
+
 #define MSG_PROBE_MEMORY 0x3001
 #define MSG_PROBE_UICONTROL 0x3002
 #define MSG_PROBE_UIEVENT 0x3003
@@ -236,24 +268,42 @@ static inline char *pack_args(char *to, const char *fmt, ...)
                BUF_PTR = pack_string(BUF_PTR, file_path);              \
        } while (0)
 
-/* #define PACK_SCREENSHOT(image_file_path, orienation)                        \ */
-/*             do {                                                    \ */
-/*                       BUF_PTR = pack_string(BUF_PTR, image_file_path); \ */
-/*                       BUF_PTR = pack_int32(BUF_PTR, orienation);    \ */
-/*               } while (0) */
-
-/* #define PACK_SCENE(scene_name, form_name, form_pointer,             \ */
-/*                panel_name, panel_pointer, transition_time,  \ */
-/*                user_transition_time)                        \ */
-/*             do {                                                    \ */
-/*     BUF_PTR = pack_string(BUF_PTR, scene_name);                             \ */
-/*     BUF_PTR = pack_string(BUF_PTR, form_name);                              \ */
-/*     BUF_PTR = pack_int64(BUF_PTR, form_pointer);                    \ */
-/*     BUF_PTR = pack_string(BUF_PTR, panel_name);                             \ */
-/*     BUF_PTR = pack_int64(BUF_PTR, panel_pointer);                   \ */
-/*     BUF_PTR = pack_int32(BUF_PTR, transition_time);                 \ */
-/*     BUF_PTR = pack_int32(BUF_PTR, user_transition_time);            \ */
-/*             } while (0) */
+#define PACK_SCREENSHOT(image_file_path, orientation)                          \
+               do {                                                            \
+                         BUF_PTR = pack_string(BUF_PTR, image_file_path);      \
+                         BUF_PTR = pack_int32(BUF_PTR, orientation);           \
+               } while (0)
+
+#define PACK_SCENE(scene_name, formid, pform, panelid, ppanel, transition, user)       \
+       do {                                                                            \
+               BUF_PTR = pack_string(BUF_PTR,  scene_name);                            \
+               if (unlikely(pform == NULL)) {                                          \
+                       BUF_PTR = pack_string(BUF_PTR, "");                             \
+                       BUF_PTR = pack_int64(BUF_PTR, 0);                               \
+               } else {                                                                \
+                       char *type = NULL, *name = NULL;                                \
+                       if (find_object_hash((void*)(pform), &type, &name) == 1) {      \
+                               BUF_PTR = pack_string(BUF_PTR, name);                   \
+                       } else {                                                        \
+                               BUF_PTR = pack_string(BUF_PTR, "");                     \
+                       }                                                               \
+                       BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)pform);                \
+               }                                                                       \
+               if (unlikely(ppanel == NULL)) {                                         \
+                       BUF_PTR = pack_string(BUF_PTR, "");                             \
+                       BUF_PTR = pack_int64(BUF_PTR, 0);                               \
+               } else {                                                                \
+                       char *type = NULL, *name = NULL;                                \
+                       if (find_object_hash((void*)(ppanel), &type, &name) == 1) {     \
+                               BUF_PTR = pack_string(BUF_PTR, name);                   \
+                       } else {                                                        \
+                               BUF_PTR = pack_string(BUF_PTR, "");                     \
+                       }                                                               \
+                       BUF_PTR = pack_int64(BUF_PTR, (uintptr_t)(ppanel));             \
+               }                                                                       \
+               BUF_PTR = pack_int64(BUF_PTR, transition);                              \
+               BUF_PTR = pack_int64(BUF_PTR, user);                                    \
+       } while(0)
 
  #define PACK_THREAD(thread_id, thread_type, api_type) \
         do {                                                           \
@@ -278,23 +328,6 @@ static inline char *pack_args(char *to, const char *fmt, ...)
                BUF_PTR = pack_int32(BUF_PTR, api_type);             \
        } while (0)
 
-#define LOG_PATH "/tmp/trace.bin"
-#define OPEN_LOG()                                     \
-               do {                                    \
-                       log_fd = creat(LOG_PATH, 0644); \
-                       if (log_fd == -1) {             \
-                               exit(1);                \
-                       }                               \
-               } while (0)
-#define CLOSE_LOG()                            \
-               do {                            \
-                       if (log_fd > 0) {       \
-                               close(log_fd);  \
-                       }                       \
-               } while (0)
-
-
-
 #define LOCAL_BUF_SIZE 1024
 #define PREPARE_LOCAL_BUF()                    \
                char buf[LOCAL_BUF_SIZE];       \
@@ -305,11 +338,11 @@ static inline char *pack_args(char *to, const char *fmt, ...)
 #define MSG_HDR_LEN 20
 #define FLUSH_LOCAL_BUF()                                              \
                *(uint32_t *)(buf + MSG_LEN_OFFSET) = (p - buf) - MSG_HDR_LEN; \
-               write(log_fd, buf, p - buf);
+               send(gTraceInfo.socket.daemonSock, buf, (p - buf), 0);
 
 // =========================== post block macro ===========================
 
-#define POST_PACK_PROBEBLOCK_BEGIN(LCTYPE, RETVALUE, INPUTFORMAT, ...) \
+#define POST_PACK_PROBEBLOCK_BEGIN()                                   \
        newerrno = errno;                                               \
        if(postBlockBegin(blockresult)) {
 
@@ -318,9 +351,6 @@ static inline char *pack_args(char *to, const char *fmt, ...)
        }                                                               \
        errno = (newerrno != 0) ? newerrno : olderrno
 
-/* data */
-extern int log_fd;
-
 /* int main(int argc, char **argv) */
 /* { */
 /*     char buf[1024]; */