summaryrefslogtreecommitdiff
blob: 63f76d013df2bd471512f9f74d8af14c875738a2 (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
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
diff -ru tic98/main_tic.c tic98-new/main_tic.c
--- tic98/main_tic.c	Thu Jul  1 21:02:56 1999
+++ tic98-new/main_tic.c	Fri Mar 16 11:43:56 2001
@@ -11,6 +11,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <errno.h>
 
 #include "arithcode.h"
 #include "globals.h"
@@ -96,8 +97,10 @@
   marklistptr list=NULL,list2=NULL;
   marktype copy;
 
-  if(marktype_readnamed(fn, image)!=0)
+  if(marktype_readnamed(fn, image)!=0) {
+    fprintf(stderr, "imagefn_to_list(): bad input file %s\n", fn);
     return NULL;
+  }
 
   *w=image->w;
   *h=image->h;
@@ -495,7 +498,10 @@
 
     TimerStart(1);
 
-    freopen(outfilename[0],"wb",stdout);
+    if (! freopen(outfilename[0],"wb",stdout)) {
+	 fprintf(stderr, "failed to open %s for writing: %s\n",
+		 outfilename[0], strerror(errno));
+    }
 
     tic98_init(&t);
     tic98_start_encoding();
@@ -503,8 +509,11 @@
     for(i=0;i<num_in;i++){
       int w,h,xx,yy,ok=0;
       marktype image;
-      list=imagefn_to_list(&image,infilename[i], &w, &h);
-      
+      if (! (list=imagefn_to_list(&image,infilename[i], &w, &h))) {
+	   fprintf(stderr, "cannot read file %s\n", infilename[i]);
+	   exit(1);
+      }
+
       tic98_num_encode(&t,NEW_PAGE);
 
       for(xx=0;xx<image.w;xx++)
@@ -560,7 +569,10 @@
     newoutname=(char*)malloc(sizeof(char)*(strlen(outfilename[0])+10));
     assert(newoutname);
 
-    freopen(infilename[0],"rb",stdin);
+    if (! freopen(infilename[0],"rb",stdin)) {
+	 fprintf(stderr, "failed to open %s for reading: %s\n",
+		 infilename[0], strerror(errno));
+    }
 
     tic98_init(&t);
     tic98_start_decoding();
diff -ru tic98/marklist.c tic98-new/marklist.c
--- tic98/marklist.c	Thu Jul  1 21:56:19 1999
+++ tic98-new/marklist.c	Fri Mar 16 11:44:20 2001
@@ -94,11 +94,11 @@
   magic = magic_popnamed (fn, &err) >> 16;	/* only interested in first 2 bytes */
 
   if (err != 0) {
-    return 1;			/* failure */
     fprintf (stderr, "error - can't open file '%s'\n", fn);
-    return 1;
+    return 1;			/* failure */
   }
   if (!((magic == MAGIC_P1) || (magic == MAGIC_P4))) {
+    fprintf (stderr, "bad magic in file '%s'\n", fn);
     return 1;
   }
   if (fn2) {
diff -ru tic98/utils.c tic98-new/utils.c
--- tic98/utils.c	Tue Jun 22 02:48:43 1999
+++ tic98-new/utils.c	Fri Mar 16 11:23:57 2001
@@ -117,7 +117,7 @@
     }
     else{
 	*err=1;
-/*	error("magic_popnamed","can't open file",fn);*/
+	error("magic_popnamed","can't open file",fn);
 	return 0;
     }
 }