replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / tool / svrdbeditor_src / svrdbeditorcommon.h
1 /* *****************************************************************
2  *
3  * Copyright 2017 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * *****************************************************************/
20
21 #ifndef SVRDBEDITOR_COMMON_H_
22 #define SVRDBEDITOR_COMMON_H_
23
24 #include "iotivity_config.h"
25 #ifdef HAVE_UNISTD_H
26 #include <unistd.h>
27 #endif
28
29 #include <stdio.h>
30
31 #include "securevirtualresourcetypes.h"
32
33 #define TAG  "OIC_SVR_DB_EDITOR"
34
35 #define BOLD_BEGIN    "\033[1m"
36 #define RED_BEGIN      "\033[1;31m"
37 #define YELLOW_BEGIN  "\033[1;33m"
38 #define CYAN_BEGIN  "\033[1;36m"
39 #define GREEN_BEGIN  "\033[1;92m"
40 #define COLOR_END      "\033[0m"
41 #define COLOR_END_NL      "\033[0m\n"
42
43 #define SVR_MAX_ENTITY (16)
44
45 #define SVR_DB_PATH_LENGTH (1024)
46 #define PRINT_ERR(fmt,...) printf(RED_BEGIN "error: " fmt COLOR_END_NL, ##__VA_ARGS__)
47 #define PRINT_WARN(fmt,...) printf(YELLOW_BEGIN "warning : " fmt COLOR_END_NL, ##__VA_ARGS__)
48 #define PRINT_INFO(fmt,...) printf(YELLOW_BEGIN fmt COLOR_END_NL, ##__VA_ARGS__)
49 #define PRINT_PROG(fmt,...) printf(BOLD_BEGIN fmt COLOR_END, ##__VA_ARGS__)
50 #define PRINT_DATA(fmt,...) printf(CYAN_BEGIN fmt COLOR_END, ##__VA_ARGS__)
51 #define PRINT_NORMAL(fmt,...) printf(fmt, ##__VA_ARGS__)
52 #define PRINT_NL() printf("\n");
53
54 typedef enum SubOperationType
55 {
56     SVR_PRINT = 1,
57     SVR_ADD = 2,
58     SVR_REMOVE = 3,
59     SVR_MODIFY = 4,
60     SVR_EDIT_IDX_SIZE = 5,
61     BACK = 99
62 } SubOperationType_t;
63
64 void PrintUuid(const OicUuid_t *uuid);
65 void PrintIntArray(const int *array, size_t length);
66 void PrintStringArray(const char **array, size_t length);
67 void PrintInt(int value);
68 void PrintString(const char *text);
69 void PrintBuffer(const uint8_t *buf, size_t bufLen);
70
71 int InputNumber(const char *infoText);
72 char *InputString(const char *infoText);
73 int InputUuid(OicUuid_t *uuid);
74
75 #endif /* SVRDBEDITOR_COMMON_H_ */