-
Notifications
You must be signed in to change notification settings - Fork 0
/
ATARIDOS.C
executable file
·170 lines (146 loc) · 5.35 KB
/
ATARIDOS.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* Programm ATARIDOS.C konvertiert Textdateien von ATARI- nach */
/* DOS-Format. Dazu mssen diese auf einer DOS-formatierten Diskette */
/* auf dem ATARI abgespeichert worden sein (720 KB Diskette). */
#include <stdio.h>
main()
{
FILE *stream;
FILE *in;
char datei_out[67];
char datei_in[67];
int j, ch, chsp1, chsp2, chsp3, chsp4;
printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»" );
printf("º ATARIDOS (c) 1992 Rolf Bernhardt, Tel. 02533/2174 º" );
printf("º º" );
printf("º Mit Hilfe dieses Programmes k”nnen ATARI-Textdateien in DOS-Textdateien º" );
printf("º berfhrt werden. Formatierungen, Trennungen usw. werden weitgehend aus der º" );
printf("º Atari-Textdatei entfernt. Ca. 98%% der unter DOS nicht nutzbaren Formatierun- º" );
printf("º gen werden durch dieses Programm berschrieben. Sie mssen den Text nach der º" );
printf("º Konvertierung nach eventuell verbliebenen unbrauchbaren Zeichen durchsuchen! º" );
printf("º º" );
printf("º Im aktuellen Pfad muá die tempor„re Datei 'atari.tmp' speicherbar sein. Eine º" );
printf("º eventuell existierende Datei gleichen Namens wird berschrieben. º" );
printf("º Drcken Sie bei den gefragten Dateinamen nur RETURN, so endet das Programm. º" );
printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ" );
printf("\n Aus welcher ATARI-Datei lesen? ");
gets( datei_out );
if( strlen(datei_out) == 0 ) exit(0);
printf("\n In welche DOS-Datei schreiben? ");
gets( datei_in );
if( strlen(datei_in) == 0 ) exit(0);
printf( "\n\n %s -> %s ", datei_out, datei_in);
if( (stream = fopen(datei_out,"r")) == NULL)
{
printf("\nDatei %s konnte zum Lesen nicht ge”ffnet werden!", datei_out);
exit(1);
}
if( (in = fopen(datei_in,"w")) == NULL)
{
printf("\nDatei %s konnte zum Schreiben nicht ge”ffnet werden!", datei_in);
exit(1);
}
ch = fgetc(stream);
if( ch == 30 )
ch = 32;
if( ch == 158 )
ch = 225;
while( !feof(stream) )
{
if( ( (ch > 31) || (ch == 10) ) && ( (ch != 128) && (ch != 133) ) )
fputc( ch, in); /* ATARI-Steuerzeichen nicht bersetzen */
ch = fgetc(stream); /* n„chstes Zeichen holen */
if( ch == 30 ) ch = 32;
if( ch == 158 ) ch = 225;
if( ch == 27 ) ch = 13;
if( ch == '-' ) /* Trennzeichen? */
{
chsp1 = ch; /* Zeichen erstmal speichern */
ch = fgetc(stream); /* Noch ein Zeichen holen */
if( ch == 30 ) ch = 32;
chsp2 = ch; /* Auch speichern */
ch = fgetc(stream); /* Noch ein Zeichen holen */
if( ch == 30 ) ch = 32;
chsp3 = ch; /* Auch speichern */
ch = fgetc(stream); /* Noch ein Zeichen holen */
if( ch == 30 ) ch = 32;
chsp4 = ch; /* Auch speichern */
if( chsp3 == 10 || chsp3 == 29 ) /* Folgt CR? */
{
fputc( chsp4, in );
ch = fgetc(stream); /* '-' und ' ' und CR ignorieren */
if( ch == 30 ) ch = 32;
}
else if( chsp2 == 10 ) /* Folgt CR? */
{
fputc( chsp3, in );
fputc( chsp4, in );
ch = fgetc(stream); /* '-' und ' ' und CR ignorieren */
if( ch == 30 ) ch = 32;
}
else
{
fputc( chsp1, in );
fputc( chsp2, in );
fputc( chsp3, in );
fputc( chsp4, in );
ch = fgetc( stream );
if( ch == 30 ) ch = 32;
}
}
if( ch == 10 ) /* CR? */
{
chsp1 = ch;
ch = fgetc(stream);
if( ch == 30 ) ch = 32;
chsp2 = ch;
if( chsp2 != 10 ) /* Zeilenwechsel */
{
fputc( 13, in ); /* 'Harten' Absatz ausgeben */
fputc( chsp2, in );
ch = fgetc( stream );
if( ch == 30 ) ch = 32;
}
}
}
fclose(stream);
fclose(in);
stream = fopen(datei_in,"r");
if( (in = fopen("atari.tmp","w")) == NULL)
{
printf("\nDatei 'atari.tmp' konnte zum Schreiben nicht ge”ffnet werden!" );
exit(1);
}
chsp1 = fgetc( stream );
chsp2 = fgetc( stream );
if( chsp1 == 32 && chsp2 == 32 )
{
fputc( 32, in );
}
while( !feof(stream) )
{
chsp1 = fgetc( stream );
chsp2 = fgetc( stream );
if( chsp1 == 32 && chsp2 == 32 )
{
fputc( 32, in );
}
else
{
fputc( chsp1, in );
fputc( chsp2, in );
}
}
fclose(stream);
fclose(in);
stream = fopen("atari.tmp","r");
in = fopen(datei_in,"w");
while( !feof(stream) )
{
ch = fgetc(stream);
fputc( ch, in );
}
fclose(stream);
fclose(in);
printf( "\x1B[%i;%iH",20,0 );
printf( " Konvertierung von %s nach %s beendet. \n\n", datei_out, datei_in);
}