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 <cerrno> 20 #include <cstdarg> 21 #include <cstdint> 22 #include <cstdio> 23 #include <cstdlib> 24 #include <cstring> 25 #include <pthread.h> 26 #include <sys/time.h> 27 #include <unistd.h> 28 29 #include "distributed_kv_data_manager.h" 30 31 typedef enum { 32 CTRL_CODE_SOFTBUS_TYPE = 1000, 33 CTRL_CODE_SOFTBUS_OPEN_SESSION, 34 CTRL_CODE_DATAMGR_TYPE = 2000, 35 CTRL_CODE_DATAMGR_GET_DATA, 36 CTRL_CODE_DATAMGR_GET_DATA_REPLY, 37 CTRL_CODE_DATAMGR_CREATE_KV, 38 CTRL_CODE_DATAMGR_DELETE_KV, 39 CTRL_CODE_DATAMGR_PUT_DATA, 40 CTRL_CODE_DATAMGR_DELETE_DATA, 41 CTRL_CODE_DM_TYPE = 3000, 42 CTRL_CODE_FILEMGR_TYPE = 4000, 43 CTRL_CODE_DP_TYPE = 5000, 44 CTRL_CODE_SEC_TYPE = 6000, 45 CTRL_CODE_MEDIA_TYPE = 7000, 46 CTRL_CODE_RESULT_TYPE = 9999, 47 } CtrlCodeType; 48 49 #define LOG(format, ...) \ 50 do { \ 51 time_t timeSec; \ 52 time(&timeSec); \ 53 struct tm tmRst; \ 54 localtime_r(&timeSec, &tmRst); \ 55 char strTime[10]; \ 56 strftime(strTime, sizeof(strTime), "%H:%M:%S", &tmRst); \ 57 fprintf(stdout, "[process-dataMsg] %s " format "\n", strTime, ##__VA_ARGS__); \ 58 } while (0) 59 60 int ProcessSoftBus(int code, char* recvData); 61 int ProcessDataMgr(int code, char* recvData); 62 int ProcessDP(int code, char* recvData); 63 int ProcessDM(int code, char* recvData); 64 int ProcessFileMgr(int code, char* recvData); 65 int ProcessSecMgr(int code, char* recvData); 66 int ProcessMediaMgr(int code, char* recvData); 67 68 int processDeletetData(char* putData); 69 int processGetData(char* putData); 70 int processPutData(char* putData); 71 int processCreateKv(char* putData); 72 int processDeleteKv(char* putData); 73 char* getRealData(char* str, char* delims); 74 void getParam(char* putData, char ret[][1024]); 75 void initKvstoreId(void); 76 #endif