summaryrefslogtreecommitdiff
path: root/support/asc2tex2/tconv.c
blob: 45ff546c75cf00b4f5eb8c2e7c995a9e2a2e5f7a (plain)
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
#include<io.h>
#include<stdio.h>

int main ( int argc, char *argv[] )
{
  char oldName [256];
  char newName [256];
  FILE *oldFile;
  FILE *newFile;
  int zeichen;

  if ( argc < 2 ) {
    printf ( "usage: TCONV <file>\n" );
    printf ( "don't use suffix \".tex\"\n");
    return -1;
  };

  strcpy (oldName, argv[1]);
  strcat (oldName, ".bak");
  strcpy (newName, argv[1]);
  strcat (newName, ".tex");

  if ( rename (newName, oldName) != 0 ) {
    printf ("Konnte Datei nicht umbenennen (*.bak vorhanden ?)\n");
    return -1;
  };

  oldFile = fopen ( oldName, "rb" );
  newFile = fopen ( newName, "wb" );

  if ( oldFile == NULL || newFile == NULL ) {
    printf ("Fehler beim ffnen der Dateien\n");
    fcloseall ();
    return -1;
  };

  do {
   zeichen = getc (oldFile);
   if ( zeichen == 132  ) {  /*  */
     putc ( (int) '\"', newFile ); putc ( (int) 'a', newFile ); }
   else if ( zeichen == 148 ) { /*  */
     putc ( (int) '\"', newFile ); putc ( (int) 'o', newFile ); }
   else if ( zeichen == 129 ) { /*  */
     putc ( (int) '\"', newFile ); putc ( (int) 'u', newFile ); }
   else if ( zeichen == 225 ) { /*  */
     putc ( (int) '\"', newFile ); putc ( (int) 's', newFile ); }
   else if ( zeichen == 142 ) { /*  */
     putc ( (int) '\"', newFile ); putc ( (int) 'A', newFile ); }
   else if ( zeichen == 153 ) { /*  */  
     putc ( (int) '\"', newFile ); putc ( (int) 'O', newFile ); }
   else if ( zeichen == 154 ) { /*  */
     putc ( (int) '\"', newFile ); putc ( (int) 'U', newFile ); }
   else if (zeichen != EOF && zeichen != 26 && zeichen != 13) {
     putc (zeichen, newFile); }
  } while ( zeichen != EOF );
  fcloseall ();
  return 1;
};