summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/pseudo_llvm-rc.c
blob: 7acb2a3cfe4f6804a2560ef56314b545ae318bd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>

int main(int argc, char* argv[])
{
  FILE* source;
  FILE* target;
  int i;
  for (i = 1; i < argc; ++i) {
    if (strcmp(argv[i], "-bad") == 0) {
      fprintf(stdout, "stdout from bad command line arg '-bad'\n");
      fprintf(stderr, "stderr from bad command line arg '-bad'\n");
      return 1;
    }
  }
  source = fopen(argv[argc - 1], "rb");
  if (source == NULL) {
    return 1;
  }
  target = fopen(argv[argc - 2], "wb");
  if (target != NULL) {
    char buffer[500];
    size_t n = fread(buffer, 1, sizeof(buffer), source);
    fwrite(buffer, 1, n, target);
    fclose(source);
    fclose(target);
    return 0;
  }
  return 1;
}