| 164 | #define MAXCOMMAND 4096 |
| 165 | |
| 166 | static int command_loop(const char *child) |
| 167 | { |
| 168 | char buffer[MAXCOMMAND]; |
| 169 | |
| 170 | while (1) { |
| 171 | size_t i; |
| 172 | const char *arg; |
| 173 | |
| 174 | if (!fgets(buffer, MAXCOMMAND - 1, stdin)) { |
| 175 | if (ferror(stdin)) |
| 176 | die("Command input error"); |
| 177 | exit(0); |
| 178 | } |
| 179 | /* Strip end of line characters. */ |
| 180 | i = strlen(buffer); |
| 181 | while (i > 0 && isspace(buffer[i - 1])) |
| 182 | buffer[--i] = 0; |
| 183 | |
| 184 | if (!strcmp(buffer, "capabilities")) { |
| 185 | printf("*connect\n\n"); |
| 186 | fflush(stdout); |
| 187 | } else if (skip_prefix(buffer, "connect ", &arg)) { |
| 188 | printf("\n"); |
| 189 | fflush(stdout); |
| 190 | return run_child(child, arg); |
| 191 | } else { |
| 192 | fprintf(stderr, "Bad command"); |
| 193 | return 1; |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | int cmd_remote_ext(int argc, |
| 199 | const char **argv, |
no test coverage detected