summaryrefslogtreecommitdiff
path: root/utils/zenutils/source/shared/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/zenutils/source/shared/utils.h')
-rw-r--r--[-rwxr-xr-x]utils/zenutils/source/shared/utils.h136
1 files changed, 68 insertions, 68 deletions
diff --git a/utils/zenutils/source/shared/utils.h b/utils/zenutils/source/shared/utils.h
index ca9e291514..694cb9c8b1 100755..100644
--- a/utils/zenutils/source/shared/utils.h
+++ b/utils/zenutils/source/shared/utils.h
@@ -1,68 +1,68 @@
1/* zenutils - Utilities for working with creative firmwares. 1/* zenutils - Utilities for working with creative firmwares.
2 * Copyright 2007 (c) Rasmus Ry <rasmus.ry{at}gmail.com> 2 * Copyright 2007 (c) Rasmus Ry <rasmus.ry{at}gmail.com>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 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 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 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 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 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 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 17 */
18 18
19#ifndef SHARED_UTILS_H_INCLUDED 19#ifndef SHARED_UTILS_H_INCLUDED
20#define SHARED_UTILS_H_INCLUDED 20#define SHARED_UTILS_H_INCLUDED
21 21
22#include <vector> 22#include <vector>
23#include <pelib/PeLib.h> 23#include <pelib/PeLib.h>
24 24
25#ifndef byte 25#ifndef byte
26typedef PeLib::byte byte; 26typedef PeLib::byte byte;
27#endif 27#endif
28#ifndef word 28#ifndef word
29typedef PeLib::word word; 29typedef PeLib::word word;
30#endif 30#endif
31#ifndef dword 31#ifndef dword
32typedef PeLib::dword dword; 32typedef PeLib::dword dword;
33#endif 33#endif
34 34
35namespace shared { 35namespace shared {
36 typedef std::vector<byte> bytes; 36 typedef std::vector<byte> bytes;
37 37
38 inline dword swap(dword val) 38 inline dword swap(dword val)
39 { 39 {
40 return ((val & 0xFF) << 24) 40 return ((val & 0xFF) << 24)
41 | ((val & 0xFF00) << 8) 41 | ((val & 0xFF00) << 8)
42 | ((val & 0xFF0000) >> 8) 42 | ((val & 0xFF0000) >> 8)
43 | ((val & 0xFF000000) >> 24); 43 | ((val & 0xFF000000) >> 24);
44 } 44 }
45 45
46 template <typename _Type> 46 template <typename _Type>
47 inline void reverse(_Type* start, _Type* end) 47 inline void reverse(_Type* start, _Type* end)
48 { 48 {
49 while (start < end) 49 while (start < end)
50 { 50 {
51 *start ^= *end; 51 *start ^= *end;
52 *end ^= *start; 52 *end ^= *start;
53 *start ^= *end; 53 *start ^= *end;
54 start++; 54 start++;
55 end--; 55 end--;
56 } 56 }
57 } 57 }
58 58
59 std::string replace_extension(const std::string& filename, const std::string& extension); 59 std::string replace_extension(const std::string& filename, const std::string& extension);
60 std::string remove_extension(const std::string& filename); 60 std::string remove_extension(const std::string& filename);
61 std::string get_path(const std::string& filename); 61 std::string get_path(const std::string& filename);
62 std::string double_quote(const std::string& str); 62 std::string double_quote(const std::string& str);
63 63
64 bool inflate_to_file(const bytes& buffer, const char* filename); 64 bool inflate_to_file(const bytes& buffer, const char* filename);
65 bool deflate_to_file(const bytes& buffer, const char* filename); 65 bool deflate_to_file(const bytes& buffer, const char* filename);
66}; //namespace shared 66}; //namespace shared
67 67
68#endif //SHARED_UTILS_H_INCLUDED 68#endif //SHARED_UTILS_H_INCLUDED