Mercurial
view playground/main.c @ 123:3f4ec30e42e0
Added blog files.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Thu, 08 Jan 2026 06:46:10 -0800 |
| parents | 1c446ab6f945 |
| children | e7899c93da77 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #define REPO_ROOT "/Users/mrjunejune/zenbu" int main() { char command[512]; snprintf(command, sizeof(command), "hg -R %s serve --stdio", REPO_ROOT); printf("command: %s\n", command); FILE *hg_pipe = popen(command, "r+"); if (!hg_pipe) { printf("Failed to open pipe\n"); return -1; } fprintf(hg_pipe, "capabilities\n"); fflush(hg_pipe); char *output = malloc(sizeof(char) * 2048); char *curr = output; int c; int number_of_breakline = 0; while ((c = fgetc(hg_pipe)) != NULL) { *curr++ = c; printf("output: %s\n", output); if (c == '\n') number_of_breakline++; if (number_of_breakline == 2) break; printf("char: %c\n", c); } pclose(hg_pipe); return 0; }