ADD file via upload

master
prnmxfqg4 2 years ago
parent 572f4eacea
commit 3d212b0252

@ -0,0 +1,55 @@
#define __LIBRARY__
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdarg.h>
FILE __stdout;
#define O_RDONLY 00
#define MSG_LEN 256
#define MAX_NUMBER_BYTES 1024
_syscall3(int,open,const char *,filename,int, flag,int, mode)
_syscall3(int,write,int ,fd,const char *, buf, off_t ,count)
_syscall3(int,read,int ,fildes,char *, buf, off_t ,count)
_syscall0(int,sync)
_syscall1(int,close,int,fildes)
_syscall3(int ,vsprintf1,char *, buf, const char *, fmt, va_list ,args)
static char printbuf[1024];
int printf(const char *fmt,...)
{
write(2,fmt,strlen(fmt));
}
int main(int argc, char **argv)
{
int num, fd;
char msg[MSG_LEN+1];
if (argc == 1)
return EXIT_FAILURE;
/* open the file */
if ((fd=open(argv[1], O_RDONLY, 0)) < 0)
return EXIT_FAILURE;
do{
/* read the file */
if ((num = read(fd, msg, MSG_LEN)) < 0) {
close(fd);
return EXIT_FAILURE;
} else if (num == 0) {
break;
}
/* display on screen */
msg[num] = '\0';
printf( msg);
}while(1);
printf("\n");
/* exit */
close(fd);
sync();
return EXIT_SUCCESS;
}
Loading…
Cancel
Save