mindterm

16:39:08.004 INFO  jd.cli.Main - Decompiling mindterm.jar
package com.isnetworks.ssh;

import java.util.Vector;

public abstract class AbstractFileBrowser
  implements FileBrowser
{
  public FileDisplayControl mFileDisplay;
  public Vector<FileListItem> dirs;
  public Vector<FileListItem> files;
  
  public AbstractFileBrowser(FileDisplayControl paramFileDisplayControl)
  {
    mFileDisplay = paramFileDisplayControl;
    mFileDisplay.setFileBrowser(this);
    dirs = new Vector(32);
    files = new Vector(256);
  }
  
  public void disconnect() {}
}

/* Location:
 * Qualified Name:     com.isnetworks.ssh.AbstractFileBrowser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.isnetworks.ssh;

public abstract interface FileBrowser
{
  public abstract void fileDoubleClicked(FileListItem paramFileListItem)
    throws Exception;
  
  public abstract void refresh()
    throws Exception;
  
  public abstract void delete(FileListItem[] paramArrayOfFileListItem)
    throws Exception;
  
  public abstract void initialize()
    throws Exception;
  
  public abstract void makeDirectory(String paramString)
    throws Exception;
  
  public abstract void rename(FileListItem paramFileListItem, String paramString)
    throws Exception;
  
  public abstract void changeDirectory(String paramString)
    throws Exception;
  
  public abstract void disconnect();
}

/* Location:
 * Qualified Name:     com.isnetworks.ssh.FileBrowser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.isnetworks.ssh;

import com.mindbright.ssh.SSHMiscDialogs;
import com.mindbright.sshcommon.SSHFileTransferDialogControl;
import com.mindbright.util.ArraySort;
import com.mindbright.util.StringUtil;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class FileDisplay
  extends JPanel
  implements ActionListener, ListSelectionListener, MouseListener, FileDisplayControl
{
  private static final long serialVersionUID = 1L;
  private FileBrowser mBrowser;
  private JButton mChgDirButton;
  private JButton mDeleteButton;
  private JPanel mFileHeaderPanel;
  private FileList mFileList;
  private JLabel mMachineDescriptionLabel;
  private String mMachineDescriptionText;
  private JComboBox mFileSystemLocationComboBox;
  private String mCurrDir;
  private JButton mMkDirButton;
  private JButton mRefreshButton;
  private JButton mRenameButton;
  private Component mOwner;
  private SSHFileTransferDialogControl mFileXferDialog;
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    try
    {
      String str1 = paramActionEvent.getActionCommand();
      Object localObject;
      if ("setdir".equals(str1))
      {
        localObject = getFileSystemLocation();
        if ((localObject == null) || (((String)localObject).equals(mCurrDir))) {
          return;
        }
        mBrowser.changeDirectory((String)localObject);
      }
      else if ("chdir".equals(str1))
      {
        localObject = SSHMiscDialogs.textInput("Change directory", "Directory", mOwner, getFileSystemLocation());
        if (localObject != null) {
          mBrowser.changeDirectory((String)localObject);
        }
      }
      else if ("mkdir".equals(str1))
      {
        localObject = SSHMiscDialogs.textInput("Make directory relative to current path", "Directory name", mOwner);
        if (localObject != null) {
          mBrowser.makeDirectory((String)localObject);
        }
      }
      else if ("rename".equals(str1))
      {
        localObject = getSelectedFile();
        String str2 = SSHMiscDialogs.textInput("Rename file", "New file name", mOwner, ((FileListItem)localObject).getName());
        if (str2 != null) {
          mBrowser.rename((FileListItem)localObject, str2);
        }
      }
      else if ("delete".equals(str1))
      {
        mBrowser.delete(getSelectedFiles());
      }
      else if (!"refresh".equals(str1)) {}
      mBrowser.refresh();
    }
    catch (Exception localException)
    {
      mFileXferDialog.logError(localException);
      try
      {
        mBrowser.refresh();
      }
      catch (Throwable localThrowable) {}
    }
  }
  
  public void valueChanged(ListSelectionEvent paramListSelectionEvent)
  {
    enableButtons();
    mFileList.ensureIndexIsVisible(mFileList.getLeadSelectionIndex());
  }
  
  public void mouseClicked(MouseEvent paramMouseEvent)
  {
    if (paramMouseEvent.getClickCount() >= 2)
    {
      int i = mFileList.locationToIndex(paramMouseEvent.getPoint());
      mFileList.ensureIndexIsVisible(i);
      FileListItem localFileListItem = mFileList.getFileListItem((String)mFileList.getModel().getElementAt(i));
      if (localFileListItem != null) {
        try
        {
          mBrowser.fileDoubleClicked(localFileListItem);
          mBrowser.refresh();
        }
        catch (Exception localException)
        {
          mFileXferDialog.logError(localException);
        }
      }
    }
  }
  
  public void mouseEntered(MouseEvent paramMouseEvent) {}
  
  public void mouseExited(MouseEvent paramMouseEvent) {}
  
  public void mousePressed(MouseEvent paramMouseEvent) {}
  
  public void mouseReleased(MouseEvent paramMouseEvent) {}
  
  public FileDisplay(Component paramComponent, String paramString, SSHFileTransferDialogControl paramSSHFileTransferDialogControl)
  {
    super(new BorderLayout());
    mOwner = paramComponent;
    mFileXferDialog = paramSSHFileTransferDialogControl;
    mMachineDescriptionLabel = new JLabel(paramString);
    mMachineDescriptionText = paramString;
    add("North", getFileHeaderPanel());
    FileList localFileList = getFileList();
    JScrollPane localJScrollPane = new JScrollPane(localFileList, 20, 30);
    add("Center", localJScrollPane);
    add("South", getFileButtonsPanel());
  }
  
  private JPanel getFileHeaderPanel()
  {
    if (mFileHeaderPanel == null)
    {
      mFileHeaderPanel = new JPanel(new GridLayout(2, 1));
      mFileHeaderPanel.add(getMachineDescriptionLabel());
      mFileHeaderPanel.add(getFileSystemLocationComboBox());
    }
    return mFileHeaderPanel;
  }
  
  private JLabel getMachineDescriptionLabel()
  {
    return mMachineDescriptionLabel;
  }
  
  private JComboBox getFileSystemLocationComboBox()
  {
    if (mFileSystemLocationComboBox == null)
    {
      mFileSystemLocationComboBox = new JComboBox();
      mFileSystemLocationComboBox.addActionListener(this);
      mFileSystemLocationComboBox.setActionCommand("setdir");
    }
    return mFileSystemLocationComboBox;
  }
  
  private JPanel getFileButtonsPanel()
  {
    JPanel localJPanel1 = new JPanel(new GridLayout(2, 3, 5, 5));
    localJPanel1.add(getChgDirButton());
    localJPanel1.add(getMkDirButton());
    localJPanel1.add(getRenameButton());
    localJPanel1.add(getDeleteButton());
    localJPanel1.add(getRefreshButton());
    JPanel localJPanel2 = new JPanel(new BorderLayout());
    localJPanel2.add(new JLabel(" "), "North");
    localJPanel2.add(localJPanel1, "West");
    localJPanel2.add(new JLabel(""), "Center");
    return localJPanel2;
  }
  
  private JButton makeButton(String paramString1, String paramString2)
  {
    JButton localJButton = new JButton(paramString1);
    localJButton.setActionCommand(paramString2);
    localJButton.addActionListener(this);
    localJButton.setMargin(new Insets(2, 2, 2, 2));
    return localJButton;
  }
  
  private JButton getChgDirButton()
  {
    if (mChgDirButton == null) {
      mChgDirButton = makeButton("ChDir", "chdir");
    }
    return mChgDirButton;
  }
  
  private JButton getMkDirButton()
  {
    if (mMkDirButton == null) {
      mMkDirButton = makeButton("MkDir", "mkdir");
    }
    return mMkDirButton;
  }
  
  private JButton getRenameButton()
  {
    if (mRenameButton == null) {
      mRenameButton = makeButton("Rename", "rename");
    }
    return mRenameButton;
  }
  
  private JButton getDeleteButton()
  {
    if (mDeleteButton == null) {
      mDeleteButton = makeButton("Delete", "delete");
    }
    return mDeleteButton;
  }
  
  private JButton getRefreshButton()
  {
    if (mRefreshButton == null) {
      mRefreshButton = makeButton("Refresh", "refresh");
    }
    return mRefreshButton;
  }
  
  private FileList getFileList()
  {
    if (mFileList == null)
    {
      mFileList = new FileList();
      mFileList.addListSelectionListener(this);
      mFileList.addMouseListener(this);
    }
    return mFileList;
  }
  
  private void enableButtons()
  {
    mRenameButton.setEnabled(mFileList.getSelectionCount() == 1);
    mDeleteButton.setEnabled(mFileList.getSelectionCount() > 0);
  }
  
  public String getFileSystemLocation()
  {
    return (String)getFileSystemLocationComboBox().getSelectedItem();
  }
  
  private void setFileSystemLocations(String[] paramArrayOfString, String paramString1, String paramString2)
  {
    ArrayList localArrayList = new ArrayList();
    if (paramArrayOfString != null)
    {
      localArrayList.add(paramString2);
      try
      {
        File localFile = new File(paramString2);
        while (localFile != null)
        {
          localFile = localFile.getParentFile();
          String str2 = localFile.getCanonicalPath();
          if (!str2.endsWith(paramString1)) {
            str2 = str2 + paramString1;
          }
          localArrayList.add(0, str2);
        }
      }
      catch (Throwable localThrowable) {}
      for (int i = 0; i < paramArrayOfString.length; i++) {
        localArrayList.add(paramArrayOfString[i]);
      }
    }
    else
    {
      int j;
      for (String str1 = paramString2;; str1 = str1.substring(0, j + 1))
      {
        localArrayList.add(0, str1);
        j = str1.lastIndexOf(paramString1, str1.length() - 2);
        if (j < 0) {
          break;
        }
      }
    }
    mCurrDir = paramString2;
    getFileSystemLocationComboBox().setModel(new DefaultComboBoxModel(localArrayList.toArray(new String[localArrayList.size()])));
    getFileSystemLocationComboBox().setSelectedItem(paramString2);
  }
  
  public void setFileList(Vector<FileListItem> paramVector1, Vector<FileListItem> paramVector2, String paramString1, String paramString2, boolean paramBoolean)
  {
    if (!paramString1.endsWith(paramString2)) {
      paramString1 = paramString1 + paramString2;
    }
    String[] arrayOfString = null;
    if (paramBoolean) {
      try
      {
        ArrayList localArrayList = new ArrayList();
        File[] arrayOfFile = File.listRoots();
        if (arrayOfFile.length > 1)
        {
          String str1 = new File(paramString1).getCanonicalPath();
          for (int m = 0; m < arrayOfFile.length; m++)
          {
            String str2 = arrayOfFile[m].toString();
            if (!str1.startsWith(str2)) {
              localArrayList.add(str2);
            }
          }
        }
        arrayOfString = (String[])localArrayList.toArray(new String[localArrayList.size()]);
      }
      catch (Throwable localThrowable) {}
    }
    setFileSystemLocations(arrayOfString, paramString2, paramString1);
    int j = paramVector1.size();
    int k = paramVector2.size();
    long l = 0L;
    FileListItem[] arrayOfFileListItem = new FileListItem[j + k];
    for (int i = 0; i < j; i++) {
      arrayOfFileListItem[i] = ((FileListItem)paramVector1.elementAt(i));
    }
    for (i = 0; i < k; i++)
    {
      localObject = (FileListItem)paramVector2.elementAt(i);
      arrayOfFileListItem[(i + j)] = localObject;
      l += ((FileListItem)localObject).getSize();
    }
    Object localObject = "";
    if (l > 0L) {
      localObject = " (" + StringUtil.nBytesToString(l, 4) + ")";
    }
    getMachineDescriptionLabel().setText(mMachineDescriptionText + " : " + k + " file" + (k > 1 ? "s" : "") + (String)localObject);
    ArraySort.sort(arrayOfFileListItem, 0, j);
    ArraySort.sort(arrayOfFileListItem, j, j + k);
    paramVector1.setSize(0);
    paramVector2.setSize(0);
    mFileList.setListItems(arrayOfFileListItem);
    enableButtons();
  }
  
  public void setFileBrowser(FileBrowser paramFileBrowser)
  {
    mBrowser = paramFileBrowser;
  }
  
  public FileListItem getSelectedFile()
  {
    return mFileList.getSelectedFileListItem();
  }
  
  public FileListItem[] getSelectedFiles()
  {
    return mFileList.getSelectedFileListItems();
  }
}

/* Location:
 * Qualified Name:     com.isnetworks.ssh.FileDisplay
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.isnetworks.ssh;

import java.util.Vector;

public abstract interface FileDisplayControl
{
  public abstract void setFileBrowser(FileBrowser paramFileBrowser);
  
  public abstract void setFileList(Vector<FileListItem> paramVector1, Vector<FileListItem> paramVector2, String paramString1, String paramString2, boolean paramBoolean);
}

/* Location:
 * Qualified Name:     com.isnetworks.ssh.FileDisplayControl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.isnetworks.ssh;

import com.mindbright.util.StringUtil;
import javax.swing.JList;
import javax.swing.ListModel;

public class FileList
  extends JList
{
  private static final long serialVersionUID = 1L;
  private FileListItem[] mListItems;
  
  public void setListItems(FileListItem[] paramArrayOfFileListItem)
  {
    mListItems = paramArrayOfFileListItem;
    String[] arrayOfString = new String[paramArrayOfFileListItem.length];
    for (int i = 0; i < paramArrayOfFileListItem.length; i++)
    {
      FileListItem localFileListItem = paramArrayOfFileListItem[i];
      if (localFileListItem.isDirectory())
      {
        arrayOfString[i] = ("[" + localFileListItem.getName() + "]");
      }
      else
      {
        long l = localFileListItem.getSize();
        arrayOfString[i] = (localFileListItem.getName() + (l >= 0L ? " (" + StringUtil.nBytesToString(l, 4) + ")" : ""));
      }
    }
    setListData(arrayOfString);
  }
  
  public FileListItem getSelectedFileListItem()
  {
    FileListItem localFileListItem = null;
    if (getSelectedIndex() != -1) {
      localFileListItem = mListItems[getSelectedIndex()];
    }
    return localFileListItem;
  }
  
  public FileListItem[] getSelectedFileListItems()
  {
    int[] arrayOfInt = getSelectedIndices();
    int i = (isSelectedIndex(0)) && (mListItems[0].getName().equals("..")) ? 1 : 0;
    FileListItem[] arrayOfFileListItem = new FileListItem[getSelectionCount()];
    int j = 0;
    for (int k = 0; k < arrayOfInt.length; k++) {
      if ((arrayOfInt[k] != 0) || (i == 0)) {
        arrayOfFileListItem[(j++)] = mListItems[arrayOfInt[k]];
      }
    }
    return arrayOfFileListItem;
  }
  
  public int getSelectionCount()
  {
    int[] arrayOfInt = getSelectedIndices();
    if ((isSelectedIndex(0)) && (mListItems[0].getName().equals(".."))) {
      return arrayOfInt.length - 1;
    }
    return arrayOfInt.length;
  }
  
  public FileListItem getFileListItem(String paramString)
  {
    if (paramString != null)
    {
      ListModel localListModel = getModel();
      for (int i = 0; i < localListModel.getSize(); i++) {
        if (paramString.equals(localListModel.getElementAt(i))) {
          return mListItems[i];
        }
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     com.isnetworks.ssh.FileList
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.isnetworks.ssh;

import com.mindbright.util.ArraySort;
import com.mindbright.util.ArraySort.Comparable;

public final class FileListItem
  implements ArraySort.Comparable
{
  private String name;
  private String parent;
  private boolean directory;
  private long size;
  
  public FileListItem(String paramString1, String paramString2, boolean paramBoolean, String paramString3)
  {
    this(paramString1, paramString2, paramBoolean, paramString3, -1L);
  }
  
  public FileListItem(String paramString1, String paramString2, boolean paramBoolean, String paramString3, long paramLong)
  {
    if (!paramString2.endsWith(paramString3)) {
      paramString2 = paramString2 + paramString3;
    }
    name = paramString1;
    parent = paramString2;
    directory = paramBoolean;
    size = paramLong;
  }
  
  public String getAbsolutePath()
  {
    return parent + name;
  }
  
  public String getName()
  {
    return name;
  }
  
  public long getSize()
  {
    return size;
  }
  
  public String getParent()
  {
    return parent;
  }
  
  public boolean isDirectory()
  {
    return directory;
  }
  
  public void sort(FileListItem[] paramArrayOfFileListItem)
  {
    ArraySort.sort(paramArrayOfFileListItem);
  }
  
  public int compareTo(ArraySort.Comparable paramComparable)
  {
    if (name.equals("..")) {
      return -1;
    }
    FileListItem localFileListItem = (FileListItem)paramComparable;
    return name.toUpperCase().compareTo(name.toUpperCase());
  }
}

/* Location:
 * Qualified Name:     com.isnetworks.ssh.FileListItem
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.isnetworks.ssh;

import java.io.File;
import java.io.IOException;
import java.util.Vector;

public class LocalFileBrowser
  extends AbstractFileBrowser
{
  private File cwd;
  
  public LocalFileBrowser(FileDisplayControl paramFileDisplayControl, String paramString)
  {
    super(paramFileDisplayControl);
    try
    {
      changeDirectory(paramString);
    }
    catch (Exception localException)
    {
      cwd = new File(".");
    }
  }
  
  public void initialize()
    throws Exception
  {
    refresh();
  }
  
  public void refresh()
    throws Exception
  {
    String[] arrayOfString = cwd.list();
    int i = cwd.getParent() == null ? 1 : 0;
    if (i == 0) {
      dirs.addElement(new FileListItem("..", "", true, File.separator));
    }
    String str = null;
    try
    {
      str = cwd.getCanonicalPath();
    }
    catch (IOException localIOException)
    {
      throw new Exception("Unable to refresh file list");
    }
    if (arrayOfString != null) {
      for (int j = 0; j < arrayOfString.length; j++)
      {
        File localFile = new File(cwd, arrayOfString[j]);
        FileListItem localFileListItem = new FileListItem(arrayOfString[j], str, localFile.isDirectory(), File.separator, localFile.length());
        if (localFile.isDirectory()) {
          dirs.addElement(localFileListItem);
        } else {
          files.addElement(localFileListItem);
        }
      }
    }
    mFileDisplay.setFileList(dirs, files, str, File.separator, true);
  }
  
  public void makeDirectory(String paramString)
    throws Exception
  {
    File localFile = new File(cwd, paramString);
    if (!localFile.mkdirs()) {
      throw new Exception("Unable to make directory: " + localFile.getAbsolutePath());
    }
  }
  
  public void delete(FileListItem[] paramArrayOfFileListItem)
    throws Exception
  {
    for (int i = 0; i < paramArrayOfFileListItem.length; i++)
    {
      File localFile = new File(paramArrayOfFileListItem[i].getParent(), paramArrayOfFileListItem[i].getName());
      if (!localFile.delete()) {
        throw new Exception("Unable to delete " + paramArrayOfFileListItem[i].getAbsolutePath() + " - may not have permission or directory may not be empty");
      }
    }
  }
  
  public void changeDirectory(String paramString)
    throws Exception
  {
    File localFile = new File(paramString);
    if (!localFile.exists()) {
      throw new Exception("Directory " + paramString + " does not exist or you do not have permission to access it.");
    }
    if (localFile.isFile()) {
      throw new Exception(paramString + " a file, not a directory.");
    }
    cwd = localFile;
  }
  
  public void rename(FileListItem paramFileListItem, String paramString)
    throws Exception
  {
    File localFile1 = new File(paramFileListItem.getParent(), paramFileListItem.getName());
    File localFile2 = null;
    if (!paramString.startsWith(File.separator)) {
      localFile2 = new File(cwd, paramString);
    } else {
      localFile2 = new File(paramString);
    }
    if (!localFile1.renameTo(localFile2)) {
      throw new Exception("Unable to rename file " + paramFileListItem.getAbsolutePath() + " to " + paramString);
    }
  }
  
  public void fileDoubleClicked(FileListItem paramFileListItem)
    throws Exception
  {
    if (paramFileListItem.isDirectory())
    {
      File localFile = null;
      if (paramFileListItem.getName().equals("..")) {
        localFile = new File(cwd.getParent());
      } else {
        localFile = new File(paramFileListItem.getParent(), paramFileListItem.getName());
      }
      if ((!localFile.exists()) || (!localFile.isDirectory())) {
        throw new Exception("Unable to open directory: " + localFile.getAbsolutePath());
      }
      cwd = localFile;
    }
  }
}

/* Location:
 * Qualified Name:     com.isnetworks.ssh.LocalFileBrowser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.jcraft.jzlib;

final class Adler32
{
  private static final int BASE = 65521;
  private static final int NMAX = 5552;
  
  long adler32(long paramLong, byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    if (paramArrayOfByte == null) {
      return 1L;
    }
    long l1 = paramLong & 0xFFFF;
    for (long l2 = paramLong >> 16 & 0xFFFF; paramInt2 > 0; l2 %= 65521L)
    {
      int i = paramInt2 < 5552 ? paramInt2 : 5552;
      paramInt2 -= i;
      while (i >= 16)
      {
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
        l2 += l1;
        i -= 16;
      }
      if (i != 0) {
        do
        {
          l1 += (paramArrayOfByte[(paramInt1++)] & 0xFF);
          l2 += l1;
          i--;
        } while (i != 0);
      }
      l1 %= 65521L;
    }
    return l2 << 16 | l1;
  }
}

/* Location:
 * Qualified Name:     com.jcraft.jzlib.Adler32
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.jcraft.jzlib;

class Deflate$Config
{
  int good_length;
  int max_lazy;
  int nice_length;
  int max_chain;
  int func;
  
  Deflate$Config(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5)
  {
    good_length = paramInt1;
    max_lazy = paramInt2;
    nice_length = paramInt3;
    max_chain = paramInt4;
    func = paramInt5;
  }
}

/* Location:
 * Qualified Name:     com.jcraft.jzlib.Deflate.Config
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.jcraft.jzlib;

public final class Deflate
{
  private static final int MAX_MEM_LEVEL = 9;
  private static final int Z_DEFAULT_COMPRESSION = -1;
  private static final int MAX_WBITS = 15;
  private static final int DEF_MEM_LEVEL = 8;
  private static final int STORED = 0;
  private static final int FAST = 1;
  private static final int SLOW = 2;
  private static final Config[] config_table = new Config[10];
  private static final String[] z_errmsg = { "need dictionary", "stream end", "", "file error", "stream error", "data error", "insufficient memory", "buffer error", "incompatible version", "" };
  private static final int NeedMore = 0;
  private static final int BlockDone = 1;
  private static final int FinishStarted = 2;
  private static final int FinishDone = 3;
  private static final int PRESET_DICT = 32;
  private static final int Z_FILTERED = 1;
  private static final int Z_HUFFMAN_ONLY = 2;
  private static final int Z_DEFAULT_STRATEGY = 0;
  private static final int Z_NO_FLUSH = 0;
  private static final int Z_PARTIAL_FLUSH = 1;
  private static final int Z_FULL_FLUSH = 3;
  private static final int Z_FINISH = 4;
  private static final int Z_OK = 0;
  private static final int Z_STREAM_END = 1;
  private static final int Z_NEED_DICT = 2;
  private static final int Z_STREAM_ERROR = -2;
  private static final int Z_DATA_ERROR = -3;
  private static final int Z_BUF_ERROR = -5;
  private static final int INIT_STATE = 42;
  private static final int BUSY_STATE = 113;
  private static final int FINISH_STATE = 666;
  private static final int Z_DEFLATED = 8;
  private static final int STORED_BLOCK = 0;
  private static final int STATIC_TREES = 1;
  private static final int DYN_TREES = 2;
  private static final int Z_BINARY = 0;
  private static final int Z_ASCII = 1;
  private static final int Z_UNKNOWN = 2;
  private static final int Buf_size = 16;
  private static final int REP_3_6 = 16;
  private static final int REPZ_3_10 = 17;
  private static final int REPZ_11_138 = 18;
  private static final int MIN_MATCH = 3;
  private static final int MAX_MATCH = 258;
  private static final int MIN_LOOKAHEAD = 262;
  private static final int MAX_BITS = 15;
  private static final int D_CODES = 30;
  private static final int BL_CODES = 19;
  private static final int LENGTH_CODES = 29;
  private static final int LITERALS = 256;
  private static final int L_CODES = 286;
  private static final int HEAP_SIZE = 573;
  private static final int END_BLOCK = 256;
  ZStream strm;
  int status;
  byte[] pending_buf;
  int pending_buf_size;
  int pending_out;
  int pending;
  int noheader;
  byte data_type;
  byte method;
  int last_flush;
  int w_size;
  int w_bits;
  int w_mask;
  byte[] window;
  int window_size;
  short[] prev;
  short[] head;
  int ins_h;
  int hash_size;
  int hash_bits;
  int hash_mask;
  int hash_shift;
  int block_start;
  int match_length;
  int prev_match;
  int match_available;
  int strstart;
  int match_start;
  int lookahead;
  int prev_length;
  int max_chain_length;
  int max_lazy_match;
  int level;
  int strategy;
  int good_match;
  int nice_match;
  short[] dyn_ltree = new short['?'];
  short[] dyn_dtree = new short[122];
  short[] bl_tree = new short[78];
  Tree l_desc = new Tree();
  Tree d_desc = new Tree();
  Tree bl_desc = new Tree();
  short[] bl_count = new short[16];
  int[] heap = new int['?'];
  int heap_len;
  int heap_max;
  byte[] depth = new byte['?'];
  int l_buf;
  int lit_bufsize;
  int last_lit;
  int d_buf;
  int opt_len;
  int static_len;
  int matches;
  int last_eob_len;
  short bi_buf;
  int bi_valid;
  
  void lm_init()
  {
    window_size = (2 * w_size);
    head[(hash_size - 1)] = 0;
    for (int i = 0; i < hash_size - 1; i++) {
      head[i] = 0;
    }
    max_lazy_match = config_tablelevel].max_lazy;
    good_match = config_tablelevel].good_length;
    nice_match = config_tablelevel].nice_length;
    max_chain_length = config_tablelevel].max_chain;
    strstart = 0;
    block_start = 0;
    lookahead = 0;
    match_length = (prev_length = 2);
    match_available = 0;
    ins_h = 0;
  }
  
  void tr_init()
  {
    l_desc.dyn_tree = dyn_ltree;
    l_desc.stat_desc = StaticTree.static_l_desc;
    d_desc.dyn_tree = dyn_dtree;
    d_desc.stat_desc = StaticTree.static_d_desc;
    bl_desc.dyn_tree = bl_tree;
    bl_desc.stat_desc = StaticTree.static_bl_desc;
    bi_buf = 0;
    bi_valid = 0;
    last_eob_len = 8;
    init_block();
  }
  
  void init_block()
  {
    for (int i = 0; i < 286; i++) {
      dyn_ltree[(i * 2)] = 0;
    }
    for (i = 0; i < 30; i++) {
      dyn_dtree[(i * 2)] = 0;
    }
    for (i = 0; i < 19; i++) {
      bl_tree[(i * 2)] = 0;
    }
    dyn_ltree['?'] = 1;
    opt_len = (static_len = 0);
    last_lit = (matches = 0);
  }
  
  void pqdownheap(short[] paramArrayOfShort, int paramInt)
  {
    int i = heap[paramInt];
    int j = paramInt << 1;
    while (j <= heap_len)
    {
      if ((j < heap_len) && (smaller(paramArrayOfShort, heap[(j + 1)], heap[j], depth))) {
        j++;
      }
      if (smaller(paramArrayOfShort, i, heap[j], depth)) {
        break;
      }
      heap[paramInt] = heap[j];
      paramInt = j;
      j <<= 1;
    }
    heap[paramInt] = i;
  }
  
  static boolean smaller(short[] paramArrayOfShort, int paramInt1, int paramInt2, byte[] paramArrayOfByte)
  {
    int i = paramArrayOfShort[(paramInt1 * 2)];
    int j = paramArrayOfShort[(paramInt2 * 2)];
    return (i < j) || ((i == j) && (paramArrayOfByte[paramInt1] <= paramArrayOfByte[paramInt2]));
  }
  
  void scan_tree(short[] paramArrayOfShort, int paramInt)
  {
    int j = -1;
    int m = paramArrayOfShort[1];
    int n = 0;
    int i1 = 7;
    int i2 = 4;
    if (m == 0)
    {
      i1 = 138;
      i2 = 3;
    }
    paramArrayOfShort[((paramInt + 1) * 2 + 1)] = -1;
    for (int i = 0; i <= paramInt; i++)
    {
      int k = m;
      m = paramArrayOfShort[((i + 1) * 2 + 1)];
      n++;
      if ((n >= i1) || (k != m))
      {
        if (n < i2)
        {
          int tmp98_97 = (k * 2);
          short[] tmp98_91 = bl_tree;
          tmp98_91[tmp98_97] = ((short)(tmp98_91[tmp98_97] + n));
        }
        else if (k != 0)
        {
          if (k != j)
          {
            int tmp128_127 = (k * 2);
            short[] tmp128_121 = bl_tree;
            tmp128_121[tmp128_127] = ((short)(tmp128_121[tmp128_127] + 1));
          }
          short[] tmp140_135 = bl_tree;
          tmp140_135[32] = ((short)(tmp140_135[32] + 1));
        }
        else if (n <= 10)
        {
          short[] tmp162_157 = bl_tree;
          tmp162_157[34] = ((short)(tmp162_157[34] + 1));
        }
        else
        {
          short[] tmp177_172 = bl_tree;
          tmp177_172[36] = ((short)(tmp177_172[36] + 1));
        }
        n = 0;
        j = k;
        if (m == 0)
        {
          i1 = 138;
          i2 = 3;
        }
        else if (k == m)
        {
          i1 = 6;
          i2 = 3;
        }
        else
        {
          i1 = 7;
          i2 = 4;
        }
      }
    }
  }
  
  int build_bl_tree()
  {
    scan_tree(dyn_ltree, l_desc.max_code);
    scan_tree(dyn_dtree, d_desc.max_code);
    bl_desc.build_tree(this);
    for (int i = 18; (i >= 3) && (bl_tree[(Tree.bl_order[i] * 2 + 1)] == 0); i--) {}
    opt_len += 3 * (i + 1) + 5 + 5 + 4;
    return i;
  }
  
  void send_all_trees(int paramInt1, int paramInt2, int paramInt3)
  {
    send_bits(paramInt1 - 257, 5);
    send_bits(paramInt2 - 1, 5);
    send_bits(paramInt3 - 4, 4);
    for (int i = 0; i < paramInt3; i++) {
      send_bits(bl_tree[(Tree.bl_order[i] * 2 + 1)], 3);
    }
    send_tree(dyn_ltree, paramInt1 - 1);
    send_tree(dyn_dtree, paramInt2 - 1);
  }
  
  void send_tree(short[] paramArrayOfShort, int paramInt)
  {
    int j = -1;
    int m = paramArrayOfShort[1];
    int n = 0;
    int i1 = 7;
    int i2 = 4;
    if (m == 0)
    {
      i1 = 138;
      i2 = 3;
    }
    for (int i = 0; i <= paramInt; i++)
    {
      int k = m;
      m = paramArrayOfShort[((i + 1) * 2 + 1)];
      n++;
      if ((n >= i1) || (k != m))
      {
        if (n < i2)
        {
          do
          {
            send_code(k, bl_tree);
            n--;
          } while (n != 0);
        }
        else if (k != 0)
        {
          if (k != j)
          {
            send_code(k, bl_tree);
            n--;
          }
          send_code(16, bl_tree);
          send_bits(n - 3, 2);
        }
        else if (n <= 10)
        {
          send_code(17, bl_tree);
          send_bits(n - 3, 3);
        }
        else
        {
          send_code(18, bl_tree);
          send_bits(n - 11, 7);
        }
        n = 0;
        j = k;
        if (m == 0)
        {
          i1 = 138;
          i2 = 3;
        }
        else if (k == m)
        {
          i1 = 6;
          i2 = 3;
        }
        else
        {
          i1 = 7;
          i2 = 4;
        }
      }
    }
  }
  
  final void put_byte(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    System.arraycopy(paramArrayOfByte, paramInt1, pending_buf, pending, paramInt2);
    pending += paramInt2;
  }
  
  final void put_byte(byte paramByte)
  {
    pending_buf[(pending++)] = paramByte;
  }
  
  final void put_short(int paramInt)
  {
    put_byte((byte)paramInt);
    put_byte((byte)(paramInt >>> 8));
  }
  
  final void putShortMSB(int paramInt)
  {
    put_byte((byte)(paramInt >> 8));
    put_byte((byte)paramInt);
  }
  
  final void send_code(int paramInt, short[] paramArrayOfShort)
  {
    int i = paramInt * 2;
    send_bits(paramArrayOfShort[i] & 0xFFFF, paramArrayOfShort[(i + 1)] & 0xFFFF);
  }
  
  void send_bits(int paramInt1, int paramInt2)
  {
    int i = paramInt2;
    if (bi_valid > 16 - i)
    {
      int j = paramInt1;
      bi_buf = ((short)(bi_buf | j << bi_valid & 0xFFFF));
      put_short(bi_buf);
      bi_buf = ((short)(j >>> 16 - bi_valid));
      bi_valid += i - 16;
    }
    else
    {
      bi_buf = ((short)(bi_buf | paramInt1 << bi_valid & 0xFFFF));
      bi_valid += i;
    }
  }
  
  void _tr_align()
  {
    send_bits(2, 3);
    send_code(256, StaticTree.static_ltree);
    bi_flush();
    if (1 + last_eob_len + 10 - bi_valid < 9)
    {
      send_bits(2, 3);
      send_code(256, StaticTree.static_ltree);
      bi_flush();
    }
    last_eob_len = 7;
  }
  
  boolean _tr_tally(int paramInt1, int paramInt2)
  {
    pending_buf[(d_buf + last_lit * 2)] = ((byte)(paramInt1 >>> 8));
    pending_buf[(d_buf + last_lit * 2 + 1)] = ((byte)paramInt1);
    pending_buf[(l_buf + last_lit)] = ((byte)paramInt2);
    last_lit += 1;
    if (paramInt1 == 0)
    {
      int tmp78_77 = (paramInt2 * 2);
      short[] tmp78_72 = dyn_ltree;
      tmp78_72[tmp78_77] = ((short)(tmp78_72[tmp78_77] + 1));
    }
    else
    {
      matches += 1;
      paramInt1--;
      int tmp117_116 = ((Tree._length_code[paramInt2] + 256 + 1) * 2);
      short[] tmp117_101 = dyn_ltree;
      tmp117_101[tmp117_116] = ((short)(tmp117_101[tmp117_116] + 1));
      int tmp133_132 = (Tree.d_code(paramInt1) * 2);
      short[] tmp133_124 = dyn_dtree;
      tmp133_124[tmp133_132] = ((short)(tmp133_124[tmp133_132] + 1));
    }
    if (((last_lit & 0x1FFF) == 0) && (level > 2))
    {
      int i = last_lit * 8;
      int j = strstart - block_start;
      for (int k = 0; k < 30; k++) {
        i = (int)(i + dyn_dtree[(k * 2)] * (5L + Tree.extra_dbits[k]));
      }
      i >>>= 3;
      if ((matches < last_lit / 2) && (i < j / 2)) {
        return true;
      }
    }
    return last_lit == lit_bufsize - 1;
  }
  
  void compress_block(short[] paramArrayOfShort1, short[] paramArrayOfShort2)
  {
    int k = 0;
    if (last_lit != 0) {
      do
      {
        int i = pending_buf[(d_buf + k * 2)] << 8 & 0xFF00 | pending_buf[(d_buf + k * 2 + 1)] & 0xFF;
        int j = pending_buf[(l_buf + k)] & 0xFF;
        k++;
        if (i == 0)
        {
          send_code(j, paramArrayOfShort1);
        }
        else
        {
          int m = Tree._length_code[j];
          send_code(m + 256 + 1, paramArrayOfShort1);
          int n = Tree.extra_lbits[m];
          if (n != 0)
          {
            j -= Tree.base_length[m];
            send_bits(j, n);
          }
          i--;
          m = Tree.d_code(i);
          send_code(m, paramArrayOfShort2);
          n = Tree.extra_dbits[m];
          if (n != 0)
          {
            i -= Tree.base_dist[m];
            send_bits(i, n);
          }
        }
      } while (k < last_lit);
    }
    send_code(256, paramArrayOfShort1);
    last_eob_len = paramArrayOfShort1['?'];
  }
  
  void set_data_type()
  {
    int i = 0;
    int j = 0;
    int k = 0;
    while (i < 7)
    {
      k += dyn_ltree[(i * 2)];
      i++;
    }
    while (i < 128)
    {
      j += dyn_ltree[(i * 2)];
      i++;
    }
    while (i < 256)
    {
      k += dyn_ltree[(i * 2)];
      i++;
    }
    data_type = ((byte)(k > j >>> 2 ? 0 : 1));
  }
  
  void bi_flush()
  {
    if (bi_valid == 16)
    {
      put_short(bi_buf);
      bi_buf = 0;
      bi_valid = 0;
    }
    else if (bi_valid >= 8)
    {
      put_byte((byte)bi_buf);
      bi_buf = ((short)(bi_buf >>> 8));
      bi_valid -= 8;
    }
  }
  
  void bi_windup()
  {
    if (bi_valid > 8) {
      put_short(bi_buf);
    } else if (bi_valid > 0) {
      put_byte((byte)bi_buf);
    }
    bi_buf = 0;
    bi_valid = 0;
  }
  
  void copy_block(int paramInt1, int paramInt2, boolean paramBoolean)
  {
    bi_windup();
    last_eob_len = 8;
    if (paramBoolean)
    {
      put_short((short)paramInt2);
      put_short((short)(paramInt2 ^ 0xFFFFFFFF));
    }
    put_byte(window, paramInt1, paramInt2);
  }
  
  void flush_block_only(boolean paramBoolean)
  {
    _tr_flush_block(block_start >= 0 ? block_start : -1, strstart - block_start, paramBoolean);
    block_start = strstart;
    strm.flush_pending();
  }
  
  int deflate_stored(int paramInt)
  {
    int i = 65535;
    if (i > pending_buf_size - 5) {
      i = pending_buf_size - 5;
    }
    do
    {
      do
      {
        if (lookahead <= 1)
        {
          fill_window();
          if ((lookahead == 0) && (paramInt == 0)) {
            return 0;
          }
          if (lookahead == 0) {
            break;
          }
        }
        strstart += lookahead;
        lookahead = 0;
        int j = block_start + i;
        if ((strstart == 0) || (strstart >= j))
        {
          lookahead = (strstart - j);
          strstart = j;
          flush_block_only(false);
          if (strm.avail_out == 0) {
            return 0;
          }
        }
      } while (strstart - block_start < w_size - 262);
      flush_block_only(false);
    } while (strm.avail_out != 0);
    return 0;
    flush_block_only(paramInt == 4);
    if (strm.avail_out == 0) {
      return paramInt == 4 ? 2 : 0;
    }
    return paramInt == 4 ? 3 : 1;
  }
  
  void _tr_stored_block(int paramInt1, int paramInt2, boolean paramBoolean)
  {
    send_bits(0 + (paramBoolean ? 1 : 0), 3);
    copy_block(paramInt1, paramInt2, true);
  }
  
  void _tr_flush_block(int paramInt1, int paramInt2, boolean paramBoolean)
  {
    int k = 0;
    int i;
    int j;
    if (level > 0)
    {
      if (data_type == 2) {
        set_data_type();
      }
      l_desc.build_tree(this);
      d_desc.build_tree(this);
      k = build_bl_tree();
      i = opt_len + 3 + 7 >>> 3;
      j = static_len + 3 + 7 >>> 3;
      if (j <= i) {
        i = j;
      }
    }
    else
    {
      i = j = paramInt2 + 5;
    }
    if ((paramInt2 + 4 <= i) && (paramInt1 != -1))
    {
      _tr_stored_block(paramInt1, paramInt2, paramBoolean);
    }
    else if (j == i)
    {
      send_bits(2 + (paramBoolean ? 1 : 0), 3);
      compress_block(StaticTree.static_ltree, StaticTree.static_dtree);
    }
    else
    {
      send_bits(4 + (paramBoolean ? 1 : 0), 3);
      send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1, k + 1);
      compress_block(dyn_ltree, dyn_dtree);
    }
    init_block();
    if (paramBoolean) {
      bi_windup();
    }
  }
  
  void fill_window()
  {
    do
    {
  
1 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

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd