rpm  5.4.10
rpmversion.h
Go to the documentation of this file.
1 #ifndef __RPMVERSION_H__
2 #define __RPMVERSION_H__
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 /*@unchecked@*/ /*@observer@*/
9 extern const char * RPMVERSION;
10 
11 /*@unchecked@*/ /*@observer@*/
12 extern const char * rpmNAME;
13 
14 /*@unchecked@*/ /*@observer@*/
15 extern const char * rpmEVR;
16 
17 /*@unchecked@*/
18 extern int rpmFLAGS;
19 
20 /*
21  VERSION <M,N,t,O,R,s>
22  ---------------------
23 
24  3 2 1 0
25  10987654321098765432109876543210
26  | || || || || ||
27  | M || N ||t|| O || R |s
28 
29  M: bits 31-27 (5 bit): [0... 32[ [0..31] major version (architecture generation counter)
30  N: bits 26-21 (6 bit): [0... 64[ [0..63] minor version (functionality generation counter)
31  t: bits 20-18 (3 bit): {_,a,b,c,r} {_,a,b,c,r} release type
32  O: bits 17-10 (8 bit): [0...256[ [0..255] major revision (maintenance generation counter)
33  R: bits 09-01 (9 bit): [0...512[ [0..511] minor revision (hotfix generation counter)
34  s: bits 00-00 (1 bit): {_,s} {_,s} is snapshot?
35 
36  TIMESTAMP <Y,M,D,h,m>
37  ---------------------
38 
39  3 2 1 0
40  10987654321098765432109876543210
41  | || || || || |
42  | Y ||M || D || h || m |
43 
44  Y: bits 30-20 (12 bit): [0...4096[ [0...4095] year
45  M: bits 19-16 ( 4 bit): [0...16[ [1..12] month
46  D: bits 15-11 ( 5 bit): [0...32[ [1..31] day
47  h: bits 10-06 ( 5 bit): [0...32[ [00..23] hour (UTC +0000)
48  m: bits 05-00 ( 6 bit): [0...64[ [00..61] minute (UTC +0000)
49 
50  EXAMPLES
51  --------
52 
53  version encoding
54  5.6.DEV RPMLIB_VERSION_ENCODE(5,6,_,0,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,HH,MM)
55  5.6.SNAP.YYYYMMDD RPMLIB_VERSION_ENCODE(5,6,_,0,0,s) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
56  5.6a7 RPMLIB_VERSION_ENCODE(5,6,a,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
57  5.6b7 RPMLIB_VERSION_ENCODE(5,6,b,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
58  5.6rc7 RPMLIB_VERSION_ENCODE(5,6,b,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
59  5.6.7 RPMLIB_VERSION_ENCODE(5,6,r,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
60  5.6.7.8 RPMLIB_VERSION_ENCODE(5,6,r,7,8,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
61 
62  USAGE
63  -----
64 
65  #include <rpmversion.h>
66  #if defined(RPMLIB_VERSION) && RPMLIB_VENDOR_EQ('R','P','M','5') && \
67  RPMLIB_VERSION_GE(5,0,a,1,0,_) && RPMLIB_TIMESTAMP_GT(2007,11,13,00,00)
68  [...]
69  #endif
70 */
71 
72 /* link-time information */
73 extern uint32_t rpmlibVersion(void)
74  /*@*/;
75 extern uint32_t rpmlibTimestamp(void)
76  /*@*/;
77 extern uint32_t rpmlibVendor(void)
78  /*@*/;
79 
80 /* compile-time information */
81 #define RPMLIB_VERSION RPMLIB_VERSION_ENCODE(5,4,r,10,0,_)
82 #define RPMLIB_TIMESTAMP RPMLIB_TIMESTAMP_ENCODE(2012,7,6,0,0)
83 #define RPMLIB_VENDOR RPMLIB_VENDOR_ENCODE('R','P','M','5')
84 
85 /* RPM release version encoding */
86 #define RPMLIB_VERSION_ENCODE(major,minor,type,micro,revision,snap) \
87  ( RPMLIB_BITFIELD_SET(31,27,(major)) \
88  | RPMLIB_BITFIELD_SET(26,21,(minor)) \
89  | RPMLIB_BITFIELD_SET(20,18,RPMLIB_VERSION_ENCODE_T(type)) \
90  | RPMLIB_BITFIELD_SET(17,10,(micro)) \
91  | RPMLIB_BITFIELD_SET(9,1,(revision)) \
92  | RPMLIB_BITFIELD_SET(0,0,RPMLIB_VERSION_ENCODE_S(snap)))
93 #define RPMLIB_VERSION_ENCODE_T(type) RPMLIB_VERSION_ENCODE_T_##type
94 #define RPMLIB_VERSION_ENCODE_T__ 0
95 #define RPMLIB_VERSION_ENCODE_T_a 1
96 #define RPMLIB_VERSION_ENCODE_T_b 2
97 #define RPMLIB_VERSION_ENCODE_T_c 3
98 #define RPMLIB_VERSION_ENCODE_T_r 4
99 #define RPMLIB_VERSION_ENCODE_S(snap) RPMLIB_VERSION_ENCODE_S_##snap
100 #define RPMLIB_VERSION_ENCODE_S__ 0
101 #define RPMLIB_VERSION_ENCODE_S_s 1
102 
103 /* RPM release timestamp encoding */
104 #define RPMLIB_TIMESTAMP_ENCODE(year,month,date,hour,minute) \
105  ( RPMLIB_BITFIELD_SET(31,20,(year)) \
106  | RPMLIB_BITFIELD_SET(19,16,(month)) \
107  | RPMLIB_BITFIELD_SET(15,11,(date)) \
108  | RPMLIB_BITFIELD_SET(10,6,(hour)) \
109  | RPMLIB_BITFIELD_SET(5,0,(minute)))
110 
111 /* RPM vendor tag encoding */
112 #define RPMLIB_VENDOR_ENCODE(c1,c2,c3,c4) \
113  ( RPMLIB_BITFIELD_SET(31,24,(c1)) \
114  | RPMLIB_BITFIELD_SET(23,16,(c2)) \
115  | RPMLIB_BITFIELD_SET(15,8,(c3)) \
116  | RPMLIB_BITFIELD_SET(7,0,(c4)))
117 
118 /* RPM release version assertion */
119 #define RPMLIB_VERSION_LT(major,minor,type,micro,revision,snap) \
120  (RPMLIB_VERSION < RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
121 #define RPMLIB_VERSION_LE(major,minor,type,micro,revision,snap) \
122  (RPMLIB_VERSION <= RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
123 #define RPMLIB_VERSION_EQ(major,minor,type,micro,revision,snap) \
124  (RPMLIB_VERSION == RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
125 #define RPMLIB_VERSION_GE(major,minor,type,micro,revision,snap) \
126  (RPMLIB_VERSION >= RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
127 #define RPMLIB_VERSION_GT(major,minor,type,micro,revision,snap) \
128  (RPMLIB_VERSION > RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
129 
130 /* RPM release timestamp assertion */
131 #define RPMLIB_TIMESTAMP_LT(year,month,date,hour,minute) \
132  (RPMLIB_TIMESTAMP < RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
133 #define RPMLIB_TIMESTAMP_LE(major,minor,type,micro,revision) \
134  (RPMLIB_TIMESTAMP <= RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
135 #define RPMLIB_TIMESTAMP_EQ(major,minor,type,micro,revision) \
136  (RPMLIB_TIMESTAMP == RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
137 #define RPMLIB_TIMESTAMP_GE(major,minor,type,micro,revision) \
138  (RPMLIB_TIMESTAMP >= RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
139 #define RPMLIB_TIMESTAMP_GT(major,minor,type,micro,revision) \
140  (RPMLIB_TIMESTAMP > RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
141 
142 /* RPM vendor tag assertion */
143 #define RPMLIB_VENDOR_EQ(c1,c2,c3,c4) \
144  (RPMLIB_VENDOR == RPMLIB_VENDOR_ENCODE((c1),(c2),(c3),(c4)))
145 
146 /* encode numer "n" into the bits "l" (msb) to "r" (lsb) */
147 #define RPMLIB_BITFIELD_SET(l,r,n) \
148  (((n) & ((1<<(((l)-(r))+1))-1) ) << (r))
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif /* __RPMVERSION_H__ */