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

Function make_object_name

src/common/isc_sync.cpp:2706–2764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2704
2705#ifdef WIN_NT
2706static bool make_object_name(TEXT* buffer, size_t bufsize,
2707 const TEXT* object_name,
2708 const TEXT* object_type)
2709{
2710/**************************************
2711 *
2712 * m a k e _ o b j e c t _ n a m e ( W I N _ N T )
2713 *
2714 **************************************
2715 *
2716 * Functional description
2717 * Create an object name from a name and type.
2718 * Also replace the file separator with "_".
2719 *
2720 **************************************/
2721 char hostname[64];
2722 const int rc = snprintf(buffer, bufsize, object_name, ISC_get_host(hostname, sizeof(hostname)));
2723 if (size_t(rc) == bufsize || rc <= 0)
2724 {
2725 SetLastError(ERROR_FILENAME_EXCED_RANGE);
2726 return false;
2727 }
2728
2729 char& limit = buffer[bufsize - 1];
2730 limit = 0;
2731
2732 char* p;
2733 char c;
2734 for (p = buffer; c = *p; p++)
2735 {
2736 if (c == '/' || c == '\\' || c == ':')
2737 *p = '_';
2738 }
2739
2740 // We either append the full object type or produce failure.
2741 if (p >= &limit || p + strlen(object_type) > &limit)
2742 {
2743 SetLastError(ERROR_FILENAME_EXCED_RANGE);
2744 return false;
2745 }
2746
2747 strcpy(p, object_type);
2748
2749 // hvlad: windows file systems use case-insensitive file names
2750 // while kernel objects such as events use case-sensitive names.
2751 // Since we use root directory as part of kernel objects names
2752 // we must use lower (or upper) register for object name to avoid
2753 // misunderstanding between processes
2754 strlwr(buffer);
2755
2756 // CVC: I'm not convinced that if this call has no space to put the prefix,
2757 // we can ignore that fact, hence I changed that signature, too.
2758 if (!fb_utils::private_kernel_object_name(buffer, bufsize))
2759 {
2760 SetLastError(ERROR_FILENAME_EXCED_RANGE);
2761 return false;
2762 }
2763 return true;

Callers 3

SharedMemoryBaseMethod · 0.85
ISC_mutex_initFunction · 0.85
remapFileMethod · 0.85

Calls 3

ISC_get_hostFunction · 0.85
snprintfFunction · 0.70

Tested by

no test coverage detected