Package: psutils / 1.17.dfsg-2

off_t.patch Patch series | download
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
Index: psutils-1.17.dfsg/psutil.c
===================================================================
--- psutils-1.17.dfsg.orig/psutil.c	2012-08-25 06:25:33.273367851 -0400
+++ psutils-1.17.dfsg/psutil.c	2012-08-25 06:25:33.653367839 -0400
@@ -5,7 +5,10 @@
  * utilities for PS programs
  */
 
+
 /*
+ *  Daniele Giacomini appunti2@gmail.com 2010-09-02
+ *    Changed to using ftello() and fseeko()
  *  AJCD 6/4/93
  *    Changed to using ftell() and fseek() only (no length calculations)
  *  Hunter Goatley    31-MAY-1993 23:33
@@ -13,6 +16,9 @@
  *  Hunter Goatley     2-MAR-1993 14:41
  *    Added VMS support.
  */
+
+#define _FILE_OFFSET_BITS 64
+
 #include "psutil.h"
 #include "pserror.h"
 #include "patchlev.h"
@@ -20,6 +26,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <stdio.h>
 
 #define iscomment(x,y) (strncmp(x,y,strlen(y)) == 0)
 
@@ -33,14 +40,14 @@
 
 static char buffer[BUFSIZ];
 static long bytes = 0;
-static long pagescmt = 0;
-static long headerpos = 0;
-static long endsetup = 0;
-static long beginprocset = 0;		/* start of pstops procset */
-static long endprocset = 0;
+static off_t pagescmt = 0;
+static off_t headerpos = 0;
+static off_t endsetup = 0;
+static off_t beginprocset = 0;		/* start of pstops procset */
+static off_t endprocset = 0;
 static int outputpage = 0;
 static int maxpages = 100;
