view playground/main.c @ 116:7bd795bac997

[Postdog] Added scrollable area to inputs and history files, buttons to delete and view.
author June Park <parkjune1995@gmail.com>
date Wed, 07 Jan 2026 04:52:17 -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;
}