当前位置: 首页>>代码示例>>C++>>正文


C++ IS_PRINTABLE函数代码示例

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


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


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