1 /*
2 * Copyright (C) 2024 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 #ifndef RUST_HDC_BASE
16 #define RUST_HDC_BASE
17
18 #include <cstdio>
19 #include <securec.h>
20 #include <vector>
21 #include <string>
22
23 namespace Hdc {
24 using namespace std;
25
26 constexpr uint16_t MAX_SIZE_IOBUF = 61440;
27 constexpr uint16_t BUF_SIZE_MEDIUM = 512;
28 constexpr uint16_t BUF_SIZE_DEFAULT = 1024;
29 constexpr uint16_t BUF_SIZE_DEFAULT4 = BUF_SIZE_DEFAULT * 4;
30
GetMaxBufSize()31 inline int GetMaxBufSize()
32 {
33 return MAX_SIZE_IOBUF;
34 }
35
ZeroStruct(T & structBuf)36 template<class T> int ZeroStruct(T &structBuf)
37 {
38 return memset_s(&structBuf, sizeof(T), 0, sizeof(T));
39 }
40
41 const std::string StringFormat(const char * const formater, va_list &vaArgs);
42
43 const std::string StringFormat(const char * const formater, ...);
44
45 bool RunPipeComand(const char *cmdString, char *outBuf, uint16_t sizeOutBuf, bool ignoreTailLf);
46 }
47 #endif