本文整理汇总了C++中run函数的典型用法代码示例。如果您正苦于以下问题:C++ run函数的具体用法?C++ run怎么用?C++ run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: complete
static void
complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlenptr, size_t *outprespace)
{
run(mf, in, len, prespace, out, outlenptr, outprespace, TRUE);
}
示例2: main
//.........这里部分代码省略.........
/* Finally, add rule in our forwarding table to pass to our virtual interface */
{
char *const route_args[] =
{
"ip", "route", "add", "default", "dev", dev,
"table", DNS_TABLE, NULL
};
if (0 != fork_and_exec (sbin_ip, route_args))
goto cleanup_forward_3;
}
/* drop privs *except* for the saved UID; this is not perfect, but better
than doing nothing */
#ifdef HAVE_SETRESUID
if (0 != setresuid (uid, uid, 0))
{
fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
r = 24;
goto cleanup_route_4;
}
#else
/* Note: no 'setuid' here as we must keep our saved UID as root */
if (0 != seteuid (uid))
{
fprintf (stderr, "Failed to seteuid: %s\n", strerror (errno));
r = 24;
goto cleanup_route_4;
}
#endif
r = 0; /* did fully setup routing table (if nothing else happens, we were successful!) */
/* now forward until we hit a problem */
run (fd_tun);
/* now need to regain privs so we can remove the firewall rules we added! */
#ifdef HAVE_SETRESUID
if (0 != setresuid (uid, 0, 0))
{
fprintf (stderr, "Failed to setresuid back to root: %s\n", strerror (errno));
r = 40;
goto cleanup_route_4;
}
#else
if (0 != seteuid (0))
{
fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno));
r = 40;
goto cleanup_route_4;
}
#endif
/* update routing tables again -- this is why we could not fully drop privs */
/* now undo updating of routing tables; normal exit or clean-up-on-error case */
cleanup_route_4:
{
char *const route_clean_args[] =
{
"ip", "route", "del", "default", "dev", dev,
"table", DNS_TABLE, NULL
};
if (0 != fork_and_exec (sbin_ip, route_clean_args))
r += 1;
}
cleanup_forward_3:
{
示例3: dag_link
static void
dag_link(struct dag * slf,char *output, char *match, char ** look, char ** lnk)
{
int i, rv, main_count;
char * args;
struct pkg ** pks;
if(slf->sorted){
main_count = num_main_pkgs(slf);
if( main_count > 1 ){
pks = filter_relevant_main(slf, match);
}else{
pks = slf->sorted;
}
if( ! global_get_bool("-dryrun") ){
if( dag_binary_up2date( pks , output ) ){
if(! global_get_bool("-quiet")){
printf("up 2 date: %s\n", output );
}
return;
}
}
struct strvec * v = new_strvec();
v->add(v, global_get_str("-backend"));
v->add(v, "-o");
v->add(v, output );
for(i = 0; pks[i]; i++){
if(pks[i]->o_file){
v->add(v, pks[i]->o_file);
}
}
if(v->len(v) > 3){
if(!global_get_bool("-quiet") && !global_get_bool("-dryrun") ) {
printf("linking : %s\n", output );
}
if( global_get_bool("-static") ){
v->add(v, "-static");
}
if(look){
for(i = 0; look[i]; i++){
v->add(v, "-L");
v->add(v, look[i]);
}
}
if(lnk){
for(i = 0; lnk[i]; i++){
v->add(v, "-l");
v->add(v, lnk[i]);
}
}
args = v->join(v, " ");
if(global_get_bool("-dryrun")) {
printf("%s\n", args);
}else{
rv = run(args);
if(rv == -1){ panic("failed to fork()",__FILE__,__LINE__); }
if(rv){ exit(EXIT_FAILURE); }
}
free(args);
}
v->free(v);
// we have allocated a new array if we filtered
if( main_count > 1 ){
free(pks);
}
}
};
示例4: run
void TestFixture::run(const std::string &str)
{
testToRun = str;
run();
}
示例5: ATF_TC_BODY
ATF_TC_BODY(glob_star_not, tc)
{
run("a/**", 0, glob_star_not, __arraycount(glob_star_not));
}
示例6: run_and_delete
void run_and_delete() {
run();
delete this;
}
示例7: main
// This test is expected to be executed either by a regular
// user or by root. If executed by a regular user it doesn't
// test all the functions that would depend on changing the
// effective user id. If executed by a super-user everything
// gets tested. Here are different ways of execing the test binary:
// 1. regular user assuming user == yarn user
// $ test-container-executor
// 2. regular user with a given yarn user
// $ test-container-executor yarn_user
// 3. super user with a given user and assuming user == yarn user
// # test-container-executor user
// 4. super user with a given user and a given yarn user
// # test-container-executor user yarn_user
int main(int argc, char **argv) {
LOGFILE = stdout;
ERRORFILE = stderr;
// clean up any junk from previous run
if (system("chmod -R u=rwx " TEST_ROOT "; rm -fr " TEST_ROOT)) {
exit(1);
}
if (mkdirs(TEST_ROOT "/logs/userlogs", 0755) != 0) {
exit(1);
}
if (write_config_file(TEST_ROOT "/test.cfg", 1) != 0) {
exit(1);
}
read_config(TEST_ROOT "/test.cfg");
local_dirs = extract_values(strdup(NM_LOCAL_DIRS));
log_dirs = extract_values(strdup(NM_LOG_DIRS));
create_nm_roots(local_dirs);
// See the description above of various ways this test
// can be executed in order to understand the following logic
char* current_username = strdup(getpwuid(getuid())->pw_name);
if (getuid() == 0 && (argc == 2 || argc == 3)) {
username = argv[1];
yarn_username = (argc == 3) ? argv[2] : argv[1];
} else {
username = current_username;
yarn_username = (argc == 2) ? argv[1] : current_username;
}
set_nm_uid(geteuid(), getegid());
if (set_user(username)) {
exit(1);
}
printf("\nStarting tests\n");
printf("\nTesting resolve_config_path()\n");
test_resolve_config_path();
printf("\nTesting get_user_directory()\n");
test_get_user_directory();
printf("\nTesting get_app_directory()\n");
test_get_app_directory();
printf("\nTesting get_container_directory()\n");
test_get_container_directory();
printf("\nTesting get_container_launcher_file()\n");
test_get_container_launcher_file();
printf("\nTesting get_app_log_dir()\n");
test_get_app_log_dir();
test_check_configuration_permissions();
printf("\nTesting delete_container()\n");
test_delete_container();
printf("\nTesting delete_app()\n");
test_delete_app();
test_check_user();
// the tests that change user need to be run in a subshell, so that
// when they change user they don't give up our privs
run_test_in_child("test_signal_container_group", test_signal_container_group);
// init app and run container can't be run if you aren't testing as root
if (getuid() == 0) {
// these tests do internal forks so that the change_owner and execs
// don't mess up our process.
test_init_app();
test_run_container();
}
seteuid(0);
// test_delete_user must run as root since that's how we use the delete_as_user
test_delete_user();
free_configurations();
printf("\nTrying banned default user()\n");
//.........这里部分代码省略.........
示例8: run
void BundleRTS::apply() {
run();
output();
}
示例9: do_async
typename std::shared_future<typename std::result_of<F(detail::convertible_to_async_helper)>::type> do_async(F f){
auto ret = std::make_shared<detail::simple_async_function_holder<F>>(f);
return ret->run();
}
示例10: m_device
GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
gui::IGUIElement* parent,
IMenuManager *menumgr,
scene::ISceneManager* smgr,
MainMenuData* data,
bool& kill) :
m_device(dev),
m_parent(parent),
m_menumanager(menumgr),
m_smgr(smgr),
m_data(data),
m_texture_source(NULL),
m_sound_manager(NULL),
m_formspecgui(0),
m_buttonhandler(0),
m_menu(0),
m_kill(kill),
m_startgame(false),
m_script(0),
m_scriptdir(""),
m_irr_toplefttext(0),
m_clouds_enabled(true),
m_cloud()
{
//initialize texture pointers
for (unsigned int i = 0; i < TEX_LAYER_MAX; i++) {
m_textures[i].texture = NULL;
}
// is deleted by guiformspec!
m_buttonhandler = new TextDestGuiEngine(this);
//create texture source
m_texture_source = new MenuTextureSource(m_device->getVideoDriver());
//create soundmanager
MenuMusicFetcher soundfetcher;
#if USE_SOUND
m_sound_manager = createOpenALSoundManager(&soundfetcher);
#endif
if(!m_sound_manager)
m_sound_manager = &dummySoundManager;
//create topleft header
std::wstring t = narrow_to_wide(std::string("")); // = narrow_to_wide(std::string("MultiCraft ") + g_version_hash);
core::rect<s32> rect(0, 0, g_fontengine->getTextWidth(t), g_fontengine->getTextHeight());
rect += v2s32(4, 0);
m_irr_toplefttext =
m_device->getGUIEnvironment()->addStaticText(t.c_str(),
rect,false,true,0,-1);
//create formspecsource
m_formspecgui = new FormspecFormSource("");
/* Create menu */
m_menu = new GUIFormSpecMenu(m_device,
m_parent,
-1,
m_menumanager,
NULL /* &client */,
NULL /* gamedef */,
m_texture_source,
m_formspecgui,
m_buttonhandler,
NULL,
false);
m_menu->allowClose(false);
m_menu->lockSize(true,v2u32(800,600));
// Initialize scripting
infostream << "GUIEngine: Initializing Lua" << std::endl;
m_script = new MainMenuScripting(this);
try {
if (m_data->errormessage != "") {
m_script->setMainMenuErrorMessage(m_data->errormessage);
m_data->errormessage = "";
}
if (!loadMainMenuScript()) {
errorstream << "No future without mainmenu" << std::endl;
abort();
}
run();
}
catch(LuaError &e) {
errorstream << "MAINMENU ERROR: " << e.what() << std::endl;
m_data->errormessage = e.what();
}
m_menu->quitMenu();
m_menu->drop();
m_menu = NULL;
}
示例11: run
MatrixXd MCDAQ_t::run_get_data() {
run();
return get_data();
}
示例12: filter
static void
filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlenptr, size_t *outprespace)
{
run(mf, in, len, prespace, out, outlenptr, outprespace, FALSE);
}
示例13: cli_commands
void cli::start()
{
cli_commands() = get_method_names(0);
_run_complete = fc::async( [&](){ run(); } );
}
示例14: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
auto keys = QStyleFactory::keys();
for (auto s : keys)
{
qDebug(s.toStdString().c_str());
}
QString ss = load_stylesheet(":/Stylesheets/common.qss");
#ifdef _6IT_UI_MOBILE
ss.append(load_stylesheet(":/Stylesheets/common_mobile.qss"));
#else
ss.append(load_stylesheet(":/Stylesheets/common_desktop.qss"));
#endif
#ifdef _6IT_QT_WINRT_DESKTOP
ss.append(load_stylesheet(":/Stylesheets/winrt_desktop.qss"));
#elif defined(_6IT_QT_WINRT_PHONE)
a.setStyle(QStyleFactory::create("Fusion"));
ss.append(load_stylesheet(":/Stylesheets/winrt_phone.qss"));
#elif defined(_6IT_QT_WINRT_DESKTOP)
ss.append(load_stylesheet(":/Stylesheets/windows_desktop.qss"));
#elif defined(_6IT_QT_IOS)
ss.append(load_stylesheet(":/Stylesheets/ios.qss"));
#elif defined(_6IT_QT_ANDROID)
a.setStyle(QStyleFactory::create("Fusion"));
ss.append(load_stylesheet(":/Stylesheets/android.qss"));
#elif defined(_6IT_QT_LINUX_DESKTOP)
ss.append(load_stylesheet(":/Stylesheets/linux_desktop.qss"));
#endif
a.setStyleSheet(ss);
QThread thread;
auto pworker = new RZQtSubCWorker();
auto &worker = *pworker;
worker.moveToThread(&thread);
thread.start();
FileListWindow fileListWindow;
ViewSourceWindow editorWindow;
RunWindow runWindow;
CompileWindow compileWindow(worker);
fileListWindow.show();
QObject::connect(&fileListWindow, SIGNAL(sourceSelected(QString)), &editorWindow, SLOT(show()));
QObject::connect(&fileListWindow, SIGNAL(sourceSelected(QString)), &editorWindow, SLOT(loadFile(QString)));
QObject::connect(&fileListWindow, SIGNAL(sourceSelected(QString)), &fileListWindow, SLOT(hide()));
QObject::connect(&editorWindow, SIGNAL(navigatedBack()), &fileListWindow, SLOT(show()));
QObject::connect(&editorWindow, SIGNAL(navigatedBack()), &editorWindow, SLOT(hide()));
QObject::connect(&editorWindow, SIGNAL(runCode(QString const &)), &editorWindow, SLOT(hide()));
QObject::connect(&editorWindow, SIGNAL(runCode(QString const &)), &compileWindow, SLOT(show()));
QObject::connect(&editorWindow, SIGNAL(runCode(QString const &)), &compileWindow, SLOT(clear()));
QObject::connect(&editorWindow, SIGNAL(runCode(QString const &)), &worker, SLOT(setSource(QString const &)));
QObject::connect(&compileWindow, SIGNAL(navigatedBack()), &editorWindow, SLOT(show()));
QObject::connect(&compileWindow, SIGNAL(navigatedBack()), &compileWindow, SLOT(hide()));
QObject::connect(&worker, SIGNAL(compilationWillStart()), &compileWindow, SLOT(compileStarted()));
QObject::connect(&worker, SIGNAL(compilationDidFinish()), &compileWindow, SLOT(compileFinished()));
QObject::connect(&compileWindow, SIGNAL(runClicked()), &compileWindow, SLOT(hide()));
QObject::connect(&compileWindow, SIGNAL(runClicked()), &runWindow, SLOT(show()));
QObject::connect(&compileWindow, SIGNAL(runClicked()), &worker, SLOT(run()));
QObject::connect(&runWindow, SIGNAL(navigatedBack()), &compileWindow, SLOT(show()));
QObject::connect(&runWindow, SIGNAL(navigatedBack()), &runWindow, SLOT(hide()));
QObject::connect(&worker, SIGNAL(runWillStart()), &runWindow, SLOT(runStarted()));
QObject::connect(&worker, SIGNAL(runDidFinish()), &runWindow, SLOT(runFinished()));
QObject::connect(&worker, SIGNAL(sourceChanged()), &worker, SLOT(compile()));
QObject::connect(&worker, SIGNAL(compilerConsoleOutput(QString const &, int)), &compileWindow, SLOT(printString(QString const &, int)));
QObject::connect(&worker, SIGNAL(runConsoleOutput(QString const &, int)), &runWindow, SLOT(printString(QString const &, int)));
return a.exec();
}
示例15: glfwWindowHint
bool RenderHub::init()
{
//std::cout<<"----------------------------\n"
// <<"SPACE LION - Early Prototype\n"
// <<"----------------------------\n";
// Initialize GLFW
if(!glfwInit())
{
std::cout<<"-----\n"
<<"The time is out of joint - O cursed spite,\n"
<<"That ever I was born to set it right!\n"
<<"-----\n"
<<"Error: Couldn't initialize glfw.";
return false;
}
//std::cout<<"Initializing GLFW\n";
//glfwWindowHint(GLFW_VERSION_MAJOR,3);
//glfwWindowHint(GLFW_VERSION_MINOR,3);
glfwWindowHint(GLFW_SAMPLES, 4);
activeWindow = glfwCreateWindow(800,450,"Sea-Crossing",NULL,NULL);
if(!activeWindow)
{
std::cout<<"-----\n"
<<"The time is out of joint - O cursed spite,\n"
<<"That ever I was born to set it right!\n"
<<"-----\n"
<<"Error: Couldn't open glfw window";
glfwTerminate();
return false;
}
glfwMakeContextCurrent(activeWindow);
/*
/ The callback function needs a reference to this object,
/ so just hand it over and quietly weep in the corner.
*/
setActiveInstance(this);
glfwSetWindowSizeCallback(activeWindow,windowSizeCallback);
glfwSetWindowCloseCallback(activeWindow,windowCloseCallback);
Controls::setControlCallbacks(activeWindow);
/* Initialize glew */
//glewExperimental = GL_TRUE;
GLenum error = glewInit();
if( GLEW_OK != error)
{
std::cout<<"-----\n"
<<"The time is out of joint - O cursed spite,\n"
<<"That ever I was born to set it right!\n"
<<"-----\n"
<<"Error: "<<glewGetErrorString(error);
return false;
}
/*
/ Apparently glweInit() causes a GL ERROR 1280, so let's just catch that...
*/
glGetError();
/*
/ This is actually not supposed to be done like this!
*/
addScene();
setActiveScene(0);
run();
return true;
}