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

Function ISC_analyze_tcp

src/common/isc_file.cpp:451–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449
450
451bool ISC_analyze_tcp(tstring& file_name, tstring& node_name, bool need_file)
452{
453/**************************************
454 *
455 * I S C _ a n a l y z e _ t c p ( G E N E R I C )
456 *
457 **************************************
458 *
459 * Functional description
460 * Analyze a filename for a TCP node name on the front. If
461 * one is found, extract the node name, compute the residual
462 * file name, and return true. Otherwise return false.
463 *
464 **************************************/
465
466 // Avoid trivial case
467
468 if (!file_name.hasData())
469 return false;
470
471 // Scan file name looking for separator character
472
473 node_name.erase();
474 size p = npos;
475 if (file_name[0] == '[')
476 {
477 // [host]:file or [host]/port:file
478 p = file_name.find(']');
479 if (p == npos || p == file_name.length() - 1)
480 return false;
481 p = file_name.find(INET_FLAG, p + 1);
482 }
483 else
484 p = file_name.find(INET_FLAG);
485
486 if (p == npos || p == 0 || (need_file && (p == file_name.length() - 1)))
487 return false;
488
489 node_name = file_name.substr(0, p);
490
491#ifdef WIN_NT
492 // For Windows NT, insure that a single character node name does
493 // not conflict with an existing drive letter.
494
495 if (p == 1)
496 {
497 const ULONG dtype = GetDriveType((node_name + ":\\").c_str());
498 // Is it removable, fixed, cdrom or ramdisk?
499 if (dtype > DRIVE_NO_ROOT_DIR && (dtype != DRIVE_REMOTE || Config::getRemoteFileOpenAbility()))
500 {
501 // CVC: If we didn't match, clean our garbage or we produce side effects
502 // in the caller.
503 node_name.erase();
504 return false;
505 }
506 }
507#endif
508

Callers 2

analyzeFunction · 0.85
ISC_extract_hostFunction · 0.85

Calls 6

hasDataMethod · 0.45
eraseMethod · 0.45
findMethod · 0.45
lengthMethod · 0.45
substrMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected