summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/untar/untar.h
diff options
context:
space:
mode:
authorAlexander Krutwig <alexander.krutwig@embedded-brains.de>2016-07-13 09:22:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-07-26 10:00:04 +0200
commit1a8fe67acf5903caacc6da2854a074ed0c4b2743 (patch)
treef7f781ee2f2e847f7f5ea12e386ef27d3be09aef /cpukit/libmisc/untar/untar.h
parentsptests/spextensions01: Avoid NULL pointer access (diff)
downloadrtems-1a8fe67acf5903caacc6da2854a074ed0c4b2743.tar.bz2
Add Untar_FromChunk_Print() + Test
Diffstat (limited to '')
-rw-r--r--cpukit/libmisc/untar/untar.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/cpukit/libmisc/untar/untar.h b/cpukit/libmisc/untar/untar.h
index d67c29e7f4..006f06d065 100644
--- a/cpukit/libmisc/untar/untar.h
+++ b/cpukit/libmisc/untar/untar.h
@@ -44,6 +44,99 @@ int Untar_FromMemory_Print(void *tar_buf, size_t size, const rtems_printer* prin
int Untar_FromFile(const char *tar_name);
int Untar_FromFile_Print(const char *tar_name, const rtems_printer* printer);
+typedef struct {
+ /**
+ * @brief Current context state.
+ */
+ enum {
+ UNTAR_CHUNK_HEADER,
+ UNTAR_CHUNK_SKIP,
+ UNTAR_CHUNK_WRITE,
+ UNTAR_CHUNK_ERROR
+ } state;
+
+ /**
+ * @brief Header buffer.
+ */
+ char header[512];
+
+ /**
+ * @brief Name buffer.
+ */
+ char fname[100];
+
+ /**
+ * @brief Number of bytes of overall length are already processed.
+ */
+ size_t done_bytes;
+
+ /**
+ * @brief Overall amount of bytes to be processed.
+ */
+ long unsigned todo_bytes;
+
+ /**
+ * @brief Overall amount of blocks to be processed.
+ */
+ unsigned long todo_blocks;
+
+ /**
+ * @brief File descriptor of output file.
+ */
+ int out_fd;
+} Untar_ChunkContext;
+
+typedef struct {
+ /**
+ * @brief Instance of Chunk Context needed for tar decompression.
+ */
+ Untar_ChunkContext base;
+
+ /**
+ * @brief Current zlib context.
+ */
+ z_stream strm;
+
+ /**
+ * @brief Buffer that contains the inflated data.
+ */
+ void *inflateBuffer;
+
+ /**
+ * @brief Size of buffer that contains the inflated data.
+ */
+ size_t inflateBufferSize;
+
+} Untar_GzChunkContext;
+
+/**
+ * @brief Initializes the Untar_ChunkContext files out of a part of a block of
+ * memory.
+ *
+ * @param Untar_ChunkContext *context [in] Pointer to a context structure.
+ */
+void Untar_ChunkContext_Init(Untar_ChunkContext *context);
+
+/*
+ * @brief Rips links, directories and files out of a part of a block of memory.
+ *
+ * @param Untar_ChunkContext *context [in] Pointer to a context structure.
+ * @param void *chunk [in] Pointer to a chunk of a TAR buffer.
+ * @param size_t chunk_size [in] Length of the chunk of a TAR buffer.
+ *
+ * @retval UNTAR_SUCCESSFUL (0) on successful completion.
+ * @retval UNTAR_FAIL for a faulty step within the process.
+ * @retval UNTAR_INVALID_CHECKSUM for an invalid header checksum.
+ * @retval UNTAR_INVALID_HEADER for an invalid header.
+ */
+
+int Untar_FromChunk_Print(
+ Untar_ChunkContext *context,
+ void *chunk,
+ size_t chunk_size,
+ const rtems_printer* printer
+);
+
/**************************************************************************
* This converts octal ASCII number representations into an
* unsigned long. Only support 32-bit numbers for now.