inkjar.cpp revision f8352938a2f3b082d86b61757f2ebf21f59222a9
/*
* Copyright (C) 1999, 2000 Bryan Burns
* Copyright (C) 2004 Johan Ceuppens
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
/*
* - configure #ifdefs should be enabled
* - move to cstdlib instead of stdlib.h etc.
* - remove exit functions
* - move to clean C++ code
* - windowsify
* - unseekable files
* - move to LGPL by rewriting macros
* - crcs for compressed files
* - put in eof
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
//#ifdef STDC_HEADERS
//#endif
//#ifdef HAVE_UNISTD_H
//#endif
//#ifdef HAVE_SYS_PARAM_H
//#else
//#define MAXPATHLEN 1024
//#endif
//#ifdef HAVE_DIRENT_H
//#endif
//#ifdef HAVE_FCNTL_H
#include <fcntl.h>
//#endif
#include <cstring>
#include <string>
#include <cstdlib>
#include <glib.h>
#include <zlib.h>
#include "inkjar.h"
#include <fstream>
#ifdef WORDS_BIGENDIAN
((l & 0x00ff0000) >> 8) | \
((l & 0x0000ff00) << 8) | \
((l & 0x000000ff) << 24);
#endif
namespace Inkjar {
{
}
//fixme: the following should probably just return a const gchar* and not
// use strdup
{
}
{
if (_last_filename != NULL)
}
bool JarFile::init_inflation()
{
return false;
}
return true;
}
{
return false;
}
if (!init_inflation())
return false;
return true;
}
{
inflateEnd(&_zs);
return true;
}
return false;
}
bool JarFile::read_signature()
{
return false;
}
#ifdef DEBUG
#endif
if (signature == 0x08074b50) {
//skip data descriptor
return false;
} else {
}
return true;
} else {
return false;
}
return false;
}
{
//no data descriptor
if (!(flags & 0x0008)) {
#ifdef DEBUG
#endif
}
return crc;
}
{
* (filename_length+1));
return NULL;
}
#ifdef DEBUG
#endif
return filename;
}
{
}
{
//get compressed size
return NULL;
}
if (filename_length == 0) {
if (_last_filename != NULL)
return NULL;
}
#ifdef DEBUG
#endif
return NULL;
if (_last_filename != NULL)
//check if this is a directory and skip
char *c_ptr;
if (*(++c_ptr) == '\0') {
return NULL;
}
}
return NULL;
}
unsigned int file_length = 0;//uncompressed file length
return NULL;
}
} else if (method == 0) {
return NULL;
}
} else {
return NULL;
}
return gba;
}
{
unsigned int out_a = 0;
unsigned int in_a = compressed_size;
while(out_a < compressed_size){
return NULL;
}
#ifdef DEBUG
#endif
}
return NULL;
}
return bytes;
}
{
int nbytes;
exit(1);
return 0;
}
return nbytes;
}
/* FIXME: this could probably use ZlibBuffer */
unsigned int& file_length,
{
if (compressed_size == 0)
return NULL;
int nbytes;
unsigned int leftover_in = compressed_size;
do {
< 0) {
}
leftover_in -= RDSZ;
}
* tmp_len);
}
if (ret == Z_STREAM_END) {
break;
}
#ifdef DEBUG
#endif
else
inflateReset(&_zs);
return ret_bytes;
}
{
//fixme: does not work yet
if(flags & 0x0008) {
return false;
}
if(signature != 0x08074b50) {
}
}
#ifdef DEBUG
#endif
}
return true;
}
{
*this = rhs;
}
{
if (this == &rhs)
return *this;
else
if (_last_filename == NULL)
else
return *this;
}
/////////////////////////
// JarFileReader //
/////////////////////////
{
}
return _jarfile.get_next_file_contents();
}
{
if (&rhs == this)
return *this;
return *this;
}
/*
* If the filename gets reset, a jarfile object gets generated again,
* ready to be opened for reading.
*/
{
}
{
}
{
*this = rhs;
}
} // namespace Inkjar
#if 0 //testing code
#include "jar.h"
/*
* This program writes all the files from a jarfile to stdout and inflates
* where needed.
*/
{
if (argc < 2) {
filename = "./ide.jar\0";
} else {
}
for (;;) {
char *c_ptr;
if (last_filename == NULL)
break;
if (*(++c_ptr) == '\0') {
continue;
}
}
else
break;
}
return 0;
}
#endif