1 /* zenutils - Utilities for working with creative firmwares.
2 * Copyright 2007 (c) Rasmus Ry <rasmus.ry{at}gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef SHARED_UTILS_H_INCLUDED
20 #define SHARED_UTILS_H_INCLUDED
23 #include <pelib/PeLib.h>
26 typedef PeLib::byte byte
;
29 typedef PeLib::word word
;
32 typedef PeLib::dword dword
;
36 typedef std::vector
<byte
> bytes
;
38 inline dword
swap(dword val
)
40 return ((val
& 0xFF) << 24)
41 | ((val
& 0xFF00) << 8)
42 | ((val
& 0xFF0000) >> 8)
43 | ((val
& 0xFF000000) >> 24);
46 template <typename _Type
>
47 inline void reverse(_Type
* start
, _Type
* end
)
59 std::string
replace_extension(const std::string
& filename
, const std::string
& extension
);
60 std::string
remove_extension(const std::string
& filename
);
61 std::string
get_path(const std::string
& filename
);
62 std::string
double_quote(const std::string
& str
);
64 bool inflate_to_file(const bytes
& buffer
, const char* filename
);
65 bool deflate_to_file(const bytes
& buffer
, const char* filename
);
68 #endif //SHARED_UTILS_H_INCLUDED