1 /* 2 * Copyright (c) 2021 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 PLUGIN_ADAPTER_ 17 #define PLUGIN_ADAPTER_ 18 #include <memory.h> 19 #include <stdint.h> 20 #include <stdio.h> 21 22 #include "init_log.h" 23 #include "securec.h" 24 25 typedef struct { 26 char *name; 27 int (*cmdExecutor)(int id, const char *name, int argc, const char **argv); 28 int index; 29 } PluginCmd; 30 31 #define READ_DURATION 100000 32 #define PLUGIN_LOG_FILE "plugintest.log" 33 #define PLUGIN_LABEL "PLUGIN" 34 #define PLUGIN_LOGI(fmt, ...) STARTUP_LOGI(PLUGIN_LOG_FILE, PLUGIN_LABEL, fmt, ##__VA_ARGS__) 35 #define PLUGIN_LOGE(fmt, ...) STARTUP_LOGE(PLUGIN_LOG_FILE, PLUGIN_LABEL, fmt, ##__VA_ARGS__) 36 #define PLUGIN_LOGV(fmt, ...) STARTUP_LOGV(PLUGIN_LOG_FILE, PLUGIN_LABEL, fmt, ##__VA_ARGS__) 37 38 #define PLUGIN_CHECK(ret, exper, ...) \ 39 if (!(ret)) { \ 40 PLUGIN_LOGE(__VA_ARGS__); \ 41 exper; \ 42 } 43 #define PLUGIN_ONLY_CHECK(ret, exper, ...) \ 44 if (!(ret)) { \ 45 exper; \ 46 } 47 #endif