• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IS_PRINTABLE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IS_PRINTABLE函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_PRINTABLE函数的具体用法?C++ IS_PRINTABLE怎么用?C++ IS_PRINTABLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IS_PRINTABLE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dump_cols

static void dump_cols (ut8 *a, int as, ut8 *b, int bs, int w) {
	ut32 sz = R_MIN (as, bs);
	ut32 i, j;
	switch (w) {
	case 8:
		printf ("  offset     0 1 2 3 4 5 6 7 01234567    0 1 2 3 4 5 6 7 01234567\n");
		break;
	case 16:
		printf ("  offset     "
			"0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF    "
			"0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF\n");
		break;
	default:
		eprintf ("Invalid column width\n");
		return ;
	}
	for (i=0; i<sz; i+=w) {
		printf ("0x%08x%c ", i, (memcmp (a+i, b+i, 8))? ' ': '!');
		for (j=0; j<w; j++)
			printf ("%02x", a[i+j]);
		printf (" ");
		for (j=0; j<w; j++)
                	printf ("%c", IS_PRINTABLE (a[i+j])?a[i+j]:'.');
		printf ("   ");
		for (j=0; j<w; j++)
			printf ("%02x", b[i+j]);
		printf (" ");
		for (j=0; j<w; j++)
                	printf ("%c", IS_PRINTABLE (b[i+j])? b[i+j]:'.');
		printf ("\n");
	}
	if (as != bs)
		printf ("...\n");
}
开发者ID:Kakkoroid,项目名称:radare2,代码行数:34,代码来源:radiff2.c


示例2: r_print_format_nulltermstring

static void r_print_format_nulltermstring(const RPrint* p, const int len, int endian, int mode,
		const char* setval, ut64 seeki, ut8* buf, int i, int size) {
	if (MUSTSET) {
		int buflen = strlen ((const char *)buf+seeki), vallen = strlen(setval);
		char *newstring, *ons;
		newstring = ons = strdup(setval);
		if ((newstring[0] == '\"' && newstring[vallen-1] == '\"')
				|| (newstring[0] == '\'' && newstring[vallen-1] == '\'')) {
			newstring[vallen-1] = '\0';
			newstring++;
			vallen-=2;
		}
		if (vallen > buflen) {
			eprintf ("Warning: new string is longer than previous one\n");
		}
		p->cb_printf ("wx ");
		for (i=0;i<vallen;i++) {
			if (i < vallen-3 && newstring[i] == '\\' && newstring[i+1] == 'x') {
				p->cb_printf ("%c%c", newstring[i+2], newstring[i+3]);
				i+=3;
			} else {
				p->cb_printf ("%2x", newstring[i]);
			}
		}
		p->cb_printf (" @ 0x%08"PFMT64x"\n", seeki);
		free(ons);
	} else if (mode & R_PRINT_DOT) {
		int j = i;
		p->cb_printf ("\\\"", seeki);
		for (; j<len && ((size==-1 || size-- >0) && buf[j]) ; j++) {
			char ch = buf[j];
			if (ch == '"') {
				p->cb_printf ("\\\"");
			} else if (IS_PRINTABLE (ch)) {
				p->cb_printf ("%c", ch);
			} else p->cb_printf (".");
		}
		p->cb_printf ("\\\"");
	} else if (MUSTSEE) {
		int j = i;
		if (!SEEVALUE) p->cb_printf ("0x%08"PFMT64x" = ", seeki);
		for (; j<len && ((size==-1 || size-- >0) && buf[j]) ; j++) {
			if (IS_PRINTABLE (buf[j]))
				p->cb_printf ("%c", buf[j]);
			else p->cb_printf (".");
		}
	} else if (MUSTSEEJSON) {
		int j = i;
		p->cb_printf ("%d,\"string\":\"", seeki);
		for (; j<len && ((size==-1 || size-- >0) && buf[j]) ; j++) {
			if (IS_PRINTABLE (buf[j]))
				p->cb_printf ("%c", buf[j]);
			else p->cb_printf (".");
		}
		p->cb_printf ("\"}");
	}
}
开发者ID:mjdunn,项目名称:radare2,代码行数:57,代码来源:p_format.c


