#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

/*
 * First argument: mode (libc or syscall)
 * Second argument: size of buffer
 */

int main(int argc, char *argv[]) {
    char buffer[2000000];
    int i;

    if( !strcmp(argv[1], "syscall") ) {
        i = read(0, &buffer, strtol(argv[2], (char **)NULL, 10));

        while(i > 0) {
            write(1, &buffer, strtol(argv[2], (char **)NULL, 10));
            i = read(0, &buffer, strtol(argv[2], (char **)NULL, 10));
        }
    }
    else if( !strcmp(argv[1], "libc") ) {
        i = fread(&buffer, strtol(argv[2], (char **)NULL, 10), 1, stdin);

        while(i > 0) {
            fwrite(&buffer, strtol(argv[2], (char **)NULL, 10), 1, stdout);
            i = fread(&buffer, strtol(argv[2], (char **)NULL, 10), 1, stdin);
        }

    }
    else {
        printf("%s: Unknown option.\n", argv[0]);
    }

    return 1;
}

