コード例 #1
0
ファイル: spawn.c プロジェクト: rashadkm/grass_cmake
static char *make_command_line(int shell, const char *cmd, const char **argv)
{
    struct buffer result;
    int i;

    init(&result);

    if (shell) {
	const char *comspec = getenv("COMSPEC");
	append(&result, comspec ? comspec : "cmd.exe");
	append(&result, " /c \"");
	escape_arg(&result, cmd);
    }

    for (i = shell ? 1 : 0; argv[i]; i++) {
	if (result.len > 0)
	    append_char(&result, ' ');
	escape_arg(&result, argv[i]);
    }

    append(&result, "\"");

    return release(&result);
}
コード例 #2
0
ファイル: wrapper.c プロジェクト: wiiiky/pyadb
static char *_am_command(transport_type transport, char *serial,
                         int argc, char **argv) {
    char buf[4096];

    snprintf(buf, sizeof(buf), "shell:am");

    while(argc-- > 0) {
        char *quoted = escape_arg(*argv++);
        if(quoted[0]!='\"') {
            strncat(buf, " ", sizeof(buf) - 1);
            strncat(buf, quoted, sizeof(buf) - 1);
        }
        free(quoted);
    }

    return _send_shellcommand(transport, serial, buf);
}
コード例 #3
0
ファイル: wrapper.c プロジェクト: wiiiky/pyadb
static int _delete_file(transport_type transport, char* serial, char* filename) {
    char buf[4096];
    char* quoted;

    snprintf(buf, sizeof(buf), "shell:rm -f ");
    quoted = escape_arg(filename);
    strncat(buf, quoted, sizeof(buf)-1);
    free(quoted);

    char *result = _send_shellcommand(transport, serial, buf);
    int ret = -1;
    if(result&&strstr(result, "OKAY")) {
        ret = 0;
    }
    free(result);
    return ret;
}