Exemplo n.º 1
0
Arquivo: mpd.c Projeto: avih/miniweb
int mpRead(char* buf, int bufsize)
{
	int n;
	if (mpState == MP_IDLE || !mpx.fdStdoutRead) return 0;
	mpx.buffer = buf;
	mpx.iBufferSize = bufsize;
	n = ShellRead(&mpx);
	if (n < 0) return -1;
	buf[n] = 0;
	return n;
}
Exemplo n.º 2
0
int ShellRun(SHELL_PARAM* param, const char* cmdline)
{
    int ret;
    SHELL_PARAM* proc = param;
    if (!param) proc = calloc(1, sizeof(SHELL_PARAM));

    ret = ShellExec(proc, cmdline);
    if (ret == 0)
    {
        if (proc->flags & SF_READ_STDOUT_ALL)
            ShellRead(proc, -1);
        else
            ShellWait(proc, -1);
    }
    ShellClean(proc);

    if (!param)
    {
        free(proc);
    }
    return ret;
}