Beispiel #1
0
static bool create_http_servlet(file_tmpl& tmpl)
{
	tpl_t* tpl = tmpl.open_tpl("http_servlet.cpp");
	if (tpl == NULL)
		return false;

	printf("Do you want add cookie? y[y/n]: "); fflush(stdout);
	int ch = getchar();
	if (ch != 'n')
		set_cookies(tpl);

	string filepath;
	filepath.format("%s/http_servlet.cpp", tmpl.get_project_name());
	if (tpl_save_as(tpl, filepath.c_str()) != TPL_OK)
	{
		printf("save to %s error: %s\r\n", filepath.c_str(),
			last_serror());
		tpl_free(tpl);
		return false;
	}

	printf("create %s ok.\r\n", filepath.c_str());
	tpl_free(tpl);

	// 设置服务器模板类型
	return create_service(tmpl);
}
Beispiel #2
0
static bool create_master_udp(file_tmpl& tmpl)
{
	string file(tmpl.get_project_name());
	file << ".cf";
	if (tmpl.copy_and_replace("master_udp.cf", file.c_str()) == false)
		return false;

	const char* name = "master_udp";
	const FILE_FROM_TO tab[] = {
		{ "main_udp.cpp", "main.cpp" },
		{ "master_udp.h", "master_service.h" },
		{ "master_udp.cpp", "master_service.cpp" },
		{ NULL, NULL }
	};

	return tmpl. files_copy(name, tab);
}
Beispiel #3
0
static bool create_fiber(file_tmpl& tmpl)
{
	string file(tmpl.get_project_name());
	file << ".cf";
	if (tmpl.copy_and_replace("master_fiber.cf", file.c_str()) == false)
		return false;

	const char* name = "master_fiber";
	const FILE_FROM_TO tab[] = {
		{ "main_fiber.cpp", "main.cpp" },
		{ "master_fiber.h", "master_service.h" },
		{ "master_fiber.cpp", "master_service.cpp" },
		{ "stdafx_fiber.h", "stdafx.h" },
		{ "http_servlet.h", "http_servlet.h" },
		{ NULL, NULL }
	};

	return tmpl.files_copy(name, tab)
		&& tmpl.copy_and_replace("Makefile_fiber", "Makefile")
		&& tmpl.file_copy("tmpl/Makefile_fiber.in",
			"Makefile.in");
}