Commit 68b7fa97 authored by Hellwig Geisse's avatar Hellwig Geisse

add another two converters

parent 881f208c
......@@ -4,7 +4,7 @@
BUILD = ../build
DIRS = mkdisk oberon2unix unix2oberon mem2bin
DIRS = mkdisk dos2oberon oberon2dos oberon2unix unix2oberon mem2bin
all:
for i in $(DIRS) ; do \
......
#
# Makefile for DOS-to-Oberon text converter
#
BUILD = ../../build
all: dos2oberon
install: dos2oberon
mkdir -p $(BUILD)/bin
cp dos2oberon $(BUILD)/bin
dos2oberon: dos2oberon.c
gcc -g -Wall -o dos2oberon dos2oberon.c
clean:
rm -f *~ dos2oberon
/*
* dos2oberon.c -- convert DOS line endings to Oberon line endings
*/
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE *in, *out;
int c;
if (argc != 3) {
printf("usage: %s <input file> <output file>\n", argv[0]);
return 1;
}
in = fopen(argv[1], "r");
if (in == NULL) {
printf("error: cannot open input file '%s'\n", argv[1]);
return 1;
}
out = fopen(argv[2], "w");
if (out == NULL) {
printf("error: cannot open output file '%s'\n", argv[2]);
return 1;
}
while (1) {
c = fgetc(in);
if (c == EOF) {
break;
}
if (c == '\r') {
c = fgetc(in);
if (c != EOF && c != '\n') {
ungetc(c, in);
}
c = '\r';
}
fputc(c, out);
}
fclose(in);
fclose(out);
return 0;
}
#
# Makefile for Oberon-to-DOS text converter
#
BUILD = ../../build
all: oberon2dos
install: oberon2dos
mkdir -p $(BUILD)/bin
cp oberon2dos $(BUILD)/bin
oberon2dos: oberon2dos.c
gcc -g -Wall -o oberon2dos oberon2dos.c
clean:
rm -f *~ oberon2dos
/*
* oberon2dos.c -- convert Oberon line endings to DOS line endings
*/
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE *in, *out;
int c;
if (argc != 3) {
printf("usage: %s <input file> <output file>\n", argv[0]);
return 1;
}
in = fopen(argv[1], "r");
if (in == NULL) {
printf("error: cannot open input file '%s'\n", argv[1]);
return 1;
}
out = fopen(argv[2], "w");
if (out == NULL) {
printf("error: cannot open output file '%s'\n", argv[2]);
return 1;
}
while (1) {
c = fgetc(in);
if (c == EOF) {
break;
}
if (c == '\r') {
fputc(c, out);
c = '\n';
}
fputc(c, out);
}
fclose(in);
fclose(out);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment