本文整理汇总了C++中UCHAR函数的典型用法代码示例。如果您正苦于以下问题:C++ UCHAR函数的具体用法?C++ UCHAR怎么用?C++ UCHAR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UCHAR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_section
void print_section(Elf_data* data, int i)
{
unsigned int j;
while (++i < E_SHNUM(data))
if (SH_SIZE(data, i) > 0)
{
printf("Contents of section %s:\n", &data->strtab[SH_NAME(data, i)]);
j = 0;
while (j < SH_SIZE(data, i) && SH_OFFSET(data, i) + j < data->fsize)
{
if (j == 0)
printf(" %04x\t", (unsigned int)SH_ADDR(data, i) + j);
printf("%02x", *(UCHAR(data->data) + SH_OFFSET(data, i) + j));
++j;
if (j != 0 && j % 16 == 0)
{
print_char(UCHAR(data->data) + SH_OFFSET(data, i), j - 16, j);
printf("\n %04x\t", (unsigned int)SH_ADDR(data, i) + j);
}
else if (j != 0 && j % 4 == 0)
printf(" ");
}
print_char(UCHAR(data->data) + SH_OFFSET(data, i), j - (j % 16), j);
printf("\n");
}
}
示例2: match
int match(char *str, char *substr)
/*
**--------------------------------------------------------------
** Input: *str = string being searched
** *substr = substring being searched for
** Output: returns 1 if substr found in str, 0 if not
** Purpose: sees if substr matches any part of str
**
** (Not case sensitive)
**--------------------------------------------------------------
*/
{
int i,j;
/*** Updated 9/7/00 ***/
/* Fail if substring is empty */
if (!substr[0]) return(0);
/* Skip leading blanks of str. */
for (i=0; str[i]; i++)
if (str[i] != ' ') break;
/* Check if substr matches remainder of str. */
for (i=i,j=0; substr[j]; i++,j++)
if (!str[i] || UCHAR(str[i]) != UCHAR(substr[j]))
return(0);
return(1);
} /* end of match */
示例3: match
int match(char *str, char *substr)
//
// Input: str = character string being searched
// substr = sub-string being searched for
// Output: returns 1 if sub-string found, 0 if not
// Purpose: sees if a sub-string of characters appears in a string
// (not case sensitive).
//
{
int i,j;
// --- fail if substring is empty
if (!substr[0]) return(0);
// --- skip leading blanks of str
for (i = 0; str[i]; i++)
{
if (str[i] != ' ') break;
}
// --- check if substr matches remainder of str
for (i = i,j = 0; substr[j]; i++,j++)
{
if (!str[i] || UCHAR(str[i]) != UCHAR(substr[j])) return(0);
}
return(1);
}
示例4: samestr
/* Case-insensitive comparison of strings s1 and s2 */
int samestr(char *s1, char *s2)
{
int i;
for (i=0; UCHAR(s1[i]) == UCHAR(s2[i]); i++)
if (!s1[i+1] && !s2[i+1]) return(1);
return(0);
} /* End of samestr */
示例5: TkGetDoublePixels
int
TkGetDoublePixels(
Tcl_Interp *interp, /* Use this for error reporting. */
Tk_Window tkwin, /* Window whose screen determines conversion
* from centimeters and other absolute
* units. */
const char *string, /* String describing a number of pixels. */
double *doublePtr) /* Place to store converted result. */
{
char *end;
double d;
d = strtod((char *) string, &end);
if (end == string) {
goto error;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
}
switch (*end) {
case 0:
break;
case 'c':
d *= 10*WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
end++;
break;
case 'i':
d *= 25.4*WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
end++;
break;
case 'm':
d *= WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
end++;
break;
case 'p':
d *= (25.4/72.0)*WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
end++;
break;
default:
goto error;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
}
if (*end != 0) {
goto error;
}
*doublePtr = d;
return TCL_OK;
error:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad screen distance \"%s\"", string));
Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL);
return TCL_ERROR;
}
示例6: it_add
/*
* NAME: item->add()
* DESCRIPTION: add an item to a set
*/
static void it_add(itchunk **c, item **ri, char *ref, unsigned short ruleno, unsigned short offset, bool sort)
{
/*
* add item to set
*/
if (offset == UCHAR(ref[0]) << 1) {
offset = UCHAR(ref[1]); /* skip possible function at the end */
}
if (sort) {
while (*ri != (item *) NULL &&
((*ri)->ref < ref ||
((*ri)->ref == ref && (*ri)->offset <= offset))) {
if ((*ri)->ref == ref && (*ri)->offset == offset) {
return; /* already in set */
}
ri = &(*ri)->next;
}
} else {
while (*ri != (item *) NULL) {
if ((*ri)->ref == ref && (*ri)->offset == offset) {
return; /* already in set */
}
ri = &(*ri)->next;
}
}
*ri = it_new(c, ref, ruleno, offset, *ri);
}
示例7: treatmnt_readExpression
int treatmnt_readExpression(char* tok[], int ntoks)
//
// Input: tok[] = array of string tokens
// ntoks = number of tokens
// Output: returns an error code
// Purpose: reads a treatment expression from a tokenized line of input.
//
{
char s[MAXLINE+1];
char* expr;
int i, j, k, p;
MathExpr* equation; // ptr. to a math. expression //(5.0.010 - LR)
// --- retrieve node & pollutant
if ( ntoks < 3 ) return error_setInpError(ERR_ITEMS, "");
j = project_findObject(NODE, tok[0]);
if ( j < 0 ) return error_setInpError(ERR_NAME, tok[0]);
p = project_findObject(POLLUT, tok[1]);
if ( p < 0 ) return error_setInpError(ERR_NAME, tok[1]);
// --- concatenate remaining tokens into a single string
strcpy(s, tok[2]);
for ( i=3; i<ntoks; i++)
{
strcat(s, " ");
strcat(s, tok[i]);
}
// --- check treatment type
if ( UCHAR(s[0]) == 'R' ) k = 0;
else if ( UCHAR(s[0]) == 'C' ) k = 1;
else return error_setInpError(ERR_KEYWORD, tok[2]);
// --- start treatment expression after equals sign
expr = strchr(s, '=');
if ( expr == NULL ) return error_setInpError(ERR_KEYWORD, "");
else expr++;
// --- create treatment objects at node j if they don't already exist
if ( Node[j].treatment == NULL )
{
if ( !createTreatment(j) ) return error_setInpError(ERR_MEMORY, "");
}
// --- create a parsed expression tree from the string expr
// (getVariableIndex is the function that converts a treatment
// variable's name into an index number)
equation = mathexpr_create(expr, getVariableIndex);
if ( equation == NULL )
return error_setInpError(ERR_TREATMENT_EXPR, "");
// --- save the treatment parameters in the node's treatment object
Node[j].treatment[p].treatType = k;
Node[j].treatment[p].equation = equation;
return 0;
}
示例8: Ns_NextWord
char *
Ns_NextWord(char *line)
{
while (*line != '\0' && !isspace(UCHAR(*line))) {
++line;
}
while (*line != '\0' && isspace(UCHAR(*line))) {
++line;
}
return line;
}
示例9: while
//检查1245
BOOL CStringChecker::CheckDirName( LPCTSTR cStr )
{
// BOOL b;
// b = CheckEmpty(cStr);
// if(!b) return b;
// b = CheckWindowsRuler(cStr);
// if(!b) return b;
// b = CheckSpacePoint(cStr);
// if(!b) return b;
// b = CheckLength(cStr, 20);
// return b;
//char str[] = "^[a-zA-Z_\\xB0-\\xF7\\xA1-\\xFE][a-zA-Z0-9_\\xB0-\\xF7\\xA1-\\xFE]*$";
//BOOL b = RegexMatch(cStr, str);
BOOL b = TRUE;
LPCTSTR p = cStr;
unsigned char c = *p;
//if(c >= '0' && c <= '9') b =FALSE;
//else
while(c = *p++)
{
if((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_' )
{
if(
(c >= 0xB0 && c<= 0xF7 && UCHAR(*p) >= 0xA1 && UCHAR(*p) <= 0xFE)
|| (c == 0xA6 && UCHAR(*p) >= 0xA1 && UCHAR(*p) <= 0xFE)
)
{//属于汉字范围(16-87区)或希腊字母(6区)
p++;
continue;
}
if (c=='-') // 允许文件夹名称有中画线杠'-'
continue;
b = FALSE;
break;
}
}
if(CString(cStr).FindOneOf(CStringCheckerConfig::CheckFilter) != -1)
{//字符查找
b = FALSE;
}
if(!b)
{
SetLastErr(CStringCheckerConfig::CheckErrorDir);
return b;
}
b = CheckEmpty(cStr);
if(!b) return b;
b = CheckLength(cStr, 20);
return b;
}
示例10: compile_sprtext
a_sprite *
compile_sprtext (const a_fontdata *font, const char *text,
enum text_option topt, unsigned int maxwidth,
int offset)
{
unsigned int nspaces;
unsigned int text_width = 0;
check_message_is_drawable (font, text);
if (topt & T_FLUSHED_LEFT) { /* FLUSHED_LEFT or JUSTIFIED */
if (topt & T_FLUSHED_RIGHT) { /* JUSTIFIED */
text_width = compute_text_width (font, text, &nspaces);
if (nspaces == 0) { /* we cannot justify a text without spaces */
topt &= ~T_JUSTIFIED;
topt |= T_FLUSHED_LEFT;
}
}
} else { /* FLUSHED_RIGHT or CENTERED */
text_width = compute_text_width (font, text, 0);
if (topt & T_FLUSHED_RIGHT) /* FLUSHED_RIGHT */
offset -= (int) text_width;
else /* CENTERED */
offset -= (int) text_width/2;
}
new_sprprog ();
for (; *text; ++text) {
if (*text == ' ') {
if ((topt & T_JUSTIFIED) == T_JUSTIFIED) {
unsigned int off = (maxwidth - text_width) / nspaces;
offset += off;
text_width += off;
--nspaces;
} else
offset += font->width[' '];
} else {
/* ensure that the letter actually exists before drawing it */
if (font->width[UCHAR (*text)])
add_sprprog (compile_sprrle (font->upper_left[UCHAR (*text)], 0,
font->height, font->width[UCHAR (*text)],
font->line_size, xbuf),
offset);
offset += font->width[UCHAR (*text)];
}
}
if (topt & T_WAVING)
return end_sprprogwav ();
else
return end_sprprog ();
}
示例11: Tk_GetScreenMM
int
Tk_GetScreenMM(
Tcl_Interp *interp, /* Use this for error reporting. */
Tk_Window tkwin, /* Window whose screen determines conversion
* from centimeters and other absolute
* units. */
const char *string, /* String describing a screen distance. */
double *doublePtr) /* Place to store converted result. */
{
char *end;
double d;
d = strtod(string, &end);
if (end == string) {
error:
Tcl_AppendResult(interp, "bad screen distance \"", string, "\"", NULL);
return TCL_ERROR;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
}
switch (*end) {
case 0:
d /= WidthOfScreen(Tk_Screen(tkwin));
d *= WidthMMOfScreen(Tk_Screen(tkwin));
break;
case 'c':
d *= 10;
end++;
break;
case 'i':
d *= 25.4;
end++;
break;
case 'm':
end++;
break;
case 'p':
d *= 25.4/72.0;
end++;
break;
default:
goto error;
}
while ((*end != '\0') && isspace(UCHAR(*end))) {
end++;
}
if (*end != 0) {
goto error;
}
*doublePtr = d;
return TCL_OK;
}
示例12: init_thread_affinity_mask
mask_type init_thread_affinity_mask(
std::size_t num_thread
, bool numa_sensitive
)
{ // {{{
std::size_t num_of_cores = hardware_concurrency();
std::size_t affinity = num_thread % num_of_cores;
ULONG numa_nodes = 1;
if (GetNumaHighestNodeNumber(&numa_nodes))
++numa_nodes;
std::size_t num_of_cores_per_numa_node = num_of_cores / numa_nodes;
ULONGLONG node_affinity_mask = 0;
ULONGLONG mask = 0x01LL;
if (numa_sensitive) {
UCHAR numa_node = UCHAR(affinity % numa_nodes);
if (!GetNumaNodeProcessorMask(numa_node, &node_affinity_mask))
{
HPX_THROW_EXCEPTION(kernel_error
, "hpx::threads::windows_topology::init_thread_affinity_mask"
, boost::str(boost::format(
"failed to initialize thread %1% affinity mask")
% num_thread));
}
mask = least_significant_bit(node_affinity_mask) <<
(affinity / numa_nodes);
}
else {
UCHAR numa_node = UCHAR(get_numa_node_number(num_thread));
if (!GetNumaNodeProcessorMask(numa_node, &node_affinity_mask))
{
HPX_THROW_EXCEPTION(kernel_error
, "hpx::threads::windows_topology::init_thread_affinity_mask"
, boost::str(boost::format(
"failed to initialize thread %1% affinity mask")
% num_thread));
}
mask = least_significant_bit(node_affinity_mask) <<
(affinity % num_of_cores_per_numa_node);
}
while (!(mask & node_affinity_mask)) {
mask <<= 1LL;
if (0 == mask)
mask = 0x01LL;
}
return static_cast<mask_type>(mask);
} // }}}
示例13: strTemp
std::string CStringChecker::ReplaceDirName( LPCTSTR str, LPCTSTR strRe )
{
std::string strTemp(str);
std::string strReplace(strRe);
std::string strReturn;
if(strTemp.empty()) return strReturn;
for(int i = 0; i < (int)strTemp.length(); i++)
{
UCHAR c = strTemp[i];
BOOL b = TRUE;
if(c < 0xB0 && CString(CHAR(c)).FindOneOf(CStringCheckerConfig::CheckFilterReplace) != -1)
{//字符查找
b = FALSE;
}
else if(CString(strTemp.substr(i, 2).c_str()).FindOneOf(CStringCheckerConfig::CheckFilterReplace) != -1)
{//汉字查找
i++;
b = FALSE;
}
else if((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_' )
{
if(c >= 0xB0 && c<= 0xF7 && UCHAR(strTemp[i + 1]) >= 0xA1 && UCHAR(strTemp[i + 1]) <= 0xFE)
{//属于汉字范围
strReturn += strTemp.substr(i, 2);
i++;
continue;
}
if(c >= 0x80)
{//是全角符号
strReturn += strTemp.substr(i, 2);
i++;
continue;
}
b = FALSE;
}
if(b)
{//加上原字符
strReturn += c;
}
else
{//加上替换字符串
strReturn += strRe;
}
}
return strReturn;
}
示例14: NextBitmapWord
static int
NextBitmapWord(
ParseInfo *parseInfoPtr) /* Describes what we're reading and where we
* are in it. */
{
const char *src;
char *dst;
int c;
parseInfoPtr->wordLength = 0;
dst = parseInfoPtr->word;
if (parseInfoPtr->string != NULL) {
for (src = parseInfoPtr->string; isspace(UCHAR(*src)) || (*src == ',');
src++) {
if (*src == 0) {
return TCL_ERROR;
}
}
for ( ; !isspace(UCHAR(*src)) && (*src != ',') && (*src != 0); src++) {
*dst = *src;
dst++;
parseInfoPtr->wordLength++;
if (parseInfoPtr->wordLength > MAX_WORD_LENGTH) {
return TCL_ERROR;
}
}
parseInfoPtr->string = src;
} else {
for (c = GetByte(parseInfoPtr->chan); isspace(UCHAR(c)) || (c == ',');
c = GetByte(parseInfoPtr->chan)) {
if (c == EOF) {
return TCL_ERROR;
}
}
for ( ; !isspace(UCHAR(c)) && (c != ',') && (c != EOF);
c = GetByte(parseInfoPtr->chan)) {
*dst = c;
dst++;
parseInfoPtr->wordLength++;
if (parseInfoPtr->wordLength > MAX_WORD_LENGTH) {
return TCL_ERROR;
}
}
}
if (parseInfoPtr->wordLength == 0) {
return TCL_ERROR;
}
parseInfoPtr->word[parseInfoPtr->wordLength] = 0;
return TCL_OK;
}
示例15: Ns_StrToUpper
char *
Ns_StrToUpper(char *string)
{
char *s;
s = string;
while (*s != '\0') {
if (islower(UCHAR(*s))) {
*s = toupper(UCHAR(*s));
}
++s;
}
return string;
}