common_bundle.h

Go to the documentation of this file.
00001 #ifndef COMMON_BUNDLER_DEFS
00002 #define COMMON_BUNDLER_DEFS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : common bundler definitions                                        *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2007-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00019 
00024 #include <basis/astring.h>
00025 #include <basis/contracts.h>
00026 #include <filesystem/byte_filer.h>
00027 #include <structures/set.h>
00028 
00030 
00032 enum special_bundling_flags {
00033   SOURCE_EXECUTE = 0x2,  
00034   TARGET_EXECUTE = 0x4,  
00035   RECURSIVE_SRC = 0x8,  
00036   OMIT_PACKING = 0x10,  
00037   SET_VARIABLE = 0x20,  
00038   IGNORE_ERRORS = 0x40,  
00039   NO_OVERWRITE = 0x80,  
00040   QUIET_FAILURE = 0x100,  
00041   MAKE_BACKUP_FILE = 0x200,  
00042   TEST_VARIABLE_DEFINED = 0x400  
00043 };
00044 
00046 
00048 
00053 struct manifest_chunk : public basis::text_formable
00054 {
00055   basis::un_int _size;  
00056   basis::astring _payload;  
00057   basis::un_int _flags;  
00058   basis::astring _parms;  
00059   structures::string_set _keywords;  
00060   basis::byte_array c_filetime;  
00061 
00062   // note: when flags has SET_VARIABLE, the _payload is the variable
00063   // name to be set and the _parms is the value to use.
00064 
00065   static int packed_filetime_size();
00066 
00068   manifest_chunk(int size, const basis::astring &target, int flags,
00069       const basis::astring &parms, const structures::string_set &keywords)
00070       : _size(size), _payload(target), _flags(flags), _parms(parms),
00071         _keywords(keywords), c_filetime(packed_filetime_size()) {
00072     for (int i = 0; i < packed_filetime_size(); i++) c_filetime[i] = 0;
00073   }
00074 
00075   manifest_chunk() : _size(0), _flags(0), c_filetime(packed_filetime_size()) {
00077     for (int i = 0; i < packed_filetime_size(); i++) c_filetime[i] = 0;
00078   }
00079 
00080   virtual ~manifest_chunk();
00081 
00082   virtual void text_form(basis::base_string &state_fill) const {
00083     state_fill.assign(basis::astring(class_name())
00084         + basis::a_sprintf(": size=%d payload=%s flags=%x parms=%s",
00085               _size, _payload.s(), _flags, _parms.s()));
00086   }
00087 
00088   DEFINE_CLASS_NAME("manifest_chunk");
00089 
00090   void pack(basis::byte_array &target) const;  
00091   bool unpack(basis::byte_array &source);  
00092 
00093   static bool read_manifest(filesystem::byte_filer &bundle, manifest_chunk &to_fill);
00095 
00097   static basis::astring read_a_string(filesystem::byte_filer &bundle);
00099 
00100   static bool read_an_int(filesystem::byte_filer &bundle, basis::un_int &found);
00102 
00103   static bool read_an_obscured_int(filesystem::byte_filer &bundle, basis::un_int &found);
00105 
00106   static bool read_a_filetime(filesystem::byte_filer &bundle, basis::byte_array &found);
00108 };
00109 
00111 
00112 #endif
00113 
Generated on Sat Jan 28 04:22:01 2012 for hoople2 project by  doxygen 1.6.3