diff --git a/src/bin/cat/Makefile b/src/bin/cat/Makefile new file mode 100755 index 0000000..3b37181 --- /dev/null +++ b/src/bin/cat/Makefile @@ -0,0 +1,48 @@ +# $Id$ +# Application Makefile (C) 2002-2004 The UbixOS Project + +# Include Global 'Source' Options +include ../../Makefile.inc +include ../Makefile.inc + +#Linker +LD = ld + +#Binary File Name +BINARY = cat + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +LIBRARIES = ../../lib/libc_old/libc_old.so + +# Link The Binary +$(BINARY) : $(OBJS) + $(CC) $(CFLAGS) -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + strip $(BINARY) + +# Compile the source files +.cpp.o: + $(CXX) -Wall -O $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.cc.o: + $(CXX) -Wall -O $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.cc.s: + $(CXX) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.c.o: + $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.c.s: + $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.S.o: + $(CC) -Wall $(CLFAGS) $(INCLUDES) -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/src/bin/cat/main.c b/src/bin/cat/main.c new file mode 100644 index 0000000..0ef45d9 --- /dev/null +++ b/src/bin/cat/main.c @@ -0,0 +1,30 @@ +#include + +int main(int argc, char *argv[]) +{ + if(argc != 2) + { + printf("Usage: %s \n", argv[0]); + return 1; + } + else + { + FILE *fd; + char buffer[4096]; + + fd = fopen(argv[1], "rb"); + if(fd == NULL) + { + printf("Usage: %s \n", argv[0]); + return 1; + } + while(feof(fd) == 0) + { + fread(buffer, 4096, 1, fd); + printf("%s", buffer); + } + fclose(fd); + + } + return 0; +}