• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef TEST_PROCESS_MSG_H
17 #define TEST_PROCESS_MSG_H
18 
19 #include <errno.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <unistd.h>
24 #include <stdint.h>
25 #include <pthread.h>
26 #include <stdarg.h>
27 #include "distributed_kv_data_manager.h"
28 #include <sys/time.h>
29 
30 #define MAX_DATA_LENGTH 1024
31 #define RESULT_OK  0
32 #define RESULT_ERR 1
33 
34 typedef enum{
35     CTRL_CODE_SOFTBUS_TYPE = 1000,
36     CTRL_CODE_SOFTBUS_OPEN_SESSION,
37     CTRL_CODE_DATAMGR_TYPE = 2000,
38     CTRL_CODE_DATAMGR_GET_DATA,
39     CTRL_CODE_DATAMGR_GET_DATA_REPLY,
40     CTRL_CODE_DATAMGR_CREATE_KV,
41     CTRL_CODE_DATAMGR_DELETE_KV,
42     CTRL_CODE_DATAMGR_PUT_DATA,
43     CTRL_CODE_DATAMGR_DELETE_DATA,
44     CTRL_CODE_DM_TYPE = 3000,
45     CTRL_CODE_FILEMGR_TYPE = 4000,
46     CTRL_CODE_DP_TYPE = 5000,
47     CTRL_CODE_SEC_TYPE = 6000,
48     CTRL_CODE_MEDIA_TYPE = 7000,
49     CTRL_CODE_RESULT_TYPE = 9999,
50 } CtrlCodeType;
51 
52 
53 #define LOG(format, ...)                           \
54 do                                                 \
55 {                                                  \
56     time_t timeSec;                                \
57     time(&timeSec);                                \
58     struct tm tmRst;                               \
59     localtime_r(&timeSec, &tmRst);                 \
60     char strTime[10];                              \
61     strftime(strTime, sizeof(strTime), "%H:%M:%S", &tmRst);              \
62     fprintf(stdout, "[process-dataMsg] %s " format "\n", strTime, ##__VA_ARGS__);   \
63 } while(0)
64 
65 
66 int ProcessSoftBus(int code, char* recvData);
67 int ProcessDataMgr(int code, char* recvData);
68 int ProcessDP(int code, char* recvData);
69 int ProcessDM(int code, char* recvData);
70 int ProcessFileMgr(int code, char* recvData);
71 int ProcessSecMgr(int code, char* recvData);
72 int ProcessMediaMgr(int code, char* recvData);
73 
74 int processDeletetData(char* putData);
75 int processGetData(char* putData);
76 int processPutData(char* putData);
77 int processCreateKv(char* putData);
78 int processDeleteKv(char* putData);
79 char* getRealData(char* str, char* delims);
80 int str2int(char *str, int base);
81 void getParam(char* str, char ret[] [MAX_DATA_LENGTH]);
82 void initKvstoreId();
83 #endif
84 
85 
86