MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / ISC_analyze_protocol

Function ISC_analyze_protocol

src/common/isc_file.cpp:390–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388
389
390bool ISC_analyze_protocol(const char* protocol, tstring& expanded_name, tstring& node_name,
391 const char* separator, bool need_file)
392{
393/**************************************
394 *
395 * I S C _ a n a l y z e _ p r o t o c o l
396 *
397 **************************************
398 *
399 * Functional description
400 * Analyze a filename for a known protocol prefix.
401 * If one is found, extract the node name, compute the residual
402 * file name, and return true. Otherwise return false.
403 *
404 **************************************/
405 node_name.erase();
406
407 const PathName prefix = PathName(protocol) + "://";
408
409 if (prefix.length() > expanded_name.length())
410 return false;
411
412 if (IgnoreCaseComparator::compare(prefix.c_str(), expanded_name.c_str(), prefix.length()) != 0)
413 return false;
414
415 PathName savedName = expanded_name;
416 expanded_name.erase(0, prefix.length());
417
418 if (separator) // this implies node name is expected!
419 {
420 size p = expanded_name.find_first_of('/');
421 if (p != 0 && p != npos)
422 {
423 node_name = p == npos ? expanded_name : expanded_name.substr(0, p);
424 expanded_name.erase(0, node_name.length() + 1);
425
426 if (node_name[0] == '[')
427 {
428 p = node_name.find_first_of(']');
429 if (p == npos)
430 p = 0;
431 }
432 else
433 p = 0;
434
435 p = node_name.find_first_of(':', p);
436 if (p != npos)
437 node_name[p] = *separator;
438 }
439 }
440
441 if (need_file && !expanded_name.hasData())
442 {
443 expanded_name = savedName;
444 return false;
445 }
446
447 return true;

Callers 1

analyzeFunction · 0.85

Calls 7

compareClass · 0.50
eraseMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45
find_first_ofMethod · 0.45
substrMethod · 0.45
hasDataMethod · 0.45

Tested by

no test coverage detected