本文整理汇总了C++中pg_strncasecmp函数的典型用法代码示例。如果您正苦于以下问题:C++ pg_strncasecmp函数的具体用法?C++ pg_strncasecmp怎么用?C++ pg_strncasecmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_strncasecmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is_select_command
/*
* Check whether the specified command is a SELECT (or VALUES).
*/
static bool
is_select_command(const char *query)
{
int wordlen;
/*
* First advance over any whitespace, comments and left parentheses.
*/
for (;;)
{
query = skip_white_space(query);
if (query[0] == '(')
query++;
else
break;
}
/*
* Check word length (since "selectx" is not "select").
*/
wordlen = 0;
while (isalpha((unsigned char) query[wordlen]))
wordlen += PQmblen(&query[wordlen], pset.encoding);
if (wordlen == 6 && pg_strncasecmp(query, "select", 6) == 0)
return true;
if (wordlen == 6 && pg_strncasecmp(query, "values", 6) == 0)
return true;
return false;
}
示例2: equivalent_locale
/*
* equivalent_locale()
*
* Best effort locale-name comparison. Return false if we are not 100% sure
* the locales are equivalent.
*/
static bool
equivalent_locale(const char *loca, const char *locb)
{
const char *chara = strrchr(loca, '.');
const char *charb = strrchr(locb, '.');
int lencmp;
/* If they don't both contain an encoding part, just do strcasecmp(). */
if (!chara || !charb)
return (pg_strcasecmp(loca, locb) == 0);
/*
* Compare the encoding parts. Windows tends to use code page numbers for
* the encoding part, which equivalent_encoding() won't like, so accept if
* the strings are case-insensitive equal; otherwise use
* equivalent_encoding() to compare.
*/
if (pg_strcasecmp(chara + 1, charb + 1) != 0 &&
!equivalent_encoding(chara + 1, charb + 1))
return false;
/*
* OK, compare the locale identifiers (e.g. en_US part of en_US.utf8).
*
* It's tempting to ignore non-alphanumeric chars here, but for now it's
* not clear that that's necessary; just do case-insensitive comparison.
*/
lencmp = chara - loca;
if (lencmp != charb - locb)
return false;
return (pg_strncasecmp(loca, locb, lencmp) == 0);
}
示例3: equivalent_locale
/*
* equivalent_locale()
*
* Best effort locale-name comparison. Return false if we are not 100% sure
* the locales are equivalent.
*
* Note: The encoding parts of the names are ignored. This function is
* currently used to compare locale names stored in pg_database, and
* pg_database contains a separate encoding field. That's compared directly
* in check_locale_and_encoding().
*/
static bool
equivalent_locale(int category, const char *loca, const char *locb)
{
const char *chara;
const char *charb;
char *canona;
char *canonb;
int lena;
int lenb;
/*
* If the names are equal, the locales are equivalent. Checking this
* first avoids calling setlocale() in the common case that the names
* are equal. That's a good thing, if setlocale() is buggy, for example.
*/
if (pg_strcasecmp(loca, locb) == 0)
return true;
/*
* Not identical. Canonicalize both names, remove the encoding parts,
* and try again.
*/
canona = get_canonical_locale_name(category, loca);
chara = strrchr(canona, '.');
lena = chara ? (chara - canona) : strlen(canona);
canonb = get_canonical_locale_name(category, locb);
charb = strrchr(canonb, '.');
lenb = charb ? (charb - canonb) : strlen(canonb);
if (lena == lenb && pg_strncasecmp(canona, canonb, lena) == 0)
return true;
return false;
}
示例4: complete_from_list
/**
* complete_from_list()
*
* Returns one of a fixed, NULL pointer terminated list of strings (if matching)
* in their defined order. This can be used if there are only a fixed number of
* SQL words that can appear at certain spot.
*/
static char *
complete_from_list(const char *text, int state)
{
static int string_length,
list_index,
matches;
static bool casesensitive;
const char *item;
/* Initialization */
if (state == 0)
{
list_index = 0;
string_length = strlen(text);
casesensitive = completion_case_sensitive;
matches = 0;
}
while ((item = completion_charpp[list_index++]))
{
/* First pass is case sensitive */
if (casesensitive && strncmp(text, item, string_length) == 0)
{
matches++;
return strdup(item);
}
/* Second pass is case insensitive, don't bother counting matches */
if (!casesensitive && pg_strncasecmp(text, item, string_length) == 0)
{
if (completion_case_sensitive)
return strdup(item);
else
/*
* If case insensitive matching was requested initially,
* adjust the case according to setting.
*/
return fb_strdup_keyword_case(item, text);
}
}
/*
* No matches found. If we're not case insensitive already, lets switch to
* being case insensitive and try again
*/
if (casesensitive && matches == 0)
{
casesensitive = false;
list_index = 0;
state++;
return complete_from_list(text, state);
}
/* If no more matches, return null. */
return NULL;
}
示例5: ParseVariableBool
/*
* Try to interpret value as boolean value. Valid values are: true,
* false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
*/
bool
ParseVariableBool(const char *value)
{
size_t len;
if (value == NULL)
return false; /* not set -> assume "off" */
len = strlen(value);
if (pg_strncasecmp(value, "true", len) == 0)
return true;
else if (pg_strncasecmp(value, "false", len) == 0)
return false;
else if (pg_strncasecmp(value, "yes", len) == 0)
return true;
else if (pg_strncasecmp(value, "no", len) == 0)
return false;
/* 'o' is not unique enough */
else if (pg_strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
return true;
else if (pg_strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
return false;
else if (pg_strcasecmp(value, "1") == 0)
return true;
else if (pg_strcasecmp(value, "0") == 0)
return false;
else
{
/* NULL is treated as false, so a non-matching value is 'true' */
psql_error("unrecognized Boolean value; assuming \"on\"\n");
return true;
}
}
示例6: transformRelOptions
/*
* Transform a relation options list (list of DefElem) into the text array
* format that is kept in pg_class.reloptions.
*
* This is used for three cases: CREATE TABLE/INDEX, ALTER TABLE SET, and
* ALTER TABLE RESET. In the ALTER cases, oldOptions is the existing
* reloptions value (possibly NULL), and we replace or remove entries
* as needed.
*
* If ignoreOids is true, then we should ignore any occurrence of "oids"
* in the list (it will be or has been handled by interpretOidsOption()).
*
* Note that this is not responsible for determining whether the options
* are valid.
*
* Both oldOptions and the result are text arrays (or NULL for "default"),
* but we declare them as Datums to avoid including array.h in reloptions.h.
*/
Datum
transformRelOptions(Datum oldOptions, List *defList,
bool ignoreOids, bool isReset)
{
Datum result;
ArrayBuildState *astate;
ListCell *cell;
/* no change if empty list */
if (defList == NIL)
return oldOptions;
/* We build new array using accumArrayResult */
astate = NULL;
/* Copy any oldOptions that aren't to be replaced */
if (DatumGetPointer(oldOptions) != 0)
{
ArrayType *array = DatumGetArrayTypeP(oldOptions);
Datum *oldoptions;
int noldoptions;
int i;
Assert(ARR_ELEMTYPE(array) == TEXTOID);
deconstruct_array(array, TEXTOID, -1, false, 'i',
&oldoptions, NULL, &noldoptions);
for (i = 0; i < noldoptions; i++)
{
text *oldoption = DatumGetTextP(oldoptions[i]);
char *text_str = VARDATA(oldoption);
int text_len = VARSIZE(oldoption) - VARHDRSZ;
/* Search for a match in defList */
foreach(cell, defList)
{
DefElem *def = lfirst(cell);
int kw_len = strlen(def->defname);
if (text_len > kw_len && text_str[kw_len] == '=' &&
pg_strncasecmp(text_str, def->defname, kw_len) == 0)
break;
}
if (!cell)
{
/* No match, so keep old option */
astate = accumArrayResult(astate, oldoptions[i],
false, TEXTOID,
CurrentMemoryContext);
}
}
示例7: SpecialTags
static void
SpecialTags(TParser * prs)
{
switch (prs->state->lencharlexeme)
{
case 8: /* </script */
if (pg_strncasecmp(prs->lexeme, "</script", 8) == 0)
prs->ignore = false;
break;
case 7: /* <script || </style */
if (pg_strncasecmp(prs->lexeme, "</style", 7) == 0)
prs->ignore = false;
else if (pg_strncasecmp(prs->lexeme, "<script", 7) == 0)
prs->ignore = true;
break;
case 6: /* <style */
if (pg_strncasecmp(prs->lexeme, "<style", 6) == 0)
prs->ignore = true;
break;
default:
break;
}
}
示例8: weekday_search
static int
weekday_search(const WeekDays *weekdays, const char *str, int len)
{
int i;
for (i = 0; i < 7; i++)
{
int n = strlen(weekdays->names[i]);
if (n > len)
continue; /* too short */
if (pg_strncasecmp(weekdays->names[i], str, n) == 0)
return i;
}
return -1; /* not found */
}
示例9: check_special_value
static bool
check_special_value(char *ptr, double *retval, char **endptr)
{
if (pg_strncasecmp(ptr, "NaN", 3) == 0)
{
*retval = get_float8_nan();
*endptr = ptr + 3;
return true;
}
else if (pg_strncasecmp(ptr, "Infinity", 8) == 0)
{
*retval = get_float8_infinity();
*endptr = ptr + 8;
return true;
}
else if (pg_strncasecmp(ptr, "-Infinity", 9) == 0)
{
*retval = -get_float8_infinity();
*endptr = ptr + 9;
return true;
}
return false;
}
示例10: ora_seq_prefix_search
static int
ora_seq_prefix_search(const char *name, STRING_PTR_FIELD_TYPE array[], int max)
{
int i;
if (!*name)
return -1;
for (i = 0; array[i]; i++)
{
if (pg_strncasecmp(name, array[i], max) == 0)
return i;
}
return -1; /* not found */
}
示例11: get_option_set
relopt_value *
get_option_set(relopt_value *options, int num_options, const char *opt_name)
{
int i;
int opt_name_len;
int cmp_len;
opt_name_len = strlen(opt_name);
for (i = 0; i < num_options; ++i)
{
cmp_len = options[i].gen->namelen > opt_name_len ? opt_name_len : options[i].gen->namelen;
if (options[i].isset && pg_strncasecmp(options[i].gen->name, opt_name, cmp_len) == 0)
return &options[i];
}
return NULL;
}
示例12: complete_from_query
/**
* complete_from_query()
*
* Dynamically generate tab completion candidates from the specified query
*/
static char *
complete_from_query(const char *text, int state)
{
static int list_index,
string_length;
static FBresult *result = NULL;
char *query;
if (state == 0)
{
string_length = strlen(text);
list_index = 0;
query = malloc(strlen(completion_charp) * 2 + 1);
if (completion_info_charp != NULL)
{
sprintf(query, completion_charp, string_length, text, completion_info_charp);
}
else
{
sprintf(query, completion_charp, string_length, text);
}
result = FQexecTransaction(fset.conn, query);
free(query);
}
/* Find something that matches */
if (result && FQresultStatus(result) == FBRES_TUPLES_OK)
{
const char *item;
while (list_index < FQntuples(result) &&
(item = FQgetvalue(result, list_index++, 0)))
{
if (pg_strncasecmp(text, item, string_length) == 0)
return strdup(item);
}
}
FQclear(result);
result = NULL;
return NULL;
}
示例13: scan_directory_ci
/*
* scan_pl specified directory for a case-insensitive match to fname
* (of length fnamelen --- fname may not be null terminated!). If found,
* copy the actual filename into canonname and return true.
*/
static bool
scan_directory_ci(
const char *dirname,
const char *fname,
int fnamelen,
char *canonname,
int canonnamelen)
{
bool found = false;
DIR* dirdesc;
struct dirent *direntry;
dirdesc = alloc_dir(dirname);
if (!dirdesc) {
ereport(LOG, (
errcode_file_access(),
errmsg("could not open directory \"%s\": %m", dirname)));
return false;
}
while ((direntry = read_dir(dirdesc, dirname)) != NULL) {
/*
* Ignore . and .., plus any other "hidden" files. This is a security
* measure to prevent access to files outside the timezone directory.
*/
if (direntry->d_name[0] == '.')
continue;
if (strlen(direntry->d_name) == fnamelen
&& pg_strncasecmp(direntry->d_name, fname, fnamelen) == 0) {
/* Found our match */
strlcpy(canonname, direntry->d_name, canonnamelen);
found = true;
break;
}
}
free_dir(dirdesc);
return found;
}
示例14: create_or_drop_keyword_generator
/**
* create_or_drop_keyword_generator()
*
* List of keywords which can follow CREATE or DROP
*/
static char *
create_or_drop_keyword_generator(const char *text, int state)
{
static int list_index,
string_length;
const char *name;
/* If this is the first time for this completion, init some values */
if (state == 0)
{
list_index = 0;
string_length = strlen(text);
}
/* find something that matches */
while ((name = words_after_create[list_index++].name))
{
if (pg_strncasecmp(name, text, string_length) == 0)
return fb_strdup_keyword_case(name, text);
}
/* if nothing matches, return NULL */
return NULL;
}
示例15: ParseVariableBool
/*
* Try to interpret "value" as a boolean value, and if successful,
* store it in *result. Otherwise don't clobber *result.
*
* Valid values are: true, false, yes, no, on, off, 1, 0; as well as unique
* prefixes thereof.
*
* "name" is the name of the variable we're assigning to, to use in error
* report if any. Pass name == NULL to suppress the error report.
*
* Return true when "value" is syntactically valid, false otherwise.
*/
bool
ParseVariableBool(const char *value, const char *name, bool *result)
{
size_t len;
bool valid = true;
/* Treat "unset" as an empty string, which will lead to error below */
if (value == NULL)
value = "";
len = strlen(value);
if (len > 0 && pg_strncasecmp(value, "true", len) == 0)
*result = true;
else if (len > 0 && pg_strncasecmp(value, "false", len) == 0)
*result = false;
else if (len > 0 && pg_strncasecmp(value, "yes", len) == 0)
*result = true;
else if (len > 0 && pg_strncasecmp(value, "no", len) == 0)
*result = false;
/* 'o' is not unique enough */
else if (pg_strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
*result = true;
else if (pg_strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
*result = false;
else if (pg_strcasecmp(value, "1") == 0)
*result = true;
else if (pg_strcasecmp(value, "0") == 0)
*result = false;
else
{
/* string is not recognized; don't clobber *result */
if (name)
psql_error("unrecognized value \"%s\" for \"%s\": boolean expected\n",
value, name);
valid = false;
}
return valid;
}