# syntax:
#
# user_agent $variable_name {
#     default         value;
#     greedy        name;
#
#     name [([+|-]version) | (version1~version2)]  value;
# }

user_agent $browser {

    # default
    default                                             unknown;

    # greedy
    greedy                                              Chrome;
    greedy                                              Safari;
    greedy                                              Firefox;

    # name                   version                     value

    # match version greater than 18.0[18.0,+OO]
    Chrome                  18.0+                       chrome18;
    # match version in[16.0,16.9999]
    Chrome                  17.0~17.9999                chrome17;
    Chrome                  16.0~16.9999                chrome16;
    Chrome                  15.0~15.9999                chrome15;
    Chrome                  14.0~14.9999                chrome14;
    Chrome                  13.0~13.9999                chrome13;
    Chrome                  12.0~12.9999                chrome12;
    Chrome                  11.0~11.9999                chrome11;
    Chrome                  10.0~10.9999                chrome10;
    Chrome                  0~0.9999                    chrome_low;

    # match version 4.0 exactly
    ChromePlus              4.0                         chromeplus4;
    ChromePlus              0~3.9999                    chromeplus;

    Firebird                3.0~3.9999                  firebird3;
    Firebird                0.7~0.7.9999                firebird07;
    Firebird                0.6~0.6.9999                firebird06;

    Firefox                 9.0~9.9999                  firefox9;
    Firefox                 7.0~7.9999                  firefox7;
    Firefox                 8.0~8.9999                  firefox8;
    Firefox                 6.0~6.9999                  firefox6;
    Firefox                 5.0~5.9999                  firefox5;
    Firefox                 4.0~4.9999                  firefox4;
    Firefox                 0~3.9999                    firefox_low;

    MSIE                    10.0~10.9999                msie10;
    MSIE                    9.0~9.9999                  msie9;
    MSIE                    8.0~8.9999                  msie8;
    MSIE                    7.0~7.9999                  msie7;
    MSIE                    6.0~6.9999                  msie6;
    # match version less than 5.9999[-OO,5.9999]
    MSIE                    5.9999-                     msie_low;

    Maxthon                 3.0~3.9999                  maxthon3;
    Maxthon                 2.9999-                     maxthon_low;

    Safari                  419.9999-                   safari_low;
    Safari                  522.0~525.29.9999           safari3;
    Safari                  526.8~526.11.999            safari_dp1;
    Safari                  530.18.0~533.15.999         safari4;
    Safari                  533.16.0~533.17.999         safari501;
    Safari                  533.18.0~533.18.6           safari502;
    Safari                  6533.18.0~6533.18.5.99      safari502;
    Safari                  533.19.4~533.19.9           safari503;
    Safari                  533.20.0~533.20.27          safari504;
    Safari                  533.21~533.22               safari505;
    Safari                  7534.48~7534.48.9          safari51;
    Safari                  534.53~534.57               safari51;
    Safari                  8536.25~8536.9999           safari6;

    # match all versions
    Opera                                               opera;

    # mobile browsers
    BlackBerry                                          blackberry;

    Blazer                                              blazer;

    'Maemo Browser'                                     maemobrowser;

    'Opera Mini'                                        operamini;
    'Opera Mobile'                                      operamobile;

    Skyfire                                             skyfire;

    UCWEB                                               UCWEB;
}

user_agent $os {
    default                                             unknown;

    iPad                                                ipad;
    iPhone                                              iphone;
    Symbian                                             symbian;
    MeeGo                                               meego;
    'Windows Phone'                                     windowsphone;
    Android                                             android;
    BlackBerry                                          blackberry;
    MIUI                                                miui;
    'Windows NT'            5.1                         windowsxp;
    'Windows NT'            6.1                         windows7;
    'Windows NT'            6.0                         windowsvista;
    linux                                               linux;
    unix                                                unix;
    FreeBSD                                             freebsd;
    Macintosh                                           macos;
}
