CMS 3D CMS Logo

Namespaces | Functions
OnlineDBOutputService.cc File Reference
#include "CondCore/DBOutputService/interface/OnlineDBOutputService.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include <curl/curl.h>

Go to the source code of this file.

Namespaces

 cond
 

Functions

static size_t getHtmlCallback (void *contents, size_t size, size_t nmemb, void *ptr)
 
bool getInfoFromService (const std::string &urlString, std::string &info)
 
cond::Time_t cond::getLastLumiFromOMS (const std::string &omsServiceUrl)
 
cond::Time_t cond::getLatestLumiFromFile (const std::string &fileName)
 

Function Documentation

◆ getHtmlCallback()

static size_t getHtmlCallback ( void *  contents,
size_t  size,
size_t  nmemb,
void *  ptr 
)
static

Definition at line 6 of file OnlineDBOutputService.cc.

6  {
7  // Cast ptr to std::string pointer and append contents to that string
8  ((std::string*)ptr)->append((char*)contents, size * nmemb);
9  return size * nmemb;
10 }

References relmon_rootfiles_spy::contents, findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getInfoFromService().

◆ getInfoFromService()

bool getInfoFromService ( const std::string &  urlString,
std::string &  info 
)

Definition at line 12 of file OnlineDBOutputService.cc.

12  {
13  CURL* curl;
14  CURLcode res;
15  std::string htmlBuffer;
16  char errbuf[CURL_ERROR_SIZE];
17 
18  curl = curl_easy_init();
19  bool ret = false;
20  if (curl) {
21  struct curl_slist* chunk = nullptr;
22  chunk = curl_slist_append(chunk, "content-type:document/plain");
23  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
24  curl_easy_setopt(curl, CURLOPT_URL, urlString.c_str());
25  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, getHtmlCallback);
26  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &htmlBuffer);
27  curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
28  res = curl_easy_perform(curl);
29  if (CURLE_OK == res) {
30  info = htmlBuffer;
31  ret = true;
32  } else {
33  size_t len = strlen(errbuf);
34  fprintf(stderr, "\nlibcurl: (%d) ", res);
35  if (len)
36  fprintf(stderr, "%s%s", errbuf, ((errbuf[len - 1] != '\n') ? "\n" : ""));
37  else
38  fprintf(stderr, "%s\n", curl_easy_strerror(res));
39  }
40  curl_easy_cleanup(curl);
41  }
42  return ret;
43 }

References getHtmlCallback(), info(), runTheMatrix::ret, submitPVResolutionJobs::stderr, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::getLastLumiFromOMS().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
relmon_rootfiles_spy.contents
contents
Definition: relmon_rootfiles_spy.py:129
getHtmlCallback
static size_t getHtmlCallback(void *contents, size_t size, size_t nmemb, void *ptr)
Definition: OnlineDBOutputService.cc:6
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
submitPVResolutionJobs.stderr
stderr
Definition: submitPVResolutionJobs.py:45
res
Definition: Electron.h:6
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443