cpio_parser.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Copyright (C) 2019 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef __CPIO_PARSER_H_
  13. #define __CPIO_PARSER_H_
  14. #include "osi_compiler.h"
  15. #include <stdint.h>
  16. OSI_EXTERN_C_BEGIN
  17. typedef struct cpio_stream cpioStream_t;
  18. /**
  19. * \brief Cpio file struct
  20. */
  21. typedef struct
  22. {
  23. char *name;
  24. uint8_t *data;
  25. uint32_t data_size;
  26. uint16_t mode;
  27. } cpioFile_t;
  28. /**
  29. * \brief Cpio stream configure
  30. */
  31. typedef struct
  32. {
  33. uint32_t file_size_max;
  34. uint32_t file_path_max;
  35. } cpioStreamCfg_t;
  36. /**
  37. * \brief Create a cpio stream
  38. *
  39. * \param cfg stream configure
  40. * \return cpio stream or NULL
  41. */
  42. cpioStream_t *cpioStreamCreate(const cpioStreamCfg_t *cfg);
  43. /**
  44. * \brief Destroy the cpio stream
  45. * \param stream the stream
  46. */
  47. void cpioStreamDestroy(cpioStream_t *stream);
  48. /**
  49. * \brief Push data to the stream
  50. * \param stream the stream
  51. * \param data the data
  52. * \param len the data length
  53. */
  54. void cpioStreamPushData(cpioStream_t *stream, void *data, uint32_t len);
  55. /**
  56. * \brief Check the number of unused files in current stream
  57. * \param stream the stream
  58. * \return the number of files
  59. */
  60. uint32_t cpioStreamGetFileCount(cpioStream_t *stream);
  61. /**
  62. * \brief Pop a file from the stream
  63. * \param stream the stream
  64. * \return one cpio file (and file count -1)
  65. */
  66. cpioFile_t *cpioStreamPopFile(cpioStream_t *stream);
  67. /**
  68. * \brief Destroy a cpio file from stream
  69. * \param stream the stream
  70. * \param file the cpio file
  71. */
  72. void cpioStreamDestroyFile(cpioStream_t *stream, cpioFile_t *file);
  73. OSI_EXTERN_C_END
  74. #endif