Home

root/tasks/cat.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

#include "kstructs.h"
#include "syscalls.h"
#include "lib.h"

int main(int argc, char **argv)
{
    int ret;

    FD InFile = open(argv[1]);
    if (InFile != -1) {
        struct FileInfo inf;
        stat(InFile, &inf);

        char *buffer = malloc(inf.Length + 1);
        ret = read(InFile, buffer, inf.Length);
        buffer[inf.Length] = 0;
        write(STDOUT, buffer, inf.Length + 1);
        close(InFile);
        free(buffer);
    }
    exit();
    return (0);
}

/* [<][>][^][v][top][bottom][index][help] */
Home