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

Generated on Mon Nov 29 2010 05:18:45 for rpm by  doxygen 1.7.2