47 #define F_ISSET(mask) ((m_Flags & (mask)) == (mask))
50 #define USTR(str) (F_ISSET(fNoCase) ? s_ToLower(str) : (str))
71 }
else if (ncbi_app) {
74 user_agent = getenv(
"HTTP_USER_AGENT");
76 if ( !user_agent.empty() ) {
198 bool current_status,
bool use_patterns,
202 string external_patterns;
213 current_status =
true;
221 current_status =
true;
225 if (!current_status) {
234 current_status =
true;
248 current_status =
true;
253 current_status =
true;
265 current_status =
true;
277 current_status =
true;
295 return current_status;
299 external_patterns = current_status ?
304 external_patterns = current_status ?
309 external_patterns = current_status ?
314 external_patterns = current_status ?
320 return current_status;
325 if ( !external_patterns.empty() ) {
335 if (current_status) {
359 return !current_status;
362 return current_status;
397 if (
flags & need_flag ) {
840 if ( start_pos >=
len ) {
844 if ( token[start_pos] ==
'v' ) {
847 if ( (start_pos >=
len) ||
848 !
isdigit((
unsigned char)token[start_pos]) ) {
858 if ( (pos <
len-1) && (token[pos] ==
'.') ) {
859 minor = atoi(token.c_str() + pos + 1);
861 if ( (pos <
len-1) && (token[pos] ==
'.') ) {
862 patch = atoi(token.c_str() + pos + 1);
865 major = atoi(token.c_str() + start_pos);
867 version->SetVersion(major, minor, patch);
900 string vendor_product;
912 else if ((pos ==
len - 1) &&
919 if (pos_comment !=
NPOS) {
920 vendor_product =
m_UserAgent.substr(pos, pos_comment - pos);
934 search =
USTR(
" Mobile/");
952 pos += search.length();
965 search =
"(compatible;";
968 pos += search.length();
973 while (end <
len && par) {
994 if ( (major < 0) || (major < 5) ) {
1013 search =
USTR(
" Trident/");
1020 pos += search.length();
1034 search =
USTR(
" MSIE ");
1037 pos += search.length();
1074 if ( (major < 1) || (major > 5) ) {
1084 search =
USTR(
" AppleWebKit/");
1087 search =
USTR(
" WebKit/");
1092 pos += search.length();
1099 search =
USTR(
" KHTML/");
1103 pos += search.length();
1106 search =
USTR(
"KHTML,");
1124 search =
USTR(
" Version/");
1125 pos = vendor_product.find(search);
1127 pos += search.length();
1138 }
else if (rev < 124 ) {
1140 }
else if (rev < 312 ) {
1142 }
else if (rev < 412 ) {
1144 }
else if (rev < 420 ) {
1146 }
else if (rev < 525 ) {
1148 }
else if (rev < 528 ) {
1252 if ( pos !=
NPOS ) {
1253 pos +=
key.length();
1264 if ( (pos <
len-1 ) &&
1265 ((token[pos] ==
' ') || (token[pos] ==
'/')) ) {
static CNcbiApplication * Instance(void)
Singleton method.
static const char * str(char *buf, int n)
const CNcbiEnvironment & GetEnvironment(void) const
Get the application's cached environment.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
const CCgiContext & GetContext(void) const
Get current server context. Throw exception if the context is not set.
const CCgiRequest & GetRequest(void) const
static CCgiApplication * Instance(void)
Singleton.
const string & GetProperty(ECgiProp prop) const
Get value of a "standard" property (return empty string if not defined)
EBrowserPlatform m_Platform
Platform type.
void x_Parse(const string &user_agent)
Parse user agent string.
bool x_CheckPattern(int what, bool current_status, bool use_patterns, const string &include_patterns=kEmptyStr, const string &exclude_patterns=kEmptyStr) const
Helper method to check UA-string against external pattern lists.
TUserAgentVersion m_EngineVersion
Browser engine version.
bool IsBrowser(void) const
Check that this is known browser.
bool x_ParseToken(const string &token, int where, EBrowserEngine engine=eEngine_Unknown)
Parse token with browser name and version.
EBrowserEngine GetEngine(void) const
Get browser engine type and name.
EBrowserEngine m_Engine
Browser engine type.
void Reset(const string &user_agent)
Parse new user agent string.
string GetPlatformName(void) const
TFlags m_Flags
Comparison and parsing flags.
EBrowserEngine
Browser engine types.
EBrowser GetBrowser(void) const
Get browser type.
TUserAgentVersion m_MozillaVersion
Browser mozilla version.
bool IsMobileDevice(const string &include_patterns=kEmptyStr, const string &exclude_patterns=kEmptyStr) const
Check that this is a known mobile device.
EBrowserPlatform GetPlatform(void) const
Get platform (OS) type and name.
bool IsPhoneDevice(const string &include_patterns=kEmptyStr, const string &exclude_patterns=kEmptyStr) const
Check that this is a known phone-size device.
EBrowser m_Browser
Browser type.
unsigned int TFlags
Binary OR of "EFlags".
string GetEngineName(void) const
bool IsTabletDevice(const string &include_patterns=kEmptyStr, const string &exclude_patterns=kEmptyStr) const
Check that this is a known tablet device.
TUserAgentVersion m_BrowserVersion
Browser version info.
unsigned int TBotFlags
Binary OR of "EBotFlags".
CCgiUserAgent(TFlags flags=0)
Default constructor.
void x_Init(void)
Init class members.
string m_UserAgent
User-Agent string.
EBrowserPlatform
Platform types.
TDeviceFlags m_DeviceFlags
Device type flags.
string m_BrowserName
Browser name.
bool IsBot(TBotFlags flags=fBotAll, const string &include_patterns=kEmptyStr, const string &exclude_patterns=kEmptyStr) const
Check that this is known search robot/bot.
@ fUseBotPatterns
Use external pattern list from registry/environment to check on bots, off by default.
@ fUseDevicePatterns
Use external pattern lists from registry/environment to check on phone/tablet/mobile device when pars...
@ eEngine_Bot
Search robot/bot/checker/...
@ eEngine_Unknown
Unknown engine.
@ eEngine_KHTML
KHTML-based.
@ eEngine_Gecko
Gecko-based.
@ eEngine_Blink
Google Blink (WebKit/537.36 fork)
@ eEngine_WebKit
Apple WebKit (KHTML fork)
@ eEngine_Edge
Microsoft Edge.
@ eEngine_IE
Microsoft Internet Explorer (Trident and etc)
@ fDevice_Phone
Phone / not known tablet / mobile browser on desktop.
@ fDevice_Tablet
Known tablet.
@ ePlatform_Android
Android.
@ ePlatform_Symbian
SymbianOS.
@ ePlatform_Windows
Microsoft Windows.
@ ePlatform_WindowsCE
Microsoft Windows CE (+ Windows Mobile)
@ ePlatform_MobileDevice
Other mobile devices or services.
@ ePlatform_Unknown
Unknown OS.
@ eMinimo
Minimo (www.mozilla.org/projects/minimo)
@ eEnigmaBrowser
Enigma Browser (www.suttondesigns.com)
@ eSafari
Safari (www.apple.com/safari)
@ eChrome
Google Chrome (www.google.com/chrome)
@ eUnknown
Unknown user agent.
@ eQtWeb
QtWeb (www.qtweb.net)
@ eKonqueror
Konqueror (www.konqueror.org) (KHTML based since v3.2 ?)
@ eMadfox
Madfox (www.splyb.com/madfox)
@ ePolaris
Polaris Browser (www.infraware.co.kr)
@ eIceweasel
Debian Iceweasel (www.geticeweasel.org)
@ ePIE
Pocket IE (www.reensoft.com/PIEPlus)
@ eScript
Class: script tools (perl/php/...)
@ eOperaMobile
Opera Mobile (www.opera.com/mobile)
@ eEudoraWeb
EudoraWeb (www.eudora.com)
@ eSEMCBrowser
Sony Ericsson SEMC-Browser (www.sonyericsson.com)
@ eFirefox
Firefox (www.mozilla.org/products/firefox)
@ eBeonex
Beonex Communicator (www.beonex.com)
@ eNetCaptor
NetCaptor (www.netcaptor.com)
@ ePocketLink
PocketLink (www.mobilefan.net)
@ eKNinja
K-Ninja Samurai (k-ninja-samurai.en.softonic.com)
@ eNetFront
NetFront (www.access-company.com)
@ eOpera
Opera (www.opera.com)
@ eNagios
check_http/nagios-plugins (nagiosplugins.org)
@ eMultiZilla
MultiZilla (multizilla.mozdev.org)
@ eOmniWeb
OmniWeb (www.omnigroup.com/applications/omniweb)
@ eDoCoMo
DoCoMo (www.nttdocomo.com)
@ eIceCat
GNU IceCat (http://www.gnu.org/software/gnuzilla)
@ eTelecaObigo
Teleca/Obigo (www.teleca.com / www.obigo.com)
@ eEdge
Microsoft Edge (www.microsoft.com)
@ eBlackberry
Blackberry (www.blackberry.com)
@ eSeaMonkey
SeaMonkey (www.mozilla.org/projects/seamonkey)
@ eGranParadiso
GranParadiso (www.mozilla.org)
@ eXiino
Xiino (www.ilinx.co.jp/en/)
@ eChimera
Chimera (chimera.mozdev.org)
@ eStainless
Stainless (www.stainlessapp.com)
@ eiCab
iCab (www.icab.de)
@ eCrazyBrowser
Crazy Browser (www.crazybrowser.com)
@ eAirEdge
Mobile devices (browsers and services for: telephones, smartphones, tablets and etc) Some mobile devi...
@ eOpenWave
OpenWave/UP.Browser (www.openwave.com)
@ eLynx
Lynx (lynx.browser.org)
@ eIE
Microsoft Internet Explorer (www.microsoft.com/windows/ie)
@ eSafariMobile
Mobile Safari (www.apple.com/safari)
@ eOfflineBrowser
Class: offline browsers.
@ eMaxthon
Maxthon/MyIE2 (www.maxthon.com)
@ eCamino
Camino (www.caminobrowser.org)
@ eNetNewsWire
NetNewsWire (www.apple.com)
@ eOperaMini
Opera Mini (www.opera.com/mini)
@ ePapers
Papers (papersapp.com)
@ eNetscape
Netscape (Navigator), versions >=6 are Gecko-based (www.netscape.com)
@ eAvantGo
AvantGo (www.sybase.com/avantgo)
@ eAvantBrowser
Avant Browser (www.avantbrowser.com)
@ eIRider
iRider (www.irider.com)
@ eReqwireless
Reqwireless Webviewer.
@ euZardWeb
uZard Web (www.uzard.com)
@ eFlock
Flock (www.flock.com)
@ eAOL
America Online Browser (www.aol.com)
@ eUCBrowser
UC Browser (www.ucweb.com/ucbrowser)
@ eKazehakase
Kazehakase (kazehakase.sourceforge.jp)
@ eGaleon
Galeon (galeon.sourceforge.net)
@ eMozilla
Any other Gecko-based not from the list above, Mozilla version >= 5.0.
@ eFluid
Fluid (fluidapp.com)
@ eWebValidator
Class: validators.
@ eLinkChecker
Class: link checkers.
@ eMozillaCompatible
Any other not from list above.
@ eKMeleon
K-Meleon (kmeleon.sf.net)
@ eShiira
Shiira (hmdt-web.net/shiira/en)
@ eOregano
Oregano (www.castle.org.uk/oregano)
@ eCrawler
Search robots/bots/validators.
@ eAcooBrowser
Acoo Browser (www.acoobrowser.com)
@ eVodafone
Ex J-Phone, now Vodafone Live! (www.vodafone.com)
@ ePlucker
Plucker (www.plkr.org)
const string & Get(const string &name, bool *found=NULL) const
Get environment value by name.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static bool MatchesMask(CTempString str, CTempString mask, ECase use_case=eCase)
Match "str" against the "mask".
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string.
static string & ToLower(string &str)
Convert string to lower case – string& version.
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
int GetMajor(void) const
Major version.
void SetVersion(int ver_major, int ver_minor, int patch_level=0)
const string version
version string
const struct ncbi::grid::netcache::search::fields::KEY key
static patstr * include_patterns
static patstr * exclude_patterns
CCgiUserAgent::EBrowserEngine engine
CCgiUserAgent::EBrowser type
CCgiUserAgent::EBrowserPlatform platform
NCBI_PARAM_DEF(string, CGI, Bots, "")
void s_ParseVersion(const string &token, SIZE_TYPE start_pos, TUserAgentVersion *version)
const char * kMultiLinePatternDelimiters
const char * kSingleLinePatternDelimiters
const SBrowser s_Browsers[]
string s_ToLower(string str)
SIZE_TYPE s_SkipDigits(const string &str, SIZE_TYPE pos)
NCBI_PARAM_DECL(string, CGI, Bots)
API to parse user agent strings.