예제 #1
0
void master_creator()
{
	file_tmpl tmpl;

	// 设置源程序所在目录
	tmpl.set_path_from("tmpl/master");

	while (true)
	{
		char buf[256];
		int  n;

		printf("please input your program name: ");
		fflush(stdout);

		n = acl_vstream_gets_nonl(ACL_VSTREAM_IN, buf, sizeof(buf));
		if (n == ACL_VSTREAM_EOF)
			break;
		if (n == 0)
			acl::safe_snprintf(buf, sizeof(buf), "master_service");

		tmpl.set_project_name(buf);
		// 创建目录
		tmpl.create_dirs();

		printf("choose master_service type:\r\n");
		printf("	t: for master_threads\r\n"
			"	p: for master_proc\r\n"
			"	a: for master_aio\t\n"
			"	g: for master_trigger\r\n"
			"	r: for master_rpc\r\n"
			"	u: for master_udp\r\n"
			"	s: skip choose, try again\r\n");
		printf(">");
		fflush(stdout);

		n = acl_vstream_gets_nonl(ACL_VSTREAM_IN, buf, sizeof(buf));
		if (n == ACL_VSTREAM_EOF)
			break;
		else if (strcasecmp(buf, "t") == 0)
		{
			create_master_threads(tmpl);
			break;
		}
		else if (strcasecmp(buf, "p") == 0)
		{
			create_master_proc(tmpl);
			break;
		}
		else if (strcasecmp(buf, "a") == 0)
		{
			create_master_aio(tmpl);
			break;
		}
		else if (strcasecmp(buf, "r") == 0)
		{
			create_master_rpc(tmpl);
			break;
		}
		else if (strcasecmp(buf, "g") == 0)
		{
			create_master_trigger(tmpl);
			break;
		}
		else if (strcasecmp(buf, "u") == 0)
		{
			create_master_udp(tmpl);
			break;
		}
		else if (strcasecmp(buf, "s") == 0)
			goto END;
		else
			printf("unknown ch: %s\r\n", buf);
	}

	tmpl.create_common();

END:
	for (int i = 0; i < 78; i++)
		putchar('-');
	printf("\r\n");
}
예제 #2
0
void master_creator()
{
	char buf[256];
	int  n;

	while (true)
	{
		printf("please input your program name: "); fflush(stdout);
		n = acl_vstream_gets_nonl(ACL_VSTREAM_IN, buf, sizeof(buf));
		if (n == ACL_VSTREAM_EOF)
			break;
		if (n == 0)
			snprintf(master_name, sizeof(master_name), "master_service");
		else
			snprintf(master_name, sizeof(master_name), "%s", buf);

		// ´´½¨Ä¿Â¼
		snprintf(dst_path_, sizeof(dst_path_), "%s", master_name);
		acl_make_dirs(dst_path_, 0755);

		printf("choose master_service type:\r\n");
		printf("t: for master_threads; p: for master_proc; "
			"a: for master_aio; g: for master_trigger; "
			"r: for master_rpc; u: for master_udp; "
			"s: skip choose\r\n");
		printf(">"); fflush(stdout);

		n = acl_vstream_gets_nonl(ACL_VSTREAM_IN, buf, sizeof(buf));
		if (n == ACL_VSTREAM_EOF)
			break;
		else if (strcasecmp(buf, "t") == 0)
		{
			create_master_threads();
			break;
		}
		else if (strcasecmp(buf, "p") == 0)
		{
			create_master_proc();
			break;
		}
		else if (strcasecmp(buf, "a") == 0)
		{
			create_master_aio();
			break;
		}
		else if (strcasecmp(buf, "r") == 0)
		{
			create_master_rpc();
			break;
		}
		else if (strcasecmp(buf, "g") == 0)
		{
			create_master_trigger();
			break;
		}
		else if (strcasecmp(buf, "u") == 0)
		{
			create_master_udp();
			break;
		}
		else if (strcasecmp(buf, "s") == 0)
			break;
		else
			printf("unknown ch: %s\r\n", buf);
	}
	for (int i = 0; i < 78; i++)
		putchar('-');
	printf("\r\n");
}