示例3: r_print_format_char

static void r_print_format_char(const RPrint* p, int endian, int mode,
		const char* setval, ut64 seeki, ut8* buf, int i, int size) {
	int elem = -1;
	if (size >= ARRAYINDEX_COEF) {
		elem = size/ARRAYINDEX_COEF-1;
		size %= ARRAYINDEX_COEF;
	}
	if (MUSTSET) {
		p->printf ("\"w %s\" @ 0x%08"PFMT64x"\n", setval, seeki);
	} else if (MUSTSEE) {
		p->printf ("0x%08"PFMT64x" = ", seeki);
		if (size==-1)
			p->printf (" %d ; '%c'", buf[i], buf[i], buf[i],
				IS_PRINTABLE (buf[i])?buf[i]:'.');
		else {
			p->printf ("[ ");
			while (size--) {
				if (elem == -1 || elem == 0) {
					p->printf ("%d ; '%c'", buf[i], buf[i], buf[i],
						IS_PRINTABLE (buf[i])?buf[i]:'.');
					if (elem == 0) elem = -2;
				}
				if (size != 0 && elem == -1)
					p->printf (", ");
				if (elem > -1) elem--;
				i++;
			}
			p->printf (" ]");
		}
	} else if (MUSTSEEJSON) {
		if (size==-1)
			p->printf ("\"%c\"", buf[i]);
		else {
			p->printf ("[ ");
			while (size--) {
				if (elem == -1 || elem == 0) {
					p->printf ("\"%c\"", buf[i]);
					if (elem == 0) elem = -2;
				}
				if (size != 0 && elem == -1)
					p->printf (", ");
				if (elem > -1) elem--;
				i++;
			}
			p->printf (" ]");
		}
		p->printf ("}");
	}
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:49,代码来源:p_format.c


示例4: radare_compare

// move it out // r_diff maybe?
static int radare_compare(RCore *core, const ut8 *f, const ut8 *d, int len) {
	int i, eq = 0;
	for (i=0; i<len; i++) {
		if (f[i]==d[i]) {
			eq++;
			continue;
		}
		r_cons_printf ("0x%08"PFMT64x" (byte=%.2d)   %02x '%c'  ->  %02x '%c'\n",
			core->offset+i, i+1,
			f[i], (IS_PRINTABLE(f[i]))?f[i]:' ',
			d[i], (IS_PRINTABLE(d[i]))?d[i]:' ');
	}
	eprintf ("Compare %d/%d equal bytes\n", eq, len);
	return len-eq;
}
开发者ID:ericfode,项目名称:radare2,代码行数:16,代码来源:cmd_cmp.c


示例5: is_string

static int is_string (const ut8 *buf, int size, int *len) {
	int i;
	if (size<1)
		return 0;
	if (size>3 && buf[0] &&!buf[1]&&buf[2]&&!buf[3]) {
		*len = 1; // XXX: TODO: Measure wide string length
		return 2; // is wide
	}
	for (i=0; i<size; i++) {
		if (!buf[i] && i>MINLEN) {
			*len = i;
			return 1;
		}
		if (buf[i]<32 || buf[i]>127) {
			// not ascii text
			return 0;
		}
		if (buf[i]==10||buf[i]==13||buf[i]==9) {
			continue;
		}
		if (!IS_PRINTABLE (buf[i])) {
			*len = i;
			return 0;
		}
	}
	*len = i;
	return 1;
}
开发者ID:idkwim,项目名称:radare2,代码行数:28,代码来源:data.c


示例6: r_name_validate_char

/* TODO: use a whitelist :) */
static int r_name_validate_char(const char ch) {
	if ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9'))
		return R_TRUE;
	switch (ch) {
		case '.':
		case '_':
			return R_TRUE;
	}
	return R_FALSE;
#if 0
	switch (ch) {
	case '!': case ':': case '{': case '}': case '$': case '=': case '*':
	case '/': case '+': case '|': case '&': case ';': case '~': case '"':
	case '>': case '<': case '#': case '%': case '(': case ')': case '`':
	case '\'': case '-': case ' ': case '\n': case '\t': case '[': case ']':
	case '@':
		return 0;
	default:
		if (((ch >= '0') && (ch <= '9')))
			return R_TRUE;
		if (!IS_PRINTABLE (ch))
			return R_FALSE;
	}
	return R_TRUE;
#endif
}
开发者ID:CodingFree,项目名称:radare2,代码行数:27,代码来源:name.c


示例7: r_str_ncpy

// Copy all printable characters from src to dst, copy all printable characters
// as '.'. 
R_API void r_str_ncpy(char *dst, const char *src, int n) {
	int i;
	for (i = 0; src[i] && n > 0; i++, n--) {
		dst[i] = IS_PRINTABLE (src[i])? src[i]: '.';
	}
	dst[i] = 0;
}
开发者ID:bigendiansmalls,项目名称:radare2,代码行数:9,代码来源:str.c


示例8: strlen

R_API char *r_str_unscape(char *buf) {
	char *ptr, *ret;
	int len = strlen (buf);
	ptr = ret = malloc (1+len*2);
	if (ptr == NULL)
		return NULL;
	for (;*buf;buf++,ptr++) {
		if (*buf=='\n') {
			*ptr = '\\';
			ptr++;
			*ptr = 'n';
		} else
		if (*buf=='\t') {
			*ptr = '\\';
			ptr++;
			*ptr = 't';
		} else
		if (IS_PRINTABLE (*buf)) {
			*ptr = *buf;
		} else break;
	}
	*ptr = 0;
	r_str_sanitize (ret);
	return ret;
}
开发者ID:pixilla,项目名称:radare2,代码行数:25,代码来源:str.c


示例9: r_print_format_hexpairs

static int r_print_format_hexpairs(const RPrint* p, int endian, int mode,
		const char* setval, ut64 seeki, ut8* buf, int size) {
	int j;
	if (MUSTSET) {
		p->printf ("?e pf X not yet implemented\n");
	} else if (MUSTSEE) {
		size = (size < 1) ? 1 : size;
		p->printf ("0x%08"PFMT64x" = ", seeki);
		j=0;
		for (; j<10; j++)
				p->printf ("%02x ", buf[j]);
		p->printf (" ... (");
		for (j=0; j<size; j++)
			if (IS_PRINTABLE (buf[j]))
				p->printf ("%c", buf[j]);
			else
				p->printf (".");
		p->printf (")");
	} else if (MUSTSEEJSON) {
		size = (size < 1) ? 1 : size;
		p->printf ("[ %d", buf[0]);
		j=1;
		for (; j<10; j++)
			p->printf (", %d", buf[j]);
		p->printf ("]}");
		return size;
	}
	return size;
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:29,代码来源:p_format.c


示例10: r_print_format_10bytes

static int r_print_format_10bytes(const RPrint* p, int mustset, const char* setval, ut64 seeki, ut64 addr, ut8* buf) {
	ut8 buffer[255];
	int j;

	if (mustset) {
		realprintf ("?e pf B not yet implemented\n");
	} else {
		if (!p->iob.read_at) {
			printf ("(cannot read memory)\n");
			return -1;
		} else
			p->iob.read_at (p->iob.io, (ut64)addr, buffer, 248);

		p->printf ("0x%08"PFMT64x" = ", seeki);

		for (j=0; j<10; j++)
			p->printf ("%02x ", buf[j]);

		p->printf (" ... (");
		for (j=0; j<10; j++)
			if (IS_PRINTABLE (buf[j]))
				p->printf ("%c", buf[j]);
			else
				p->printf (".");
		p->printf (")");
	}
	return 0;
}
开发者ID:svensvin,项目名称:radare2,代码行数:28,代码来源:p_format.c


示例11: r_print_format_nulltermwidestring

static void r_print_format_nulltermwidestring(const RPrint* p, const int len, int endian, int mode,
		const char* setval, ut64 seeki, ut8* buf, int i, int size) {
	if (MUSTSET) {
		int vallen = strlen(setval);
		char *newstring, *ons;
		newstring = ons = strdup(setval);
		if ((newstring[0] == '\"' && newstring[vallen-1] == '\"')
				|| (newstring[0] == '\'' && newstring[vallen-1] == '\'')) {
			newstring[vallen-1] = '\0';
			newstring++;
			vallen-=2;
		}
		if ((size = strlen (setval)) > r_wstr_clen((char*)(buf+seeki)))
			eprintf ("Warning: new string is longer than previous one\n");
		p->printf ("ww %s @ 0x%08"PFMT64x"\n", newstring, seeki);
		free(ons);
	} else if (MUSTSEE) {
		int j = i;
		p->printf ("0x%08"PFMT64x" = ", seeki);
		for (; j<len && ((size || size==-1) && buf[j]) ; j+=2) {
			if (IS_PRINTABLE (buf[j]))
				p->printf ("%c", buf[j]);
			else p->printf (".");
		}
	}
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:26,代码来源:p_format.c


示例12: r_hash_pcprint

/* returns 0-100 */
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
	const ut8 *end = buffer + len;
	int n;
	for (n=0; buffer<end; buffer++)
		if (IS_PRINTABLE (*buffer))
			n++;
	return ((100*n)/len);
}
开发者ID:DJHartley,项目名称:radare2,代码行数:9,代码来源:hash.c


示例13: r_mem_is_printable

R_API bool r_mem_is_printable(const ut8 *a, int la) {
	int i;
	for (i = 0; i < la; i++) {
		if (a[i] != '\n' && a[i] != '\t' && !IS_PRINTABLE (a[i])) {
			return false;
		}
	}
	return true;
}
开发者ID:aronsky,项目名称:radare2,代码行数:9,代码来源:mem.c


示例14: r_str_filter_zeroline

R_API void r_str_filter_zeroline(char *str, int len) {
	int i;
	for (i=0; str[i] && i<len; i++) {
		if (str[i]=='\n' || str[i]=='\r')
			break;
		if (!IS_PRINTABLE (str[i]))
			break;
	}
	str[i] = 0;
}
开发者ID:djpohly,项目名称:radare2,代码行数:10,代码来源:str.c


示例15: print_string_value

/* there may be unprintable characters in string - should escape them when printing */
static void print_string_value(char *string)
{
	int i;

	for (i = 0; string[i] != 0; i++) {
		if (IS_PRINTABLE(string[i]))
			printf("%c", string[i]);
		else
			printf("^%c", string[i] ^ 0x40);
	}
}
开发者ID:initng,项目名称:initng,代码行数:12,代码来源:active_db_print.c


示例16: r_core_visual_show_char

R_API void r_core_visual_show_char (RCore *core, char ch) {
	if (r_config_get_i (core->config, "scr.feedback")<2)
		return;
	if (!IS_PRINTABLE (ch))
		return;
	r_cons_gotoxy (1, 2);
	r_cons_printf (".---.\n");
	r_cons_printf ("| %c |\n", ch);
	r_cons_printf ("'---'\n");
	r_cons_flush ();
	r_sys_sleep (1);
}
开发者ID:xuwenbo,项目名称:radare2,代码行数:12,代码来源:visual.c


示例17: R_MIN

// XXX: redesign ? :)
R_API char *r_print_hexpair(RPrint *p, const char *str, int n) {
	const char *s, *lastcol = Color_WHITE;
	char *d, *dst = (char *)malloc ((strlen (str)+2)*32);
	int colors = p->flags & R_PRINT_FLAGS_COLOR;
	/* XXX That's hacky as shit.. but partially works O:) */
	/* TODO: Use r_print_set_cursor for win support */
	int cur = R_MIN (p->cur, p->ocur);
	int ocur = R_MAX (p->cur, p->ocur);
	int ch, i;

	if (p->cur_enabled && cur==-1)
		cur = ocur;
	ocur++;
#if CURDBG
	sprintf (dst, "(%d/%d/%d/%d)", p->cur_enabled, cur, ocur, n);
	d = dst+ strlen(dst);
#else
	d = dst;
#endif
	// XXX: overflow here
// TODO: Use r_cons primitives here
#define memcat(x,y) { memcpy(x,y,strlen(y));x+=strlen(y); }
	//for (s=str, d=dst; *s; s+=2, d+=2, i++) {
	for (s=str, i=0 ; *s; s+=2, d+=2, i++) {
		if (p->cur_enabled) {
			if (i==ocur-n)
				//memcat (d, "\x1b[27;47;30m");
				//memcat (d, "\x1b[0m");//27;47;30m");
				memcat (d, "\x1b[0m");
				memcat (d, lastcol);
			if (i>=cur-n && i<ocur-n)
				memcat (d, "\x1b[7m");
		}
		if (colors) {
			if (s[0]=='0' && s[1]=='0') lastcol = Color_GREEN;
			else if (s[0]=='7' && s[1]=='f') lastcol = Color_YELLOW;
			else if (s[0]=='f' && s[1]=='f') lastcol = Color_RED;
			else {
				ch = r_hex_pair2bin(s);
				//sscanf (s, "%02x", &ch); // XXX can be optimized
				if (IS_PRINTABLE (ch))
					lastcol = Color_MAGENTA;
			}
			memcat (d, lastcol);
		}
		memcpy (d, s, 2);
	}
	if (colors || p->cur_enabled)
		memcpy (d, Color_RESET, strlen (Color_RESET)+1);
	else *d = 0;
	return dst;
}
开发者ID:rchiossi,项目名称:radare2,代码行数:53,代码来源:print.c


示例18: r_print_byte

R_API void r_print_byte(RPrint *p, const char *fmt, int idx, ut8 ch) {
	ut8 rch = ch;
	if (!IS_PRINTABLE (ch) && fmt[0]=='%'&&fmt[1]=='c')
		rch = '.';
	r_print_cursor (p, idx, 1);
	//if (p->flags & R_PRINT_FLAGS_CURSOR && idx == p->cur) {
	if (p->flags & R_PRINT_FLAGS_COLOR) {
		char *pre = NULL;
		switch (ch) {
		case 0x00: pre = Color_GREEN; break;
		case 0x7F: pre = Color_YELLOW; break;
		case 0xFF: pre = Color_RED; break;
		default:
			if (IS_PRINTABLE (ch))
				pre = Color_MAGENTA;
		}
		if (pre) p->printf (pre);
		p->printf (fmt, rch);
		if (pre) p->printf (Color_RESET);
	} else p->printf (fmt, rch);
	r_print_cursor (p, idx, 0);
}
开发者ID:rchiossi,项目名称:radare2,代码行数:22,代码来源:print.c


示例19: r_hash_pcprint

/* returns 0-100 */
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
	const ut8 *end = buffer + len;
	int n;
	if (len < 1) {
		return 0;
	}
	for (n = 0; buffer < end; buffer++) {
		if (IS_PRINTABLE (*buffer)) {
			n++;
		}
	}
	return ((100 * n) / len);
}
开发者ID:ghostbar,项目名称:radare2.deb,代码行数:14,代码来源:hash.c


示例20: r_print_format_char

static void r_print_format_char(const RPrint* p, int endian, int mustset,
		const char* setval, ut64 seeki, ut8* buf, int i, int size) {
	if (mustset) {
		realprintf ("\"w %s\" @ 0x%08"PFMT64x"\n", setval, seeki);
	} else {
		p->printf ("0x%08"PFMT64x" = ", seeki);
		if (size==-1)
		p->printf ("%d ; %d ; '%c'", buf[i], buf[i],
			IS_PRINTABLE (buf[i])?buf[i]:0);
		else {
			p->printf ("[ %d ; %d ; '%c'", buf[i], buf[i],
				IS_PRINTABLE (buf[i])?buf[i]:0);
			size--;
			i++;
			while (size--) {
				p->printf (", %d ; %d ; '%c'", buf[i], buf[i],
					IS_PRINTABLE (buf[i])?buf[i]:0);
				i++;
			}
			p->printf (" ]");
		}
	}
}
开发者ID:svensvin,项目名称:radare2,代码行数:23,代码来源:p_format.c



注:本文中的IS_PRINTABLE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IS_PWR_PVD_LEVEL函数代码示例发布时间:2022-05-30
下一篇:
C++ IS_PLAYER_GUID函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap