2 * Copyright 2005-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
12 #include "fs_shell_command.h"
15 bool gUsesFifos
= true;
19 send_external_command(const char* command
, int* result
)
21 // open the pipe to the FS shell
22 FILE* out
= fdopen(4, "w");
24 fprintf(stderr
, "Error: Failed to open command output: %s\n",
29 // open the pipe from the FS shell
30 FILE* in
= fdopen(3, "r");
32 fprintf(stderr
, "Error: Failed to open command reply input: %s\n",
38 if (fputs(command
, out
) == EOF
|| fputc('\n', out
) == EOF
39 || fflush(out
) == EOF
) {
40 fprintf(stderr
, "Error: Failed to write command to FS shell: %s\n",
47 if (fgets(buffer
, sizeof(buffer
), in
) == NULL
) {
48 fprintf(stderr
, "Error: Failed to get command reply: %s\n",
55 *result
= strtol(buffer
, &end
, 10);
57 fprintf(stderr
, "Error: Read non-number command reply from FS shell: "