Further to this...

This is how the program flow works. There are a series of modules (compiled
with CRTCMOD) - the most important being UNZIP and MINIUNZ. UNZIP is the
wrapper for zLib. UNZIP has a struct in it called "unz_s" which stores the
FILE* in it. Now, the calling program (MINIUNZ) calls an Open ZIP function
which does a fopen(path, "rb") on the input file:

extern unzFile ZEXPORT unzOpen (path)
        const char *path;
{
        unz_s *s;
        unz_s us;

        ...

        opfin = fopen(path, "rb");

        ...

        us.file=opfin;

        ...


        s=(unz_s*)ALLOC(sizeof(unz_s));
        *s=us;
        s->file = opfin;
        unzGoToFirstFile((unzFile)s);
        return (unzFile)s;
}

Here, the opfin is declared outside the function within the module.

Now, at this point if I add an fseek/fread then it works. As soon as it
returns to the calling function (in MINIUNZ) and calls another function
(again in the UNZIP module) the FILE* now won't work.

Originally, the opfin was not global but I've now even tried to make the
opfin externally defined (in MINIUNZ) w/o any luck.

It seems to be a problem with scope but I don't have enough experience with
AS/400 programming to track it down.

S.

-----Original Message-----
From: Steven Newson [mailto:steven.newson@chp.co.uk]
Sent: 22 February 2002 15:52
To: 'c400-l@midrange.com'
Subject: [C400-L] zLib

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--
[ Picked text/plain from multipart/alternative ]
I've been trying to get zlib to work on my AS/400. I'm using an addon (from
http://homepage1.nifty.com/uzaemon/ <http://homepage1.nifty.com/uzaemon/> )
which allows me to just handle ZIP files. I've managed to get the
compression to work, but the miniunz (mini unzip) program will not work
correctly. I was wondering if anyone else has attempted to use this and had
any problems.

Whenever I run miniunz then I get a "Pointer not set for location
referenced." message on the job log. I've tracked this down to the following
piece of code in "unzip.c":

if (fseek(pfile_in_zip_read_info->file,
file_in_zip_read_info->pos_in_zipfile +
pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
return UNZ_ERRNO;

I've tried patching this code to:

if (fseek(fin, 0, SEEK_SET) != 0)
            return UNZ_ERRNO;

But I still get the error. I've also made fin a global variable and ensured
that it never gets closed once it has opened. However, if I just comment out
this line then the following "fread" fails in the same way. It's definitely
the FILE* that's causing the problem since I can replace it with stdin and
no get any problems (other than the obvious).

It's driving me insane so any help would be greatfully received :-)

Steve.
_______________________________________________
This is the C programming iSeries / AS400 (C400-L) mailing list
To post a message email: C400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/c400-l
or email: C400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.


This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact [javascript protected email address].