• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

lib/rpmversion.h

Go to the documentation of this file.
00001 #ifndef __RPMVERSION_H__
00002 #define __RPMVERSION_H__
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 /*@unchecked@*/ /*@observer@*/
00009 extern const char * RPMVERSION;
00010 
00011 /*@unchecked@*/ /*@observer@*/
00012 extern const char * rpmNAME;
00013 
00014 /*@unchecked@*/ /*@observer@*/
00015 extern const char * rpmEVR;
00016 
00017 /*@unchecked@*/
00018 extern int rpmFLAGS;
00019 
00020 /*
00021    VERSION <M,N,t,O,R,s>
00022    ---------------------
00023 
00024     3         2         1         0
00025    10987654321098765432109876543210
00026    |   ||     || ||      ||      ||
00027    | M ||   N ||t||  O   ||   R  |s
00028 
00029    M: bits 31-27 (5 bit): [0... 32[    [0..31]      major version  (architecture  generation counter)
00030    N: bits 26-21 (6 bit): [0... 64[    [0..63]      minor version  (functionality generation counter)
00031    t: bits 20-18 (3 bit): {_,a,b,c,r}  {_,a,b,c,r}  release type
00032    O: bits 17-10 (8 bit): [0...256[    [0..255]     major revision (maintenance   generation counter)
00033    R: bits 09-01 (9 bit): [0...512[    [0..511]     minor revision (hotfix        generation counter)
00034    s: bits 00-00 (1 bit): {_,s}        {_,s}        is snapshot?
00035 
00036    TIMESTAMP <Y,M,D,h,m>
00037    ---------------------
00038 
00039     3         2         1         0
00040    10987654321098765432109876543210
00041    |          ||  ||   ||   ||    |
00042    |    Y     ||M || D || h || m  |
00043 
00044    Y: bits 30-20 (12 bit): [0...4096[  [0...4095]   year
00045    M: bits 19-16 ( 4 bit): [0...16[    [1..12]      month
00046    D: bits 15-11 ( 5 bit): [0...32[    [1..31]      day
00047    h: bits 10-06 ( 5 bit): [0...32[    [00..23]     hour   (UTC +0000)
00048    m: bits 05-00 ( 6 bit): [0...64[    [00..61]     minute (UTC +0000)
00049 
00050    EXAMPLES
00051    --------
00052 
00053    version                        encoding
00054    5.6.DEV                        RPMLIB_VERSION_ENCODE(5,6,_,0,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,HH,MM)
00055    5.6.SNAP.YYYYMMDD              RPMLIB_VERSION_ENCODE(5,6,_,0,0,s) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
00056    5.6a7                          RPMLIB_VERSION_ENCODE(5,6,a,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
00057    5.6b7                          RPMLIB_VERSION_ENCODE(5,6,b,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
00058    5.6rc7                         RPMLIB_VERSION_ENCODE(5,6,b,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
00059    5.6.7                          RPMLIB_VERSION_ENCODE(5,6,r,7,0,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
00060    5.6.7.8                        RPMLIB_VERSION_ENCODE(5,6,r,7,8,_) RPMLIB_TIMESTAMP_ENCODE(YYYY,MM,DD,00,00)
00061 
00062    USAGE
00063    -----
00064 
00065    #include <rpmversion.h>
00066    #if defined(RPMLIB_VERSION) && RPMLIB_VENDOR_EQ('R','P','M','5') && \
00067        RPMLIB_VERSION_GE(5,0,a,1,0,_) && RPMLIB_TIMESTAMP_GT(2007,11,13,00,00)
00068    [...]
00069    #endif
00070 */
00071 
00072 /* link-time information */
00073 extern uint32_t rpmlibVersion(void)
00074         /*@*/;
00075 extern uint32_t rpmlibTimestamp(void)
00076         /*@*/;
00077 extern uint32_t rpmlibVendor(void)
00078         /*@*/;
00079 
00080 /* compile-time information */
00081 #define RPMLIB_VERSION   RPMLIB_VERSION_ENCODE(5,2,r,1,0,_)
00082 #define RPMLIB_TIMESTAMP RPMLIB_TIMESTAMP_ENCODE(2009,0,0,0,0)
00083 #define RPMLIB_VENDOR    RPMLIB_VENDOR_ENCODE('R','P','M','5')
00084 
00085 /* RPM release version encoding */
00086 #define RPMLIB_VERSION_ENCODE(major,minor,type,micro,revision,snap) \
00087     ( RPMLIB_BITFIELD_SET(31,27,(major)) \
00088     | RPMLIB_BITFIELD_SET(26,21,(minor)) \
00089     | RPMLIB_BITFIELD_SET(20,18,RPMLIB_VERSION_ENCODE_T(type)) \
00090     | RPMLIB_BITFIELD_SET(17,10,(micro)) \
00091     | RPMLIB_BITFIELD_SET(9,1,(revision)) \
00092     | RPMLIB_BITFIELD_SET(0,0,RPMLIB_VERSION_ENCODE_S(snap)))
00093 #define RPMLIB_VERSION_ENCODE_T(type) RPMLIB_VERSION_ENCODE_T_##type
00094 #define RPMLIB_VERSION_ENCODE_T__     0
00095 #define RPMLIB_VERSION_ENCODE_T_a     1
00096 #define RPMLIB_VERSION_ENCODE_T_b     2
00097 #define RPMLIB_VERSION_ENCODE_T_c     3
00098 #define RPMLIB_VERSION_ENCODE_T_r     4
00099 #define RPMLIB_VERSION_ENCODE_S(snap) RPMLIB_VERSION_ENCODE_S_##snap
00100 #define RPMLIB_VERSION_ENCODE_S__     0
00101 #define RPMLIB_VERSION_ENCODE_S_s     1
00102 
00103 /* RPM release timestamp encoding */
00104 #define RPMLIB_TIMESTAMP_ENCODE(year,month,date,hour,minute) \
00105     ( RPMLIB_BITFIELD_SET(31,20,(year)) \
00106     | RPMLIB_BITFIELD_SET(19,16,(month)) \
00107     | RPMLIB_BITFIELD_SET(15,11,(date)) \
00108     | RPMLIB_BITFIELD_SET(10,6,(hour)) \
00109     | RPMLIB_BITFIELD_SET(5,0,(minute)))
00110 
00111 /* RPM vendor tag encoding */
00112 #define RPMLIB_VENDOR_ENCODE(c1,c2,c3,c4) \
00113     ( RPMLIB_BITFIELD_SET(31,24,(c1)) \
00114     | RPMLIB_BITFIELD_SET(23,16,(c2)) \
00115     | RPMLIB_BITFIELD_SET(15,8,(c3)) \
00116     | RPMLIB_BITFIELD_SET(7,0,(c4)))
00117 
00118 /* RPM release version assertion */
00119 #define RPMLIB_VERSION_LT(major,minor,type,micro,revision,snap) \
00120     (RPMLIB_VERSION <  RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
00121 #define RPMLIB_VERSION_LE(major,minor,type,micro,revision,snap) \
00122     (RPMLIB_VERSION <= RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
00123 #define RPMLIB_VERSION_EQ(major,minor,type,micro,revision,snap) \
00124     (RPMLIB_VERSION == RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
00125 #define RPMLIB_VERSION_GE(major,minor,type,micro,revision,snap) \
00126     (RPMLIB_VERSION >= RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
00127 #define RPMLIB_VERSION_GT(major,minor,type,micro,revision,snap) \
00128     (RPMLIB_VERSION >  RPMLIB_VERSION_ENCODE((major),(minor),(type),(micro),(revision),(snap)))
00129 
00130 /* RPM release timestamp assertion */
00131 #define RPMLIB_TIMESTAMP_LT(year,month,date,hour,minute) \
00132     (RPMLIB_TIMESTAMP <  RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
00133 #define RPMLIB_TIMESTAMP_LE(major,minor,type,micro,revision) \
00134     (RPMLIB_TIMESTAMP <= RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
00135 #define RPMLIB_TIMESTAMP_EQ(major,minor,type,micro,revision) \
00136     (RPMLIB_TIMESTAMP == RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
00137 #define RPMLIB_TIMESTAMP_GE(major,minor,type,micro,revision) \
00138     (RPMLIB_TIMESTAMP >= RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
00139 #define RPMLIB_TIMESTAMP_GT(major,minor,type,micro,revision) \
00140     (RPMLIB_TIMESTAMP >  RPMLIB_TIMESTAMP_ENCODE((year),(month),(date),(hour),(minute)))
00141 
00142 /* RPM vendor tag assertion */
00143 #define RPMLIB_VENDOR_EQ(c1,c2,c3,c4) \
00144     (RPMLIB_VENDOR == RPMLIB_VENDOR_ENCODE((c1),(c2),(c3),(c4)))
00145 
00146 /* encode numer "n" into the bits "l" (msb) to "r" (lsb) */
00147 #define RPMLIB_BITFIELD_SET(l,r,n) \
00148     (((n) & ((1<<(((l)-(r))+1))-1) ) << (r))
00149 
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153 
00154 #endif /* __RPMVERSION_H__ */

Generated on Fri Dec 3 2010 20:53:47 for rpm by  doxygen 1.7.2