rpm: added individual override variables for opensync building
[barry/progweb.git] / src / cod.h
blob498830454ec6f7606dc1cfdfb5d7056f93aaa348
1 ///
2 /// \file cod.h
3 /// COD file API
4 ///
6 /*
7 Copyright (C) 2009-2011, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_COD_H__
23 #define __BARRY_COD_H__
25 #include "dll.h"
26 #include "data.h"
27 #include <sys/types.h>
28 #include <stdint.h>
29 #include <iostream>
30 #include <sstream>
32 namespace Barry {
36 // SeekNextCod
38 /// Seeks the input stream to the next packed sibling .cod file and returns
39 /// the packed .cod file size. When all siblings have been read, zero is
40 /// returned.
41 ///
42 /// When input stream does not contain the signature for a packed .cod file,
43 /// it's assumed the entire stream is the .cod file.
44 ///
45 /// \param input stream to read from
46 ///
47 /// \return size of next packed .cod file, or 0 finished reading .cod files
48 ///
49 size_t SeekNextCod(std::istream &input);
52 ///
53 /// The CodFileBuilder class is used to assemble multiple .cod files into
54 /// a single packed .cod file using the pkzip file format.
55 ///
56 class BXEXPORT CodFileBuilder
58 std::string m_module_name;
60 size_t m_module_count;
61 unsigned int m_current_module;
63 std::ostringstream m_directory;
65 public:
66 CodFileBuilder(const std::string &module_name, size_t module_count = 1);
68 ~CodFileBuilder();
70 ///
71 /// Writes packed .cod file header to the output stream, and appends
72 /// an entry to the central directory. If the module count used to
73 /// create CodFileBuilder is equal to one, the call is ignored.
74 ///
75 /// Note: it is the caller's responsibility to write the actual
76 /// COD file data after calling this function.
77 ///
78 /// \param output stream to write to
79 ///
80 /// \param buffer buffered .cod file data, input to CRC-32 function
81 ///
82 /// \param module_size total size of .cod file data
83 ///
84 void WriteNextHeader(std::ostream &output, const uint8_t* buffer,
85 uint32_t module_size);
87 ///
88 /// Write the central directory and central directory ending indicator
89 /// to the output stream.
90 ///
91 /// \param output stream to write to
92 ///
93 void WriteFooter(std::ostream &output);
98 #endif