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


C++ redirect函数代码示例

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


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

示例1: GetSessionId

bool ESP8266WebServerEx::VerifyCookie(const char* mime) {
  if ( !hasLogin || strcmp(mime,"text/html")!=0 ) return true;

  String session = GetSessionId();
  long tag = -1;
  if ( session.length()==32 && g_Session.isValid(session,&tag) ) {
    if ( tag>0 && tag<10 ) {
      SetSessionId(session);
      return true;
    }
  }
  redirect("/"); 
  return false;    
}
开发者ID:binhpham1909,项目名称:Arduino,代码行数:14,代码来源:ESP8266WebServerEx.cpp

示例2: main

int main() {

  /* redirect the standand IO to /dev/tty */
    if (redirect(STDOUT_FILENO, "/dev/tty", O_WRONLY | O_CREAT) == -1) {
        return -1;
	  }

if (redirect(STDIN_FILENO, "/dev/tty", O_RDONLY) == -1) {
return -1;
}

while (1) {
char line[256]; /* assume the longest command will have less than 256 characters */
char *command;

printf ("utdash$ ");
fgets(line, sizeof(line), stdin);
command = trim(line);
process(command);
}

return 0;
}
开发者ID:madhavivenkatesh,项目名称:Simple-Bash,代码行数:23,代码来源:SimpleShell.c

示例3: main

int main(int argc, char *argv[], char *envp[]) {
   int oldPipe[2]; 
   int newPipe[2];
   printf("$ \n");
   /* For the pipe test, the parent will feed the child. */
   /* In live shell usage, this next line won't exist. */
   pid = 1;
   int i;
   for(i = 0; i < 4; i++){
      if(pid){
         pipe(newPipe);
         redirect(oldPipe, newPipe);
      }
   }
   newPipe[0] = 0;
   newPipe[1] = 0;
   redirect(oldPipe, newPipe); /* This child should print to stdout. */
   if(pid){
      printf("Multi-pipe test successful.\n");
      while(waitpid(-1,return_status) != -1){}; /* Wait until all processes finish. */
   }
   return 0;
}
开发者ID:sapid,项目名称:Minix-Mods,代码行数:23,代码来源:multipipetest.c

示例4: m_isCurrentlyRedirecting

 MetaProcessor::MaybeRedirectOutputRAII::MaybeRedirectOutputRAII(
                                         MetaProcessor* p)
 :m_MetaProcessor(p), m_isCurrentlyRedirecting(0) {
   StringRef redirectionFile;
   m_MetaProcessor->increaseRedirectionRAIILevel();
   if (!m_MetaProcessor->m_PrevStdoutFileName.empty()) {
     redirectionFile = m_MetaProcessor->m_PrevStdoutFileName.back();
     redirect(stdout, redirectionFile.str(), kSTDOUT);
   }
   if (!m_MetaProcessor->m_PrevStderrFileName.empty()) {
     redirectionFile = m_MetaProcessor->m_PrevStderrFileName.back();
     // Deal with the case 2>&1 and 2&>1
     if (strcmp(redirectionFile.data(), "_IO_2_1_stdout_") == 0) {
       // If out is redirected to a file.
       if (!m_MetaProcessor->m_PrevStdoutFileName.empty()) {
         redirectionFile = m_MetaProcessor->m_PrevStdoutFileName.back();
       } else {
         unredirect(m_MetaProcessor->m_backupFDStderr, STDERR_FILENO, stderr);
       }
     }
     redirect(stderr, redirectionFile.str(), kSTDERR);
   }
 }
开发者ID:CristinaCristescu,项目名称:root,代码行数:23,代码来源:MetaProcessor.cpp

示例5: unmake

PatchGrid& PatchGrid::operator=(const PatchGrid& grid) {
	Grid::operator=(grid);
	ntilex = grid.ntilex;
	ntiley = grid.ntiley;
	ntiles = grid.ntiles;

	if (~spec & abstract) {
		unmake();
		make();
	} else {
		redirect();
	}

	return *this;
}
开发者ID:luminoctum,项目名称:prime,代码行数:15,代码来源:PatchGrid.cpp

示例6: protect

