11b8d9b87Sopenharmony_ci/*
21b8d9b87Sopenharmony_ci* Copyright (C) 2021 Huawei Device Co., Ltd.
31b8d9b87Sopenharmony_ci* Licensed under the Apache License, Version 2.0 (the "License");
41b8d9b87Sopenharmony_ci* you may not use this file except in compliance with the License.
51b8d9b87Sopenharmony_ci* You may obtain a copy of the License at
61b8d9b87Sopenharmony_ci*
71b8d9b87Sopenharmony_ci*    http://www.apache.org/licenses/LICENSE-2.0
81b8d9b87Sopenharmony_ci*
91b8d9b87Sopenharmony_ci* Unless required by applicable law or agreed to in writing, software
101b8d9b87Sopenharmony_ci* distributed under the License is distributed on an "AS IS" BASIS,
111b8d9b87Sopenharmony_ci* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121b8d9b87Sopenharmony_ci* See the License for the specific language governing permissions and
131b8d9b87Sopenharmony_ci* limitations under the License.
141b8d9b87Sopenharmony_ci*/
151b8d9b87Sopenharmony_ci
161b8d9b87Sopenharmony_ci#ifndef HC_PARCEL_H
171b8d9b87Sopenharmony_ci#define HC_PARCEL_H
181b8d9b87Sopenharmony_ci
191b8d9b87Sopenharmony_ci#include <stdint.h>
201b8d9b87Sopenharmony_ci#include <stdbool.h>
211b8d9b87Sopenharmony_ci#include "memory.h"
221b8d9b87Sopenharmony_ci
231b8d9b87Sopenharmony_ci#ifdef __cplusplus
241b8d9b87Sopenharmony_ciextern "C" {
251b8d9b87Sopenharmony_ci#endif
261b8d9b87Sopenharmony_ci
271b8d9b87Sopenharmony_ci#define PARCEL_DEFAULT_LENGTH 0
281b8d9b87Sopenharmony_ci#define PARCEL_DEFAULT_ALLOC_UNIT 0
291b8d9b87Sopenharmony_ci
301b8d9b87Sopenharmony_ci    typedef struct {
311b8d9b87Sopenharmony_ci        char *data;
321b8d9b87Sopenharmony_ci        unsigned int beginPos;
331b8d9b87Sopenharmony_ci        unsigned int endPos;
341b8d9b87Sopenharmony_ci        unsigned int length;
351b8d9b87Sopenharmony_ci        unsigned int allocUnit;
361b8d9b87Sopenharmony_ci    } HcParcel;
371b8d9b87Sopenharmony_ci
381b8d9b87Sopenharmony_ci    HcParcel CreateParcel(uint32_t size, uint32_t allocUnit);
391b8d9b87Sopenharmony_ci    void DeleteParcel(HcParcel *parcel);
401b8d9b87Sopenharmony_ci    bool ParcelWrite(HcParcel *parcel, const void *src, uint32_t dataSize);
411b8d9b87Sopenharmony_ci    uint32_t GetParcelDataSize(const HcParcel *parcel);
421b8d9b87Sopenharmony_ci    const char *GetParcelData(const HcParcel *parcel);
431b8d9b87Sopenharmony_ci
441b8d9b87Sopenharmony_ci    bool ParcelWriteInt8(HcParcel *parcel, char src);
451b8d9b87Sopenharmony_ci    bool ParcelPopBack(HcParcel *parcel, uint32_t size);
461b8d9b87Sopenharmony_ci
471b8d9b87Sopenharmony_ci#ifdef __cplusplus
481b8d9b87Sopenharmony_ci}
491b8d9b87Sopenharmony_ci#endif
501b8d9b87Sopenharmony_ci#endif
51