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


C++ eprintf函数代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
	char buffer[MAX_PACKET_SIZE];
	static struct sockaddr_in addr;
	int rc, i, count;
	struct timeval t1, t2, dt;


	KICK(argc < 3, "incorrect usage\n"
	"Usage:\n"
	"./linphone_proxy <local_ip> <remote_ip>\n");
	local_ip = argv[1];
	remote_ip = argv[2];

	add_poll(&fds[0], STDIN_FILENO);

	proxy_to_linphone_socket = create_socket(SOCK_DGRAM, SIP_LINPHONE);
	init_sockaddr(&proxy_to_linphone_addr, "127.0.0.1", SIP_PORT);
	add_poll(&fds[1], proxy_to_linphone_socket);
	eprintf("created proxy_to_linphone SIP socket   SRC:localhost:%d - DST:localhost:%d\n",
			SIP_LINPHONE, SIP_PORT);

	proxy_to_proxy_socket = create_socket(SOCK_DGRAM, SIP_PROXY);
	init_sockaddr(&proxy_to_proxy_addr, remote_ip, SIP_PROXY);
	add_poll(&fds[2], proxy_to_proxy_socket);
	eprintf("created proxy_to_sip SIP socket        SRC:localhost:%d - DST:%s:%d\n",
			SIP_PROXY, remote_ip, SIP_PROXY);

	proxy_to_linphone_data_socket = create_socket(SOCK_DGRAM, DATA_LINPHONE);
	init_sockaddr(&proxy_to_linphone_data_addr, "127.0.0.1", DATA_PORT);
	add_poll(&fds[3], proxy_to_linphone_data_socket);
	eprintf("created proxy_to_linphone DATA socket  SRC:localhost:%d - DST:localhost:%d\n",
			DATA_LINPHONE, DATA_PORT);

	proxy_to_proxy_data_socket = create_socket(SOCK_DGRAM, DATA_PROXY);
	init_sockaddr(&proxy_to_proxy_data_addr, remote_ip, DATA_PROXY);
	add_poll(&fds[4], proxy_to_proxy_data_socket);
	eprintf("created proxy_to_proxy DATA socket     SRC:localhost:%d - DST:%s:%d\n",
			DATA_PROXY, remote_ip, DATA_PROXY);

	manager_socket = create_socket(SOCK_DGRAM, MANAGER_PORT);
	init_sockaddr(&manager_addr, "0.0.0.0", MANAGER_PORT);
	add_poll(&fds[5], manager_socket);
	eprintf("created manager socket                 SRC:localhost:%d - DST:0.0.0.0:0\n",
			MANAGER_PORT);

	while (1) {
		rc = poll(fds, NUM_FDS, -1);
		DIE(-1 == rc, "poll");

		for (i = 0; i < NUM_FDS; i++) {
			if (0 == fds[i].revents) {
				continue;
			}

			switch(i) {
			/* receive line from console */
			case 0:
				break;

			/* receive SIP packet from linphone */
			case 1:
				gettimeofday_safe(&t1);
				count = recv_msg(fds[i].fd, &proxy_to_linphone_addr, buffer);

				if (begins_with(buffer, "INVITE")) {
					copy_packet(&out_invite, buffer, count);
					//printf("captured INVITE packet:\n%s\n", out_invite.buffer);
				} else if (begins_with(buffer, "ACK")) {
					copy_packet(&out_ack, buffer, count);
					//printf("captured ACK packet:\n%s\n", out_ack.buffer);
				} else if (strstr(buffer, "200 OK") && strstr(buffer, "OPTIONS" )) {
					copy_packet(&out_op_ok, buffer, count);
					//printf("captured OPTIONS OK packet:\n%s\n", out_op_ok.buffer);
				}

				send_msg(proxy_to_proxy_socket, &proxy_to_proxy_addr, buffer, count);
				gettimeofday_safe(&t2);
				time_diff(&t1, &t2, &dt);
				printf("time case 1: %lu.%06lu\n", dt.tv_sec, dt.tv_usec);

				break;

			/* receive SIP packet from proxy */
			case 2:
				gettimeofday_safe(&t1);
				count = recv_msg(fds[i].fd, &addr, buffer);
				send_msg(proxy_to_linphone_socket, &proxy_to_linphone_addr, buffer, count);
				gettimeofday_safe(&t2);
				time_diff(&t1, &t2, &dt);
				printf("time case 2: %lu.%06lu\n", dt.tv_sec, dt.tv_usec);
				break;

			/* receive data packet from linphone */
			case 3:
				gettimeofday_safe(&t1);
				count = recv_msg(fds[i].fd, &proxy_to_linphone_data_addr, buffer);
				send_msg(proxy_to_proxy_data_socket, &proxy_to_proxy_data_addr, buffer, count);
				gettimeofday_safe(&t2);
				time_diff(&t1, &t2, &dt);
//.........这里部分代码省略.........
开发者ID:cristianbercaru,项目名称:linphone_proxy,代码行数:101,代码来源:main.c

示例2: usage

static void
usage(void)
{
	eprintf("usage: %s [name]\n", argv0);
}
开发者ID:rovaughn,项目名称:distro,代码行数:5,代码来源:hostname.c

示例3: main

int main(int argc, char **argv) {
	const char *addr = NULL;
	RCore *c, *c2;
	RDiff *d;
	ut8 *bufa, *bufb;
	int o, sza, szb, /*diffmode = 0,*/ delta = 0;
	int mode = MODE_DIFF;
	int diffops = 0;
	int threshold = -1;
	int gdiff_mode = 0;
	double sim;

	while ((o = getopt (argc, argv, "a:b:CDnpg:Ojrhcdsvxt:")) != -1) {
		switch (o) {
		case 'a':
			arch = optarg;
			break;
		case 'b':
			bits = atoi (optarg);
			break;
		case 'p':
			useva = false;
			break;
		case 'r':
			diffmode = 'r';
			break;
		case 'g':
			mode = MODE_GRAPH;
			addr = optarg;
			break;
		case 'c':
			showcount = 1;
			break;
		case 'C':
			mode = MODE_CODE;
			gdiff_mode++;
			break;
		case 'n':
			showbare = true;
			break;
		case 'O':
			diffops = 1;
			break;
		case 't':
			threshold = atoi (optarg);
			printf ("%s\n", optarg);
			break;
		case 'd':
			delta = 1;
			break;
		case 'D':
			disasm = true;
			break;
		case 'h':
			return show_help (1);
		case 's':
			mode = MODE_DIST;
			break;
		case 'x':
			mode = MODE_COLS;
			break;
		case 'v':
			printf ("radiff2 v"R2_VERSION"\n");
			return 0;
		case 'j':
			diffmode = 'j';
			break;
		default:
			return show_help (0);
		}
	}
	
	if (argc<3 || optind+2>argc)
		return show_help (0);

	if (optind<argc) {
		file = argv[optind];
	} else {
		file = NULL;
	}
	
	if (optind+1<argc) {
		file2 = argv[optind+1];
	} else {
		file2 = NULL;
	}

	switch (mode) {
	case MODE_GRAPH:
	case MODE_CODE:
		c = opencore (file);
		if (!c) eprintf ("Cannot open '%s'\n", r_str_get (file));
		c2 = opencore (file2);
		if (!c || !c2) {
			eprintf ("Cannot open '%s'\n", r_str_get (file2));
			return 1;
		}
		if (arch) {
			r_config_set (c->config, "asm.arch", arch);
			r_config_set (c2->config, "asm.arch", arch);
//.........这里部分代码省略.........
开发者ID:0xABD,项目名称:radare2,代码行数:101,代码来源:radiff2.c

示例4: r_core_visual_panels

R_API int r_core_visual_panels(RCore *core) {
#define OS_INIT() ostack.size = 0; ostack.panels[0] = 0;
#define OS_PUSH(x) if (ostack.size<LIMIT) {ostack.panels[++ostack.size]=x;}
#define OS_POP() ((ostack.size>0)? ostack.panels[--ostack.size]:0)
	int okey, key, wheel;
	int w, h;
	int asm_comments = 0;
	int asm_bytes = 0;
	n_panels = 0;
	panels = NULL;
	callgraph = 0;
	_core = core;

	OS_INIT();
	w = r_cons_get_size (&h);
	can = r_cons_canvas_new (w, h);
	can->linemode = 1;
	can->color = r_config_get_i (core->config, "scr.color");
	// disable colors in disasm because canvas doesnt supports ansi text yet
	r_config_set_i (core->config, "scr.color", 0);
	//can->color = 0; 
	if (!can) {
		eprintf ("Cannot create RCons.canvas context\n");
		return R_FALSE;
	}
	n_panels = bbPanels (core, &panels);
	if (!panels) {
		r_config_set_i (core->config, "scr.color", can->color);
		free (can);
		return R_FALSE;
	}

	reloadPanels (core);

	asm_comments = r_config_get_i (core->config, "asm.comments");
	r_config_set_i (core->config, "asm.comments", 0);
	asm_bytes = r_config_get_i (core->config, "asm.bytes");
	r_config_set_i (core->config, "asm.bytes", 0);

repeat:
	core->cons->event_data = core;
	core->cons->event_resize = \
		(RConsEvent)r_core_panels_refresh;
	w = r_cons_get_size (&h);
	Layout_run (panels);
	r_core_panels_refresh (core);
	wheel = r_config_get_i (core->config, "scr.wheel");
	if (wheel)
		r_cons_enable_mouse (R_TRUE);

	// r_core_graph_inputhandle()
	okey = r_cons_readchar ();
	key = r_cons_arrow_to_hjkl (okey);

	switch (key) {
	case ' ':
	case '\n':
		if (menu_y) {
			const char *action = menus_sub[menu_x][menu_y-1];
			eprintf ("ACTION %s\n", action);
			if (strstr (action, "New")) {
				int i;
				// add new panel for testing
				for (i=0; panels[i].text; i++) {
					// find last panel
				}
				panels[i].text = strdup ("Test");
				panels[i].cmd = r_str_newf ("pxW $r-2");
				panels[i].addr = core->offset;
				panels[i].type = PANEL_TYPE_FRAME;
				i++;
				n_panels++;
				panels[i].text = NULL;
			}
			if (strstr (action, "Quit")) {
				goto beach;
			}
		}
		break;
	case '?':
		r_cons_clear00 ();
		r_cons_printf ("Visual Ascii Art Panels:\n"
		" !    run r2048 game\n"
		" .    - center graph to the current node\n"
		" :    - run r2 command in prompt\n"
		" hl   - toggle scr.color\n"
		" HL   - move vertical column split\n"
		" JK   - select prev/next panels\n"
		" jk   - scroll/select menu\n"
		" q    - quit, back to visual mode\n"
		);
		r_cons_flush ();
		r_cons_any_key (NULL);
		break;
	case ':':
		core->vmode = R_FALSE;
		r_core_visual_prompt_input (core);
		core->vmode = R_TRUE;
		break;
	case 'C':
//.........这里部分代码省略.........
开发者ID:0x2F,项目名称:radare2,代码行数:101,代码来源:panels.c

示例5: main

int main(int argc, char **argv) {
    int         maxtokens = 50;
    int         ntokens, verbose = 0, i;
    Tokenizer  *tkz;
    const char *sep;
    char        str[100];

#ifdef NDEBUG
    eprintf("[email protected]%s:%d:"
            "Unit tests must be compiled without -DNDEBUG flag\n",
            __FILE__, __LINE__);
#endif

    switch (argc) {
    case 1:
        break;
    case 2:
        if(strncmp(argv[1], "-v", 2) != 0)
            eprintf("usage: xtokenizer [-v]\n");
        verbose = 1;
        break;
    default:
        eprintf("usage: xtokenizer [-v]\n");
    }

    tkz = Tokenizer_new(maxtokens);
    assert(Tokenizer_ntokens(tkz) == 0);
    strcpy(str, "; now;   \t: \t is       ::the  ,time  \n,");
    sep = ";:,";
    if(verbose) {
        printf("sep=\"%s\"\n", sep);
        printf("str=\"%s\"\n", str);
    }
    ntokens = Tokenizer_split(tkz, str, sep);
    if(verbose) {
        printf("ntokens=%d\n", ntokens);
        fflush(stdout);
    }
    assert(ntokens == Tokenizer_ntokens(tkz));
    assert(ntokens == 5);
    assert(strcmp(Tokenizer_token(tkz, 0), " now") == 0);
    assert(strcmp(Tokenizer_token(tkz, 1), "   \t") == 0);
    assert(strcmp(Tokenizer_token(tkz, 2), " \t is       ") == 0);
    assert(strcmp(Tokenizer_token(tkz, 3), "the  ") == 0);
    assert(strcmp(Tokenizer_token(tkz, 4), "time  \n") == 0);

    if(verbose) {
        for(i = 0; i < ntokens; ++i)
            printf("%4d \"%s\"\n", i, Tokenizer_token(tkz, i));
    }

    ntokens = Tokenizer_strip(tkz, " \t\n");
    assert(ntokens == 4);
    assert(strcmp(Tokenizer_token(tkz, 0), "now") == 0);
    assert(strcmp(Tokenizer_token(tkz, 1), "is") == 0);
    assert(strcmp(Tokenizer_token(tkz, 2), "the") == 0);
    assert(strcmp(Tokenizer_token(tkz, 3), "time") == 0);

    assert(Tokenizer_find(tkz, "now") == 0);
    assert(Tokenizer_find(tkz, "is") == 1);
    assert(Tokenizer_find(tkz, "the") == 2);
    assert(Tokenizer_find(tkz, "time") == 3);
    assert(Tokenizer_find(tkz, "not there") == ntokens);

    if(verbose) {
        printf("after stripping extraneous chars, ntokens is %d\n", ntokens);
        for(i = 0; i < ntokens; ++i)
            printf("%4d \"%s\"\n", i, Tokenizer_token(tkz, i));
        printf("Tokenizer_print:\n");
        Tokenizer_print(tkz, stdout);
    }

    strcpy(str, "afasf");
    ntokens = Tokenizer_split(tkz, str, ":");
    assert(ntokens == 1);

    strcpy(str, "");
    ntokens = Tokenizer_split(tkz, str, ":");
    assert(ntokens == 0);

    Tokenizer_free(tkz);

    unitTstResult("Tokenizer", "OK");
    fflush(stdout);

    return 0;
}
开发者ID:alanrogers,项目名称:ldpsiz,代码行数:87,代码来源:xtokenizer.c

示例6: uiAskNextVolume

bool uiAskNextVolume(wchar *VolName,size_t MaxSize)
{
    eprintf(St(MAskNextVol),VolName);
    return Ask(St(MContinueQuit))!=2;
}
开发者ID:Cpasjuste,项目名称:nzbm,代码行数:5,代码来源:uiconsole.cpp

示例7: r_bin_mdmp_init_directory

int r_bin_mdmp_init_directory(struct r_bin_mdmp_obj *obj, PMINIDUMP_DIRECTORY dir)
{
	size_t i, j, k;
	void *p, *m;
	switch (dir->StreamType) {
	case UnusedStream:
		break;
	case ThreadListStream:
		if (r_bin_mdmp_directory_check(obj, dir, sizeof(MINIDUMP_THREAD), "ThreadListStream")) {
			r_list_append(obj->threads, obj->b->buf + dir->Location.Rva);
		};
		break;
	case ModuleListStream:
		if (r_bin_mdmp_directory_check(obj, dir, sizeof(MINIDUMP_MODULE_LIST), "ModuleListStream"))
		{
			p = obj->b->buf + dir->Location.Rva;
			j = ((PMINIDUMP_MODULE_LIST)p)->NumberOfModules;
			for (i = 0; i < j; i++) {
				p = (void *)(&((PMINIDUMP_MODULE_LIST)p)->Modules[i]);
				if (p - (void *)obj->b->buf + sizeof(MINIDUMP_MODULE) > obj->b->length) {
					eprintf("Warning in r_bin_mdmp_init_directory: length too short, not enough space for all MINIDUMP_MODULE\n");
					break;
				}
				r_list_append(obj->modules, p);
			};
		};
		break;
	case MemoryListStream:
		break;
	case ExceptionStream:
		break;
	case SystemInfoStream:
		if (obj->system_info)
		{
			eprintf("Warning in r_bin_mdmp_init_directory: another SystemInfoStream encountered, ignored\n");
			return R_FALSE;
		}
		if (r_bin_mdmp_directory_check(obj, dir, sizeof(MINIDUMP_SYSTEM_INFO), "SystemInfoStream"))
		{
			obj->system_info = (PMINIDUMP_SYSTEM_INFO)(obj->b->buf + dir->Location.Rva);
		};
		break;
	case ThreadExListStream:
		break;
	case Memory64ListStream:
		if (r_bin_mdmp_directory_check(obj, dir, sizeof(MINIDUMP_MEMORY64_LIST), "Memory64ListStream"))
		{
			p = obj->b->buf + dir->Location.Rva;
			j = ((PMINIDUMP_MEMORY64_LIST)p)->NumberOfMemoryRanges;
			for (i = 0; i < j; i++) {
				p = (void *)(&((PMINIDUMP_MEMORY64_LIST)p)->MemoryRanges[i]);
				if (p - (void *)obj->b->buf + sizeof(MINIDUMP_MEMORY_DESCRIPTOR64) > obj->b->length) {
					eprintf("Warning in r_bin_mdmp_init_directory: length too short, not enough space for all MINIDUMP_MEMORY_DESCRIPTOR64\n");
					break;
				}
				r_list_append(obj->memory64, p);
			};
		};
		break;
	case CommentStreamA:
		break;
	case CommentStreamW:
		break;
	case HandleDataStream:
		break;
	case FunctionTableStream:
		break;
	case UnloadedModuleListStream:
		break;
	case MiscInfoStream:
		if (dir->Location.Rva + dir->Location.DataSize > obj->b->length)
		{
			eprintf("Warning in r_bin_mdmp_init_directory: length too short, not enough space for MiscInfoStream\n");
			return R_FALSE;
		}
		p = obj->b->buf + dir->Location.Rva;
		i = ((PMINIDUMP_MISC_INFO)p)->SizeOfInfo;
		if (i != dir->Location.DataSize) {
			eprintf("Warning in r_bin_mdmp_init_directory: MINIDUMP_MISC_INFO DataSize size mismatch\n");
			return R_FALSE;
		}
		if(!(m = malloc(sizeof(MINIDUMP_MISC_INFO_N)))) {
			eprintf("Warning in r_bin_mdmp_init_directory: malloc failed\n");
			return R_FALSE;
		}
		memset(m, 0, sizeof(MINIDUMP_MISC_INFO_N));
		if (i <= sizeof(MINIDUMP_MISC_INFO_N)) {
			memcpy(m, p, i);
		} else {
			memcpy (m, p, sizeof(MINIDUMP_MISC_INFO_N));
			eprintf ("Warning in r_bin_mdmp_init_directory: PMINIDUMP_MISC_INFO structure bigger than expected, truncated from %d\n", (int)i);
		}
		r_list_append(obj->misc_info, m);
		break;
	case MemoryInfoListStream:
		if (r_bin_mdmp_directory_check(obj, dir, sizeof(MINIDUMP_MEMORY_INFO_LIST), "MemoryInfoListStream"))
		{
			p = obj->b->buf + dir->Location.Rva;
			if ((sizeof(MINIDUMP_MEMORY_INFO_LIST) != ((PMINIDUMP_MEMORY_INFO_LIST)p)->SizeOfHeader) || (sizeof(MINIDUMP_MEMORY_INFO) != ((PMINIDUMP_MEMORY_INFO_LIST)p)->SizeOfEntry))
			{
//.........这里部分代码省略.........
开发者ID:AitorATuin,项目名称:radare2,代码行数:101,代码来源:mdmp.c

示例8: r_anal_value_to_string


//.........这里部分代码省略.........
		break;
	case R_ANAL_OP_TYPE_ADD:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s += %s", r0, a0);
		} else {
			snprintf (ret, sizeof (ret), "%s = %s + %s", r0, a0, a1);
		}
		break;
	case R_ANAL_OP_TYPE_SUB:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s -= %s", r0, a0);
		} else {
			snprintf (ret, sizeof (ret), "%s = %s - %s", r0, a0, a1);
		}
		break;
	case R_ANAL_OP_TYPE_MUL:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s *= %s", r0, a0);
		} else {
			snprintf (ret, sizeof (ret), "%s = %s * %s", r0, a0, a1);
		}
		break;
	case R_ANAL_OP_TYPE_DIV:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s /= %s", r0, a0);
		} else snprintf (ret, sizeof (ret), "%s = %s / %s", r0, a0, a1);
		break;
	case R_ANAL_OP_TYPE_AND:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s &= %s", r0, a0);
		} else snprintf (ret, sizeof (ret), "%s = %s & %s", r0, a0, a1);
		break;
	case R_ANAL_OP_TYPE_OR:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s |= %s", r0, a0);
		} else snprintf (ret, sizeof (ret), "%s = %s | %s", r0, a0, a1);
		break;
	case R_ANAL_OP_TYPE_XOR:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s ^= %s", r0, a0);
		} else snprintf (ret, sizeof (ret), "%s = %s ^ %s", r0, a0, a1);
		break;
	case R_ANAL_OP_TYPE_LEA:
		snprintf (ret, sizeof (ret), "%s -> %s", r0, a0);
		break;
	case R_ANAL_OP_TYPE_CMP:
		memcpy (ret, ";", 2);
		break;
	case R_ANAL_OP_TYPE_NOP:
		memcpy (ret, "nop", 4);
		break;
	case R_ANAL_OP_TYPE_RET:
		memcpy (ret, "ret", 4);
		break;
	case R_ANAL_OP_TYPE_CRET:
		if ((bb = r_anal_bb_from_offset (anal, op->addr))) {
			cstr = r_anal_cond_to_string (bb->cond);
			snprintf (ret, sizeof (ret), "if (%s) ret", cstr);
			free (cstr);
		} else {
			strcpy (ret, "if (unk) ret");
		}
		break;
	case R_ANAL_OP_TYPE_LEAVE:
		memcpy (ret, "leave", 6);
		break;
	case R_ANAL_OP_TYPE_MOD:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "%s %%= %s", r0, a0);
		} else {
			snprintf (ret, sizeof (ret), "%s = %s %% %s", r0, a0, a1);
		}
		break;
	case R_ANAL_OP_TYPE_XCHG:
		if (!a1 || !strcmp (a0, a1)) {
			snprintf (ret, sizeof (ret), "tmp = %s; %s = %s; %s = tmp", r0, r0, a0, a0);
		} else {
			snprintf (ret, sizeof (ret), "%s = %s ^ %s", r0, a0, a1);
		}
		break;
	case R_ANAL_OP_TYPE_ROL:
	case R_ANAL_OP_TYPE_ROR:
	case R_ANAL_OP_TYPE_SWITCH:
	case R_ANAL_OP_TYPE_CASE:
		eprintf ("Command not implemented.\n");
		free (r0);
		free (a0);
		free (a1);
		return NULL;
	default:
		free (r0);
		free (a0);
		free (a1);
		return NULL;
	}
	free (r0);
	free (a0);
	free (a1);
	return strdup (ret);
}
开发者ID:jroimartin,项目名称:radare2,代码行数:101,代码来源:op.c

示例9: feh_load_options_for_theme

static void feh_load_options_for_theme(char *theme)
{
	FILE *fp = NULL;
	char *home = getenv("HOME");
	char *rcpath = NULL;
	char *oldrcpath = NULL;
	char *confbase = getenv("XDG_CONFIG_HOME");
	char s[1024], s1[1024], s2[1024];
	int cont = 0;
	int bspos;

	if (!home)
		eprintf("You have no HOME, cannot read themes");

	oldrcpath = estrjoin("/", home, ".fehrc", NULL);

	if (confbase)
		rcpath = estrjoin("/", confbase, "feh/themes", NULL);
	else
		rcpath = estrjoin("/", home, ".config/feh/themes", NULL);

	fp = fopen(rcpath, "r");

	free(rcpath);

	if (!fp && ((fp = fopen(oldrcpath, "r")) != NULL))
		weprintf("The theme config file was moved from ~/.fehrc to "
			"~/.config/feh/themes. Run\n"
			"    mkdir -p ~/.config/feh; mv ~/.fehrc ~/.config/feh/themes\n"
			"to fix this.");

	free(oldrcpath);

	if (!fp && ((fp = fopen("/etc/feh/themes", "r")) == NULL))
		return;

	/* Oooh. We have an options file :) */
	for (; fgets(s, sizeof(s), fp);) {
		s1[0] = '\0';
		s2[0] = '\0';

		if (cont) {
			sscanf(s, " %[^\n]\n", (char *) &s2);
			if (!*s2)
				break;
			D(("Got continued options %s\n", s2));
		} else {
			sscanf(s, "%s %[^\n]\n", (char *) &s1, (char *) &s2);
			if (!(*s1) || (!*s2) || (*s1 == '\n') || (*s1 == '#')) {
				cont = 0;
				continue;
			}
			D(("Got theme/options pair %s/%s\n", s1, s2));
		}

		if (!strcmp(s1, theme) || cont) {

			bspos = strlen(s2)-1;

			if (s2[bspos] == '\\') {
				D(("Continued line\n"));
				s2[bspos] = '\0';
				cont = 1;
				/* A trailing whitespace confuses the option parser */
				if (bspos && (s2[bspos-1] == ' '))
					s2[bspos-1] = '\0';
			} else
				cont = 0;

			D(("A match. Using options %s\n", s2));
			feh_parse_options_from_string(s2);

			if (!cont)
				break;
		}
	}
	fclose(fp);
	return;
}
开发者ID:0ion9,项目名称:feh,代码行数:79,代码来源:options.c

示例10: print_escaped_string

static void print_escaped_string (const char *str, int len) {
  eprintf ("\"");
  const char *end = str + len;
  while (str < end) {
    int n = valid_utf8_char (str);
    if (n < 0) {
      eprintf ("\\x%02x", (int)(unsigned char)*str);
      str ++;
    } else if (n >= 2) {
      int i;
      for (i = 0; i < n; i++) {
        eprintf ("%c", *(str ++));
      }
    } else if (((unsigned char)*str) >= ' ' && *str != '"' && *str != '\\') {
      eprintf ("%c", *str);      
      str ++;
    } else {
      switch (*str) {
      case '\n':
        eprintf("\\n");
        break;
      case '\r':
        eprintf("\\r");
        break;
      case '\t':
        eprintf("\\t");
        break;
      case '\b':
        eprintf("\\b");
        break;
      case '\a':
        eprintf("\\a");
        break;
      case '\\':
        eprintf ("\\\\");
        break;
      case '"':
        eprintf ("\\\"");
        break;
      default:
        eprintf ("\\x%02x", (int)(unsigned char)*str);
        break;
      }
      str ++;
    }
  }
  eprintf ("\"");
}
开发者ID:CISTEAM,项目名称:tgl,代码行数:48,代码来源:auto-static-print-ds.c

示例11: printvect

void printvect(string name, vector vec)
{
  eprintf("[%s: %12s  %10.5f  %10.5f  %10.5f]\n",
	  getargv0(), name, vec[0], vec[1], vec[2]);
}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:5,代码来源:snaprect.c

示例12: print_offset

static void print_offset (void) {
  int i;
  for (i = 0; i < multiline_offset; i++) {
    eprintf (" ");
  }
}
开发者ID:CISTEAM,项目名称:tgl,代码行数:6,代码来源:auto-static-print-ds.c

示例13: switch


//.........这里部分代码省略.........
          }
          break;
        default:
          if (Switch[1]=='+')
          {
            InclFileAttr|=GetExclAttr(Switch+2);
            InclAttrSet=true;
          }
          else
            ExclFileAttr|=GetExclAttr(Switch+1);
          break;
      }
      break;
    case 'F':
      if (Switch[1]==0)
        FreshFiles=true;
      else
        BadSwitch(Switch);
      break;
    case 'H':
      switch (toupperw(Switch[1]))
      {
        case 'P':
          EncryptHeaders=true;
          if (Switch[2]!=0)
          {
            Password.Set(Switch+2);
            cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0]));
          }
          else
            if (!Password.IsSet())
            {
              uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password);
              eprintf(L"\n");
            }
          break;
        default :
          BadSwitch(Switch);
          break;
      }
      break;
    case 'I':
      if (wcsnicomp(Switch+1,L"LOG",3)==0)
      {
        wcsncpyz(LogName,Switch[4]!=0 ? Switch+4:DefLogName,ASIZE(LogName));
        break;
      }
      if (wcsicomp(Switch+1,L"SND")==0)
      {
        Sound=true;
        break;
      }
      if (wcsicomp(Switch+1,L"ERR")==0)
      {
        MsgStream=MSG_STDERR;
        break;
      }
      if (wcsnicomp(Switch+1,L"EML",3)==0)
      {
        wcsncpyz(EmailTo,Switch[4]!=0 ? Switch+4:L"@",ASIZE(EmailTo));
        break;
      }
      if (wcsicomp(Switch+1,L"NUL")==0)
      {
        MsgStream=MSG_NULL;
        break;
开发者ID:KastB,项目名称:OpenCPN,代码行数:67,代码来源:cmddata.cpp

示例14: r_core_file_reopen

R_API int r_core_file_reopen(RCore *core, const char *args, int perm, int loadbin) {
	int isdebug = r_config_get_i (core->config, "cfg.debug");
	char *path;
	ut64 laddr = r_config_get_i (core->config, "bin.laddr");
	RCoreFile *file = NULL;
	RCoreFile *ofile = core->file;
	RBinFile *bf = ofile ? r_bin_file_find_by_fd (core->bin, ofile->fd)
		: NULL;
	RIODesc *odesc = (core->io && ofile) ? r_io_desc_get (core->io, ofile->fd) : NULL;
	char *ofilepath = NULL, *obinfilepath = (bf && bf->file)? strdup (bf->file): NULL;
	int ret = false;
	ut64 origoff = core->offset;
	if (odesc) {
		if (odesc->referer) {
			ofilepath = odesc->referer;
		} else if (odesc->uri) {
			ofilepath = odesc->uri;
		}
	}

	if (r_sandbox_enable (0)) {
		eprintf ("Cannot reopen in sandbox\n");
		free (obinfilepath);
		return false;
	}
	if (!core->file) {
		eprintf ("No file opened to reopen\n");
		free (ofilepath);
		free (obinfilepath);
		return false;
	}
	int newpid = odesc? odesc->fd: -1;

	if (isdebug) {
		r_debug_kill (core->dbg, core->dbg->pid, core->dbg->tid, 9); // KILL
		perm = 7;
	} else {
		if (!perm) {
			perm = 4; //R_PERM_R;
		}
	}
	if (!ofilepath) {
		eprintf ("Unknown file path");
		free (obinfilepath);
		return false;
	}

	// HACK: move last mapped address to higher place
	// XXX - why does this hack work?
	// when the new memory maps are created.
	path = strdup (ofilepath);
	free (obinfilepath);
	obinfilepath = strdup (ofilepath);

	// r_str_trim (path);
	file = r_core_file_open (core, path, perm, laddr);
	if (file) {
		bool had_rbin_info = false;

		if (ofile) {
			if (r_bin_file_delete (core->bin, ofile->fd)) {
				had_rbin_info = true;
			}
		}
		r_core_file_close (core, ofile);
		r_core_file_set_by_file (core, file);
		ofile = NULL;
		odesc = NULL;
		//	core->file = file;
		eprintf ("File %s reopened in %s mode\n", path,
			(perm & R_PERM_W)? "read-write": "read-only");

		if (loadbin && (loadbin == 2 || had_rbin_info)) {
			ut64 baddr = r_config_get_i (core->config, "bin.baddr");
			ret = r_core_bin_load (core, obinfilepath, baddr);
			r_core_bin_update_arch_bits (core);
			if (!ret) {
				eprintf ("Error: Failed to reload rbin for: %s", path);
			}
		}

		if (core->bin->cur && core->io && r_io_desc_get (core->io, file->fd) && !loadbin) {
			//force here NULL because is causing uaf look this better in future XXX @alvarofe
			core->bin->cur = NULL;
		}
		// close old file
	} else if (ofile) {
		eprintf ("r_core_file_reopen: Cannot reopen file: %s with perms 0x%x,"
			" attempting to open read-only.\n", path, perm);
		// lower it down back
		//ofile = r_core_file_open (core, path, R_PERM_R, addr);
		r_core_file_set_by_file (core, ofile);
	} else {
		eprintf ("Cannot reopen\n");
	}
	if (isdebug) {
		int newtid = newpid;
		// XXX - select the right backend
		if (core->file) {
			newpid = r_io_fd_get_pid (core->io, core->file->fd);
//.........这里部分代码省略.........
开发者ID:aronsky,项目名称:radare2,代码行数:101,代码来源:cfile.c

示例15: r_print_format_length

/* hack from print */
R_API int r_print_format_length (const char *fmt) {
	int nargs, i, j, idx, times, endian;
	char *args, *bracket, tmp, last = 0;
	const char *arg = fmt;
	const char *argend = arg+strlen (fmt);
	char namefmt[8];
	int viewflags = 0;
	nargs = endian = i = j = 0;

	while (*arg && iswhitechar (*arg)) arg++;
	/* get times */
	times = atoi (arg);
	if (times > 0)
		while ((*arg>='0'&&*arg<='9')) arg++;
	bracket = strchr (arg,'{');
	if (bracket) {
		char *end = strchr (arg,'}');
		if (end == NULL) {
			eprintf ("No end bracket. Try pm {ecx}b @ esi\n");
			return 0;
		}
		*end='\0';
		times = r_num_math (NULL, bracket+1);
		arg = end + 1;
	}

	if (*arg=='\0')
		return 0;

	/* get args */
	args = strchr (arg, ' ');
	if (args) {
		int l=0, maxl = 0;
		argend = args;
		args = strdup (args+1);
		nargs = r_str_word_set0 (args+1);
		if (nargs == 0)
			R_FREE (args);
		for (i=0; i<nargs; i++) {
			int len = strlen (r_str_word_get0 (args+1, i));
			if (len>maxl) maxl = len;
		}
		l++;
		snprintf (namefmt, sizeof (namefmt), "%%%ds : ", maxl);
	}

	/* go format */
	i = 0;
	if (!times) times = 1;
	for (; times; times--) { // repeat N times
		const char * orig = arg;
		idx = 0;
		arg = orig;
		for (idx=0; arg<argend && *arg; idx++, arg++) {
			tmp = *arg;
		feed_me_again:
			if (tmp == 0 && last != '*')
				break;
			/* skip chars */
			switch (tmp) {
			case '*':
				if (i<=0) break;
				tmp = last;
				arg--;
				idx--;
				goto feed_me_again;
			case '+':
				idx--;
				viewflags = !viewflags;
				continue;
			case 'e': // tmp swap endian
				idx--;
				endian ^= 1;
				continue;
			case '.': // skip char
				i++;
				idx--;
				continue;
			case 'p':
				tmp = (sizeof (void*)==8)? 'q': 'x';
				break;
			case '?': // help
				idx--;
				return 0;
			}
			switch (tmp) {
			case 'e': i += 8; break;
			case 'q': i += 8; break;
			case 'b': i++; break;
			case 'c': i++; break;
			case 'B': i += 4; break;
			case 'i': i += 4; break;
			case 'd': i += 4; break;
			case 'x': i += 4; break;
			case 'w':
			case '1': i+=2; break;
			case 'z': // XXX unsupported
			case 'Z': // zero terminated wide string
				break;
//.........这里部分代码省略.........
开发者ID:djpohly,项目名称:radare2,代码行数:101,代码来源:str.c


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