Exemplo n.º 1
0
int main(void) {
  plan(2);

  const char *downloaded = "__remote_readme__.md";
  unlink(downloaded);

  const char *url = "https://raw.github.com/thlorenz/cre-downloader/master/README.md";
  FILE *fp;

  char *remote = 0;
  int remote_len, status;

  // Download
  fp = fopen(downloaded, "wb");
  status = download_url_file(url, fp);
  fclose(fp);

  cmp_ok(status, "==", 200, "returns status 200");

  // Read downloaded README
  fp = fopen(downloaded, "r");

  remote_len = fs_fsize(fp);
  remote = malloc(remote_len);
  fread(remote, 1, remote_len, fp);
  fclose(fp);

  unlink(downloaded);

  like(remote, "cre-downloader", "downloaded README has same content as local README");

  return 0;
}
Exemplo n.º 2
0
Arquivo: fs.c Projeto: 8cbx/ljudge
char *
fs_fread (FILE *file) {
  size_t fsize = fs_fsize(file);
  return fs_fnread(file, fsize);
}