OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A very simple driver program while sanitises the file given as argv[1] and | 5 // A very simple driver program while sanitises the file given as argv[1] and |
6 // writes the sanitised version to stdout. | 6 // writes the sanitised version to stdout. |
7 | 7 |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #if defined(_WIN32) | 10 #if defined(_WIN32) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 std::fprintf(stderr, "ERROR: "); | 42 std::fprintf(stderr, "ERROR: "); |
43 else | 43 else |
44 std::fprintf(stderr, "WARNING: "); | 44 std::fprintf(stderr, "WARNING: "); |
45 va_start(va, format); | 45 va_start(va, format); |
46 std::vfprintf(stderr, format, va); | 46 std::vfprintf(stderr, format, va); |
47 std::fprintf(stderr, "\n"); | 47 std::fprintf(stderr, "\n"); |
48 va_end(va); | 48 va_end(va); |
49 } | 49 } |
50 | 50 |
51 virtual ots::TableAction GetTableAction(uint32_t tag) { | 51 virtual ots::TableAction GetTableAction(uint32_t tag) { |
52 #define TAG(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) | |
53 switch (tag) { | 52 switch (tag) { |
54 case TAG('S','i','l','f'): | 53 case OTS_TAG('S','i','l','f'): |
55 case TAG('S','i','l','l'): | 54 case OTS_TAG('S','i','l','l'): |
56 case TAG('G','l','o','c'): | 55 case OTS_TAG('G','l','o','c'): |
57 case TAG('G','l','a','t'): | 56 case OTS_TAG('G','l','a','t'): |
58 case TAG('F','e','a','t'): | 57 case OTS_TAG('F','e','a','t'): |
| 58 case OTS_TAG('C','B','D','T'): |
| 59 case OTS_TAG('C','B','L','C'): |
59 return ots::TABLE_ACTION_PASSTHRU; | 60 return ots::TABLE_ACTION_PASSTHRU; |
60 default: | 61 default: |
61 return ots::TABLE_ACTION_DEFAULT; | 62 return ots::TABLE_ACTION_DEFAULT; |
62 } | 63 } |
63 #undef TAG | |
64 } | 64 } |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 int main(int argc, char **argv) { | 69 int main(int argc, char **argv) { |
70 if (argc < 2 || argc > 3) return Usage(argv[0]); | 70 if (argc < 2 || argc > 3) return Usage(argv[0]); |
71 | 71 |
72 const int fd = ::open(argv[1], O_RDONLY | ADDITIONAL_OPEN_FLAGS); | 72 const int fd = ::open(argv[1], O_RDONLY | ADDITIONAL_OPEN_FLAGS); |
73 if (fd < 0) { | 73 if (fd < 0) { |
(...skipping 18 matching lines...) Expand all Loading... |
92 out = fopen(argv[2], "wb"); | 92 out = fopen(argv[2], "wb"); |
93 | 93 |
94 ots::FILEStream output(out); | 94 ots::FILEStream output(out); |
95 const bool result = context.Process(&output, data, st.st_size); | 95 const bool result = context.Process(&output, data, st.st_size); |
96 | 96 |
97 if (!result) { | 97 if (!result) { |
98 std::fprintf(stderr, "Failed to sanitise file!\n"); | 98 std::fprintf(stderr, "Failed to sanitise file!\n"); |
99 } | 99 } |
100 return !result; | 100 return !result; |
101 } | 101 } |
OLD | NEW |