home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
libraries
/
pplib_414
/
example.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-12-15
|
2KB
|
99 lines
/*********************************
* *
* powerpacker.library V34.2 *
* *
* Release 1.1a *
* *
* (c) Oct 1990 Nico François *
* *
* example.c *
* *
* This source is public domain *
* in all respects. *
* *
*********************************/
#include <exec/types.h>
#include <exec/memory.h>
#include <libraries/dos.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>
/* if you define NO_PRAGMAS before including proto/powerpacker.h
you must link with ppSCglue.o or ppLCglue.o */
#include <proto/powerpacker.h>
#include <libraries/ppbase.h>
struct PPBase *PPBase = NULL;
UBYTE *filestart = NULL;
ULONG filelen;
char file[108] = "testfile";
main()
{
int err;
if (!(PPBase = (struct PPBase *)OpenLibrary ("powerpacker.library", 0L)))
puts ("You need powerpacker.library V33+ !");
else {
puts ("Loading file...");
err = ppLoadData (file, DECR_POINTER, 0L, &filestart, &filelen, NULL);
if (err) {
switch (err) {
case PP_READERR:
puts ("Error loading text file !");
break;
case PP_NOMEMORY:
puts ("No memory to decrunch file !");
break;
case PP_PASSERR:
puts ("Incorrect password, loading aborted !");
break;
case PP_OPENERR:
puts ("Can't open file !");
break;
case PP_UNKNOWNPP:
puts ("Crunched with unknown PP !");
break;
default:
puts ("Unknown error !");
break;
}
}
else {
puts ("file in memory, using it...");
/* file is loaded at 'filestart' and can now be used */
/* ... */
puts ("done, freeing file...");
}
}
/* free all resources */
if (filestart) FreeMem (filestart, filelen);
if (PPBase) CloseLibrary ((struct Library *)PPBase);
puts ("exiting.");
exit (0);
}