59 #define NCBI_USE_ERRCODE_X Cgi_Application
67 CGI_PRINT_HTTP_REFERER);
73 CGI_PRINT_USER_AGENT);
85 CGI_PRINT_REQUEST_METHOD);
97 CGI_CLIENT_CONNECTION_INTERRUPTION_OKAY);
111 CGI_CLIENT_CONNECTION_INTERRUPTION_SEVERITY);
126 size_t* bytes_read = 0);
141 if (x_read > 0 ||
count == 0) {
148 *bytes_read = x_read;
160 CGI_COUNT_TRANSFERED);
178 size_t* bytes_written = 0);
209 m_ErrorReported(
false),
213 m_UsedChunkedTransfer(
false)
237 size_t* bytes_written)
258 ERR_POST_X(16,
"CCgiStreamWrapperWriter::Write() -- attempt to "
259 "write data after finishing chunked transfer.");
262 ERR_POST_X(15,
"CCgiStreamWrapperWriter::Write() -- attempt to "
263 "write data after sending headers on HEAD request.");
274 const char* cbuf =
static_cast<const char*
>(
buf);
282 count -= chunk_count;
283 written += chunk_count;
286 if (!
m_Out->good()) {
288 written -= chunk_count;
309 *bytes_written = written;
344 m_Out->exceptions(ios_base::goodbit);
345 m_Out->setstate(ios_base::badbit);
360 list<CNcbiOstream*> slist;
361 slist.push_back(
m_Out);
362 slist.push_back(&stream);
485 #if defined(NCBI_OS_UNIX)
487 if ( !TParamAllowSigpipe::GetDefault() ) {
488 signal(SIGPIPE, SIG_IGN);
489 struct sigaction sigterm, sigtermold;
490 memset(&sigterm, 0,
sizeof(sigterm));
492 sigterm.sa_flags = SA_RESETHAND;
493 if (sigaction(SIGTERM, &sigterm, &sigtermold) == 0
494 && sigtermold.sa_handler != SIG_DFL) {
495 sigaction(SIGTERM, &sigtermold, 0);
510 bool skip_stat_log =
false;
511 unique_ptr<CCgiStatistics> stat(is_stat_log ?
CreateStat() : 0);
516 unique_ptr<CNcbiOstream> new_stream;
517 shared_ptr<CCgiContext>
context;
518 unique_ptr<ICache> cache;
521 _TRACE(
"(CGI) CCgiApplication::Run: calling ProcessRequest");
542 }
catch (
const exception& ex) {
543 ERR_POST_X(1,
"Couldn't create cache : " << ex.what());
545 bool skip_process_request =
false;
547 if (cache && caching_needed) {
552 if (!skip_process_request) {
555 context->GetResponse().GetOutput());
560 list<CNcbiOstream*> slist;
561 orig_stream =
context->GetResponse().GetOutput();
562 slist.push_back(orig_stream);
563 slist.push_back(&result_copy);
566 context->GetResponse().SetOutput(new_stream.get());
584 context->GetResponse().Finalize();
588 context->GetResponse().AbortChunkedTransfer();
590 context->GetResponse().FinishChunkedTransfer();
592 context->GetResponse().Flush();
601 }
else if (caching_needed) {
618 context->GetResponse().FinishChunkedTransfer();
630 if ( is_stat_log && !skip_stat_log ) {
632 stat->Submit(stat->Compose());
637 _TRACE(
"CCgiApplication::Run: flushing");
638 context->GetResponse().Flush();
643 catch (exception& e) {
645 context->GetResponse().AbortChunkedTransfer();
660 string msg =
"(CGI) CCgiApplication::ProcessRequest() failed: ";
665 msg = stat->Compose();
667 skip_stat_log =
true;
675 if ( !TClientConnIntOk::GetDefault() ) {
677 "Connection interrupted");
686 #ifndef NCBI_OS_MSWIN
688 if ( is_stat_log && !skip_stat_log ) {
690 stat->Submit(stat->Compose());
708 if ( !ref.empty() ) {
722 const auto& req =
ctx.GetRequest();
726 if (TPrintRequestMethodParam::GetDefault()) {
728 string method = req.GetRequestMethodName();
729 if (!method.empty()) {
730 diag.Extra().Print(
"REQUEST_METHOD", method);
733 if ( TPrintSelfUrlParam::GetDefault() ) {
735 string self_url =
ctx.GetSelfURL();
736 if ( !self_url.empty() ) {
738 req.GetRandomProperty(
"REDIRECT_QUERY_STRING",
false);
739 if ( args.empty() ) {
742 if ( !args.empty() ) {
743 self_url +=
"?" + args;
748 if ( !target_url.empty() ) {
749 bool secure =
AStrEquiv(req.GetRandomProperty(
"HTTPS",
751 string host = (secure ?
"https://" :
"http://") + diag.GetHost();
753 if (!port.empty() && port != (secure ?
"443" :
"80")) {
756 target_url = host + target_url;
758 if ( !self_url.empty() || !target_url.empty() ) {
759 diag.Extra().Print(
"SELF_URL", self_url).
760 Print(
"TARGET_URL", target_url);
764 if ( TPrintRefererParam::GetDefault() ) {
766 if ( !
str.empty() ) {
767 diag.Extra().Print(
"HTTP_REFERER",
str);
771 if ( TPrintUserAgentParam::GetDefault() ) {
773 if ( !
str.empty() ) {
774 diag.Extra().Print(
"USER_AGENT",
str);
785 string name = it->substr(5);
788 env[name] = rq_env.
Get(*it);
805 ERR_POST_X(2,
"CCgiApplication::GetContext: no context set");
806 throw runtime_error(
"no context set");
815 ERR_POST_X(3,
"CCgiApplication::GetResource: no resource set");
816 throw runtime_error(
"no resource set");
832 ERR_POST_X(17,
"CCgiApplication::GetResource: no processor set");
833 throw runtime_error(
"no request processor set");
847 if (processor !=
nullptr)
delete processor;
860 CGI_MERGE_LOG_LINES);
866 if ( TMergeLogLines::GetDefault() ) {
939 bool need_output_wrapper =
940 TCGI_Count_Transfered::GetDefault() ||
946 if ( TCGI_Count_Transfered::GetDefault() ) {
957 if ( need_output_wrapper ) {
976 (errbuf_size >= 0) ? (
size_t) errbuf_size : 256,
1029 m_CaughtSigterm(
false),
1079 if (!pprocessor)
break;
1090 .AllowBadSymbolsInArgNames()
1105 auto span = req_ctx.GetTracerSpan();
1108 if (!s.empty()) span->SetName(s);
1118 if ( args.empty() ) {
1121 if ( !args.empty() ) {
1153 extra.
Print(it->name, it->value);
1163 if (!pprocessor)
break;
1175 catch (
const exception&) {
1180 if ( !
out.good() ) {
1187 catch (
const exception&) {
1198 if (!pprocessor)
break;
1215 if (TClientConnIntOk::GetDefault() ||
1289 string dest = request.
GetEntry(
"diag-destination", &is_set);
1306 string threshold = request.
GetEntry(
"diag-threshold", &is_set);
1310 if (threshold ==
"fatal") {
1312 }
else if (threshold ==
"critical") {
1314 }
else if (threshold ==
"error") {
1316 }
else if (threshold ==
"warning") {
1318 }
else if (threshold ==
"info") {
1320 }
else if (threshold ==
"trace") {
1333 TFlagMap& flagmap = s_FlagMap.
Get();
1350 if (flagmap.empty()) {
1376 TFlagMap::const_iterator it;
1377 if ((it = flagmap.find(*flag)) != flagmap.end()) {
1378 new_flags |= it->second;
1379 }
else if ((*flag)[0] ==
'!'
1380 && ((it = flagmap.find(flag->substr(1)))
1381 != flagmap.end())) {
1382 new_flags &= ~(it->second);
1383 }
else if (*flag ==
"default") {
1384 new_flags |= defaults;
1439 const char*
const* argv)
1444 if (argc != 2 || !argv[1]) {
1470 string checksum, content;
1479 CRStream cache_reader(reader.get());
1482 }
catch (
const exception& ex) {
1483 ERR_POST_X(5,
"Couldn't read cached request : " << ex.what());
1491 string checksum, content;
1499 CWStream cache_writer(writer.get());
1502 }
catch (
const exception& ex) {
1503 ERR_POST_X(6,
"Couldn't cache request : " << ex.what());
1513 unique_ptr<IWriter> writer( cache.
GetWriteStream(rid, 0,
"NS_JID") );
1515 CWStream cache_stream(writer.get());
1518 }
catch (
const exception& ex) {
1519 ERR_POST_X(7,
"Couldn't save request : " << ex.what());
1529 unique_ptr<IReader> reader(cache.
GetReadStream(rid, 0,
"NS_JID"));
1531 CRStream cache_stream(reader.get());
1533 request->Deserialize(cache_stream, 0);
1534 return request.release();
1536 }
catch (
const exception& ex) {
1537 ERR_POST_X(8,
"Couldn't read saved request : " << ex.what());
1547 string cookie_name =
GetConfig().
Get(
"CGI-LB",
"Name");
1548 if ( cookie_name.empty() )
1551 int life_span = reg.
GetInt(
"CGI-LB",
"LifeSpan", 0, 0,
1554 string domain = reg.
GetString(
"CGI-LB",
"Domain",
".ncbi.nlm.nih.gov");
1556 if ( domain.empty() ) {
1557 ERR_POST_X(9,
"CGI-LB: 'Domain' not specified.");
1559 if (domain[0] !=
'.') {
1560 domain.insert(0,
".");
1564 string path = reg.
Get(
"CGI-LB",
"Path");
1566 bool secure = reg.
GetBool(
"CGI-LB",
"Secure",
false,
1579 host = reg.
Get(
"CGI-LB",
"Host");
1580 if ( host.empty() ) {
1581 if (
m_Caf.get() ) {
1582 char host_ip[64] = {0,};
1583 m_Caf->GetHostIP(host_ip,
sizeof(host_ip));
1588 ERR_POST_X(10,
"CGI-LB: 'Host' not specified.");
1594 CCgiCookie cookie(cookie_name, host, domain, path);
1595 if (life_span > 0) {
1601 cookies.
Add(cookie);
1613 string x_moz =
context.GetRequest().GetRandomProperty(
"X_MOZ");
1616 "Prefetch is not allowed for CGIs");
1644 string log_path =
"/log/";
1651 size_t min_pos = exe_path.length();
1655 if (!it->empty() && (*it)[0] !=
'/') {
1657 string mask =
"/" + *it;
1658 if (
mask[
mask.length() - 1] !=
'/') {
1661 size_t pos = exe_path.find(
mask);
1662 if (pos < min_pos) {
1669 if (exe_path.substr(0, it->length()) == *it) {
1675 if ( !web_dir.empty() ) {
1679 const char* port = ::getenv(
"SERVER_PORT");
1680 return port ? log_path +
string(port) : log_path +
"srv";
1711 bool this_wc =
m_Type ==
"*";
1712 bool other_wc = entry.
m_Type ==
"*";
1713 if (this_wc != other_wc)
return !this_wc;
1717 if (this_wc != other_wc)
return !this_wc;
1747 if (!TEnableHelpRequest::GetDefault())
return false;
1752 if ( !found )
return false;
1789 bool use_alt_name =
false;
1790 string vparam = TEnableVersionRequest::GetDefault();
1791 if ( vparam.empty() )
return false;
1794 if (!is_enabled)
return false;
1797 use_alt_name =
true;
1802 if ( use_alt_name ) {
1803 ver_type = request.
GetEntry(vparam, &found);
1806 ver_type = request.
GetEntry(
"ncbi_version", &found);
1808 if ( !found )
return false;
1811 if (ver_type.empty() || ver_type ==
"short") {
1814 else if (ver_type ==
"full") {
1819 "Unsupported ncbi_version argument value");
1837 string cmd_name = request.
GetEntry(
"ncbi_admin_cmd", &found);
1843 if ( path_info.empty() )
return false;
1844 cmd_name = path_info;
1877 CGI_VALIDATE_CSRF_TOKEN);
1891 const char* p = getenv(
"FCGI_STANDALONE_SERVER");
1911 if (x_iterations > 0) {
1912 ret = (
unsigned int) x_iterations;
1914 ERR_POST_X(6,
"CCgiApplication::x_RunFastCGI: invalid "
1915 "[FastCGI].Iterations config.parameter value: "
1923 if (iterations_rnd_inc > 0) {
1924 ret += rand() % iterations_rnd_inc;
1927 _TRACE(
"CCgiApplication::Run: FastCGI limited to "
1928 << ret <<
" iterations");
1935 return GetConfig().
GetBool(
"FastCGI",
"Complete_Request_On_Sigterm",
false);
1941 const string& orig_filename =
GetConfig().
Get(
"FastCGI",
"WatchFile.Name");
1942 if ( !orig_filename.empty() ) {
1945 if (filename != orig_filename) {
1946 _TRACE(
"Adjusted relative CGI watch file name " << orig_filename
1947 <<
" to " << filename);
1964 if ( have_watcher ) {
1965 ERR_POST_X(7,
"CCgiApplication::x_RunFastCGI: non-positive "
1966 "[FastCGI].WatchFile.Timeout conf.param. value ignored: " << ret);
1970 return (
unsigned int) ret;
1977 if (ret <= 0)
return 0;
1981 double r = rand() / (RAND_MAX + 1.0);
1982 return 1 + (
int)(ret *
r);
2011 const int kDefaultMaxThreads = 8;
2013 if (ret <= 0) ret = kDefaultMaxThreads;
2014 return (
unsigned int)ret;
2021 if ( !
CDirEntry(filename).GetTime(&mtime) ) {
2023 "Cannot get modification time of the CGI executable "
2038 ERR_POST(
"Could not check self memory usage" );
2040 else if (memory_usage.
total > limit) {
2042 ") is above the configured limit (" <<
2059 if (restart_reason !=
eSR_None)
return restart_reason;
2064 if ( mtimeNew != mtime) {
2065 _TRACE(
"CCgiApplication::x_RunFastCGI: "
2066 "the program modification date has changed");
2068 }
else if ( watcher && watcher->
HasChanged()) {
2072 "Scheduling restart of Fast-CGI, as its watch file has changed");
2077 if (restart_time->IsEmpty()) {
2079 restart_time->SetCurrent();
2080 restart_time->AddSecond(delay);
2081 _TRACE(
"Will restart Fast-CGI in " << delay <<
" seconds, at "
2082 << restart_time->GetLocalTime().AsString(
"h:m:s"));
2085 return restart_reason;
2108 : m_CgiApp(cgi_app), m_LogDelim(
";")
2120 const std::exception* ex)
2137 if (time_cutoff > 0) {
2139 if (diff < time_cutoff) {
2144 string msg, tmp_str;
2147 if ( !tmp_str.empty() ) {
2148 msg.append(tmp_str);
2153 if ( !tmp_str.empty() ) {
2154 msg.append(tmp_str);
2162 if ( !tmp_str.empty() ) {
2163 msg.append(tmp_str);
2169 if ( !tmp_str.empty() ) {
2170 msg.append(tmp_str);
2174 if ( !tmp_str.empty() ) {
2175 msg.append(tmp_str);
2213 string log_args = reg.
Get(
"CGI",
"LogArgs");
2214 if ( log_args.empty() )
2223 bool is_entry_found;
2224 const string& arg = *
i;
2226 size_t pos = arg.find_last_of(
'=');
2229 }
else if (pos != string::npos) {
2230 string key = arg.substr(0, pos);
2232 if ( is_entry_found ) {
2233 string alias = arg.
substr(pos+1, arg.length());
2242 if ( is_entry_found ) {
2276 return (
int)
in.gcount();
2283 : m_Filename(filename), m_Limit(limit), m_Buf(new char[limit])
2287 ERR_POST_X(2,
"Failed to open CGI watch file " << filename);
2333 string content_type;
2336 string fname_fmt = base_name +
".help." +
format;
2337 if (
CFile(fname_fmt).Exists() ) {
2342 fname_fmt =
"help." +
format;
2343 if (
CFile(fname_fmt).Exists() ) {
2352 if ( fname.empty() ) {
2356 string fname_accept = base_name +
".help." + it->m_Subtype + it->m_MediaRangeParams;
2357 if (
CFile(fname_accept).Exists() ) {
2358 fname = fname_accept;
2359 content_type = it->m_Type +
"/" + it->m_Subtype;
2363 if ( fname.empty() ) {
2365 string fname_accept =
"help." + it->m_Subtype + it->m_MediaRangeParams;
2366 if (
CFile(fname_accept).Exists() ) {
2367 fname = fname_accept;
2368 content_type = it->m_Type +
"/" + it->m_Subtype;
2376 if ( fname.empty() ) {
2378 string fname_std = base_name +
".help." +
kStdFormats[
i];
2386 if ( fname.empty() ) {
2389 if (
CFile(fname_std).Exists() ) {
2398 if ( !fname.empty() ) {
2402 bool ct_found =
false;
2408 if ( eol.empty() ) {
2417 if ( !content_type.empty()) {
2433 "Can not find help for CGI application");
2442 string content_type =
"text/plain";
2446 if (it->m_Subtype ==
"xml" || it->m_Subtype ==
"json" ||
2447 (it->m_Type ==
"text" && it->m_Subtype ==
"plain")) {
2449 content_type = it->m_Type +
"/" + it->m_Subtype;
2468 else if (
format ==
"xml") {
2478 else if (
format ==
"json") {
2490 "Unsupported version format");
2517 if (!TParamValidateCSRFToken::GetDefault())
return true;
2527 if ( !ref.empty() ) {
2529 if ( !args.empty() ) ref +=
"?" + args;
2537 CGI_EXCEPTION_MESSAGE);
2544 string status_str =
"500 Server Error";
2545 string message =
"";
2568 status_str =
"400 Malformed HTTP Request";
2582 string expt_msg = TExceptionMessage::GetDefault();
2583 if ( !expt_msg.empty() ) {
2589 os <<
"Status: " << status_str <<
HTTP_EOL;
2606 ERR_POST_X(4,
"CCgiApplication::OnException() failed to send error page"
2607 " back to the client");
2611 catch (
const exception& ex) {
2627 m_Context->GetResponse().SetStatus(status, reason);
2651 if (accept.empty())
return;
2657 if ( parts.empty() )
continue;
2663 list<string>::const_iterator ext_it = parts.begin();
2665 bool aparams =
false;
2666 while (ext_it != parts.end()) {
2673 if (entry.
m_Quality == 0 && errno != 0) {
cache (ICache) external reference using hash key(CRC32, MD5)
Exception classes used by the NCBI CGI framework.
NCBI_PARAM_DEF_EX(bool, CGI, Print_Http_Referer, true, eParam_NoThread, CGI_PRINT_HTTP_REFERER)
const char * kWebDirToPort
NCBI_PARAM_ENUM_DEF_EX(EDiagSev, CGI, Client_Connection_Interruption_Severity, eDiag_Error, eParam_NoThread, CGI_CLIENT_CONNECTION_INTERRUPTION_SEVERITY)
const char * kToolkitRcPath
typedef NCBI_PARAM_TYPE(CGI, Print_Http_Referer) TPrintRefererParam
DEFINE_STATIC_FAST_MUTEX(s_RestartReasonMutex)
static const char * kStdFormats[]
NCBI_PARAM_ENUM_ARRAY(EDiagSev, CGI, Client_Connection_Interruption_Severity)
NCBI_PARAM_DEF(bool, CGI, DisableTrackingCookie, false)
string FindContentType(CTempString format)
static void s_CleanupProcessor(CCgiRequestProcessor *processor, void *)
static const char * kStdContentTypes[]
NCBI_PARAM_DECL(bool, CGI, Print_Http_Referer)
static const char * kCSRFTokenName
CAsBodyDiagFactory(CCgiApplication *app)
virtual CDiagHandler * New(const string &)
Factory method interface.
virtual ERW_Result Read(void *buf, size_t count, size_t *bytes_read=0)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
virtual ERW_Result PendingCount(size_t *)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
CCGIStreamReader(istream &is)
bool GetHashedContent(const string &hash_str, const string &hashed_content, string *ref_value)
Get hashed content Method compares both hash value and hashed content.
void StoreHashedContent(const string &hash_str, const string &hashed_content, const string &ref_value)
Store hashed content.
Base class for request processors.
void FinishChunkedTransfer(const CCgiStreamWrapper::TTrailer *trailer)
void SetCacheStream(CNcbiOstream &stream)
virtual ERW_Result Write(const void *buf, size_t count, size_t *bytes_written=0)
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
CCgiStreamWrapper::EStreamMode GetMode(void) const
bool m_UsedChunkedTransfer
void x_WriteChunk(const char *buf, size_t count)
CCgiStreamWrapper::EStreamMode m_Mode
virtual ~CCgiStreamWrapperWriter(void)
void AbortChunkedTransfer(void)
void x_SetChunkSize(size_t sz)
void SetMode(CCgiStreamWrapper::EStreamMode mode)
virtual ERW_Result Flush(void)
Flush pending data (if any) down to the output device.
CCgiStreamWrapperWriter(CNcbiOstream &out)
IWriter which can write simultaneously to the different streams.
static CNcbiApplication * Instance(void)
Singleton method.
Note about the "buf_size" parameter for streams in this API.
Reader-writer-based stream buffer.
@ fOwnReader
Own the underlying reader.
@ fOwnWriter
Own the underlying writer.
T & Get(void)
Create the variable if not created yet, return the reference.
virtual CDiagHandler * New(const string &)
Factory method interface.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Writer-based output stream.
BLOB cache read/write/maintenance interface.
virtual IWriter * GetWriteStream(const string &key, TBlobVersion version, const string &subkey, unsigned int time_to_live=0, const string &owner=kEmptyStr)=0
Return sequential stream interface to write BLOB data.
virtual IReader * GetReadStream(const string &key, TBlobVersion version, const string &subkey)=0
Return sequential stream interface to read BLOB data.
A very basic data-read interface.
A very basic data-write interface.
container_type::const_iterator const_iterator
const_iterator end() const
const_iterator find(const key_type &key) const
void Print(const CCompactSAMApplication::AlignInfo &ai)
std::ofstream out("events_result.xml")
main entry point for tests
static const struct name_t names[]
static const char * str(char *buf, int n)
static const struct type types[]
static string GetAppName(EAppNameType name_type=eBaseName, int argc=0, const char *const *argv=NULL)
const CNcbiEnvironment & GetEnvironment(void) const
Get the application's cached environment.
const string & GetProgramExecutablePath(EFollowLinks follow_links=eIgnoreLinks) const
Get the application's executable path.
virtual void Init(void)
Initialize the application.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
CVersionInfo GetVersion(void) const
Get the program version information.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
EPreparseArgs
Result of PreparseArgs()
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
void SetStdioFlags(TStdioSetupFlags stdio_flags)
Adjust the behavior of standard I/O streams.
const CArgDescriptions * GetArgDescriptions(void) const
Get argument descriptions (set by SetupArgDescriptions)
element_type * get(void) const
Get pointer.
virtual void Exit(void)
Cleanup on application exit.
const string & GetProgramDisplayName(void) const
Get the application's "display" name.
void DisableArgDescriptions(TDisableArgDesc disable=fDisableStdArgs)
CNcbiRegistry & GetRWConfig(void)
Get the application's cached configuration parameters, accessible for read-write for an application's...
const CVersionAPI & GetFullVersion(void) const
Get the program version information.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ fBinaryCout
treat standard output as binary
@ fBinaryCin
treat standard input as binary
@ ePreparse_Exit
Exit the application with zero exit code.
@ ePreparse_Continue
Continue application execution.
virtual string & PrintUsage(string &str, bool detailed=false) const
Print usage message to end of specified string.
virtual void PrintUsageXml(CNcbiOstream &out) const
Print argument description in XML format.
CArgs & Assign(const CArgs &other)
Copy contents of another object into this one.
void SetArgsType(EArgSetType args_type)
Set type of argument description (cmdline vs CGI).
void ConvertKeys(CArgs *args, const T &arg_map, bool update) const
Convert argument map (key-value pairs) into arguments in accordance with the argument descriptions.
@ eCgiArgs
CGI application.
void x_InitArgs(void) const
void SetHTTPStatus(unsigned int status, const string &reason=kEmptyStr)
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
EAdminCommand
Admin commands passed through ncbi_admin_cmd argument.
virtual string Compose_Entries(void)
virtual void Init(void)
This method is called on the CGI application initialization – before starting to process a HTTP reque...
virtual int OnException(std::exception &e, CNcbiOstream &os)
This method is called if an exception is thrown during the processing of HTTP request.
unsigned int GetFastCGIWatchFileTimeout(bool have_watcher) const
bool GetRequestStartPrinted(void) const
virtual string Compose_ErrMessage(void)
const CCgiResponse & GetResponse(void) const
virtual ~CCgiStatistics()
void SetOutputBroken(bool val)
const CCgiContext & GetContext(void) const
Get current server context. Throw exception if the context is not set.
void SetRequestStartPrinted(bool val)
bool GetFastCGIComplete_Request_On_Sigterm(void) const
bool CheckMemoryLimit(void)
virtual string Compose_Result(void)
CCgiStatistics(CCgiApplication &cgi_app)
virtual bool x_RunFastCGI(int *result, unsigned int def_iter=10)
void SetErrorStatus(bool val)
const CCgiRequest & GetRequest(void) const
unsigned int GetFastCGIIterations(unsigned int def_iter) const
shared_ptr< CCgiContext > m_Context
CCgiStreamWrapperWriter * m_Writer
bool GetOutputBroken(void) const
unsigned int GetFastCGIMTMaxThreads(void) const
void AbortChunkedTransfer(void)
friend class CCgiRequestProcessor
CDiagFactory * FindDiagFactory(const string &key)
CAtomicCounter m_Iteration
virtual void ProcessVersionRequest(CCgiApplication::EVersionType ver_type)
virtual void ConfigureDiagFormat(CCgiContext &context)
int GetFastCGIWatchFileRestartDelay(void) const
CCgiApplication(const SBuildInfo &build_info=NCBI_SBUILDINFO_DEFAULT())
virtual CCgiRequestProcessor * CreateRequestProcessor(void)
Create request processor to process the request.
virtual void ConfigureDiagnostics(CCgiContext &context)
virtual int ProcessRequest(CCgiContext &context)
Process request provided by the context. By default calls application's ProcessRequest.
static CTime GetFileModificationTime(const string &filename)
string m_MediaRangeParams
Media range parameters.
int m_RequestFlags
Bit flags for CCgiRequest.
CCgiRequestProcessor & x_GetProcessor(void) const
bool ProcessAdminRequest_Base(CCgiApplication::EAdminCommand cmd)
virtual void Exit(void)
This method is called on the CGI application exit.
virtual ~CCgiRequestProcessor(void)
virtual void ConfigureDiagDestination(CCgiContext &context)
bool x_IsSetProcessor(void) const
virtual ICgiSessionStorage * GetSessionStorage(CCgiSessionParameters ¶ms) const
Get instance of CGI session storage interface.
virtual EPreparseArgs PreparseArgs(int argc, const char *const *argv)
Check the command line arguments before parsing them.
virtual bool ProcessAdminRequest(CCgiApplication::EAdminCommand cmd)
bool GetFastCGIStatLog(void) const
void RegisterDiagFactory(const string &key, CDiagFactory *fact)
CCgiApplication::SAcceptEntry TAcceptEntry
void SetInputStream(CNcbiIstream *in)
unique_ptr< CNcbiResource > m_Resource
CCgiWatchFile(const string &filename, int limit=1024)
void SetCacheStream(CNcbiOstream &stream)
CNcbiResource & x_GetResource(void) const
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments extended with CGI parameters.
bool GetFastCGIStopIfFailed(void) const
static bool ProcessCORSRequest(const CCgiRequest &request, CCgiResponse &response)
Process cross-origin resource sharing (CORS) request.
bool x_ProcessHelpRequest(CCgiRequestProcessor &processor)
virtual void OnEvent(EEvent event, int status)
This method is called after each request, or when the CGI is forced to skip a request,...
CNcbiOstream & GetOutputStream(void)
virtual void OnEvent(CCgiApplication::EEvent event, int status)
virtual void ProcessHelpRequest(const string &format)
float m_Quality
Quality factor or "1" if not set (or not numeric).
virtual void Reset(const CTime &start_time, int result, const std::exception *ex=0)
bool GetErrorStatus(void) const
EStreamMode GetWriterMode(void)
virtual void ConfigureDiagThreshold(CCgiContext &context)
string GetFastCGIStandaloneServer(void) const
static ERestartReason ShouldRestart(CTime &mtime, CCgiWatchFile *watcher, int delay)
virtual bool ProcessAdminRequest(EAdminCommand cmd)
Process admin command passed through ncbi_admin_cmd argument.
bool operator<(const SAcceptEntry &entry) const
CCgiContext & x_GetContext(void) const
void SetRequestId(const string &rid, bool is_done)
void SetHTTPStatus(unsigned int status, const string &reason=kEmptyStr)
Set HTTP status code in the current request context and in the current CHttpResponse if one exists.
bool x_ProcessAdminRequest(CCgiRequestProcessor &processor)
virtual void AppStart(void)
Prepare properties and print the application start message.
virtual CCgiContext * CreateContext(CNcbiArguments *args=0, CNcbiEnvironment *env=0, CNcbiIstream *inp=0, CNcbiOstream *out=0, int ifd=-1, int ofd=-1)
Factory method for the Context object construction.
void x_OnEvent(CCgiRequestProcessor *pprocessor, EEvent event, int status)
bool x_DoneHeadRequest(CCgiContext &context) const
void ParseAcceptHeader(TAcceptEntries &entries) const
virtual ICache * GetCacheStorage(void) const
unique_ptr< CCookieAffinity > m_Caf
virtual string Compose(void)
CCgiApplication::TAcceptEntries TAcceptEntries
virtual int OnException(std::exception &e, CNcbiOstream &os)
virtual string Compose_ProgramName(void)
void SetWriterMode(EStreamMode mode)
bool IsSetOutputStream(void) const
virtual int Run(void)
Do not override this method yourself! – it includes all the CGI specific machinery.
ELogOpt GetLogOpt(void) const
virtual bool ValidateSynchronizationToken(void)
string GetRID(void) const
TDiagFactoryMap m_DiagFactories
ELogOpt
Analyze registry settings ([CGI] Log) and return current logging option.
virtual bool ValidateSynchronizationToken(void)
Validate synchronization token (cross-site request forgery prevention).
virtual bool IsCachingNeeded(const CCgiRequest &request) const
friend class CCgiStatistics
virtual void Submit(const string &message)
virtual CCgiStatistics * CreateStat()
Class factory for statistics class.
void SetRequestId(const string &rid, bool is_done)
virtual void ProcessHelpRequest(const string &format)
Process help request: set content type, print usage informations etc.
virtual CNcbiResource * LoadResource(void)
virtual string Compose_Timing(const CTime &end_time)
void SaveResultToCache(const CCgiRequest &request, CNcbiIstream &is, ICache &cache)
bool x_ProcessVersionRequest(CCgiRequestProcessor &processor)
bool IsSetInputStream(void) const
void InitArgs(CArgs &args, CCgiContext &context) const
void SetContext(shared_ptr< CCgiContext > context)
CCgiApplication & m_CgiApp
void SaveRequest(const string &rid, const CCgiRequest &request, ICache &cache)
CCgiRequestProcessor * x_GetProcessorOrNull(void) const
void SetOutputStream(CNcbiOstream *out)
bool IsSetContext(void) const
virtual CCgiServerContext * LoadServerContext(CCgiContext &context)
static CCgiApplication * Instance(void)
Singleton.
virtual void ProcessVersionRequest(EVersionType ver_type)
Process version request: set content type, print version informations etc.
virtual CCgiContext * CreateContextWithFlags(CNcbiArguments *args, CNcbiEnvironment *env, CNcbiIstream *inp, CNcbiOstream *out, int ifd, int ofd, int flags)
The same as CreateContext(), but allows for a custom set of flags to be specified in the CCgiRequest ...
CCgiContext & GetContext(void)
CCgiRequestProcessor & x_CreateProcessor(void)
CCgiRequest * GetSavedRequest(const string &rid, ICache &cache)
string GetSelfReferer(void) const
Get self-URL to be used as referer.
CCgiRequestProcessor(CCgiApplication &app)
list< SAcceptEntry > TAcceptEntries
CRef< CTls< CCgiRequestProcessor > > m_Processor
CCgiContext * CreateContextWithFlags_Default(CCgiRequestProcessor &processor, CNcbiArguments *args, CNcbiEnvironment *env, CNcbiIstream *inp, CNcbiOstream *out, int ifd, int ofd, int flags)
Default implementation of CreateContextWithFlags.
Client_Connection_Interruption_Okay
virtual int ProcessRequest(CCgiContext &context)=0
This is the method you should override.
void ParseAcceptHeader(TAcceptEntries &entries) const
Parse "Accept:" header, put entries to the list, more specific first.
void SetCafService(CCookieAffinity *caf)
Attach cookie affinity service interface.
bool GetFastCGIDebug(void) const
CCgiWatchFile * CreateFastCGIWatchFile(void) const
unique_ptr< CArgs > m_CgiArgs
CCgiStreamWrapper(CNcbiOstream &out)
Client_Connection_Interruption_Severity
virtual string GetDefaultLogPath(void) const
Get default path for the log files.
CNcbiIstream & GetInputStream(void)
bool GetResultReady(void) const
bool GetResultFromCache(const CCgiRequest &request, CNcbiOstream &os, ICache &cache)
virtual void AppStop(int exit_code)
Prepare properties for application stop message.
void LogRequest(void) const
bool GetFastCGIHonorExitRequest(void) const
TParams m_AcceptParams
Accept parameters.
void VerifyCgiContext(CCgiContext &context)
Check CGI context for possible problems, throw exception with HTTP status set if something is wrong.
void FinishChunkedTransfer(const TTrailer *trailer)
const string & GetSelfURL(ESelfUrlPort) const
Using HTTP environment variables, compose the CGI's own URL as: SCHEME://SERVER_NAME[:SERVER_PORT]/SC...
bool GetFastCGIChannelErrors(void) const
void AddLBCookie(CCgiCookies &cookies)
void ProcessHttpReferer(void)
Set CONN_HTTP_REFERER, print self-URL and referer to log.
@ eAdmin_HealthZ
Report health for this CGI as kubernetes expects.
@ eAdmin_Health
Report health for this CGI only.
@ eAdmin_Unknown
Unrecognized command.
@ eAdmin_HealthDeep
Report health for this CGI and any services used by it.
@ eAdmin_LiveZ
Report if this CGI is alive as kubernetes expects.
@ eAdmin_ReadyZ
Report readyness for this CGI as kubernetes expects.
@ eException
An exception occured during the request processing.
@ eExitRequest
FCGI forced to exit by client's 'exitfastcgi' request.
@ eExit
No more iterations, exiting (called the very last)
@ eWaiting
Periodic awakening while waiting for the next request.
@ eError
The HTTP request was processed, non-zero exit code.
@ eEndRequest
HTTP request processed, all results sent to client.
@ eExecutable
FCGI forced to exit as its modif. time has changed.
@ eWatchFile
FCGI forced to exit as its "watch file" has changed.
@ eExitOnFail
[FastCGI].StopIfFailed set, and the iteration failed
@ eSuccess
The HTTP request was processed, with zero exit code.
#define NCBI_CGI_THROW_WITH_STATUS(exception, err_code, message, status)
EStatusCode GetStatusCode(void) const
static string GetStdStatusMessage(EStatusCode code)
string GetStatusMessage(void) const
@ eStatusNotSet
Internal value - code not set.
bool HaveContentRange(void) const
Check if 'Content-Range' header is set.
void SetSecure(bool secure)
bool CalcChecksum(string &checksum, string &content) const
SIZE_TYPE find(const char *s, SIZE_TYPE pos=0) const
CCgiCookie * Find(const string &name, const string &domain, const string &path)
Return NULL if cannot find this exact cookie.
void Serialize(CNcbiOstream &os) const
Serialize/Deserialize a request to/from a stream.
void GetCGIEntries(CEntryCollector_Base &collector) const
Get full set of arguments (both GET and POST), URL-encoded.
CNcbiOstream & out(void) const
Get output stream. Throw exception if GetOutput() is NULL.
const string & GetValue() const
Get the value as a string, (necessarily) prefetching it all if applicable; the result remains availab...
void SetExpTime(const CTime &exp_time)
const CCgiCookies & GetCookies(void) const
Retrieve the request cookies.
static bool x_ClientSupportsChunkedTransfer(const CNcbiEnvironment &env)
string substr(SIZE_TYPE i=0, SIZE_TYPE n=NPOS) const
void SetOutput(CNcbiOstream *os, int fd=-1)
Set output stream (NULL here means "no output stream").
const string & GetProperty(ECgiProp prop) const
Get value of a "standard" property (return empty string if not defined)
CDiagContext_Extra::TExtraArgs & GetArgs(void)
const string & GetTrackingCookie(void) const
CCgiCookie * Add(const string &name, const string &value, const string &domain=kEmptyStr, const string &path=kEmptyStr, EOnBadCookie on_bad_cookie=eOnBadCookie_SkipAndError)
All Add() functions: if the added cookie has the same {name, domain, path} as an already existing one...
static size_t GetChunkSize(void)
bool IsHeaderWritten() const
bool AcceptRangesBytes(void) const
Check if 'Accept-Ranges' header is set to 'bytes'.
void SetContentType(const string &type)
Set content type (text/html by default if not provided)
const string & GetRandomProperty(const string &key, bool http=true) const
Get value of a random client property; if "http" is TRUE then add prefix "HTTP_" to the property name...
CNcbiOstream & WriteHeader(void) const
Write HTTP response header to the output stream.
const CCgiEntry & GetEntry(const string &name, bool *is_found=0) const
Get entry value by name.
static const string GetPropertyName(ECgiProp prop)
Get name (not value!) of a "standard" property.
CNcbiOstream * GetOutput(void) const
Get output stream (NULL here means "no output stream").
ERequestMethod GetRequestMethod(void) const
Get request method.
void Set(TValue new_value) THROWS_NONE
Set atomic counter value.
virtual CDiagHandler * New(const string &s)=0
Factory method interface.
void PushDiagPostPrefix(const char *prefix)
Push a string to the list of message prefixes.
void PrintRequestStop(void)
Print request stop message (for request-driven applications)
CDiagContext_Extra & Print(const string &name, const string &value)
The method does not print the argument, but adds it to the string.
void SetBytesWr(Int8 bytes)
void SetDiagPostFlag(EDiagPostFlag flag)
Set the specified flag (globally).
#define LOG_POST_X(err_subcode, message)
static bool IsSetOldPostFormat(void)
Check old/new format flag (for compatibility only)
void PrintStart(const string &message)
Print start/stop etc.
CDiagContext & GetDiagContext(void)
Get diag context instance.
void SetTracerSpanKind(ITracerSpan::ESpanKind kind)
At least Opentememetry tracer allows to set span kind only at span creation time.
void SetAppState(EDiagAppState state)
Set application state.
void PrintRequestStart(const string &message)
Print request start message (for request-driven applications)
CDiagContext_Extra Extra(void) const
Create a temporary CDiagContext_Extra object.
int TDiagPostFlags
Binary OR of "EDiagPostFlag".
void SetProperty(const string &name, const string &value)
Add/change property.
shared_ptr< ITracerSpan > GetTracerSpan(void) const
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
void SetRequestStatus(int status)
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
void SetExitCode(int exit_code)
Set exit code.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
void Flush(void)
Print the message and reset object.
void SetBytesRd(Int8 bytes)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void SetDiagHandler(CDiagHandler *handler, bool can_delete=true)
Set the diagnostic handler using the specified diagnostic handler class.
void Reset(void)
Reset all properties to the initial state.
void SetDiagTrace(EDiagTrace how, EDiagTrace dflt=eDT_Default)
Set the diagnostic trace settings.
EDiagSev
Severity level for the posted diagnostics.
TDiagPostFlags SetDiagPostAllFlags(TDiagPostFlags flags)
Set global post flags to "flags".
void SetDiagTraceFlag(EDiagPostFlag flag)
@ eDPF_Location
Include class and function if any.
@ eDPF_MergeLines
Escape EOLs.
@ eDPF_DateTime
Include date and time.
@ eDPF_ErrorID
Error code and subcode (default)
@ eDPF_Log
Print the posted message only; without severity, location, prefix, etc.
@ eDPF_Severity
Severity (default)
@ eDPF_OmitInfoSev
No sev. indication if eDiag_Info.
@ eDPF_Trace
Default flags to use when tracing.
@ eDPF_File
File name (not full path)
@ eDPF_LongFilename
Full file path.
@ eDPF_Prefix
Prefix (default)
@ eDPF_All
All flags (except for the "unusual" ones!)
@ eDT_Enable
Enable messages of severity "eDiag_Trace".
@ eDiagAppState_RequestEnd
RE.
@ eDiagAppState_RequestBegin
RB.
@ eDiagAppState_Request
R.
@ eDiag_Trace
Trace message.
@ eDiag_Info
Informational message.
@ eDiag_Error
Error message.
@ eDiag_Warning
Warning message.
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
@ eDiag_Critical
Critical error message.
@ e299_PartialContentBrokenConnection
Non-standard status code - used to indicate broken connection while serving partial-content request.
@ e499_BrokenConnection
Non-standard status code - used to indicate broken connection while serving normal request.
const string & Get(const string &name, bool *found=NULL) const
Get environment value by name.
void Enumerate(list< string > &names, const string &prefix=kEmptyStr) const
Find all variable names starting with an optional prefix.
const string & GetProgramName(EFollowLinks follow_links=eIgnoreLinks) const
Get program name.
#define NCBI_EXCEPTION_VAR(name, exception_class, err_code, message)
Create an instance of the exception to be thrown later.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
const string & GetMsg(void) const
Get message string.
void Warning(CExceptionArgs_Base &args)
#define NCBI_EXCEPTION_THROW(exception_var)
Throw an existing exception object.
#define NCBI_REPORT_EXCEPTION_X(err_subcode, title, ex)
Generate a report on the exception with default error code and given subcode.
static string CreateAbsolutePath(const string &path, ERelativeToWhat rtw=eRelativeToCwd)
Get an absolute path from some, possibly relative, path.
virtual bool Exists(void) const
Check existence of file.
@ eRelativeToExe
Relative to the executable's location.
@ eParam_NoThread
Do not use per-thread values.
uint64_t Uint8
8-byte (64-bit) unsigned integer
static TPid GetPid(void)
Get process identifier (pid) for the current process.
size_t total
Total memory usage.
static bool GetMemoryUsage(SMemoryUsage &usage)
Get current process memory usage.
virtual bool GetBool(const string §ion, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get boolean value of specified parameter name.
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
virtual int GetInt(const string §ion, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get integer value of specified parameter name.
virtual void EnumerateEntries(const string §ion, list< string > *entries, TFlags flags=fAllLayers) const
Enumerate parameter names for a specified section.
virtual string GetString(const string §ion, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
bool Set(const string §ion, const string &name, const string &value, TFlags flags=0, const string &comment=kEmptyStr)
Set the configuration parameter value.
@ eReturn
Return default value.
@ eErrPost
Log the error message and return default value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
ERW_Result
Result codes for I/O operations.
Int8 NcbiStreamposToInt8(NCBI_NS_STD::char_traits< char >::pos_type stream_pos)
Convert stream position to 64-bit int.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static streamsize Readsome(CNcbiIstream &is, CT_CHAR_TYPE *buf, streamsize buf_size)
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
bool NcbiStreamCopy(CNcbiOstream &os, CNcbiIstream &is)
Copy the entire contents of stream "is" to stream "os".
@ eRW_NotImplemented
Action / information is not available.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Error
Unrecoverable error, no retry possible.
@ eRW_Success
Everything is okay, I/O completed.
static bool StringToBool(const CTempString str)
Convert string to bool.
NCBI_NS_STD::string::size_type SIZE_TYPE
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
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 int strcmp(const char *s1, const char *s2)
String compare.
const char * g_GetNcbiString(ENcbiStrings what)
static string HtmlEncode(const CTempString str, THtmlEncode flags=fHtmlEnc_EncodeAll)
Encode a string for HTML.
static Uint8 StringToUInt8_DataSize(const CTempString str, TStringToNumFlags flags=0)
Convert string that can contain "software" qualifiers to Uint8.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
bool AStrEquiv(const Arg1 &x, const Arg2 &y, Pred pr)
Check equivalence of arguments using predicate.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static void TrimSuffixInPlace(string &str, const CTempString suffix, ECase use_case=eCase)
Trim suffix from a string (in-place)
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
static void TrimPrefixInPlace(string &str, const CTempString prefix, ECase use_case=eCase)
Trim prefix from a string (in-place)
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
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.
@ fConvErr_NoThrow
Do not throw an exception on error.
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
@ eNocase
Case insensitive compare.
void Reset(void)
Reset thread local storage.
void SetValue(TValue *value, FCleanup cleanup=0, void *cleanup_data=0, ENativeThreadCleanup native=eSkipCleanup)
Set value.
TValue * GetValue(void) const
Get the pointer previously stored by SetValue().
Int8 TSeconds
Number of seconds.
CTime & AddSecond(TSeconds seconds=1, EDaylight adl=eDaylightDefault)
Add specified seconds.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
CTime CurrentTime(CTime::ETimeZone tz=CTime::eLocal, CTime::ETimeZonePrecision tzp=CTime::eTZPrecisionDefault)
CTimeSpan DiffTimeSpan(const CTime &t) const
Difference in nanoseconds from specified time.
TSeconds DiffSecond(const CTime &t) const
Difference in seconds from specified time.
string AsString(const CTimeFormat &fmt=kEmptyStr) const
Transform time span to string.
@ eCurrent
Use current time. See also CCurrentTime.
@ eGmt
GMT (Greenwich Mean Time)
const TArgs & GetArgs(void) const
Get the const list of arguments.
virtual string Print(void) const
Print version information.
string Print(const string &appname, TPrintFlags flags=fPrintAll) const
Print version data, plain text.
string PrintXml(const string &appname, TPrintFlags flags=fPrintAll) const
Print version data, XML.
string PrintJson(const string &appname, TPrintFlags flags=fPrintAll) const
Print version data, JSON.
@ fPackageShort
Print package info, if available.
@ fVersionInfo
Print version info.
unsigned int
A callback function used to compare two keys in a database.
Definition of all error codes used in cgi (xcgi.lib).
const TYPE & Get(const CNamedParameterList *param)
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Static variables safety - create on demand, destroy on application termination.
String constants used in NCBI C/C++ toolkit.
void SuppressSystemMessageBox(TSuppressSystemMessageBox mode=fSuppress_Default)
Suppress popup messages on execution errors.
const char * s_ArgFullVersion
const char * s_ArgVersion
Defines unified interface to application:
#define GetProgramName
Avoid name clash with the NCBI C Toolkit.
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
Defines CRequestContext class for NCBI C++ diagnostic API.
Reader-writer based streams.
static SLJIT_INLINE sljit_ins st(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Process memory usage information, in bytes.
This class allows to add build info (date and tag) to application version.
static CS_CONTEXT * context
static wxAcceleratorEntry entries[3]