merged 2.2 branch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2000-07-15 19:51:35 +00:00
parent 8a693e6e04
commit f6bcfd974e
1835 changed files with 237729 additions and 67990 deletions

View File

@@ -436,10 +436,10 @@ private:
static void usage()
{
wxString prog = g_argv[0];
wxString basename = prog.BeforeLast('/');
wxString basename = prog.AfterLast('/');
#ifdef __WXMSW__
if ( !basename )
basename = prog.BeforeLast('\\');
basename = prog.AfterLast('\\');
#endif
if ( !basename )
basename = prog;
@@ -788,7 +788,7 @@ void HelpGenVisitor::VisitClass( spClass& cl )
// the file name is built from the class name by removing the leading "wx"
// if any and converting it to the lower case
wxString filename = m_directoryOut;
wxString filename;
if ( name(0, 2) == "wx" ) {
filename << name.c_str() + 2;
}
@@ -798,6 +798,7 @@ void HelpGenVisitor::VisitClass( spClass& cl )
filename.MakeLower();
filename += ".tex";
filename.Prepend(m_directoryOut);
if ( !m_overwrite && wxFile::Exists(filename) ) {
wxLogError("Won't overwrite existing file '%s' - please use '-f'.",
@@ -1938,6 +1939,12 @@ static const char *GetCurrentTime(const char *timeFormat)
/*
$Log$
Revision 1.11 2000/07/15 19:50:42 cvsuser
merged 2.2 branch
Revision 1.10.2.2 2000/03/27 15:33:10 VZ
don't trasnform output dir name to lower case
Revision 1.10 2000/03/11 10:05:23 VS
now compiles with wxBase

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *copy_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 4 1",
" c None",
". c Black",
"X c Gray100",
"o c #000080",
/* pixels */
" ",
" ...... ",
" .XXXX.. ",
" .XXXX.X. ",
" .X..X.oooooo ",
" .XXXXXoXXXXoo ",
" .X....oXXXXoXo ",
" .XXXXXoX..Xoooo",
" .X....oXXXXXXXo",
" .XXXXXoX.....Xo",
" ......oXXXXXXXo",
" oX.....Xo",
" oXXXXXXXo",
" ooooooooo",
" "
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,24 @@
/* XPM */
static char *cut_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 3 1",
" c None",
". c Black",
"X c #000080",
/* pixels */
" ",
" . . ",
" . . ",
" . . ",
" .. .. ",
" . . ",
" ... ",
" . ",
" X.X ",
" X XXX ",
" XXX X X ",
" X X X X ",
" X X X X ",
" X X XX ",
" XX "
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *help_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 4 1",
" c None",
". c Black",
"X c Blue",
"o c #000080",
/* pixels */
" ",
" ...... ",
" .XXXXX.. ",
" .XX...oX.. ",
" .X.. .X.. ",
" .X.. .XX.. ",
" .. .XX.. ",
" .XX.. ",
" .X.. ",
" .X.. ",
" .o.. ",
" .. ",
" .XX.. ",
" .XX.. ",
" ... "
};

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,24 @@
/* XPM */
static char *new_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 3 1",
" c None",
". c Black",
"X c Gray100",
/* pixels */
" ",
" ........ ",
" .XXXXXX.. ",
" .XXXXXX.X. ",
" .XXXXXX.... ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" .XXXXXXXXX. ",
" ........... ",
" "
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,26 @@
/* XPM */
static char *open_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 5 1",
" c None",
". c Black",
"X c Yellow",
"o c Gray100",
"O c #bfbf00",
/* pixels */
" ",
" ... ",
" . . .",
" ..",
" ... ...",
" .XoX....... ",
" .oXoXoXoXo. ",
" .XoXoXoXoX. ",
" .oXoX..........",
" .XoX.OOOOOOOOO.",
" .oo.OOOOOOOOO. ",
" .X.OOOOOOOOO. ",
" ..OOOOOOOOO. ",
" ........... ",
" "
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,26 @@
/* XPM */
static char *paste_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 5 1",
" c Black",
". c None",
"X c Gray100",
"o c #808080",
"O c Cyan",
/* pixels */
" .......",
" XXXXXXX ......",
" XXXXXXX . .....",
" XXXXXXX ....",
" XXXXXXXXXX ....",
" XXXXXXX ....",
" XXXXXX o..o ...",
" XXXXX oOO.oo ..",
" XXXXX .O..o. ..",
" XXXXX ....o. ..",
" XXXXX o..Ooo ..",
" XXXXXX o..o o..",
" XXXXXXX o .",
" XXXXXXXXXX . ",
" .. "
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,26 @@
/* XPM */
static char *print_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 5 1",
" c None",
". c Black",
"X c Gray100",
"o c #808000",
"O c Yellow",
/* pixels */
" ",
" ......... ",
" .XXXXXXXX. ",
" .X.....X. ",
" .XXXXXXXX. ",
" .X.....X.... ",
" .XXXXXXXX. . .",
" .......... . ..",
". . . .",
"............. .",
". ooo . . ",
". OOO ... ",
"............. . ",
" . . . ",
" ........... "
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@@ -0,0 +1,25 @@
/* XPM */
static char *save_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 15 4 1",
" c None",
". c Black",
"X c #808000",
"o c #808080",
/* pixels */
" ",
" .............. ",
" .X. . . ",
" .X. ... ",
" .X. .X. ",
" .X. .X. ",
" .X. .X. ",
" .X. .X. ",
" .XX........oX. ",
" .XXXXXXXXXXXX. ",
" .XX.........X. ",
" .XX...... .X. ",
" .XX...... .X. ",
" .XX...... .X. ",
" ............. "
};

View File

@@ -0,0 +1,23 @@
# Purpose: makefile for toolbar example (Unix)
# Created: 2000-03-14
CC = gcc
PROGRAM = wxib
OBJECTS = $(PROGRAM).o
# implementation
.SUFFIXES: .o .cpp
.cpp.o :
$(CC) -c `wx-config --cflags` -o $@ $<
all: $(PROGRAM)
$(PROGRAM): $(OBJECTS)
$(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
clean:
rm -f *.o $(PROGRAM)

View File

@@ -0,0 +1,10 @@
# Purpose: makefile for toolbar example (BC++ 32bit)
# Created: 2000-03-14
WXDIR = $(WXWIN)
TARGET=wxib
OBJECTS = $(TARGET).obj
!include $(WXDIR)\src\makeprog.b32

View File

@@ -0,0 +1,14 @@
# Purpose: makefile for toolbar example (BC++ 16bit)
# Created: 2000-03-14
!if "$(WXWIN)" == ""
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
!endif
WXDIR = $(WXWIN)
TARGET=toolbar
OBJECTS=$(TARGET).obj
!include $(WXDIR)\src\makeprog.bcc

View File

@@ -0,0 +1,10 @@
# Purpose: makefile for toolbar example (VC++ 1.5x)
# Created: 2000-03-14
WXDIR = $(WXWIN)
TARGET=toolbar
OBJECTS=$(TARGET).obj
!include $(WXDIR)\src\makeprog.msc

View File

@@ -0,0 +1,10 @@
# Purpose: makefile for toolbar example (Cygwin/Mingw32)
# Created: #03.01.00
WXDIR = ../..
TARGET=toolbar
OBJECTS = $(TARGET).o
include $(WXDIR)\src\makeprog.g95

View File

@@ -0,0 +1,37 @@
# Purpose: makefile for toolbar example (Symantec C++)
# Created: 2000-03-14
WXDIR = $(WXWIN)
WXLIB = $(WXDIR)\lib\wx.lib
INCDIR = $(WXDIR)\include
INCLUDE=$(INCDIR)
TARGET=toolbar
include $(WXDIR)\src\makesc.env
toolbar.exe: toolbar.obj $(DEFFILE) toolbar.res
*$(CC) $(LDFLAGS) -o$@ $** $(LIBS)
*$(RC) -k toolbar.res
sc32.def:
echo EXETYPE NT > sc32.def
echo SUBSYSTEM WINDOWS >> sc32.def
sc16.def:
echo NAME $(TARGET) > sc16.def
echo EXETYPE WINDOWS >> sc16.def
echo STUB 'WINSTUB.EXE' >> sc16.def
echo CODE PRELOAD MOVEABLE DISCARDABLE >> sc16.def
echo DATA PRELOAD MOVEABLE MULTIPLE >> sc16.def
echo HEAPSIZE 1024 >> sc16.def
echo STACKSIZE 8192 >> sc16.def
clean:
-del *.obj
-del *.exe
-del *.res
-del *.map
-del *.rws
-del sc32.def
-del sc16.def

View File

@@ -0,0 +1,14 @@
# Purpose: makefile for toolbar example (Salford C++)
# Created: 2000-03-14
PROGRAM = toolbar
OBJECTS = $(PROGRAM).obj
include ..\..\src\makeprog.sl
all: wx $(TARGET)
wx:
cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all
cd $(WXDIR)\samples\toolbar

View File

@@ -0,0 +1,35 @@
# Purpose: makefile for toolbar example (TWIN)
# Created: 2000-03-14
WXDIR = ../..
# All common UNIX compiler flags and options are now in
# this central makefile.
include $(WXDIR)/src/maketwin.env
OBJECTS = $(OBJDIR)/toolbar.$(OBJSUFF) $(OBJDIR)/toolbar.$(OBJSUFF)
all: $(OBJDIR) toolbar$(GUISUFFIX)$(EXESUFF)
wx:
$(OBJDIR):
mkdir $(OBJDIR)
toolbar$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB)
$(CC) $(LDFLAGS) -o toolbar$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS)
$(OBJDIR)/toolbar.$(OBJSUFF): toolbar.$(SRCSUFF)
$(CC) -c $(CPPFLAGS) -o $@ toolbar.$(SRCSUFF)
toolbar.c: toolbar.rc
$(RESCOMP) $(RCINPUTSWITCH) toolbar.rc $(RCOUTPUTSWITCH) toolbar.c $(RESFLAGS)
$(OBJDIR)/toolbar.$(OBJSUFF): toolbar.c
$(CC) -c $(CPPFLAGS) -o $@ toolbar.c
#$(OBJDIR)/toolbar.o: toolbar.rc
# $(RESCOMP) $(RCINPUTSWITCH) toolbar.rc $(RCOUTPUTSWITCH) $(OBJDIR)/toolbar.o $(RESFLAGS)
clean:
rm -f $(OBJECTS) toolbar$(GUISUFFIX).exe core *.rsc *.res

View File

@@ -0,0 +1,23 @@
# Purpose: makefile for toolbar example (Unix)
# Created: 2000-03-14
CC = gcc
PROGRAM = toolbar
OBJECTS = $(PROGRAM).o
# implementation
.SUFFIXES: .o .cpp
.cpp.o :
$(CC) -c `wx-config --cflags` -o $@ $<
all: $(PROGRAM)
$(PROGRAM): $(OBJECTS)
$(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`
clean:
rm -f *.o $(PROGRAM)

View File

@@ -0,0 +1,11 @@
# Purpose: makefile for toolbar example (VC++ 32bit)
# Created: 2000-03-14
# Set WXDIR for your system
WXDIR = $(WXWIN)
PROGRAM=wxib
OBJECTS = $(PROGRAM).obj
!include $(WXDIR)\src\makeprog.vc

View File

@@ -0,0 +1,11 @@
# Purpose: makefile for toolbar example (Watcom)
# Created: 2000-03-14
WXDIR = $(%WXWIN)
PROGRAM = toolbar
OBJECTS = $(PROGRAM).obj
!include $(WXDIR)\src\makeprog.wat

View File

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 766 B

View File

@@ -0,0 +1,44 @@
/* XPM */
static char *mondrian_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 6 1",
" c Black",
". c Blue",
"X c #00bf00",
"o c Red",
"O c Yellow",
"+ c Gray100",
/* pixels */
" ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" oooooo +++++++++++++++++++++++ ",
" ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ .... ",
" ++++++ ++++++++++++++++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++++++++++++++++ ++++ ",
" ++++++ ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
" "
};

View File

@@ -0,0 +1,647 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wxib.cpp
// Purpose: wxInstall Builder
// Author: Julian Smart
// Author: Brian Smith
// Modified by:
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <wx/toolbar.h>
#include <wx/log.h>
#include <wx/image.h>
// define this to 1 to use wxToolBarSimple instead of the native one
#define USE_GENERIC_TBAR 0
#if USE_GENERIC_TBAR
#if !wxUSE_TOOLBAR_SIMPLE
#error wxToolBarSimple is not compiled in, set wxUSE_TOOLBAR_SIMPLE \
to 1 in setup.h and recompile the library.
#else
#include <wx/tbarsmpl.h>
#endif
#endif // USE_GENERIC_TBAR
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------
#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "mondrian.xpm"
#include "bitmaps/new.xpm"
#include "bitmaps/open.xpm"
#include "bitmaps/save.xpm"
#include "bitmaps/copy.xpm"
#include "bitmaps/cut.xpm"
#include "bitmaps/preview.xpm" // paste XPM
#include "bitmaps/print.xpm"
#include "bitmaps/help.xpm"
#endif // GTK or Motif
char appName[] = "wxInstall Builder";
// ----------------------------------------------------------------------------
// classes
// ----------------------------------------------------------------------------
// Define a new application
class MyApp : public wxApp
{
public:
bool OnInit();
};
// Define a new frame
class MyFrame: public wxFrame
{
public:
MyFrame(wxFrame *parent,
wxWindowID id = -1,
const wxString& title = "wxInstall Builder",
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
void RecreateToolbar();
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
void OnNewScript(wxCommandEvent& event);
void OnOpenScript(wxCommandEvent& event);
void OnSaveScript(wxCommandEvent& event);
void OnNewProject(wxCommandEvent& event);
void OnOpenProject(wxCommandEvent& event);
void OnSaveProject(wxCommandEvent& event);
void OnCut(wxCommandEvent& event);
void OnCopy(wxCommandEvent& event);
void OnPaste(wxCommandEvent& event);
void OnListBoxDoubleClick(wxCommandEvent& event);
#if USE_GENERIC_TBAR
virtual wxToolBar *OnCreateToolBar(long style,
wxWindowID id,
const wxString& name );
#endif // USE_GENERIC_TBAR
private:
bool m_smallToolbar,
m_horzToolbar;
size_t m_rows; // 1 or 2 only
wxTextCtrl* m_textWindow;
wxListBox* m_listBox;
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
const int ID_TOOLBAR = 500;
enum
{
ID_COMBO = 1000,
ID_LISTBOX,
wxID_NEW_SCRIPT,
wxID_SAVE_SCRIPT,
wxID_OPEN_SCRIPT,
wxID_NEW_PROJECT,
wxID_SAVE_PROJECT,
wxID_OPEN_PROJECT
};
// ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
// help button.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
EVT_MENU(wxID_HELP, MyFrame::OnAbout)
EVT_MENU(wxID_NEW_SCRIPT, MyFrame::OnNewScript)
EVT_MENU(wxID_OPEN_SCRIPT, MyFrame::OnOpenScript)
EVT_MENU(wxID_SAVE_SCRIPT, MyFrame::OnSaveScript)
EVT_MENU(wxID_NEW_PROJECT, MyFrame::OnNewProject)
EVT_MENU(wxID_OPEN_PROJECT, MyFrame::OnOpenProject)
EVT_MENU(wxID_SAVE_PROJECT, MyFrame::OnSaveProject)
EVT_MENU(wxID_CUT, MyFrame::OnCut)
EVT_MENU(wxID_COPY, MyFrame::OnCopy)
EVT_MENU(wxID_PASTE, MyFrame::OnPaste)
EVT_LISTBOX_DCLICK(ID_LISTBOX, MyFrame::OnListBoxDoubleClick)
END_EVENT_TABLE()
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// MyApp
// ----------------------------------------------------------------------------
IMPLEMENT_APP(MyApp)
// The `main program' equivalent, creating the windows and returning the
// main frame
bool MyApp::OnInit()
{
// Create the main frame window
MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
"wxInstall Builder",
wxPoint(100, 100), wxSize(450, 300));
frame->SetAutoLayout(TRUE);
frame->Show(TRUE);
frame->SetStatusText("Welcome to wxWindows Install Builder");
SetTopWindow(frame);
return TRUE;
}
void MyFrame::RecreateToolbar()
{
// delete and recreate the toolbar
wxToolBarBase *toolBar = GetToolBar();
delete toolBar;
SetToolBar(NULL);
long style = wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE;
style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
toolBar = CreateToolBar(style, ID_TOOLBAR);
toolBar->SetMargins( 4, 4 );
// Set up toolbar
wxBitmap toolBarBitmaps[8];
toolBarBitmaps[0] = wxBITMAP(new);
toolBarBitmaps[1] = wxBITMAP(open);
toolBarBitmaps[2] = wxBITMAP(save);
toolBarBitmaps[3] = wxBITMAP(copy);
toolBarBitmaps[4] = wxBITMAP(cut);
toolBarBitmaps[5] = wxBITMAP(paste);
toolBarBitmaps[6] = wxBITMAP(print);
toolBarBitmaps[7] = wxBITMAP(help);
if ( !m_smallToolbar )
{
int w = 2*toolBarBitmaps[0].GetWidth(),
h = 2*toolBarBitmaps[0].GetHeight();
for ( size_t n = 0; n < WXSIZEOF(toolBarBitmaps); n++ )
{
toolBarBitmaps[n] =
wxImage(toolBarBitmaps[n]).Scale(w, h).ConvertToBitmap();
}
toolBar->SetToolBitmapSize(wxSize(w, h));
}
#ifdef __WXMSW__
int width = 24;
#else
int width = 16;
#endif
int currentX = 5;
toolBar->AddTool(wxID_NEW_SCRIPT, toolBarBitmaps[0], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New script");
currentX += width + 5;
toolBar->AddTool(wxID_OPEN_SCRIPT, toolBarBitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open script");
// neither the generic nor Motif native toolbars really support this
currentX += width + 5;
toolBar->AddTool(wxID_SAVE_SCRIPT, toolBarBitmaps[2], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save script");
currentX += width + 5;
toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Copy");
currentX += width + 5;
toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Cut");
currentX += width + 5;
toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste");
currentX += width + 5;
toolBar->AddSeparator();
toolBar->AddTool(wxID_HELP, toolBarBitmaps[7], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help button");
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
toolBar->Realize();
toolBar->SetRows(m_horzToolbar ? m_rows : 10 / m_rows);
}
// ----------------------------------------------------------------------------
// MyFrame
// ----------------------------------------------------------------------------
// Define my frame constructor
MyFrame::MyFrame(wxFrame* parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style)
: wxFrame(parent, id, title, pos, size, style)
{
m_listBox = new wxListBox(this, ID_LISTBOX, wxPoint(0,0), wxSize(-1, -1));
m_listBox->Append("loadwxr");
m_listBox->Append("closeold");
m_listBox->Append("mleview");
m_listBox->Append("setbutton");
m_listBox->Append("getcheck");
m_listBox->Append("message");
m_listBox->Append("disable");
m_listBox->Append("settext");
m_listBox->Append("gettext");
m_listBox->Append("grabfile");
m_listBox->Append("remove");
m_listBox->Append("system");
m_listBox->Append("startinst");
wxLayoutConstraints *b1 = new wxLayoutConstraints;
b1->left.SameAs (this, wxLeft, 0);
b1->top.SameAs (this, wxTop, 0);
b1->width.PercentOf (this, wxWidth, 20);
b1->bottom.SameAs (this, wxBottom, 0);
m_listBox->SetConstraints(b1);
m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0,0), wxSize(-1, -1), wxTE_MULTILINE);
m_textWindow->AppendText("; Script generated by wxInstall Builder\n");
wxLayoutConstraints *b2 = new wxLayoutConstraints;
b2->top.SameAs (this, wxTop, 0);
b2->left.SameAs (m_listBox, wxRight, 0);
b2->width.PercentOf (this, wxWidth, 80);
b2->bottom.SameAs (this, wxBottom, 0);
m_textWindow->SetConstraints(b2);
m_smallToolbar = TRUE;
m_horzToolbar = TRUE;
m_rows = 1;
// Give it a status line
CreateStatusBar();
// Give it an icon
SetIcon(wxICON(mondrian));
wxMenu *fileMenu = new wxMenu;
fileMenu->Append(wxID_NEW_SCRIPT, "&New Script", "New wxInstall Script" );
fileMenu->Append(wxID_OPEN_SCRIPT, "&Open Script", "Open wxInstall Script" );
fileMenu->Append(wxID_SAVE_SCRIPT, "&Save Script", "Save wxInstall Script" );
fileMenu->AppendSeparator();
/*fileMenu->Append(wxID_NEW_PROJECT, "N&ew Project", "New wxInstall Project" );
fileMenu->Append(wxID_OPEN_PROJECT, "O&pen Project", "Open wxInstall Project" );
fileMenu->Append(wxID_SAVE_PROJECT, "S&ave Project", "Save wxInstall Project" );
fileMenu->AppendSeparator();*/
fileMenu->Append(wxID_EXIT, "E&xit", "Quit wxInstall Builder" );
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(wxID_HELP, "&About", "About wxInstall Builder");
wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE );
menuBar->Append(fileMenu, "&File");
menuBar->Append(helpMenu, "&Help");
// Associate the menu bar with the frame
SetMenuBar(menuBar);
// Create the toolbar
RecreateToolbar();
}
#if USE_GENERIC_TBAR
wxToolBar* MyFrame::OnCreateToolBar(long style,
wxWindowID id,
const wxString& name)
{
return (wxToolBar *)new wxToolBarSimple(this, id,
wxDefaultPosition, wxDefaultSize,
style, name);
}
#endif // USE_GENERIC_TBAR
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnCut(wxCommandEvent& WXUNUSED(event))
{
m_textWindow->Cut();
}
void MyFrame::OnCopy(wxCommandEvent& WXUNUSED(event))
{
m_textWindow->Copy();
}
void MyFrame::OnPaste(wxCommandEvent& WXUNUSED(event))
{
m_textWindow->Paste();
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
(void)wxMessageBox("wxInstall Builder by Brian Smith", "About wxInstall Builder");
}
void MyFrame::OnNewScript(wxCommandEvent& event)
{
m_textWindow->Clear();
m_textWindow->AppendText("; Script generated by wxInstall Builder\n");
}
void MyFrame::OnOpenScript(wxCommandEvent& event)
{
wxFileDialog dialog2(this, "Open Script", "", "", "*.ini", 0);
if (dialog2.ShowModal() == wxID_OK)
m_textWindow->LoadFile(dialog2.GetPath());
}
void MyFrame::OnSaveScript(wxCommandEvent& event)
{
wxFileDialog dialog2(this, "Save Script", "", "", "*.ini", 0);
if (dialog2.ShowModal() == wxID_OK)
m_textWindow->SaveFile(dialog2.GetPath());
}
void MyFrame::OnNewProject(wxCommandEvent& event)
{
}
void MyFrame::OnOpenProject(wxCommandEvent& event)
{
}
void MyFrame::OnSaveProject(wxCommandEvent& event)
{
}
void MyFrame::OnListBoxDoubleClick( wxCommandEvent &event )
{
int item;
item = m_listBox->GetSelection();
switch(item)
{
case 0:
{
wxFileDialog dialog2(this, "Choose wxr filename", "", "", "*.wxr", 0);
if (dialog2.ShowModal() == wxID_OK)
{
char tempbuf[1024] = "DialogEd ";
wxString tmp = dialog2.GetFilename();
m_textWindow->WriteText("loadwxr,");
m_textWindow->WriteText(tmp);
m_textWindow->WriteText("\n");
strcat(tempbuf, tmp);
wxExecute(tempbuf);
}
}
break;
case 1:
{
m_textWindow->WriteText("closeold\n");
}
break;
case 2:
{
wxFileDialog dialog2(this, "Choose filename to view", "", "", "*.txt", 0);
if (dialog2.ShowModal() == wxID_OK)
{
wxTextEntryDialog dialog3(this,
"Please enter name of the MLE widget",
appName,
"",
wxOK | wxCANCEL);
if (dialog3.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("mleview,");
m_textWindow->WriteText(dialog3.GetValue());
m_textWindow->WriteText(",");
m_textWindow->WriteText(dialog2.GetFilename());
m_textWindow->WriteText("\n");
}
}
}
break;
case 3:
{
wxFileDialog dialog2(this, "Choose script to attach to button", "", "", "*.ini", 0);
if (dialog2.ShowModal() == wxID_OK)
{
wxTextEntryDialog dialog3(this,
"Please enter ID of the button",
appName,
"",
wxOK | wxCANCEL);
if (dialog3.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("setbutton,");
m_textWindow->WriteText(dialog3.GetValue());
m_textWindow->WriteText(",");
m_textWindow->WriteText(dialog2.GetFilename());
m_textWindow->WriteText("\n");
}
}
}
break;
case 4:
{
wxFileDialog dialog2(this, "Choose script to run if not checked", "", "", "*.ini", 0);
if (dialog2.ShowModal() == wxID_OK)
{
wxTextEntryDialog dialog3(this,
"Please enter name of the checkbox widget",
appName,
"",
wxOK | wxCANCEL);
if (dialog3.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("getcheck,");
m_textWindow->WriteText(dialog3.GetValue());
m_textWindow->WriteText(",");
m_textWindow->WriteText(dialog2.GetFilename());
m_textWindow->WriteText("\n");
}
}
}
break;
case 5:
{
wxTextEntryDialog dialog2(this,
"Please enter the message to display to the user",
appName,
"",
wxOK | wxCANCEL);
if (dialog2.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("message,\"");
m_textWindow->WriteText(dialog2.GetValue());
m_textWindow->WriteText("\"\n");
}
}
break;
case 6:
{
wxTextEntryDialog dialog2(this,
"Please enter the widget name to disable",
appName,
"",
wxOK | wxCANCEL);
if (dialog2.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("disable,");
m_textWindow->WriteText(dialog2.GetValue());
m_textWindow->WriteText("\n");
}
}
break;
case 7:
{
wxTextEntryDialog dialog2(this,
"Please enter text widget name to set from",
appName,
"",
wxOK | wxCANCEL);
if (dialog2.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("settext,");
m_textWindow->WriteText(dialog2.GetValue());
m_textWindow->WriteText("\n");
}
}
break;
case 8:
{
wxTextEntryDialog dialog2(this,
"Please enter text widget name to get from",
appName,
"",
wxOK | wxCANCEL);
if (dialog2.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("gettext,");
m_textWindow->WriteText(dialog2.GetValue());
m_textWindow->WriteText("\n");
}
}
break;
case 9:
{
wxFileDialog dialog2(this, "Choose file to grab", "", "", "*", 0);
if (dialog2.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("grabfile,");
m_textWindow->WriteText(dialog2.GetFilename());
m_textWindow->WriteText("\n");
}
}
break;
case 10:
{
wxFileDialog dialog2(this, "Choose file to remove", "", "", "*", 0);
if (dialog2.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("remove,");
m_textWindow->WriteText(dialog2.GetFilename());
m_textWindow->WriteText("\n");
}
}
break;
case 11:
{
wxTextEntryDialog dialog2(this,
"Please enter the command to execute",
appName,
"",
wxOK | wxCANCEL);
if (dialog2.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("system,");
m_textWindow->WriteText(dialog2.GetValue());
m_textWindow->WriteText("\n");
}
}
break;
case 12:
{
wxFileDialog dialog2(this, "Choose script to run at installation completion", "", "", "*.ini", 0);
if (dialog2.ShowModal() == wxID_OK)
{
wxTextEntryDialog dialog3(this,
"Please enter name of the gauge widget",
appName,
"",
wxOK | wxCANCEL);
if (dialog3.ShowModal() == wxID_OK)
{
m_textWindow->WriteText("startinst,");
m_textWindow->WriteText(dialog3.GetValue());
m_textWindow->WriteText(",");
m_textWindow->WriteText(dialog2.GetFilename());
m_textWindow->WriteText("\n");
}
}
}
break;
}
}

View File

@@ -0,0 +1,8 @@
NAME ToolTest
DESCRIPTION 'wxToolBar Sample'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 8192

View File

@@ -0,0 +1,12 @@
mondrian ICON "mondrian.ico"
#include "wx/msw/wx.rc"
new BITMAP "bitmaps/new.bmp"
open BITMAP "bitmaps/open.bmp"
save BITMAP "bitmaps/save.bmp"
copy BITMAP "bitmaps/copy.bmp"
cut BITMAP "bitmaps/cut.bmp"
paste BITMAP "bitmaps/paste.bmp"
print BITMAP "bitmaps/print.bmp"
help BITMAP "bitmaps/help.bmp"

View File

@@ -0,0 +1,175 @@
# Microsoft Developer Studio Project File - Name="wxibVC" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=wxibVC - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "wxibVC.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wxibVC.mak" CFG="wxibVC - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wxibVC - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "wxibVC - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE "wxibVC - Win32 Debug DLL" (based on "Win32 (x86) Application")
!MESSAGE "wxibVC - Win32 Release DLL" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "wxibVC - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /out:"Release/wxib.exe" /libpath:"../../lib" /libpath:"../../contrib/lib"
!ELSEIF "$(CFG)" == "wxibVC - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /Yu"wx/wxprec.h" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib xpmd.lib pngd.lib zlibd.lib jpegd.lib tiffd.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"wxib.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib"
!ELSEIF "$(CFG)" == "wxibVC - Win32 Debug DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "DebugDLL"
# PROP BASE Intermediate_Dir "DebugDLL"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugDLL"
# PROP Intermediate_Dir "DebugDLL"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../../contrib/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxdlld.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/wxib.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib"
!ELSEIF "$(CFG)" == "wxibVC - Win32 Release DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "ReleaseDLL"
# PROP BASE Intermediate_Dir "ReleaseDLL"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "ReleaseDLL"
# PROP Intermediate_Dir "ReleaseDLL"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../include" /I "../../contrib/include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxdll.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/wxib.exe" /libpath:"../../lib" /libpath:"../../contrib/lib"
!ENDIF
# Begin Target
# Name "wxibVC - Win32 Release"
# Name "wxibVC - Win32 Debug"
# Name "wxibVC - Win32 Debug DLL"
# Name "wxibVC - Win32 Release DLL"
# Begin Source File
SOURCE=.\wxib.cpp
!IF "$(CFG)" == "wxibVC - Win32 Release"
!ELSEIF "$(CFG)" == "wxibVC - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "wxibVC - Win32 Debug DLL"
# SUBTRACT BASE CPP /YX /Yc /Yu
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "wxibVC - Win32 Release DLL"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\wxib.rc
# ADD BASE RSC /l 0x809
# ADD RSC /l 0x809 /i "../../include" /i "../../contrib/include"
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "wxibVC"=.\wxibVC.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,151 @@
#ifndef __acestruc_h
#define __acestruc_h
#include "declare.h"
#include "portable.h"
#define acesign_len 7
#define bytes_before_acesign 7
#define acever 10
struct tech
{
UCHAR TYPE;
UCHAR QUAL;
USHORT PARM;
};
typedef struct tacehead
{
USHORT HEAD_CRC;
USHORT HEAD_SIZE;
UCHAR HEAD_TYPE;
USHORT HEAD_FLAGS;
ULONG ADDSIZE;
UCHAR other[2048];
} thead;
typedef struct tacemhead
{
USHORT HEAD_CRC;
USHORT HEAD_SIZE;
UCHAR HEAD_TYPE;
USHORT HEAD_FLAGS;
UCHAR ACESIGN[acesign_len];
UCHAR VER_MOD;
UCHAR VER_CR;
UCHAR HOST_CR;
UCHAR VOL_NUM;
ULONG TIME_CR;
USHORT RES1;
USHORT RES2;
ULONG RES;
UCHAR AV_SIZE;
UCHAR AV[256];
USHORT COMM_SIZE;
UCHAR COMM[2048];
} tmhead;
#ifndef PATH_MAX
#define PATH_MAX 512
#endif
typedef struct tacefhead
{
USHORT HEAD_CRC;
USHORT HEAD_SIZE;
UCHAR HEAD_TYPE;
USHORT HEAD_FLAGS;
ULONG PSIZE;
ULONG SIZE;
ULONG FTIME;
ULONG ATTR;
ULONG CRC32;
struct tech TECH;
USHORT RESERVED;
USHORT FNAME_SIZE;
UCHAR FNAME[PATH_MAX];
USHORT COMM_SIZE;
UCHAR COMM[2048];
} tfhead;
#define mhead (*t_mhead)
#define fhead (*t_fhead)
#define rhead (*t_rhead)
#define tmpmhead (*t_tmpmhead)
#define tmpfhead (*t_tmpfhead)
#define tmprhead (*t_tmprhead)
#define mhead_size h_mhead_size(mhead)
#define fhead_size h_fhead_size(fhead)
#define rhead_size ((INT)&rhead.REC_CRC-(INT)&head.HEAD_TYPE+sizeof(rhead.REC_CRC))
#define h_mhead_size(phead) ((INT)mhead.AV-(INT)&head.HEAD_TYPE+ \
(phead).AV_SIZE+ \
((phead).HEAD_FLAGS&ACE_COMM? \
sizeof((phead).COMM_SIZE)+H_MCOMM_SIZE(phead):0))
#define h_fhead_size(phead) ((INT)fhead.FNAME-(INT)&head.HEAD_TYPE+ \
(phead).FNAME_SIZE+ \
((phead).HEAD_FLAGS&ACE_COMM? \
sizeof((phead).COMM_SIZE)+H_FCOMM_SIZE(phead):0))
//main-comment-definitions
#define H_MCOMM_SIZE(head) (BUF2WORD((UCHAR*)&(head).AV+(head).AV_SIZE))
#define MCOMM_SIZE H_MCOMM_SIZE(mhead)
#define H_MCOMM(head) ((UCHAR*)&(head).AV+(head).AV_SIZE+sizeof((head).COMM_SIZE))
#define MCOMM H_MCOMM(mhead)
//file-comment-definitions
#define H_FCOMM_SIZE(head) (BUF2WORD((UCHAR*)&(head).FNAME+(head).FNAME_SIZE))
#define FCOMM_SIZE H_FCOMM_SIZE(fhead)
#define H_FCOMM(head) ((UCHAR*)&(head).FNAME+(head).FNAME_SIZE+sizeof((head).COMM_SIZE))
#define FCOMM H_FCOMM(fhead)
//
#define calc_head_crc getcrc16(CRC_MASK, (CHAR*)&head.HEAD_TYPE, head.HEAD_SIZE)
#define GET_ADDSIZE ((head.HEAD_FLAGS & ACE_ADDSIZE) ? head.ADDSIZE : 0)
//archive-header-flags
#define ACE_LIM256 1024
#define ACE_MULT_VOL 2048
#define ACE_AV 4096
#define ACE_RECOV 8192
#define ACE_LOCK 16384
#define ACE_SOLID 32768
//file-header-flags
#define ACE_ADDSIZE 1
#define ACE_PASSW 16384
#define ACE_SP_BEF 4096
#define ACE_SP_AFTER 8192
#define ACE_COMM 2
//block types
#define MAIN_BLK 0
#define FILE_BLK 1
#define REC_BLK 2
//known compression types
#define TYPE_STORE 0
#define TYPE_LZW1 1
//structure for archive handling
struct tadat
{
INT sol,
vol,
vol_num;
ULONG time_cr;
};
#endif /* __acestruc_h */

View File

@@ -0,0 +1,33 @@
#ifndef __attribs_h
#define __attribs_h
#ifndef _A_SUBDIR
#define _A_SUBDIR 0x10 // MS-DOS directory constant
#endif
#ifndef S_IEXEC
#ifdef S_IEXECUTE
#define S_IEXEC S_IEXECUTE
#else
#define S_IEXEC 0
#endif
#endif
#ifndef S_IDELETE
#define S_IDELETE 0
#endif
#ifndef S_IRGRP
#define S_IRGRP 0
#define S_IWGRP 0
#endif
#ifndef S_IROTH
#define S_IROTH 0
#define S_IWOTH 0
#endif
#endif /* __attribs_h */

View File

@@ -0,0 +1,38 @@
/******************************************************/
/* */
/* declare.h: declaration-symbols (UCHAR, ULONG, ...) */
/* */
/******************************************************/
#ifndef __declare_h
#define __declare_h
#if defined(__CYGWIN__)
#include <Windows32/Base.h>
#endif
#if !defined(OS2_H_INCLUDED) && !defined(__CYGWIN__)
#ifdef AMIGA
#include <exec/types.h>
#else /* AMIGA */
typedef unsigned short USHORT;
typedef short SHORT ;
typedef unsigned short UWORD ;
typedef short WORD ;
typedef unsigned long ULONG ;
typedef long LONG ;
#endif /* !AMIGA */
typedef unsigned char UCHAR ;
typedef char CHAR ;
typedef unsigned UINT ;
typedef int INT ;
#else
typedef unsigned short UWORD ;
#endif
#endif /* __declare_h */

View File

@@ -0,0 +1,90 @@
/* ------------------------------------------------------------------------ */
/* */
/* Global variable definitions */
/* */
/* ------------------------------------------------------------------------ */
#ifndef __globals_h
#define __globals_h
#include "acestruc.h"
#include "unace.h"
//-------- Ace sign
extern const char *acesign;
//-------- Version string for program
extern const char *version;
//-------- header buffer and pointers
extern thead head;
extern tmhead *t_mhead;
extern tfhead *t_fhead;
//-------- buffers
extern ULONG *buf_rd ;
extern CHAR *buf ;
extern CHAR *buf_wr ;
extern UCHAR *readbuf;
//-------- decompressor variables
extern
SHORT rpos ,
dcpr_do ,
dcpr_do_max ,
blocksize ,
dcpr_dic ,
dcpr_oldnum ,
bits_rd ,
dcpr_frst_file;
extern
USHORT dcpr_code_mn[1 << maxwd_mn],
dcpr_code_lg[1 << maxwd_lg];
extern
UCHAR dcpr_wd_mn[maxcode + 2],
dcpr_wd_lg[maxcode + 2],
wd_svwd[svwd_cnt];
extern
ULONG dcpr_dpos ,
cpr_dpos2 ,
dcpr_dicsiz ,
dcpr_dican ,
dcpr_size ,
dcpr_olddist[4],
code_rd ;
extern
CHAR *dcpr_text ;
//-------- quicksort
extern USHORT sort_org[maxcode + 2];
extern UCHAR sort_freq[(maxcode + 2) * 2];
//-------- file handling
extern CHAR aname[PATH_MAX];
extern
INT archan,
wrhan;
#if !defined(__EMX__) && !defined(__OS2__)
extern FILE *farchan;
#endif
extern LONG skipsize;
//-------- structures for archive handling
extern struct tadat adat;
//-------- flags
extern
INT f_err ,
f_ovrall ,
f_allvol_pr,
f_curpas ,
f_criterr ;
int pipeit(char *format, ...);
void error(char *format, ...);
int confirm(char *format, ...);
#endif /* __globals_h */

26
utils/Install/incace/os.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef __os_h
#define __os_h
#if defined(AMIGA)
#define DIRSEP '/'
#define HI_LO_BYTE_ORDER
#endif
#if defined(DOS) || defined(WINNT) || defined(WIN16)
#define DIRSEP '\\'
#define LO_HI_BYTE_ORDER
#endif
#if defined(OS2) || defined(__EMX__)
#define DIRSEP '\\'
#define LO_HI_BYTE_ORDER
#endif
#if defined(UNIX)
#define DIRSEP '/'
#define HI_LO_BYTE_ORDER
#endif
#endif /* __os_h */

View File

@@ -0,0 +1,101 @@
/****************************************************************/
/* */
/* A collection of routines used in making ACE portable for */
/* different computers */
/* */
/****************************************************************/
#ifndef __portable_h
#define __portable_h
#include "os.h"
#ifdef HI_LO_BYTE_ORDER
/* All kinds of inplace swap routines, to reverse from LOHI to HILO byte order */
#ifdef AMIGA
#if __SASC && __VERSION__>=6 && __REVISION__>=58
#define WORDswap(n) (*(n) = __builtin_rol(*(n), 8, 1))
#define LONGswap(n) ( WORDswap(&((WORD *)(n))[0]),\
WORDswap(&((WORD *)(n))[1]),\
*(n) = __builtin_rol(*(n), 16, 2) )
#else /* __SASC */
#define EORSWAP
#endif /* !__SASC */
#endif /* AMIGA */
#ifdef EORSWAP
/* With some compilers and processors these work faster then the
* regular swap below, for example on a Amiga 68040 using SAS C 6.58.
* But using builtin rotates works even faster, see above.
*/
#define WORDswap(n) (((BYTE*)(n))[0] ^= ((BYTE*)(n))[1],\
((BYTE*)(n))[1] ^= ((BYTE*)(n))[0],\
((BYTE*)(n))[0] ^= ((BYTE*)(n))[1])
#define LONGswap(n) (((BYTE*)(n))[0] ^= ((BYTE*)(n))[3],\
((BYTE*)(n))[3] ^= ((BYTE*)(n))[0],\
((BYTE*)(n))[0] ^= ((BYTE*)(n))[3],\
((BYTE*)(n))[1] ^= ((BYTE*)(n))[2],\
((BYTE*)(n))[2] ^= ((BYTE*)(n))[1],\
((BYTE*)(n))[1] ^= ((BYTE*)(n))[2])
#endif /* EORSWAP */
#ifndef WORDswap
/* If not yet defined use the standard swaps */
#define WORDswap(n) (*(n) = (*(n) << 8) | (*(n) >> 8))
#define LONGswap(n) ( WORDswap(&((WORD *)(n))[0]),\
WORDswap(&((WORD *)(n))[1]),\
*(n) = (*(n) >> 16) | (*(n) << 16) )
#endif /* WORDSWAP */
#endif /* HI_LO_BYTE_ORDER */
/* GENERIC: Convert to LONG or WORD from BYTE-Pointer-to-LOHI-byte-order data,
* without worrying if the bytes are word alined in memory.
* p is a pointer to char.
*/
#ifdef HI_LO_BYTE_ORDER
#define BUFP2WORD(p) ((UWORD)*(p)++ | ((*(p)++)<<8))
#define BUFP2LONG(p) ((ULONG)*(p)++ | ((*(p)++)<<8) | ((*(p)++)<<16) | ((*(p)++)<<24))
#define BUF2WORD(p) ((UWORD)*(p) | (*((p)+1)<<8))
#define BUF2LONG(p) ((ULONG)*(p) | (*((p)+1)<<8) | (*((p)+2)<<16) | (*((p)+3)<<24))
#else /* HI_LO_BYTE_ORDER */
#define BUFP2WORD(p) *(UWORD*)((p+=2)-2)
#define BUFP2LONG(p) *(ULONG*)((p+=4)-4)
#define BUF2WORD(p) (*(UWORD*)p)
#define BUF2LONG(p) (*(ULONG*)p)
#endif /* !HI_LO_BYTE_ORDER */
/* Timestamp macros */
#define get_tx(m,d,h,n) (((ULONG)m<<21)+((ULONG)d<<16)+((ULONG)h<<11)+(n<<5))
#define get_tstamp(y,m,d,h,n,s) ((((ULONG)(y-1980))<<25)+get_tx(m,d,h,n)+(s/2))
#define ts_year(ts) ((UINT)((ts >> 25) & 0x7f) + 1980)
#define ts_month(ts) ((UINT)(ts >> 21) & 0x0f) // 1..12 means Jan..Dec
#define ts_day(ts) ((UINT)(ts >> 16) & 0x1f) // 1..31 means 1st..31st
#define ts_hour(ts) ((UINT)(ts >> 11) & 0x1f)
#define ts_min(ts) ((UINT)(ts >> 5) & 0x3f)
#define ts_sec(ts) ((UINT)((ts & 0x1f) * 2))
#endif /* __portable_h */

View File

@@ -0,0 +1,14 @@
#ifndef __uac_comm_h
#define __uac_comm_h
#include "declare.h"
extern INT comm_cpr_size;
extern CHAR *comm;
void comment_out(CHAR *top);
#endif /* __uac_comm_h */

View File

@@ -0,0 +1,20 @@
#ifndef __uac_crc_h
#define __uac_crc_h
#include "declare.h"
#define CRC_MASK 0xFFFFFFFFL
#define CRCPOLY 0xEDB88320L
extern ULONG crctable[256];
extern ULONG rd_crc;
ULONG getcrc(ULONG crc, UCHAR * addr, INT len);
void make_crctable(void);
#endif /* __uac_crc_h */

View File

@@ -0,0 +1,12 @@
#ifndef __uac_crt_h
#define __uac_crt_h
#include "acestruc.h"
CHAR *ace_fname(CHAR * s, thead * head, INT nopath);
INT create_dest_file(CHAR * file, INT a);
#endif /* __uac_crt_h */

View File

@@ -0,0 +1,14 @@
#ifndef __uac_dcpr_h
#define __uac_dcpr_h
#include "declare.h"
INT calc_dectabs(void);
void dcpr_comm(INT comm_size);
INT read_wd(UINT maxwd, USHORT * code, UCHAR * wd, INT max_el);
void dcpr_init(void);
INT dcpr_adds_blk(CHAR * buf, UINT len);
void dcpr_init_file(void);
#endif /* __uac_dcpr_h */

View File

@@ -0,0 +1,18 @@
#ifndef __uac_sys_h
#define __uac_sys_h
#include "declare.h"
#define upcase(ch) ((in(ch,'a','z'))?(ch-32):(ch))
void memset16(USHORT * dest, SHORT val, INT len);
INT cancel(void);
INT wrask(CHAR * s);
#if !defined(__MINGW32__)
void beep(void);
#endif
void set_handler(void);
#endif

View File

@@ -0,0 +1,66 @@
#ifndef __unace_h
#define __unace_h
#include "declare.h"
//--------- functions
INT read_adds_blk(CHAR * buffer, INT len);
//--------- buffers: increase sizes when possible to speed up the program
#define size_rdb 1024
#define size_wrb 2048
#define size_buf 1024
#define size_headrdb (sizeof(head)-20) // (some bytes less esp. for Amiga)
//--------- (de-)compressor constants
#define maxdic 22
#define maxwd_mn 11
#define maxwd_lg 11
#define maxwd_svwd 7
#define maxlength 259
#define maxdis2 255
#define maxdis3 8191
#define maxcode (255+4+maxdic)
#define svwd_cnt 15
#define max_cd_mn (256+4+(maxdic+1)-1)
#define max_cd_lg (256-1)
//--------- flags
#define ERR_MEM 1
#define ERR_FILES 2
#define ERR_FOUND 3
#define ERR_FULL 4
#define ERR_OPEN 5
#define ERR_READ 6
#define ERR_WRITE 7
#define ERR_CLINE 8
#define ERR_CRC 9
#define ERR_OTHER 10
#define ERR_USER 255
//--------- system things
#define flush fflush(stdout);
#define in(v1,v2,v3) ((((long)v1)>=(v2)) && (((long)v1)<=(v3)))
#define delay_len 500
//-------- file creation
#define fileexists(name) (!access(name, 0))
//-------- eof
#endif /* __unace_h */

View File

@@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------
consts.h
This file contains global, initialized variables that never change. It is
included by unzip.c and windll/windll.c.
---------------------------------------------------------------------------*/
/* And'ing with mask_bits[n] masks the lower n bits */
ZCONST ush near mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
ZCONST char Far VersionDate[] = VERSION_DATE; /* now defined in version.h */
#ifndef SFX
ZCONST char Far EndSigMsg[] =
"\nnote: didn't find end-of-central-dir signature at end of central dir.\n";
#endif
ZCONST char Far CentSigMsg[] =
"error: expected central file header signature not found (file #%u).\n";
ZCONST char Far SeekMsg[] =
"error [%s]: attempt to seek before beginning of zipfile\n%s";
ZCONST char Far FilenameNotMatched[] = "caution: filename not matched: %s\n";
ZCONST char Far ExclFilenameNotMatched[] =
"caution: excluded filename not matched: %s\n";
#ifdef VMS
ZCONST char Far ReportMsg[] = "\
(please check that you have transferred or created the zipfile in the\n\
appropriate BINARY mode--this includes ftp, Kermit, AND unzip'd zipfiles)\n";
#else
ZCONST char Far ReportMsg[] = "\
(please check that you have transferred or created the zipfile in the\n\
appropriate BINARY mode and that you have compiled UnZip properly)\n";
#endif
#ifndef SFX
ZCONST char Far Zipnfo[] = "zipinfo";
ZCONST char Far CompiledWith[] = "Compiled with %s%s for %s%s%s%s.\n\n";
#endif

View File

@@ -0,0 +1,24 @@
/*
crypt.h (dummy version) by Info-ZIP. Last revised: 15 Aug 98
This is a non-functional version of Info-ZIP's crypt.h encryption/
decryption header file for Zip, ZipCloak, UnZip and fUnZip. This
file is not copyrighted and may be distributed without restriction.
See the "WHERE" file for sites from which to obtain the full crypt
sources (zcrypt28.zip or later).
*/
#ifndef __crypt_h /* don't include more than once */
#define __crypt_h
#ifdef CRYPT
# undef CRYPT
#endif
#define CRYPT 0 /* dummy version */
#define zencode
#define zdecode
#define zfwrite fwrite
#endif /* !__crypt_h */

View File

@@ -0,0 +1,272 @@
/*---------------------------------------------------------------------------
ebcdic.h
The CECP 1047 (Extended de-facto EBCDIC) <-> ISO 8859-1 conversion tables,
from ftp://aix1.segi.ulg.ac.be/pub/docs/iso8859/iso8859.networking
NOTES:
<Paul_von_Behren@stortek.com> (OS/390 port 12/97)
These table no longer represent the standard mappings (for example in the
OS/390 iconv utility). In order to follow current standards I remapped
ebcdic x0a to ascii x15 and
ebcdic x85 to ascii x25 (and vice-versa)
Without these changes, newlines in auto-convert text files appeared
as literal \045.
I'm not sure what effect this remap would have on the MVS and CMS ports, so
I ifdef'd these changes. Hopefully these ifdef's can be removed when the
MVS/CMS folks test the new mappings.
Christian Spieler <spieler@ikp.tu-darmstadt.de>, 27-Apr-1998
The problem mentioned by Paul von Behren was already observed previously
on VM/CMS, during the preparation of the CMS&MVS port of UnZip 5.20 in
1996. At that point, the ebcdic tables were not changed since they seemed
to be an adopted standard (to my knowledge, these tables are still used
as presented in mainfraime KERMIT). Instead, the "end-of-line" conversion
feature of Zip's and UnZip's "text-translation" mode was used to force
correct mappings between ASCII and EBCDIC newline markers.
Before interchanging the ASCII mappings of the EBCDIC control characters
"NL" 0x25 and "LF" 0x15 according to the OS/390 setting, we have to
make sure that EBCDIC 0x15 is never used as line termination.
---------------------------------------------------------------------------*/
#ifndef __ebcdic_h /* prevent multiple inclusions */
#define __ebcdic_h
#ifndef ZCONST
# define ZCONST const
#endif
#ifdef EBCDIC
#ifndef MTS /* MTS uses a slightly "special" EBCDIC code page */
ZCONST uch ebcdic[] = {
0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */
#ifdef OS390
0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
#else
0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
#endif
0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */
0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */
0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */
0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */
0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */
0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */
0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */
0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, /* 58 - 5F */
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */
0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */
0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */
#ifdef OS390
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, /* 80 - 87 */
#else
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */
#endif
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */
0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */
0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */
0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */
0xBB, 0xB4, 0x9A, 0x8A, 0xB0, 0xCA, 0xAF, 0xBC, /* A8 - AF */
0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */
0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */
0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */
0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */
0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xBA, 0xAE, 0x59, /* D8 - DF */
0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */
0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */
0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */
};
#if (defined(ZIP) || CRYPT)
ZCONST uch ascii[] = {
0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */
0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
#ifdef OS390
0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, /* 10 - 17 */
#else
0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */
#endif
0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
#ifdef OS390
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, /* 20 - 27 */
#else
0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */
#endif
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */
0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */
0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */
0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */
0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */
0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */
0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, /* 58 - 5F */
0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */
0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */
0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */
0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */
0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */
0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */
0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */
0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */
0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */
0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0x5B, 0xDE, 0xAE, /* A8 - AF */
0xAC, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */
0xBD, 0xBE, 0xDD, 0xA8, 0xAF, 0x5D, 0xB4, 0xD7, /* B8 - BF */
0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */
0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */
0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */
0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */
0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */
0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */
0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */
};
#endif /* ZIP || CRYPT */
#else /* MTS */
/*
* This is the MTS ASCII->EBCDIC translation table. It provides a 1-1
* translation from ISO 8859/1 8-bit ASCII to IBM Code Page 37 EBCDIC.
*/
ZCONST uch ebcdic[] = {
0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, /* 00 - 07 */
0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, /* 10 - 17 */
0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, /* 20 - 27 */
0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, /* 28 - 2F */
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, /* 30 - 37 */
0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, /* 38 - 3F */
0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, /* 40 - 47 */
0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, /* 48 - 4F */
0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, /* 50 - 57 */
0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D, /* 58 - 5F */
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60 - 67 */
0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* 68 - 6F */
0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, /* 70 - 77 */
0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07, /* 78 - 7F */
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, /* 80 - 87 */
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, /* 88 - 8F */
0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, /* 90 - 97 */
0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF, /* 98 - 9F */
0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, /* A0 - A7 */
0xBD, 0xB4, 0x9A, 0x8A, 0x5F, 0xCA, 0xAF, 0xBC, /* A8 - AF */
0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, /* B0 - B7 */
0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB, /* B8 - BF */
0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, /* C0 - C7 */
0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* C8 - CF */
0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, /* D0 - D7 */
0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xAD, 0xAE, 0x59, /* D8 - DF */
0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, /* E0 - E7 */
0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* E8 - EF */
0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, /* F0 - F7 */
0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF /* F8 - FF */
};
#if (defined(ZIP) || CRYPT)
ZCONST uch ascii[] = {
0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, /* 00 - 07 */
0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /* 08 - 0F */
0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, /* 10 - 17 */
0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, /* 18 - 1F */
0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, /* 20 - 27 */
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, /* 28 - 2F */
0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30 - 37 */
0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, /* 38 - 3F */
0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, /* 40 - 47 */
0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C, /* 48 - 4F */
0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, /* 50 - 57 */
0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAC, /* 58 - 5F */
0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, /* 60 - 67 */
0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, /* 68 - 6F */
0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, /* 70 - 77 */
0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, /* 78 - 7F */
0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80 - 87 */
0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1, /* 88 - 8F */
0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, /* 90 - 97 */
0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4, /* 98 - 9F */
0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* A0 - A7 */
0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0xDD, 0xDE, 0xAE, /* A8 - AF */
0x5E, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, /* B0 - B7 */
0xBD, 0xBE, 0x5B, 0x5D, 0xAF, 0xA8, 0xB4, 0xD7, /* B8 - BF */
0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* C0 - C7 */
0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5, /* C8 - CF */
0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, /* D0 - D7 */
0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF, /* D8 - DF */
0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* E0 - E7 */
0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5, /* E8 - EF */
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* F0 - F7 */
0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F /* F8 - FF */
};
#endif /* ZIP || CRYPT */
#endif /* ?MTS */
#endif /* EBCDIC */
/*---------------------------------------------------------------------------
The following conversion tables translate between IBM PC CP 850
(OEM codepage) and the "Western Europe & America" Windows codepage 1252.
The Windows codepage 1252 contains the ISO 8859-1 "Latin 1" codepage,
with some additional printable characters in the range (0x80 - 0x9F),
that is reserved to control codes in the ISO 8859-1 character table.
The ISO <--> OEM conversion tables were constructed with the help
of the WIN32 (Win16?) API's OemToAnsi() and AnsiToOem() conversion
functions and have been checked against the CP850 and LATIN1 tables
provided in the MS-Kermit 3.14 distribution.
---------------------------------------------------------------------------*/
#ifdef IZ_ISO2OEM_ARRAY
ZCONST uch Far iso2oem[] = {
0x3F, 0x3F, 0x27, 0x9F, 0x22, 0x2E, 0xC5, 0xCE, /* 80 - 87 */
0x5E, 0x25, 0x53, 0x3C, 0x4F, 0x3F, 0x3F, 0x3F, /* 88 - 8F */
0x3F, 0x27, 0x27, 0x22, 0x22, 0x07, 0x2D, 0x2D, /* 90 - 97 */
0x7E, 0x54, 0x73, 0x3E, 0x6F, 0x3F, 0x3F, 0x59, /* 98 - 9F */
0xFF, 0xAD, 0xBD, 0x9C, 0xCF, 0xBE, 0xDD, 0xF5, /* A0 - A7 */
0xF9, 0xB8, 0xA6, 0xAE, 0xAA, 0xF0, 0xA9, 0xEE, /* A8 - AF */
0xF8, 0xF1, 0xFD, 0xFC, 0xEF, 0xE6, 0xF4, 0xFA, /* B0 - B7 */
0xF7, 0xFB, 0xA7, 0xAF, 0xAC, 0xAB, 0xF3, 0xA8, /* B8 - BF */
0xB7, 0xB5, 0xB6, 0xC7, 0x8E, 0x8F, 0x92, 0x80, /* C0 - C7 */
0xD4, 0x90, 0xD2, 0xD3, 0xDE, 0xD6, 0xD7, 0xD8, /* C8 - CF */
0xD1, 0xA5, 0xE3, 0xE0, 0xE2, 0xE5, 0x99, 0x9E, /* D0 - D7 */
0x9D, 0xEB, 0xE9, 0xEA, 0x9A, 0xED, 0xE8, 0xE1, /* D8 - DF */
0x85, 0xA0, 0x83, 0xC6, 0x84, 0x86, 0x91, 0x87, /* E0 - E7 */
0x8A, 0x82, 0x88, 0x89, 0x8D, 0xA1, 0x8C, 0x8B, /* E8 - EF */
0xD0, 0xA4, 0x95, 0xA2, 0x93, 0xE4, 0x94, 0xF6, /* F0 - F7 */
0x9B, 0x97, 0xA3, 0x96, 0x81, 0xEC, 0xE7, 0x98 /* F8 - FF */
};
#endif /* IZ_ISO2OEM_ARRAY */
#ifdef IZ_OEM2ISO_ARRAY
ZCONST uch Far oem2iso[] = {
0xC7, 0xFC, 0xE9, 0xE2, 0xE4, 0xE0, 0xE5, 0xE7, /* 80 - 87 */
0xEA, 0xEB, 0xE8, 0xEF, 0xEE, 0xEC, 0xC4, 0xC5, /* 88 - 8F */
0xC9, 0xE6, 0xC6, 0xF4, 0xF6, 0xF2, 0xFB, 0xF9, /* 90 - 97 */
0xFF, 0xD6, 0xDC, 0xF8, 0xA3, 0xD8, 0xD7, 0x83, /* 98 - 9F */
0xE1, 0xED, 0xF3, 0xFA, 0xF1, 0xD1, 0xAA, 0xBA, /* A0 - A7 */
0xBF, 0xAE, 0xAC, 0xBD, 0xBC, 0xA1, 0xAB, 0xBB, /* A8 - AF */
0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xC1, 0xC2, 0xC0, /* B0 - B7 */
0xA9, 0xA6, 0xA6, 0x2B, 0x2B, 0xA2, 0xA5, 0x2B, /* B8 - BF */
0x2B, 0x2D, 0x2D, 0x2B, 0x2D, 0x2B, 0xE3, 0xC3, /* C0 - C7 */
0x2B, 0x2B, 0x2D, 0x2D, 0xA6, 0x2D, 0x2B, 0xA4, /* C8 - CF */
0xF0, 0xD0, 0xCA, 0xCB, 0xC8, 0x69, 0xCD, 0xCE, /* D0 - D7 */
0xCF, 0x2B, 0x2B, 0xA6, 0x5F, 0xA6, 0xCC, 0xAF, /* D8 - DF */
0xD3, 0xDF, 0xD4, 0xD2, 0xF5, 0xD5, 0xB5, 0xFE, /* E0 - E7 */
0xDE, 0xDA, 0xDB, 0xD9, 0xFD, 0xDD, 0xAF, 0xB4, /* E8 - EF */
0xAD, 0xB1, 0x3D, 0xBE, 0xB6, 0xA7, 0xF7, 0xB8, /* F0 - F7 */
0xB0, 0xA8, 0xB7, 0xB9, 0xB3, 0xB2, 0xA6, 0xA0 /* F8 - FF */
};
#endif /* IZ_OEM2ISO_ARRAY */
#endif /* __ebcdic_h */

View File

@@ -0,0 +1,395 @@
/*---------------------------------------------------------------------------
globals.h
There is usually no need to include this file since unzip.h includes it.
This header file is used by all of the UnZip source files. It contains
a struct definition that is used to "house" all of the global variables.
This is done to allow for multithreaded environments (OS/2, NT, Win95,
Unix) to call UnZip through an API without a semaphore. REENTRANT should
be defined for all platforms that require this.
GLOBAL CONSTRUCTOR AND DESTRUCTOR (API WRITERS READ THIS!!!)
------------------------------------------------------------
No, it's not C++, but it's as close as we can get with K&R.
The main() of each process that uses these globals must include the
CONSTRUCTGLOBALS; statement. This will malloc enough memory for the
structure and initialize any variables that require it. This must
also be done by any API function that jumps into the middle of the
code.
The DESTROYGLOBALS; statement should be inserted before EVERY "EXIT(n)".
Naturally, it also needs to be put before any API returns as well.
In fact, it's much more important in API functions since the process
will NOT end, and therefore the memory WON'T automatically be freed
by the operating system.
USING VARIABLES FROM THE STRUCTURE
----------------------------------
All global variables must now be prefixed with `G.' which is either a
global struct (in which case it should be the only global variable) or
a macro for the value of a local pointer variable that is passed from
function to function. Yes, this is a pain. But it's the only way to
allow full reentrancy.
ADDING VARIABLES TO THE STRUCTURE
---------------------------------
If you make the inclusion of any variables conditional, be sure to only
check macros that are GUARANTEED to be included in every module.
For instance, newzip and pwdarg are needed only if CRYPT is TRUE,
but this is defined after unzip.h has been read. If you are not careful,
some modules will expect your variable to be part of this struct while
others won't. This will cause BIG problems. (Inexplicable crashes at
strange times, car fires, etc.) When in doubt, always include it!
Note also that UnZipSFX needs a few variables that UnZip doesn't. However,
it also includes some object files from UnZip. If we were to conditionally
include the extra variables that UnZipSFX needs, the object files from
UnZip would not mesh with the UnZipSFX object files. Result: we just
include the UnZipSFX variables every time. (It's only an extra 4 bytes
so who cares!)
ADDING FUNCTIONS
----------------
To support this new global struct, all functions must now conditionally
pass the globals pointer (pG) to each other. This is supported by 5 macros:
__GPRO, __GPRO__, __G, __G__ and __GDEF. A function that needs no other
parameters would look like this:
int extract_or_test_files(__G)
__GDEF
{
... stuff ...
}
A function with other parameters would look like:
int memextract(__G__ tgt, tgtsize, src, srcsize)
__GDEF
uch *tgt, *src;
ulg tgtsize, srcsize;
{
... stuff ...
}
In the Function Prototypes section of unzpriv.h, you should use __GPRO and
__GPRO__ instead:
int uz_opts OF((__GPRO__ int *pargc, char ***pargv));
int process_zipfiles OF((__GPRO));
Note that there is NO comma after __G__ or __GPRO__ and no semi-colon after
__GDEF. I wish there was another way but I don't think there is.
TESTING THE CODE
-----------------
Whether your platform requires reentrancy or not, you should always try
building with REENTRANT defined if any functions have been added. It is
pretty easy to forget a __G__ or a __GDEF and this mistake will only show
up if REENTRANT is defined. All platforms should run with REENTRANT
defined. Platforms that can't take advantage of it will just be paying
a performance penalty needlessly.
SIGNAL MADNESS
--------------
This whole pointer passing scheme falls apart when it comes to SIGNALs.
I handle this situation 2 ways right now. If you define USETHREADID,
UnZip will include a 64-entry table. Each entry can hold a global
pointer and thread ID for one thread. This should allow up to 64
threads to access UnZip simultaneously. Calling DESTROYGLOBALS()
will free the global struct and zero the table entry. If somebody
forgets to call DESTROYGLOBALS(), this table will eventually fill up
and UnZip will exit with an error message. A good way to test your
code to make sure you didn't forget a DESTROYGLOBALS() is to change
THREADID_ENTRIES to 3 or 4 in globals.c, making the table real small.
Then make a small test program that calls your API a dozen times.
Those platforms that don't have threads still need to be able to compile
with REENTRANT defined to test and see if new code is correctly written
to work either way. For these platforms, I simply keep a global pointer
called GG that points to the Globals structure. Good enough for testing.
I believe that NT has thread level storage. This could probably be used
to store a global pointer for the sake of the signal handler more cleanly
than my table approach.
---------------------------------------------------------------------------*/
#ifndef __globals_h
#define __globals_h
#ifdef USE_ZLIB
# include "zlib.h"
#endif
/*************/
/* Globals */
/*************/
typedef struct Globals {
#ifdef DLL
zvoid *callerglobs; /* pointer to structure of pass-through global vars */
#endif
/* command options of general use */
UzpOpts UzO; /* command options of general use */
#ifndef FUNZIP
/* command options specific to the high level command line interface */
#ifdef MORE
int M_flag; /* -M: built-in "more" function */
#endif
/* internal flags and general globals */
#ifdef MORE
int height; /* check for SIGWINCH, etc., eventually... */
#endif /* (take line-wrapping into account?) */
#if (defined(IZ_CHECK_TZ) && defined(USE_EF_UT_TIME))
int tz_is_valid; /* indicates that timezone info can be used */
#endif
#ifdef WINDLL
int prompt_always; /* prompt to overwrite if TRUE */
#endif
int noargs; /* did true command line have *any* arguments? */
unsigned filespecs; /* number of real file specifications to be matched */
unsigned xfilespecs; /* number of excluded filespecs to be matched */
int process_all_files;
int create_dirs; /* used by main(), mapname(), checkdir() */
int extract_flag;
int newzip; /* reset in extract.c; used in crypt.c */
LONGINT real_ecrec_offset;
LONGINT expect_ecrec_offset;
long csize; /* used by decompr. (NEXTBYTE): must be signed */
long ucsize; /* used by unReduce(), explode() */
long used_csize; /* used by extract_or_test_member(), explode() */
#ifdef DLL
int fValidate; /* true if only validating an archive */
int filenotfound;
int redirect_data; /* redirect data to memory buffer */
int redirect_text; /* redirect text output to buffer */
# ifndef NO_SLIDE_REDIR
int redirect_slide; /* redirect decompression area to mem buffer */
unsigned _wsize;
# endif
unsigned redirect_size; /* size of redirected output buffer */
uch *redirect_buffer; /* pointer to head of allocated buffer */
uch *redirect_pointer; /* pointer past end of written data */
# ifndef NO_SLIDE_REDIR
uch *redirect_sldptr; /* head of decompression slide buffer */
# endif
# ifdef OS2DLL
cbList(processExternally); /* call-back list */
# endif
#endif /* DLL */
char **pfnames;
char **pxnames;
char sig[4];
char answerbuf[10];
min_info info[DIR_BLKSIZ];
min_info *pInfo;
#endif /* !FUNZIP */
union work area; /* see unzpriv.h for definition of work */
#ifndef FUNZIP
# if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
ZCONST ulg near *crc_32_tab;
# else
ZCONST ulg Far *crc_32_tab;
# endif
#endif
ulg crc32val; /* CRC shift reg. (was static in funzip) */
#ifdef FUNZIP
FILE *in; /* file descriptor of compressed stream */
#endif
uch *inbuf; /* input buffer (any size is OK) */
uch *inptr; /* pointer into input buffer */
int incnt;
#ifndef FUNZIP
ulg bitbuf;
int bits_left; /* unreduce and unshrink only */
int zipeof;
char *argv0; /* used for NT and EXE_EXTENSION */
char *wildzipfn;
char *zipfn; /* GRR: WINDLL: must nuke any malloc'd zipfn... */
#ifdef USE_STRM_INPUT
FILE *zipfd; /* zipfile file descriptor */
#else
int zipfd; /* zipfile file handle */
#endif
LONGINT ziplen;
LONGINT cur_zipfile_bufstart; /* extract_or_test, readbuf, ReadByte */
LONGINT extra_bytes; /* used in unzip.c, misc.c */
uch *extra_field; /* Unix, VMS, Mac, OS/2, Acorn, ... */
uch *hold;
local_file_hdr lrec; /* used in unzip.c, extract.c */
cdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c */
ecdir_rec ecrec; /* used in unzip.c, extract.c */
struct stat statbuf; /* used by main, mapname, check_for_newer */
int mem_mode;
uch *outbufptr; /* extract.c static */
ulg outsize; /* extract.c static */
int reported_backslash; /* extract.c static */
int disk_full;
int newfile;
int didCRlast; /* fileio static */
ulg numlines; /* fileio static: number of lines printed */
int sol; /* fileio static: at start of line */
int no_ecrec; /* process static */
#ifdef SYMLINKS
int symlnk;
#endif
#ifdef NOVELL_BUG_FAILSAFE
int dne; /* true if stat() says file doesn't exist */
#endif
FILE *outfile;
uch *outbuf;
uch *realbuf;
#ifndef VMS /* if SMALL_MEM, outbuf2 is initialized in */
uch *outbuf2; /* process_zipfiles() (never changes); */
#endif /* else malloc'd ONLY if unshrink and -a */
#endif /* !FUNZIP */
uch *outptr;
ulg outcnt; /* number of chars stored in outbuf */
#ifndef FUNZIP
char filename[FILNAMSIZ]; /* also used by NT for temporary SFX path */
#ifdef CMS_MVS
char *tempfn; /* temp file used; erase on close */
#endif
char *key; /* crypt static: decryption password or NULL */
int nopwd; /* crypt static */
#endif /* !FUNZIP */
ulg keys[3]; /* crypt static: keys defining pseudo-random sequence */
#if (!defined(DOS_FLX_H68_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
int echofd; /* ttyio static: file descriptor whose echo is off */
#endif /* !(MACOS || ATARI || VMS) */
#endif /* !(DOS_FLX_H68_OS2_W32 || AMIGA || RISCOS) */
unsigned hufts; /* track memory usage */
#ifdef USE_ZLIB
int inflInit; /* inflate static: zlib inflate() initialized */
z_stream dstrm; /* inflate global: decompression stream */
#else
struct huft *fixed_tl; /* inflate static */
struct huft *fixed_td; /* inflate static */
int fixed_bl, fixed_bd; /* inflate static */
unsigned wp; /* inflate static: current position in slide */
ulg bb; /* inflate static: bit buffer */
unsigned bk; /* inflate static: bits in bit buffer */
#endif /* ?USE_ZLIB */
#ifndef FUNZIP
#ifdef SMALL_MEM
char rgchBigBuffer[512];
char rgchSmallBuffer[96];
char rgchSmallBuffer2[160]; /* boosted to 160 for local3[] in unzip.c */
#endif
MsgFn *message;
InputFn *input;
PauseFn *mpause;
PasswdFn *decr_passwd;
StatCBFn *statreportcb;
#ifdef WINDLL
LPUSERFUNCTIONS lpUserFunctions;
#endif
int incnt_leftover; /* so improved NEXTBYTE does not waste input */
uch *inptr_leftover;
#ifdef VMS_TEXT_CONV
int VMS_line_state; /* so native VMS variable-length text files are */
int VMS_line_length; /* readable on other platforms */
int VMS_line_pad;
#endif
#endif /* !FUNZIP */
#ifdef SYSTEM_SPECIFIC_GLOBALS
SYSTEM_SPECIFIC_GLOBALS
#endif
} Uz_Globs; /* end of struct Globals */
/***************************************************************************/
#ifdef FUNZIP
# if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
extern ZCONST ulg near crc_32_tab[256];
# else
extern ZCONST ulg Far *crc_32_tab;
# endif
# define CRC_32_TAB crc_32_tab
#else
# define CRC_32_TAB G.crc_32_tab
#endif
Uz_Globs *globalsCtor OF((void));
/* pseudo constant sigs; they are initialized at runtime so unzip executable
* won't look like a zipfile
*/
extern char local_hdr_sig[4];
extern char central_hdr_sig[4];
extern char end_central_sig[4];
/* extern char extd_local_sig[4]; NOT USED YET */
#ifdef REENTRANT
# define G (*(Uz_Globs *)pG)
# define __G pG
# define __G__ pG,
# define __GPRO Uz_Globs *pG
# define __GPRO__ Uz_Globs *pG,
# define __GDEF Uz_Globs *pG;
# ifdef USETHREADID
extern int lastScan;
void deregisterGlobalPointer OF((__GPRO));
Uz_Globs *getGlobalPointer OF((void));
# define GETGLOBALS() Uz_Globs *pG = getGlobalPointer();
# define DESTROYGLOBALS() {free_G_buffers(pG); deregisterGlobalPointer(pG);}
# else
extern Uz_Globs *GG;
# define GETGLOBALS() Uz_Globs *pG = GG;
# define DESTROYGLOBALS() {free_G_buffers(pG); free(pG);}
# endif /* ?USETHREADID */
# define CONSTRUCTGLOBALS() Uz_Globs *pG = globalsCtor()
#else /* !REENTRANT */
extern Uz_Globs G;
# define __G
# define __G__
# define __GPRO void
# define __GPRO__
# define __GDEF
# define GETGLOBALS()
# define CONSTRUCTGLOBALS() globalsCtor()
# define DESTROYGLOBALS()
#endif /* ?REENTRANT */
#define uO G.UzO
#endif /* __globals_h */

View File

@@ -0,0 +1,24 @@
/* inflate.h for UnZip -- put in the public domain by Mark Adler
version c14f, 23 November 1995 */
/* You can do whatever you like with this source file, though I would
prefer that if you modify it and redistribute it that you include
comments to that effect with your name and the date. Thank you.
History:
vers date who what
---- --------- -------------- ------------------------------------
c14 12 Mar 93 M. Adler made inflate.c standalone with the
introduction of inflate.h.
c14d 28 Aug 93 G. Roelofs replaced flush/FlushOutput with new version
c14e 29 Sep 93 G. Roelofs moved everything into unzip.h; added crypt.h
c14f 23 Nov 95 G. Roelofs added UNZIP_INTERNAL to accommodate newly
split unzip.h
*/
#define UNZIP_INTERNAL
#include "unzip.h" /* provides slide[], typedefs and macros */
#ifdef FUNZIP
# include "crypt.h" /* provides NEXTBYTE macro for crypt version of funzip */
#endif

28
utils/Install/inczip/nt.h Normal file
View File

@@ -0,0 +1,28 @@
/* nt.h: central header for EF_NTSD "SD" extra field */
#ifndef _NT_H
#define _NT_H
#define NTSD_BUFFERSIZE (1024) /* threshold to cause malloc() */
#define OVERRIDE_BACKUP 1 /* we have SeBackupPrivilege on remote */
#define OVERRIDE_RESTORE 2 /* we have SeRestorePrivilege on remote */
#define OVERRIDE_SACL 4 /* we have SeSystemSecurityPrivilege on remote */
typedef struct {
BOOL bValid; /* are our contents valid? */
BOOL bProcessDefer; /* process deferred entry yet? */
BOOL bUsePrivileges; /* use privilege overrides? */
DWORD dwFileSystemFlags; /* describes target file system */
BOOL bRemote; /* is volume remote? */
DWORD dwRemotePrivileges; /* relevant only on remote volumes */
DWORD dwFileAttributes;
char RootPath[MAX_PATH+1]; /* path to network / filesystem */
} VOLUMECAPS, *PVOLUMECAPS, *LPVOLUMECAPS;
BOOL SecuritySet(char *resource, PVOLUMECAPS VolumeCaps, uch *securitydata);
BOOL GetVolumeCaps(char *rootpath, char *name, PVOLUMECAPS VolumeCaps);
BOOL ValidateSecurity(uch *securitydata);
BOOL ProcessDefer(PDWORD dwDirectoryCount, PDWORD dwBytesProcessed,
PDWORD dwDirectoryFail, PDWORD dwBytesFail);
#endif /* _NT_H */

View File

@@ -0,0 +1,32 @@
/* os2acl.h
*
* Author: Kai Uwe Rommel <rommel@ars.de>
* Created: Fri Mar 29 1996
*/
/* $Id$ */
/*
* $Log$
* Revision 1.2 2000/07/15 19:50:44 cvsuser
* merged 2.2 branch
*
* Revision 1.1.2.1 2000/04/11 12:38:05 BS
* Added wxInstall a self extracting installation program using wxWindows.
*
* Revision 1.1 1996/03/30 09:35:00 rommel
* Initial revision
*
*/
#ifndef _OS2ACL_H
#define _OS2ACL_H
#define ACL_BUFFERSIZE 4096
int acl_get(char *server, const char *resource, char *buffer);
int acl_set(char *server, const char *resource, char *buffer);
#endif /* _OS2ACL_H */
/* end of os2acl.h */

View File

@@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------
OS/2 specific configuration section:
---------------------------------------------------------------------------*/
#ifndef __os2cfg_h
#define __os2cfg_h
#ifdef MSDOS
# include <dos.h> /* for REGS macro (TC) or _dos_setftime (MSC) */
# ifdef __TURBOC__ /* includes Power C */
# include <sys/timeb.h> /* for structure ftime */
# ifndef __BORLANDC__ /* there appears to be a bug (?) in Borland's */
# include <mem.h> /* MEM.H related to __STDC__ and far poin- */
# endif /* ters. (dpk) [mem.h included for memcpy] */
# endif
#endif /* MSDOS */
#ifdef __IBMC__
# define S_IFMT 0xF000
# define timezone _timezone /* (underscore names work with */
# define tzset _tzset /* all versions of C Set) */
# define PIPE_ERROR (errno == EERRSET || errno == EOS2ERR)
#endif /* __IBMC__ */
#ifdef __WATCOMC__
# ifdef __386__
# ifndef WATCOMC_386
# define WATCOMC_386
# endif
# define __32BIT__
# undef far
# define far
# undef near
# define near
/* Get asm routines to link properly without using "__cdecl": */
# ifndef USE_ZLIB
# pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
# pragma aux get_crc_table "_*" parm caller [] value [eax] \
modify [eax ecx edx]
# endif /* !USE_ZLIB */
# else /* !__386__ */
# ifndef USE_ZLIB
# pragma aux crc32 "_*" parm caller [] value [ax dx] \
modify [ax cx dx bx]
# pragma aux get_crc_table "_*" parm caller [] value [ax] \
modify [ax cx dx bx]
# endif /* !USE_ZLIB */
# endif /* ?__386__ */
# ifndef EPIPE
# define EPIPE -1
# endif
# define PIPE_ERROR (errno == EPIPE)
#endif /* __WATCOMC__ */
#ifdef __EMX__
# ifndef __32BIT__
# define __32BIT__
# endif
# define far
#endif
#ifndef __32BIT__
# define __16BIT__
#endif
#ifdef MSDOS
# undef MSDOS
#endif
#if defined(M_I86CM) || defined(M_I86LM)
# define MED_MEM
#endif
#if (defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__))
# define MED_MEM
#endif
#ifdef __16BIT__
# ifndef MED_MEM
# define SMALL_MEM
# endif
#endif
#ifdef __16BIT__
# if defined(MSC) || defined(__WATCOMC__)
# include <malloc.h>
# define nearmalloc _nmalloc
# define nearfree _nfree
# endif
# if defined(__TURBOC__) && defined(DYNALLOC_CRCTAB)
# if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
# undef DYNALLOC_CRCTAB
# endif
# endif
# ifndef nearmalloc
# define nearmalloc malloc
# define nearfree free
# endif
#endif
/* TIMESTAMP is now supported on OS/2, so enable it by default */
#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
#endif
/* check that TZ environment variable is defined before using UTC times */
#if (!defined(NO_IZ_CHECK_TZ) && !defined(IZ_CHECK_TZ))
# define IZ_CHECK_TZ
#endif
#ifndef OS2_EAS
# define OS2_EAS /* for -l and -v listings (list.c) */
#endif
#ifdef isupper
# undef isupper
#endif
#ifdef tolower
# undef tolower
#endif
#define isupper(x) IsUpperNLS((unsigned char)(x))
#define tolower(x) ToLowerNLS((unsigned char)(x))
#define USETHREADID
/* handlers for OEM <--> ANSI string conversions */
#ifndef _OS2_ISO_ANSI
/* use home-brewed conversion functions; internal charset is OEM */
# ifdef CRTL_CP_IS_ISO
# undef CRTL_CP_IS_ISO
# endif
# ifndef CRTL_CP_IS_OEM
# define CRTL_CP_IS_OEM
# endif
#endif
#endif /* !__os2cfg_h */

View File

@@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------
os2data.h
OS/2-specific structures and data to be included in the global data struc-
ture.
---------------------------------------------------------------------------*/
#define MAXNAMLEN 256
#define MAXPATHLEN 256
#define MAXLEN 256 /* temporary buffer length */
#define IBUF_LEN 4096 /* input buffer length */
#define INCL_NOPM
#define INCL_DOSNLS
#define INCL_DOSPROCESS
#define INCL_DOSDEVICES
#define INCL_DOSDEVIOCTL
#define INCL_DOSERRORS
#define INCL_DOSMISC
#if (defined(OS2DLL) && !defined(DLL))
# undef OS2DLL
#endif
#ifdef OS2DLL
# define INCL_REXXSAA
# include <rexxsaa.h>
#endif
#include <os2.h>
struct direct
{
ino_t d_ino; /* a bit of a farce */
int d_reclen; /* more farce */
int d_namlen; /* length of d_name */
char d_name[MAXNAMLEN + 1]; /* null terminated */
/* nonstandard fields */
long d_size; /* size in bytes */
unsigned d_mode; /* MS-DOS or OS/2 file attributes */
unsigned d_time;
unsigned d_date;
};
/* The fields d_size and d_mode are extensions by me (Kai Uwe Rommel). The
* find_first and find_next calls deliver these data without any extra cost.
* If these data are needed, the fields save a lot of extra calls to stat()
* (each stat() again performs a find_first call !).
*/
struct _dircontents
{
char *_d_entry;
long _d_size;
unsigned _d_mode, _d_time, _d_date;
struct _dircontents *_d_next;
};
typedef struct _dirdesc
{
int dd_id; /* uniquely identify each open directory */
long dd_loc; /* where we are in directory entry is this */
struct _dircontents *dd_contents; /* pointer to contents of dir */
struct _dircontents *dd_cp; /* pointer to current position */
}
DIR;
struct os2Global {
#ifndef SFX
HDIR hdir;
#ifdef __32BIT__
ULONG count;
FILEFINDBUF3 find;
#else
USHORT count;
FILEFINDBUF find;
#endif
#endif /* !SFX */
int created_dir; /* used by mapname(), checkdir() */
int renamed_fullpath; /* ditto */
int fnlen; /* ditto */
#ifdef __32BIT__
ULONG nLabelDrive; /* ditto */
#else
USHORT nLabelDrive;
#endif
int longnameEA; /* checkdir(), close_outfile() */
char *lastpathcomp; /* ditto */
struct direct dp;
int lower;
USHORT nLastDrive, nResult;
DIR *dir;
char *dirname, *wildname, matchname[FILNAMSIZ];
int firstcall, have_dirname, dirnamelen;
int rootlen; /* length of rootpath */
char *rootpath; /* user's "extract-to" directory */
char *buildpathHPFS; /* full path (so far) to extracted file, */
char *buildpathFAT; /* both HPFS/EA (main) and FAT versions */
char *endHPFS; /* corresponding pointers to end of */
char *endFAT; /* buildpath ('\0') */
#ifdef OS2DLL
char buffer[IBUF_LEN];
char output_var[MAXLEN];
char getvar_buf[MAXLEN];
int getvar_len;
int output_idx;
int stem_len;
int putchar_idx;
int rexx_error;
char *rexx_mes;
SHVBLOCK request;
#endif
};
#define SYSTEM_SPECIFIC_GLOBALS struct os2Global os2;
#define SYSTEM_SPECIFIC_CTOR os2GlobalsCtor
#ifdef OS2DLL
# ifdef API_DOC
# define SYSTEM_API_BRIEF REXXBrief
# define SYSTEM_API_DETAILS REXXDetails
extern char *REXXBrief;
extern APIDocStruct REXXDetails[];
# endif
#endif

View File

@@ -0,0 +1,155 @@
/* rsxntwin.h
*
* fills some gaps in the rsxnt 1.3 win32 header files (<windows.h>) that are
* required for compiling Info-ZIP sources for Win NT / Win 95
*/
#ifdef __RSXNT__
#if !defined (_RSXNTWIN_H)
#define _RSXNTWIN_H
#ifdef TFUNCT /* TFUNCT is undefined when MSSDK headers are used */
#ifdef __cplusplus
extern "C" {
#endif
#define PASCAL __stdcall
#define ANYSIZE_ARRAY 1
#ifndef TIME_ZONE_ID_UNKNOWN
# define TIME_ZONE_ID_UNKNOWN 0
#endif
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
#define FILE_SHARE_DELETE 0x00000004
#define FILE_PERSISTENT_ACLS 0x00000008
#define HFILE_ERROR ((HFILE)-1)
#define FS_PERSISTENT_ACLS FILE_PERSISTENT_ACLS
BOOL WINAPI DosDateTimeToFileTime(WORD, WORD, LPFILETIME);
#ifndef SetVolumeLabel
#define SetVolumeLabel TFUNCT(SetVolumeLabel)
#endif
BOOL WINAPI SetVolumeLabel(LPCTSTR, LPCTSTR);
#ifndef GetDriveType
#define GetDriveType TFUNCT(GetDriveType)
#endif
DWORD GetDriveType(LPCTSTR);
#define DRIVE_UNKNOWN 0
#define DRIVE_REMOVABLE 2
#define DRIVE_FIXED 3
#define DRIVE_REMOTE 4
#define DRIVE_CDROM 5
#define DRIVE_RAMDISK 6
#ifndef SearchPath
#define SearchPath TFUNCT(SearchPath)
#endif
BOOL WINAPI SearchPath(LPCTSTR, LPCTSTR, LPCTSTR, UINT, LPTSTR, LPTSTR *);
#define ERROR_SUCCESS 0
#define ERROR_INSUFFICIENT_BUFFER 122
LONG WINAPI InterlockedExchange(LPLONG, LONG);
#define ACCESS_SYSTEM_SECURITY 0x01000000L
typedef PVOID PSECURITY_DESCRIPTOR;
typedef PVOID PSID;
typedef struct _ACL {
BYTE AclRevision;
BYTE Sbz1;
WORD AclSize;
WORD AceCount;
WORD Sbz2;
} ACL;
typedef ACL *PACL;
typedef struct _LUID {
DWORD LowPart;
LONG HighPart;
} LUID, *PLUID;
typedef struct _LUID_AND_ATTRIBUTES {
LUID Luid;
DWORD Attributes;
} LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
typedef struct _TOKEN_PRIVILEGES {
DWORD PrivilegeCount;
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
} TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
#define TOKEN_QUERY 0x0008
#define TOKEN_ADJUST_PRIVILEGES 0x0020
BOOL WINAPI OpenProcessToken(HANDLE, DWORD, PHANDLE);
BOOL WINAPI AdjustTokenPrivileges(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD,
PTOKEN_PRIVILEGES, PDWORD);
#ifndef LookupPrivilegeValue
#define LookupPrivilegeValue TFUNCT(LookupPrivilegeValue)
#endif
BOOL WINAPI LookupPrivilegeValue(LPCTSTR, LPCTSTR, PLUID);
typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
#define OWNER_SECURITY_INFORMATION 0x00000001L
#define GROUP_SECURITY_INFORMATION 0x00000002L
#define DACL_SECURITY_INFORMATION 0x00000004L
#define SACL_SECURITY_INFORMATION 0x00000008L
typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
#define SE_DACL_PRESENT 0x0004
#define SE_SACL_PRESENT 0x0010
#define SE_PRIVILEGE_ENABLED 0x00000002L
#define SE_SECURITY_NAME TEXT("SeSecurityPrivilege")
#define SE_BACKUP_NAME TEXT("SeBackupPrivilege")
#define SE_RESTORE_NAME TEXT("SeRestorePrivilege")
BOOL WINAPI GetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION,
PSECURITY_DESCRIPTOR, DWORD, LPDWORD);
BOOL WINAPI SetKernelObjectSecurity(HANDLE, SECURITY_INFORMATION,
PSECURITY_DESCRIPTOR);
BOOL WINAPI IsValidSid(PSID);
BOOL WINAPI IsValidAcl(PACL);
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR);
BOOL WINAPI IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR);
DWORD WINAPI GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR);
BOOL WINAPI GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR,
PSECURITY_DESCRIPTOR_CONTROL, LPDWORD);
BOOL WINAPI SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR,
SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL);
BOOL WINAPI GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR,
LPBOOL, PACL *, LPBOOL);
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
BOOL WINAPI GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR,
LPBOOL, PACL *, LPBOOL);
BOOL WINAPI SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR, BOOL, PACL, BOOL);
BOOL WINAPI GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID *, LPBOOL);
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR, PSID, BOOL);
BOOL WINAPI GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID *, LPBOOL);
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR, PSID, BOOL);
VOID WINAPI InitializeCriticalSection();
#ifdef __cplusplus
}
#endif
#endif /* TFUNCT */
#endif /* !defined (_RSXNTWIN_H) */
#endif /* __RSXNT__ */

View File

@@ -0,0 +1,81 @@
/*---------------------------------------------------------------------------
tables.h
This file contains only the 32-bit CRC table used in fUnZip;
it is in a separate file because it is rather big and ugly and
gets in the way during editing.
This file can be included in no more than ONE source file per
executable, of course.
---------------------------------------------------------------------------*/
#ifndef __tables_h /* prevent multiple inclusions */
#define __tables_h
#ifdef FUNZIP
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
/* Table of CRC-32's of all single-byte values (made by makecrc.c) */
ZCONST ulg near crc_32_tab[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
#else /* USE_ZLIB && !USE_OWN_CRCTAB */
ZCONST uLongf *crc_32_tab = NULL;
#endif /* ?(!USE_ZLIB || USE_OWN_CRCTAB) */
#endif /* FUNZIP */
#endif /* __tables_h */

View File

@@ -0,0 +1,186 @@
/*
ttyio.h
*/
#ifndef __ttyio_h /* don't include more than once */
#define __ttyio_h
#ifndef __crypt_h
# include "crypt.h" /* ensure that encryption header file has been seen */
#endif
#if (CRYPT || (defined(UNZIP) && !defined(FUNZIP)))
/*
* Non-echo keyboard/console input support is needed and enabled.
*/
#ifndef __G /* UnZip only, for now (DLL stuff) */
# define __G
# define __G__
# define __GDEF
# define __GPRO void
# define __GPRO__
#endif
#ifndef ZCONST /* UnZip only (until have configure script like Zip) */
# define ZCONST const
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WIN32))
# ifndef DOS_OS2_W32
# define DOS_OS2_W32
# endif
#endif
#if (defined(DOS_OS2_W32) || defined(__human68k__))
# ifndef DOS_H68_OS2_W32
# define DOS_H68_OS2_W32
# endif
#endif
#if (defined(DOS_OS2_W32) || defined(FLEXOS))
# ifndef DOS_FLX_OS2_W32
# define DOS_FLX_OS2_W32
# endif
#endif
#if (defined(DOS_H68_OS2_W32) || defined(FLEXOS))
# ifndef DOS_FLX_H68_OS2_W32
# define DOS_FLX_H68_OS2_W32
# endif
#endif
#if (defined(VM_CMS) || defined(MVS))
# ifndef CMS_MVS
# define CMS_MVS
# endif
#endif
/* Function prototypes */
/* The following systems supply a `non-echo' character input function "getch()"
* (or an alias) and do not need the echoff() / echon() function pair.
*/
#ifdef AMIGA
# define echoff(f)
# define echon()
# define getch() Agetch()
# define HAVE_WORKING_GETCH
#endif /* AMIGA */
#ifdef ATARI
# define echoff(f)
# define echon()
# include <osbind.h>
# define getch() (Cnecin() & 0x000000ff)
# define HAVE_WORKING_GETCH
#endif
#ifdef MACOS
# define echoff(f)
# define echon()
# define getch() macgetch()
# define HAVE_WORKING_GETCH
#endif
#ifdef QDOS
# define echoff(f)
# define echon()
# define HAVE_WORKING_GETCH
#endif
#ifdef RISCOS
# define echoff(f)
# define echon()
# define getch() SWI_OS_ReadC()
# define HAVE_WORKING_GETCH
#endif
#ifdef DOS_H68_OS2_W32
# define echoff(f)
# define echon()
# ifdef WIN32
# ifndef getch
# define getch() getch_win32()
# endif
# else /* !WIN32 */
# ifdef __EMX__
# ifndef getch
# define getch() _read_kbd(0, 1, 0)
# endif
# else /* !__EMX__ */
# ifdef __GO32__
# include <pc.h>
# define getch() getkey()
# else /* !__GO32__ */
# include <conio.h>
# endif /* ?__GO32__ */
# endif /* ?__EMX__ */
# endif /* ?WIN32 */
# define HAVE_WORKING_GETCH
#endif /* DOS_H68_OS2_W32 */
#ifdef FLEXOS
# define echoff(f)
# define echon()
# define getch() getchar() /* not correct, but may not be on a console */
# define HAVE_WORKING_GETCH
#endif
/* For VM/CMS and MVS, we do not (yet) have any support to switch terminal
* input echo on and off. The following "fake" definitions allow inclusion
* of crypt support and UnZip's "pause prompting" features, but without
* any echo suppression.
*/
#ifdef CMS_MVS
# define echoff(f)
# define echon()
#endif
/* VMS has a single echo() function in ttyio.c to toggle terminal
* input echo on and off.
*/
#ifdef VMS
# define echoff(f) echo(0)
# define echon() echo(1)
int echo OF((int));
#endif
/* For all other systems, ttyio.c supplies the two functions Echoff() and
* Echon() for suppressing and (re)enabling console input echo.
*/
#ifndef echoff
# define echoff(f) Echoff(__G__ f)
# define echon() Echon(__G)
void Echoff OF((__GPRO__ int f));
void Echon OF((__GPRO));
#endif
/* this stuff is used by MORE and also now by the ctrl-S code; fileio.c only */
#if (defined(UNZIP) && !defined(FUNZIP))
# ifdef HAVE_WORKING_GETCH
# define FGETCH(f) getch()
# endif
# ifndef FGETCH
/* default for all systems where no getch()-like function is available */
int zgetch OF((__GPRO__ int f));
# define FGETCH(f) zgetch(__G__ f)
# endif
#endif /* UNZIP && !FUNZIP */
#if (CRYPT && !defined(WINDLL))
char *getp OF((__GPRO__ ZCONST char *m, char *p, int n));
#endif
#else /* !(CRYPT || (UNZIP && !FUNZIP)) */
/*
* No need for non-echo keyboard/console input; provide dummy definitions.
*/
#define echoff(f)
#define echon()
#endif /* ?(CRYPT || (UNZIP && !FUNZIP)) */
#endif /* !__ttyio_h */

View File

@@ -0,0 +1,548 @@
/*---------------------------------------------------------------------------
unzip.h (new)
This header file contains the public macros and typedefs required by
both the UnZip sources and by any application using the UnZip API. If
UNZIP_INTERNAL is defined, it includes unzpriv.h (containing includes,
prototypes and extern variables used by the actual UnZip sources).
---------------------------------------------------------------------------*/
#ifndef __unzip_h /* prevent multiple inclusions */
#define __unzip_h
/*---------------------------------------------------------------------------
Predefined, machine-specific macros.
---------------------------------------------------------------------------*/
#ifdef __GO32__ /* MS-DOS extender: NOT Unix */
# ifdef unix
# undef unix
# endif
# ifdef __unix
# undef __unix
# endif
# ifdef __unix__
# undef __unix__
# endif
#endif
#if ((defined(__convex__) || defined(__convexc__)) && !defined(CONVEX))
# define CONVEX
#endif
#if (defined(unix) || defined(__unix) || defined(__unix__))
# ifndef UNIX
# define UNIX
# endif
#endif /* unix || __unix || __unix__ */
#if (defined(M_XENIX) || defined(COHERENT) || defined(__hpux))
# ifndef UNIX
# define UNIX
# endif
#endif /* M_XENIX || COHERENT || __hpux */
#if (defined(CONVEX) || defined(MINIX) || defined(_AIX) || defined(__QNX__))
# ifndef UNIX
# define UNIX
# endif
#endif /* CONVEX || MINIX || _AIX || __QNX__ */
#if (defined(VM_CMS) || defined(MVS))
# define CMS_MVS
#endif
#if (defined(__OS2__) && !defined(OS2))
# define OS2
#endif
#if (defined(__TANDEM) && !defined(TANDEM))
# define TANDEM
#endif
#if (defined(__VMS) && !defined(VMS))
# define VMS
#endif
#if ((defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32))
# define WIN32
#endif
#if ((defined(__WINNT__) || defined(__WINNT)) && !defined(WIN32))
# define WIN32
#endif
#ifdef __COMPILER_KCC__
# include <c-env.h>
# ifdef SYS_T20
# define TOPS20
# endif
#endif /* __COMPILER_KCC__ */
/* Borland C does not define __TURBOC__ if compiling for a 32-bit platform */
#ifdef __BORLANDC__
# ifndef __TURBOC__
# define __TURBOC__
# endif
# if (!defined(__MSDOS__) && !defined(OS2) && !defined(WIN32))
# define __MSDOS__
# endif
#endif
/* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
#ifdef __POWERC
# define __TURBOC__
# define MSDOS
#endif /* __POWERC */
#if (defined(__MSDOS__) && !defined(MSDOS)) /* just to make sure */
# define MSDOS
#endif
/* RSXNTDJ (at least up to v1.3) compiles for WIN32 (RSXNT) using a derivate
of the EMX environment, but defines MSDOS and __GO32__. ARG !!! */
#if (defined(MSDOS) && defined(WIN32))
# undef MSDOS /* WIN32 is >>>not<<< MSDOS */
#endif
#if (defined(__GO32__) && defined(__EMX__) && defined(__RSXNT__))
# undef __GO32__
#endif
#if (defined(linux) && !defined(LINUX))
# define LINUX
#endif
#ifdef __riscos
# define RISCOS
#endif
#if (defined(THINK_C) || defined(MPW))
# define MACOS
#endif
#if (defined(__MWERKS__) && defined(macintosh))
# define MACOS
#endif
/* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C, or
* Silicon Graphics, or Convex?, or IBM C Set/2, or GNU gcc/emx, or Watcom C,
* or Macintosh, or Windows NT, or Sequent, or Atari or IBM RS/6000.
*/
#if (defined(__STDC__) || defined(MSDOS) || defined(WIN32) || defined(__EMX__))
# ifndef PROTO
# define PROTO
# endif
# ifndef MODERN
# define MODERN
# endif
#endif
#if (defined(__IBMC__) || defined(__BORLANDC__) || defined(__WATCOMC__))
# ifndef PROTO
# define PROTO
# endif
# ifndef MODERN
# define MODERN
# endif
#endif
#if (defined(MACOS) || defined(ATARI_ST) || defined(RISCOS))
# ifndef PROTO
# define PROTO
# endif
# ifndef MODERN
# define MODERN
# endif
#endif
/* Sequent running Dynix/ptx: non-modern compiler */
#if (defined(_AIX) || defined(sgi) || (defined(_SEQUENT_) && !defined(PTX)))
# ifndef PROTO
# define PROTO
# endif
# ifndef MODERN
# define MODERN
# endif
#endif
#if (defined(CMS_MVS) || defined(__BEOS__)) /* || defined(CONVEX) */
# ifndef PROTO
# define PROTO
# endif
# ifndef MODERN
# define MODERN
# endif
#endif
/* turn off prototypes if requested */
#if (defined(NOPROTO) && defined(PROTO))
# undef PROTO
#endif
/* used to remove arguments in function prototypes for non-ANSI C */
#ifdef PROTO
# define OF(a) a
#else
# define OF(a) ()
#endif
/* enable the "const" keyword only if MODERN and if not otherwise instructed */
#ifdef MODERN
# if (!defined(ZCONST) && (defined(USE_CONST) || !defined(NO_CONST)))
# define ZCONST const
# endif
#endif
#ifndef ZCONST
# define ZCONST
#endif
/*---------------------------------------------------------------------------
Grab system-specific public include headers.
---------------------------------------------------------------------------*/
#ifdef POCKET_UNZIP /* WinCE port */
# include "wince/punzip.h" /* must appear before windows.h */
#endif
#ifdef WINDLL
# include <windows.h>
# include "windll/structs.h"
#endif
/*---------------------------------------------------------------------------
Grab system-dependent definition of EXPENTRY for prototypes below.
---------------------------------------------------------------------------*/
#if 0
#if (defined(OS2) && !defined(FUNZIP))
# ifdef UNZIP_INTERNAL
# define INCL_NOPM
# define INCL_DOSNLS
# define INCL_DOSPROCESS
# define INCL_DOSDEVICES
# define INCL_DOSDEVIOCTL
# define INCL_DOSERRORS
# define INCL_DOSMISC
# ifdef OS2DLL
# define INCL_REXXSAA
# include <rexxsaa.h>
# endif
# endif /* UNZIP_INTERNAL */
# include <os2.h>
# define UZ_EXP EXPENTRY
#endif /* OS2 && !FUNZIP */
#endif /* 0 */
#if (defined(OS2) && !defined(FUNZIP))
# if (defined(__IBMC__) || defined(__WATCOMC__))
# define UZ_EXP _System /* compiler keyword */
# else
# define UZ_EXP
# endif
#endif /* OS2 && !FUNZIP */
#if (defined(WINDLL) || defined(USE_UNZIP_LIB))
# ifndef EXPENTRY
# define UZ_EXP WINAPI
# else
# define UZ_EXP EXPENTRY
# endif
#endif
#ifndef UZ_EXP
# define UZ_EXP
#endif
/*---------------------------------------------------------------------------
Public typedefs.
---------------------------------------------------------------------------*/
#ifndef _IZ_TYPES_DEFINED
#ifdef MODERN
typedef void zvoid;
#else /* !MODERN */
# ifndef AOS_VS /* mostly modern? */
# ifndef VAXC /* not fully modern, but has knows 'void' */
# define void int
# endif /* !VAXC */
# endif /* !AOS_VS */
typedef char zvoid;
#endif /* ?MODERN */
typedef unsigned char uch; /* code assumes unsigned bytes; these type- */
typedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */
typedef unsigned long ulg; /* predefined on some systems) & match zip */
#define _IZ_TYPES_DEFINED
#endif /* !_IZ_TYPES_DEFINED */
/* InputFn is not yet used and is likely to change: */
#ifdef PROTO
typedef int (UZ_EXP MsgFn) (zvoid *pG, uch *buf, ulg size, int flag);
typedef int (UZ_EXP InputFn) (zvoid *pG, uch *buf, int *size, int flag);
typedef void (UZ_EXP PauseFn) (zvoid *pG, ZCONST char *prompt, int flag);
typedef int (UZ_EXP PasswdFn) (zvoid *pG, int *rcnt, char *pwbuf,
int size, ZCONST char *zfn,
ZCONST char *efn);
typedef int (UZ_EXP StatCBFn) (zvoid *pG, int fnflag, ZCONST char *zfn,
ZCONST char *efn, ZCONST zvoid *details);
typedef void (UZ_EXP UsrIniFn) (void);
#else /* !PROTO */
typedef int (UZ_EXP MsgFn) ();
typedef int (UZ_EXP InputFn) ();
typedef void (UZ_EXP PauseFn) ();
typedef int (UZ_EXP PasswdFn) ();
typedef int (UZ_EXP StatCBFn) ();
typedef void (UZ_EXP UsrIniFn) ();
#endif /* ?PROTO */
typedef struct _UzpBuffer { /* rxstr */
ulg strlength; /* length of string */
char *strptr; /* pointer to string */
} UzpBuffer;
typedef struct _UzpInit {
ulg structlen; /* length of the struct being passed */
/* GRR: can we assume that each of these is a 32-bit pointer? if not,
* does it matter? add "far" keyword to make sure? */
MsgFn *msgfn;
InputFn *inputfn;
PauseFn *pausefn;
UsrIniFn *userfn; /* user init function to be called after */
/* globals constructed and initialized */
/* pointer to program's environment area or something? */
/* hooks for performance testing? */
/* hooks for extra unzip -v output? (detect CPU or other hardware?) */
/* anything else? let me (Greg) know... */
} UzpInit;
typedef struct _UzpCB {
ulg structlen; /* length of the struct being passed */
/* GRR: can we assume that each of these is a 32-bit pointer? if not,
* does it matter? add "far" keyword to make sure? */
MsgFn *msgfn;
InputFn *inputfn;
PauseFn *pausefn;
PasswdFn *passwdfn;
StatCBFn *statrepfn;
} UzpCB;
/* the collection of general UnZip option flags and option arguments */
typedef struct _UzpOpts {
#ifndef FUNZIP
char *exdir; /* pointer to extraction root directory (-d option) */
char *pwdarg; /* pointer to command-line password (-P option) */
int zipinfo_mode; /* behave like ZipInfo or like normal UnZip? */
int aflag; /* -a: do ASCII-EBCDIC and/or end-of-line translation */
#ifdef VMS
int bflag; /* -b: force fixed record format for binary files */
#endif
#ifdef UNIXBACKUP
int B_flag; /* -B: back up existing files by renaming to *~ first */
#endif
int cflag; /* -c: output to stdout */
int C_flag; /* -C: match filenames case-insensitively */
#ifdef MACOS
int E_flag; /* -E: [MacOS] show Mac extra field during restoring */
#endif
int fflag; /* -f: "freshen" (extract only newer files) */
#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
int acorn_nfs_ext; /* -F: RISC OS types & NFS filetype extensions */
#endif
int hflag; /* -h: header line (zipinfo) */
#ifdef MACOS
int i_flag; /* -i: [MacOS] ignore filenames stored in Mac e.f. */
#endif
#ifdef RISCOS
int scanimage; /* -I: scan image files */
#endif
int jflag; /* -j: junk pathnames (unzip) */
#if (defined(__BEOS__) || defined(MACOS))
int J_flag; /* -J: ignore BeOS/MacOS extra field info (unzip) */
#endif
int lflag; /* -12slmv: listing format (zipinfo) */
int L_flag; /* -L: convert filenames from some OSes to lowercase */
int overwrite_none; /* -n: never overwrite files (no prompting) */
#ifdef AMIGA
int N_flag; /* -N: restore comments as AmigaDOS filenotes */
#endif
int overwrite_all; /* -o: OK to overwrite files without prompting */
#endif /* !FUNZIP */
int qflag; /* -q: produce a lot less output */
#ifndef FUNZIP
#if (defined(MSDOS) || defined(FLEXOS) || defined(OS2) || defined(WIN32))
int sflag; /* -s: convert spaces in filenames to underscores */
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WIN32))
int volflag; /* -$: extract volume labels */
#endif
int tflag; /* -t: test (unzip) or totals line (zipinfo) */
int T_flag; /* -T: timestamps (unzip) or dec. time fmt (zipinfo) */
int uflag; /* -u: "update" (extract only newer/brand-new files) */
int vflag; /* -v: (verbosely) list directory */
int V_flag; /* -V: don't strip VMS version numbers */
#if (defined(TANDEM) || defined(UNIX) || defined(VMS) || defined(__BEOS__))
int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */
#endif
#if (defined(OS2) || defined(WIN32))
int X_flag; /* -X: restore owner/protection or UID/GID or ACLs */
#endif
int zflag; /* -z: display the zipfile comment (only, for unzip) */
#endif /* !FUNZIP */
} UzpOpts;
/* intended to be a private struct: */
typedef struct _ver {
uch major; /* e.g., integer 5 */
uch minor; /* e.g., 2 */
uch patchlevel; /* e.g., 0 */
uch not_used;
} _version_type;
typedef struct _UzpVer {
ulg structlen; /* length of the struct being passed */
ulg flag; /* bit 0: is_beta bit 1: uses_zlib */
char *betalevel; /* e.g., "g BETA" or "" */
char *date; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
char *zlib_version; /* e.g., "0.95" or NULL */
_version_type unzip;
_version_type zipinfo;
_version_type os2dll;
_version_type windll;
} UzpVer;
/* for Visual BASIC access to Windows DLLs: */
typedef struct _UzpVer2 {
ulg structlen; /* length of the struct being passed */
ulg flag; /* bit 0: is_beta bit 1: uses_zlib */
char betalevel[10]; /* e.g., "g BETA" or "" */
char date[20]; /* e.g., "4 Sep 95" (beta) or "4 September 1995" */
char zlib_version[10]; /* e.g., "0.95" or NULL */
_version_type unzip;
_version_type zipinfo;
_version_type os2dll;
_version_type windll;
} UzpVer2;
typedef struct central_directory_file_header { /* CENTRAL */
uch version_made_by[2];
uch version_needed_to_extract[2];
ush general_purpose_bit_flag;
ush compression_method;
ulg last_mod_dos_datetime;
ulg crc32;
ulg csize;
ulg ucsize;
ush filename_length;
ush extra_field_length;
ush file_comment_length;
ush disk_number_start;
ush internal_file_attributes;
ulg external_file_attributes;
ulg relative_offset_local_header;
} cdir_file_hdr;
#define UZPINIT_LEN sizeof(UzpInit)
#define UZPVER_LEN sizeof(UzpVer)
#define cbList(func) int (* UZ_EXP func)(char *filename, cdir_file_hdr *crec)
/*---------------------------------------------------------------------------
Return (and exit) values of the public UnZip API functions.
---------------------------------------------------------------------------*/
/* external return codes */
#define PK_OK 0 /* no error */
#define PK_COOL 0 /* no error */
#define PK_GNARLY 0 /* no error */
#define PK_WARN 1 /* warning error */
#define PK_ERR 2 /* error in zipfile */
#define PK_BADERR 3 /* severe error in zipfile */
#define PK_MEM 4 /* insufficient memory (during initialization) */
#define PK_MEM2 5 /* insufficient memory (password failure) */
#define PK_MEM3 6 /* insufficient memory (file decompression) */
#define PK_MEM4 7 /* insufficient memory (memory decompression) */
#define PK_MEM5 8 /* insufficient memory (not yet used) */
#define PK_NOZIP 9 /* zipfile not found */
#define PK_PARAM 10 /* bad or illegal parameters specified */
#define PK_FIND 11 /* no files found */
#define PK_DISK 50 /* disk full */
#define PK_EOF 51 /* unexpected EOF */
#define IZ_CTRLC 80 /* user hit ^C to terminate */
#define IZ_UNSUP 81 /* no files found: all unsup. compr/encrypt. */
#define IZ_BADPWD 82 /* no files found: all had bad password */
/* internal and DLL-only return codes */
#define IZ_DIR 76 /* potential zipfile is a directory */
#define IZ_CREATED_DIR 77 /* directory created: set time and permissions */
#define IZ_VOL_LABEL 78 /* volume label, but can't set on hard disk */
#define IZ_EF_TRUNC 79 /* local extra field truncated (PKZIP'd) */
/* return codes of password fetches (negative = user abort; positive = error) */
#define IZ_PW_ENTERED 0 /* got some password string; use/try it */
#define IZ_PW_CANCEL -1 /* no password available (for this entry) */
#define IZ_PW_CANCELALL -2 /* no password, skip any further pwd. request */
#define IZ_PW_ERROR 5 /* = PK_MEM2 : failure (no mem, no tty, ...) */
/* flag values for status callback function */
#define UZ_ST_START_EXTRACT 1
#define UZ_ST_IN_PROGRESS 2
#define UZ_ST_FINISH_MEMBER 3
/* return values of status callback function */
#define UZ_ST_CONTINUE 0
#define UZ_ST_BREAK 1
/*---------------------------------------------------------------------------
Prototypes for public UnZip API (DLL) functions.
---------------------------------------------------------------------------*/
#define UzpMatch match
int UZ_EXP UzpMain OF((int argc, char **argv));
int UZ_EXP UzpAltMain OF((int argc, char **argv, UzpInit *init));
UzpVer * UZ_EXP UzpVersion OF((void));
void UZ_EXP UzpFreeMemBuffer OF((UzpBuffer *retstr));
#ifndef WINDLL
int UZ_EXP UzpUnzipToMemory OF((char *zip, char *file, UzpOpts *optflgs,
UzpCB *UsrFunc, UzpBuffer *retstr));
#endif
#ifndef WINDLL
int UZ_EXP UzpGrep OF((char *archive, char *file,
char *pattern, int cmd, int SkipBin,
UzpCB *UsrFunc));
#endif
#ifdef OS2
int UZ_EXP UzpFileTree OF((char *name, cbList(callBack),
char *cpInclude[], char *cpExclude[]));
#endif
void UZ_EXP UzpVersion2 OF((UzpVer2 *version));
int UZ_EXP UzpValidate OF((char *archive, int AllCodes));
/* default I/O functions (can be swapped out via UzpAltMain() entry point): */
int UZ_EXP UzpMessagePrnt OF((zvoid *pG, uch *buf, ulg size, int flag));
int UZ_EXP UzpMessageNull OF((zvoid *pG, uch *buf, ulg size, int flag));
int UZ_EXP UzpInput OF((zvoid *pG, uch *buf, int *size, int flag));
void UZ_EXP UzpMorePause OF((zvoid *pG, ZCONST char *prompt, int flag));
int UZ_EXP UzpPassword OF((zvoid *pG, int *rcnt, char *pwbuf,
int size, ZCONST char *zfn,
ZCONST char *efn));
/*---------------------------------------------------------------------------
Remaining private stuff for UnZip compilation.
---------------------------------------------------------------------------*/
#ifdef UNZIP_INTERNAL
# include "unzpriv.h"
#endif
int pipeit(char *format, ...);
int pipeit2(char *format, int flag, ...);
int confirm(char *format, ...);
#endif /* !__unzip_h */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
/*
version.h (for UnZip) by Info-ZIP.
This header file is not copyrighted and may be distributed without
restriction. (That's a little geek humor, heh heh.)
*/
#ifndef __version_h /* don't include more than once */
#define __version_h
#ifdef BETA
# undef BETA /* define BETA for internal beta releases */
#endif
#ifdef BETA
# define BETALEVEL "d BETA"
# define VERSION_DATE "27 November 98" /* internal beta version */
#else
# define BETALEVEL ""
# define VERSION_DATE "28 November 1998" /* official release version */
# define RELEASE
#endif
#define UZ_MAJORVER 5 /* UnZip */
#define UZ_MINORVER 4
#define ZI_MAJORVER 2 /* ZipInfo */
#define ZI_MINORVER 3
#define PATCHLEVEL 0
/* these are obsolete but remain for backward compatibility: */
#define D2_MAJORVER UZ_MAJORVER /* DLL for OS/2 */
#define D2_MINORVER UZ_MINORVER
#define D2_PATCHLEVEL PATCHLEVEL
#define DW_MAJORVER UZ_MAJORVER /* DLL for MS Windows */
#define DW_MINORVER UZ_MINORVER
#define DW_PATCHLEVEL PATCHLEVEL
#define WIN_VERSION_DATE VERSION_DATE
#endif /* !__version_h */

View File

@@ -0,0 +1,222 @@
/*---------------------------------------------------------------------------
Win32 specific configuration section:
---------------------------------------------------------------------------*/
#ifndef __w32cfg_h
#define __w32cfg_h
#if (defined(__CYGWIN__) && !defined(__CYGWIN32__))
# define __CYGWIN32__ /* new versions of CygWin may not define this */
#endif
#include <sys/types.h> /* off_t, time_t, dev_t, ... */
#include <sys/stat.h>
#include <io.h> /* read(), open(), etc. */
#include <time.h>
#if (defined(__RSXNT__) || defined(__EMX__)) && !defined(tzset)
# define tzset _tzset
#endif
#ifdef __MINGW32__
extern void _tzset(void); /* this is missing in <time.h> */
# ifndef tzset
# define tzset _tzset
# endif
#endif
#include <memory.h>
#if (!defined(__RSXNT__) && !defined(__CYGWIN32__))
# include <direct.h> /* mkdir() */
#endif
#include <fcntl.h>
#ifdef __CYGWIN32__
# include <unistd.h>
extern int setmode(int, int); /* this is missing in <fcntl.h> */
#endif
#if (defined(MSC) || defined(__WATCOMC__) || defined(__MINGW32__))
# include <sys/utime.h>
#else
# include <utime.h>
#endif
#if defined(FILEIO_C)
# ifndef __CYGWIN32__
# include <conio.h>
# endif
# include <windows.h>
# ifdef __RSXNT__
# include "win32/rsxntwin.h"
# endif
#endif
#if (defined(ENVARGS_C) || defined(EXTRACT_C) || defined(UNZIP_C) || \
defined(ZCRYPT_INTERNAL))
# include <windows.h>
# ifdef __RSXNT__
# include "win32/rsxntwin.h"
# endif
#endif
#if (defined(__CYGWIN32__) || defined(__MINGW32__))
/* the following definitions are missing in their <windows.h> */
# ifndef AnsiToOem
# define AnsiToOem CharToOemA
# endif
# ifndef OemToAnsi
# define OemToAnsi OemToCharA
# endif
#endif
#define DIR_END '\\' /* OS uses '\\' as directory separator */
#define DIR_END2 '/' /* also check for '/' (RTL may convert) */
#ifndef DATE_FORMAT
# define DATE_FORMAT DF_MDY
#endif
#define lenEOL 2
#define PutNativeEOL {*q++ = native(CR); *q++ = native(LF);}
#if (defined(__RSXNT__) && !defined(HAVE_MKTIME))
# define HAVE_MKTIME /* use mktime() in time conversion routines */
#endif
#if (defined(__CYGWIN32__) && defined(HAVE_MKTIME))
# undef HAVE_MKTIME /* Cygnus' mktime() implementation is buggy */
#endif
#if (!defined(NT_TZBUG_WORKAROUND) && !defined(NO_NT_TZBUG_WORKAROUND))
# define NT_TZBUG_WORKAROUND
#endif
#if (!defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME))
# define USE_EF_UT_TIME
#endif
#if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP))
# define TIMESTAMP
#endif
#if (!defined(NO_NTSD_EAS) && !defined(NTSD_EAS))
# define NTSD_EAS /* enable NTSD support unless explicitly suppressed */
#endif
/* handlers for OEM <--> ANSI string conversions */
#ifdef __RSXNT__
/* RSXNT uses OEM coded strings in functions supplied by C RTL */
# ifdef CRTL_CP_IS_ISO
# undef CRTL_CP_IS_ISO
# endif
# ifndef CRTL_CP_IS_OEM
# define CRTL_CP_IS_OEM
# endif
#else
/* "real" native WIN32 compilers use ANSI coded strings in C RTL calls */
# ifndef CRTL_CP_IS_ISO
# define CRTL_CP_IS_ISO
# endif
# ifdef CRTL_CP_IS_OEM
# undef CRTL_CP_IS_OEM
# endif
#endif
#ifdef CRTL_CP_IS_ISO
/* C RTL's file system support assumes ANSI coded strings */
# define ISO_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define OEM_TO_INTERN(src, dst) OemToAnsi(src, dst)
# define INTERN_TO_ISO(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define INTERN_TO_OEM(src, dst) AnsiToOem(src, dst)
#endif /* CRTL_CP_IS_ISO */
#ifdef CRTL_CP_IS_OEM
/* C RTL's file system support assumes OEM coded strings */
# define ISO_TO_INTERN(src, dst) AnsiToOem(src, dst)
# define OEM_TO_INTERN(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
# define INTERN_TO_ISO(src, dst) OemToAnsi(src, dst)
# define INTERN_TO_OEM(src, dst) {if ((src) != (dst)) strcpy((dst), (src));}
#endif /* CRTL_CP_IS_OEM */
#define _OEM_INTERN(str1) OEM_TO_INTERN(str1, str1)
#define _ISO_INTERN(str1) ISO_TO_INTERN(str1, str1)
#ifndef WINDLL
/* Despite best intentions, for the command-line version UzpPassword()
* could return either character set, depending on whether running under
* Win95 (DOS-session) or WinNT (native WinNT command interpreter)! */
# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
# define STR_TO_CP3(dst, src) (OemToAnsi(src, dst), dst)
#else
/* The WINDLL front end is known to supply ISO/ANSI-coded passwords! */
# define STR_TO_CP2(dst, src) (AnsiToOem(src, dst), dst)
#endif
/* dummy defines to disable these functions, they are not needed */
#define STR_TO_OEM
#define STR_TO_ISO
/* Static variables that we have to add to Uz_Globs: */
#define SYSTEM_SPECIFIC_GLOBALS \
int created_dir, renamed_fullpath, fnlen;\
unsigned nLabelDrive;\
char lastRootPath[4];\
int lastVolOldFAT, lastVolLocTim;\
char *rootpath, *buildpathHPFS, *buildpathFAT, *endHPFS, *endFAT;\
char *dirname, *wildname, matchname[FILNAMSIZ];\
int rootlen, have_dirname, dirnamelen, notfirstcall;\
zvoid *wild_dir;
/* created_dir, renamed_fullpath, fnlen, and nLabelDrive are used by */
/* both mapname() and checkdir(). */
/* lastRootPath and lastVolOldFAT are used by IsVolumeOldFAT(). */
/* rootlen, rootpath, buildpathHPFS, buildpathFAT, endHPFS, and endFAT */
/* are used by checkdir(). */
/* wild_dir, dirname, wildname, matchname[], dirnamelen, have_dirname, */
/* and notfirstcall are used by do_wild(). */
#if (defined(_MSC_VER) && !defined(MSC))
# define MSC
#endif
/* This replacement for C-RTL-supplied getch() (or similar) functionality
* avoids leaving unabsorbed LFs in the keyboard buffer under Windows95,
* and supports the <ALT>+[0]<digit><digit><digit> feature.
*/
int getch_win32 OF((void));
/* This patch of stat() is useful for at least two compilers. It is */
/* difficult to take a stat() of a root directory under Windows95, so */
/* zstat_win32() detects that case and fills in suitable values. */
#ifndef __RSXNT__
# ifndef W32_STATROOT_FIX
# define W32_STATROOT_FIX
# endif
#endif /* !__RSXNT__ */
#if (defined(NT_TZBUG_WORKAROUND) || defined(W32_STATROOT_FIX))
# define W32_STAT_BANDAID
# if (defined(NT_TZBUG_WORKAROUND) && defined(REENTRANT))
# define __W32STAT_GLOBALS__ Uz_Globs *pG,
# define __W32STAT_G__ pG,
# else
# define __W32STAT_GLOBALS__
# define __W32STAT_G__
# endif
# undef SSTAT
# ifdef WILD_STAT_BUG
# define SSTAT(path, pbuf) (iswild(path) || zstat_win32(__W32STAT_G__ path, pbuf))
# else
# define SSTAT(path, pbuf) zstat_win32(__W32STAT_G__ path, pbuf)
# endif
#endif
#ifdef __WATCOMC__
# ifdef __386__
# ifndef WATCOMC_386
# define WATCOMC_386
# endif
# define __32BIT__
# undef far
# define far
# undef near
# define near
/* Get asm routines to link properly without using "__cdecl": */
# ifndef USE_ZLIB
# pragma aux crc32 "_*" parm caller [] value [eax] modify [eax]
# pragma aux get_crc_table "_*" parm caller [] value [eax] \
modify [eax ecx edx]
# endif /* !USE_ZLIB */
# endif /* __386__ */
# ifndef EPIPE
# define EPIPE -1
# endif
# define PIPE_ERROR (errno == EPIPE)
#endif /* __WATCOMC__ */
#endif /* !__w32cfg_h */

View File

@@ -0,0 +1,15 @@
/* This is a dummy zip.h to allow the source files shared with Zip (crypt.c,
crc32.c, crctab.c, ttyio.c) to compile for UnZip. */
#ifndef __zip_h /* don't include more than once */
#define __zip_h
#define UNZIP_INTERNAL
#include "unzip.h"
#define local static
#define ZE_MEM PK_MEM
#define ziperr(c, h) return
#endif /* !__zip_h */

1081
utils/Install/install.c Normal file

File diff suppressed because it is too large Load Diff

116
utils/Install/install.h Normal file
View File

@@ -0,0 +1,116 @@
#ifdef __cplusplus
extern "C" {
#endif
#define I_DialogBeta 329
#define I_Dialog1 330
#define I_Dialog2 331
#define I_Dialog3 332
#define I_Dialog4 333
#define I_Dialog5 334
#define I_Dialog6 335
#define I_Dialog7 336
#define I_Dialog8 337
#define I_Dialog9 338
#define I_Dialog10 339
#define I_Dialog11 340
#define I_Dialog12 341
#define I_Cancel 258
#define I_Icon 261
#define I_Logo 262
#define I_Ja 265
#define I_Nein 266
#define I_Halt 267
#define I_Alle 268
#define I_Karte 269
#define I_Confirm 270
#define I_BMPWin 271
#define I_Dest 300
#define I_Text 301
#define I_OK 304
#define I_Cancel2 305
#define I_Logo16 306
#define NONE 0
#define INSTALLING 1
#define ABORTED 2
#define COMPLETED 3
#define UPDATE_ALWAYS 1
#define UPDATE_NONEXIST 2
#define DLG_PACKAGESTOINSTALL 305
#define PACKAGES 306
#define PB_SELECTALL 308
#define PB_DESELECTALL 309
#define DLG_SELECTINSTALLATIONDRIVE 311
#define PB_OK 313
#define PB_CANCEL 314
#define DRIVELIST 312
#define I_LOGO1 316
#define I_LOGO2 317
#define I_LOGO3 318
#define I_LOGO4 319
#define I_LOGO5 320
#define I_LOGO6 321
#define I_LOGO7 322
#define I_LOGO8 323
#define I_LOGOBETA 324
/* These are static */
#define I_Status 348
#define I_Welcome 349
/* Keep these in order... so we can loop */
#define I_INFOBOX 355
#define I_Info1 356
#define I_Info2 357
#define I_Info3 358
#define I_README 359
#define I_Licence 360
#define I_Agree 361
#define I_Updates1 362
#define I_Updates2 363
#define I_Updates4 364
#define I_Updates3 365
#define I_Dirs 366
#define I_InstallDir 367
#define I_Drives 368
#define I_Percent 369
#define I_Back 370
#define I_Next 371
#define I_Progress 372
#define I_Grid 373
#define I_MAX 374
#define FILEICON 3800
#define FOLDERICON 3810
#define THREAD_STACK_SIZE 32768
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* #define ENABLE_LOGGING */
void grabfile(char *filename);
void readme(void *param);
void install_thread(void *param);
void install_init(char *installername);
int getparseline(FILE *f, char comment, char delimiter, char quotes, char *raw, char *entry, char *entrydata, char *entrydata2);
#ifdef __cplusplus
}
#endif

717
utils/Install/instsup.cpp Normal file
View File

@@ -0,0 +1,717 @@
/*
* instsup.c (c) 1999,2000 Brian Smith
*/
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#if defined(__OS2__) || defined(__EMX__) || defined(WIN32) || defined(WINNT)
#include <process.h>
#endif
#include <sys/types.h>
#ifdef WIN32
#include <shlobj.h>
#endif
#include "install.h"
#include "instsup.h"
extern char *INSTALLER_TITLE;
extern char *INSTALLER_PROGRAM;
extern char *INSTALLER_FOLDER;
extern char *INSTALLER_SHADOW;
extern char *INSTALLER_OBJECT;
extern char tempPath[], installdir[], csfile[], bufile[], bootdrive[], instlog[], installdir2[];
extern int installstate, success;
extern FILE *self;
#ifdef __cplusplus
extern "C" {
#endif
char *replaceem(char *orig);
int sendmessage(int destination, int messid)
{
#if 0
/* Update percentage bar */
if(messid == 1)
{
wxMutexGuiEnter();
updatepercent();
wxMutexGuiLeave();
}
if(messid == 2)
{
extern wxCondition *InstCond;
InstCond->Broadcast();
}
#endif
return 0;
}
void DoGUI(void)
{
updatepercent();
wxYield();
}
/* This should return the current color depth */
unsigned long color_depth(void)
{
#if __OS2__
HDC hdc = WinOpenWindowDC(HWND_DESKTOP);
LONG colors;
DevQueryCaps(hdc, CAPS_COLORS, 1, &colors);
DevCloseDC(hdc);
return colors;
#endif
return 0;
}
/*
* Call the reboot vector.
*/
void sysreboot(void)
{
#if __OS2__
#define SYSFUNC 0xD5
#define REBOOT 0xAB
#define REBOOTDEV "\\DEV\\DOS$"
APIRET rc;
HFILE hREBOOT;
ULONG ulAction;
rc = DosOpen(REBOOTDEV,
&hREBOOT,
&ulAction,
0L,
FILE_NORMAL,
FILE_OPEN,
OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
0L);
if (rc == 0)
{
DosDevIOCtl(hREBOOT,
SYSFUNC,
REBOOT,
NULL,
0L,
NULL,
NULL,
0L,
NULL);
DosClose(hREBOOT);
}
#endif
}
/*
* Display an informational dialog box to the user with the given text.
*/
int mesg(char *format, ...) {
va_list args;
char outbuf[4096];
va_start(args, format);
vsprintf(outbuf, format, args);
va_end(args);
wxMessageBox(outbuf, INSTALLER_TITLE,
wxOK | wxICON_EXCLAMATION, NULL);
return strlen(outbuf);
}
int checktext(char *text, char *buffer, int buflen)
{
int z, len = strlen(text);
for(z=0;z<(buflen-len);z++)
{
if(memcmp(text, &buffer[z], len) == 0)
return z;
}
return -1;
}
/*
* Returns the offset withing the executable to the specified text.
*/
long findtext(char *text)
{
char buffer[512];
int offset;
unsigned long curpos = 0;
fseek(self, 0, SEEK_SET);
fread(buffer, 1, 512, self);
if((offset = checktext(text, buffer, 512)) > -1)
return offset;
while(!feof(self))
{
memcpy(buffer, &buffer[256], 256);
fread(&buffer[256], 1, 256, self);
curpos += 256;
if((offset = checktext(text, buffer, 512)) > -1)
return offset+curpos;
}
return -1;
}
/* We encode archive search text so we don't get confused
* by the string table - I was using LXLite to take care
* of this problem on OS/2 but in portable code this may
* not be an option. */
char *decode(char *input)
{
char *result;
int i = 0;
result = (char *)malloc(strlen(input) / 2 + 1);
while (input[0] && input[1])
{
result[i] = ((input[0] - 0x41) << 4) | (input[1] - 0x41);
input += 2;
i++;
}
result[i] = '\0';
return result;
}
/*
* Removes any carriage returns or line feeds from the buffer.
*/
void stripcrlf(char *buffer)
{
int z, len = strlen(buffer);
for(z=0;z<len;z++)
{
if(buffer[z] == '\r' || buffer[z] == '\n')
{
buffer[z] = 0;
return;
}
}
}
/*
* Returns the space free on a given drive... where 0 is A: in MB
*/
unsigned long drivefree(int drive)
{
#if __OS2__
ULONG aulFSInfoBuf[40] = {0};
APIRET rc = NO_ERROR;
double bytesFree;
DosError(FERR_DISABLEHARDERR);
rc = DosQueryFSInfo(drive,
FSIL_ALLOC,
(PVOID)aulFSInfoBuf,
sizeof(aulFSInfoBuf));
DosError(FERR_ENABLEHARDERR);
if (rc != NO_ERROR)
return 0;
bytesFree = (double)aulFSInfoBuf[3] * (double)aulFSInfoBuf[1] * (USHORT)aulFSInfoBuf[4];
return (unsigned long)(bytesFree / (1024.0 * 1024.0));
#endif
return 0;
}
/*
* Display a fatal error message and set the abort flag in case we are in a secondary thread.
*/
void error(char *format, ...) {
va_list args;
char errstring[1024];
va_start(args, format);
vsprintf(errstring, format, args);
va_end(args);
if(installstate != ABORTED)
{
success=1;
installstate=ABORTED;
}
wxMessageBox(errstring, INSTALLER_TITLE,
wxOK | wxICON_EXCLAMATION, NULL);
}
void setdrivedir(char *drivedir)
{
wxSetWorkingDirectory(drivedir);
}
/*
* Make the TEMP directory the current directory, or the root directory of the boot drive.
*/
void settempdir(void)
{
#if defined(__EMX__) || defined(__OS2__) || defined(WIN32) || defined(WINNT)
/* Windows or OS/2 */
char *envdir = getenv("TMP");
int len;
if (!envdir)
envdir = getenv("TEMP");
if (!envdir)
envdir = replaceem("%BOOTDRIVE%:\\");
strcpy(tempPath,envdir);
len = strlen(tempPath);
if (len > 3 && tempPath[len-1] == '\\')
tempPath[len-1] = 0;
strupr(tempPath);
setdrivedir(tempPath);
#else
/* Unix */
setdrivedir("/tmp");
#endif
}
void getbootdrive(void)
{
/* On windows I don't think you can boot from anything
except C: drive. So I am not going to do anything here. */
}
void PM_backslash(char *s)
{
unsigned int pos = strlen(s);
if (s[pos-1] != '\\') {
s[pos] = '\\';
s[pos+1] = '\0';
}
}
/*
* Makes a folder on the desktop.
*/
void MakeFolder(char Title[], char Icon[], char dest[], char id[], char setup[])
{
#ifdef __OS2__
char szArg[200];
memset(szArg,0,sizeof(szArg));
if ((Icon != NULL) && (strlen(Icon) != 0))
{
strcat(szArg,"ICONFILE=");
strcat(szArg,Icon);
}
if ((id != NULL) && (strlen(id) != 0))
{
strcat(szArg,";OBJECTID=");
strcat(szArg,id);
}
if ((setup != NULL) && (strlen(setup) != 0))
{
strcat(szArg,";");
strcat(szArg,setup);
}
WinCreateObject("WPFolder",Title,szArg,dest,CO_REPLACEIFEXISTS);
#elif defined(WIN32)
char startpath[MAX_PATH];
LPITEMIDLIST pidl;
if(!SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidl))
{
SHGetPathFromIDList(pidl, startpath);
if(startpath[strlen(startpath)-1] != '\\')
strcat(startpath, "\\");
strcat(startpath, Title);
CreateDirectory(startpath, NULL);
}
#else
/* Unix? */
#endif
}
#ifdef WIN32
HRESULT CreateLink(LPCSTR lpszPathObj,
LPSTR lpszPathLink, LPSTR lpszDesc)
{
HRESULT hres;
IShellLink* psl;
// Get a pointer to the IShellLink interface.
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
if (SUCCEEDED(hres)) {
IPersistFile* ppf;
// Set the path to the shortcut target, and add the
// description.
psl->SetPath(lpszPathObj);
psl->SetDescription(lpszDesc);
// Query IShellLink for the IPersistFile interface for saving the
// shortcut in persistent storage.
hres = psl->QueryInterface(IID_IPersistFile,
(void **)&ppf);
if (SUCCEEDED(hres)) {
WCHAR wsz[MAX_PATH];
// Ensure that the string is ANSI.
MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1,
wsz, MAX_PATH);
// Save the link by calling IPersistFile::Save.
hres = ppf->Save(wsz, TRUE);
ppf->Release();
}
psl->Release();
}
return hres;
}
#endif
/*
* Makes a Program object on the desktop.
*/
void MakeProgram(char Title[], char Program[], char Icon[], char dest[], char id[], char setup[])
{
#ifdef __OS2__
char szArg[200];
memset(szArg,0,sizeof(szArg));
strcat(szArg,"EXENAME=");
strcat(szArg,Program);
if ((Icon != NULL) && (strlen(Icon) != 0))
{
strcat(szArg,";ICONFILE=");
strcat(szArg,Icon);
}
if ((id != NULL) && (strlen(id) != 0))
{
strcat(szArg,";OBJECTID=");
strcat(szArg,id);
}
if ((setup != NULL) && (strlen(setup) != 0))
{
strcat(szArg,";");
strcat(szArg,setup);
}
WinCreateObject("WPProgram",Title,szArg,dest,CO_REPLACEIFEXISTS);
#elif defined(WIN32)
char startpath[MAX_PATH];
LPITEMIDLIST pidl;
if(!SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidl))
{
SHGetPathFromIDList(pidl, startpath);
if(startpath[strlen(startpath)-1] != '\\')
strcat(startpath, "\\");
strcat(startpath, dest);
strcat(startpath, "\\");
strcat(startpath, Title);
strcat(startpath, ".lnk");
CoInitialize(NULL);
CreateLink(Program, startpath, Title);
CoUninitialize();
}
#else
/* Unix? */
#endif
}
/*
* Makes a user defined object on the desktop.
*/
void MakeObject(char Title[], char oclass[], char dest[], char id[], char setup[])
{
#ifdef __OS2__
char szArg[200];
memset(szArg,0,sizeof(szArg));
if ((oclass == NULL) || (strlen(oclass) == 0))
return;
if ((id != NULL) && (strlen(id) != 0))
{
strcat(szArg,"OBJECTID=");
strcat(szArg,id);
}
if ((setup != NULL) && (strlen(setup) != 0))
{
if ((id != NULL) && (strlen(id) != 0))
strcat(szArg,";");
strcat(szArg,setup);
}
WinCreateObject(oclass,Title,szArg,dest,CO_REPLACEIFEXISTS);
#elif defined(WIN32)
/* Not sure if there is an equivilent on Windows */
#else
/* Unix? */
#endif
}
/*
* Makes a shadow on the desktop.
*/
void MakeShadow(char Title[], char reference[], char dest[], char id[])
{
#ifdef __OS2__
char szArg[400];
memset(szArg,0,sizeof(szArg));
strcpy(szArg,"SHADOWID=");
strcat(szArg,reference);
if ((id != NULL) && (strlen(id) != 0))
{
strcat(szArg,";OBJECTID=");
strcat(szArg,id);
}
strcat(szArg,";");
WinCreateObject("WPShadow",Title,szArg,dest,CO_REPLACEIFEXISTS);
#elif defined(WIN32)
/* Nothing like this on Windows9x anyway */
#else
/* Unix? */
#endif
}
/* This creates program objects on the desktop, it was originally designed
* for the OS/2 Workplace Shell so it may be somewhat different in use on
* other platforms.
*/
void create_wps_objects(void)
{
char *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
char temp[5000];
char zerotext[2] = "";
int z, argn, len;
/* No distinction for the moment... this may change.. */
strcpy(installdir2, installdir);
/* Create Folder Objects */
if(strlen(INSTALLER_FOLDER)>0)
{
strcpy(temp, replaceem(INSTALLER_FOLDER));
argn=0;
arg1=&temp[0];
arg2=arg3=arg4=arg5=&zerotext[0];
len = strlen(temp);
for(z=0;z<len;z++)
{
if(temp[z]==',')
{
argn++;
temp[z]=0;
switch(argn)
{
case 1:
arg2=&temp[z+1];
break;
case 2:
arg3=&temp[z+1];
break;
case 3:
arg4=&temp[z+1];
break;
case 4:
arg5=&temp[z+1];
break;
case 5:
argn=0;
MakeFolder(arg1, arg2, arg3, arg4, arg5);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSFolderAdd>,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5);
#endif
arg1=&temp[z+1];
arg2=arg3=arg4=arg5=&zerotext[0];
break;
}
}
}
MakeFolder(arg1, arg2, arg3, arg4, arg5);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSFolderAdd>,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5);
#endif
}
/* Create Program Objects */
if(strlen(INSTALLER_PROGRAM)>0)
{
strcpy(temp, replaceem(INSTALLER_PROGRAM));
argn=0;
arg1=&temp[0];
arg2=arg3=arg4=arg5=arg6=&zerotext[0];
len = strlen(temp);
for(z=0;z<len;z++)
{
if(temp[z]==',')
{
argn++;
temp[z]=0;
switch(argn)
{
case 1:
arg2=&temp[z+1];
break;
case 2:
arg3=&temp[z+1];
break;
case 3:
arg4=&temp[z+1];
break;
case 4:
arg5=&temp[z+1];
break;
case 5:
arg6=&temp[z+1];
break;
case 6:
argn=0;
MakeProgram(arg1, arg2, arg3, arg4, arg5, arg6);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSProgramAdd>,%s,%s,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4,arg5,arg6);
#endif
arg1=&temp[z+1];
arg2=arg3=arg4=arg5=arg6=&zerotext[0];
break;
}
}
}
MakeProgram(arg1, arg2, arg3, arg4, arg5, arg6);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSProgramAdd>,%s,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5,arg6);
#endif
}
/* Create Shadow Objects */
if(strlen(INSTALLER_SHADOW)>0)
{
strcpy(temp, replaceem(INSTALLER_SHADOW));
argn=0;
arg1=&temp[0];
arg2=arg3=arg4=&zerotext[0];
len = strlen(temp);
for(z=0;z<len;z++)
{
if(temp[z]==',')
{
argn++;
temp[z]=0;
switch(argn)
{
case 1:
arg2=&temp[z+1];
break;
case 2:
arg3=&temp[z+1];
break;
case 3:
arg4=&temp[z+1];
break;
case 4:
argn=0;
MakeShadow(arg1, arg2, arg3, arg4);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSShadowAdd>,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4);
#endif
arg1=&temp[z+1];
arg2=arg3=arg4=&zerotext[0];
break;
}
}
}
MakeShadow(arg1, arg2, arg3, arg4);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSShadowAdd>,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4);
#endif
}
/* Create Generic Objects */
if(strlen(INSTALLER_OBJECT)>0)
{
strcpy(temp, replaceem(INSTALLER_OBJECT));
argn=0;
arg1=&temp[0];
arg2=arg3=arg4=arg5=&zerotext[0];
len = strlen(temp);
for(z=0;z<len;z++)
{
if(temp[z]==',')
{
argn++;
temp[z]=0;
switch(argn)
{
case 1:
arg2=&temp[z+1];
break;
case 2:
arg3=&temp[z+1];
break;
case 3:
arg4=&temp[z+1];
break;
case 4:
arg5=&temp[z+1];
break;
case 5:
argn=0;
MakeObject(arg1, arg2, arg3, arg4, arg5);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSObjectAdd>,%s,%s,%s,%s,%s\r\n", arg1,arg2,arg3,arg4,arg5);
#endif
arg1=&temp[z+1];
arg2=arg3=arg4=arg5=&zerotext[0];
break;
}
}
}
MakeObject(arg1, arg2, arg3, arg4, arg5);
#ifdef ENABLE_LOGGING
fprintf(logfile, "<WPSObjectAdd>,%s,%s,%s,%s,%s\r\n", arg1, arg2,arg3,arg4,arg5);
#endif
}
}
#ifdef __cplusplus
}
#endif

26
utils/Install/instsup.h Normal file
View File

@@ -0,0 +1,26 @@
#ifdef __cplusplus
extern "C" {
#endif
void create_wps_objects(void);
unsigned long color_depth(void);
void sysreboot(void);
int mesg(char *format, ...);
int checktext(char *text, char *buffer, int buflen);
long findtext(char *text);
char *decode(char *input);
void viewfile(char *filename);
void stripcrlf(char *buffer);
unsigned long drivefree(int drive);
void error(char *format, ...);
void setdrivedir(char *drivedir);
void settempdir(void);
void getbootdrive(void);
int cmdrun(char *progname);
void PM_backslash(char *s);
int sendmessage(int destination, int messid);
void DoGUI(void);
#ifdef __cplusplus
}
#endif
int parse_ini(char *filename);
void updatepercent(void);

View File

@@ -0,0 +1,134 @@
/* ------------------------------------------------------------------------ */
/* */
/* Global variable declarations */
/* */
/* ------------------------------------------------------------------------ */
#include "os.h"
#include "acestruc.h"
#include "unace.h"
#include <string.h>
#include <stdio.h>
//-------- Ace sign
const char *acesign = "**ACE**";
//-------- Version string for program
const char *version="UNACE v1.1 public version\n";
#ifdef AMIGA
//-------- Version string for VERSION program
static char *_version="$VER: Unace Amiga 1.1 "__AMIGADATE__"\n\n";
#endif
//-------- header buffer and pointers
thead head;
tmhead *t_mhead = (tmhead *) & head;
tfhead *t_fhead = (tfhead *) & head;
//-------- buffers
ULONG *buf_rd =0;
CHAR *buf =0;
CHAR *buf_wr =0;
UCHAR *readbuf =0;
//-------- decompressor variables
SHORT rpos =0,
dcpr_do =0,
dcpr_do_max =0,
blocksize =0,
dcpr_dic =0,
dcpr_oldnum =0,
bits_rd =0,
dcpr_frst_file =0;
USHORT dcpr_code_mn[1 << maxwd_mn],
dcpr_code_lg[1 << maxwd_lg];
UCHAR dcpr_wd_mn[maxcode + 2],
dcpr_wd_lg[maxcode + 2],
wd_svwd[svwd_cnt];
ULONG dcpr_dpos =0,
cpr_dpos2 =0,
dcpr_dicsiz =0,
dcpr_dican =0,
dcpr_size =0,
dcpr_olddist[4]={0,0,0,0},
code_rd =0;
CHAR *dcpr_text =0;
//-------- quicksort
USHORT sort_org[maxcode + 2];
UCHAR sort_freq[(maxcode + 2) * 2];
//-------- file handling
CHAR aname[PATH_MAX];
INT archan,
wrhan;
#if !defined(__EMX__) && !defined(__OS2__)
FILE *farchan = NULL;
#endif
LONG skipsize=0;
//-------- structures for archive handling
struct tadat adat;
//-------- flags
INT f_err =0,
f_ovrall =0,
f_allvol_pr=0,
f_curpas =0,
f_criterr =0;
void resetglobals(void)
{
t_mhead = (tmhead *) & head;
t_fhead = (tfhead *) & head;
buf_rd =0;
buf =0;
buf_wr =0;
readbuf =0;
rpos =0;
dcpr_do =0;
dcpr_do_max =0;
blocksize =0;
dcpr_dic =0;
dcpr_oldnum =0;
bits_rd =0;
dcpr_frst_file =0;
memset(&dcpr_code_mn, 0, sizeof(dcpr_code_mn));
memset(&dcpr_code_lg, 0, sizeof(dcpr_code_lg));
memset(&dcpr_wd_mn, 0, sizeof(dcpr_wd_mn));
memset(&dcpr_wd_lg, 0, sizeof(dcpr_wd_lg));
memset(&wd_svwd, 0, sizeof(wd_svwd));
dcpr_dpos =0;
cpr_dpos2 =0;
dcpr_dicsiz =0;
dcpr_dican =0;
dcpr_size =0;
memset(&dcpr_olddist, 0, sizeof(dcpr_olddist));
code_rd =0;
dcpr_text =0;
memset(&sort_org, 0, sizeof(sort_org));
memset(&sort_freq, 0, sizeof(sort_freq));
archan=0;
wrhan=0;
skipsize=0;
f_err =0;
f_ovrall =0;
f_allvol_pr=0;
f_curpas =0;
f_criterr =0;
}

View File

@@ -0,0 +1,46 @@
# Installer Makefile
CC = gcc
RM = rm -f
RC = rc
MAKE = make
DEFS =
LIBS =
CFLAGS = -O -g -I../incace -Wall
LDFLAGS =
OBJECTS = globals.o packinst.o uac_comm.o uac_crc.o \
uac_crt.o uac_dcpr.o uac_sys.o unace.o
SOURCES = globals.c ../packinst/packinst.c uac_comm.c \
uac_crc.c uac_crt.c uac_dcpr.c uac_sys.c unace.c
all: packinst
$(OBJECTS):
$(CC) $(CFLAGS) -c $<
Include: ../incace/Makefile Makefile
# cd include
# $(MAKE) -f Makefile all
packinst: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -o packinst $(OBJECTS)
clean:
$(RM) $(OBJECTS) packinst *~
globals.o: globals.c ../incace/globals.h ../incace/acestruc.h ../incace/unace.h
packinst.o: ../packinst/packinst.c
uac_comm.o: uac_comm.c ../incace/globals.h ../incace/uac_dcpr.h ../incace/uac_comm.h
uac_crc.o: uac_crc.c ../incace/uac_crc.h
uac_crt.o: uac_crt.c ../incace/os.h ../incace/attribs.h ../incace/globals.h ../incace/uac_crt.h ../incace/uac_sys.h
uac_dcpr.o: uac_dcpr.c ../incace/os.h ../incace/globals.h ../incace/portable.h ../incace/uac_comm.h ../incace/uac_crc.h \
../incace/uac_dcpr.h ../incace/uac_sys.h
uac_sys.o: uac_sys.c ../incace/os.h ../incace/globals.h ../incace/uac_sys.h
unace.o: unace.c ../incace/os.h ../incace/globals.h ../incace/portable.h ../incace/uac_comm.h ../incace/uac_crc.h ../incace/uac_crt.h \
../incace/uac_dcpr.h ../incace/uac_sys.h

View File

@@ -0,0 +1,41 @@
# Common settings for Borland 32-bit compilation (makefile.b32 files)
LINK=ilink32
OPT = -O2
LDFLAGS = -lxncd -l-P
CPPFLAGS = /I"..\incace" /DWIN32
LINKFLAGS=/aa -L$(BCCDIR)\lib\psdk
DUMMY=dummy
SRCSUFF = cpp
OBJSUFF = obj
TARGET = packinst
OBJECTS = globals.obj uac_comm.obj uac_crc.obj uac_crt.obj uac_dcpr.obj uac_sys.obj unace.obj packinst.obj
all: $(TARGET).exe
packinst.exe: $(OBJECTS)
bcc32 $(LDFLAGS) -epackinst.exe @&&|
$(OBJECTS)
|
.$(SRCSUFF).obj:
bcc32 $(CPPFLAGS) -c {$< }
packinst.obj: ..\packinst\packinst.c
bcc32 $(CPPFLAGS) -P- -c ..\packinst\packinst.c
.c.obj:
bcc32 $(CPPFLAGS) -P- -c {$< }
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.rws
-erase *.tds
-erase *.il?

View File

@@ -0,0 +1,46 @@
# Installer Makefile
CC = gcc
RM = rm -f
RC = rc
MAKE = make
DEFS =
LIBS =
CFLAGS = -mno-cygwin -O -g -I../incace -Wall -DWIN32
LDFLAGS = -mno-cygwin
OBJECTS = globals.o packinst.o uac_comm.o uac_crc.o \
uac_crt.o uac_dcpr.o uac_sys.o unace.o
SOURCES = globals.c ../packinst/packinst.c uac_comm.c \
uac_crc.c uac_crt.c uac_dcpr.c uac_sys.c unace.c
all: packinst
$(OBJECTS):
$(CC) $(CFLAGS) -c $<
Include: ../incace/Makefile Makefile
# cd include
# $(MAKE) -f Makefile all
packinst: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -o packinst $(OBJECTS)
clean:
$(RM) $(OBJECTS) packinst *~
globals.o: globals.c ../incace/globals.h ../incace/acestruc.h ../incace/unace.h
packinst.o: ../packinst/packinst.c
uac_comm.o: uac_comm.c ../incace/globals.h ../incace/uac_dcpr.h ../incace/uac_comm.h
uac_crc.o: uac_crc.c ../incace/uac_crc.h
uac_crt.o: uac_crt.c ../incace/os.h ../incace/attribs.h ../incace/globals.h ../incace/uac_crt.h ../incace/uac_sys.h
uac_dcpr.o: uac_dcpr.c ../incace/os.h ../incace/globals.h ../incace/portable.h ../incace/uac_comm.h ../incace/uac_crc.h \
../incace/uac_dcpr.h ../incace/uac_sys.h
uac_sys.o: uac_sys.c ../incace/os.h ../incace/globals.h ../incace/uac_sys.h
unace.o: unace.c ../incace/os.h ../incace/globals.h ../incace/portable.h ../incace/uac_comm.h ../incace/uac_crc.h ../incace/uac_crt.h \
../incace/uac_dcpr.h ../incace/uac_sys.h

View File

@@ -0,0 +1,46 @@
# Installer Makefile
CC = gcc
RM = rm -f
RC = rc
MAKE = make
DEFS =
LIBS =
CFLAGS = -O -g -I../incace -Wall
LDFLAGS =
OBJECTS = globals.o packinst.o uac_comm.o uac_crc.o \
uac_crt.o uac_dcpr.o uac_sys.o unace.o
SOURCES = globals.c ../packinst/packinst.c uac_comm.c \
uac_crc.c uac_crt.c uac_dcpr.c uac_sys.c unace.c
all: packinst
$(OBJECTS):
$(CC) $(CFLAGS) -c $<
Include: ../incace/Makefile Makefile
# cd include
# $(MAKE) -f Makefile all
packinst: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -o packinst $(OBJECTS)
clean:
$(RM) $(OBJECTS) packinst *~
globals.o: globals.c ../incace/globals.h ../incace/acestruc.h ../incace/unace.h
packinst.o: ../packinst/packinst.c
uac_comm.o: uac_comm.c ../incace/globals.h ../incace/uac_dcpr.h ../incace/uac_comm.h
uac_crc.o: uac_crc.c ../incace/uac_crc.h
uac_crt.o: uac_crt.c ../incace/os.h ../incace/attribs.h ../incace/globals.h ../incace/uac_crt.h ../incace/uac_sys.h
uac_dcpr.o: uac_dcpr.c ../incace/os.h ../incace/globals.h ../incace/portable.h ../incace/uac_comm.h ../incace/uac_crc.h \
../incace/uac_dcpr.h ../incace/uac_sys.h
uac_sys.o: uac_sys.c ../incace/os.h ../incace/globals.h ../incace/uac_sys.h
unace.o: unace.c ../incace/os.h ../incace/globals.h ../incace/portable.h ../incace/uac_comm.h ../incace/uac_crc.h ../incace/uac_crt.h \
../incace/uac_dcpr.h ../incace/uac_sys.h

View File

@@ -0,0 +1,51 @@
/* ------------------------------------------------------------------------ */
/* */
/* Decompresses and outputs comment if present. */
/* */
/* ------------------------------------------------------------------------ */
#include <stdio.h> // printf()
#include "globals.h"
#include "uac_dcpr.h"
#include "uac_comm.h"
INT comm_cpr_size=0;
CHAR *comm;
void comment_out(CHAR *top) // outputs comment if present
{
INT i;
if (head.HEAD_FLAGS & ACE_COMM)
{ // comment present?
if (head.HEAD_TYPE == MAIN_BLK)
{ // get begin and size of comment data
comm = (CHAR *)MCOMM;
comm_cpr_size = MCOMM_SIZE;
}
else
{
comm = (CHAR *)FCOMM;
comm_cpr_size = FCOMM_SIZE;
} // limit comment size if too big
i = sizeof(head) - (INT)(comm - (CHAR*) &head);
if (comm_cpr_size > i)
comm_cpr_size = i;
dcpr_comm(i); // decompress comment
#ifdef AMIGA
{
char *p=comm;
while (*p)
{
if (*p==0x0D)
*p=0x0A; // Replace ms-dos line termination
p++;
}
}
#endif
pipeit("%s\n\n%s\n\n", top, comm); // output comment
}
}

View File

@@ -0,0 +1,36 @@
/* ------------------------------------------------------------------------ */
/* */
/* CRC-calculation routines. */
/* */
/* ------------------------------------------------------------------------ */
#include "uac_crc.h"
ULONG crctable[256];
ULONG rd_crc=0;
void make_crctable(void) // initializes CRC table
{
ULONG r,
i,
j;
for (i = 0; i <= 255; i++)
{
for (r = i, j = 8; j; j--)
r = (r & 1) ? (r >> 1) ^ CRCPOLY : (r >> 1);
crctable[i] = r;
}
}
// Updates crc from addr till addr+len-1
//
ULONG getcrc(ULONG crc, UCHAR * addr, INT len)
{
while (len--)
crc = crctable[(unsigned char) crc ^ (*addr++)] ^ (crc >> 8);
return (crc);
}

View File

@@ -0,0 +1,149 @@
/* ------------------------------------------------------------------------ */
/* */
/* Creates/Replaces files or directories. */
/* */
/* ------------------------------------------------------------------------ */
#include "os.h"
#include <stdlib.h>
#include <fcntl.h> // AMIGA: open()
#include <stdio.h> // pipeit() remove()
#include <string.h> // strncpy()
#include <sys/types.h>
#include <sys/stat.h> // struct stat
#include <string.h>
#if defined(DOS) || defined(WINNT) || defined(WIN16)
#include <io.h> // access()
#endif
#if defined(__IBMC__)
#include <direct.h>
#endif
#define DIRSEP '\\'
#include "attribs.h"
#include "globals.h"
#include "uac_crt.h"
#include "uac_sys.h"
/* gets file name from header
*/
CHAR *ace_fname(CHAR * s, thead * head, INT nopath)
{
INT i;
char *cp;
strncpy(s, (CHAR *)(*(tfhead *) head).FNAME, i = (*(tfhead *) head).FNAME_SIZE);
s[i] = 0;
if (nopath)
{
cp=strrchr(s, '\\');
if (cp)
memmove(s, cp+1, strlen(cp));
}
return s;
}
void check_ext_dir(CHAR * f) // checks/creates path of file
{
CHAR *cp,
d[PATH_MAX];
INT i;
d[0] = 0;
for (;;)
{
if ((cp = (CHAR *) strchr(&f[strlen(d) + 1], DIRSEP))!=NULL)
{
i = cp - f;
strncpy(d, f, i);
d[i] = 0;
}
else
return;
if (!fileexists(d))
#if (defined(__OS2__) && !defined(__EMX__)) || (defined(WINNT) && !defined(__CYGWIN__))
if (mkdir(d))
#else
if (mkdir(d, 0))
#endif
{
f_err = ERR_WRITE;
pipeit("\n Error while creating directory.\n");
}
}
}
INT ovr_delete(CHAR * n) // deletes directory or file
{
if (remove(n) && rmdir(n))
{
pipeit("\n Could not delete file or directory. Access denied.\n");
return (1);
}
return (0);
}
INT create_dest_file(CHAR * file, INT a) // creates file or directory
{
INT han,
i = 0,
ex = fileexists(file);
struct stat st;
check_ext_dir(file);
if (f_err)
return (-1);
if (a & _A_SUBDIR)
{ // create dir or file?
if (ex)
stat(file, &st);
#if (defined(__OS2__) && !defined(__EMX__)) || (!defined(__CYGWIN__) && defined(WINNT))
if ((!ex && mkdir(file)) || (ex && (st.st_mode & S_IFDIR)))
#else
if ((!ex && mkdir(file, 0)) || (ex && (st.st_mode & S_IFDIR)))
#endif
{
pipeit("\n Could not create directory.\n");
return (-1);
}
#ifdef DOS
_dos_setfileattr(file, a); // set directory attributes
#endif
return (-1);
}
else
{
if (ex)
{ // does the file already exist
if (!f_ovrall)
{
i = wrask("Overwrite existing file?"); // prompt for overwrite
f_ovrall = (i == 1);
if (i == 3)
f_err = ERR_USER;
}
if ((i && !f_ovrall) || ovr_delete(file))
return (-1); // delete?
}
#if defined(__OS2_) || defined(__EMX__) || defined(WIN32)
if ((han = open(file, O_WRONLY | O_TRUNC | O_CREAT | O_BINARY,
S_IREAD | S_IWRITE | S_IEXEC | S_IDELETE |
S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH )) < 0)
#else
if ((han = open(file, O_WRONLY | O_TRUNC | O_CREAT,
S_IREAD | S_IWRITE | S_IEXEC | S_IDELETE |
S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH )) < 0)
#endif
pipeit("\n Could not create destination file.\n");
return (han);
}
}

View File

@@ -0,0 +1,553 @@
/* ------------------------------------------------------------------------ */
/* */
/* These are the decompression algorithms. */
/* Don't change here anything (apart from memory allocation perhaps). */
/* Any changes will very likely cause bugs! */
/* */
/* ------------------------------------------------------------------------ */
#include "os.h"
#if defined(AMIGA)
#include <string.h> // mem*()
#endif
#if defined(DOS) || defined(WIN16) || defined(WINNT) || defined(OS2) || defined(UNIX)
#if !defined(__CYGWIN__)
#include <mem.h> // mem*()
#endif
#endif
#include <stdio.h> // pipeit()
#include <stdlib.h> // malloc()
#include <string.h>
#include "globals.h"
#include "portable.h"
#include "uac_comm.h"
#include "uac_crc.h"
#include "uac_dcpr.h"
#include "uac_sys.h"
#ifdef CRYPT
#include "unace_ps.h"
#endif /* CRYPT */
//------------------------------ QUICKSORT ---------------------------------//
#define xchg_def(v1,v2) {INT dummy;\
dummy=v1; \
v1=v2; \
v2=dummy;}
void sortrange(INT left, INT right)
{
INT zl = left,
zr = right,
hyphen;
hyphen = sort_freq[right];
//divides by hyphen the given range into 2 parts
do
{
while (sort_freq[zl] > hyphen)
zl++;
while (sort_freq[zr] < hyphen)
zr--;
//found a too small (left side) and
//a too big (right side) element-->exchange them
if (zl <= zr)
{
xchg_def(sort_freq[zl], sort_freq[zr]);
xchg_def(sort_org[zl], sort_org[zr]);
zl++;
zr--;
}
}
while (zl < zr);
//sort partial ranges - when very small, sort directly
if (left < zr)
{
if (left < zr - 1)
sortrange(left, zr);
else if (sort_freq[left] < sort_freq[zr])
{
xchg_def(sort_freq[left], sort_freq[zr]);
xchg_def(sort_org[left], sort_org[zr]);
}
}
if (right > zl)
{
if (zl < right - 1)
sortrange(zl, right);
else if (sort_freq[zl] < sort_freq[right])
{
xchg_def(sort_freq[zl], sort_freq[right]);
xchg_def(sort_org[zl], sort_org[right]);
}
}
}
void quicksort(INT n)
{
INT i;
for (i = n + 1; i--;)
sort_org[i] = i;
sortrange(0, n);
}
//------------------------------ read bits ---------------------------------//
void readdat(void)
{
UINT i;
i = (size_rdb - 2) << 2;
rpos -= size_rdb - 2;
buf_rd[0] = buf_rd[size_rdb - 2];
buf_rd[1] = buf_rd[size_rdb - 1];
read_adds_blk((CHAR *) & buf_rd[2], i);
#ifdef HI_LO_BYTE_ORDER
{
ULONG *p;
i>>=2; // count LONGs not BYTEs
p=&buf_rd[2];
while (i--)
{
LONGswap(p);
p++;
}
}
#endif
}
#define addbits(bits) \
{ \
rpos+=(bits_rd+=bits)>>5; \
bits_rd&=31; \
if (rpos==(size_rdb-2)) readdat(); \
code_rd=(buf_rd[rpos] << bits_rd) \
+((buf_rd[rpos+1] >> (32-bits_rd))&(!bits_rd-1)); \
}
//---------------------- COMMENT DECOMPRESSION -----------------------------//
#define comm_cpr_hf(a,b) (a+b)
void dcpr_comm_init(void)
{
INT i;
i = comm_cpr_size > size_rdb * sizeof(LONG) ? size_rdb * sizeof(LONG) : comm_cpr_size;
if (!f_err)
memcpy(buf_rd, comm, i);
#ifdef HI_LO_BYTE_ORDER
{
ULONG *p;
i>>=2; // count LONGs not BYTEs
p=buf_rd;
while (i--)
{
LONGswap(p);
p++;
}
}
#endif
code_rd = buf_rd[0];
rpos = bits_rd = 0;
}
void dcpr_comm(INT comm_size)
{
SHORT hash[comm_cpr_hf(255, 255) + 1];
INT dpos = 0,
c,
pos = 0,
len,
hs;
memset(&hash, 0, sizeof(hash));
if (comm_cpr_size)
{
dcpr_comm_init();
len = code_rd >> (32 - 15);
addbits(15);
if (len >= comm_size)
len = comm_size - 1;
if (read_wd(maxwd_mn, dcpr_code_mn, dcpr_wd_mn, max_cd_mn))
do
{
if (dpos > 1)
{
pos = hash[hs = comm_cpr_hf(comm[dpos - 1], comm[dpos - 2])];
hash[hs] = dpos;
}
addbits(dcpr_wd_mn[(c = dcpr_code_mn[code_rd >> (32 - maxwd_mn)])]);
if (rpos == size_rdb - 3)
rpos = 0;
if (c > 255)
{
c -= 256;
c += 2;
while (c--)
comm[dpos++] = comm[pos++];
}
else
{
comm[dpos++] = c;
}
}
while (dpos < len);
comm[len] = 0;
}
}
//------------------------- LZW1 DECOMPRESSION -----------------------------//
void wrchar(CHAR ch)
{
dcpr_do++;
dcpr_text[dcpr_dpos] = ch;
dcpr_dpos++;
dcpr_dpos &= dcpr_dican;
}
void copystr(LONG d, INT l)
{
INT mpos;
dcpr_do += l;
mpos = dcpr_dpos - d;
mpos &= dcpr_dican;
if ((mpos >= dcpr_dicsiz - maxlength) || (dcpr_dpos >= dcpr_dicsiz - maxlength))
{
while (l--)
{
dcpr_text[dcpr_dpos] = dcpr_text[mpos];
dcpr_dpos++;
dcpr_dpos &= dcpr_dican;
mpos++;
mpos &= dcpr_dican;
}
}
else
{
while (l--)
dcpr_text[dcpr_dpos++] = dcpr_text[mpos++];
dcpr_dpos &= dcpr_dican;
}
}
void decompress(void)
{
INT c,
lg,
i,
k;
ULONG dist;
while (dcpr_do < dcpr_do_max)
{
if (!blocksize)
if (!calc_dectabs())
return;
addbits(dcpr_wd_mn[(c = dcpr_code_mn[code_rd >> (32 - maxwd_mn)])]);
blocksize--;
if (c > 255)
{
if (c > 259)
{
if ((c -= 260) > 1)
{
dist = (code_rd >> (33 - c)) + (1L << (c - 1));
addbits(c - 1);
}
else
dist = c;
dcpr_olddist[(dcpr_oldnum = (dcpr_oldnum + 1) & 3)] = dist;
i = 2;
if (dist > maxdis2)
{
i++;
if (dist > maxdis3)
i++;
}
}
else
{
dist = dcpr_olddist[(dcpr_oldnum - (c &= 255)) & 3];
for (k = c + 1; k--;)
dcpr_olddist[(dcpr_oldnum - k) & 3] = dcpr_olddist[(dcpr_oldnum - k + 1) & 3];
dcpr_olddist[dcpr_oldnum] = dist;
i = 2;
if (c > 1)
i++;
}
addbits(dcpr_wd_lg[(lg = dcpr_code_lg[code_rd >> (32 - maxwd_lg)])]);
dist++;
lg += i;
copystr(dist, lg);
}
else
wrchar(c);
}
}
//-------------------------- HUFFMAN ROUTINES ------------------------------//
INT makecode(UINT maxwd, UINT size1_t, UCHAR * wd, USHORT * code)
{
UINT maxc,
size2_t,
l,
c,
i,
max_make_code;
memcpy(&sort_freq, wd, (size1_t + 1) * sizeof(CHAR));
if (size1_t)
quicksort(size1_t);
else
sort_org[0] = 0;
sort_freq[size1_t + 1] = size2_t = c = 0;
while (sort_freq[size2_t])
size2_t++;
if (size2_t < 2)
{
i = sort_org[0];
wd[i] = 1;
size2_t += (size2_t == 0);
}
size2_t--;
max_make_code = 1 << maxwd;
for (i = size2_t + 1; i-- && c < max_make_code;)
{
maxc = 1 << (maxwd - sort_freq[i]);
l = sort_org[i];
if (c + maxc > max_make_code)
{
dcpr_do = dcpr_do_max;
return (0);
}
memset16(&code[c], l, maxc);
c += maxc;
}
return (1);
}
INT read_wd(UINT maxwd, USHORT * code, UCHAR * wd, INT max_el)
{
UINT c,
i,
j,
num_el,
l,
uplim,
lolim;
memset(wd, 0, max_el * sizeof(CHAR));
memset(code, 0, (1 << maxwd) * sizeof(SHORT));
num_el = code_rd >> (32 - 9);
addbits(9);
if (num_el > max_el)
num_el = max_el;
lolim = code_rd >> (32 - 4);
addbits(4);
uplim = code_rd >> (32 - 4);
addbits(4);
for (i = -1; ++i <= uplim;)
{
wd_svwd[i] = code_rd >> (32 - 3);
addbits(3);
}
if (!makecode(maxwd_svwd, uplim, wd_svwd, code))
return (0);
j = 0;
while (j <= num_el)
{
c = code[code_rd >> (32 - maxwd_svwd)];
addbits(wd_svwd[c]);
if (c < uplim)
wd[j++] = c;
else
{
l = (code_rd >> 28) + 4;
addbits(4);
while (l-- && j <= num_el)
wd[j++] = 0;
}
}
if (uplim)
for (i = 0; ++i <= num_el;)
wd[i] = (wd[i] + wd[i - 1]) % uplim;
for (i = -1; ++i <= num_el;)
if (wd[i])
wd[i] += lolim;
return (makecode(maxwd, num_el, wd, code));
}
INT calc_dectabs(void)
{
if (!read_wd(maxwd_mn, dcpr_code_mn, dcpr_wd_mn, max_cd_mn)
|| !read_wd(maxwd_lg, dcpr_code_lg, dcpr_wd_lg, max_cd_lg))
return (0);
blocksize = code_rd >> (32 - 15);
addbits(15);
return (1);
}
//---------------------------- BLOCK ROUTINES ------------------------------//
INT decompress_blk(CHAR * buf, UINT len)
{
LONG old_pos = dcpr_dpos;
INT i;
dcpr_do = 0;
if ((dcpr_do_max = len - maxlength) > dcpr_size)
dcpr_do_max = dcpr_size;
if ((LONG) dcpr_size > 0 && dcpr_do_max)
{
decompress();
if (old_pos + dcpr_do > dcpr_dicsiz)
{
i = dcpr_dicsiz - old_pos;
memcpy(buf, &dcpr_text[old_pos], i);
memcpy(&buf[i], dcpr_text, dcpr_do - i);
}
else
memcpy(buf, &dcpr_text[old_pos], dcpr_do);
}
dcpr_size -= dcpr_do;
return (dcpr_do);
}
INT unstore(CHAR * buf, UINT len)
{
UINT rd = 0,
i,
pos = 0;
#ifdef CRYPT
len = crypt_len(len - 8); /* because of decryption */
#endif /* CRYPT */
while ((i = read_adds_blk((CHAR *) buf_rd, (INT) ((i = ((len > dcpr_size) ? dcpr_size : len)) > size_rdb ? size_rdb : i))) != 0)
{
rd += i;
len -= i;
memcpy(&buf[pos], buf_rd, i);
pos += i;
}
dcpr_size -= rd;
for (i = 0; i < rd; i++)
{
dcpr_text[dcpr_dpos] = buf[i];
dcpr_dpos++;
dcpr_dpos &= dcpr_dican;
}
return (INT)rd;
}
INT dcpr_adds_blk(CHAR * buf, UINT len)
{
INT r;
switch (fhead.TECH.TYPE)
{
case TYPE_STORE:
r = unstore(buf, len);
break;
case TYPE_LZW1:
r = decompress_blk(buf, len);
break;
default:
pipeit("\nFile compressed with unknown method. Decompression not possible.\n");
f_err = ERR_OTHER;
r = 0;
}
rd_crc = getcrc(rd_crc, (UCHAR *)buf, r);
return r;
}
//----------------------------- INIT ROUTINES ------------------------------//
void dcpr_init(void)
{
dcpr_frst_file = 1;
dcpr_dic = 20;
while ((dcpr_text = malloc(dcpr_dicsiz = (LONG) 1 << dcpr_dic))==NULL)
dcpr_dic--;
dcpr_dican = dcpr_dicsiz - 1;
}
void dcpr_init_file(void)
{
UINT i;
#ifdef CRYPT
reset_cryptkey();
#else /* CRYPT */
if (head.HEAD_FLAGS & ACE_PASSW)
{
pipeit("\nFound passworded file. Decryption not supported.\n");
f_err = ERR_OTHER;
return;
}
#endif /* CRYPT */
rd_crc = CRC_MASK;
dcpr_size = fhead.SIZE;
if (fhead.TECH.TYPE == TYPE_LZW1)
{
if ((fhead.TECH.PARM & 15) + 10 > dcpr_dic)
{
pipeit("\nNot enough memory or dictionary of archive too large.\n");
f_err = ERR_MEM;
return;
}
i = size_rdb * sizeof(LONG);
read_adds_blk((CHAR *) buf_rd, i);
#ifdef HI_LO_BYTE_ORDER
{
ULONG *p;
i>>=2; // count LONGs not BYTEs
p=buf_rd;
while (i--)
{
LONGswap(p);
p++;
}
}
#endif
code_rd = buf_rd[0];
bits_rd = rpos = 0;
blocksize = 0;
}
if (!adat.sol || dcpr_frst_file)
dcpr_dpos = 0;
dcpr_oldnum = 0;
memset(&dcpr_olddist, 0, sizeof(dcpr_olddist));
dcpr_frst_file = 0;
}

View File

@@ -0,0 +1,105 @@
/* ------------------------------------------------------------------------ */
/* */
/* Some basic things. */
/* */
/* ------------------------------------------------------------------------ */
#include "os.h"
#include <signal.h> // signal()
#include <stdio.h> // fprintf() fflush() getch() putc()
#if defined(DOS) || defined(WINNT) || defined(WIN16)
#if !defined(__CYGWIN__)
#include <conio.h> // getch()
#endif
#endif
#if defined(DOS)
#include <dos.h> // delay() sound()
#endif
#include "globals.h"
#include "uac_sys.h"
void memset16(USHORT * dest, SHORT val, INT len) // fills short-array with
{ // value
while (len--)
*(dest++) = val;
}
INT cancel(void) // checks whether to interrupt the program
{
#ifdef DOS
while (kbhit())
{
if (getch() == 27)
f_err = ERR_USER;
}
#endif
return (f_err);
}
INT wrask(CHAR * s) // prompt-routine
{
CHAR ch = 0;
fprintf(stderr, "\n %s (Yes,Always,No,Cancel) ", s);
fflush(stderr);
do
{
/*ch = getch();
ch = upcase(ch);*/
}
while (ch != 'Y' && ch != 'A' && ch != 'N' && ch != 'C' && ch != 27);
fprintf(stderr, "%s", ch == 'Y' ? "Yes" : (ch == 'A' ? "Always" : (ch == 'N' ? "No" : "Cancel")));
fflush(stderr);
return (ch == 'Y' ? 0 : (ch == 'A' ? 1 : (ch == 'N' ? 2 : 3)));
}
void beep(void) // makes some noise
{
#ifdef DOS
sound(800);
delay(250);
nosound();
#endif
#ifdef AMIGA
putc(0x07, stderr);
#endif
}
void my_signalhandler(INT sig_number) // sets f_err if ctrl+c or ctrl+brk
{
f_err = ERR_USER;
pipeit("\nUser break\n");
}
#ifdef DOS // handles hardware errors
#ifdef __BORLANDC__
INT harderrhandler(UINT deverr, UINT errc, UINT * devhdr)
#else
INT __far harderrhandler(UINT deverr, UINT errc, UINT * devhdr)
#endif
{
f_criterr = 'A' + deverr & 0xff;
f_err = ERR_OTHER;
return (0x3);
}
#endif
void set_handler(void) // initializes handlers
{
#if defined(DOS) && !defined(__BORLANDC__)
signal(SIGBREAK, my_signalhandler); // set ctrl-break/-c handlers
#endif
signal(SIGINT, my_signalhandler);
#if defined(DOS) && !defined(__CONSOLE__) // set hardware error handler
#ifdef __BORLANDC__
harderr(harderrhandler);
#else
_harderr(harderrhandler);
#endif
#endif
}

View File

@@ -0,0 +1,584 @@
/* ------------------------------------------------------------------------ */
/* */
/* Main file of public UNACE. */
/* */
/* ------------------------------------------------------------------------ */
//--------------- include general files ------------------------------------//
#include <ctype.h> // tolower()
#include <fcntl.h> // open()
#include <stdio.h> // printf() sprintf() remove()
#include <stdlib.h> // malloc()
#include <string.h> // str*()
#include <sys/types.h>
#include <sys/stat.h> // S_I* AMIGA: fstat()
#define DIRSEP '\\'
#if (!defined(__EMX__) && !defined(__OS2__) && !defined(WINNT) && !defined(WIN32)) || defined(__CYGWIN__)
#include <sys/errno.h>
#endif
//--------------- include unace specific header files ----------------------//
#include "os.h"
#include "globals.h"
#include "portable.h"
#include "uac_comm.h"
#include "uac_crc.h"
#include "uac_crt.h"
#include "uac_dcpr.h"
#include "uac_sys.h"
#ifdef CRYPT
#include "unace_ps.h"
#endif /* CRYPT */
int files=0;
//--------------- BEGIN OF UNACE ROUTINES ----------------------------------//
int pipeit(char *format, ...) {
/* Do nothing ... perhaps pipe this somewhere in the future */
return 0;
}
void init_unace(void) // initializes unace
{
buf_rd =malloc(size_rdb * sizeof(ULONG)); // Allocate buffers: increase
buf =malloc(size_buf); // sizes when possible to speed
buf_wr =malloc(size_wrb); // up the program
readbuf=malloc(size_headrdb);
if (buf_rd ==NULL ||
buf ==NULL ||
buf_wr ==NULL ||
readbuf==NULL )
f_err = ERR_MEM;
make_crctable(); // initialize CRC table
dcpr_init(); // initialize decompression
set_handler(); // ctrl+break etc.
}
void done_unace(void)
{
if (buf_rd ) free(buf_rd );
if (buf ) free(buf );
if (buf_wr ) free(buf_wr );
if (readbuf ) free(readbuf );
if (dcpr_text) free(dcpr_text);
}
INT read_header(INT print_err) // reads any header from archive
{
USHORT rd,
head_size,
crc_ok;
LONG crc;
UCHAR *tp=readbuf;
lseek(archan, skipsize, SEEK_CUR); // skip ADDSIZE block
if (read(archan, &head, 4)<4)
return (0); // read CRC and header size
#ifdef HI_LO_BYTE_ORDER
WORDswap(&head.HEAD_CRC);
WORDswap(&head.HEAD_SIZE);
#endif
// read size_headrdb bytes into
head_size = head.HEAD_SIZE; // header structure
rd = (head_size > size_headrdb) ? size_headrdb : head_size;
if (read(archan, readbuf, rd) < rd)
return (0);
head_size -= rd;
crc = getcrc(CRC_MASK, readbuf, rd);
while (head_size) // skip rest of header
{
rd = (head_size > size_buf) ? size_buf : head_size;
if (read(archan, buf, rd) < rd)
return (0);
head_size -= rd;
crc = getcrc(crc, (UCHAR *)buf, rd);
}
head.HEAD_TYPE =*tp++; // generic buffer to head conversion
head.HEAD_FLAGS=BUFP2WORD(tp);
if (head.HEAD_FLAGS & ACE_ADDSIZE)
skipsize = head.ADDSIZE = BUF2LONG(tp); // get ADDSIZE
else
skipsize = 0;
// check header CRC
if (!(crc_ok = head.HEAD_CRC == (crc & 0xffff)) && print_err)
pipeit("\nError: archive is broken\n");
else
switch (head.HEAD_TYPE) // specific buffer to head conversion
{
case MAIN_BLK:
memcpy(mhead.ACESIGN, tp, acesign_len); tp+=acesign_len;
mhead.VER_MOD=*tp++;
mhead.VER_CR =*tp++;
mhead.HOST_CR=*tp++;
mhead.VOL_NUM=*tp++;
mhead.TIME_CR=BUFP2LONG(tp);
mhead.RES1 =BUFP2WORD(tp);
mhead.RES2 =BUFP2WORD(tp);
mhead.RES =BUFP2LONG(tp);
mhead.AV_SIZE=*tp++;
memcpy(mhead.AV, tp, rd-(USHORT)(tp-readbuf));
break;
case FILE_BLK:
fhead.PSIZE =BUFP2LONG(tp);
fhead.SIZE =BUFP2LONG(tp);
fhead.FTIME =BUFP2LONG(tp);
fhead.ATTR =BUFP2LONG(tp);
fhead.CRC32 =BUFP2LONG(tp);
fhead.TECH.TYPE =*tp++;
fhead.TECH.QUAL =*tp++;
fhead.TECH.PARM =BUFP2WORD(tp);
fhead.RESERVED =BUFP2WORD(tp);
fhead.FNAME_SIZE=BUFP2WORD(tp);
memcpy(fhead.FNAME, tp, rd-(USHORT)(tp-readbuf));
break;
// default: (REC_BLK and future things):
// do nothing 'cause isn't needed for extraction
}
return (crc_ok);
}
// maximum SFX module size
#define max_sfx_size 65536 // (needed by read_arc_head)
INT read_arc_head(void) // searches for the archive header and reads it
{
INT i,
flags,
buf_pos = 0;
LONG arc_head_pos,
old_fpos,
fpos = 0;
struct stat st;
fstat(archan, &st);
memset(buf, 0, size_buf);
#if !defined(__EMX__) && !defined(__OS2__)
while (ftell(farchan)<st.st_size && fpos < max_sfx_size)
#else
while (tell(archan)<st.st_size && fpos < max_sfx_size)
#endif
{
old_fpos = fpos;
fpos += read(archan, &buf[buf_pos], size_buf - buf_pos);
for (i = 0; i < size_buf; i++) // look for the acesign
{
if (!memcmp(acesign, &buf[i], acesign_len))
{
// seek to the probable begin
// of the archive
arc_head_pos = old_fpos + i - buf_pos - bytes_before_acesign;
lseek(archan, arc_head_pos, SEEK_SET);
if (read_header(0)) // try to read archive header
{
flags = mhead.HEAD_FLAGS;
adat.sol = (flags & ACE_SOLID) > 0;
adat.vol = (flags & ACE_MULT_VOL) > 0;
adat.vol_num = mhead.VOL_NUM;
adat.time_cr = mhead.TIME_CR;
return (1);
}
}
}
// was no archive header,
// continue search
lseek(archan, fpos, SEEK_SET);
memcpy(buf, &buf[size_buf - 512], 512);
buf_pos = 512; // keep 512 old bytes
}
return (0);
}
INT open_archive(INT print_err) // opens archive (or volume)
{
CHAR av_str[80];
#if defined(__OS2_) || defined(__EMX__) || defined(WIN32)
archan = open(aname, O_RDONLY | O_BINARY); // open file
#else
archan = open(aname, O_RDONLY); // open file
#endif
#if !defined(__EMX__) && !defined(__OS2__)
farchan = fdopen(archan, "rb");
#endif
if (archan == -1)
{
pipeit("\nError opening file %s", aname);
return (0);
}
if (!read_arc_head()) // read archive header
{
if (print_err)
pipeit("\nInvalid archive file: %s\n", aname);
#if !defined(__EMX__) && !defined(__OS2__)
fclose(farchan);
#endif
close(archan);
return (0);
}
pipeit("\nProcessing archive: %s\n\n", aname);
if (head.HEAD_FLAGS & ACE_AV)
{
pipeit("Authenticity Verification:"); // print the AV
sprintf(av_str, "\ncreated on %d.%d.%d by ",
ts_day(adat.time_cr), ts_month(adat.time_cr), ts_year(adat.time_cr));
pipeit(av_str);
strncpy(av_str, (char *)mhead.AV, mhead.AV_SIZE);
av_str[mhead.AV_SIZE] = 0;
pipeit("%s\n\n", av_str);
}
comment_out("Main comment:"); // print main comment
return (1);
}
void get_next_volname(void) // get file name of next volume
{
CHAR *cp;
INT num;
if ((cp = (CHAR *) strrchr(aname, '.')) == NULL || !*(cp + 1))
num = -1;
else
{
cp++;
num = (*(cp + 1) - '0') * 10 + *(cp + 2) - '0';
if (!in(num, 0, 99))
num = -1;
if (in(*cp, '0', '9'))
num += (*cp - '0') * 100;
}
num++;
if (num < 100)
*cp = 'C';
else
*cp = num / 100 + '0';
*(cp + 1) = (num / 10) % 10 + '0';
*(cp + 2) = num % 10 + '0';
}
INT proc_vol(void) // opens volume
{
INT i;
CHAR s[80];
if (!fileexists(aname) || !f_allvol_pr)
{
do
{
sprintf(s, "Ready to process %s?", aname);
#if !defined(__MINGW32__)
beep();
#else
beep(500,500);
#endif
i = wrask(s); // ask whether ready or not
f_allvol_pr = (i == 1); // "Always" --> process all volumes
if (i >= 2)
{
f_err = ERR_FOUND;
return (0);
}
}
while (!fileexists(aname));
}
if (!open_archive(1)) // open volume
{
pipeit("\nError while opening archive. File not found or archive broken.\n");
f_err = ERR_OPEN;
return (0);
}
return (1);
}
INT proc_next_vol(void) // opens next volume to process
{
#if !defined(__EMX__) && !defined(__OS2__)
fclose(farchan);
#endif
close(archan); // close handle
get_next_volname(); // get file name of next volume
if (!proc_vol()) // try to open volume, read archive header
return 0;
if (!read_header(1)) // read 2nd header
{
f_err=ERR_READ;
return 0;
}
return 1;
}
INT read_adds_blk(CHAR * buffer, INT len) // reads part of ADD_SIZE block
{
INT rd = 0,
l = len;
LONG i;
#ifdef CRYPT
char *cbuffer=buffer;
if (head.HEAD_TYPE == FILE_BLK && (head.HEAD_FLAGS & ACE_PASSW))
len = crypt_len(len);
#endif /* CRYPT */
while (!f_err && len && skipsize)
{
i = (skipsize > len) ? len : skipsize;
skipsize -= i;
/* How do I check error condition when comping -mno-cygwin? */
#if !defined(__MINGW32__)
errno = 0;
#endif
rd += read(archan, buffer, i);
#if !defined(__MINGW32__)
if (errno)
{
pipeit("\nRead error\n");
f_err = ERR_READ;
}
#endif
buffer += i;
len -= i;
if (!skipsize) // if block is continued on next volume
if (head.HEAD_FLAGS & ACE_SP_AFTER && !proc_next_vol())
break;
}
#ifdef CRYPT
if (head.HEAD_TYPE == FILE_BLK && (head.HEAD_FLAGS & ACE_PASSW))
decrypt(cbuffer, rd);
#endif /* CRYPT */
return (rd > l ? l : rd);
}
void crc_print(void) // checks CRC, prints message
{
INT crc_not_ok = rd_crc != fhead.CRC32; /* check CRC of file */
if (!f_err) // print message
{
pipeit(crc_not_ok ? " CRC-check error" : " CRC OK");
flush;
}
}
void analyze_file(void) // analyzes one file (for solid archives)
{
pipeit("\n Analyzing");
flush;
while (!cancel() && (dcpr_adds_blk(buf_wr, size_wrb))) // decompress only
;
crc_print();
}
void extract_file(void) // extracts one file
{
INT rd;
pipeit("\n Extracting");
flush; // decompress block
while (!cancel() && (rd = dcpr_adds_blk(buf_wr, size_wrb)))
{
if (write(wrhan, buf_wr, rd) != rd) // write block
{
pipeit("\nWrite error\n");
f_err = ERR_WRITE;
}
}
crc_print();
}
/* extracts or tests all files of the archive
*/
void extract_files(int nopath, int test)
{
CHAR file[PATH_MAX];
while (!cancel() && read_header(1))
{
if (head.HEAD_TYPE == FILE_BLK)
{
comment_out("File comment:"); // show file comment
ace_fname(file, &head, nopath); // get file name
pipeit("\n%s", file);
flush;
dcpr_init_file(); // initialize decompression of file
if (!f_err)
{
if (test ||
(wrhan = create_dest_file(file, (INT) fhead.ATTR))<0)
{
if (test || adat.sol)
analyze_file(); // analyze file
}
else
{
extract_file(); // extract it
#ifdef DOS // set file time
_dos_setftime(wrhan, (USHORT) (fhead.FTIME >> 16), (USHORT) fhead.FTIME);
#endif
close(wrhan);
#ifdef DOS // set file attributes
_dos_setfileattr(file, (UINT) fhead.ATTR);
#endif
#ifdef AMIGA
{ // set file date and time
struct DateTime dt;
char Date[9], Time[9];
ULONG tstamp=fhead.FTIME;
sprintf(Date, "%02d-%02d-%02d", ts_year(tstamp)-1900, ts_month(tstamp), ts_day(tstamp));
sprintf(Time, "%02d:%02d:%02d", ts_hour(tstamp), ts_min(tstamp), ts_sec(tstamp));
dt.dat_Format = FORMAT_INT;
dt.dat_Flags = 0;
dt.dat_StrDate= Date;
dt.dat_StrTime= Time;
if (StrToDate(&dt))
SetFileDate(file, &dt.dat_Stamp);
}
#endif
if (f_err)
remove(file);
}
}
}
}
}
unsigned percentage(ULONG p, ULONG d)
{
return (unsigned)( d ? (d/2+p*100)/d : 100 );
}
void list_files(int verbose)
{
ULONG size =0,
psize=0,
tpsize;
CHAR file[PATH_MAX];
pipeit("Date |Time |Packed |Size |Ratio|File\n");
while (!cancel() && read_header(1))
{
if (head.HEAD_TYPE == FILE_BLK)
{
ULONG ti=fhead.FTIME;
ace_fname(file, &head, verbose ? 0 : 1); // get file name
size += fhead.SIZE;
psize +=
tpsize = fhead.PSIZE;
files++;
while (head.HEAD_FLAGS & ACE_SP_AFTER)
{
skipsize=0;
if (!proc_next_vol())
break;
psize += fhead.PSIZE;
tpsize+= fhead.PSIZE;
}
if (!f_err)
pipeit("%02u.%02u.%02u|%02u:%02u|%c%c%9lu|%9lu|%4u%%|%c%s\n",
ts_day (ti), ts_month(ti), ts_year(ti)%100,
ts_hour(ti), ts_min (ti),
fhead.HEAD_FLAGS & ACE_SP_BEF ? '<' : ' ',
fhead.HEAD_FLAGS & ACE_SP_AFTER ? '>' : ' ',
tpsize, fhead.SIZE, percentage(tpsize, fhead.SIZE),
fhead.HEAD_FLAGS & ACE_PASSW ? '*' : ' ',
file
);
}
}
if (!f_err)
{
pipeit("\n %9lu|%9lu|%4u%%| %u file%s",
psize,
size,
percentage(psize, size),
files,
(char*)(files == 1 ? "" : "s")
);
}
}
void showhelp(void)
{
pipeit("\n"
"Usage: UNACE <command> <archive[.ace]>\n"
"\n"
"Where <command> is one of:\n"
"\n"
" e Extract files\n"
" l List archive\n"
" t Test archive integrity\n"
" v List archive (verbose)\n"
" x Extract files with full path"
);
}
int include_unpack(char *bleah) // processes the archive
{
CHAR *s;
strcpy(aname, bleah);
init_unace(); // initialize unace
if (!(s = (CHAR *) strrchr(aname, DIRSEP)))
s = aname;
if (!strrchr(s, '.'))
strcat(aname, ".ACE");
if (open_archive(1)) // open archive to process
{
if (adat.vol_num)
pipeit("\nFirst volume of archive required!\n");
else
list_files (0 );
#if !defined(__EMX__) && !defined(__OS2__)
fclose(farchan);
#endif
close(archan);
if (f_err)
{
pipeit("\nError occurred\n");
if (f_criterr)
pipeit("Critical error on drive %c\n", f_criterr);
}
}
else
f_err = ERR_CLINE;
done_unace();
return (f_err);
}

601
utils/Install/packzip/api.c Normal file
View File

@@ -0,0 +1,601 @@
/*---------------------------------------------------------------------------
api.c
This module supplies an UnZip engine for use directly from C/C++
programs. The functions are:
UzpVer *UzpVersion(void);
void UzpVersion2(UzpVer2 *version)
int UzpMain(int argc, char *argv[]);
int UzpAltMain(int argc, char *argv[], UzpInit *init);
int UzpValidate(char *archive, int AllCodes);
void UzpFreeMemBuffer(UzpBuffer *retstr);
int UzpUnzipToMemory(char *zip, char *file, UzpOpts *optflgs,
UzpCB *UsrFuncts, UzpBuffer *retstr);
non-WINDLL only (a special WINDLL variant is defined in windll/windll.c):
int UzpGrep(char *archive, char *file, char *pattern, int cmd, int SkipBin,
UzpCB *UsrFuncts);
OS/2 only (for now):
int UzpFileTree(char *name, cbList(callBack), char *cpInclude[],
char *cpExclude[]);
You must define `DLL' in order to include the API extensions.
---------------------------------------------------------------------------*/
#ifdef OS2
# define INCL_DOSMEMMGR
# include <os2.h>
#endif
#include <setjmp.h>
#define UNZIP_INTERNAL
#include "unzip.h"
#include "version.h"
#ifdef WINDLL
# include "windll/windll.h"
#endif
#ifdef DLL /* This source file supplies DLL-only interface code. */
jmp_buf dll_error_return;
/*---------------------------------------------------------------------------
Documented API entry points
---------------------------------------------------------------------------*/
UzpVer * UZ_EXP UzpVersion() /* should be pointer to const struct */
{
static UzpVer version; /* doesn't change between calls */
version.structlen = UZPVER_LEN;
#ifdef BETA
version.flag = 1;
#else
version.flag = 0;
#endif
version.betalevel = BETALEVEL;
version.date = VERSION_DATE;
#ifdef ZLIB_VERSION
version.zlib_version = ZLIB_VERSION;
version.flag |= 2;
#else
version.zlib_version = NULL;
#endif
/* someday each of these may have a separate patchlevel: */
version.unzip.major = UZ_MAJORVER;
version.unzip.minor = UZ_MINORVER;
version.unzip.patchlevel = PATCHLEVEL;
version.zipinfo.major = ZI_MAJORVER;
version.zipinfo.minor = ZI_MINORVER;
version.zipinfo.patchlevel = PATCHLEVEL;
/* these are retained for backward compatibility only: */
version.os2dll.major = UZ_MAJORVER;
version.os2dll.minor = UZ_MINORVER;
version.os2dll.patchlevel = PATCHLEVEL;
version.windll.major = UZ_MAJORVER;
version.windll.minor = UZ_MINORVER;
version.windll.patchlevel = PATCHLEVEL;
return &version;
}
void UZ_EXP UzpVersion2(UzpVer2 *version)
{
version->structlen = UZPVER_LEN;
#ifdef BETA
version->flag = 1;
#else
version->flag = 0;
#endif
strcpy(version->betalevel, BETALEVEL);
strcpy(version->date, VERSION_DATE);
#ifdef ZLIB_VERSION
strcpy(version->zlib_version, ZLIB_VERSION);
version->flag |= 2;
#else
version->zlib_version[0] = '\0';
#endif
/* someday each of these may have a separate patchlevel: */
version->unzip.major = UZ_MAJORVER;
version->unzip.minor = UZ_MINORVER;
version->unzip.patchlevel = PATCHLEVEL;
version->zipinfo.major = ZI_MAJORVER;
version->zipinfo.minor = ZI_MINORVER;
version->zipinfo.patchlevel = PATCHLEVEL;
/* these are retained for backward compatibility only: */
version->os2dll.major = UZ_MAJORVER;
version->os2dll.minor = UZ_MINORVER;
version->os2dll.patchlevel = PATCHLEVEL;
version->windll.major = UZ_MAJORVER;
version->windll.minor = UZ_MINORVER;
version->windll.patchlevel = PATCHLEVEL;
}
#ifndef WINDLL
int UZ_EXP UzpAltMain(int argc, char *argv[], UzpInit *init)
{
int r, (*dummyfn)();
CONSTRUCTGLOBALS();
if (init->structlen >= (sizeof(ulg) + sizeof(dummyfn)) && init->msgfn)
G.message = init->msgfn;
if (init->structlen >= (sizeof(ulg) + 2*sizeof(dummyfn)) && init->inputfn)
G.input = init->inputfn;
if (init->structlen >= (sizeof(ulg) + 3*sizeof(dummyfn)) && init->pausefn)
G.mpause = init->pausefn;
if (init->structlen >= (sizeof(ulg) + 4*sizeof(dummyfn)) && init->userfn)
(*init->userfn)(); /* allow void* arg? */
r = unzip(__G__ argc, argv);
DESTROYGLOBALS()
RETURN(r);
}
#endif /* !WINDLL */
#ifndef __16BIT__
void UZ_EXP UzpFreeMemBuffer(UzpBuffer *retstr)
{
if (retstr->strptr != NULL) {
free(retstr->strptr);
retstr->strptr = NULL;
}
}
#ifndef WINDLL
static int UzpDLL_Init OF((zvoid *pG, UzpCB *UsrFuncts));
static int UzpDLL_Init(pG, UsrFuncts)
zvoid *pG;
UzpCB *UsrFuncts;
{
int (*dummyfn)();
if (UsrFuncts->structlen >= (sizeof(ulg) + sizeof(dummyfn)) &&
UsrFuncts->msgfn)
((Uz_Globs *)pG)->message = UsrFuncts->msgfn;
else
return FALSE;
if (UsrFuncts->structlen >= (sizeof(ulg) + 2*sizeof(dummyfn)) &&
UsrFuncts->inputfn)
((Uz_Globs *)pG)->input = UsrFuncts->inputfn;
if (UsrFuncts->structlen >= (sizeof(ulg) + 3*sizeof(dummyfn)) &&
UsrFuncts->pausefn)
((Uz_Globs *)pG)->mpause = UsrFuncts->pausefn;
if (UsrFuncts->structlen >= (sizeof(ulg) + 4*sizeof(dummyfn)) &&
UsrFuncts->passwdfn)
((Uz_Globs *)pG)->decr_passwd = UsrFuncts->passwdfn;
if (UsrFuncts->structlen >= (sizeof(ulg) + 5*sizeof(dummyfn)) &&
UsrFuncts->statrepfn)
((Uz_Globs *)pG)->statreportcb = UsrFuncts->statrepfn;
return TRUE;
}
int UZ_EXP UzpUnzipToMemory(char *zip, char *file, UzpOpts *optflgs,
UzpCB *UsrFuncts, UzpBuffer *retstr)
{
int r;
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
char *intern_zip, *intern_file;
#endif
CONSTRUCTGLOBALS();
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
intern_zip = (char *)malloc(strlen(zip)+1);
if (intern_zip == NULL) {
DESTROYGLOBALS()
return PK_MEM;
}
intern_file = (char *)malloc(strlen(file)+1);
if (intern_file == NULL) {
DESTROYGLOBALS()
free(intern_zip);
return PK_MEM;
}
ISO_TO_INTERN(zip, intern_zip);
ISO_TO_INTERN(file, intern_file);
# define zip intern_zip
# define file intern_file
#endif
/* Copy those options that are meaningful for UzpUnzipToMemory, instead of
* a simple "memcpy(G.UzO, optflgs, sizeof(UzpOpts));"
*/
uO.pwdarg = optflgs->pwdarg;
uO.aflag = optflgs->aflag;
uO.C_flag = optflgs->C_flag;
uO.qflag = optflgs->qflag; /* currently, overridden in unzipToMemory */
if (!UzpDLL_Init((zvoid *)&G, UsrFuncts)) {
DESTROYGLOBALS();
return PK_BADERR;
}
G.redirect_data = 1;
r = (unzipToMemory(__G__ zip, file, retstr) <= PK_WARN);
DESTROYGLOBALS()
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
# undef file
# undef zip
free(intern_file);
free(intern_zip);
#endif
if (!r && retstr->strlength) {
free(retstr->strptr);
retstr->strptr = NULL;
}
return r;
}
#endif /* !WINDLL */
#endif /* !__16BIT__ */
#ifdef OS2DLL
int UZ_EXP UzpFileTree(char *name, cbList(callBack), char *cpInclude[],
char *cpExclude[])
{
int r;
CONSTRUCTGLOBALS();
uO.qflag = 2;
uO.vflag = 1;
uO.C_flag = 1;
G.wildzipfn = name;
G.process_all_files = TRUE;
if (cpInclude) {
char **ptr = cpInclude;
while (*ptr != NULL) ptr++;
G.filespecs = ptr - cpInclude;
G.pfnames = cpInclude, G.process_all_files = FALSE;
}
if (cpExclude) {
char **ptr = cpExclude;
while (*ptr != NULL) ptr++;
G.xfilespecs = ptr - cpExclude;
G.pxnames = cpExclude, G.process_all_files = FALSE;
}
G.processExternally = callBack;
r = process_zipfiles(__G)==0;
DESTROYGLOBALS()
return r;
}
#endif /* OS2DLL */
/*---------------------------------------------------------------------------
Helper functions
---------------------------------------------------------------------------*/
void setFileNotFound(__G)
__GDEF
{
G.filenotfound++;
}
int unzipToMemory(__GPRO__ char *zip, char *file, UzpBuffer *retstr)
{
int r;
char *incname[2];
G.process_all_files = FALSE;
G.extract_flag = TRUE;
uO.qflag = 2;
G.wildzipfn = zip;
G.pfnames = incname;
incname[0] = file;
incname[1] = NULL;
G.filespecs = 1;
r = process_zipfiles(__G);
if (retstr) {
retstr->strptr = (char *)G.redirect_buffer;
retstr->strlength = G.redirect_size;
}
return r; /* returns `PK_???' error values */
}
int redirect_outfile(__G)
__GDEF
{
if (G.redirect_size != 0 || G.redirect_buffer != NULL)
return FALSE;
#ifndef NO_SLIDE_REDIR
G.redirect_slide = !G.pInfo->textmode;
#endif
G.redirect_size = (G.pInfo->textmode ?
G.lrec.ucsize * lenEOL : G.lrec.ucsize);
#ifdef OS2
DosAllocMem((void **)&G.redirect_buffer, G.redirect_size+1,
PAG_READ|PAG_WRITE|PAG_COMMIT);
G.redirect_pointer = G.redirect_buffer;
#else
#ifdef __16BIT__
if ((ulg)((extent)G.redirect_size) != G.redirect_size)
return FALSE;
#endif
G.redirect_pointer = G.redirect_buffer = malloc(G.redirect_size+1);
#endif
if (!G.redirect_buffer)
return FALSE;
G.redirect_pointer[G.redirect_size] = '\0';
return TRUE;
}
int writeToMemory(__GPRO__ uch *rawbuf, ulg size)
{
if (rawbuf != G.redirect_pointer)
memcpy(G.redirect_pointer,rawbuf,size);
G.redirect_pointer += size;
return 0;
}
int close_redirect(__G)
__GDEF
{
if (G.pInfo->textmode) {
*G.redirect_pointer = '\0';
G.redirect_size = G.redirect_pointer - G.redirect_buffer;
if ((G.redirect_buffer =
realloc(G.redirect_buffer, G.redirect_size + 1)) == NULL) {
G.redirect_size = 0;
return EOF;
}
}
return 0;
}
#ifndef __16BIT__
#ifndef WINDLL
/* Purpose: Determine if file in archive contains the string szSearch
Parameters: archive = archive name
file = file contained in the archive. This cannot be
a wild card to be meaningful
pattern = string to search for
cmd = 0 - case-insensitive search
1 - case-sensitve search
2 - case-insensitive, whole words only
3 - case-sensitive, whole words only
SkipBin = if true, skip any files that have control
characters other than CR, LF, or tab in the first
100 characters.
Returns: TRUE if a match is found
FALSE if no match is found
-1 on error
Comments: This does not pretend to be as useful as the standard
Unix grep, which returns the strings associated with a
particular pattern, nor does it search past the first
matching occurrence of the pattern.
*/
int UZ_EXP UzpGrep(char *archive, char *file, char *pattern, int cmd,
int SkipBin, UzpCB *UsrFuncts)
{
int retcode = FALSE, compare;
ulg i, j, patternLen, buflen;
char * sz, *p;
UzpOpts flgopts;
UzpBuffer retstr;
memzero(&flgopts, sizeof(UzpOpts)); /* no special options */
if (!UzpUnzipToMemory(archive, file, &flgopts, UsrFuncts, &retstr)) {
return -1; /* not enough memory, file not found, or other error */
}
if (SkipBin) {
if (retstr.strlength < 100)
buflen = retstr.strlength;
else
buflen = 100;
for (i = 0; i < buflen; i++) {
if (iscntrl(retstr.strptr[i])) {
if ((retstr.strptr[i] != 0x0A) &&
(retstr.strptr[i] != 0x0D) &&
(retstr.strptr[i] != 0x09))
{
/* OK, we now think we have a binary file of some sort */
free(retstr.strptr);
return FALSE;
}
}
}
}
patternLen = strlen(pattern);
if (retstr.strlength < patternLen) {
free(retstr.strptr);
return FALSE;
}
sz = malloc(patternLen + 3); /* add two in case doing whole words only */
if (cmd > 1) {
strcpy(sz, " ");
strcat(sz, pattern);
strcat(sz, " ");
} else
strcpy(sz, pattern);
if ((cmd == 0) || (cmd == 2)) {
for (i = 0; i < strlen(sz); i++)
sz[i] = toupper(sz[i]);
for (i = 0; i < retstr.strlength; i++)
retstr.strptr[i] = toupper(retstr.strptr[i]);
}
for (i = 0; i < (retstr.strlength - patternLen); i++) {
p = &retstr.strptr[i];
compare = TRUE;
for (j = 0; j < patternLen; j++) {
/* We cannot do strncmp here, as we may be dealing with a
* "binary" file, such as a word processing file, or perhaps
* even a true executable of some sort. */
if (p[j] != sz[j]) {
compare = FALSE;
break;
}
}
if (compare == TRUE) {
retcode = TRUE;
break;
}
}
free(sz);
free(retstr.strptr);
return retcode;
}
#endif /* !WINDLL */
#endif /* !__16BIT__ */
int UZ_EXP UzpValidate(char *archive, int AllCodes)
{
int retcode;
CONSTRUCTGLOBALS();
uO.jflag = 1;
uO.tflag = 1;
uO.overwrite_none = 0;
G.extract_flag = (!uO.zipinfo_mode &&
!uO.cflag && !uO.tflag && !uO.vflag && !uO.zflag
#ifdef TIMESTAMP
&& !uO.T_flag
#endif
);
uO.qflag = 2; /* turn off all messages */
G.fValidate = TRUE;
G.pfnames = (char **)&fnames[0]; /* assign default filename vector */
#ifdef WINDLL
Wiz_NoPrinting(TRUE);
#endif
if (archive == NULL) { /* something is screwed up: no filename */
DESTROYGLOBALS();
return PK_NOZIP;
}
G.wildzipfn = (char *)malloc(FILNAMSIZ + 1);
strcpy(G.wildzipfn, archive);
#if (defined(WINDLL) && !defined(CRTL_CP_IS_ISO))
_ISO_INTERN(G.wildzipfn);
#endif
G.process_all_files = TRUE; /* for speed */
retcode = setjmp(dll_error_return);
if (retcode) {
#ifdef WINDLL
Wiz_NoPrinting(FALSE);
#endif
free(G.wildzipfn);
DESTROYGLOBALS();
return PK_BADERR;
}
retcode = process_zipfiles(__G);
free(G.wildzipfn);
#ifdef WINDLL
Wiz_NoPrinting(FALSE);
#endif
DESTROYGLOBALS();
/* PK_WARN == 1 and PK_FIND == 11. When we are just looking at an
archive, we should still be able to see the files inside it,
even if we can't decode them for some reason.
We also still want to be able to get at files even if there is
something odd about the zip archive, hence allow PK_WARN,
PK_FIND, IZ_UNSUP as well as PK_ERR
*/
if (AllCodes)
return retcode;
if ((retcode == PK_OK) || (retcode == PK_WARN) || (retcode == PK_ERR) ||
(retcode == IZ_UNSUP) || (retcode == PK_FIND))
return TRUE;
else
return FALSE;
}
#endif /* DLL */

View File

@@ -0,0 +1,147 @@
/* apihelp.c */
#ifdef API_DOC
#define UNZIP_INTERNAL
#include "unzip.h"
#include "version.h"
APIDocStruct APIDoc[] = {
{
"UZPVERSION" , "UzpVersion" ,
"UzpVer *UzpVersion(void);",
"Get version numbers of the API and the underlying UnZip code.\n\n"
"\t\tThis is used for comparing the version numbers of the run-time\n"
"\t\tDLL code with those expected from the unzip.h at compile time.\n"
"\t\tIf the version numbers do not match, there may be compatibility\n"
"\t\tproblems with further use of the DLL.\n\n"
" Example:\t/* Check the major version number of the DLL code. */\n"
"\t\tUzpVer *pVersion;\n"
"\t\tpVersion = UzpVersion();\n"
"\t\tif (pVersion->unzip.major != UZ_MAJORVER)\n"
"\t\t fprintf(stderr, \"error: using wrong version of DLL\\n\");\n\n"
"\t\tSee unzip.h for details and unzipstb.c for an example.\n"
},
{
"UZPMAIN" , "UzpMain" ,
"int UzpMain(int argc, char *argv[]);",
"Provide a direct entry point to the command line interface.\n\n"
"\t\tThis is used by the UnZip stub but you can use it in your\n"
"\t\town program as well. Output is sent to stdout.\n"
"\t\t0 on return indicates success.\n\n"
" Example:\t/* Extract 'test.zip' silently, junking paths. */\n"
"\t\tchar *argv[] = { \"-q\", \"-j\", \"test.zip\" };\n"
"\t\tint argc = 3;\n"
"\t\tif (UzpMain(argc,argv))\n"
"\t\t printf(\"error: unzip failed\\n\");\n\n"
"\t\tSee unzip.h for details.\n"
},
{
"UZPALTMAIN" , "UzpAltMain" ,
"int UzpAltMain(int argc, char *argv[], UzpInit *init);",
"Provide a direct entry point to the command line interface,\n"
"optionally installing replacement I/O handler functions.\n\n"
"\t\tAs with UzpMain(), output is sent to stdout by default.\n"
"\t\t`InputFn *inputfn' is not yet implemented. 0 on return\n"
"\t\tindicates success.\n\n"
" Example:\t/* Replace normal output and `more' functions. */\n"
"\t\tchar *argv[] = { \"-q\", \"-j\", \"test.zip\" };\n"
"\t\tint argc = 3;\n"
"\t\tUzpInit init = { 16, MyMessageFn, NULL, MyPauseFn };\n"
"\t\tif (UzpAltMain(argc,argv,&init))\n"
"\t\t printf(\"error: unzip failed\\n\");\n\n"
"\t\tSee unzip.h for details.\n"
},
{
"UZPUNZIPTOMEMORY", "UzpUnzipToMemory",
"int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);",
"Pass the name of the zip file and the name of the file\n"
"\t\tyou wish to extract. UzpUnzipToMemory will create a\n"
"\t\tbuffer and return it in *retstr; 0 on return indicates\n"
"\t\tfailure.\n\n"
"\t\tSee unzip.h for details.\n"
},
{
"UZPFILETREE", "UzpFileTree",
"int UzpFileTree(char *name, cbList(callBack),\n"
"\t\t\tchar *cpInclude[], char *cpExclude[]);",
"Pass the name of the zip file, a callback function, an\n"
"\t\tinclude and exclude file list. UzpFileTree calls the\n"
"\t\tcallback for each valid file found in the zip file.\n"
"\t\t0 on return indicates failure.\n\n"
"\t\tSee unzip.h for details.\n"
},
{ 0 }
};
static int function_help OF((__GPRO__ APIDocStruct *doc, char *fname));
static int function_help(__G__ doc, fname)
__GDEF
APIDocStruct *doc;
char *fname;
{
strcpy(slide, fname);
/* strupr(slide); non-standard */
while (doc->compare && STRNICMP(doc->compare,slide,strlen(fname)))
doc++;
if (!doc->compare)
return 0;
else
Info(slide, 0, ((char *)slide,
" Function:\t%s\n\n Syntax:\t%s\n\n Purpose:\t%s",
doc->function, doc->syntax, doc->purpose));
return 1;
}
void APIhelp(__G__ argc, argv)
__GDEF
int argc;
char **argv;
{
if (argc > 1) {
struct APIDocStruct *doc;
if (function_help(__G__ APIDoc, argv[1]))
return;
#ifdef SYSTEM_API_DETAILS
if (function_help(__G__ SYSTEM_API_DETAILS, argv[1]))
return;
#endif
Info(slide, 0, ((char *)slide,
"%s is not a documented command.\n\n", argv[1]));
}
Info(slide, 0, ((char *)slide, "\
This API provides a number of external C and REXX functions for handling\n\
zipfiles in OS/2. Programmers are encouraged to expand this API.\n\
\n\
C functions: -- See unzip.h for details\n\
UzpVer *UzpVersion(void);\n\
int UzpMain(int argc, char *argv[]);\n\
int UzpAltMain(int argc, char *argv[], UzpInit *init);\n\
int UzpUnzipToMemory(char *zip, char *file, UzpBuffer *retstr);\n\
int UzpFileTree(char *name, cbList(callBack),\n\
char *cpInclude[], char *cpExclude[]);\n\n"));
#ifdef SYSTEM_API_BRIEF
Info(slide, 0, ((char *)slide, SYSTEM_API_BRIEF));
#endif
Info(slide, 0, ((char *)slide,
"\nFor more information, type 'unzip -A <function-name>'\n"));
}
#endif /* API_DOC */

View File

@@ -0,0 +1,56 @@
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id$ */
#define __CRC32_C /* identifies this source module */
#include "zip.h"
#ifndef USE_ZLIB
#ifndef ASM_CRC
#ifndef ZCONST
# define ZCONST const
#endif
#ifdef CRC32
# undef CRC32
#endif
#define CRC32(c, b) (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
#define DO1(buf) crc = CRC32(crc, *buf++)
#define DO2(buf) DO1(buf); DO1(buf)
#define DO4(buf) DO2(buf); DO2(buf)
#define DO8(buf) DO4(buf); DO4(buf)
/* ========================================================================= */
ulg crc32(crc, buf, len)
register ulg crc; /* crc shift register */
register ZCONST uch *buf; /* pointer to bytes to pump through */
extent len; /* number of bytes in buf[] */
/* Run a set of bytes through the crc shift register. If buf is a NULL
pointer, then initialize the crc shift register contents instead.
Return the current crc in either case. */
{
register ZCONST ulg near *crc_table;
if (buf == NULL) return 0L;
crc_table = get_crc_table();
crc = crc ^ 0xffffffffL;
#ifndef NO_UNROLLED_LOOPS
while (len >= 8) {
DO8(buf);
len -= 8;
}
#endif
if (len) do {
DO1(buf);
} while (--len);
return crc ^ 0xffffffffL; /* (instead of ~c for 64-bit machines) */
}
#endif /* !ASM_CRC */
#endif /* !USE_ZLIB */

View File

@@ -0,0 +1,230 @@
/*
* crc_i386.S, optimized CRC calculation function for Zip and UnZip, not
* copyrighted by Paul Kienitz and Christian Spieler. Last revised 12 Oct 97.
*
* GRR 961110: incorporated Scott Field optimizations from win32/crc_i386.asm
* => overall 6% speedup in "unzip -tq" on 9MB zipfile (486-66)
*
* SPC 970402: revised for Rodney Brown's optimizations (32-bit-wide
* aligned reads for most of the data from buffer), can be
* disabled by defining the macro NO_32_BIT_LOADS
*
* SPC 971012: added Rodney Brown's additional tweaks for 32-bit-optimized
* CPUs (like the Pentium Pro, Pentium II, and probably some
* Pentium clones). This optimization is controlled by the
* preprocessor switch "__686" and is disabled by default.
* (This default is based on the assumption that most users
* do not yet work on a Pentium Pro or Pentium II machine ...)
*
* FLAT memory model assumed. Calling interface:
* - args are pushed onto the stack from right to left,
* - return value is given in the EAX register,
* - all other registers (with exception of EFLAGS) are preserved. (With
* GNU C 2.7.x, %edx and %ecx are `scratch' registers, but preserving
* them nevertheless adds only 4 single byte instructions.)
*
* This source generates the function
* ulg crc32(ulg crc, ZCONST uch *buf, ulg len).
*
* The loop unrolling can be disabled by defining the macro NO_UNROLLED_LOOPS.
* This results in shorter code at the expense of reduced performance.
*/
/* This file is NOT used in conjunction with zlib. */
#ifndef USE_ZLIB
/* Preprocess with -DNO_UNDERLINE if your C compiler does not prefix
* external symbols with an underline character '_'.
*/
#if defined(NO_UNDERLINE) || defined(__ELF__)
# define _crc32 crc32
# define _get_crc_table get_crc_table
#endif
/* Use 16-byte alignment if your assembler supports it. Warning: gas
* uses a log(x) parameter (.align 4 means 16-byte alignment). On SVR4
* the parameter is a number of bytes.
*/
#ifndef ALIGNMENT
# define ALIGNMENT .align 4,0x90
#endif
#if defined(i386) || defined(_i386) || defined(_I386) || defined(__i386)
/* This version is for 386 Unix, OS/2, MSDOS in 32 bit mode (gcc & gas).
* Warning: it uses the AT&T syntax: mov source,dest
* This file is only optional. If you want to use the C version,
* remove -DASM_CRC from CFLAGS in Makefile and set OBJA to an empty string.
*/
.file "crc_i386.S"
#if defined(NO_STD_STACKFRAME) && defined(USE_STD_STACKFRAME)
# undef USE_STACKFRAME
#else
/* The default is to use standard stack frame entry, because it
* results in smaller code!
*/
# ifndef USE_STD_STACKFRAME
# define USE_STD_STACKFRAME
# endif
#endif
#ifdef USE_STD_STACKFRAME
# define _STD_ENTRY pushl %ebp ; movl %esp,%ebp
# define arg1 8(%ebp)
# define arg2 12(%ebp)
# define arg3 16(%ebp)
# define _STD_LEAVE popl %ebp
#else /* !USE_STD_STACKFRAME */
# define _STD_ENTRY
# define arg1 24(%esp)
# define arg2 28(%esp)
# define arg3 32(%esp)
# define _STD_LEAVE
#endif /* ?USE_STD_STACKFRAME */
/*
* These two (three) macros make up the loop body of the CRC32 cruncher.
* registers modified:
* eax : crc value "c"
* esi : pointer to next data byte (or lword) "buf++"
* registers read:
* edi : pointer to base of crc_table array
* scratch registers:
* ebx : index into crc_table array
* (requires upper three bytes = 0 when __686 is undefined)
*/
#ifndef __686 /* optimize for 386, 486, Pentium */
#define Do_CRC /* c = (c >> 8) ^ table[c & 0xFF] */\
movb %al, %bl ;/* tmp = c & 0xFF */\
shrl $8, %eax ;/* c = (c >> 8) */\
xorl (%edi, %ebx, 4), %eax ;/* c ^= table[tmp] */
#else /* __686 : optimize for Pentium Pro and compatible CPUs */
#define Do_CRC /* c = (c >> 8) ^ table[c & 0xFF] */\
movzbl %al, %ebx ;/* tmp = c & 0xFF */\
shrl $8, %eax ;/* c = (c >> 8) */\
xorl (%edi, %ebx, 4), %eax ;/* c ^=table[tmp] */
#endif /* ?__686 */
#define Do_CRC_byte /* c = (c >> 8) ^ table[(c^*buf++)&0xFF] */\
xorb (%esi), %al ;/* c ^= *buf */\
incl %esi ;/* buf++ */\
Do_CRC
#ifndef NO_32_BIT_LOADS
#define Do_CRC_lword \
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */\
addl $4, %esi ;/* ((ulg *)buf)++ */\
Do_CRC \
Do_CRC \
Do_CRC \
Do_CRC
#endif /* !NO_32_BIT_LOADS */
.text
.globl _crc32
_crc32: /* ulg crc32(ulg crc, uch *buf, extent len) */
_STD_ENTRY
pushl %edi
pushl %esi
pushl %ebx
pushl %edx
pushl %ecx
movl arg2, %esi /* 2nd arg: uch *buf */
subl %eax, %eax /* > if (!buf) */
testl %esi, %esi /* > return 0; */
jz .L_fine /* > else { */
call _get_crc_table
movl %eax, %edi
movl arg1, %eax /* 1st arg: ulg crc */
#ifndef __686
subl %ebx, %ebx /* ebx=0; bl usable as dword */
#endif
movl arg3, %ecx /* 3rd arg: extent len */
notl %eax /* > c = ~crc; */
#ifndef NO_UNROLLED_LOOPS
# ifndef NO_32_BIT_LOADS
testl %ecx, %ecx
jz .L_bail
/* Assert now have positive length */
.L_align_loop:
testl $3, %esi /* Align buf on lword boundary */
jz .L_aligned_now
Do_CRC_byte
decl %ecx
jnz .L_align_loop
.L_aligned_now:
# endif /* !NO_32_BIT_LOADS */
movl %ecx, %edx /* save len in edx */
andl $7, %edx /* edx = len % 8 */
shrl $3, %ecx /* ecx = len / 8 */
jz .L_No_Eights
/* align loop head at start of 486 internal cache line !! */
ALIGNMENT
.L_Next_Eight:
# ifndef NO_32_BIT_LOADS
/* Do_CRC_lword */
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */
addl $4, %esi ;/* ((ulg *)buf)++ */
Do_CRC
Do_CRC
Do_CRC
Do_CRC
/* Do_CRC_lword */
xorl (%esi), %eax ;/* c ^= *(ulg *)buf */
addl $4, %esi ;/* ((ulg *)buf)++ */
Do_CRC
Do_CRC
Do_CRC
Do_CRC
# else /* NO_32_BIT_LOADS */
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
# endif /* ?NO_32_BIT_LOADS */
decl %ecx
jnz .L_Next_Eight
.L_No_Eights:
movl %edx, %ecx
#endif /* NO_UNROLLED_LOOPS */
#ifndef NO_JECXZ_SUPPORT
jecxz .L_bail /* > if (len) */
#else
testl %ecx, %ecx /* > if (len) */
jz .L_bail
#endif
/* align loop head at start of 486 internal cache line !! */
ALIGNMENT
.L_loupe: /* > do { */
Do_CRC_byte /* c = CRC32(c, *buf++); */
decl %ecx /* > } while (--len); */
jnz .L_loupe
.L_bail: /* > } */
notl %eax /* > return ~c; */
.L_fine:
popl %ecx
popl %edx
popl %ebx
popl %esi
popl %edi
_STD_LEAVE
ret
#else
error: this asm version is for 386 only
#endif /* i386 || _i386 || _I386 || __i386 */
#endif /* !USE_ZLIB */

View File

@@ -0,0 +1,229 @@
; crc_i386.asm, optimized CRC calculation function for Zip and UnZip, not
; copyrighted by Paul Kienitz and Christian Spieler. Last revised 25 Mar 98.
;
; Revised 06-Oct-96, Scott Field (sfield@microsoft.com)
; fixed to assemble with masm by not using .model directive which makes
; assumptions about segment alignment. Also,
; avoid using loop, and j[e]cxz where possible. Use mov + inc, rather
; than lodsb, and other misc. changes resulting in the following performance
; increases:
;
; unrolled loops NO_UNROLLED_LOOPS
; *8 >8 <8 *8 >8 <8
;
; +54% +42% +35% +82% +52% +25%
;
; first item in each table is input buffer length, even multiple of 8
; second item in each table is input buffer length, > 8
; third item in each table is input buffer length, < 8
;
; Revised 02-Apr-97, Chr. Spieler, based on Rodney Brown (rdb@cmutual.com.au)
; Incorporated Rodney Brown's 32-bit-reads optimization as found in the
; UNIX AS source crc_i386.S. This new code can be disabled by defining
; the macro symbol NO_32_BIT_LOADS.
;
; Revised 12-Oct-97, Chr. Spieler, based on Rodney Brown (rdb@cmutual.com.au)
; Incorporated Rodney Brown's additional tweaks for 32-bit-optimized CPUs
; (like the Pentium Pro, Pentium II, and probably some Pentium clones).
; This optimization is controlled by the macro symbol __686 and is disabled
; by default. (This default is based on the assumption that most users
; do not yet work on a Pentium Pro or Pentium II machine ...)
;
; FLAT memory model assumed.
;
; The loop unrolling can be disabled by defining the macro NO_UNROLLED_LOOPS.
; This results in shorter code at the expense of reduced performance.
;
; Revised 25-Mar-98, Cosmin Truta (cosmint@cs.ubbcluj.ro)
; Working without .model directive caused tasm32 version 5.0 to produce
; bad object code. The optimized alignments can be optionally disabled
; by defining NO_ALIGN, thus allowing to use .model flat. There is no need
; to define this macro if using other version of tasm.
;
;==============================================================================
;
; Do NOT assemble this source if external crc32 routine from zlib gets used.
;
IFNDEF USE_ZLIB
;
.386p
name crc_i386
IFDEF NO_ALIGN
.model flat
ENDIF
extrn _get_crc_table:near ; ZCONST ulg near *get_crc_table(void);
;
IFNDEF NO_STD_STACKFRAME
; Use a `standard' stack frame setup on routine entry and exit.
; Actually, this option is set as default, because it results
; in smaller code !!
STD_ENTRY MACRO
push ebp
mov ebp,esp
ENDM
Arg1 EQU 08H[ebp]
Arg2 EQU 0CH[ebp]
Arg3 EQU 10H[ebp]
STD_LEAVE MACRO
pop ebp
ENDM
ELSE ; NO_STD_STACKFRAME
STD_ENTRY MACRO
ENDM
Arg1 EQU 18H[esp]
Arg2 EQU 1CH[esp]
Arg3 EQU 20H[esp]
STD_LEAVE MACRO
ENDM
ENDIF ; ?NO_STD_STACKFRAME
; These two (three) macros make up the loop body of the CRC32 cruncher.
; registers modified:
; eax : crc value "c"
; esi : pointer to next data byte (or dword) "buf++"
; registers read:
; edi : pointer to base of crc_table array
; scratch registers:
; ebx : index into crc_table array
; (requires upper three bytes = 0 when __686 is undefined)
IFNDEF __686 ; optimize for 386, 486, Pentium
Do_CRC MACRO
mov bl,al ; tmp = c & 0xFF
shr eax,8 ; c = (c >> 8)
xor eax,[edi+ebx*4] ; ^ table[tmp]
ENDM
ELSE ; __686 : optimize for Pentium Pro, Pentium II and compatible CPUs
Do_CRC MACRO
movzx ebx,al ; tmp = c & 0xFF
shr eax,8 ; c = (c >> 8)
xor eax,[edi+ebx*4] ; ^ table[tmp]
ENDM
ENDIF ; ?__686
Do_CRC_byte MACRO
xor al, byte ptr [esi] ; c ^= *buf
inc esi ; buf++
Do_CRC ; c = (c >> 8) ^ table[c & 0xFF]
ENDM
IFNDEF NO_32_BIT_LOADS
Do_CRC_dword MACRO
xor eax, dword ptr [esi] ; c ^= *(ulg *)buf
add esi, 4 ; ((ulg *)buf)++
Do_CRC
Do_CRC
Do_CRC
Do_CRC
ENDM
ENDIF ; !NO_32_BIT_LOADS
IFNDEF NO_ALIGN
_TEXT segment use32 para public 'CODE'
ELSE
_TEXT segment use32
ENDIF
assume CS: _TEXT
public _crc32
_crc32 proc near ; ulg crc32(ulg crc, ZCONST uch *buf, extent len)
STD_ENTRY
push edi
push esi
push ebx
push edx
push ecx
mov esi,Arg2 ; 2nd arg: uch *buf
sub eax,eax ;> if (!buf)
test esi,esi ;> return 0;
jz fine ;> else {
call _get_crc_table
mov edi,eax
mov eax,Arg1 ; 1st arg: ulg crc
IFNDEF __686
sub ebx,ebx ; ebx=0; make bl usable as a dword
ENDIF
mov ecx,Arg3 ; 3rd arg: extent len
not eax ;> c = ~crc;
IFNDEF NO_UNROLLED_LOOPS
IFNDEF NO_32_BIT_LOADS
test ecx,ecx
je bail
align_loop:
test esi,3 ; align buf pointer on next
jz SHORT aligned_now ; dword boundary
Do_CRC_byte
dec ecx
jnz align_loop
aligned_now:
ENDIF ; !NO_32_BIT_LOADS
mov edx,ecx ; save len in edx
and edx,000000007H ; edx = len % 8
shr ecx,3 ; ecx = len / 8
jz SHORT No_Eights
IFNDEF NO_ALIGN
; align loop head at start of 486 internal cache line !!
align 16
ENDIF
Next_Eight:
IFNDEF NO_32_BIT_LOADS
Do_CRC_dword
Do_CRC_dword
ELSE ; NO_32_BIT_LOADS
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
Do_CRC_byte
ENDIF ; ?NO_32_BIT_LOADS
dec ecx
jnz Next_Eight
No_Eights:
mov ecx,edx
ENDIF ; NO_UNROLLED_LOOPS
IFNDEF NO_JECXZ_SUPPORT
jecxz bail ;> if (len)
ELSE
test ecx,ecx ;> if (len)
jz SHORT bail
ENDIF
IFNDEF NO_ALIGN
; align loop head at start of 486 internal cache line !!
align 16
ENDIF
loupe: ;> do {
Do_CRC_byte ; c = CRC32(c, *buf++);
dec ecx ;> } while (--len);
jnz loupe
bail: ;> }
not eax ;> return ~c;
fine:
pop ecx
pop edx
pop ebx
pop esi
pop edi
STD_LEAVE
ret
_crc32 endp
_TEXT ends
;
ENDIF ; !USE_ZLIB
;
end

View File

@@ -0,0 +1,215 @@
/* crc_i386.c -- Microsoft 32-bit C/C++ adaptation of crc_i386.asm
* Created by Rodney Brown from crc_i386.asm, modified by Chr. Spieler.
* Last revised: 22-Mai-1998
*
* Original coded (in crc_i386.asm) and put into the public domain
* by Paul Kienitz and Christian Spieler.
*
* Revised 06-Oct-96, Scott Field (sfield@microsoft.com)
* fixed to assemble with masm by not using .model directive which makes
* assumptions about segment alignment. Also,
* avoid using loop, and j[e]cxz where possible. Use mov + inc, rather
* than lodsb, and other misc. changes resulting in the following performance
* increases:
*
* unrolled loops NO_UNROLLED_LOOPS
* *8 >8 <8 *8 >8 <8
*
* +54% +42% +35% +82% +52% +25%
*
* first item in each table is input buffer length, even multiple of 8
* second item in each table is input buffer length, > 8
* third item in each table is input buffer length, < 8
*
* Revised 02-Apr-97, Chr. Spieler, based on Rodney Brown (rdb@cmutual.com.au)
* Incorporated Rodney Brown's 32-bit-reads optimization as found in the
* UNIX AS source crc_i386.S. This new code can be disabled by defining
* the macro symbol NO_32_BIT_LOADS.
*
* Revised 12-Oct-97, Chr. Spieler, based on Rodney Brown (rdb@cmutual.com.au)
* Incorporated Rodney Brown's additional tweaks for 32-bit-optimized CPUs
* (like the Pentium Pro, Pentium II, and probably some Pentium clones).
* This optimization is controlled by the macro symbol __686 and is disabled
* by default. (This default is based on the assumption that most users
* do not yet work on a Pentium Pro or Pentium II machine ...)
*
* Revised 16-Nov-97, Chr. Spieler: Made code compatible with Borland C++
* 32-bit, removed unneeded kludge for potentially unknown movzx mnemonic,
* confirmed correct working with MS VC++ (32-bit).
*
* Revised 22-Mai-98, Peter Kunath, Chr. Spieler : The 16-Nov-97 revision broke
* MSVC 5.0. Inside preprocessor macros, each instruction is enclosed in its
* own __asm {...} construct. For MSVC, a "#pragma warning" was added to
* shut up the "no return value" warning message.
*
* FLAT memory model assumed.
*
* The loop unrolling can be disabled by defining the macro NO_UNROLLED_LOOPS.
* This results in shorter code at the expense of reduced performance.
*
*/
#include "zip.h"
#ifndef USE_ZLIB
#ifndef ZCONST
# define ZCONST const
#endif
/* Select wether the following inline-assember code is supported. */
#if (defined(_MSC_VER) && _MSC_VER >= 700)
#if (defined(_M_IX86) && _M_IX86 >= 300)
# define MSC_INLINE_ASM_32BIT_SUPPORT
/* Disable warning for no return value, typical of asm functions */
# pragma warning( disable : 4035 )
#endif
#endif
#if (defined(__BORLANDC__) && __BORLANDC__ >= 452)
# define MSC_INLINE_ASM_32BIT_SUPPORT
#endif
#ifdef MSC_INLINE_ASM_32BIT_SUPPORT
/* This code is intended for Microsoft C/C++ (32-bit) compatible compilers. */
/*
* These two (three) macros make up the loop body of the CRC32 cruncher.
* registers modified:
* eax : crc value "c"
* esi : pointer to next data byte (or dword) "buf++"
* registers read:
* edi : pointer to base of crc_table array
* scratch registers:
* ebx : index into crc_table array
* (requires upper three bytes = 0 when __686 is undefined)
*/
#ifndef __686
#define Do_CRC { \
__asm { mov bl, al }; \
__asm { shr eax, 8 }; \
__asm { xor eax, [edi+ebx*4] }; }
#else /* __686 */
#define Do_CRC { \
__asm { movzx ebx, al }; \
__asm { shr eax, 8 }; \
__asm { xor eax, [edi+ebx*4] }; }
#endif /* ?__686 */
#define Do_CRC_byte { \
__asm { xor al, byte ptr [esi] }; \
__asm { inc esi }; \
Do_CRC; }
#ifndef NO_32_BIT_LOADS
#define Do_CRC_dword { \
__asm { xor eax, dword ptr [esi] }; \
__asm { add esi, 4 }; \
Do_CRC; \
Do_CRC; \
Do_CRC; \
Do_CRC; }
#endif /* !NO_32_BIT_LOADS */
/* ========================================================================= */
ulg crc32(crc, buf, len)
ulg crc; /* crc shift register */
ZCONST uch *buf; /* pointer to bytes to pump through */
extent len; /* number of bytes in buf[] */
/* Run a set of bytes through the crc shift register. If buf is a NULL
pointer, then initialize the crc shift register contents instead.
Return the current crc in either case. */
{
__asm {
push edx
push ecx
mov esi,buf ;/* 2nd arg: uch *buf */
sub eax,eax ;/*> if (!buf) */
test esi,esi ;/*> return 0; */
jz fine ;/*> else { */
call get_crc_table
mov edi,eax
mov eax,crc ;/* 1st arg: ulg crc */
#ifndef __686
sub ebx,ebx ;/* ebx=0; => bl usable as a dword */
#endif
mov ecx,len ;/* 3rd arg: extent len */
not eax ;/*> c = ~crc; */
#ifndef NO_UNROLLED_LOOPS
# ifndef NO_32_BIT_LOADS
test ecx,ecx
je bail
align_loop:
test esi,3 ;/* align buf pointer on next */
jz aligned_now ;/* dword boundary */
}
Do_CRC_byte ;
__asm {
dec ecx
jnz align_loop
aligned_now:
# endif /* !NO_32_BIT_LOADS */
mov edx,ecx ;/* save len in edx */
and edx,000000007H ;/* edx = len % 8 */
shr ecx,3 ;/* ecx = len / 8 */
jz No_Eights
; align loop head at start of 486 internal cache line !!
align 16
Next_Eight:
}
# ifndef NO_32_BIT_LOADS
Do_CRC_dword ;
Do_CRC_dword ;
# else /* NO_32_BIT_LOADS */
Do_CRC_byte ;
Do_CRC_byte ;
Do_CRC_byte ;
Do_CRC_byte ;
Do_CRC_byte ;
Do_CRC_byte ;
Do_CRC_byte ;
Do_CRC_byte ;
# endif /* ?NO_32_BIT_LOADS */
__asm {
dec ecx
jnz Next_Eight
No_Eights:
mov ecx,edx
#endif /* NO_UNROLLED_LOOPS */
#ifndef NO_JECXZ_SUPPORT
jecxz bail ;/*> if (len) */
#else
test ecx,ecx ;/*> if (len) */
jz bail
#endif
; align loop head at start of 486 internal cache line !!
align 16
loupe: ;/*> do { */
}
Do_CRC_byte ;/* c = CRC32(c, *buf++); */
__asm {
dec ecx ;/*> } while (--len); */
jnz loupe
bail: ;/*> } */
not eax ;/*> return ~c; */
fine:
pop ecx
pop edx
}
#ifdef NEED_RETURN
return _EAX;
#endif
}
#endif /* MSC_INLINE_ASM_32BIT_SUPPORT */
#if (defined(_MSC_VER) && _MSC_VER >= 700)
#if (defined(_M_IX86) && _M_IX86 >= 300)
/* Reenable missing return value warning */
# pragma warning( default : 4035 )
#endif
#endif
#endif /* !USE_ZLIB */

View File

@@ -0,0 +1,108 @@
; crc_lcc.asm, optimized CRC calculation function for Zip and UnZip, not
; copyrighted by Paul Kienitz and Christian Spieler. Last revised 25 Mar 98.
;
; The code in this file has been copied verbatim from crc_i386.{asm|S};
; only the assembler syntax and metacommands have been adapted to
; the habits of the free LCC-Win32 C compiler package.
; This version of the code uses the "optimized for i686" variant of
; crc_i386.{asm|S}.
;
; For more information (and a revision log), look into the original
; source files.
;
.text
.file "crc32.c"
.text
.type _crc32,function
_crc32:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %ebx
pushl %esi
pushl %edi
.line 34
.line 37
movl 12(%ebp),%esi
subl %eax,%eax
testl %esi,%esi
jz _$3
.line 39
call _get_crc_table
movl %eax,%edi
.line 41
movl 8(%ebp),%eax
movl 16(%ebp),%ecx
notl %eax
testl %ecx,%ecx
jz _$4
_$5:
testl $3,%esi
jz _$6
xorb (%esi),%al
incl %esi
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
decl %ecx
jnz _$5
_$6:
movl %ecx,%edx
andl $7,%edx
shrl $3,%ecx
jz _$8
_$7:
xorl (%esi),%eax
addl $4,%esi
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
xorl (%esi),%eax
addl $4,%esi
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
decl %ecx
jnz _$7
_$8:
movl %edx,%ecx
jecxz _$4
_$9:
xorb (%esi),%al
incl %esi
movzbl %al,%ebx
shrl $8,%eax
xorl (%edi,%ebx,4),%eax
decl %ecx
jnz _$9
_$4:
xorl $0xffffffff,%eax
_$3:
.line 52
popl %edi
popl %esi
popl %ebx
leave
ret
_$34:
.size _crc32,_$34-_crc32
.globl _crc32
.extern _get_crc_table

View File

@@ -0,0 +1,219 @@
/* crctab.c -- supply the CRC table needed for CRC-32 calculations.
* Copyright (C) 1995 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* $Id$ */
/*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
Polynomials over GF(2) are represented in binary, one bit per coefficient,
with the lowest powers in the most significant bit. Then adding polynomials
is just exclusive-or, and multiplying a polynomial by x is a right shift by
one. If we call the above polynomial p, and represent a byte as the
polynomial q, also with the lowest power in the most significant bit (so the
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
where a mod b means the remainder after dividing a by b.
This calculation is done using the shift-register method of multiplying and
taking the remainder. The register is initialized to zero, and for each
incoming bit, x^32 is added mod p to the register if the bit is a one (where
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
x (which is shifting right by one and adding x^32 mod p if the bit shifted
out is a one). We start with the highest power (least significant bit) of
q and repeat for all eight bits of q.
The table is simply the CRC of all possible eight bit values. This is all
the information needed to generate CRC's on data a byte at a time for all
combinations of CRC register values and incoming bytes.
*/
#define __CRCTAB_C /* identifies this source module */
#include "zip.h"
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
#ifndef ZCONST
# define ZCONST const
#endif
#ifdef DYNAMIC_CRC_TABLE
/* =========================================================================
* Make the crc table. This function is needed only if you want to compute
* the table dynamically.
*/
local void make_crc_table OF((void));
#if (defined(DYNALLOC_CRCTAB) && defined(REENTRANT))
error: Dynamic allocation of CRC table not safe with reentrant code.
#endif /* DYNALLOC_CRCTAB && REENTRANT */
#ifdef DYNALLOC_CRCTAB
local ulg near *crc_table = NULL;
# if 0 /* not used, since sizeof("near *") <= sizeof(int) */
/* Use this section when access to a "local int" is faster than access to
a "local pointer" (e.g.: i86 16bit code with far pointers). */
local int crc_table_empty = 1;
# define CRC_TABLE_IS_EMPTY (crc_table_empty != 0)
# define MARK_CRCTAB_FILLED crc_table_empty = 0
# define MARK_CRCTAB_EMPTY crc_table_empty = 1
# else
/* Use this section on systems where the size of pointers and ints is
equal (e.g.: all 32bit systems). */
# define CRC_TABLE_IS_EMPTY (crc_table == NULL)
# define MARK_CRCTAB_FILLED crc_table = crctab_p
# define MARK_CRCTAB_EMPTY crc_table = NULL
# endif
#else /* !DYNALLOC_CRCTAB */
local ulg near crc_table[256];
local int crc_table_empty = 1;
# define CRC_TABLE_IS_EMPTY (crc_table_empty != 0)
# define MARK_CRCTAB_FILLED crc_table_empty = 0
#endif /* ?DYNALLOC_CRCTAB */
local void make_crc_table()
{
ulg c; /* crc shift register */
int n; /* counter for all possible eight bit values */
int k; /* byte being shifted into crc apparatus */
#ifdef DYNALLOC_CRCTAB
ulg near *crctab_p; /* temporary pointer to allocated crc_table area */
#else /* !DYNALLOC_CRCTAB */
# define crctab_p crc_table
#endif /* DYNALLOC_CRCTAB */
#ifdef COMPUTE_XOR_PATTERN
/* This piece of code has been left here to explain how the XOR pattern
* used in the creation of the crc_table values can be recomputed.
* For production versions of this function, it is more efficient to
* supply the resultant pattern at compile time.
*/
ulg xor; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static uch p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* make exclusive-or pattern from polynomial (0xedb88320L) */
xor = 0L;
for (i = 0; i < sizeof(p)/sizeof(uch); i++)
xor |= 1L << (31 - p[i]);
#else
# define xor 0xedb88320L
#endif
#ifdef DYNALLOC_CRCTAB
crctab_p = (ulg near *) nearmalloc (256*sizeof(ulg));
if (crctab_p == NULL) {
ziperr(ZE_MEM, "crc_table allocation");
}
#endif /* DYNALLOC_CRCTAB */
for (n = 0; n < 256; n++) {
c = (ulg)n;
for (k = 8; k; k--)
c = c & 1 ? xor ^ (c >> 1) : c >> 1;
crctab_p[n] = c;
}
MARK_CRCTAB_FILLED;
}
#else /* !DYNAMIC_CRC_TABLE */
#ifdef DYNALLOC_CRCTAB
error: Inconsistent flags, DYNALLOC_CRCTAB without DYNAMIC_CRC_TABLE.
#endif
/* ========================================================================
* Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
local ZCONST ulg near crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
#endif /* ?DYNAMIC_CRC_TABLE */
/* use "OF((void))" here to work around a Borland TC++ 1.0 problem */
#ifdef USE_ZLIB
ZCONST uLongf *get_crc_table OF((void))
#else
ZCONST ulg near *get_crc_table OF((void))
#endif
{
#ifdef DYNAMIC_CRC_TABLE
if (CRC_TABLE_IS_EMPTY)
make_crc_table();
#endif
#ifdef USE_ZLIB
return (ZCONST uLongf *)crc_table;
#else
return (ZCONST ulg near *)crc_table;
#endif
}
#ifdef DYNALLOC_CRCTAB
void free_crc_table()
{
if (!CRC_TABLE_IS_EMPTY)
{
nearfree((ulg near *)crc_table);
MARK_CRCTAB_EMPTY;
}
}
#endif
#endif /* !USE_ZLIB || USE_OWN_CRCTAB */

View File

@@ -0,0 +1,12 @@
/*
crypt.c (dummy version) by Info-ZIP. Last revised: 15 Aug 98
This is a non-functional version of Info-ZIP's crypt.c encryption/
decryption code for Zip, ZipCloak, UnZip and fUnZip. This file is
not copyrighted and may be distributed freely. :-) See the "WHERE"
file for sites from which to obtain the full encryption/decryption
sources (zcrypt28.zip or later).
*/
/* something "externally visible" to shut up compiler/linker warnings */
int zcr_dummy;

View File

@@ -0,0 +1,314 @@
/*----------------------------------------------------------------*
| envargs - add default options from environment to command line
|----------------------------------------------------------------
| Author: Bill Davidsen, original 10/13/91, revised 23 Oct 1991.
| This program is in the public domain.
|----------------------------------------------------------------
| Minor program notes:
| 1. Yes, the indirection is a tad complex
| 2. Parentheses were added where not needed in some cases
| to make the action of the code less obscure.
|----------------------------------------------------------------
| UnZip notes: 24 May 92 ("v1.4"):
| 1. #include "unzip.h" for prototypes (24 May 92)
| 2. changed ch to type char (24 May 92)
| 3. added an ifdef to avoid Borland warnings (24 May 92)
| 4. included Rich Wales' mksargs() routine (for MS-DOS, maybe
| OS/2? NT?) (4 Dec 93)
| 5. added alternate-variable string envstr2 (21 Apr 94)
| 6. added support for quoted arguments (6 Jul 96)
*----------------------------------------------------------------*/
#define ENVARGS_C
#define UNZIP_INTERNAL
#include "unzip.h"
#ifdef __EMX__ /* emx isspace() returns TRUE on extended ASCII !! */
# define ISspace(c) ((c) & 0x80 ? 0 : isspace((unsigned)c))
#else
# define ISspace(c) isspace((unsigned)c)
#endif /* ?__EMX__ */
static int count_args OF((ZCONST char *));
static void mem_err OF((__GPRO));
static ZCONST char Far NoMemArguments[] =
"envargs: cannot get memory for arguments";
void envargs(__G__ Pargc, Pargv, envstr, envstr2)
__GDEF
int *Pargc;
char ***Pargv;
ZCONST char *envstr, *envstr2;
{
#ifndef RISCOS
char *getenv();
#endif
char *envptr; /* value returned by getenv */
char *bufptr; /* copy of env info */
int argc = 0; /* internal arg count */
register int ch; /* spare temp value */
char **argv; /* internal arg vector */
char **argvect; /* copy of vector address */
/* see if anything in the environment */
if ((envptr = getenv(envstr)) != (char *)NULL) /* usual var */
while (ISspace(*envptr)) /* must discard leading spaces */
envptr++;
if (envptr == (char *)NULL || *envptr == '\0')
if ((envptr = getenv(envstr2)) != (char *)NULL) /* alternate var */
while (ISspace(*envptr))
envptr++;
if (envptr == (char *)NULL || *envptr == '\0')
return;
bufptr = malloc(1 + strlen(envptr));
if (bufptr == (char *)NULL)
mem_err(__G);
#if (defined(WIN32) || defined(WINDLL))
# ifdef WIN32
if (IsWinNT()) {
/* SPC: don't know codepage of 'real' WinNT console */
strcpy(bufptr, envptr);
} else {
/* Win95 environment is DOS and uses OEM character coding */
OEM_TO_INTERN(envptr, bufptr);
}
# else /* !WIN32 */
/* DOS environment uses OEM codepage */
OEM_TO_INTERN(envptr, bufptr);
# endif
#else /* !(WIN32 || WINDLL) */
strcpy(bufptr, envptr);
#endif /* ?(WIN32 || WINDLL) */
/* count the args so we can allocate room for them */
argc = count_args(bufptr);
/* allocate a vector large enough for all args */
argv = (char **)malloc((argc + *Pargc + 1) * sizeof(char *));
if (argv == (char **)NULL) {
free(bufptr);
mem_err(__G);
}
argvect = argv;
/* copy the program name first, that's always true */
*(argv++) = *((*Pargv)++);
/* copy the environment args next, may be changed */
do {
#if defined(AMIGA) || defined(UNIX)
if (*bufptr == '"') {
char *argstart = ++bufptr;
*(argv++) = argstart;
for (ch = *bufptr; ch != '\0' && ch != '\"'; ch = *(++bufptr))
if (ch == '\\' && bufptr[1] != '\0')
++bufptr; /* skip char after backslash */
if (ch != '\0')
*(bufptr++) = '\0'; /* overwrite trailing " */
/* remove escape characters */
while ((argstart = strchr(argstart, '\\')) != (char *)NULL) {
strcpy(argstart, argstart + 1);
if (*argstart)
++argstart;
}
} else {
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
}
#else
#ifdef DOS_FLX_OS2_W32
/* we do not support backslash-quoting of quotes in quoted
* strings under DOS_OS2_W32, because backslashes are directory
* separators and double quotes are illegal in filenames */
if (*bufptr == '"') {
*(argv++) = ++bufptr;
while ((ch = *bufptr) != '\0' && ch != '\"')
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
} else {
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
}
#else
*(argv++) = bufptr;
while ((ch = *bufptr) != '\0' && !ISspace(ch))
++bufptr;
if (ch != '\0')
*(bufptr++) = '\0';
#endif /* ?DOS_FLX_OS2_W32 */
#endif /* ?(AMIGA || UNIX) */
while ((ch = *bufptr) != '\0' && ISspace(ch))
++bufptr;
} while (ch);
/* now save old argc and copy in the old args */
argc += *Pargc;
while (--(*Pargc))
*(argv++) = *((*Pargv)++);
/* finally, add a NULL after the last arg, like Unix */
*argv = (char *)NULL;
/* save the values and return */
*Pargv = argvect;
*Pargc = argc;
}
static int count_args(s)
ZCONST char *s;
{
int count = 0;
char ch;
do {
/* count and skip args */
++count;
#if defined(AMIGA) || defined(UNIX)
if (*s == '\"') {
for (ch = *(++s); ch != '\0' && ch != '\"'; ch = *(++s))
if (ch == '\\' && s[1] != '\0')
++s;
if (*s)
++s; /* trailing quote */
} else
#else
#ifdef DOS_FLX_OS2_W32
if (*s == '\"') {
++s; /* leading quote */
while ((ch = *s) != '\0' && ch != '\"')
++s;
if (*s)
++s; /* trailing quote */
} else
#endif /* DOS_FLX_OS2_W32 */
#endif /* ?(AMIGA || UNIX) */
while ((ch = *s) != '\0' && !ISspace(ch)) /* note else-clauses above */
++s;
while ((ch = *s) != '\0' && ISspace(ch))
++s;
} while (ch);
return count;
}
static void mem_err(__G)
__GDEF
{
perror(LoadFarString(NoMemArguments));
DESTROYGLOBALS()
EXIT(PK_MEM);
}
#ifdef TEST
main(argc, argv)
int argc;
char **argv;
{
int i;
pipeit("Orig argv: %p\n", argv);
dump_args(argc, argv);
envargs(__G__ &argc, &argv, "ENVTEST");
pipeit(" New argv: %p\n", argv);
dump_args(argc, argv);
}
dump_args(argc, argv)
int argc;
char *argv[];
{
int i;
pipeit("\nDump %d args:\n", argc);
for (i = 0; i < argc; ++i)
pipeit("%3d %s\n", i, argv[i]);
}
#endif /* TEST */
#ifdef MSDOS /* DOS_OS2? DOS_OS2_W32? */
/*
* void mksargs(int *argcp, char ***argvp)
*
* Substitutes the extended command line argument list produced by
* the MKS Korn Shell in place of the command line info from DOS.
*
* The MKS shell gets around DOS's 128-byte limit on the length of
* a command line by passing the "real" command line in the envi-
* ronment. The "real" arguments are flagged by prepending a tilde
* (~) to each one.
*
* This "mksargs" routine creates a new argument list by scanning
* the environment from the beginning, looking for strings begin-
* ning with a tilde character. The new list replaces the original
* "argv" (pointed to by "argvp"), and the number of arguments
* in the new list replaces the original "argc" (pointed to by
* "argcp").
*
* Rich Wales
*/
void mksargs(argcp, argvp)
int *argcp;
char ***argvp;
{
#ifndef MSC /* declared differently in MSC 7.0 headers, at least */
#ifndef __WATCOMC__
extern char **environ; /* environment */
#endif
#endif
char **envp; /* pointer into environment */
char **newargv; /* new argument list */
char **argp; /* pointer into new arg list */
int newargc; /* new argument count */
/* sanity check */
if (environ == NULL || argcp == NULL || argvp == NULL || *argvp == NULL)
return;
/* find out how many environment arguments there are */
for (envp = environ, newargc = 0; *envp != NULL && (*envp)[0] == '~';
envp++, newargc++)
;
if (newargc == 0)
return; /* no environment arguments */
/* set up new argument list */
newargv = (char **) malloc(sizeof(char **) * (newargc+1));
if (newargv == NULL)
return; /* malloc failed */
for (argp = newargv, envp = environ; *envp != NULL && (*envp)[0] == '~';
*argp++ = &(*envp++)[1])
;
*argp = NULL; /* null-terminate the list */
/* substitute new argument list in place of old one */
*argcp = newargc;
*argvp = newargv;
}
#endif /* MSDOS */

View File

@@ -0,0 +1,871 @@
/* explode.c -- put in the public domain by Mark Adler
version c15, 6 July 1996 */
/* You can do whatever you like with this source file, though I would
prefer that if you modify it and redistribute it that you include
comments to that effect with your name and the date. Thank you.
History:
vers date who what
---- --------- -------------- ------------------------------------
c1 30 Mar 92 M. Adler explode that uses huft_build from inflate
(this gives over a 70% speed improvement
over the original unimplode.c, which
decoded a bit at a time)
c2 4 Apr 92 M. Adler fixed bug for file sizes a multiple of 32k.
c3 10 Apr 92 M. Adler added a little memory tracking if DEBUG
c4 11 Apr 92 M. Adler added NOMEMCPY do kill use of memcpy()
c5 21 Apr 92 M. Adler added the WSIZE #define to allow reducing
the 32K window size for specialized
applications.
c6 31 May 92 M. Adler added typecasts to eliminate some warnings
c7 27 Jun 92 G. Roelofs added more typecasts.
c8 17 Oct 92 G. Roelofs changed ULONG/UWORD/byte to ulg/ush/uch.
c9 19 Jul 93 J. Bush added more typecasts (to return values);
made l[256] array static for Amiga.
c10 8 Oct 93 G. Roelofs added used_csize for diagnostics; added
buf and unshrink arguments to flush();
undef'd various macros at end for Turbo C;
removed NEXTBYTE macro (now in unzip.h)
and bytebuf variable (not used); changed
memset() to memzero().
c11 9 Jan 94 M. Adler fixed incorrect used_csize calculation.
c12 9 Apr 94 G. Roelofs fixed split comments on preprocessor lines
to avoid bug in Encore compiler.
c13 25 Aug 94 M. Adler fixed distance-length comment (orig c9 fix)
c14 22 Nov 95 S. Maxwell removed unnecessary "static" on auto array
c15 6 Jul 96 W. Haidinger added ulg typecasts to flush() calls.
c16 8 Feb 98 C. Spieler added ZCONST modifiers to const tables
and #ifdef DEBUG around debugging code.
c16b 25 Mar 98 C. Spieler modified DLL code for slide redirection.
*/
/*
Explode imploded (PKZIP method 6 compressed) data. This compression
method searches for as much of the current string of bytes (up to a length
of ~320) in the previous 4K or 8K bytes. If it doesn't find any matches
(of at least length 2 or 3), it codes the next byte. Otherwise, it codes
the length of the matched string and its distance backwards from the
current position. Single bytes ("literals") are preceded by a one (a
single bit) and are either uncoded (the eight bits go directly into the
compressed stream for a total of nine bits) or Huffman coded with a
supplied literal code tree. If literals are coded, then the minimum match
length is three, otherwise it is two.
There are therefore four kinds of imploded streams: 8K search with coded
literals (min match = 3), 4K search with coded literals (min match = 3),
8K with uncoded literals (min match = 2), and 4K with uncoded literals
(min match = 2). The kind of stream is identified in two bits of a
general purpose bit flag that is outside of the compressed stream.
Distance-length pairs for matched strings are preceded by a zero bit (to
distinguish them from literals) and are always coded. The distance comes
first and is either the low six (4K) or low seven (8K) bits of the
distance (uncoded), followed by the high six bits of the distance coded.
Then the length is six bits coded (0..63 + min match length), and if the
maximum such length is coded, then it's followed by another eight bits
(uncoded) to be added to the coded length. This gives a match length
range of 2..320 or 3..321 bytes.
The literal, length, and distance codes are all represented in a slightly
compressed form themselves. What is sent are the lengths of the codes for
each value, which is sufficient to construct the codes. Each byte of the
code representation is the code length (the low four bits representing
1..16), and the number of values sequentially with that length (the high
four bits also representing 1..16). There are 256 literal code values (if
literals are coded), 64 length code values, and 64 distance code values,
in that order at the beginning of the compressed stream. Each set of code
values is preceded (redundantly) with a byte indicating how many bytes are
in the code description that follows, in the range 1..256.
The codes themselves are decoded using tables made by huft_build() from
the bit lengths. That routine and its comments are in the inflate.c
module.
*/
#define UNZIP_INTERNAL
#include "unzip.h" /* must supply slide[] (uch) array and NEXTBYTE macro */
#ifndef WSIZE
# define WSIZE 0x8000 /* window size--must be a power of two, and */
#endif /* at least 8K for zip's implode method */
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
# define wsize G._wsize
#else
# define wsize WSIZE
#endif
/* routines here */
static int get_tree OF((__GPRO__ unsigned *l, unsigned n));
static int explode_lit8 OF((__GPRO__ struct huft *tb, struct huft *tl,
struct huft *td, int bb, int bl, int bd));
static int explode_lit4 OF((__GPRO__ struct huft *tb, struct huft *tl,
struct huft *td, int bb, int bl, int bd));
static int explode_nolit8 OF((__GPRO__ struct huft *tl, struct huft *td,
int bl, int bd));
static int explode_nolit4 OF((__GPRO__ struct huft *tl, struct huft *td,
int bl, int bd));
int explode OF((__GPRO));
/* The implode algorithm uses a sliding 4K or 8K byte window on the
uncompressed stream to find repeated byte strings. This is implemented
here as a circular buffer. The index is updated simply by incrementing
and then and'ing with 0x0fff (4K-1) or 0x1fff (8K-1). Here, the 32K
buffer of inflate is used, and it works just as well to always have
a 32K circular buffer, so the index is anded with 0x7fff. This is
done to allow the window to also be used as the output buffer. */
/* This must be supplied in an external module useable like "uch slide[8192];"
or "uch *slide;", where the latter would be malloc'ed. In unzip, slide[]
is actually a 32K area for use by inflate, which uses a 32K sliding window.
*/
/* Tables for length and distance */
static ZCONST ush cplen2[] =
{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};
static ZCONST ush cplen3[] =
{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};
static ZCONST ush extra[] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8};
static ZCONST ush cpdist4[] =
{1, 65, 129, 193, 257, 321, 385, 449, 513, 577, 641, 705,
769, 833, 897, 961, 1025, 1089, 1153, 1217, 1281, 1345, 1409, 1473,
1537, 1601, 1665, 1729, 1793, 1857, 1921, 1985, 2049, 2113, 2177,
2241, 2305, 2369, 2433, 2497, 2561, 2625, 2689, 2753, 2817, 2881,
2945, 3009, 3073, 3137, 3201, 3265, 3329, 3393, 3457, 3521, 3585,
3649, 3713, 3777, 3841, 3905, 3969, 4033};
static ZCONST ush cpdist8[] =
{1, 129, 257, 385, 513, 641, 769, 897, 1025, 1153, 1281,
1409, 1537, 1665, 1793, 1921, 2049, 2177, 2305, 2433, 2561, 2689,
2817, 2945, 3073, 3201, 3329, 3457, 3585, 3713, 3841, 3969, 4097,
4225, 4353, 4481, 4609, 4737, 4865, 4993, 5121, 5249, 5377, 5505,
5633, 5761, 5889, 6017, 6145, 6273, 6401, 6529, 6657, 6785, 6913,
7041, 7169, 7297, 7425, 7553, 7681, 7809, 7937, 8065};
/* Macros for inflate() bit peeking and grabbing.
The usage is:
NEEDBITS(j)
x = b & mask_bits[j];
DUMPBITS(j)
where NEEDBITS makes sure that b has at least j bits in it, and
DUMPBITS removes the bits from b. The macros use the variable k
for the number of bits in b. Normally, b and k are register
variables for speed.
*/
#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE)<<k;k+=8;}}
#define DUMPBITS(n) {b>>=(n);k-=(n);}
static int get_tree(__G__ l, n)
__GDEF
unsigned *l; /* bit lengths */
unsigned n; /* number expected */
/* Get the bit lengths for a code representation from the compressed
stream. If get_tree() returns 4, then there is an error in the data.
Otherwise zero is returned. */
{
unsigned i; /* bytes remaining in list */
unsigned k; /* lengths entered */
unsigned j; /* number of codes */
unsigned b; /* bit length for those codes */
/* get bit lengths */
i = NEXTBYTE + 1; /* length/count pairs to read */
k = 0; /* next code */
do {
b = ((j = NEXTBYTE) & 0xf) + 1; /* bits in code (1..16) */
j = ((j & 0xf0) >> 4) + 1; /* codes with those bits (1..16) */
if (k + j > n)
return 4; /* don't overflow l[] */
do {
l[k++] = b;
} while (--j);
} while (--i);
return k != n ? 4 : 0; /* should have read n of them */
}
static int explode_lit8(__G__ tb, tl, td, bb, bl, bd)
__GDEF
struct huft *tb, *tl, *td; /* literal, length, and distance tables */
int bb, bl, bd; /* number of bits decoded by those */
/* Decompress the imploded data using coded literals and an 8K sliding
window. */
{
long s; /* bytes to decompress */
register unsigned e; /* table entry flag/number of extra bits */
unsigned n, d; /* length and index for copy */
unsigned w; /* current window position */
struct huft *t; /* pointer to table entry */
unsigned mb, ml, md; /* masks for bb, bl, and bd bits */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* explode the coded data */
b = k = w = 0; /* initialize bit buffer, window */
u = 1; /* buffer unflushed */
mb = mask_bits[bb]; /* precompute masks for speed */
ml = mask_bits[bl];
md = mask_bits[bd];
s = G.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--decode it */
{
DUMPBITS(1)
s--;
NEEDBITS((unsigned)bb) /* get coded literal */
if ((e = (t = tb + ((~(unsigned)b) & mb))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
redirSlide[w++] = (uch)t->v.n;
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(7) /* get distance low bits */
d = (unsigned)b & 0x7f;
DUMPBITS(7)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
/* &= w/ wsize not needed and wrong if redirect */
if (d >= wsize)
return 1;
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
} else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > n ? n : e);
if (u && w <= d)
{
memzero(redirSlide + w, e);
w += e;
d += e;
}
else
#ifndef NOMEMCPY
if (w - d >= e) /* (this test assumes unsigned comparison) */
{
memcpy(redirSlide + w, redirSlide + d, e);
w += e;
d += e;
}
else /* do it slow to avoid memcpy() overlap */
#endif /* !NOMEMCPY */
do {
redirSlide[w++] = redirSlide[d++];
} while (--e);
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
return 5;
}
return 0;
}
static int explode_lit4(__G__ tb, tl, td, bb, bl, bd)
__GDEF
struct huft *tb, *tl, *td; /* literal, length, and distance tables */
int bb, bl, bd; /* number of bits decoded by those */
/* Decompress the imploded data using coded literals and a 4K sliding
window. */
{
long s; /* bytes to decompress */
register unsigned e; /* table entry flag/number of extra bits */
unsigned n, d; /* length and index for copy */
unsigned w; /* current window position */
struct huft *t; /* pointer to table entry */
unsigned mb, ml, md; /* masks for bb, bl, and bd bits */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* explode the coded data */
b = k = w = 0; /* initialize bit buffer, window */
u = 1; /* buffer unflushed */
mb = mask_bits[bb]; /* precompute masks for speed */
ml = mask_bits[bl];
md = mask_bits[bd];
s = G.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--decode it */
{
DUMPBITS(1)
s--;
NEEDBITS((unsigned)bb) /* get coded literal */
if ((e = (t = tb + ((~(unsigned)b) & mb))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
redirSlide[w++] = (uch)t->v.n;
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(6) /* get distance low bits */
d = (unsigned)b & 0x3f;
DUMPBITS(6)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
/* &= w/ wsize not needed and wrong if redirect */
if (d >= wsize)
return 1;
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
} else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > n ? n : e);
if (u && w <= d)
{
memzero(redirSlide + w, e);
w += e;
d += e;
}
else
#ifndef NOMEMCPY
if (w - d >= e) /* (this test assumes unsigned comparison) */
{
memcpy(redirSlide + w, redirSlide + d, e);
w += e;
d += e;
}
else /* do it slow to avoid memcpy() overlap */
#endif /* !NOMEMCPY */
do {
redirSlide[w++] = redirSlide[d++];
} while (--e);
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
return 5;
}
return 0;
}
static int explode_nolit8(__G__ tl, td, bl, bd)
__GDEF
struct huft *tl, *td; /* length and distance decoder tables */
int bl, bd; /* number of bits decoded by tl[] and td[] */
/* Decompress the imploded data using uncoded literals and an 8K sliding
window. */
{
long s; /* bytes to decompress */
register unsigned e; /* table entry flag/number of extra bits */
unsigned n, d; /* length and index for copy */
unsigned w; /* current window position */
struct huft *t; /* pointer to table entry */
unsigned ml, md; /* masks for bl and bd bits */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* explode the coded data */
b = k = w = 0; /* initialize bit buffer, window */
u = 1; /* buffer unflushed */
ml = mask_bits[bl]; /* precompute masks for speed */
md = mask_bits[bd];
s = G.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--get eight bits */
{
DUMPBITS(1)
s--;
NEEDBITS(8)
redirSlide[w++] = (uch)b;
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
DUMPBITS(8)
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(7) /* get distance low bits */
d = (unsigned)b & 0x7f;
DUMPBITS(7)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
/* &= w/ wsize not needed and wrong if redirect */
if (d >= wsize)
return 1;
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
} else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > n ? n : e);
if (u && w <= d)
{
memzero(redirSlide + w, e);
w += e;
d += e;
}
else
#ifndef NOMEMCPY
if (w - d >= e) /* (this test assumes unsigned comparison) */
{
memcpy(redirSlide + w, redirSlide + d, e);
w += e;
d += e;
}
else /* do it slow to avoid memcpy() overlap */
#endif /* !NOMEMCPY */
do {
redirSlide[w++] = redirSlide[d++];
} while (--e);
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
return 5;
}
return 0;
}
static int explode_nolit4(__G__ tl, td, bl, bd)
__GDEF
struct huft *tl, *td; /* length and distance decoder tables */
int bl, bd; /* number of bits decoded by tl[] and td[] */
/* Decompress the imploded data using uncoded literals and a 4K sliding
window. */
{
long s; /* bytes to decompress */
register unsigned e; /* table entry flag/number of extra bits */
unsigned n, d; /* length and index for copy */
unsigned w; /* current window position */
struct huft *t; /* pointer to table entry */
unsigned ml, md; /* masks for bl and bd bits */
register ulg b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
unsigned u; /* true if unflushed */
/* explode the coded data */
b = k = w = 0; /* initialize bit buffer, window */
u = 1; /* buffer unflushed */
ml = mask_bits[bl]; /* precompute masks for speed */
md = mask_bits[bd];
s = G.ucsize;
while (s > 0) /* do until ucsize bytes uncompressed */
{
NEEDBITS(1)
if (b & 1) /* then literal--get eight bits */
{
DUMPBITS(1)
s--;
NEEDBITS(8)
redirSlide[w++] = (uch)b;
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
DUMPBITS(8)
}
else /* else distance/length */
{
DUMPBITS(1)
NEEDBITS(6) /* get distance low bits */
d = (unsigned)b & 0x3f;
DUMPBITS(6)
NEEDBITS((unsigned)bd) /* get coded distance high bits */
if ((e = (t = td + ((~(unsigned)b) & md))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
d = w - d - t->v.n; /* construct offset */
NEEDBITS((unsigned)bl) /* get coded length */
if ((e = (t = tl + ((~(unsigned)b) & ml))->e) > 16)
do {
if (e == 99)
return 1;
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((~(unsigned)b) & mask_bits[e]))->e) > 16);
DUMPBITS(t->b)
n = t->v.n;
if (e) /* get length extra bits */
{
NEEDBITS(8)
n += (unsigned)b & 0xff;
DUMPBITS(8)
}
/* do the copy */
s -= n;
do {
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide) {
/* &= w/ wsize not needed and wrong if redirect */
if (d >= wsize)
return 1;
n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
} else
#endif
n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > n ? n : e);
if (u && w <= d)
{
memzero(redirSlide + w, e);
w += e;
d += e;
}
else
#ifndef NOMEMCPY
if (w - d >= e) /* (this test assumes unsigned comparison) */
{
memcpy(redirSlide + w, redirSlide + d, e);
w += e;
d += e;
}
else /* do it slow to avoid memcpy() overlap */
#endif /* !NOMEMCPY */
do {
redirSlide[w++] = redirSlide[d++];
} while (--e);
if (w == wsize)
{
flush(__G__ redirSlide, (ulg)w, 0);
w = u = 0;
}
} while (n);
}
}
/* flush out redirSlide */
flush(__G__ redirSlide, (ulg)w, 0);
if (G.csize + G.incnt + (k >> 3)) /* should have read csize bytes, but */
{ /* sometimes read one too many: k>>3 compensates */
G.used_csize = G.lrec.csize - G.csize - G.incnt - (k >> 3);
return 5;
}
return 0;
}
int explode(__G)
__GDEF
/* Explode an imploded compressed stream. Based on the general purpose
bit flag, decide on coded or uncoded literals, and an 8K or 4K sliding
window. Construct the literal (if any), length, and distance codes and
the tables needed to decode them (using huft_build() from inflate.c),
and call the appropriate routine for the type of data in the remainder
of the stream. The four routines are nearly identical, differing only
in whether the literal is decoded or simply read in, and in how many
bits are read in, uncoded, for the low distance bits. */
{
unsigned r; /* return codes */
struct huft *tb; /* literal code table */
struct huft *tl; /* length code table */
struct huft *td; /* distance code table */
int bb; /* bits for tb */
int bl; /* bits for tl */
int bd; /* bits for td */
unsigned l[256]; /* bit lengths for codes */
#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
if (G.redirect_slide)
wsize = G.redirect_size, redirSlide = G.redirect_buffer;
else
wsize = WSIZE, redirSlide = slide;
#endif
/* Tune base table sizes. Note: I thought that to truly optimize speed,
I would have to select different bl, bd, and bb values for different
compressed file sizes. I was surprised to find out that the values of
7, 7, and 9 worked best over a very wide range of sizes, except that
bd = 8 worked marginally better for large compressed sizes. */
bl = 7;
bd = (G.csize + G.incnt) > 200000L ? 8 : 7;
/* With literal tree--minimum match length is 3 */
#ifdef DEBUG
G.hufts = 0; /* initialize huft's malloc'ed */
#endif
if (G.lrec.general_purpose_bit_flag & 4)
{
bb = 9; /* base table size for literals */
if ((r = get_tree(__G__ l, 256)) != 0)
return (int)r;
if ((r = huft_build(__G__ l, 256, 256, NULL, NULL, &tb, &bb)) != 0)
{
if (r == 1)
huft_free(tb);
return (int)r;
}
if ((r = get_tree(__G__ l, 64)) != 0)
return (int)r;
if ((r = huft_build(__G__ l, 64, 0, cplen3, extra, &tl, &bl)) != 0)
{
if (r == 1)
huft_free(tl);
huft_free(tb);
return (int)r;
}
if ((r = get_tree(__G__ l, 64)) != 0)
return (int)r;
if (G.lrec.general_purpose_bit_flag & 2) /* true if 8K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist8, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
huft_free(tb);
return (int)r;
}
r = explode_lit8(__G__ tb, tl, td, bb, bl, bd);
}
else /* else 4K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist4, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
huft_free(tb);
return (int)r;
}
r = explode_lit4(__G__ tb, tl, td, bb, bl, bd);
}
huft_free(td);
huft_free(tl);
huft_free(tb);
}
else
/* No literal tree--minimum match length is 2 */
{
if ((r = get_tree(__G__ l, 64)) != 0)
return (int)r;
if ((r = huft_build(__G__ l, 64, 0, cplen2, extra, &tl, &bl)) != 0)
{
if (r == 1)
huft_free(tl);
return (int)r;
}
if ((r = get_tree(__G__ l, 64)) != 0)
return (int)r;
if (G.lrec.general_purpose_bit_flag & 2) /* true if 8K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist8, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
return (int)r;
}
r = explode_nolit8(__G__ tl, td, bl, bd);
}
else /* else 4K */
{
if ((r = huft_build(__G__ l, 64, 0, cpdist4, extra, &td, &bd)) != 0)
{
if (r == 1)
huft_free(td);
huft_free(tl);
return (int)r;
}
r = explode_nolit4(__G__ tl, td, bl, bd);
}
huft_free(td);
huft_free(tl);
}
Trace((stderr, "<%u > ", G.hufts));
return (int)r;
}
/* so explode.c and inflate.c can be compiled together into one object: */
#undef NEXTBYTE
#undef NEEDBITS
#undef DUMPBITS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,468 @@
/* funzip.c -- put in the public domain by Mark Adler */
#define VERSION "3.93 of 21 November 1998"
/* You can do whatever you like with this source file, though I would
prefer that if you modify it and redistribute it that you include
comments to that effect with your name and the date. Thank you.
History:
vers date who what
---- --------- -------------- ------------------------------------
1.0 13 Aug 92 M. Adler really simple unzip filter.
1.1 13 Aug 92 M. Adler cleaned up somewhat, give help if
stdin not redirected, warn if more
zip file entries after the first.
1.2 15 Aug 92 M. Adler added check of lengths for stored
entries, added more help.
1.3 16 Aug 92 M. Adler removed redundant #define's, added
decryption.
1.4 27 Aug 92 G. Roelofs added exit(0).
1.5 1 Sep 92 K. U. Rommel changed read/write modes for OS/2.
1.6 6 Sep 92 G. Roelofs modified to use dummy crypt.c and
crypt.h instead of -DCRYPT.
1.7 23 Sep 92 G. Roelofs changed to use DOS_OS2; included
crypt.c under MS-DOS.
1.8 9 Oct 92 M. Adler improved inflation error msgs.
1.9 17 Oct 92 G. Roelofs changed ULONG/UWORD/byte to ulg/ush/uch;
renamed inflate_entry() to inflate();
adapted to use new, in-place zdecode.
2.0 22 Oct 92 M. Adler allow filename argument, prompt for
passwords and don't echo, still allow
command-line password entry, but as an
option.
2.1 23 Oct 92 J-l. Gailly fixed crypt/store bug,
G. Roelofs removed crypt.c under MS-DOS, fixed
decryption check to compare single byte.
2.2 28 Oct 92 G. Roelofs removed declaration of key.
2.3 14 Dec 92 M. Adler replaced fseek (fails on stdin for SCO
Unix V.3.2.4). added quietflg for
inflate.c.
3.0 11 May 93 M. Adler added gzip support
3.1 9 Jul 93 K. U. Rommel fixed OS/2 pipe bug (PIPE_ERROR)
3.2 4 Sep 93 G. Roelofs moved crc_32_tab[] to tables.h; used FOPx
from unzip.h; nuked OUTB macro and outbuf;
replaced flush(); inlined FlushOutput();
renamed decrypt to encrypted
3.3 29 Sep 93 G. Roelofs replaced ReadByte() with NEXTBYTE macro;
revised (restored?) flush(); added FUNZIP
3.4 21 Oct 93 G. Roelofs renamed quietflg to qflag; changed outcnt,
H. Gessau second updcrc() arg and flush() arg to ulg;
added inflate_free(); added "g =" to null
getc(in) to avoid compiler warnings
3.5 31 Oct 93 H. Gessau changed DOS_OS2 to DOS_NT_OS2
3.6 6 Dec 93 H. Gessau added "near" to mask_bits[]
3.7 9 Dec 93 G. Roelofs added extent typecasts to fwrite() checks
3.8 28 Jan 94 GRR/JlG initialized g variable in main() for gcc
3.81 22 Feb 94 M. Hanning-Lee corrected usage message
3.82 27 Feb 94 G. Roelofs added some typecasts to avoid warnings
3.83 22 Jul 94 G. Roelofs changed fprintf to macro for DLLs
- 2 Aug 94 - public release with UnZip 5.11
- 28 Aug 94 - public release with UnZip 5.12
3.84 1 Oct 94 K. U. Rommel changes for Metaware High C
3.85 29 Oct 94 G. Roelofs changed fprintf macro to Info
3.86 7 May 95 K. Davis RISCOS patches;
P. Kienitz Amiga patches
3.87 12 Aug 95 G. Roelofs inflate_free(), DESTROYGLOBALS fixes
3.88 4 Sep 95 C. Spieler reordered macro to work around MSC 5.1 bug
3.89 22 Nov 95 PK/CS ifdef'd out updcrc() for ASM_CRC
3.9 17 Dec 95 G. Roelofs modified for USE_ZLIB (new fillinbuf())
- 30 Apr 96 - public release with UnZip 5.2
3.91 17 Aug 96 G. Roelofs main() -> return int (Peter Seebach)
3.92 13 Apr 97 G. Roelofs minor cosmetic fixes to messages
- 22 Apr 97 - public release with UnZip 5.3
- 31 May 97 - public release with UnZip 5.31
3.93 20 Sep 97 G. Roelofs minor cosmetic fixes to messages
- 3 Nov 97 - public release with UnZip 5.32
- 28 Nov 98 - public release with UnZip 5.4
*/
/*
All funzip does is take a zipfile from stdin and decompress the
first entry to stdout. The entry has to be either deflated or
stored. If the entry is encrypted, then the decryption password
must be supplied on the command line as the first argument.
funzip needs to be linked with inflate.o and crypt.o compiled from
the unzip source. If decryption is desired, the full version of
crypt.c (and crypt.h) from zcrypt21.zip or later must be used.
*/
#define FUNZIP
#define UNZIP_INTERNAL
#include "unzip.h"
#include "crypt.h"
#include "ttyio.h"
#ifdef EBCDIC
# undef EBCDIC /* don't need ebcdic[] */
#endif
#include "tables.h" /* crc_32_tab[] */
#ifndef USE_ZLIB /* zlib's function is called inflate(), too */
# define UZinflate inflate
#endif
/* PKZIP header definitions */
#define ZIPMAG 0x4b50 /* two-byte zip lead-in */
#define LOCREM 0x0403 /* remaining two bytes in zip signature */
#define LOCSIG 0x04034b50L /* full signature */
#define LOCFLG 4 /* offset of bit flag */
#define CRPFLG 1 /* bit for encrypted entry */
#define EXTFLG 8 /* bit for extended local header */
#define LOCHOW 6 /* offset of compression method */
#define LOCTIM 8 /* file mod time (for decryption) */
#define LOCCRC 12 /* offset of crc */
#define LOCSIZ 16 /* offset of compressed size */
#define LOCLEN 20 /* offset of uncompressed length */
#define LOCFIL 24 /* offset of file name field length */
#define LOCEXT 26 /* offset of extra field length */
#define LOCHDR 28 /* size of local header, including LOCREM */
#define EXTHDR 16 /* size of extended local header, inc sig */
/* GZIP header definitions */
#define GZPMAG 0x8b1f /* two-byte gzip lead-in */
#define GZPHOW 0 /* offset of method number */
#define GZPFLG 1 /* offset of gzip flags */
#define GZPMUL 2 /* bit for multiple-part gzip file */
#define GZPISX 4 /* bit for extra field present */
#define GZPISF 8 /* bit for filename present */
#define GZPISC 16 /* bit for comment present */
#define GZPISE 32 /* bit for encryption */
#define GZPTIM 2 /* offset of Unix file modification time */
#define GZPEXF 6 /* offset of extra flags */
#define GZPCOS 7 /* offset of operating system compressed on */
#define GZPHDR 8 /* length of minimal gzip header */
/* Macros for getting two-byte and four-byte header values */
#define SH(p) ((ush)(uch)((p)[0]) | ((ush)(uch)((p)[1]) << 8))
#define LG(p) ((ulg)(SH(p)) | ((ulg)(SH((p)+2)) << 16))
/* Function prototypes */
void err OF((int, char *));
int main OF((int, char **));
/* Globals */
FILE *out; /* output file (*in moved to G struct) */
ulg outsiz; /* total bytes written to out */
int encrypted; /* flag to turn on decryption */
/* Masks for inflate.c */
ZCONST ush near mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
#ifdef USE_ZLIB
int fillinbuf(__G)
__GDEF
/* Fill input buffer for pull-model inflate() in zlib. Return the number of
* bytes in inbuf. */
{
/* GRR: check return value from fread(): same as read()? check errno? */
if ((G.incnt = fread((char *)G.inbuf, 1, INBUFSIZ, G.in)) <= 0)
return 0;
G.inptr = G.inbuf;
#if CRYPT
if (encrypted) {
uch *p;
int n;
for (n = G.incnt, p = G.inptr; n--; p++)
zdecode(*p);
}
#endif /* CRYPT */
return G.incnt;
}
#endif /* USE_ZLIB */
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
#ifdef USE_ZLIB
ZCONST uLongf *get_crc_table()
{
return (ZCONST uLongf *)crc_32_tab;
}
#else /* !USE_ZLIB */
ZCONST ulg near *get_crc_table()
{
return crc_32_tab;
}
#endif /* ?USE_ZLIB */
#endif /* !USE_ZLIB || USE_OWN_CRCTAB */
void err(n, m)
int n;
char *m;
/* Exit on error with a message and a code */
{
Info(slide, 1, ((char *)slide, "funzip error: %s\n", m));
DESTROYGLOBALS()
EXIT(n);
}
int flush(w) /* used by inflate.c (FLUSH macro) */
ulg w; /* number of bytes to flush */
{
G.crc32val = crc32(G.crc32val, slide, (extent)w);
if (fwrite((char *)slide,1,(extent)w,out) != (extent)w && !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += w;
return 0;
}
int main(argc, argv)
int argc;
char **argv;
/* Given a zipfile on stdin, decompress the first entry to stdout. */
{
ush n;
uch h[LOCHDR]; /* first local header (GZPHDR < LOCHDR) */
int g = 0; /* true if gzip format */
#if CRYPT
char *s = " [-password]";
char *p; /* password */
#else /* !CRYPT */
char *s = "";
#endif /* ?CRYPT */
CONSTRUCTGLOBALS();
/* skip executable name */
argc--;
argv++;
#if CRYPT
/* get the command line password, if any */
p = (char *)NULL;
if (argc && **argv == '-')
{
argc--;
p = 1 + *argv++;
}
#endif /* CRYPT */
#ifdef MALLOC_WORK
G.area.Slide = (uch *)calloc(8193, sizeof(short)+sizeof(char)+sizeof(char));
#endif
/* if no file argument and stdin not redirected, give the user help */
if (argc == 0 && isatty(0))
{
Info(slide, 1, ((char *)slide, "fUnZip (filter UnZip), version %s\n",
VERSION));
Info(slide, 1, ((char *)slide, "usage: ... | funzip%s | ...\n", s));
Info(slide, 1, ((char *)slide, " ... | funzip%s > outfile\n", s));
Info(slide, 1, ((char *)slide, " funzip%s infile.zip > outfile\n",s));
Info(slide, 1, ((char *)slide, " funzip%s infile.gz > outfile\n", s));
Info(slide, 1, ((char *)slide, "Extracts to stdout the gzip file or first\
zip entry of stdin or the given file.\n"));
DESTROYGLOBALS()
EXIT(3);
}
/* prepare to be a binary filter */
if (argc)
{
if ((G.in = fopen(*argv, FOPR)) == (FILE *)NULL)
err(2, "cannot find input file");
}
else
{
#ifdef DOS_FLX_H68_OS2_W32
#if (defined(__HIGHC__) && !defined(FLEXOS))
setmode(stdin, _BINARY);
#else
setmode(0, O_BINARY); /* some buggy C libraries require BOTH setmode() */
#endif /* call AND the fdopen() in binary mode :-( */
#endif /* DOS_FLX_H68_OS2_W32 */
#ifdef RISCOS
G.in = stdin;
#else
if ((G.in = fdopen(0, FOPR)) == (FILE *)NULL)
err(2, "cannot find stdin");
#endif
}
#ifdef DOS_FLX_H68_OS2_W32
#if (defined(__HIGHC__) && !defined(FLEXOS))
setmode(stdout, _BINARY);
#else
setmode(1, O_BINARY);
#endif
#endif /* DOS_FLX_H68_OS2_W32 */
#ifdef RISCOS
out = stdout;
#else
if ((out = fdopen(1, FOPW)) == (FILE *)NULL)
err(2, "cannot write to stdout");
#endif
/* read local header, check validity, and skip name and extra fields */
n = getc(G.in); n |= getc(G.in) << 8;
if (n == ZIPMAG)
{
if (fread((char *)h, 1, LOCHDR, G.in) != LOCHDR || SH(h) != LOCREM)
err(3, "invalid zipfile");
if (SH(h + LOCHOW) != STORED && SH(h + LOCHOW) != DEFLATED)
err(3, "first entry not deflated or stored--cannot unpack");
for (n = SH(h + LOCFIL); n--; ) g = getc(G.in);
for (n = SH(h + LOCEXT); n--; ) g = getc(G.in);
g = 0;
encrypted = h[LOCFLG] & CRPFLG;
}
else if (n == GZPMAG)
{
if (fread((char *)h, 1, GZPHDR, G.in) != GZPHDR)
err(3, "invalid gzip file");
if (h[GZPHOW] != DEFLATED)
err(3, "gzip file not deflated");
if (h[GZPFLG] & GZPMUL)
err(3, "cannot handle multi-part gzip files");
if (h[GZPFLG] & GZPISX)
{
n = getc(G.in); n |= getc(G.in) << 8;
while (n--) g = getc(G.in);
}
if (h[GZPFLG] & GZPISF)
while ((g = getc(G.in)) != 0 && g != EOF) ;
if (h[GZPFLG] & GZPISC)
while ((g = getc(G.in)) != 0 && g != EOF) ;
g = 1;
encrypted = h[GZPFLG] & GZPISE;
}
else
err(3, "input not a zip or gzip file");
/* if entry encrypted, decrypt and validate encryption header */
if (encrypted)
#if CRYPT
{
ush i, e;
if (p == (char *)NULL) {
if ((p = (char *)malloc(IZ_PWLEN+1)) == (char *)NULL)
err(1, "out of memory");
else if ((p = getp("Enter password: ", p, IZ_PWLEN+1)) == (char *)NULL)
err(1, "no tty to prompt for password");
}
#if (defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB))
/* initialize crc_32_tab pointer for decryption */
CRC_32_TAB = (ZCONST ulg Far *)get_crc_table();
#endif
init_keys(p);
for (i = 0; i < RAND_HEAD_LEN; i++)
e = NEXTBYTE;
if (e != (ush)(h[LOCFLG] & EXTFLG ? h[LOCTIM + 1] : h[LOCCRC + 3]))
err(3, "incorrect password for first entry");
}
#else /* !CRYPT */
err(3, "cannot decrypt entry (need to recompile with full crypt.c)");
#endif /* ?CRYPT */
/* prepare output buffer and crc */
G.outptr = slide;
G.outcnt = 0L;
outsiz = 0L;
G.crc32val = CRCVAL_INITIAL;
/* decompress */
if (g || h[LOCHOW])
{ /* deflated entry */
int r;
#ifdef USE_ZLIB
/* need to allocate and prepare input buffer */
if ((G.inbuf = (uch *)malloc(INBUFSIZ)) == (uch *)NULL)
err(1, "out of memory");
#endif /* USE_ZLIB */
if ((r = UZinflate(__G)) != 0) {
if (r == 3)
err(1, "out of memory");
else
err(4, "invalid compressed data--format violated");
}
inflate_free(__G);
}
else
{ /* stored entry */
register ulg n;
n = LG(h + LOCLEN);
#if CRYPT
if (n != LG(h + LOCSIZ) - (encrypted ? RAND_HEAD_LEN : 0)) {
#else
if (n != LG(h + LOCSIZ)) {
#endif
Info(slide, 1, ((char *)slide, "len %ld, siz %ld\n", n, LG(h + LOCSIZ)));
err(4, "invalid compressed data--length mismatch");
}
while (n--) {
ush c = getc(G.in);
#if CRYPT
if (encrypted)
zdecode(c);
#endif
*G.outptr++ = (uch)c;
if (++G.outcnt == WSIZE) /* do FlushOutput() */
{
G.crc32val = crc32(G.crc32val, slide, (extent)G.outcnt);
if (fwrite((char *)slide, 1,(extent)G.outcnt,out) != (extent)G.outcnt
&& !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += G.outcnt;
G.outptr = slide;
G.outcnt = 0L;
}
}
}
if (G.outcnt) /* flush one last time; no need to reset G.outptr/outcnt */
{
G.crc32val = crc32(G.crc32val, slide, (extent)G.outcnt);
if (fwrite((char *)slide, 1,(extent)G.outcnt,out) != (extent)G.outcnt
&& !PIPE_ERROR)
err(9, "out of space on stdout");
outsiz += G.outcnt;
}
fflush(out);
/* if extended header, get it */
if (g)
{
if (fread((char *)h + LOCCRC, 1, 8, G.in) != 8)
err(3, "gzip file ended prematurely");
}
else
if ((h[LOCFLG] & EXTFLG) &&
fread((char *)h + LOCCRC - 4, 1, EXTHDR, G.in) != EXTHDR)
err(3, "zipfile ended prematurely");
/* validate decompression */
if (LG(h + LOCCRC) != G.crc32val)
err(4, "invalid compressed data--crc error");
if (LG((g ? (h + LOCSIZ) : (h + LOCLEN))) != outsiz)
err(4, "invalid compressed data--length error");
/* check if there are more entries */
if (!g && fread((char *)h, 1, 4, G.in) == 4 && LG(h) == LOCSIG)
Info(slide, 1, ((char *)slide,
"funzip warning: zipfile has more than one entry--rest ignored\n"));
DESTROYGLOBALS()
RETURN (0);
}

View File

@@ -0,0 +1,204 @@
/*---------------------------------------------------------------------------
globals.c
Routines to allocate and initialize globals, with or without threads.
Contents: registerGlobalPointer()
deregisterGlobalPointer()
getGlobalPointer()
globalsCtor()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
#ifndef FUNZIP
/* initialization of sigs is completed at runtime so unzip(sfx) executable
* won't look like a zipfile
*/
char central_hdr_sig[4] = {0, 0, 0x01, 0x02};
char local_hdr_sig[4] = {0, 0, 0x03, 0x04};
char end_central_sig[4] = {0, 0, 0x05, 0x06};
/* extern char extd_local_sig[4] = {0, 0, 0x07, 0x08}; NOT USED YET */
ZCONST char *fnames[2] = {"*", NULL}; /* default filenames vector */
#endif
#ifndef REENTRANT
Uz_Globs G;
#else /* REENTRANT */
# ifndef USETHREADID
Uz_Globs *GG;
# else /* USETHREADID */
# define THREADID_ENTRIES 0x40
int lastScan;
Uz_Globs *threadPtrTable[THREADID_ENTRIES];
ulg threadIdTable [THREADID_ENTRIES] = {
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* Make sure there are */
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* THREADID_ENTRIES 0s */
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
};
static ZCONST char Far TooManyThreads[] =
"error: more than %d simultaneous threads.\n\
Some threads are probably not calling DESTROYTHREAD()\n";
static ZCONST char Far EntryNotFound[] =
"error: couldn't find global pointer in table.\n\
Maybe somebody accidentally called DESTROYTHREAD() twice.\n";
static ZCONST char Far GlobalPointerMismatch[] =
"error: global pointer in table does not match pointer passed as\
parameter\n";
static void registerGlobalPointer OF((__GPRO));
static void registerGlobalPointer(__G)
__GDEF
{
int scan=0;
ulg tid = GetThreadId();
while (threadIdTable[scan] && scan < THREADID_ENTRIES)
scan++;
if (scan == THREADID_ENTRIES) {
ZCONST char *tooMany = LoadFarString(TooManyThreads);
Info(slide, 0x421, ((char *)slide, tooMany, THREADID_ENTRIES));
free(pG);
EXIT(PK_MEM); /* essentially memory error before we've started */
}
threadIdTable [scan] = tid;
threadPtrTable[scan] = pG;
lastScan = scan;
}
void deregisterGlobalPointer(__G)
__GDEF
{
int scan=0;
ulg tid = GetThreadId();
while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES)
scan++;
/*---------------------------------------------------------------------------
There are two things we can do if we can't find the entry: ignore it or
scream. The most likely reason for it not to be here is the user calling
this routine twice. Since this could cause BIG problems if any globals
are accessed after the first call, we'd better scream.
---------------------------------------------------------------------------*/
if (scan == THREADID_ENTRIES || threadPtrTable[scan] != pG) {
ZCONST char *noEntry;
if (scan == THREADID_ENTRIES)
noEntry = LoadFarString(EntryNotFound);
else
noEntry = LoadFarString(GlobalPointerMismatch);
Info(slide, 0x421, ((char *)slide, noEntry));
EXIT(PK_WARN); /* programming error, but after we're all done */
}
threadIdTable [scan] = 0;
lastScan = scan;
free(threadPtrTable[scan]);
}
Uz_Globs *getGlobalPointer()
{
int scan=0;
ulg tid = GetThreadId();
while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES)
scan++;
/*---------------------------------------------------------------------------
There are two things we can do if we can't find the entry: ignore it or
scream. The most likely reason for it not to be here is the user calling
this routine twice. Since this could cause BIG problems if any globals
are accessed after the first call, we'd better scream.
---------------------------------------------------------------------------*/
if (scan == THREADID_ENTRIES) {
ZCONST char *noEntry = LoadFarString(EntryNotFound);
fprintf(stderr, noEntry); /* can't use Info w/o a global pointer */
EXIT(PK_ERR); /* programming error while still working */
}
return threadPtrTable[scan];
}
# endif /* ?USETHREADID */
#endif /* ?REENTRANT */
Uz_Globs *globalsCtor()
{
#ifdef REENTRANT
Uz_Globs *pG = (Uz_Globs *)malloc(sizeof(Uz_Globs));
if (!pG)
return (Uz_Globs *)NULL;
#endif /* REENTRANT */
/* for REENTRANT version, G is defined as (*pG) */
memzero(&G, sizeof(Uz_Globs));
#ifndef FUNZIP
#ifdef CMS_MVS
uO.aflag=1;
uO.C_flag=1;
#endif
uO.lflag=(-1);
G.wildzipfn = "";
G.pfnames = (char **)fnames;
G.pxnames = (char **)&fnames[1];
G.pInfo = G.info;
G.sol = TRUE; /* at start of line */
G.message = UzpMessagePrnt;
G.input = UzpInput; /* not used by anyone at the moment... */
#if defined(WINDLL) || defined(MACOS)
G.mpause = NULL; /* has scrollbars: no need for pausing */
#else
G.mpause = UzpMorePause;
#endif
G.decr_passwd = UzpPassword;
#endif /* !FUNZIP */
#if (!defined(DOS_FLX_H68_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
G.echofd = -1;
#endif /* !(MACOS || ATARI || VMS) */
#endif /* !(DOS_FLX_H68_OS2_W32 || AMIGA || RISCOS) */
#ifdef SYSTEM_SPECIFIC_CTOR
SYSTEM_SPECIFIC_CTOR(__G);
#endif
#ifdef REENTRANT
#ifdef USETHREADID
registerGlobalPointer(__G);
#else
GG = &G;
#endif /* ?USETHREADID */
#endif /* REENTRANT */
return &G;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,649 @@
/*---------------------------------------------------------------------------
list.c
This file contains the non-ZipInfo-specific listing routines for UnZip.
Contains: list_files()
get_time_stamp() [optional feature]
ratio()
fnprint()
---------------------------------------------------------------------------*/
#define UNZIP_INTERNAL
#include "unzip.h"
#ifdef WINDLL
# ifdef POCKET_UNZIP
# include "wince/intrface.h"
# else
# include "windll/windll.h"
# endif
#endif
#ifdef TIMESTAMP
static int fn_is_dir OF((__GPRO));
#endif
#ifndef WINDLL
static ZCONST char Far CompFactorStr[] = "%c%d%%";
static ZCONST char Far CompFactor100[] = "100%%";
#ifdef OS2_EAS
static ZCONST char Far HeadersS[] =
" Length EAs ACLs Date Time Name";
static ZCONST char Far HeadersS1[] =
" -------- --- ---- ---- ---- ----";
#else
static ZCONST char Far HeadersS[] = " Length Date Time Name";
static ZCONST char Far HeadersS1[] = " -------- ---- ---- ----";
#endif
static ZCONST char Far HeadersL[] =
" Length Method Size Ratio Date Time CRC-32 Name";
static ZCONST char Far HeadersL1[] =
"-------- ------ ------- ----- ---- ---- ------ ----";
static ZCONST char Far *Headers[][2] =
{ {HeadersS, HeadersS1}, {HeadersL, HeadersL1} };
static ZCONST char Far CaseConversion[] =
"%s (\"^\" ==> case\n%s conversion)\n";
static ZCONST char Far LongHdrStats[] =
"%8lu %-7s%8lu %4s %02u-%02u-%02u %02u:%02u %08lx %c";
static ZCONST char Far LongFileTrailer[] =
"-------- ------- --- \
-------\n%8lu %8lu %4s %u file%s\n";
#ifdef OS2_EAS
static ZCONST char Far ShortHdrStats[] =
"%9lu %6lu %6lu %02u-%02u-%02u %02u:%02u %c";
static ZCONST char Far ShortFileTrailer[] = " -------- ----- ----- \
-------\n%9lu %6lu %6lu %u file%s\n";
static ZCONST char Far OS2ExtAttrTrailer[] =
"%ld file%s %ld bytes of OS/2 extended attributes attached.\n";
static ZCONST char Far OS2ACLTrailer[] =
"%ld file%s %ld bytes of access control lists attached.\n";
#else
static ZCONST char Far ShortHdrStats[] =
"%9lu %02u-%02u-%02u %02u:%02u %c";
static ZCONST char Far ShortFileTrailer[] =
" -------- -------\n%9lu %u file%s\n";
#endif /* ?OS2_EAS */
#endif /* !WINDLL */
/*************************/
/* Function list_files() */
/*************************/
int list_files(__G) /* return PK-type error code */
__GDEF
{
int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
#ifndef WINDLL
char sgn, cfactorstr[10];
int longhdr=(uO.vflag>1);
#endif
int date_format;
unsigned j, methnum, members=0;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
struct tm *t;
#endif
unsigned yr, mo, dy, hh, mm;
ulg csiz, tot_csize=0L, tot_ucsize=0L;
#ifdef OS2_EAS
ulg ea_size, tot_easize=0L, tot_eafiles=0L;
ulg acl_size, tot_aclsize=0L, tot_aclfiles=0L;
#endif
min_info info;
char methbuf[8];
static ZCONST char dtype[]="NXFS"; /* see zi_short() */
static ZCONST char Far method[NUM_METHODS+1][8] =
{"Stored", "Shrunk", "Reduce1", "Reduce2", "Reduce3", "Reduce4",
"Implode", "Token", "Defl:#", "EnhDefl", "ImplDCL", "Unk:###"};
extern int files;
/*---------------------------------------------------------------------------
Unlike extract_or_test_files(), this routine confines itself to the cen-
tral directory. Thus its structure is somewhat simpler, since we can do
just a single loop through the entire directory, listing files as we go.
So to start off, print the heading line and then begin main loop through
the central directory. The results will look vaguely like the following:
Length Method Size Ratio Date Time CRC-32 Name ("^" ==> case
-------- ------ ------- ----- ---- ---- ------ ---- conversion)
44004 Implode 13041 71% 11-02-89 19:34 8b4207f7 Makefile.UNIX
3438 Shrunk 2209 36% 09-15-90 14:07 a2394fd8 ^dos-file.ext
16717 Defl:X 5252 69% 11-03-97 06:40 1ce0f189 WHERE
-------- ------- --- -------
64159 20502 68% 3 files
---------------------------------------------------------------------------*/
G.pInfo = &info;
date_format = DATE_FORMAT;
files = 0;
#ifndef WINDLL
if (uO.qflag < 2) {
if (uO.L_flag)
Info(slide, 0, ((char *)slide, LoadFarString(CaseConversion),
LoadFarStringSmall(Headers[longhdr][0]),
LoadFarStringSmall2(Headers[longhdr][1])));
else
Info(slide, 0, ((char *)slide, "%s\n%s\n",
LoadFarString(Headers[longhdr][0]),
LoadFarStringSmall(Headers[longhdr][1])));
}
#endif /* !WINDLL */
for (j = 0; j++ < (unsigned)G.ecrec.total_entries_central_dir;) {
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, central_hdr_sig, 4)) { /* just to make sure */
Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j));
Info(slide, 0x401, ((char *)slide, LoadFarString(ReportMsg)));
return PK_BADERR; /* sig not found */
}
/* process_cdir_file_hdr() sets pInfo->hostnum, pInfo->lcflag, ...: */
if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
return error; /* only PK_EOF defined */
/*
* We could DISPLAY the filename instead of storing (and possibly trun-
* cating, in the case of a very long name) and printing it, but that
* has the disadvantage of not allowing case conversion--and it's nice
* to be able to see in the listing precisely how you have to type each
* filename in order for unzip to consider it a match. Speaking of
* which, if member names were specified on the command line, check in
* with match() to see if the current file is one of them, and make a
* note of it if it is.
*/
if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) !=
PK_COOL) /* ^--(uses pInfo->lcflag) */
{
error_in_archive = error;
if (error > PK_WARN) /* fatal: can't continue */
return error;
}
if (G.extra_field != (uch *)NULL) {
free(G.extra_field);
G.extra_field = (uch *)NULL;
}
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD))
!= 0)
{
error_in_archive = error;
if (error > PK_WARN) /* fatal */
return error;
}
if (!G.process_all_files) { /* check if specified on command line */
unsigned i;
do_this_file = FALSE;
for (i = 0; i < G.filespecs; i++)
if (match(G.filename, G.pfnames[i], uO.C_flag)) {
do_this_file = TRUE;
break; /* found match, so stop looping */
}
if (do_this_file) { /* check if this is an excluded file */
for (i = 0; i < G.xfilespecs; i++)
if (match(G.filename, G.pxnames[i], uO.C_flag)) {
do_this_file = FALSE; /* ^-- ignore case in match */
break;
}
}
}
/*
* If current file was specified on command line, or if no names were
* specified, do the listing for this file. Otherwise, get rid of the
* file comment and go back for the next file.
*/
if (G.process_all_files || do_this_file) {
#ifdef OS2DLL
/* this is used by UzpFileTree() to allow easy processing of lists
* of zip directory contents */
if (G.processExternally) {
if ((G.processExternally)(G.filename, &G.crec))
break;
++members;
} else {
#endif
#ifdef OS2_EAS
{
uch *ef_ptr = G.extra_field;
int ef_size, ef_len = G.crec.extra_field_length;
ea_size = acl_size = 0;
while (ef_len >= EB_HEADSIZE) {
ef_size = makeword(&ef_ptr[EB_LEN]);
switch (makeword(&ef_ptr[EB_ID])) {
case EF_OS2:
ea_size = makelong(&ef_ptr[EB_HEADSIZE]);
break;
case EF_ACL:
acl_size = makelong(&ef_ptr[EB_HEADSIZE]);
break;
}
ef_ptr += (ef_size + EB_HEADSIZE);
ef_len -= (ef_size + EB_HEADSIZE);
}
}
#endif
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
#ifdef IZ_CHECK_TZ
G.tz_is_valid &&
#endif
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
G.crec.last_mod_dos_datetime, &z_utime, NULL)
& EB_UT_FL_MTIME))
{
TIMET_TO_NATIVE(z_utime.mtime) /* NOP unless MSC 7.0, Mac */
t = localtime(&(z_utime.mtime));
} else
t = (struct tm *)NULL;
if (t != (struct tm *)NULL) {
mo = (unsigned)(t->tm_mon + 1);
dy = (unsigned)(t->tm_mday);
yr = (unsigned)(t->tm_year % 100);
hh = (unsigned)(t->tm_hour);
mm = (unsigned)(t->tm_min);
} else
#endif /* USE_EF_UT_TIME */
{
yr = ((((unsigned)(G.crec.last_mod_dos_datetime >> 25) & 0x7f)
+ 80) % (unsigned)100);
mo = ((unsigned)(G.crec.last_mod_dos_datetime >> 21) & 0x0f);
dy = ((unsigned)(G.crec.last_mod_dos_datetime >> 16) & 0x1f);
hh = (((unsigned)G.crec.last_mod_dos_datetime >> 11) & 0x1f);
mm = (((unsigned)G.crec.last_mod_dos_datetime >> 5) & 0x3f);
}
/* permute date so it displays according to nat'l convention
* ('methnum' is not yet set, it is used as temporary buffer) */
switch (date_format) {
case DF_YMD:
methnum = (unsigned)mo;
mo = yr; yr = dy; dy = (ush)methnum;
break;
case DF_DMY:
methnum = (unsigned)mo;
mo = dy; dy = (ush)methnum;
}
csiz = G.crec.csize;
if (G.crec.general_purpose_bit_flag & 1)
csiz -= 12; /* if encrypted, don't count encryption header */
if ((cfactor = ratio(G.crec.ucsize, csiz)) < 0) {
#ifndef WINDLL
sgn = '-';
#endif
cfactor = (-cfactor + 5) / 10;
} else {
#ifndef WINDLL
sgn = ' ';
#endif
cfactor = (cfactor + 5) / 10;
}
methnum = MIN(G.crec.compression_method, NUM_METHODS);
zfstrcpy(methbuf, method[methnum]);
if (methnum == DEFLATED) {
methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
} else if (methnum >= NUM_METHODS) {
sprintf(&methbuf[4], "%03u", G.crec.compression_method);
}
#if 0 /* GRR/Euro: add this? */
#if defined(DOS_FLX_OS2_W32) || defined(UNIX)
for (p = G.filename; *p; ++p)
if (!isprint(*p))
*p = '?'; /* change non-printable chars to '?' */
#endif /* DOS_FLX_OS2_W32 || UNIX */
#endif /* 0 */
#ifdef WINDLL
/* send data to application for formatting and printing */
(*G.lpUserFunctions->SendApplicationMessage)(G.crec.ucsize, csiz,
(ush)cfactor, mo, dy, yr, hh, mm,
(char)(G.pInfo->lcflag ? '^' : ' '),
(LPSTR)fnfilter(G.filename, slide), (LPSTR)methbuf, G.crec.crc32,
(char)((G.crec.general_purpose_bit_flag & 1) ? 'E' : ' '));
#else /* !WINDLL */
if (cfactor == 100)
sprintf(cfactorstr, LoadFarString(CompFactor100));
else
sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
if (longhdr)
Info(slide, 0, ((char *)slide, LoadFarString(LongHdrStats),
G.crec.ucsize, methbuf, csiz, cfactorstr, mo, dy,
yr, hh, mm, G.crec.crc32, (G.pInfo->lcflag? '^':' ')));
else
#ifdef OS2_EAS
Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats),
G.crec.ucsize, ea_size, acl_size,
mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));
#else
Info(slide, 0, ((char *)slide, LoadFarString(ShortHdrStats),
G.crec.ucsize,
mo, dy, yr, hh, mm, (G.pInfo->lcflag? '^':' ')));
#endif
/* fnprint(__G);*/
files++;
#endif /* ?WINDLL */
if ((error = do_string(__G__ G.crec.file_comment_length,
QCOND? DISPL_8 : SKIP)) != 0)
{
error_in_archive = error; /* might be just warning */
if (error > PK_WARN) /* fatal */
return error;
}
tot_ucsize += G.crec.ucsize;
tot_csize += csiz;
++members;
#ifdef OS2_EAS
if (ea_size) {
tot_easize += ea_size;
++tot_eafiles;
}
if (acl_size) {
tot_aclsize += acl_size;
++tot_aclfiles;
}
#endif
#ifdef OS2DLL
} /* end of "if (G.processExternally) {...} else {..." */
#endif
} else { /* not listing this file */
SKIP_(G.crec.file_comment_length)
}
} /* end for-loop (j: files in central directory) */
/*---------------------------------------------------------------------------
Print footer line and totals (compressed size, uncompressed size, number
of members in zipfile).
---------------------------------------------------------------------------*/
if (uO.qflag < 2
#ifdef OS2DLL
&& !G.processExternally
#endif
) {
if ((cfactor = ratio(tot_ucsize, tot_csize)) < 0) {
#ifndef WINDLL
sgn = '-';
#endif
cfactor = (-cfactor + 5) / 10;
} else {
#ifndef WINDLL
sgn = ' ';
#endif
cfactor = (cfactor + 5) / 10;
}
#ifdef WINDLL
/* pass the totals back to the calling application */
G.lpUserFunctions->TotalSizeComp = tot_csize;
G.lpUserFunctions->TotalSize = tot_ucsize;
G.lpUserFunctions->CompFactor = cfactor;
G.lpUserFunctions->NumMembers = members;
#else /* !WINDLL */
if (cfactor == 100)
sprintf(cfactorstr, LoadFarString(CompFactor100));
else
sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
if (longhdr) {
Info(slide, 0, ((char *)slide, LoadFarString(LongFileTrailer),
tot_ucsize, tot_csize, cfactorstr, members, members==1? "":"s"));
#ifdef OS2_EAS
if (tot_easize || tot_aclsize)
Info(slide, 0, ((char *)slide, "\n"));
if (tot_eafiles && tot_easize)
Info(slide, 0, ((char *)slide, LoadFarString(OS2ExtAttrTrailer),
tot_eafiles, tot_eafiles == 1? " has" : "s have a total of",
tot_easize));
if (tot_aclfiles && tot_aclsize)
Info(slide, 0, ((char *)slide, LoadFarString(OS2ACLTrailer),
tot_aclfiles, tot_aclfiles == 1? " has" : "s have a total of",
tot_aclsize));
#endif /* OS2_EAS */
} else
#ifdef OS2_EAS
Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer),
tot_ucsize, tot_easize, tot_aclsize, members, members == 1?
"" : "s"));
#else
Info(slide, 0, ((char *)slide, LoadFarString(ShortFileTrailer),
tot_ucsize, members, members == 1? "" : "s"));
#endif /* OS2_EAS */
#endif /* ?WINDLL */
}
/*---------------------------------------------------------------------------
Double check that we're back at the end-of-central-directory record.
---------------------------------------------------------------------------*/
if (readbuf(__G__ G.sig, 4) == 0) /* disk error? */
return PK_EOF;
if (strncmp(G.sig, end_central_sig, 4)) { /* just to make sure again */
Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
error_in_archive = PK_WARN; /* didn't find sig */
}
if (members == 0 && error_in_archive <= PK_WARN)
error_in_archive = PK_FIND;
return error_in_archive;
} /* end function list_files() */
#ifdef TIMESTAMP
/************************/
/* Function fn_is_dir() */
/************************/
static int fn_is_dir(__G) /* returns TRUE if G.filename is directory */
__GDEF
{
extent fn_len = strlen(G.filename);
register char endc;
return fn_len > 0 &&
((endc = G.filename[fn_len-1]) == '/' ||
(G.pInfo->hostnum == FS_FAT_ && !strchr(G.filename, '/') &&
endc == '\\'));
}
/*****************************/
/* Function get_time_stamp() */
/*****************************/
int get_time_stamp(__G__ last_modtime, nmember) /* return PK-type error code */
__GDEF
time_t *last_modtime;
unsigned *nmember;
{
int do_this_file=FALSE, error, error_in_archive=PK_COOL;
unsigned j;
#ifdef USE_EF_UT_TIME
iztimes z_utime;
#endif
min_info info;
/*---------------------------------------------------------------------------
Unlike extract_or_test_files() but like list_files(), this function works
on information in the central directory alone. Thus we have a single,
large loop through the entire directory, searching for the latest time
stamp.
---------------------------------------------------------------------------*/
*last_modtime = 0L; /* assuming no zipfile data older than 1970 */
*nmember = 0;
G.pInfo = &info;
for (j = 0; j++ < (unsigned)G.ecrec.total_entries_central_dir;) {
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, central_hdr_sig, 4)) { /* just to make sure */
Info(slide, 0x401, ((char *)slide, LoadFarString(CentSigMsg), j));
Info(slide, 0x401, ((char *)slide, LoadFarString(ReportMsg)));
return PK_BADERR;
}
/* process_cdir_file_hdr() sets pInfo->lcflag: */
if ((error = process_cdir_file_hdr(__G)) != PK_COOL)
return error; /* only PK_EOF defined */
if ((error = do_string(__G__ G.crec.filename_length, DS_FN)) != PK_OK)
{ /* ^-- (uses pInfo->lcflag) */
error_in_archive = error;
if (error > PK_WARN) /* fatal: can't continue */
return error;
}
if (G.extra_field != (uch *)NULL) {
free(G.extra_field);
G.extra_field = (uch *)NULL;
}
if ((error = do_string(__G__ G.crec.extra_field_length, EXTRA_FIELD))
!= 0)
{
error_in_archive = error;
if (error > PK_WARN) /* fatal */
return error;
}
if (!G.process_all_files) { /* check if specified on command line */
unsigned i;
do_this_file = FALSE;
for (i = 0; i < G.filespecs; i++)
if (match(G.filename, G.pfnames[i], uO.C_flag)) {
do_this_file = TRUE;
break; /* found match, so stop looping */
}
if (do_this_file) { /* check if this is an excluded file */
for (i = 0; i < G.xfilespecs; i++)
if (match(G.filename, G.pxnames[i], uO.C_flag)) {
do_this_file = FALSE; /* ^-- ignore case in match */
break;
}
}
}
/* If current file was specified on command line, or if no names were
* specified, check the time for this file. Either way, get rid of the
* file comment and go back for the next file.
* Directory entries are always ignored, to stay compatible with both
* Zip and PKZIP.
*/
if ((G.process_all_files || do_this_file) && !fn_is_dir(__G)) {
#ifdef USE_EF_UT_TIME
if (G.extra_field &&
#ifdef IZ_CHECK_TZ
G.tz_is_valid &&
#endif
(ef_scan_for_izux(G.extra_field, G.crec.extra_field_length, 1,
G.crec.last_mod_dos_datetime, &z_utime, NULL)
& EB_UT_FL_MTIME))
{
if (*last_modtime < z_utime.mtime)
*last_modtime = z_utime.mtime;
} else
#endif /* USE_EF_UT_TIME */
{
time_t modtime = dos_to_unix_time(G.crec.last_mod_dos_datetime);
if (*last_modtime < modtime)
*last_modtime = modtime;
}
++*nmember;
}
SKIP_(G.crec.file_comment_length)
} /* end for-loop (j: files in central directory) */
/*---------------------------------------------------------------------------
Double check that we're back at the end-of-central-directory record.
---------------------------------------------------------------------------*/
if (readbuf(__G__ G.sig, 4) == 0)
return PK_EOF;
if (strncmp(G.sig, end_central_sig, 4)) { /* just to make sure again */
Info(slide, 0x401, ((char *)slide, LoadFarString(EndSigMsg)));
error_in_archive = PK_WARN;
}
if (*nmember == 0 && error_in_archive <= PK_WARN)
error_in_archive = PK_FIND;
return error_in_archive;
} /* end function get_time_stamp() */
#endif /* TIMESTAMP */
/********************/
/* Function ratio() */ /* also used by ZipInfo routines */
/********************/
int ratio(uc, c)
ulg uc, c;
{
ulg denom;
if (uc == 0)
return 0;
if (uc > 2000000L) { /* risk signed overflow if multiply numerator */
denom = uc / 1000L;
return ((uc >= c) ?
(int) ((uc-c + (denom>>1)) / denom) :
-((int) ((c-uc + (denom>>1)) / denom)));
} else { /* ^^^^^^^^ rounding */
denom = uc;
return ((uc >= c) ?
(int) ((1000L*(uc-c) + (denom>>1)) / denom) :
-((int) ((1000L*(c-uc) + (denom>>1)) / denom)));
} /* ^^^^^^^^ rounding */
}
/************************/
/* Function fnprint() */ /* also used by ZipInfo routines */
/************************/
void fnprint(__G) /* print filename (after filtering) and newline */
__GDEF
{
char *name = fnfilter(G.filename, slide);
(*G.message)((zvoid *)&G, (uch *)name, (ulg)strlen(name), 0);
(*G.message)((zvoid *)&G, (uch *)"\n", 1L, 0);
} /* end function fnprint() */

View File

@@ -0,0 +1,146 @@
#==============================================================================
# Makefile for UnZip, UnZipSFX and fUnZip: Unix and MS-DOS ("real" makes only)
# Version: 5.4 19 November 1998
#==============================================================================
# INSTRUCTIONS (such as they are):
#
# "make sunos" -- makes UnZip in current directory on a generic SunOS 4.x Sun
# "make list" -- lists all supported systems (targets)
# "make help" -- provides pointers on what targets to try if problems occur
# "make wombat" -- chokes and dies if you haven't added the specifics for your
# Wombat 68000 (or whatever) to the systems list
#
# CF are flags for the C compiler. LF are flags for the loader. LF2 are more
# flags for the loader, if they need to be at the end of the line instead of at
# the beginning (for example, some libraries). FL and FL2 are the corre-
# sponding flags for fUnZip. LOCAL_UNZIP is an environment variable that can
# be used to add default C flags to your compile without editing the Makefile
# (e.g., -DDEBUG_STRUC, or -FPi87 on PCs using Microsoft C).
#
# Some versions of make do not define the macro "$(MAKE)"; this is rare, but
# if things don't work, try using "make" instead of "$(MAKE)" in your system's
# makerule. Or try adding the following line to your .login file:
# setenv MAKE "make"
# (That never works--makes that are too stupid to define MAKE are also too
# stupid to look in the environment--but try it anyway for kicks. :-) )
#
# Memcpy and memset are provided for those systems that don't have them; they
# are in fileio.c and will be used if -DZMEM is included in CF. These days
# almost all systems have them.
#
# Be sure to test your new UnZip (and UnZipSFX and fUnZip); successful compila-
# tion does not always imply a working program.
#####################
# MACRO DEFINITIONS #
#####################
# Defaults most systems use (use LOCAL_UNZIP in environment to add flags,
# such as -DDOSWILD).
# UnZip flags
CC = cc# try using "gcc" target rather than changing this (CC and LD
LD = $(CC)# must match, else "unresolved symbol: ___main" is possible)
AS = as
LOC = $(LOCAL_UNZIP)
AF = $(LOC)
CF = -O -I. -I.. -I../inczip $(LOC)
LF = -o packinst
LF2 = -s
# general-purpose stuff
#CP = cp
CP = ln
LN = ln
RM = rm -f
CHMOD = chmod
BINPERMS = 755
MANPERMS = 644
STRIP = strip
E =
O = .o
M = unix
SHELL = /bin/sh
# defaults for crc32 stuff and system dependent headers
CRC32 = crc32
# object files
OBJS1 = unzip$O $(CRC32)$O crctab$O crypt$O envargs$O explode$O
OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
OBJS3 = process$O ttyio$O unreduce$O unshrink$O zipinfo$O
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O packinst$O
#OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O install$O wxmain$O instsup$O
UNZIP_H = ../inczip/unzip.h ../inczip/unzpriv.h ../inczip/globals.h
# installation
# (probably can change next two to `install' and `install -d' if you have it)
INSTALL = cp
INSTALL_D = mkdir -p
###############################################
# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
###############################################
# this is for GNU make; comment out and notify zip-bugs if it causes errors
.SUFFIXES: .c .o .obj .pic.o
# yes, we should be able to use the $O macro to combine these two, but it
# fails on some brain-damaged makes (e.g., AIX's)...no big deal
.c.o:
$(CC) -c $(CF) $*.c
.c.obj:
$(CC) -c $(CF) $*.c
.c.pic.o:
$(CC) -c $(CF) -o $@ $*.c
all: sfx
# EDIT HERE FOR PARALLEL MAKES on Sequent (and others?)--screws up MS-DOS
# make utilities if default: change "unzip$E:" to "unzip$E:&"
sfx$E: $(OBJS) # add `&' for parallel makes
$(LD) $(LF) $(OBJS)
crc32$O: crc32.c $(UNZIP_H) ../inczip/zip.h
crctab$O: crctab.c $(UNZIP_H) ../inczip/zip.h
crypt$O: crypt.c $(UNZIP_H) ../inczip/zip.h ../inczip/crypt.h ../inczip/ttyio.h
envargs$O: envargs.c $(UNZIP_H)
explode$O: explode.c $(UNZIP_H)
extract$O: extract.c $(UNZIP_H) ../inczip/crypt.h
fileio$O: fileio.c $(UNZIP_H) ../inczip/crypt.h ../inczip/ttyio.h ../inczip/ebcdic.h
funzip$O: funzip.c $(UNZIP_H) ../inczip/crypt.h ../inczip/ttyio.h ../inczip/tables.h
globals$O: globals.c $(UNZIP_H)
inflate$O: inflate.c ../inczip/inflate.h $(UNZIP_H)
list$O: list.c $(UNZIP_H)
match$O: match.c $(UNZIP_H)
process$O: process.c $(UNZIP_H)
ttyio$O: ttyio.c $(UNZIP_H) ../inczip/zip.h ../inczip/crypt.h ../inczip/ttyio.h
unreduce$O: unreduce.c $(UNZIP_H)
unshrink$O: unshrink.c $(UNZIP_H)
unzip$O: unzip.c $(UNZIP_H) ../inczip/crypt.h ../inczip/version.h ../inczip/consts.h
zipinfo$O: zipinfo.c $(UNZIP_H)
unix$O: unix.c $(UNZIP_H) ../inczip/version.h # Unix only
$(CC) -c $(CF) unix.c
packinst$O: ../packinst/packinst.c
$(CC) -c $(CF) ../packinst/packinst.c
#install$O: ../install.c
# $(CC) -c $(CF) ../install.c
#
#unix$O: ../wxmain.cpp
# $(CC) -c $(CF) ../wxmain.cpp
#
#unix$O: ../instsup.cpp
# $(CC) -c $(CF) ../instsup.cpp

View File

@@ -0,0 +1,118 @@
# Makefile for UnZip(SFX) and fUnZip for Borland C++ for Windows 95/NT
# Version: 5.4 and later Alvin Koh, Jim Knoble, Christian Spieler, etc.
# Adapted from the MS-DOS makefile by E-Yen Tan
#
# Last revised: 24 Nov 98
#
#
# Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
# should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
# to the declaration of LOC here:
LOC = $(LOCAL_UNZIP)
# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
CPU_TYP = 4
# (De)Select inclusion of optimized assembler CRC32 routine:
USE_ASMCRC = 0
# If you have bcc32i, you should define:
# CC = bcc32i
# This compiler generates a faster code.
CC = bcc32
AS = tasm32
!if $(USE_ASMCRC)
ASMFLG = -DASM_CRC
ASMOBJS = crc_i386.obj
!else
ASMFLG =
ASMOBJS =
!endif
!if $(UNCLEAN)
DIRT = -DUSE_SMITH_CODE -DUSE_UNSHRINK
!else
DIRT =
!endif
# compiler flags
ASCPUFLAG = __$(CPU_TYP)86
!if $(CPU_TYP) != 0
CC_CPUFLG = -$(CPU_TYP)
!endif
ASFLAGS = -ml -m2 -w0 -D$(ASCPUFLAG) $(LOC)
CFLAGS = -O2 -w- $(CC_CPUFLG) -ff- -k- -P-.C -I. -I.. -I..\inczip -DWIN32 $(ASMFLG) $(LOC) $(DIRT)
LDFLAGS = -lxncd -l-P # for bcc
UNFLAGS = $(CFLAGS)
# implicit rules
.asm.obj:
$(AS) $(ASFLAGS) $<
.c.obj:
$(CC) -c $(UNFLAGS) {$< }
# list macros
OBJU1 = unzip.obj crc32.obj crctab.obj crypt.obj envargs.obj explode.obj
OBJU2 = extract.obj fileio.obj globals.obj inflate.obj list.obj match.obj
OBJU3 = process.obj ttyio.obj unreduce.obj unshrink.obj zipinfo.obj
OBJUS = win32.obj nt.obj $(ASMOBJS) packinst.obj
OBJU = $(OBJU1) $(OBJU2) $(OBJU3) $(OBJUS)
UNZIP_H = ..\inczip\unzip.h ..\inczip\unzpriv.h ..\inczip\globals.h ..\inczip\w32cfg.h
# explicit rules
all: packinst.exe
packinst.exe: $(OBJU)
$(CC) $(LDFLAGS) -epackinst.exe @&&|
$(OBJU)
|
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.rws
-erase *.tds
-erase *.il?
# individual file dependencies
crc32.obj: crc32.c $(UNZIP_H) ..\inczip\zip.h
crctab.obj: crctab.c $(UNZIP_H) ..\inczip\zip.h
crypt.obj: crypt.c $(UNZIP_H) ..\inczip\zip.h ..\inczip\crypt.h ..\inczip\ttyio.h
envargs.obj: envargs.c $(UNZIP_H)
explode.obj: explode.c $(UNZIP_H)
extract.obj: extract.c $(UNZIP_H) ..\inczip\crypt.h
fileio.obj: fileio.c $(UNZIP_H) ..\inczip\crypt.h ..\inczip\ttyio.h ..\inczip\ebcdic.h
globals.obj: globals.c $(UNZIP_H)
inflate.obj: inflate.c ..\inczip\inflate.h $(UNZIP_H)
list.obj: list.c $(UNZIP_H)
match.obj: match.c $(UNZIP_H)
process.obj: process.c $(UNZIP_H)
ttyio.obj: ttyio.c $(UNZIP_H) ..\inczip\zip.h ..\inczip\crypt.h ..\inczip\ttyio.h
unreduce.obj: unreduce.c $(UNZIP_H)
unshrink.obj: unshrink.c $(UNZIP_H)
unzip.obj: unzip.c $(UNZIP_H) ..\inczip\crypt.h ..\inczip\version.h ..\inczip\consts.h
zipinfo.obj: zipinfo.c $(UNZIP_H)
crc_i386.obj: crc_i386.asm
$(AS) $(ASFLAGS) crc_i386.asm, $*.obj ;
win32.obj: win32.c $(UNZIP_H)
$(CC) -c $(UNFLAGS) win32.c
packinst.obj: ..\packinst\packinst.c $(UNZIP_H)
$(CC) -c $(UNFLAGS) ..\packinst\packinst.c
nt.obj: nt.c $(UNZIP_H)
$(CC) -c $(UNFLAGS) nt.c

Some files were not shown because too many files have changed in this diff Show More