void NavigationScheduler::timerFired(Timer<NavigationScheduler>*)
{
    if (!m_frame->page())
        return;
    if (m_frame->page()->defersLoading()) {
        InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
        return;
    }

    Ref<Frame> protect(*m_frame);

    OwnPtr<ScheduledNavigation> redirect(m_redirect.release());
    redirect->fire(m_frame);
    InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:15,代码来源:NavigationScheduler.cpp

示例7: mylogFileSize

    void
    StdOutputRedirector::init(const Arguments & theArguments) {
        if (theArguments.haveOption("--std-logfile")) {
            const char * myEnv = ::getenv(LOG_WRAPAROUND_FILESIZE);
            if (myEnv) {
                string mylogFileSize(myEnv);
                _myMaximumFileSize = asl::as<long>(mylogFileSize);
            }
            myEnv = ::getenv(LOG_CREATE_ON_EACH_RUN);
            if (myEnv) {
                string myTmpStr(myEnv);
                _myLogInOneFileFlag = !(strcmp(toLowerCase(myTmpStr).c_str(), "true") == 0);
            }
            myEnv = ::getenv(LOG_REMOVE_OLD_ARCHIVE);
            if (myEnv) {
                string myTmpStr(myEnv);
                _myRemoveOldArchiveFlag = (strcmp(toLowerCase(myTmpStr).c_str(), "true") == 0);
            }

            myEnv = ::getenv(LOG_WRAPAROUND_CHECK_SEC);
            if (myEnv) {
                string myTmpStr(myEnv);
                _myFileSizeCheckFrequInSec = asl::as<long>(myTmpStr);
            }

            std::string myFilenameWithTimestamp = expandString(theArguments.getOptionArgument("--std-logfile"),
                                     _myOutputFilename);
            if (!_myLogInOneFileFlag) {
                _myOutputFilename = myFilenameWithTimestamp;
            }
            // for syncing c like stderr & c++ cerr
            // default is true, not syncing is supposted to be faster, so maybe we should disable it
            //ios_base::sync_with_stdio(false);

            redirect();

            // write a timestamp
            cout <<  ourAppStartMessage << _myOutputFilename << endl;
            cout << "Timestamp: " << getCurrentTimeString() << endl;
            cout << "---------" << endl;

            // remove all but latest archives
            if (_myRemoveOldArchiveFlag) {
                removeoldArchives();
            }

        }
    }
开发者ID:artcom,项目名称:asl,代码行数:48,代码来源:StdOutputRedirector.cpp

示例8: commonBase

/*
    Common base run for every request.
 */
static void commonBase(HttpStream *stream)
{
    cchar   *uri;

    if (!httpIsAuthenticated(stream)) {
        /*
            Access to certain pages are permitted without authentication so the user can login and logout.
         */
        uri = getUri();
        if (sstarts(uri, "/public/") || smatch(uri, "/user/login") || smatch(uri, "/user/logout")) {
            return;
        }
        feedback("error", "Access Denied. Login required.");
        redirect("/public/login.esp");
    }
}
开发者ID:embedthis,项目名称:esp,代码行数:19,代码来源:app.c

示例9: connect

QNetworkReply *PythonQtDecorator::syncGet(QNetworkAccessManager *self, QNetworkRequest request)
{
    QNetworkReply *reply;
    QEventLoop loop;

    do
    {
        // Request
        reply = self->get(request);
        connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
        loop.exec();
    }
    while (redirect(reply, request));

    return reply;
}
开发者ID:Forkk,项目名称:vlyc2,代码行数:16,代码来源:pythonqtdecorator.cpp

示例10: createSocket

/***************************************************************************//**
 * @author Hayden Waisanen
 *
 * @par Description:
 *    This function temporarily redirect STD_IN or STD_OUT to a file, specified
 *    in the file_name parameter. Must be followed by a restore method call to
 *    restore output or input.
 *
 * @par Class:
 *    Reroute
 *
 * @param[in] int file_no - Redirect STDIN, 0, or STDOUT, 1
 * @param[in] int input_pipe[] - pipe to redirect
 *
 * @returns bool - success or failure
 *
 ******************************************************************************/
bool Reroute::redirect(int file_no, string ip, string port)
{
   //Creae a socket for port and ip
   int sockfd = createSocket(ip, port);
   bool return_val; //Temporary storage for redirect return value

   //Check for a valid socket file descriptor
   if(sockfd < 0)
   {
      return false;
   }

   //Call redirect and return 
   return_val = redirect(file_no, sockfd); 
   return return_val;
}
开发者ID:haydenzone,项目名称:dsh,代码行数:33,代码来源:Reroute.cpp

示例11: processSimple

// Executes a <simple> redirection. If background == true, the command is
// executed in the background. Returns the <simple>'s status, or 0 if background
// is true and we don't wait for it to die.
int processSimple(CMD* cmd, bool background)
{
    if(IS_BUILTIN(cmd->argv[0]))
    {
        int status = execBuiltin(cmd);
        updateStatusVar(status);
        return status;
    }
    
    int pid;
    if((pid = fork()) < 0)
    {
        // error in forking
        perror(EXEC_NAME);
        return errno;
    }
    else if(pid == 0)
    {
        // child
        if(redirect(cmd) < 0)
        {
            exit(errno);
        }
        execvp(cmd->argv[0], cmd->argv);
        perror(EXEC_NAME);
        exit(EXIT_FAILURE);
    }
    else
    {
        // parent        
        if(background)
        {
            return 0;
        }
        else
        {
            int status;
            signal(SIGINT, SIG_IGN);
            waitpid(pid, &status, 0);
            signal(SIGINT, SIG_DFL);
            
            int exitStatus = GET_STATUS(status);
            updateStatusVar(exitStatus);
            return exitStatus;
        }
    }
}
开发者ID:ASchurman,项目名称:Eggshell,代码行数:50,代码来源:process.c

示例12: exec_cmd

int exec_cmd(cmd *command)
{
  pid_t *pids = malloc(command->p_len * sizeof(pid_t));
  int status, i;
  int fds[2][2];
  cmd *cmdp;
  status = pipe(fds[1]); // reduce complexity in the following code
  //fprintf(stderr, "p_len: %d\n", command->p_len);
  for (cmdp = command, i = 0; i < command->p_len; cmdp = cmdp->cmd_next, i++) {
    status = pipe(fds[i % 2]);
    if (status < 0) {
      perror("shell: pipe");
      exit(127);
    }
    if ((pids[i] = fork()) < 0) {
      perror("shell: fork");
      exit(127);
    } else if (pids[i] == 0) { // child process
      signal(SIGTSTP, SIG_DFL);
      signal(SIGINT, SIG_DFL);
      signal(SIGCONT, SIG_DFL);
      if (i != command->p_len-1) // not the first command in pipeline, redirect stdin
        dup2(fds[i%2][0], STDIN_FILENO);
      if (i != 0) // not the last command in pipeline, redirect stdout
        dup2(fds[!(i%2)][1], STDOUT_FILENO);
      close(fds[0][0]); close(fds[0][1]);
      close(fds[1][0]); close(fds[1][1]);
      redirect(cmdp);
      //fprintf(stderr, "exec: %d %d %s\n", i, (int)cmdp, cmdp->argv[0]);
      execvp(cmdp->argv[0], cmdp->argv);
      fputs("shell: ", stderr);
      perror(cmdp->argv[0]);
      exit(127);
    } else { // parent process
      close(fds[!(i%2)][0]); close(fds[!(i%2)][1]);
    }
  }
  //printf("pid: %d\n", pids[0]);
  if (command->bg) {
    jobctl_add_job(pids[0], buf, JOBCTL_RUN, 1);
  } else {
    waitcmd(pids[0], buf);
  }
  free(pids);
  return status;
}
开发者ID:ddjfreedom,项目名称:Shell,代码行数:46,代码来源:main.c

示例13: redirect

void TextCtrlTestCase::Redirector()
{
#if wxHAS_TEXT_WINDOW_STREAM && wxUSE_STD_IOSTREAM

    wxStreamToTextRedirector redirect(m_text);

    std::cout << "stringinput"
              << 10
              << 1000L
              << 3.14f
              << 2.71
              << 'a';

    CPPUNIT_ASSERT_EQUAL("stringinput1010003.142.71a", m_text->GetValue());

#endif
}
开发者ID:ruifig,项目名称:nutcracker,代码行数:17,代码来源:textctrltest.cpp

示例14: protect

void NavigationScheduler::navigateTask()
{
    Platform::current()->currentThread()->scheduler()->removePendingNavigation();

    if (!m_frame->page())
        return;
    if (m_frame->page()->defersLoading()) {
        InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
        return;
    }

    RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());

    OwnPtrWillBeRawPtr<ScheduledNavigation> redirect(m_redirect.release());
    redirect->fire(m_frame);
    InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:17,代码来源:NavigationScheduler.cpp

示例15: httpRequest

void EntryController::create()
{
    if (httpRequest().method() != Tf::Post) {
        return;
    }
    
    Entry entry = Entry::create( httpRequest().formItems("entry") );
    if (!entry.isNull()) {
        QString notice = "Created successfully.";
        tflash(notice);
        redirect(urla("show", entry.id()));
    } else {
        QString error = "Failed to create.";
        texport(error);
        render("entry");
    }
}
开发者ID:AbhimanyuAryan,项目名称:treefrog-framework,代码行数:17,代码来源:entrycontroller.cpp


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