mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:43:03 +01:00
Only strcmp and strncmp have common names across all plartforms. Cater for differences in strcasecmp/stricmp and strncasecmp/strnicmp.
This commit is contained in:
parent
b08175df09
commit
e5338ba1ed
@ -456,6 +456,7 @@ AC_CHECK_FUNCS(time times)
|
||||
AC_SEARCH_LIBS(gethostname,nsl)
|
||||
AC_SEARCH_LIBS(connect,socket)
|
||||
AC_CHECK_FUNCS(strcasecmp stricmp)
|
||||
AC_CHECK_FUNCS(strncasecmp strnicmp)
|
||||
if test "$ac_cv_func_strcasecmp" = "no" -a "$ac_cv_func_stricmp" = "no"; then
|
||||
dnl EKU: On SINIX-Z strcasecmp is in libresolv.
|
||||
AC_CHECK_LIB(resolv, strcasecmp,
|
||||
|
@ -28,8 +28,10 @@
|
||||
#ifndef INCLUDE_UTILS_PROTO_H
|
||||
#define INCLUDE_UTILS_PROTO_H
|
||||
|
||||
#include <string.h>
|
||||
#include "../common/classes/fb_string.h"
|
||||
|
||||
|
||||
namespace fb_utils
|
||||
{
|
||||
char* exact_name(char* const str);
|
||||
@ -42,6 +44,42 @@ namespace fb_utils
|
||||
bool readenv(const char* env_name, Firebird::string& env_value);
|
||||
bool readenv(const char* env_name, Firebird::PathName& env_value);
|
||||
int snprintf(char* buffer, size_t count, const char* format...);
|
||||
|
||||
// Warning: Only wrappers:
|
||||
|
||||
// ********************
|
||||
// s t r i c m p
|
||||
// ********************
|
||||
// Abstraction of incompatible routine names
|
||||
// for case insensitive comparison.
|
||||
inline int stricmp(const char* a, const char* b)
|
||||
{
|
||||
#if defined(HAVE_STRCASECMP)
|
||||
return ::strcasecmp(a, b);
|
||||
#elif defined(HAVE_STRICMP)
|
||||
return ::stricmp(a, b);
|
||||
#else
|
||||
#error dont know how to compare strings case insensitive on this system
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ********************
|
||||
// s t r n i c m p
|
||||
// ********************
|
||||
// Abstraction of incompatible routine names
|
||||
// for counted length and case insensitive comparison.
|
||||
inline int strnicmp(const char* a, const char* b, size_t count)
|
||||
{
|
||||
#if defined(HAVE_STRNCASECMP)
|
||||
return ::strncasecmp(a, b, count);
|
||||
#elif defined(HAVE_STRNICMP)
|
||||
return ::strnicmp(a, b, count);
|
||||
#else
|
||||
#error dont know how to compare counted length strings case insensitive on this system
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace fb_utils
|
||||
|
||||
#endif // INCLUDE_UTILS_PROTO_H
|
||||
|
@ -129,6 +129,8 @@
|
||||
#undef HAVE_TIMES
|
||||
#undef HAVE_STRCASECMP
|
||||
#define HAVE_STRICMP
|
||||
#undef HAVE_STRNCASECMP
|
||||
#define HAVE_STRNICMP
|
||||
#define HAVE_DIRNAME
|
||||
#undef HAVE_SIGACTION
|
||||
#undef HAVE_SETITIMER
|
||||
|
@ -1091,26 +1091,5 @@ static const TEXT* FB_LONG_MONTHS_UPPER[] =
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ======================================
|
||||
// BEGIN AUTOCONF ABSTRACTION LAYER
|
||||
// CVC: It's unacceptable that we pollute all the sources with the
|
||||
// #ifdef HAVE_<something> feature. While the function prototypes are
|
||||
// compatible or the extra params are ignored or we can pass default values,
|
||||
// we must wrap those functions in FB names.
|
||||
|
||||
#include <string.h>
|
||||
inline int fb_stricmp(const char* a, const char* b)
|
||||
{
|
||||
#if defined(HAVE_STRCASECMP)
|
||||
return strcasecmp(a, b);
|
||||
#elif defined(HAVE_STRICMP)
|
||||
return stricmp(a, b);
|
||||
#else
|
||||
#error dont know how to compare strings case insensitive on this system
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* JRD_COMMON_H */
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "../common/classes/alloc.h"
|
||||
#include "../common/classes/ClumpletWriter.h"
|
||||
#include "../jrd/ibase.h"
|
||||
#include "../common/utils_proto.h"
|
||||
|
||||
#ifdef SERVER_SHUTDOWN
|
||||
#include "../jrd/jrd_proto.h"
|
||||
@ -518,7 +519,7 @@ Service* SVC_attach(USHORT service_length,
|
||||
}
|
||||
|
||||
/* Check that the validated user has the authority to access this service */
|
||||
if (fb_stricmp(options.spb_user_name.c_str(), SYSDBA_USER_NAME))
|
||||
if (fb_utils::stricmp(options.spb_user_name.c_str(), SYSDBA_USER_NAME))
|
||||
{
|
||||
user_flag = SVC_user_any;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "../common/classes/fb_string.h"
|
||||
#include "../jrd/jrd_pwd.h"
|
||||
#endif
|
||||
#include "../common/utils_proto.h"
|
||||
|
||||
DATABASE DB = STATIC FILENAME "security2.fdb";
|
||||
|
||||
@ -257,7 +258,7 @@ SSHORT SECURITY_exec_line(ISC_STATUS* isc_status,
|
||||
|
||||
found = false;
|
||||
/* Do not allow SYSDBA user to be deleted */
|
||||
if (!fb_stricmp(io_user_data->user_name, SYSDBA_USER_NAME))
|
||||
if (!fb_utils::stricmp(io_user_data->user_name, SYSDBA_USER_NAME))
|
||||
ret = GsecMsg23;
|
||||
else {
|
||||
FOR U IN USERS WITH U.USER_NAME EQ io_user_data->user_name
|
||||
|
Loading…
Reference in New Issue
Block a user