attvtfd.c (631B)
1 #include <stdio.h> 2 3 #include "att.h" 4 #include "tfd.h" 5 #include "tfm.h" 6 7 int 8 main(int argc, char **argv) 9 { 10 struct tfm *tfm; 11 FILE *ftfd; 12 13 if (argc != 2) { 14 fprintf(stderr, "attvtf: nombre d’arguments incorrect\n"); 15 return 1; 16 } 17 18 if ((tfm = att_lire(stdin)) == NULL) { 19 fprintf(stderr, "attvtf: erreur lors de la lecture\n"); 20 return 1; 21 } 22 23 if ((ftfd = fopen(argv[1], "wb")) == NULL) { 24 fprintf(stderr, "attvtf: impossible d’ouvrir %s\n", argv[1]); 25 return 1; 26 } 27 28 if (tfd_ecrire(ftfd, tfm) < 0) { 29 fprintf(stderr, "attvtf: erreur dans l’écriture du fichier .att\n"); 30 return 1; 31 } 32 33 tfm_libr(tfm); 34 35 return 0; 36 }