Skip to content

Commit

Permalink
Initial import.
Browse files Browse the repository at this point in the history
  • Loading branch information
xarnonymous committed Oct 11, 2009
0 parents commit d291e7e
Show file tree
Hide file tree
Showing 39 changed files with 7,673 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax:glob
*.exe
*.o
*~
.deps/
Makefile
Makefile.in
aclocal.m4
autom4te.cache
config.h
config.h.in
config.log
config.status
configure
datpacker
depcomp
eclc
ecldump
install-sh
lexer.c
missing
parser.c
parser.h
stamp-h1
thanm
ylwrap
26 changes: 26 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain this list
of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce this
list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
2 changes: 2 additions & 0 deletions COPYING.autotools
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Generated files contain exceptions which allow them to be licensed under the
same license as the parent project.
689 changes: 689 additions & 0 deletions COPYING.bison

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions COPYING.flex
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Flex carries the copyright used for BSD software, slightly modified
because it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
which operates under a contract with the Department of Energy:

Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Flex Project.

Copyright (c) 1990, 1997 The Regents of the University of California.
All rights reserved.

This code is derived from software contributed to Berkeley by
Vern Paxson.

The United States Government has rights in this work pursuant
to contract no. DE-AC03-76SF00098 between the United States
Department of Energy and the University of California.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.

This basically says "do whatever you please with this software except
remove this notice or take advantage of the University's (or the flex
authors') name".

Note that the "flex.skl" scanner skeleton carries no copyright notice.
You are free to do whatever you please with scanners generated using flex;
for them, you are not even bound by the above copyright.
482 changes: 482 additions & 0 deletions COPYING.libiconv

Large diffs are not rendered by default.

110 changes: 110 additions & 0 deletions COPYING.libpng
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
This copy of the libpng notices is provided for your convenience. In case of
any discrepancy between this copy and the notices in the file png.h that is
included in the libpng distribution, the latter shall prevail.

COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:

If you modify libpng you may insert additional notices immediately following
this sentence.

This code is released under the libpng license.

libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are
Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors

Cosmin Truta

libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors

Simon-Pierre Cadieux
Eric S. Raymond
Gilles Vollant

and with the following additions to the disclaimer:

There is no warranty against interference with your enjoyment of the
library or against infringement. There is no warranty that our
efforts or the library will fulfill any of your particular purposes
or needs. This library is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.

libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:

Tom Lane
Glenn Randers-Pehrson
Willem van Schaik

libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:

John Bowler
Kevin Bracey
Sam Bushell
Magnus Holmgren
Greg Roelofs
Tom Tanner

libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.

For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:

Andreas Dilger
Dave Martindale
Guy Eric Schalnat
Paul Schmidt
Tim Wegner

The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.

Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:

1. The origin of this source code must not be misrepresented.

2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.

3. This Copyright notice may not be removed or altered from any
source or altered source distribution.

The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.


A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:

printf("%s",png_get_copyright(NULL));

Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).

Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.

Glenn Randers-Pehrson
glennrp at users.sourceforge.net
September 10, 2009
20 changes: 20 additions & 0 deletions COPYING.zlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(C) 1995-2004 Jean-loup Gailly and Mark Adler

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

Jean-loup Gailly Mark Adler
[email protected] [email protected]
71 changes: 71 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
AM_YFLAGS = -d
AM_CFLAGS = -pedantic -Wall -Wextra
LDADD = @iconv_LIBS@
BUILT_SOURCES = parser.h parser.c lexer.c
bin_PROGRAMS = datpacker eclc ecldump thanm

if COMBINE
am_datpacker_OBJECTS = datpacker.o
am_eclc_OBJECTS = eclc.o
am_ecldump_OBJECTS = ecldump.o
am_thanm_OBJECTS = thanm.o

datpacker.o: $(datpacker_SOURCES)
$(COMPILE) $(datpacker_CFLAGS) @combine_CFLAGS@ -c -o $@ $(filter %.c,$(datpacker_SOURCES))

eclc.o: $(eclc_SOURCES)
$(COMPILE) $(eclc_CFLAGS) @combine_CFLAGS@ -c -o $@ $(filter %.c,$(eclc_SOURCES)) parser.c lexer.c

ecldump.o: $(ecldump_SOURCES)
$(COMPILE) $(ecldump_CFLAGS) @combine_CFLAGS@ -c -o $@ $(filter %.c,$(ecldump_SOURCES))

thanm.o: $(thanm_SOURCES)
$(COMPILE) $(thanm_CFLAGS) @combine_CFLAGS@ -c -o $@ $(filter %.c,$(thanm_SOURCES))
endif

util_SOURCES = \
program.c \
program.h \
util.c \
util.h

datpacker_CFLAGS = $(OPENMP_CFLAGS)
datpacker_SOURCES = \
bits.c \
bits.h \
datpacker-th02.c \
datpacker-th06.c \
datpacker-th08.c \
datpacker-th75.c \
datpacker-th95.c \
datpacker.c \
datpacker.h \
thcrypt.c \
thcrypt.h \
thdat.c \
thdat.h \
thlzss.c \
thlzss.h \
thrle.c \
thrle.h \
$(util_SOURCES)

eclc_SOURCES = \
parser.h \
lexer.l \
parser.y \
$(util_SOURCES)

ecldump_LDADD = $(LDADD) -lm
ecldump_SOURCES = \
ecldump.c \
instr.c \
instr.h \
$(util_SOURCES)

thanm_CFLAGS = $(libpng_CFAGS)
thanm_LDADD = $(LDADD) $(libpng_LIBS)
thanm_SOURCES = \
thanm.c \
thanm.h \
$(util_SOURCES)
84 changes: 84 additions & 0 deletions bits.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain this list
* of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce this
* list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include "bits.h"

void
bitstream_init(bitstream_t* b, unsigned int size)
{
b->used_bytes = 0;
b->buffer = NULL;
b->buffer_size = size;
b->next_byte = 0;
b->used_bits = 0;
bitstream_grow(b);
}

void
bitstream_finish(bitstream_t* b)
{
while (b->used_bits)
bitstream_write1(b, 0);
}

void
bitstream_grow(bitstream_t* b)
{
b->buffer_size <<= 1;
b->buffer = realloc(b->buffer, b->buffer_size);
}

void
bitstream_write(bitstream_t* b, unsigned int bits, uint32_t data)
{
int i;
if (bits > 32)
bits = 32;
for (i = bits - 1; i >= 0; --i) {
const unsigned int bit = (data >> i) & 1;
bitstream_write1(b, bit);
}
}

void
bitstream_write1(bitstream_t* b, unsigned int bit)
{
b->next_byte |= bit << (7 - b->used_bits);
b->used_bits++;
if (b->used_bits >= 8) {
b->buffer[b->used_bytes] = b->next_byte;
b->used_bytes++;
if (b->used_bytes >= b->buffer_size)
bitstream_grow(b);
b->next_byte = 0;
b->used_bits = 0;
}
}
Loading

0 comments on commit d291e7e

Please sign in to comment.