FACT++  1.0
void ServiceList::ProcessServiceList ( DimInfo info)
private

Process an update of the SERVICE_LIST service of the given DimInfo

All services found are stored in the fServiceList map to be accessible through the server name. Their format is format is stored in the fFormatList. Note, that the list if only updated. So it will also contain services which are not available anymore. For an up-to-date list of service use fServiceList

Only entries matching the fType data member are stored.

Todo:
Make sure that we do not receive +/- updates on the SERVICE_LIST like on the SERVER_LIST

Definition at line 256 of file ServiceList.cc.

References buffer, fDescriptionList, fDescriptionMap, fFormatList, fServiceList, fType, DimInfo::getName(), DimInfo::getString(), Description::SplitDescription(), str, and type.

Referenced by CreateFMT(), and infoHandler().

257 {
258  const string str = info.getString();
259  if (str.empty())
260  return;
261 
262  // Get the name of the service
263  string buffer = info.getName();
264 
265  if (buffer.find("SERVICE_DESC")!=buffer.length()-12)
266  {
267  // Get the server name from the service name
268  const string server = buffer.substr(0, buffer.find_first_of('/'));
269 
270  // Initialize the entry with an empty list
271  if (str[0]!='+')
272  fServiceList[server] = vector<string>();
273 
274  // For easy and fast access get the corresponding reference
275  vector<string> &list = fServiceList[server];
276 
277  // Tokenize the stream into lines
278  stringstream stream(str);
279  while (getline(stream, buffer, '\n'))
280  {
281  if (buffer.empty())
282  continue;
283 
284  // Get the type and compare it with fType
285  const string type = buffer.substr(buffer.find_last_of('|')+1);
286  if (type!=fType)
287  continue;
288 
289  // Get format, name and command name
290  const string fmt = buffer.substr(buffer.find_first_of('|')+1, buffer.find_last_of('|')-buffer.find_first_of('|')-1);
291  const string name = buffer.substr(buffer.find_first_of('/')+1, buffer.find_first_of('|')-buffer.find_first_of('/')-1);
292  const string cmd = buffer.substr(0, buffer.find_first_of('|'));
293 
294  // Add name the the list
295  list.push_back(name);
296 
297  // Add format to the list
298  fFormatList[cmd] = fmt;
299  }
300  }
301  else
302  {
303  fDescriptionMap.clear();
304 
305  stringstream stream(str);
306  while (getline(stream, buffer, '\n'))
307  {
308  if (buffer.empty())
309  continue;
310 
311  const vector<Description> v = Description::SplitDescription(buffer);
312 
313  const string svc = v[0].name;
314 
315  fDescriptionMap[svc] = v[0].comment;
316  fDescriptionList[svc] = vector<Description>(v.begin()+1, v.end());
317  }
318  }
319 }
char * getString()
Definition: dic.hxx:108
char str[80]
Definition: test_client.c:7
StringMap fFormatList
A map storing server names and vector with all their available commands.
Definition: ServiceList.h:31
ServiceMap fServiceList
A map storing server names and a DimInfo for their SERVICE_LIST.
Definition: ServiceList.h:30
int type
const std::string fType
A DimInfo to retrieve the SERVER_LIST from teh DNS server.
Definition: ServiceList.h:27
DescriptionMap fDescriptionList
A map storing all descriptions for commands and services.
Definition: ServiceList.h:33
static std::vector< Description > SplitDescription(const std::string &buffer)
Definition: Description.cc:82
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
StringMap fDescriptionMap
A map storing all commands and their format strings.
Definition: ServiceList.h:32
char * getName()
Definition: dic.hxx:101

+ Here is the call graph for this function:

+ Here is the caller graph for this function: