• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HDI_SAMPLE_C_INF_H
17 #define HDI_SAMPLE_C_INF_H
18 
19 struct HdfSBuf;
20 struct HdfDeviceObject;
21 struct HdfDeviceIoClient;
22 
23 struct StructSample {
24     int8_t first;
25     int16_t second;
26 };
27 
28 enum EnumSample {
29     MEM_FIRST,
30     MEM_SECOND,
31     MEM_THIRD,
32 };
33 
34 enum {
35     CMD_BOOLEAN_TYPE_TEST,
36     CMD_BYTE_TYPE_TEST,
37     CMD_SHORT_TYPE_TEST,
38     CMD_INT_TYPE_TEST,
39     CMD_LONG_TYPE_TEST,
40     CMD_FLOAT_TYPE_TEST,
41     CMD_DOUBLE_TYPE_TEST,
42     CMD_STRING_TYPE_TEST,
43     CMD_UCHAR_TYPE_TEST,
44     CMD_USHORT_TYPE_TEST,
45     CMD_UINT_TYPE_TEST,
46     CMD_ULONG_TYPE_TEST,
47     CMD_LIST_TYPE_TEST,
48     CMD_ARRAY_TYPE_TEST,
49     CMD_STRUCT_TYPE_TEST,
50     CMD_ENUM_TYPE_TEST,
51 };
52 
53 struct ISample {
54     int32_t (*BooleanTypeTest)(struct HdfDeviceObject *device, const bool input, bool *output);
55 
56     int32_t (*ByteTypeTest)(struct HdfDeviceObject *device, const int8_t input, int8_t *output);
57 
58     int32_t (*ShortTypeTest)(struct HdfDeviceObject *device, const int16_t input, int16_t *output);
59 
60     int32_t (*IntTypeTest)(struct HdfDeviceObject *device, const int32_t input, int32_t *output);
61 
62     int32_t (*LongTypeTest)(struct HdfDeviceObject *device, const int64_t input, int64_t *output);
63 
64     int32_t (*FloatTypeTest)(struct HdfDeviceObject *device, const float input, float *output);
65 
66     int32_t (*DoubleTypeTest)(struct HdfDeviceObject *device, const double input, double *output);
67 
68     int32_t (*StringTypeTest)(struct HdfDeviceObject *device, const char *input, char **output);
69 
70     int32_t (*UcharTypeTest)(struct HdfDeviceObject *device, const uint8_t input, uint8_t *output);
71 
72     int32_t (*UshortTypeTest)(struct HdfDeviceObject *device, const uint16_t input, uint16_t *output);
73 
74     int32_t (*UintTypeTest)(struct HdfDeviceObject *device, const uint32_t input, uint32_t *output);
75 
76     int32_t (*UlongTypeTest)(struct HdfDeviceObject *device, const uint64_t input, uint64_t *output);
77 
78     int32_t (*ListTypeTest)(struct HdfDeviceObject *device, const int8_t *input, const uint32_t inSize,
79         int8_t **output, uint32_t *outSize);
80 
81     int32_t (*ArrayTypeTest)(struct HdfDeviceObject *device, const int8_t *input, const uint32_t inSize,
82         int8_t **output, uint32_t *outSize);
83 
84     int32_t (*StructTypeTest)(struct HdfDeviceObject *device, const struct StructSample *input,
85         struct StructSample *output);
86 
87     int32_t (*EnumTypeTest)(struct HdfDeviceObject *device, const enum EnumSample input, enum EnumSample *output);
88 };
89 
90 const struct ISample *HdiSampleImplInstance();
91 
92 int32_t SampleServiceOnRemoteRequest(struct HdfDeviceIoClient *client, int cmdId,
93     struct HdfSBuf *data, struct HdfSBuf *reply);
94 
95 #endif // HDI_SAMPLE_C_INF_H