Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / third_party / ijar / common.h
blob118041b85296a85fffd37b18e4509513855cc52e
1 // Copyright 2001,2007 Alan Donovan. All rights reserved.
2 //
3 // Author: Alan Donovan <adonovan@google.com>
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // common.h -- common definitions.
20 #ifndef INCLUDED_DEVTOOLS_IJAR_COMMON_H
21 #define INCLUDED_DEVTOOLS_IJAR_COMMON_H
23 #include <stddef.h>
24 #include <stdint.h>
25 #include <string.h>
27 namespace devtools_ijar {
29 typedef unsigned long long u8;
30 typedef uint32_t u4;
31 typedef uint16_t u2;
32 typedef uint8_t u1;
34 // be = big endian, le = little endian
36 inline u1 get_u1(const u1 *&p) {
37 return *p++;
40 inline u2 get_u2be(const u1 *&p) {
41 u4 x = (p[0] << 8) | p[1];
42 p += 2;
43 return x;
46 inline u2 get_u2le(const u1 *&p) {
47 u4 x = (p[1] << 8) | p[0];
48 p += 2;
49 return x;
52 inline u4 get_u4be(const u1 *&p) {
53 u4 x = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
54 p += 4;
55 return x;
58 inline u4 get_u4le(const u1 *&p) {
59 u4 x = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
60 p += 4;
61 return x;
64 inline void put_u1(u1 *&p, u1 x) {
65 *p++ = x;
68 inline void put_u2be(u1 *&p, u2 x) {
69 *p++ = x >> 8;
70 *p++ = x & 0xff;
73 inline void put_u2le(u1 *&p, u2 x) {
74 *p++ = x & 0xff;
75 *p++ = x >> 8;;
78 inline void put_u4be(u1 *&p, u4 x) {
79 *p++ = x >> 24;
80 *p++ = (x >> 16) & 0xff;
81 *p++ = (x >> 8) & 0xff;
82 *p++ = x & 0xff;
85 inline void put_u4le(u1 *&p, u4 x) {
86 *p++ = x & 0xff;
87 *p++ = (x >> 8) & 0xff;
88 *p++ = (x >> 16) & 0xff;
89 *p++ = x >> 24;
92 // Copy n bytes from src to p, and advance p.
93 inline void put_n(u1 *&p, const u1 *src, size_t n) {
94 memcpy(p, src, n);
95 p += n;
98 extern bool verbose;
100 } // namespace devtools_ijar
102 #endif // INCLUDED_DEVTOOLS_IJAR_COMMON_H