large file handling.
+Sat Oct 25 15:04:41 CDT 2003 Adam Heath <doogie@debian.org>
+
+ * lib/mlib.c, include/dpkg.h.in, utils/md5sum.c: Change limit and the
+ return value for buffer_copy to off_t, which fixes large file handling.
+
Sat Oct 25 15:02:27 CDT 2003 Adam Heath <doogie@debian.org>
* almost all .c files: Almost *EVERY* damn file was including config.h in
#define BUFFER_READ_SHUTDOWN 1 << 19
typedef struct buffer_data *buffer_data_t;
-typedef ssize_t (*buffer_proc_t)(buffer_data_t data, void *buf, ssize_t size, const char *desc);
+typedef off_t (*buffer_proc_t)(buffer_data_t data, void *buf, off_t size, const char *desc);
typedef union buffer_arg {
void *ptr;
int i;
buffer_copy_setup_PtrInt(file, BUFFER_READ_STREAM, NULL, \
fd, BUFFER_WRITE_FD, NULL, \
limit, desc)
-ssize_t buffer_copy_setup_PtrInt(void *p, int typeIn, void *procIn,
+off_t buffer_copy_setup_PtrInt(void *p, int typeIn, void *procIn,
int i, int typeOut, void *procOut,
- ssize_t limit, const char *desc, ...);
-ssize_t buffer_copy_setup_PtrPtr(void *p1, int typeIn, void *procIn,
+ off_t limit, const char *desc, ...);
+off_t buffer_copy_setup_PtrPtr(void *p1, int typeIn, void *procIn,
void *p2, int typeOut, void *procOut,
- ssize_t limit, const char *desc, ...);
-ssize_t buffer_copy_setup_IntPtr(int i, int typeIn, void *procIn,
+ off_t limit, const char *desc, ...);
+off_t buffer_copy_setup_IntPtr(int i, int typeIn, void *procIn,
void *p, int typeOut, void *procOut,
- ssize_t limit, const char *desc, ...);
-ssize_t buffer_copy_setup_IntInt(int i1, int typeIn, void *procIn,
+ off_t limit, const char *desc, ...);
+off_t buffer_copy_setup_IntInt(int i1, int typeIn, void *procIn,
int i2, int typeOut, void *procOut,
- ssize_t limit, const char *desc, ...);
-ssize_t buffer_copy_setup(buffer_arg argIn, int typeIn, void *procIn,
+ off_t limit, const char *desc, ...);
+off_t buffer_copy_setup(buffer_arg argIn, int typeIn, void *procIn,
buffer_arg argOut, int typeOut, void *procOut,
- ssize_t limit, const char *desc);
-ssize_t buffer_write(buffer_data_t data, void *buf, ssize_t length, const char *desc);
-ssize_t buffer_read(buffer_data_t data, void *buf, ssize_t length, const char *desc);
-ssize_t buffer_copy(buffer_data_t read_data, buffer_data_t write_data, ssize_t limit, const char *desc);
+ off_t limit, const char *desc);
+off_t buffer_write(buffer_data_t data, void *buf, off_t length, const char *desc);
+off_t buffer_read(buffer_data_t data, void *buf, off_t length, const char *desc);
+off_t buffer_copy(buffer_data_t read_data, buffer_data_t write_data, off_t limit, const char *desc);
extern volatile int onerr_abort;
* License along with dpkg; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <config.h>
+#include "config.h"
#include <unistd.h>
#include <stdio.h>
struct MD5Context ctx;
unsigned char **hash;
};
-ssize_t buffer_write(buffer_data_t data, void *buf, ssize_t length, const char *desc) {
- ssize_t ret= length;
+off_t buffer_write(buffer_data_t data, void *buf, off_t length, const char *desc) {
+ off_t ret= length;
if(data->type & BUFFER_WRITE_SETUP) {
switch(data->type ^ BUFFER_WRITE_SETUP) {
case BUFFER_WRITE_MD5:
break;
case BUFFER_WRITE_FD:
if((ret= write(data->data.i, buf, length)) < 0 && errno != EINTR)
- ohshite(_("failed in buffer_write(fd) (%i, ret=%zi %s): %s"), data->data.i, ret, desc);
+ ohshite(_("failed in buffer_write(fd) (%i, ret=%li %s): %s"), data->data.i, (long)ret, desc);
break;
case BUFFER_WRITE_NULL:
break;
return ret;
}
-ssize_t buffer_read(buffer_data_t data, void *buf, ssize_t length, const char *desc) {
- ssize_t ret= length;
+off_t buffer_read(buffer_data_t data, void *buf, off_t length, const char *desc) {
+ off_t ret= length;
if(data->type & BUFFER_READ_SETUP) {
return 0;
}
}
#define buffer_copy_setup_dual(name, type1, name1, type2, name2) \
-ssize_t buffer_copy_setup_##name(type1 n1, int typeIn, void *procIn,\
+off_t buffer_copy_setup_##name(type1 n1, int typeIn, void *procIn,\
type2 n2, int typeOut, void *procOut,\
- ssize_t limit, const char *desc, ...)\
+ off_t limit, const char *desc, ...)\
{\
va_list al;\
buffer_arg a1, a2;\
struct varbuf v;\
- ssize_t ret;\
+ off_t ret;\
a1.name1 = n1; a2.name2 = n2;\
varbufinit(&v);\
va_start(al,desc);\
buffer_copy_setup_dual(PtrInt, void *, ptr, int, i);
buffer_copy_setup_dual(PtrPtr, void *, ptr, void *, ptr);
-ssize_t buffer_copy_setup(buffer_arg argIn, int typeIn, void *procIn,
+off_t buffer_copy_setup(buffer_arg argIn, int typeIn, void *procIn,
buffer_arg argOut, int typeOut, void *procOut,
- ssize_t limit, const char *desc)
+ off_t limit, const char *desc)
{
struct buffer_data read_data = { procIn, argIn, typeIn },
write_data = { procOut, argOut, typeOut };
- ssize_t ret;
+ off_t ret;
if ( procIn == NULL )
read_data.proc = buffer_read;
return ret;
}
-ssize_t buffer_copy(buffer_data_t read_data, buffer_data_t write_data, ssize_t limit, const char *desc) {
+off_t buffer_copy(buffer_data_t read_data, buffer_data_t write_data, off_t limit, const char *desc) {
char *buf, *writebuf;
long bytesread= 0, byteswritten= 0;
int bufsize= 32768;
- ssize_t totalread= 0, totalwritten= 0;
- if((limit != -1) && (limit < bufsize)) bufsize= limit;
+ off_t totalread= 0, totalwritten= 0;
+ if((limit!=-1) && (limit < bufsize)) bufsize= limit;
if(bufsize == 0)
return 0;
writebuf= buf= malloc(bufsize);
break;
totalread+= bytesread;
- if(limit!=-1) {
+ if(limit != -1) {
limit-= bytesread;
if(limit<bufsize)
bufsize=limit;
int
mdfile(int fd, unsigned char **digest)
{
- ssize_t ret;
- while ((ret = fd_md5(fd, digest, 100 * 1024 * 1024, _("mdfile"))) >= 0);
+ off_t ret = fd_md5(fd, digest, -1, _("mdfile"));
if ( ret >= 0 )
return 0;
else