Exemplo n.º 1
0
Arquivo: Nt.c Projeto: aryx/fork-c--
int
execsh(char *args, char *cmd, Bufblock *buf, Envy *e)
{
    int tot, n, tid, pid;
    HANDLE outin, outout, inout, inin;
    struct {
        char *cmd;
        HANDLE handle;
    } *arg;

    if(buf == 0)
        outout = GetStdHandle(STD_OUTPUT_HANDLE);
    else if(CreatePipe(&outin, &outout, 0, 0) == FALSE) {
        perror("pipe");
        Exit();
    }

    if(CreatePipe(&inin, &inout, 0, 0) == FALSE) {
        perror("pipe");
        Exit();
    }

    arg = malloc(sizeof(*arg));
    arg->cmd = strdup9(cmd);
    arg->handle = inout;
    if(CreateThread(0, 0, writecmd, arg, 0, &tid) == FALSE) {
        perror("spawn writecmd");
        Exit();
    }

    pid = spinoff(inin, outout, args, 0, e);
    CloseHandle(inin);

    if(DEBUG(D_EXEC))
        printf("starting: %s\n", cmd);

    if(buf) {
        CloseHandle(outout);
        tot = 0;
        for(;;) {
            if (buf->current >= buf->end)
                growbuf(buf);
            if(ReadFile(outin, buf->current, buf->end-buf->current, &n, 0) == FALSE)
                break;
            buf->current += n;
            tot += n;
        }
        if (tot && buf->current[-1] == '\n')
            buf->current--;
        CloseHandle(outin);
    }

    return pid;
}
Exemplo n.º 2
0
Arquivo: Nt.c Projeto: aryx/fork-c--
int
pipecmd(char *cmd, Envy *e, int *fd)
{
    int pid;
    HANDLE pipein, pipeout;

    if(fd) {
        if(CreatePipe(&pipein, &pipeout, 0, 0) == FALSE) {
            perror("pipe");
            Exit();
        }
    } else
        pipeout = GetStdHandle(STD_OUTPUT_HANDLE);


    pid = spinoff(GetStdHandle(STD_INPUT_HANDLE), pipeout, "-c", cmd, e);

    if(fd) {
        CloseHandle(pipeout);
        *fd = _open_osfhandle((long)pipein, 0);
    }
    return pid;
}
Exemplo n.º 3
0
// Function to process which action to take with current trade
void portfolio::action(pTrade input){
  //  cout << "Enter action" << endl;
  if(input.sortID == "CD")
    return;

  if(input.type == "buy" || input. type == "Buy")
    buy(input);
  else if (input.type == "sell" || input.type == "Sell")
    sell(input);
  else if (input.type == "donate" || input.type == "Donate")
    donate(input);
  else if (input.type == "aquisition" || input.type == "Aquisition")
    acquistion(input);
  else if(input.type == "spinoff" || input.type == "Spinoff")
    spinoff(input);
  else if(input.type == "reverse split" || input.type == "split")
    split(input);
  else if(input.type == "exchange")
    exchange(input);
  else if(input.type == "dividend")
    dividend(input);

  //  cout << "Exit action" << endl << endl;
}