#define __DS_WAYLAND_PROTOCOL_TRACE_PRIVATE_H__
#include "DSWaylandProtocolTrace.h"
-//#include "DSWaylandProtocolTraceStruct.h"
+#include "DSWaylandProtocolTraceStruct.h"
#include <wayland-server.h>
#include <wayland-server-core.h>
#include <wayland-util.h>
#include <cstring>
-#define PATH_MAX 512
-
-#ifndef MAX
-#define MAX(x, y) (((x) > (y)) ? (x) : (y))
-#endif
-
-#ifndef MIN
-#define MIN(x, y) (((x) < (y)) ? (x) : (y))
-#endif
-
-#define BUF_SNPRINTF(fmt, ARG...) do { \
- str_l = snprintf(str_buff, str_r, fmt, ##ARG); \
- str_buff += str_l; \
- str_r -= str_l; \
-} while(0)
-
-
-/*
-#ifndef REPLY
- #define REPLY(fmt, ARG...) \
- do { \
- if (reply && len && *len > 0) \
- { \
- int s = snprintf(reply, *len, fmt, ##ARG); \
- reply += s; \
- *len -= s; \
- } \
- } while (0)
-#endif
-*/
-#define MAX_RULE 64
-#define STRING_MAX 64
namespace display_server
{
-typedef struct _ProtocolTrace_Tree_Node ProtocolTrace_Tree_Node;
-typedef struct _ProtocolTrace_Tree ProtocolTrace_Tree;
-typedef struct _ProtocolTrace_Token_Data ProtocolTrace_Token_Data;
-typedef struct _ProtocolTrace_Rule_Node ProtocolTrace_Rule_Node;
-typedef struct _ProtocolTrace_Rule ProtocolTrace_Rule;
-typedef struct _ProtocolTrace_Rule_Checker ProtocolTrace_Rule_Checker;
-typedef struct _ProtocolTrace_Protocol_Log ProtocolTrace_Protocol_Log;
-
-typedef int (*ProtocolTrace_Tree_Traverse_Cb) (ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg);
-
-struct _ProtocolTrace_Tree_Node
-{
- ProtocolTrace_Tree_Node *left;
- ProtocolTrace_Tree_Node *right;
-};
-
-struct _ProtocolTrace_Tree
-{
- int size;
- ProtocolTrace_Tree_Node *head;
-};
-
-typedef enum
-{
- PROTOCOLTRACE_TOKEN_UNKNOWN = 0,
- PROTOCOLTRACE_TOKEN_L_BR =1,
- PROTOCOLTRACE_TOKEN_R_BR =2,
- PROTOCOLTRACE_TOKEN_NOT_EQ=3,
- PROTOCOLTRACE_TOKEN_EQUAL=4,
- PROTOCOLTRACE_TOKEN_LSS_THAN=5,
- PROTOCOLTRACE_TOKEN_LSS_EQ =6,
- PROTOCOLTRACE_TOKEN_GRT_THAN=7,
- PROTOCOLTRACE_TOKEN_GRT_EQ =8,
- PROTOCOLTRACE_TOKEN_AND=9,
- PROTOCOLTRACE_TOKEN_OR=10,
- PROTOCOLTRACE_TOKEN_SPACE=11,
- PROTOCOLTRACE_TOKEN_SYMBOL=12,
- PROTOCOLTRACE_TOKEN_NUMBER=13,
- PROTOCOLTRACE_TOKEN_EOS=14,
-} ProtocolTrace_Token;
-
-struct _ProtocolTrace_Token_Data
-{
- const char **string;
- ProtocolTrace_Token last_token;
- const char *last_symbol;
- int symbol_len;
-};
-typedef enum
-{
- PROTOCOLTRACE_NODE_TYPE_NONE,
- PROTOCOLTRACE_NODE_TYPE_AND,
- PROTOCOLTRACE_NODE_TYPE_OR,
- PROTOCOLTRACE_NODE_TYPE_DATA,
- PROTOCOLTRACE_NODE_TYPE_ALL
-} ProtocolTrace_Node_Type;
-
-typedef enum
-{
- PROTOCOLTRACE_COMPARER_EQUAL,
- PROTOCOLTRACE_COMPARER_LESS,
- PROTOCOLTRACE_COMPARER_GREATER,
- PROTOCOLTRACE_COMPARER_LESS_EQ,
- PROTOCOLTRACE_COMPARER_GREATE_EQ,
- PROTOCOLTRACE_COMPARER_NOT_EQ
-} ProtocolTrace_Comparer;
-
-typedef enum
-{
- PROTOCOLTRACE_DATA_TYPE_INTEGER,
- PROTOCOLTRACE_DATA_TYPE_STRING
-} ProtocolTrace_Data_Type;
-
-typedef enum
-{
- PROTOCOLTRACE_RESULT_UNKNOWN,
- PROTOCOLTRACE_RESULT_TRUE,
- PROTOCOLTRACE_RESULT_FALSE
-} ProtocolTrace_Result_Type;
-
-struct _ProtocolTrace_Rule_Node
-{
- ProtocolTrace_Node_Type node_type;
- char variable_name[STRING_MAX];
- ProtocolTrace_Comparer comparer;
- ProtocolTrace_Data_Type value_type;
-
- union
- {
- char string[STRING_MAX];
- int integer;
- }value;
-
- ProtocolTrace_Result_Type result;
-};
-
-typedef enum
-{
- PROTOCOLTRACE_POLICY_TYPE_UNDEFINED,
- PROTOCOLTRACE_TYPE_ALLOW,
- PROTOCOLTRACE_TYPE_DENY
-} ProtocolTrace_Policy_Type;
-
-struct _ProtocolTrace_Rule
-{
- ProtocolTrace_Policy_Type policy;
- ProtocolTrace_Tree *tree;
-};
-
-struct _ProtocolTrace_Rule_Checker
-{
- ProtocolTrace_Rule rules[MAX_RULE];
- int count;
-};
-typedef enum
-{
- PROTOCOLTRACE_RULE_SET_OK,
- PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES,
- PROTOCOLTRACE_RULE_SET_ERR_PARSE,
- PROTOCOLTRACE_RULE_SET_ERR_NO_RULE
- } ProtocolTrace_Rule_Set_Result;
-typedef enum{
- PROTOCOL_TYPE_REQUEST,
- PROTOCOL_TYPE_EVENT
-} ProtocolTrace_Protocol_Type;
-struct _ProtocolTrace_Protocol_Log
-{
- ProtocolTrace_Protocol_Type type;
- int client_pid;
- int target_id;
- char name[PATH_MAX +1];
- char cmd[PATH_MAX +1];
-};
-struct argument_details {
- char type;
- int nullable;
-};
-
-typedef struct
-{
- int type;
- int target_id;
- const char *name;
- int pid;
- const char *cmd;
-} ProtocolTrace_Validate_Args;
-
-typedef struct
-{
- char **reply;
- int *len;
-} ProtocolTrace_Reply_Buffer;
-
class DSWaylandProtocolTracePrivate : public DSObjectPrivate
{
DS_PIMPL_USE_PUBLIC(DSWaylandProtocolTrace);
--- /dev/null
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* 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, sublicense,
+* 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 NONINFRINGEMENT. IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS 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.
+*/
+
+#ifndef __DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__
+#define __DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__
+
+#define PATH_MAX 512
+#define MAX_RULE 64
+#define STRING_MAX 64
+
+#ifndef MAX
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#endif
+
+#ifndef MIN
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+#endif
+
+#define BUF_SNPRINTF(fmt, ARG...) do { \
+ str_l = snprintf(str_buff, str_r, fmt, ##ARG); \
+ str_buff += str_l; \
+ str_r -= str_l; \
+} while(0)
+
+/*
+#ifndef REPLY
+ #define REPLY(fmt, ARG...) \
+ do { \
+ if (reply && len && *len > 0) \
+ { \
+ int s = snprintf(reply, *len, fmt, ##ARG); \
+ reply += s; \
+ *len -= s; \
+ } \
+ } while (0)
+#endif
+*/
+
+namespace display_server
+{
+
+typedef struct _ProtocolTrace_Tree_Node ProtocolTrace_Tree_Node;
+typedef struct _ProtocolTrace_Tree ProtocolTrace_Tree;
+typedef struct _ProtocolTrace_Token_Data ProtocolTrace_Token_Data;
+typedef struct _ProtocolTrace_Rule_Node ProtocolTrace_Rule_Node;
+typedef struct _ProtocolTrace_Rule ProtocolTrace_Rule;
+typedef struct _ProtocolTrace_Rule_Checker ProtocolTrace_Rule_Checker;
+typedef struct _ProtocolTrace_Protocol_Log ProtocolTrace_Protocol_Log;
+
+typedef int (*ProtocolTrace_Tree_Traverse_Cb) (ProtocolTrace_Tree *tree, ProtocolTrace_Tree_Node *node, ProtocolTrace_Tree_Node *parent, void *arg);
+
+struct _ProtocolTrace_Tree_Node
+{
+ ProtocolTrace_Tree_Node *left;
+ ProtocolTrace_Tree_Node *right;
+};
+
+struct _ProtocolTrace_Tree
+{
+ int size;
+ ProtocolTrace_Tree_Node *head;
+};
+
+typedef enum
+{
+ PROTOCOLTRACE_TOKEN_UNKNOWN = 0,
+ PROTOCOLTRACE_TOKEN_L_BR =1,
+ PROTOCOLTRACE_TOKEN_R_BR =2,
+ PROTOCOLTRACE_TOKEN_NOT_EQ=3,
+ PROTOCOLTRACE_TOKEN_EQUAL=4,
+ PROTOCOLTRACE_TOKEN_LSS_THAN=5,
+ PROTOCOLTRACE_TOKEN_LSS_EQ =6,
+ PROTOCOLTRACE_TOKEN_GRT_THAN=7,
+ PROTOCOLTRACE_TOKEN_GRT_EQ =8,
+ PROTOCOLTRACE_TOKEN_AND=9,
+ PROTOCOLTRACE_TOKEN_OR=10,
+ PROTOCOLTRACE_TOKEN_SPACE=11,
+ PROTOCOLTRACE_TOKEN_SYMBOL=12,
+ PROTOCOLTRACE_TOKEN_NUMBER=13,
+ PROTOCOLTRACE_TOKEN_EOS=14,
+} ProtocolTrace_Token;
+
+struct _ProtocolTrace_Token_Data
+{
+ const char **string;
+ ProtocolTrace_Token last_token;
+ const char *last_symbol;
+ int symbol_len;
+};
+typedef enum
+{
+ PROTOCOLTRACE_NODE_TYPE_NONE,
+ PROTOCOLTRACE_NODE_TYPE_AND,
+ PROTOCOLTRACE_NODE_TYPE_OR,
+ PROTOCOLTRACE_NODE_TYPE_DATA,
+ PROTOCOLTRACE_NODE_TYPE_ALL
+} ProtocolTrace_Node_Type;
+
+typedef enum
+{
+ PROTOCOLTRACE_COMPARER_EQUAL,
+ PROTOCOLTRACE_COMPARER_LESS,
+ PROTOCOLTRACE_COMPARER_GREATER,
+ PROTOCOLTRACE_COMPARER_LESS_EQ,
+ PROTOCOLTRACE_COMPARER_GREATE_EQ,
+ PROTOCOLTRACE_COMPARER_NOT_EQ
+} ProtocolTrace_Comparer;
+
+typedef enum
+{
+ PROTOCOLTRACE_DATA_TYPE_INTEGER,
+ PROTOCOLTRACE_DATA_TYPE_STRING
+} ProtocolTrace_Data_Type;
+
+typedef enum
+{
+ PROTOCOLTRACE_RESULT_UNKNOWN,
+ PROTOCOLTRACE_RESULT_TRUE,
+ PROTOCOLTRACE_RESULT_FALSE
+} ProtocolTrace_Result_Type;
+
+struct _ProtocolTrace_Rule_Node
+{
+ ProtocolTrace_Node_Type node_type;
+ char variable_name[STRING_MAX];
+ ProtocolTrace_Comparer comparer;
+ ProtocolTrace_Data_Type value_type;
+
+ union
+ {
+ char string[STRING_MAX];
+ int integer;
+ }value;
+
+ ProtocolTrace_Result_Type result;
+};
+
+typedef enum
+{
+ PROTOCOLTRACE_POLICY_TYPE_UNDEFINED,
+ PROTOCOLTRACE_TYPE_ALLOW,
+ PROTOCOLTRACE_TYPE_DENY
+} ProtocolTrace_Policy_Type;
+
+struct _ProtocolTrace_Rule
+{
+ ProtocolTrace_Policy_Type policy;
+ ProtocolTrace_Tree *tree;
+};
+
+struct _ProtocolTrace_Rule_Checker
+{
+ ProtocolTrace_Rule rules[MAX_RULE];
+ int count;
+};
+typedef enum
+{
+ PROTOCOLTRACE_RULE_SET_OK,
+ PROTOCOLTRACE_RULE_SET_ERR_TOO_MANY_RULES,
+ PROTOCOLTRACE_RULE_SET_ERR_PARSE,
+ PROTOCOLTRACE_RULE_SET_ERR_NO_RULE
+ } ProtocolTrace_Rule_Set_Result;
+typedef enum{
+ PROTOCOL_TYPE_REQUEST,
+ PROTOCOL_TYPE_EVENT
+} ProtocolTrace_Protocol_Type;
+struct _ProtocolTrace_Protocol_Log
+{
+ ProtocolTrace_Protocol_Type type;
+ int client_pid;
+ int target_id;
+ char name[PATH_MAX +1];
+ char cmd[PATH_MAX +1];
+};
+struct argument_details {
+ char type;
+ int nullable;
+};
+
+typedef struct
+{
+ int type;
+ int target_id;
+ const char *name;
+ int pid;
+ const char *cmd;
+} ProtocolTrace_Validate_Args;
+
+typedef struct
+{
+ char **reply;
+ int *len;
+} ProtocolTrace_Reply_Buffer;
+
+}
+
+
+#endif //__DS_WAYLAND_PROTOCOL_TRACE_STRUCT_H__
\ No newline at end of file