BINPATH=/usr/bin
all: discspan
-discspan: discspan.c file_size.h
- $(CC) $(CFLAGS) -o discspan discspan.c
+discspan: discspan.c filecopy.o
+ $(CC) $(CFLAGS) -o discspan discspan.c filecopy.o
+filecopy.o: filecopy.c filecopy.h
+ $(CC) $(CFLAGS) -c -o filecopy.o filecopy.c
install:
chmod 755 discspan
uninstall:
rm $(BINPATH)/discspan
clean:
- rm discspan
+ rm -f discspan filecopy.o
#include <sys/stat.h>
#include <unistd.h>
#include "file_size.h"
-
-void filecopy(const char * fsource,
- const char *ftarget)
-{
- FILE *source;
- FILE *target;
- char ch;
-
- source = fopen(fsource, "r");
- target = fopen(ftarget, "w");
-
- while((ch = fgetc(source)) != EOF) {
- fputc(ch, target);
- }
-
- fclose(source);
- fclose(target);
-}
+#include "filecopy.h"
int exists(const char *fname)
{
--- /dev/null
+#include <stdio.h>
+#include "filecopy.h"
+
+void filecopy(const char * fsource,
+ const char *ftarget)
+{
+ FILE *source;
+ FILE *target;
+ char ch;
+
+ source = fopen(fsource, "r");
+ target = fopen(ftarget, "w");
+
+ while((ch = fgetc(source)) != EOF) {
+ fputc(ch, target);
+ }
+
+ fclose(source);
+ fclose(target);
+}
--- /dev/null
+#ifndef FILE_COPY_H_
+#define FILE_COPY_H_
+
+void filecopy(const char *fsource, const char *ftarget);
+
+#endif /* FILE_COPY_H_ */