-static long *pageptr;
+static off_t *pageptr;
 
 /* list of paper sizes supported */
 static Paper papersizes[] = {
@@ -94,15 +101,15 @@
 #if defined(WINNT)
   struct _stat fs ;
 #else
-  long fpos;
+  off_t fpos;
 #endif
 
 #if defined(WINNT)
   if (_fstat(fileno(fp), &fs) == 0 && (fs.st_mode&_S_IFREG) != 0)
     return (fp);
 #else
-  if ((fpos = ftell(fp)) >= 0)
-    if (!fseek(fp, 0L, SEEK_END) && !fseek(fp, fpos, SEEK_SET))
+  if ((fpos = ftello(fp)) >= 0)
+    if (!fseeko(fp, (off_t) 0, SEEK_END) && !fseeko(fp, fpos, SEEK_SET))
       return (fp);
 #endif
 
@@ -127,7 +134,7 @@
 
   /* discard the input file, and rewind the temporary */
   (void) fclose(fp);
-  if (fseek(ft, 0L, SEEK_SET) != 0)
+  if (fseeko(ft, (off_t) 0, SEEK_SET) != 0)
     return (NULL) ;
 
   return (ft);
@@ -137,10 +144,10 @@
 
 /* copy input file from current position upto new position to output file,
  * ignoring the lines starting at something ignorelist points to */
-static int fcopy(long upto, long *ignorelist)
+static int fcopy(off_t upto, off_t *ignorelist)
 {
-  long here = ftell(infile);
-  long bytes_left;
+  off_t here = ftello(infile);
+  off_t bytes_left;
 
   if (ignorelist != NULL) {
     while (*ignorelist > 0 && *ignorelist < here)
@@ -151,7 +158,7 @@
       if (!r || fgets(buffer, BUFSIZ, infile) == NULL)
 	return 0;
       ignorelist++;
-      here = ftell(infile);
+      here = ftello(infile);
       while (*ignorelist > 0 && *ignorelist < here)
 	ignorelist++;
     }
@@ -172,27 +179,27 @@
 }
 
 /* build array of pointers to start/end of pages */
-void scanpages(long *sizeheaders)
+void scanpages(off_t *sizeheaders)
 {
    register char *comment = buffer+2;
    register int nesting = 0;
-   register long int record;
+   register off_t record;
 
    if (sizeheaders)
      *sizeheaders = 0;
 
-   if ((pageptr = (long *)malloc(sizeof(long)*maxpages)) == NULL)
+   if ((pageptr = (off_t *)malloc(sizeof(off_t)*maxpages)) == NULL)
       message(FATAL, "out of memory\n");
    pages = 0;
-   fseek(infile, 0L, SEEK_SET);
-   while (record = ftell(infile), fgets(buffer, BUFSIZ, infile) != NULL)
+   fseeko(infile, (off_t) 0, SEEK_SET);
+   while (record = ftello(infile), fgets(buffer, BUFSIZ, infile) != NULL)
       if (*buffer == '%') {
 	 if (buffer[1] == '%') {
 	    if (nesting == 0 && iscomment(comment, "Page:")) {
 	       if (pages >= maxpages-1) {
 		  maxpages *= 2;
-		  if ((pageptr = (long *)realloc((char *)pageptr,
-					     sizeof(long)*maxpages)) == NULL)
+		  if ((pageptr = (off_t *)realloc((char *)pageptr,
+					     sizeof(off_t)*maxpages)) == NULL)
 		     message(FATAL, "out of memory\n");
 	       }
 	       pageptr[pages++] = record;
@@ -219,7 +226,7 @@
 	    } else if (headerpos == 0 && iscomment(comment, "Pages:"))
 	       pagescmt = record;
 	    else if (headerpos == 0 && iscomment(comment, "EndComments"))
-	       headerpos = ftell(infile);
+	       headerpos = ftello(infile);
 	    else if (iscomment(comment, "BeginDocument") ||
 		     iscomment(comment, "BeginBinary") ||
 		     iscomment(comment, "BeginFile"))
@@ -231,23 +238,23 @@
 	    else if (nesting == 0 && iscomment(comment, "EndSetup"))
 	       endsetup = record;
 	    else if (nesting == 0 && iscomment(comment, "BeginProlog"))
-	       headerpos = ftell(infile);
+	       headerpos = ftello(infile);
 	    else if (nesting == 0 &&
 		       iscomment(comment, "BeginProcSet: PStoPS"))
 	       beginprocset = record;
 	    else if (beginprocset && !endprocset &&
 		     iscomment(comment, "EndProcSet"))
-	       endprocset = ftell(infile);
+	       endprocset = ftello(infile);
 	    else if (nesting == 0 && (iscomment(comment, "Trailer") ||
 				      iscomment(comment, "EOF"))) {
-	       fseek(infile, record, SEEK_SET);
+	       fseeko(infile, record, SEEK_SET);
 	       break;
 	    }
 	 } else if (headerpos == 0 && buffer[1] != '!')
 	    headerpos = record;
       } else if (headerpos == 0)
 	 headerpos = record;
-   pageptr[pages] = ftell(infile);
+   pageptr[pages] = ftello(infile);
    if (endsetup == 0 || endsetup > pageptr[0])
       endsetup = pageptr[0];
 }
@@ -255,7 +262,7 @@
 /* seek a particular page */
 void seekpage(int p)
 {
-   fseek(infile, pageptr[p], SEEK_SET);
+   fseeko(infile, pageptr[p], SEEK_SET);
    if (fgets(buffer, BUFSIZ, infile) != NULL &&
        iscomment(buffer, "%%Page:")) {
       char *start, *end;
@@ -332,14 +339,14 @@
 }
 
 /* write from start of file to end of header comments */
-void writeheader(int p, long *ignore)
+void writeheader(int p, off_t *ignore)
 {
    writeheadermedia(p, ignore, -1, -1);
 }
 
-void writeheadermedia(int p, long *ignore, double width, double height)
+void writeheadermedia(int p, off_t *ignore, double width, double height)
 {
-   fseek(infile, 0L, SEEK_SET);
+    fseeko(infile, (off_t) 0, SEEK_SET);
    if (pagescmt) {
       if (!fcopy(pagescmt, ignore) || fgets(buffer, BUFSIZ, infile) == NULL)
 	 message(FATAL, "I/O error in header\n");
@@ -362,7 +369,7 @@
    if (beginprocset && !fcopy(beginprocset, NULL))
       message(FATAL, "I/O error in prologue\n");
    if (endprocset)
-      fseek(infile, endprocset, SEEK_SET);
+      fseeko(infile, endprocset, SEEK_SET);
    writeprolog();
    return !beginprocset;
 }
@@ -384,7 +391,7 @@
 /* write trailer */
 void writetrailer(void)
 {
-   fseek(infile, pageptr[pages], SEEK_SET);
+   fseeko(infile, pageptr[pages], SEEK_SET);
    while (fgets(buffer, BUFSIZ, infile) != NULL) {
       writestring(buffer);
    }
Index: psutils-1.17.dfsg/psutil.h
===================================================================
--- psutils-1.17.dfsg.orig/psutil.h	2012-08-25 06:25:33.273367851 -0400
+++ psutils-1.17.dfsg/psutil.h	2012-08-25 06:25:33.653367839 -0400
@@ -4,7 +4,7 @@
  *
  * utilities for PS programs
  */
-
+#define _FILE_OFFSET_BITS 64
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -32,14 +32,14 @@
 extern void writepageheader(char *label, int p);
 extern void writepagesetup(void);
 extern void writepagebody(int p);
-extern void writeheader(int p, long *ignorelist);
-extern void writeheadermedia(int p, long *ignorelist, double width, double height);
+extern void writeheader(int p, off_t *ignorelist);
+extern void writeheadermedia(int p, off_t *ignorelist, double width, double height);
 extern int writepartprolog(void);
 extern void writeprolog(void);
 extern void writesetup(void);
 extern void writetrailer(void);
 extern void writeemptypage(void);
-extern void scanpages(long *sizeheaders);
+extern void scanpages(off_t *sizeheaders);
 extern void writestring(char *s);
 
 /* These variables are imported from the client program (e.g. psbook, psnup,
Index: psutils-1.17.dfsg/psspec.c
===================================================================
--- psutils-1.17.dfsg.orig/psspec.c	2012-08-25 06:25:33.277367851 -0400
+++ psutils-1.17.dfsg/psspec.c	2012-08-25 06:25:33.657367838 -0400
@@ -143,7 +143,7 @@
   pstops_write(modulo, pps, nobind, specs, draw, NULL);
 }
 
-void pstops_write(int modulo, int pps, int nobind, PageSpec *specs, double draw, long *ignorelist)
+void pstops_write(int modulo, int pps, int nobind, PageSpec *specs, double draw, off_t *ignorelist)
 {
    int thispg, maxpage;
    int pageindex = 0;
Index: psutils-1.17.dfsg/psspec.h
===================================================================
--- psutils-1.17.dfsg.orig/psspec.h	2012-08-25 06:25:33.273367851 -0400
+++ psutils-1.17.dfsg/psspec.h	2012-08-25 06:25:33.657367838 -0400
@@ -29,4 +29,4 @@
 extern void pstops(int modulo, int pps, int nobind, PageSpec *specs,
 		   double draw);
 extern void pstops_write(int modulo, int pps, int nobind, PageSpec *specs,
-                         double draw, long *ignorelist);
+                         double draw, off_t *ignorelist);
Index: psutils-1.17.dfsg/psnup.c
===================================================================
--- psutils-1.17.dfsg.orig/psnup.c	2012-08-25 06:25:33.273367851 -0400
+++ psutils-1.17.dfsg/psnup.c	2012-08-25 06:25:33.657367838 -0400
@@ -88,7 +88,7 @@
    double iwidth, iheight ;			/* input paper size */
    double tolerance = 100000;			/* layout tolerance */
    Paper *paper = NULL;
-   long sizeheaders[20];			/* headers to remove */
+   off_t sizeheaders[20];			/* headers to remove */
    int opt;
 
 #ifdef DEBIAN
Index: psutils-1.17.dfsg/psresize.c
===================================================================
--- psutils-1.17.dfsg.orig/psresize.c	2012-08-25 06:25:33.273367851 -0400
+++ psutils-1.17.dfsg/psresize.c	2012-08-25 06:25:33.657367838 -0400
@@ -61,7 +61,7 @@
    int rotate;
    double inwidth = -1;
    double inheight = -1;
-   long sizeheaders[20];			/* headers to remove */
+   off_t sizeheaders[20];			/* headers to remove */
    Paper *paper = NULL;
    PageSpec *specs;
    int opt;