mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-11 11:10:49 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45ab61f532 |
No files matched your search
@@ -0,0 +1,186 @@
|
||||
// $Header$
|
||||
|
||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
||||
// by flex
|
||||
|
||||
// Copyright (c) 1993 The Regents of the University of California.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code is derived from software contributed to Berkeley by
|
||||
// Kent Williams and Tom Epperly.
|
||||
//
|
||||
// Redistribution and use in source and binary forms with or without
|
||||
// modification are permitted provided that: (1) source distributions retain
|
||||
// this entire copyright notice and comment, and (2) distributions including
|
||||
// binaries display the following acknowledgement: ``This product includes
|
||||
// software developed by the University of California, Berkeley and its
|
||||
// contributors'' in the documentation or other materials provided with the
|
||||
// distribution and in all advertising materials mentioning features or use
|
||||
// of this software. 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 file defines FlexLexer, an abstract class which specifies the
|
||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
||||
// which defines a particular lexer class.
|
||||
//
|
||||
// If you want to create multiple lexer classes, you use the -P flag
|
||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer xxFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer zzFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// ...
|
||||
|
||||
#ifndef FLEXLEXER_H
|
||||
// Never included before - need to define base class.
|
||||
#define FLEXLEXER_H
|
||||
#include <iostream.h>
|
||||
|
||||
extern "C++" {
|
||||
|
||||
struct yy_buffer_state;
|
||||
typedef int yy_state_type;
|
||||
|
||||
class FlexLexer {
|
||||
public:
|
||||
virtual ~FlexLexer() { }
|
||||
|
||||
const char* YYText() { return yytext; }
|
||||
int YYLeng() { return yyleng; }
|
||||
|
||||
virtual void
|
||||
yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
|
||||
virtual struct yy_buffer_state*
|
||||
yy_create_buffer( istream* s, int size ) = 0;
|
||||
virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
|
||||
virtual void yyrestart( istream* s ) = 0;
|
||||
|
||||
virtual int yylex() = 0;
|
||||
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex( istream* new_in, ostream* new_out = 0 )
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams( istream* new_in = 0,
|
||||
ostream* new_out = 0 ) = 0;
|
||||
|
||||
int lineno() const { return yylineno; }
|
||||
|
||||
int debug() const { return yy_flex_debug; }
|
||||
void set_debug( int flag ) { yy_flex_debug = flag; }
|
||||
|
||||
protected:
|
||||
char* yytext;
|
||||
int yyleng;
|
||||
int yylineno; // only maintained if you use %option yylineno
|
||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
|
||||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
||||
// or this is a repeated include to define a different flavor of
|
||||
// yyFlexLexer, as discussed in the flex man page.
|
||||
#define yyFlexLexerOnce
|
||||
|
||||
class yyFlexLexer : public FlexLexer {
|
||||
public:
|
||||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
||||
// only make that assignment when initializing in yylex().
|
||||
yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
|
||||
|
||||
virtual ~yyFlexLexer();
|
||||
|
||||
void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
|
||||
struct yy_buffer_state* yy_create_buffer( istream* s, int size );
|
||||
void yy_delete_buffer( struct yy_buffer_state* b );
|
||||
void yyrestart( istream* s );
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams( istream* new_in, ostream* new_out );
|
||||
|
||||
protected:
|
||||
virtual int LexerInput( char* buf, int max_size );
|
||||
virtual void LexerOutput( const char* buf, int size );
|
||||
virtual void LexerError( const char* msg );
|
||||
|
||||
void yyunput( int c, char* buf_ptr );
|
||||
int yyinput();
|
||||
|
||||
void yy_load_buffer_state();
|
||||
void yy_init_buffer( struct yy_buffer_state* b, istream* s );
|
||||
void yy_flush_buffer( struct yy_buffer_state* b );
|
||||
|
||||
int yy_start_stack_ptr;
|
||||
int yy_start_stack_depth;
|
||||
int* yy_start_stack;
|
||||
|
||||
void yy_push_state( int new_state );
|
||||
void yy_pop_state();
|
||||
int yy_top_state();
|
||||
|
||||
yy_state_type yy_get_previous_state();
|
||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
||||
int yy_get_next_buffer();
|
||||
|
||||
istream* yyin; // input source for default LexerInput
|
||||
ostream* yyout; // output sink for default LexerOutput
|
||||
|
||||
struct yy_buffer_state* yy_current_buffer;
|
||||
|
||||
// yy_hold_char holds the character lost when yytext is formed.
|
||||
char yy_hold_char;
|
||||
|
||||
// Number of characters read into yy_ch_buf.
|
||||
int yy_n_chars;
|
||||
|
||||
// Points to current character in buffer.
|
||||
char* yy_c_buf_p;
|
||||
|
||||
int yy_init; // whether we need to initialize
|
||||
int yy_start; // start state number
|
||||
|
||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
||||
// instead of setting up a fresh yyin. A bit of a hack ...
|
||||
int yy_did_buffer_switch_on_eof;
|
||||
|
||||
// The following are not always needed, but may be depending
|
||||
// on use of certain flex features (like REJECT or yymore()).
|
||||
|
||||
yy_state_type yy_last_accepting_state;
|
||||
char* yy_last_accepting_cpos;
|
||||
|
||||
yy_state_type* yy_state_buf;
|
||||
yy_state_type* yy_state_ptr;
|
||||
|
||||
char* yy_full_match;
|
||||
int* yy_full_state;
|
||||
int yy_full_lp;
|
||||
|
||||
int yy_lp;
|
||||
int yy_looking_for_trail_begin;
|
||||
|
||||
int yy_more_flag;
|
||||
int yy_more_len;
|
||||
int yy_more_offset;
|
||||
int yy_prev_more_offset;
|
||||
};
|
||||
|
||||
#endif
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
---------------------------------------------------------------------------
|
||||
The Zend License, version 0.92
|
||||
Copyright (C) 1999-2001 Zend Technologies Ltd.
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
The Zend scripting engine library is a product of Zend Technologies Ltd.
|
||||
It may be used and/or distributed under the terms of the Q Public
|
||||
License (QPL) version 1.0, enclosed below.
|
||||
|
||||
For more information about Zend please visit http://www.zend.com/
|
||||
For license related questions please mail license@zend.com
|
||||
|
||||
===========================================================================
|
||||
|
||||
THE Q PUBLIC LICENSE
|
||||
version 1.0
|
||||
|
||||
Copyright (C) 1999 Troll Tech AS, Norway.
|
||||
Everyone is permitted to copy and
|
||||
distribute this license document.
|
||||
|
||||
The intent of this license is to establish freedom to share and change the
|
||||
software regulated by this license under the open source model.
|
||||
|
||||
This license applies to any software containing a notice placed by the
|
||||
copyright holder saying that it may be distributed under the terms of
|
||||
the Q Public License version 1.0. Such software is herein referred to as
|
||||
the Software. This license covers modification and distribution of the
|
||||
Software, use of third-party application programs based on the Software,
|
||||
and development of free software which uses the Software.
|
||||
|
||||
Granted Rights
|
||||
|
||||
1. You are granted the non-exclusive rights set forth in this license
|
||||
provided you agree to and comply with any and all conditions in this
|
||||
license. Whole or partial distribution of the Software, or software
|
||||
items that link with the Software, in any form signifies acceptance of
|
||||
this license.
|
||||
|
||||
2. You may copy and distribute the Software in unmodified form provided
|
||||
that the entire package, including - but not restricted to - copyright,
|
||||
trademark notices and disclaimers, as released by the initial developer
|
||||
of the Software, is distributed.
|
||||
|
||||
3. You may make modifications to the Software and distribute your
|
||||
modifications, in a form that is separate from the Software, such as
|
||||
patches. The following restrictions apply to modifications:
|
||||
|
||||
a. Modifications must not alter or remove any copyright notices in
|
||||
the Software.
|
||||
|
||||
b. When modifications to the Software are released under this
|
||||
license, a non-exclusive royalty-free right is granted to the
|
||||
initial developer of the Software to distribute your modification
|
||||
in future versions of the Software provided such versions remain
|
||||
available under these terms in addition to any other license(s) of
|
||||
the initial developer.
|
||||
|
||||
4. You may distribute machine-executable forms of the Software or
|
||||
machine-executable forms of modified versions of the Software, provided
|
||||
that you meet these restrictions:
|
||||
|
||||
a. You must include this license document in the distribution.
|
||||
|
||||
b. You must ensure that all recipients of the machine-executable forms
|
||||
are also able to receive the complete machine-readable source code
|
||||
to the distributed Software, including all modifications, without
|
||||
any charge beyond the costs of data transfer, and place prominent
|
||||
notices in the distribution explaining this.
|
||||
|
||||
c. You must ensure that all modifications included in the
|
||||
machine-executable forms are available under the terms of this
|
||||
license.
|
||||
|
||||
5. You may use the original or modified versions of the Software to
|
||||
compile, link and run application programs legally developed by you
|
||||
or by others.
|
||||
|
||||
6. You may develop application programs, reusable components and other
|
||||
software items that link with the original or modified versions of the
|
||||
Software. These items, when distributed, are subject to the following
|
||||
requirements:
|
||||
|
||||
a. You must ensure that all recipients of machine-executable forms of
|
||||
these items are also able to receive and use the complete
|
||||
machine-readable source code to the items without any charge
|
||||
beyond the costs of data transfer.
|
||||
|
||||
b. You must explicitly license all recipients of your items to use
|
||||
and re-distribute original and modified versions of the items in
|
||||
both machine-executable and source code forms. The recipients must
|
||||
be able to do so without any charges whatsoever, and they must be
|
||||
able to re-distribute to anyone they choose.
|
||||
|
||||
|
||||
c. If the items are not available to the general public, and the
|
||||
initial developer of the Software requests a copy of the items,
|
||||
then you must supply one.
|
||||
|
||||
Limitations of Liability
|
||||
|
||||
In no event shall the initial developers or copyright holders be liable
|
||||
for any damages whatsoever, including - but not restricted to - lost
|
||||
revenue or profits or other direct, indirect, special, incidental or
|
||||
consequential damages, even if they have been advised of the possibility
|
||||
of such damages, except to the extent invariable law, if any, provides
|
||||
otherwise.
|
||||
|
||||
No Warranty
|
||||
|
||||
The Software and this license document are provided AS IS with NO WARRANTY
|
||||
OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
===========================================================================
|
||||
@@ -0,0 +1,49 @@
|
||||
## Process this file with automake to produce Makefile.in -*- makefile -*-
|
||||
|
||||
#CLEANFILES = zend_language_parser.c zend_language_parser.h zend_language_scanner.c zend_language_parser.output zend_ini_parser.c zend_ini_parser.h zend_ini_scanner.c zend_ini_parser.output
|
||||
|
||||
AUTOMAKE_OPTIONS=foreign
|
||||
noinst_LTLIBRARIES=libZend.la
|
||||
|
||||
libZend_la_SOURCES=\
|
||||
zend_language_parser.y zend_language_scanner.l \
|
||||
zend_ini_parser.y zend_ini_scanner.l \
|
||||
zend_alloc.c zend_compile.c zend_constants.c zend_dynamic_array.c \
|
||||
zend_execute.c zend_execute_API.c zend_highlight.c zend_llist.c \
|
||||
zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
|
||||
zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
|
||||
zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
|
||||
zend_ini.c
|
||||
|
||||
libZend_la_LDFLAGS = @EXTRA_LIBS@
|
||||
|
||||
# automake isn't too clever about "non-standard" use of lex and yacc
|
||||
|
||||
$(libZend_la_OBJECTS): zend_language_parser.h
|
||||
|
||||
zend_ini_scanner.lo: zend_ini_parser.h
|
||||
|
||||
# Language parser/scanner rules
|
||||
|
||||
zend_language_scanner.c: $(srcdir)/zend_language_scanner.l
|
||||
$(LEX) -Pzend -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_language_scanner.l
|
||||
|
||||
zend_language_parser.h: zend_language_parser.c
|
||||
zend_language_parser.c: $(srcdir)/zend_language_parser.y
|
||||
$(YACC) -p zend -v -d $(srcdir)/zend_language_parser.y -o zend_language_parser.c
|
||||
|
||||
# INI parser/scanner rules
|
||||
|
||||
zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
|
||||
$(YACC) -p ini_ -v -d $(srcdir)/zend_ini_parser.y -o zend_ini_parser.c
|
||||
|
||||
zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
|
||||
$(LEX) -Pini_ -S$(srcdir)/flex.skl -o$@ -i $(srcdir)/zend_ini_scanner.l
|
||||
|
||||
zend_ini_parser.h: zend_ini_parser.c
|
||||
|
||||
depend:
|
||||
|
||||
zend_execute.lo: $(srcdir)/zend_execute.c
|
||||
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(INLINE_CFLAGS) -c $(srcdir)/zend_execute.c
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
Improvements
|
||||
------------
|
||||
|
||||
Zend was designed from the ground up for increased speed,
|
||||
reduced memory consumption and more reliable execution. We dare
|
||||
say it meets all of these goals and does so pretty well. Beyond
|
||||
that, there are several improvements in the language engine
|
||||
features:
|
||||
|
||||
* References support. $foo = &$a; would make $foo and $a be two
|
||||
names to the same variable. This works with arrays as well,
|
||||
on either side; e.g., $foo = &$a[7]; would make $foo and $a[7]
|
||||
be two names to the same variable. Changing one would change
|
||||
the other and vice versa.
|
||||
* Object overloading support. This feature allows various OO
|
||||
libraries to use the OO notation of PHP to access their
|
||||
functionality. Right now, no use is made of that feature,
|
||||
but we'd have a COM module ready by the time PHP 4.0 is released.
|
||||
A CORBA module would probably follow.
|
||||
* include() and eval() are now functions, and not statements.
|
||||
That means they return a value. The default return value from
|
||||
include() and eval() is 1, so that you can do if (include())
|
||||
without further coding. The return value may be changed by
|
||||
returning a value from the global scope of the included file
|
||||
or the evaluated string. For example, if 'return 7;' is executed
|
||||
in the global scope of foo.inc, include("foo.inc") would evaluate
|
||||
to 7.
|
||||
* Automatic resource deallocation. Several people have been bitten
|
||||
by the fact that PHP 3.0 had no concept of reference counting.
|
||||
Zend adds full reference counting for every value in the system,
|
||||
including resources. As soon as a resource is no longer referenced
|
||||
from any variable, it is automatically destroyed to save memory
|
||||
and resources. The most obvious example for the advantage in this
|
||||
is a loop that has an SQL query inside it, something like
|
||||
'$result = sql_query(...);'. In PHP 3.0, every iteration resulted
|
||||
in another SQL result-set allocated in the memory, and all of the
|
||||
result sets weren't destroyed until the end of the script's execution.
|
||||
In Zend, as soon as we overwrite an old result set with a new one,
|
||||
the old result set which is no longer referenced, is destroyed.
|
||||
* Full support for nesting arrays and objects within each other, in
|
||||
as many levels as you want.
|
||||
* Boolean type. true and false are now constants of type boolean.
|
||||
Comparing any other value to them would convert that value to a
|
||||
boolean first, and conduct the comparison later. That means, for
|
||||
example, that 5==true would evaluate to true (in PHP 3.0, true
|
||||
was nothing but a constant for the integer value of 1, so 5==true
|
||||
was identical to 5==1, which was false).
|
||||
* Runtime binding of function names. This complex name has a simple
|
||||
explanation - you can now call functions before they're declared!
|
||||
* Added here-docs support.
|
||||
* Added foreach. Two syntaxes supported:
|
||||
foreach(array_expr as $val) statement
|
||||
foreach(array_expr as $key => $val) statement
|
||||
* A true unset() implementation. A variable or element that is unset(), is now
|
||||
sent to oblivion in its entirely, no trace remains from it.
|
||||
* Output buffering support! Use ob_start() to begin output buffering, ob_end_flush()
|
||||
to end buffering and send out the buffered contents, ob_end_clean() to end buffering
|
||||
without sending the buffered contents, and ob_get_contents() to retreive the current
|
||||
contents of the output buffer.
|
||||
Header information (header(), content type, cookies) are not buffered. By turning
|
||||
on output buffering, you can effectively send header information all throughout your
|
||||
file, regardless of whether you've emitted body output or not.
|
||||
* Full variable reference within quoted strings:
|
||||
${expr} - full indirect reference support for scalar variables
|
||||
{variable} - full variable support
|
||||
For example:
|
||||
$foo[5]["bar"] = "foobar";
|
||||
print "{$foo[5]["bar"]}"; // would print "foobar"
|
||||
* Ability to call member functions of other classes from within member functions or from
|
||||
the global scope. You can now, for example, override a parent function with a child function,
|
||||
and call the parent function from it.
|
||||
* Runtime information for classes (class name, parent, available functions, etc.).
|
||||
* Much more efficient syntax highlighter - runs much quicker, performs more reliably, and
|
||||
generates much tighter HTML.
|
||||
* A full-featured debugger has been integrated with the language (supports breakpoints,
|
||||
expression evaluation, step-in/over, function call backtrace, and more).
|
||||
|
||||
|
||||
Incompatabilities
|
||||
-----------------
|
||||
|
||||
Zend claims 100% compatability with the engine of PHP 3.0, and is
|
||||
shamelessly lying about it. Here's why:
|
||||
|
||||
* static variable initializers only accept scalar values
|
||||
(in PHP 3.0 they accepted any valid expression). The impact
|
||||
should be somewhere in between void and non existent, since
|
||||
initializing a static variable with anything but a simple
|
||||
static value makes no sense at all.
|
||||
|
||||
* The scope of break and continue is local to that of an
|
||||
include()'d file or an eval()'d string. The impact should
|
||||
be somewhat smaller of the one above.
|
||||
|
||||
* return statement from a require()'d file no longer works. It
|
||||
hardly worked in PHP 3.0, so the impact should be fairly small.
|
||||
If you want this functionality - use include() instead.
|
||||
|
||||
* unset() is no longer a function, but a statement. It was never
|
||||
documented as a function so the impact should be no bigger than
|
||||
nada.
|
||||
|
||||
* The following letter combination is not supported within encapsulated
|
||||
strings: "{$". If you have a string that includes this letter
|
||||
combination, for example, print "{$somevar"; (which printed the
|
||||
letter { and the contents of the variable $somevar in PHP 3.0),
|
||||
it will result in a parse error under Zend. In this case, you
|
||||
would have to change the code to print "\{$somevar";
|
||||
This incompatability is due to the full variable reference
|
||||
within quoted strings feature added in Zend.
|
||||
|
||||
|
||||
+494
@@ -0,0 +1,494 @@
|
||||
# Microsoft Developer Studio Project File - Name="Zend" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=Zend - Win32 Release_inline
|
||||
!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 "Zend.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 "Zend.mak" CFG="Zend - Win32 Release_inline"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Zend - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "Zend - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "Zend - Win32 Release_inline" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Zend - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDebug" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug" /D "_LIB" /D "Zend_EXPORTS" /D ZEND_DEBUG=0 /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40d /d "NDebug"
|
||||
# ADD RSC /l 0x40d /d "NDebug"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_Debug" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_Debug" /D "_LIB" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D ZEND_DEBUG=1 /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x40d /d "_Debug"
|
||||
# ADD RSC /l 0x40d /d "_Debug"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Output_Dir "Zend___Win32_Release_inline"
|
||||
# PROP BASE Intermediate_Dir "Zend___Win32_Release_inline"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Output_Dir "Release_inline"
|
||||
# PROP Intermediate_Dir "Release_inline"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug" /D "_LIB" /D "Zend_EXPORTS" /D ZEND_DEBUG=0 /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /FR /FD /c
|
||||
# SUBTRACT BASE CPP /YX
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug" /D "_LIB" /D "Zend_EXPORTS" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "WIN32" /D "_MBCS" /D "ZEND_WIN32" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40d /d "NDebug"
|
||||
# ADD RSC /l 0x40d /d "NDebug"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Zend - Win32 Release"
|
||||
# Name "Zend - Win32 Debug"
|
||||
# Name "Zend - Win32 Release_inline"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_alloc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_API.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_builtin_functions.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_compile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_constants.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_execute.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_execute_API.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_extensions.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_hash.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_highlight.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_indent.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_parser.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_scanner.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_parser.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_scanner.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_list.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_llist.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_opcode.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_operators.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ptr_stack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_sprintf.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_stack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_variables.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FlexLexer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_API.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_builtin_functions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_compile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_config.w32.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_constants.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_errors.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_execute.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_extensions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_fast_cache.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_globals.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_hash.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_highlight.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_indent.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_parser.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_scanner.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_list.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_llist.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_modules.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_operators.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ptr_stack.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_stack.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_variables.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Parsers"
|
||||
|
||||
# PROP Default_Filter "y"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_parser.y
|
||||
|
||||
!IF "$(CFG)" == "Zend - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=.\zend_ini_parser.y
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_ini_parser.c -v -d -p ini_ zend_ini_parser.y
|
||||
|
||||
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_parser.y"
|
||||
|
||||
!IF "$(CFG)" == "Zend - Win32 Release"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=".\zend_language_parser.y"
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_language_parser.c -v -d -p zend zend_language_parser.y
|
||||
|
||||
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=".\zend_language_parser.y"
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_language_parser.c -v -d -p zend zend_language_parser.y
|
||||
|
||||
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=".\zend_language_parser.y"
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_language_parser.c -v -d -p zend zend_language_parser.y
|
||||
|
||||
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Scanners"
|
||||
|
||||
# PROP Default_Filter "l"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\flex.skl
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_scanner.l
|
||||
|
||||
!IF "$(CFG)" == "Zend - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\zend_ini_scanner.l
|
||||
|
||||
"zend_ini_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.c zend_ini_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_scanner.l"
|
||||
|
||||
!IF "$(CFG)" == "Zend - Win32 Release"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=".\zend_language_scanner.l"
|
||||
|
||||
"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -i -Pzend -ozend_language_scanner.c zend_language_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=".\zend_language_scanner.l"
|
||||
|
||||
"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -i -Pzend -ozend_language_scanner.c zend_language_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "Zend - Win32 Release_inline"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=".\zend_language_scanner.l"
|
||||
|
||||
"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -i -Pzend -ozend_language_scanner.c zend_language_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Text Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ZEND_BUGS
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ZEND_CHANGES
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ZEND_TODO
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resources"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
|
||||
AC_DEFUN(LIBZEND_BISON_CHECK,[
|
||||
|
||||
if test "$YACC" != "bison -y"; then
|
||||
AC_MSG_WARN(You will need bison if you want to regenerate the Zend parser.)
|
||||
else
|
||||
AC_MSG_CHECKING(bison version)
|
||||
set `bison --version| sed -e 's/^GNU Bison version //' -e 's/\./ /'`
|
||||
if test "${1}" = "1" -a "${2}" -lt "28"; then
|
||||
AC_MSG_WARN(You will need bison 1.28 if you want to regenerate the Zend parser (found ${1}.${2}).)
|
||||
fi
|
||||
AC_MSG_RESULT(${1}.${2} (ok))
|
||||
fi
|
||||
|
||||
])
|
||||
|
||||
AC_DEFUN(LIBZEND_BASIC_CHECKS,[
|
||||
|
||||
AC_REQUIRE([AC_PROG_YACC])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_PROG_CC_C_O])
|
||||
AC_REQUIRE([AC_PROG_LEX])
|
||||
AC_REQUIRE([AC_HEADER_STDC])
|
||||
|
||||
LIBZEND_BISON_CHECK
|
||||
|
||||
dnl Ugly hack to get around a problem with gcc on AIX.
|
||||
if test "$CC" = "gcc" -a "$ac_cv_prog_cc_g" = "yes" -a \
|
||||
"`uname -sv`" = "AIX 4"; then
|
||||
CFLAGS=`echo $CFLAGS | sed -e 's/-g//'`
|
||||
fi
|
||||
|
||||
dnl Hack to work around a Mac OS X cpp problem
|
||||
dnl Known versions needing this workaround are 5.3 and 5.4
|
||||
if test "$ac_cv_prog_gcc" = "yes" -a "`uname -s`" = "Rhapsody"; then
|
||||
CPPFLAGS="$CPPFLAGS -traditional-cpp"
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS(
|
||||
limits.h \
|
||||
malloc.h \
|
||||
string.h \
|
||||
unistd.h \
|
||||
stdarg.h \
|
||||
sys/types.h \
|
||||
sys/time.h \
|
||||
signal.h \
|
||||
unix.h \
|
||||
dlfcn.h)
|
||||
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_SIGNAL
|
||||
|
||||
AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl $LIBS"])
|
||||
AC_CHECK_FUNC(dlopen,[AC_DEFINE(HAVE_LIBDL, 1,[ ])])
|
||||
|
||||
dnl This is required for QNX and may be some BSD derived systems
|
||||
AC_CHECK_TYPE( uint, unsigned int )
|
||||
AC_CHECK_TYPE( ulong, unsigned long )
|
||||
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_FUNC_VPRINTF
|
||||
AC_FUNC_MEMCMP
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass)
|
||||
AC_ZEND_BROKEN_SPRINTF
|
||||
|
||||
AC_CHECK_FUNCS(finite isfinite isinf isnan)
|
||||
|
||||
ZEND_FP_EXCEPT
|
||||
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AC_DEFUN(LIBZEND_ENABLE_DEBUG,[
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug Compile with debugging symbols],[
|
||||
ZEND_DEBUG=$enableval
|
||||
],[
|
||||
ZEND_DEBUG=no
|
||||
])
|
||||
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AC_DEFUN(LIBZEND_OTHER_CHECKS,[
|
||||
|
||||
AC_ARG_ENABLE(experimental-zts,
|
||||
[ --enable-experimental-zts This will most likely break your build],[
|
||||
ZEND_EXPERIMENTAL_ZTS=$enableval
|
||||
],[
|
||||
ZEND_EXPERIMENTAL_ZTS=no
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(inline-optimization,
|
||||
[ --enable-inline-optimization If you have much memory and are using
|
||||
gcc, you might try this.],[
|
||||
ZEND_INLINE_OPTIMIZATION=$enableval
|
||||
],[
|
||||
ZEND_INLINE_OPTIMIZATION=no
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(memory-limit,
|
||||
[ --enable-memory-limit Compile with memory limit support. ], [
|
||||
ZEND_MEMORY_LIMIT=$enableval
|
||||
],[
|
||||
ZEND_MEMORY_LIMIT=no
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING(whether to enable experimental ZTS)
|
||||
AC_MSG_RESULT($ZEND_EXPERIMENTAL_ZTS)
|
||||
|
||||
AC_MSG_CHECKING(whether to enable inline optimization for GCC)
|
||||
AC_MSG_RESULT($ZEND_INLINE_OPTIMIZATION)
|
||||
|
||||
AC_MSG_CHECKING(whether to enable a memory limit)
|
||||
AC_MSG_RESULT($ZEND_MEMORY_LIMIT)
|
||||
|
||||
AC_MSG_CHECKING(whether to enable Zend debugging)
|
||||
AC_MSG_RESULT($ZEND_DEBUG)
|
||||
|
||||
if test "$ZEND_DEBUG" = "yes"; then
|
||||
AC_DEFINE(ZEND_DEBUG,1,[ ])
|
||||
echo " $CFLAGS" | grep ' -g' >/dev/null || DEBUG_CFLAGS="-g"
|
||||
if test "$CFLAGS" = "-g -O2"; then
|
||||
CFLAGS=-g
|
||||
fi
|
||||
test -n "$GCC" && DEBUG_CFLAGS="$DEBUG_CFLAGS -Wall"
|
||||
test -n "$GCC" && test "$USE_MAINTAINER_MODE" = "yes" && \
|
||||
DEBUG_CFLAGS="$DEBUG_CFLAGS -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"
|
||||
else
|
||||
AC_DEFINE(ZEND_DEBUG,0,[ ])
|
||||
fi
|
||||
|
||||
test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
|
||||
|
||||
if test "$ZEND_EXPERIMENTAL_ZTS" = "yes"; then
|
||||
AC_DEFINE(ZTS,1,[ ])
|
||||
CFLAGS="$CFLAGS -DZTS"
|
||||
LIBZEND_CPLUSPLUS_CHECKS
|
||||
fi
|
||||
|
||||
if test "$ZEND_MEMORY_LIMIT" = "yes"; then
|
||||
AC_DEFINE(MEMORY_LIMIT, 1, [Memory limit])
|
||||
else
|
||||
AC_DEFINE(MEMORY_LIMIT, 0, [Memory limit])
|
||||
fi
|
||||
|
||||
|
||||
changequote({,})
|
||||
if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then
|
||||
INLINE_CFLAGS=`echo $ac_n "$CFLAGS $ac_c" | sed s/-O[0-9s]*//`
|
||||
else
|
||||
INLINE_CFLAGS="$CFLAGS"
|
||||
fi
|
||||
changequote([,])
|
||||
|
||||
AC_C_INLINE
|
||||
|
||||
AC_SUBST(INLINE_CFLAGS)
|
||||
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN(LIBZEND_CPLUSPLUS_CHECKS,[
|
||||
|
||||
])
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
# Microsoft Developer Studio Generated Dependency File, included by ZendCore.mak
|
||||
|
||||
.\zend_alloc.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\alloca.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_compile.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_modules.h"\
|
||||
".\zend_operators.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_API.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
".\zend_ini.h"\
|
||||
|
||||
|
||||
.\zend_constants.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_constants.h"\
|
||||
".\zend_operators.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_execute.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_constants.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_modules.h"\
|
||||
".\zend_operators.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_API.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
".\zend_ini.h"\
|
||||
|
||||
|
||||
.\zend_highlight.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_highlight.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend_language_parser.tab.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_llist.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_opcode.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_modules.h"\
|
||||
".\zend_operators.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_API.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
".\zend_ini.h"\
|
||||
|
||||
|
||||
.\zend_operators.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_operators.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_ptr_stack.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_stack.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_variables.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_constants.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_modules.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_API.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
".\zend_ini.h"\
|
||||
".\zend_list.h"\
|
||||
|
||||
|
||||
.\zend.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_operators.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_API.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_compile.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend_constants.h"\
|
||||
".\zend_execute.h"\
|
||||
".\zend_llist.h"\
|
||||
".\zend_modules.h"\
|
||||
".\zend_operators.h"\
|
||||
".\zend_ptr_stack.h"\
|
||||
".\zend_stack.h"\
|
||||
".\zend_variables.h"\
|
||||
".\zend.h"\
|
||||
".\zend_API.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_globals.h"\
|
||||
".\zend_hash.h"\
|
||||
".\zend_ini.h"\
|
||||
".\zend_list.h"\
|
||||
|
||||
|
||||
.\zend_hash.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
|
||||
|
||||
.\zend_ini.c : \
|
||||
"..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\
|
||||
".\zend_alloc.h"\
|
||||
".\zend_config.w32.h"\
|
||||
".\zend.h"\
|
||||
".\zend_errors.h"\
|
||||
".\zend_hash.h"\
|
||||
".\zend_ini.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "ZendCore - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendCore - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "ZendCore - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendCore - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "ZendCore - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendCore - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "ZendCore - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendCore - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
+643
@@ -0,0 +1,643 @@
|
||||
# Microsoft Developer Studio Project File - Name="ZendTS" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=ZendTS - Win32 Release_TSDbg
|
||||
!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 "ZendTS.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 "ZendTS.mak" CFG="ZendTS - Win32 Release_TSDbg"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ZendTS - Win32 Release_TS" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "ZendTS - Win32 Debug_TS" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "ZendTS - Win32 Release_TS_inline" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "ZendTS - Win32 Release_TSDbg" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Output_Dir "Release_TS"
|
||||
# PROP BASE Intermediate_Dir "Release_TS"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Output_Dir "Release_TS"
|
||||
# PROP Intermediate_Dir "Release_TS"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDebug_TS" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug_TS" /D ZEND_DEBUG=0 /D _WIN32_WINNT=0x400 /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "ZTS" /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40d /d "NDebug_TS"
|
||||
# ADD RSC /l 0x40d /d "NDebug_TS"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Output_Dir "Debug_TS"
|
||||
# PROP BASE Intermediate_Dir "Debug_TS"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Output_Dir "Debug_TS"
|
||||
# PROP Intermediate_Dir "Debug_TS"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_Debug_TS" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_Debug_TS" /D ZEND_DEBUG=1 /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "ZTS" /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x40d /d "_Debug_TS"
|
||||
# ADD RSC /l 0x40d /d "_Debug_TS"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Output_Dir "ZendTS___Win32_Release_TS_inline"
|
||||
# PROP BASE Intermediate_Dir "ZendTS___Win32_Release_TS_inline"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Output_Dir "Release_TS_inline"
|
||||
# PROP Intermediate_Dir "Release_TS_inline"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug_TS" /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "ZTS" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=0 /FR /FD /c
|
||||
# SUBTRACT BASE CPP /YX
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug_TS" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D _WIN32_WINNT=0x400 /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "ZTS" /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40d /d "NDebug_TS"
|
||||
# ADD RSC /l 0x40d /d "NDebug_TS"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TSDbg"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Output_Dir "ZendTS___Win32_Release_TSDbg"
|
||||
# PROP BASE Intermediate_Dir "ZendTS___Win32_Release_TSDbg"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Output_Dir "Release_TSDbg"
|
||||
# PROP Intermediate_Dir "Release_TSDbg"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug_TS" /D ZEND_DEBUG=0 /D _WIN32_WINNT=0x400 /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "ZTS" /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /c
|
||||
# SUBTRACT BASE CPP /YX
|
||||
# ADD CPP /nologo /MD /W3 /GX /Zi /Od /I "." /D "NDebug_TS" /D ZEND_DEBUG=0 /D _WIN32_WINNT=0x400 /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "ZTS" /D "ZEND_WIN32" /D "WIN32" /D "_MBCS" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x40d /d "NDebug_TS"
|
||||
# ADD RSC /l 0x40d /d "NDebug_TS"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "ZendTS - Win32 Release_TS"
|
||||
# Name "ZendTS - Win32 Debug_TS"
|
||||
# Name "ZendTS - Win32 Release_TS_inline"
|
||||
# Name "ZendTS - Win32 Release_TSDbg"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_alloc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_API.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_builtin_functions.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_compile.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_constants.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_dynamic_array.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_execute.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_execute_API.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_extensions.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_hash.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_highlight.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_indent.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_parser.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_scanner.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_parser.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_language_scanner.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_list.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_llist.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_opcode.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_operators.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ptr_stack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_sprintf.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_stack.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_variables.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FlexLexer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_API.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_builtin_functions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_compile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_config.w32.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_constants.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_dynamic_array.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_errors.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_execute.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_execute_locks.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_extensions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_fast_cache.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_globals.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_globals_macros.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_hash.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_highlight.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_indent.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_parser.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_scanner.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_istdiostream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_parser.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_scanner.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_list.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_llist.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_modules.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_operators.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ptr_stack.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_stack.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_variables.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Parsers"
|
||||
|
||||
# PROP Default_Filter "y"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_parser.y
|
||||
|
||||
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=.\zend_ini_parser.y
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_ini_parser.c -v -d -p ini_ zend_ini_parser.y
|
||||
|
||||
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=.\zend_ini_parser.y
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_ini_parser.c -v -d -p ini_ zend_ini_parser.y
|
||||
|
||||
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=.\zend_ini_parser.y
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_ini_parser.c -v -d -p ini_ zend_ini_parser.y
|
||||
|
||||
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TSDbg"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=.\zend_ini_parser.y
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_ini_parser.c -v -d -p ini_ zend_ini_parser.y
|
||||
|
||||
"$(InputDir)\zend_ini_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_ini_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_parser.y"
|
||||
|
||||
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=".\zend_language_parser.y"
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_language_parser.c -v -d -p zend zend_language_parser.y
|
||||
|
||||
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=".\zend_language_parser.y"
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_language_parser.c -v -d -p zend zend_language_parser.y
|
||||
|
||||
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=".\zend_language_parser.y"
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_language_parser.c -v -d -p zend zend_language_parser.y
|
||||
|
||||
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TSDbg"
|
||||
|
||||
# Begin Custom Build
|
||||
InputDir=.
|
||||
InputPath=".\zend_language_parser.y"
|
||||
|
||||
BuildCmds= \
|
||||
bison --output=zend_language_parser.c -v -d -p zend zend_language_parser.y
|
||||
|
||||
"$(InputDir)\zend_language_parser.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
|
||||
"$(InputDir)\zend_language_parser.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(BuildCmds)
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Scanners"
|
||||
|
||||
# PROP Default_Filter "l"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\flex.skl
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend_ini_scanner.l
|
||||
|
||||
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\zend_ini_scanner.l
|
||||
|
||||
"zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\zend_ini_scanner.l
|
||||
|
||||
"zend_ini_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.c zend_ini_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\zend_ini_scanner.l
|
||||
|
||||
"zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TSDbg"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\zend_ini_scanner.l
|
||||
|
||||
"zend_ini_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -+ -B -i -Sflex.skl -Pini_ -ozend_ini_scanner.cpp zend_ini_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\zend_language_scanner.l"
|
||||
|
||||
!IF "$(CFG)" == "ZendTS - Win32 Release_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=".\zend_language_scanner.l"
|
||||
|
||||
"zend_language_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -+ -B -i -Sflex.skl -Pzend -ozend_language_scanner.cpp zend_language_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Debug_TS"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=".\zend_language_scanner.l"
|
||||
|
||||
"zend_language_scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -B -i -Sflex.skl -Pzend -ozend_language_scanner.c zend_language_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TS_inline"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=".\zend_language_scanner.l"
|
||||
|
||||
"zend_language_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -+ -B -i -Sflex.skl -Pzend -ozend_language_scanner.cpp zend_language_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "ZendTS - Win32 Release_TSDbg"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=".\zend_language_scanner.l"
|
||||
|
||||
"zend_language_scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
flex -+ -B -i -Sflex.skl -Pzend -ozend_language_scanner.cpp zend_language_scanner.l
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Text Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LICENSE
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ZEND_BUGS
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ZEND_CHANGES
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resources"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\zend.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,76 @@
|
||||
#define ZEND_API
|
||||
#define ZEND_DLEXPORT
|
||||
|
||||
@TOP@
|
||||
|
||||
#undef uint
|
||||
#undef ulong
|
||||
|
||||
/* Define if you want to enable memory limit support */
|
||||
#define MEMORY_LIMIT 0
|
||||
|
||||
@BOTTOM@
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
# include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#if ZEND_BROKEN_SPRINTF
|
||||
int zend_sprintf(char *buffer, const char *format, ...);
|
||||
#else
|
||||
# define zend_sprintf sprintf
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_ISNAN
|
||||
#define zend_isnan(a) isnan(a)
|
||||
#elif defined(NAN)
|
||||
#define zend_isnan(a) (((a)==NAN)?1:0)
|
||||
#elif defined(HAVE_FPCLASS)
|
||||
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
|
||||
#else
|
||||
#define zend_isnan(a) 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ISINF
|
||||
#define zend_isinf(a) isinf(a)
|
||||
#elif defined(INFINITY)
|
||||
/* Might not work, but is required by ISO C99 */
|
||||
#define zend_isinf(a) (((a)==INFINITY)?1:0)
|
||||
#elif defined(HAVE_FPCLASS)
|
||||
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
|
||||
#else
|
||||
#define zend_isinf(a) 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FINITE
|
||||
#define zend_finite(a) finite(a)
|
||||
#elif defined(HAVE_ISFINITE) || defined(isfinite)
|
||||
#define zend_finite(a) isfinite(a)
|
||||
#elif defined(fpclassify)
|
||||
#define zend_finite(a) ((fpclassify((a))!=FP_INFINITE&&fpclassify((a))!=FP_NAN)?1:0)
|
||||
#else
|
||||
#define zend_finite(a) (zend_isnan(a) ? 0 : zend_isinf(a) ? 0 : 1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,47 @@
|
||||
dnl $Id$
|
||||
dnl
|
||||
dnl This file contains local autoconf functions.
|
||||
|
||||
AC_DEFUN(ZEND_FP_EXCEPT,[
|
||||
AC_CACHE_CHECK(whether fp_except is defined, ac_cv_type_fp_except,[
|
||||
AC_TRY_COMPILE([
|
||||
#include <floatingpoint.h>
|
||||
],[
|
||||
fp_except x = (fp_except) 0;
|
||||
],[
|
||||
ac_cv_type_fp_except=yes
|
||||
],[
|
||||
ac_cv_type_fp_except=no
|
||||
],[
|
||||
ac_cv_type_fp_except=no
|
||||
])])
|
||||
if test "$ac_cv_type_fp_except" = "yes"; then
|
||||
AC_DEFINE(HAVE_FP_EXCEPT, 1, [whether floatingpoint.h defines fp_except])
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check for broken sprintf()
|
||||
dnl
|
||||
AC_DEFUN(AC_ZEND_BROKEN_SPRINTF,[
|
||||
AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
|
||||
AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
|
||||
ac_cv_broken_sprintf=no
|
||||
],[
|
||||
ac_cv_broken_sprintf=yes
|
||||
],[
|
||||
ac_cv_broken_sprintf=no
|
||||
])
|
||||
])
|
||||
if test "$ac_cv_broken_sprintf" = "yes"; then
|
||||
ac_result=1
|
||||
else
|
||||
ac_result=0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(ZEND_BROKEN_SPRINTF, $ac_result, [Whether sprintf is broken])
|
||||
])
|
||||
|
||||
AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
|
||||
LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
|
||||
])
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Makefile to generate build tools
|
||||
#
|
||||
# Standard usage:
|
||||
# make -f build.mk
|
||||
#
|
||||
# Written by Sascha Schumann
|
||||
#
|
||||
# $Id$
|
||||
|
||||
|
||||
LT_TARGETS = ltmain.sh ltconfig
|
||||
|
||||
config_h_in = zend_config.h.in
|
||||
|
||||
makefile_am_files = Makefile.am
|
||||
makefile_in_files = $(makefile_am_files:.am=.in)
|
||||
makefile_files = $(makefile_am_files:e.am=e)
|
||||
|
||||
targets = $(makefile_in_files) $(LT_TARGETS) configure $(config_h_in)
|
||||
|
||||
all: $(targets)
|
||||
|
||||
clean:
|
||||
rm -f $(targets)
|
||||
|
||||
$(LT_TARGETS):
|
||||
rm -f $(LT_TARGETS)
|
||||
libtoolize --automake $(AMFLAGS) -f
|
||||
|
||||
$(makefile_in_files): $(makefile_am_files)
|
||||
automake -a -i $(AMFLAGS) $(makefile_files)
|
||||
|
||||
aclocal.m4: configure.in acinclude.m4
|
||||
aclocal
|
||||
|
||||
$(config_h_in): configure.in acconfig.h
|
||||
# explicitly remove target since autoheader does not seem to work
|
||||
# correctly otherwise (timestamps are not updated)
|
||||
@rm -f $@
|
||||
autoheader
|
||||
|
||||
configure: aclocal.m4 configure.in
|
||||
autoconf
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
case "$1" in
|
||||
--copy)
|
||||
automake_flags=--copy
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
|
||||
libtoolize --force --automake $automake_flags
|
||||
|
||||
mv aclocal.m4 aclocal.m4.old 2>/dev/null
|
||||
aclocal
|
||||
if cmp aclocal.m4.old aclocal.m4 > /dev/null 2>&1; then
|
||||
echo "buildconf: keeping ${1}aclocal.m4"
|
||||
mv aclocal.m4.old aclocal.m4
|
||||
else
|
||||
echo "buildconf: created or modified ${1}aclocal.m4"
|
||||
fi
|
||||
|
||||
autoheader
|
||||
|
||||
automake --add-missing --include-deps $automake_flags
|
||||
|
||||
mv configure configure.old 2>/dev/null
|
||||
autoconf
|
||||
if cmp configure.old configure > /dev/null 2>&1; then
|
||||
echo "buildconf: keeping ${1}configure"
|
||||
mv configure.old configure
|
||||
else
|
||||
echo "buildconf: created or modified ${1}configure"
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
dnl $Id$
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT(zend.c)
|
||||
AM_INIT_AUTOMAKE(zend, 0.80A, nodefine)
|
||||
AM_CONFIG_HEADER(zend_config.h)
|
||||
AM_SANITY_CHECK
|
||||
AM_MAINTAINER_MODE
|
||||
AC_PROG_CC
|
||||
AM_PROG_LEX
|
||||
AM_PROG_CC_STDC
|
||||
ZEND_VERSION=$VERSION
|
||||
|
||||
dnl We want this one before the checks, so the checks can modify CFLAGS.
|
||||
test -z "$CFLAGS" && auto_cflags=1
|
||||
|
||||
sinclude(Zend.m4)
|
||||
|
||||
LIBZEND_BASIC_CHECKS
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
if test "$enable_debug" != "yes"; then
|
||||
AM_SET_LIBTOOL_VARIABLE([--silent])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Check for /usr/pkg/{lib,include} which is where NetBSD puts binary
|
||||
dnl and source packages. This should be harmless on other OSs.
|
||||
dnl
|
||||
if test -d /usr/pkg/include -a -d /usr/pkg/lib ; then
|
||||
CFLAGS="$CFLAGS -I/usr/pkg/include"
|
||||
LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
|
||||
fi
|
||||
|
||||
LIBZEND_ENABLE_DEBUG
|
||||
LIBZEND_OTHER_CHECKS
|
||||
|
||||
EXTRA_LIBS="$LIBS"
|
||||
LIBS=""
|
||||
AC_SUBST(EXTRA_LIBS)
|
||||
AC_OUTPUT(Makefile)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 4
|
||||
# End:
|
||||
+1600
File diff suppressed because it is too large.
Load diff
+832
@@ -0,0 +1,832 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_extensions.h"
|
||||
#include "zend_modules.h"
|
||||
#include "zend_constants.h"
|
||||
#include "zend_list.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_builtin_functions.h"
|
||||
#include "zend_ini.h"
|
||||
|
||||
#ifdef ZTS
|
||||
# define GLOBAL_FUNCTION_TABLE global_function_table
|
||||
# define GLOBAL_CLASS_TABLE global_class_table
|
||||
# define GLOBAL_CONSTANTS_TABLE global_constants_table
|
||||
#else
|
||||
# define GLOBAL_FUNCTION_TABLE CG(function_table)
|
||||
# define GLOBAL_CLASS_TABLE CG(class_table)
|
||||
# define GLOBAL_CONSTANTS_TABLE CG(zend_constants)
|
||||
#endif
|
||||
|
||||
#if defined(ZEND_WIN32) && ZEND_DEBUG
|
||||
BOOL WINAPI IsDebuggerPresent(VOID);
|
||||
#endif
|
||||
|
||||
/* true multithread-shared globals */
|
||||
ZEND_API zend_class_entry zend_standard_class_def;
|
||||
ZEND_API int (*zend_printf)(const char *format, ...);
|
||||
ZEND_API zend_write_func_t zend_write;
|
||||
ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
|
||||
ZEND_API void (*zend_block_interruptions)(void);
|
||||
ZEND_API void (*zend_unblock_interruptions)(void);
|
||||
ZEND_API void (*zend_ticks_function)(int ticks);
|
||||
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
||||
|
||||
static void (*zend_message_dispatcher_p)(long message, void *data);
|
||||
static int (*zend_get_configuration_directive_p)(char *name, uint name_length, zval *contents);
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
ZEND_API int compiler_globals_id;
|
||||
ZEND_API int executor_globals_id;
|
||||
ZEND_API int alloc_globals_id;
|
||||
HashTable *global_function_table;
|
||||
HashTable *global_class_table;
|
||||
HashTable *global_constants_table;
|
||||
#endif
|
||||
|
||||
zend_utility_values zend_uv;
|
||||
|
||||
ZEND_API zval zval_used_for_init; /* True global variable */
|
||||
|
||||
/* version information */
|
||||
static char *zend_version_info;
|
||||
static uint zend_version_info_length;
|
||||
#define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2001 Zend Technologies\n"
|
||||
|
||||
|
||||
#define PRINT_ZVAL_INDENT 4
|
||||
|
||||
static void print_hash(HashTable *ht, int indent)
|
||||
{
|
||||
zval **tmp;
|
||||
char *string_key;
|
||||
HashPosition iterator;
|
||||
unsigned long num_key, str_len;
|
||||
int i;
|
||||
|
||||
for (i=0; i<indent; i++) {
|
||||
ZEND_PUTS(" ");
|
||||
}
|
||||
ZEND_PUTS("(\n");
|
||||
indent += PRINT_ZVAL_INDENT;
|
||||
zend_hash_internal_pointer_reset_ex(ht, &iterator);
|
||||
while (zend_hash_get_current_data_ex(ht, (void **) &tmp, &iterator) == SUCCESS) {
|
||||
for (i=0; i<indent; i++) {
|
||||
ZEND_PUTS(" ");
|
||||
}
|
||||
ZEND_PUTS("[");
|
||||
switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator)) {
|
||||
case HASH_KEY_IS_STRING:
|
||||
ZEND_PUTS(string_key);
|
||||
break;
|
||||
case HASH_KEY_IS_LONG:
|
||||
zend_printf("%ld",num_key);
|
||||
break;
|
||||
}
|
||||
ZEND_PUTS("] => ");
|
||||
zend_print_zval_r(*tmp, indent+PRINT_ZVAL_INDENT);
|
||||
ZEND_PUTS("\n");
|
||||
zend_hash_move_forward_ex(ht, &iterator);
|
||||
}
|
||||
indent -= PRINT_ZVAL_INDENT;
|
||||
for (i=0; i<indent; i++) {
|
||||
ZEND_PUTS(" ");
|
||||
}
|
||||
ZEND_PUTS(")\n");
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy)
|
||||
{
|
||||
if (expr->type==IS_STRING) {
|
||||
*use_copy = 0;
|
||||
return;
|
||||
}
|
||||
switch (expr->type) {
|
||||
case IS_NULL:
|
||||
expr_copy->value.str.len = 0;
|
||||
expr_copy->value.str.val = empty_string;
|
||||
break;
|
||||
case IS_BOOL:
|
||||
if (expr->value.lval) {
|
||||
expr_copy->value.str.len = 1;
|
||||
expr_copy->value.str.val = estrndup("1", 1);
|
||||
} else {
|
||||
expr_copy->value.str.len = 0;
|
||||
expr_copy->value.str.val = empty_string;
|
||||
}
|
||||
break;
|
||||
case IS_RESOURCE:
|
||||
expr_copy->value.str.val = (char *) emalloc(sizeof("Resource id #")-1 + MAX_LENGTH_OF_LONG);
|
||||
expr_copy->value.str.len = sprintf(expr_copy->value.str.val, "Resource id #%ld", expr->value.lval);
|
||||
break;
|
||||
case IS_ARRAY:
|
||||
expr_copy->value.str.len = sizeof("Array")-1;
|
||||
expr_copy->value.str.val = estrndup("Array", expr_copy->value.str.len);
|
||||
break;
|
||||
case IS_OBJECT:
|
||||
expr_copy->value.str.len = sizeof("Object")-1;
|
||||
expr_copy->value.str.val = estrndup("Object", expr_copy->value.str.len);
|
||||
break;
|
||||
default:
|
||||
*expr_copy = *expr;
|
||||
zval_copy_ctor(expr_copy);
|
||||
convert_to_string(expr_copy);
|
||||
break;
|
||||
}
|
||||
expr_copy->type = IS_STRING;
|
||||
*use_copy = 1;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_print_zval(zval *expr, int indent)
|
||||
{
|
||||
return zend_print_zval_ex(zend_write, expr, indent);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent)
|
||||
{
|
||||
zval expr_copy;
|
||||
int use_copy;
|
||||
|
||||
zend_make_printable_zval(expr, &expr_copy, &use_copy);
|
||||
if (use_copy) {
|
||||
expr = &expr_copy;
|
||||
}
|
||||
if (expr->value.str.len==0) { /* optimize away empty strings */
|
||||
if (use_copy) {
|
||||
zval_dtor(expr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
write_func(expr->value.str.val,expr->value.str.len);
|
||||
if (use_copy) {
|
||||
zval_dtor(expr);
|
||||
}
|
||||
return expr->value.str.len;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_print_zval_r(zval *expr, int indent)
|
||||
{
|
||||
zend_print_zval_r_ex(zend_write, expr, indent);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent)
|
||||
{
|
||||
switch(expr->type) {
|
||||
case IS_ARRAY:
|
||||
ZEND_PUTS("Array\n");
|
||||
if (++expr->value.ht->nApplyCount>1) {
|
||||
ZEND_PUTS(" *RECURSION*");
|
||||
expr->value.ht->nApplyCount=0;
|
||||
return;
|
||||
}
|
||||
print_hash(expr->value.ht,indent);
|
||||
expr->value.ht->nApplyCount--;
|
||||
break;
|
||||
case IS_OBJECT:
|
||||
{
|
||||
zend_object *object = Z_OBJ_P(expr);
|
||||
|
||||
if (++object->properties->nApplyCount>1) {
|
||||
ZEND_PUTS(" *RECURSION*");
|
||||
object->properties->nApplyCount=0;
|
||||
return;
|
||||
}
|
||||
zend_printf("%s Object\n", object->ce->name);
|
||||
print_hash(object->properties, indent);
|
||||
object->properties->nApplyCount--;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
zend_print_variable(expr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
|
||||
{
|
||||
if (opened_path) {
|
||||
*opened_path = estrdup(filename);
|
||||
}
|
||||
return fopen(filename, "rb");
|
||||
}
|
||||
|
||||
|
||||
static void register_standard_class(void)
|
||||
{
|
||||
zend_standard_class_def.type = ZEND_INTERNAL_CLASS;
|
||||
zend_standard_class_def.name_length = sizeof("stdClass") - 1;
|
||||
zend_standard_class_def.name = zend_strndup("stdClass", zend_standard_class_def.name_length);
|
||||
zend_standard_class_def.parent = NULL;
|
||||
zend_hash_init_ex(&zend_standard_class_def.default_properties, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
|
||||
zend_hash_init_ex(&zend_standard_class_def.function_table, 0, NULL, ZEND_FUNCTION_DTOR, 1, 0);
|
||||
zend_standard_class_def.handle_function_call = NULL;
|
||||
zend_standard_class_def.handle_property_get = NULL;
|
||||
zend_standard_class_def.handle_property_set = NULL;
|
||||
zend_standard_class_def.refcount = (int *) malloc(sizeof(int));
|
||||
*zend_standard_class_def.refcount = 1;
|
||||
zend_hash_add(GLOBAL_CLASS_TABLE, "stdclass", sizeof("stdclass"), &zend_standard_class_def, sizeof(zend_class_entry), NULL);
|
||||
}
|
||||
|
||||
|
||||
static void zend_set_default_compile_time_values(TSRMLS_D)
|
||||
{
|
||||
/* default compile-time values */
|
||||
CG(asp_tags) = 0;
|
||||
CG(short_tags) = 1;
|
||||
CG(allow_call_time_pass_reference) = 1;
|
||||
CG(extended_info) = 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS_DC)
|
||||
{
|
||||
zend_function tmp_func;
|
||||
zend_class_entry tmp_class;
|
||||
|
||||
compiler_globals->compiled_filename = NULL;
|
||||
|
||||
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
|
||||
zend_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
|
||||
zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function));
|
||||
|
||||
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
|
||||
zend_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
|
||||
zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry));
|
||||
|
||||
zend_set_default_compile_time_values(TSRMLS_C);
|
||||
|
||||
CG(interactive) = 0;
|
||||
}
|
||||
|
||||
|
||||
static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS_DC)
|
||||
{
|
||||
if (compiler_globals->function_table != global_function_table) {
|
||||
zend_hash_destroy(compiler_globals->function_table);
|
||||
free(compiler_globals->function_table);
|
||||
}
|
||||
if (compiler_globals->class_table != global_class_table) {
|
||||
zend_hash_destroy(compiler_globals->class_table);
|
||||
free(compiler_globals->class_table);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS_DC)
|
||||
{
|
||||
if (global_constants_table) {
|
||||
zend_startup_constants(TSRMLS_C);
|
||||
zend_copy_constants(EG(zend_constants), global_constants_table);
|
||||
}
|
||||
zend_init_rsrc_plist(TSRMLS_C);
|
||||
EG(lambda_count)=0;
|
||||
EG(user_error_handler) = NULL;
|
||||
EG(in_execution) = 0;
|
||||
}
|
||||
|
||||
|
||||
static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS_DC)
|
||||
{
|
||||
zend_shutdown_constants(TSRMLS_C);
|
||||
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
|
||||
zend_ini_shutdown(TSRMLS_C);
|
||||
}
|
||||
|
||||
|
||||
static void zend_new_thread_end_handler(THREAD_T thread_id TSRMLS_DC)
|
||||
{
|
||||
zend_copy_ini_directives(TSRMLS_C);
|
||||
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void alloc_globals_ctor(zend_alloc_globals *alloc_globals_p TSRMLS_DC)
|
||||
{
|
||||
start_memory_manager(TSRMLS_C);
|
||||
}
|
||||
|
||||
|
||||
static void alloc_globals_dtor(zend_alloc_globals *alloc_globals_p TSRMLS_DC)
|
||||
{
|
||||
shutdown_memory_manager(0, 1);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* FreeBSD floating point precision fix */
|
||||
#include <floatingpoint.h>
|
||||
#endif
|
||||
|
||||
|
||||
static void scanner_globals_ctor(zend_scanner_globals *scanner_globals_p TSRMLS_DC)
|
||||
{
|
||||
scanner_globals_p->c_buf_p = (char *) 0;
|
||||
scanner_globals_p->init = 1;
|
||||
scanner_globals_p->start = 0;
|
||||
scanner_globals_p->current_buffer = NULL;
|
||||
}
|
||||
|
||||
|
||||
int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions)
|
||||
{
|
||||
#ifdef ZTS
|
||||
zend_compiler_globals *compiler_globals;
|
||||
zend_executor_globals *executor_globals;
|
||||
void ***tsrm_ls;
|
||||
#ifdef ZTS
|
||||
extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
|
||||
extern ZEND_API ts_rsrc_id language_scanner_globals_id;
|
||||
#else
|
||||
extern zend_scanner_globals ini_scanner_globals;
|
||||
extern zend_scanner_globals language_scanner_globals;
|
||||
#endif
|
||||
|
||||
ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
|
||||
#else
|
||||
alloc_globals_ctor(&alloc_globals TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* FreeBSD floating point precision fix */
|
||||
fpsetmask(0);
|
||||
#endif
|
||||
|
||||
zend_startup_extensions_mechanism();
|
||||
|
||||
/* Set up utility functions and values */
|
||||
zend_error_cb = utility_functions->error_function;
|
||||
zend_printf = utility_functions->printf_function;
|
||||
zend_write = (zend_write_func_t) utility_functions->write_function;
|
||||
zend_fopen = utility_functions->fopen_function;
|
||||
if (!zend_fopen) {
|
||||
zend_fopen = zend_fopen_wrapper;
|
||||
}
|
||||
zend_message_dispatcher_p = utility_functions->message_handler;
|
||||
zend_block_interruptions = utility_functions->block_interruptions;
|
||||
zend_unblock_interruptions = utility_functions->unblock_interruptions;
|
||||
zend_get_configuration_directive_p = utility_functions->get_configuration_directive;
|
||||
zend_ticks_function = utility_functions->ticks_function;
|
||||
|
||||
zend_compile_file = compile_file;
|
||||
zend_execute = execute;
|
||||
|
||||
/* set up version */
|
||||
zend_version_info = strdup(ZEND_CORE_VERSION_INFO);
|
||||
zend_version_info_length = sizeof(ZEND_CORE_VERSION_INFO)-1;
|
||||
|
||||
GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
|
||||
GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
|
||||
zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0);
|
||||
zend_hash_init_ex(GLOBAL_CLASS_TABLE, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
|
||||
register_standard_class();
|
||||
zend_hash_init_ex(&module_registry, 50, NULL, ZEND_MODULE_DTOR, 1, 0);
|
||||
zend_init_rsrc_list_dtors();
|
||||
|
||||
/* This zval can be used to initialize allocate zval's to an uninit'ed value */
|
||||
zval_used_for_init.is_ref = 0;
|
||||
zval_used_for_init.refcount = 1;
|
||||
zval_used_for_init.type = IS_NULL;
|
||||
|
||||
#ifdef ZTS
|
||||
global_constants_table = NULL;
|
||||
ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
|
||||
ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
|
||||
ts_allocate_id(&language_scanner_globals_id, sizeof(zend_scanner_globals), (ts_allocate_ctor) scanner_globals_ctor, NULL);
|
||||
ts_allocate_id(&ini_scanner_globals_id, sizeof(zend_scanner_globals), (ts_allocate_ctor) scanner_globals_ctor, NULL);
|
||||
compiler_globals = ts_resource(compiler_globals_id);
|
||||
executor_globals = ts_resource(executor_globals_id);
|
||||
tsrm_ls = ts_resource_ex(0, NULL);
|
||||
compiler_globals_dtor(compiler_globals, tsrm_ls);
|
||||
compiler_globals->function_table = GLOBAL_FUNCTION_TABLE;
|
||||
compiler_globals->class_table = GLOBAL_CLASS_TABLE;
|
||||
zend_startup_constants(tsrm_ls);
|
||||
GLOBAL_CONSTANTS_TABLE = EG(zend_constants);
|
||||
#else
|
||||
scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC);
|
||||
scanner_globals_ctor(&language_scanner_globals TSRMLS_CC);
|
||||
zend_startup_constants();
|
||||
zend_set_default_compile_time_values(TSRMLS_C);
|
||||
EG(user_error_handler) = NULL;
|
||||
#endif
|
||||
zend_register_standard_constants(TSRMLS_C);
|
||||
|
||||
#ifndef ZTS
|
||||
zend_init_rsrc_plist(TSRMLS_C);
|
||||
#endif
|
||||
|
||||
if (start_builtin_functions) {
|
||||
zend_startup_builtin_functions(TSRMLS_C);
|
||||
}
|
||||
|
||||
zend_ini_startup(TSRMLS_C);
|
||||
|
||||
#ifdef ZTS
|
||||
tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void zend_shutdown(TSRMLS_D)
|
||||
{
|
||||
#ifdef ZEND_WIN32
|
||||
zend_shutdown_timeout_thread();
|
||||
#endif
|
||||
#ifndef ZTS
|
||||
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
|
||||
#endif
|
||||
zend_destroy_rsrc_list_dtors();
|
||||
zend_hash_destroy(&module_registry);
|
||||
zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
|
||||
free(GLOBAL_FUNCTION_TABLE);
|
||||
zend_hash_destroy(GLOBAL_CLASS_TABLE);
|
||||
free(GLOBAL_CLASS_TABLE);
|
||||
zend_shutdown_extensions(TSRMLS_C);
|
||||
free(zend_version_info);
|
||||
#ifndef ZTS
|
||||
zend_shutdown_constants();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void zend_set_utility_values(zend_utility_values *utility_values)
|
||||
{
|
||||
zend_uv = *utility_values;
|
||||
zend_uv.import_use_extension_length = strlen(zend_uv.import_use_extension);
|
||||
}
|
||||
|
||||
|
||||
/* this should be compatible with the standard zenderror */
|
||||
void zenderror(char *error)
|
||||
{
|
||||
zend_error(E_PARSE, error);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void _zend_bailout(char *filename, uint lineno)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (!EG(bailout_set)) {
|
||||
zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno);
|
||||
exit(-1);
|
||||
}
|
||||
CG(unclean_shutdown) = 1;
|
||||
CG(in_compilation) = EG(in_execution) = 0;
|
||||
longjmp(EG(bailout), FAILURE);
|
||||
}
|
||||
END_EXTERN_C()
|
||||
|
||||
|
||||
void zend_append_version_info(zend_extension *extension)
|
||||
{
|
||||
char *new_info;
|
||||
uint new_info_length;
|
||||
|
||||
new_info_length = sizeof(" with v, by \n")
|
||||
+ strlen(extension->name)
|
||||
+ strlen(extension->version)
|
||||
+ strlen(extension->copyright)
|
||||
+ strlen(extension->author);
|
||||
|
||||
new_info = (char *) malloc(new_info_length+1);
|
||||
|
||||
sprintf(new_info, " with %s v%s, %s, by %s\n", extension->name, extension->version, extension->copyright, extension->author);
|
||||
|
||||
zend_version_info = (char *) realloc(zend_version_info, zend_version_info_length+new_info_length+1);
|
||||
strcat(zend_version_info, new_info);
|
||||
zend_version_info_length += new_info_length;
|
||||
free(new_info);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *get_zend_version()
|
||||
{
|
||||
return zend_version_info;
|
||||
}
|
||||
|
||||
|
||||
void zend_activate(TSRMLS_D)
|
||||
{
|
||||
EG(bailout_set) = 0;
|
||||
init_compiler(TSRMLS_C);
|
||||
init_executor(TSRMLS_C);
|
||||
startup_scanner(TSRMLS_C);
|
||||
}
|
||||
|
||||
|
||||
void zend_activate_modules(TSRMLS_D)
|
||||
{
|
||||
zend_hash_apply(&module_registry, (apply_func_t) module_registry_request_startup TSRMLS_CC);
|
||||
}
|
||||
|
||||
void zend_deactivate_modules(TSRMLS_D)
|
||||
{
|
||||
EG(opline_ptr) = NULL; /* we're no longer executing anything */
|
||||
|
||||
zend_try {
|
||||
zend_hash_apply(&module_registry, (apply_func_t) module_registry_cleanup TSRMLS_CC);
|
||||
} zend_end_try();
|
||||
}
|
||||
|
||||
void zend_deactivate(TSRMLS_D)
|
||||
{
|
||||
/* we're no longer executing anything */
|
||||
EG(opline_ptr) = NULL;
|
||||
EG(active_symbol_table) = NULL;
|
||||
|
||||
zend_try {
|
||||
shutdown_scanner(TSRMLS_C);
|
||||
} zend_end_try();
|
||||
|
||||
/* shutdown_executor() takes care of its own bailout handling */
|
||||
shutdown_executor(TSRMLS_C);
|
||||
|
||||
zend_try {
|
||||
shutdown_compiler(TSRMLS_C);
|
||||
} zend_end_try();
|
||||
|
||||
zend_try {
|
||||
zend_ini_deactivate(TSRMLS_C);
|
||||
} zend_end_try();
|
||||
}
|
||||
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void zend_message_dispatcher(long message, void *data)
|
||||
{
|
||||
if (zend_message_dispatcher_p) {
|
||||
zend_message_dispatcher_p(message, data);
|
||||
}
|
||||
}
|
||||
END_EXTERN_C()
|
||||
|
||||
|
||||
ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents)
|
||||
{
|
||||
if (zend_get_configuration_directive_p) {
|
||||
return zend_get_configuration_directive_p(name, name_length, contents);
|
||||
} else {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define ZEND_ERROR_BUFFER_SIZE 1024
|
||||
|
||||
ZEND_API void zend_error(int type, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
zval ***params;
|
||||
zval *retval;
|
||||
zval *z_error_type, *z_error_message, *z_error_filename, *z_error_lineno, *z_context;
|
||||
char *error_filename;
|
||||
uint error_lineno;
|
||||
zval *orig_user_error_handler;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
/* Obtain relevant filename and lineno */
|
||||
switch (type) {
|
||||
case E_CORE_ERROR:
|
||||
case E_CORE_WARNING:
|
||||
error_filename = NULL;
|
||||
error_lineno = 0;
|
||||
break;
|
||||
case E_PARSE:
|
||||
case E_COMPILE_ERROR:
|
||||
case E_COMPILE_WARNING:
|
||||
case E_ERROR:
|
||||
case E_NOTICE:
|
||||
case E_WARNING:
|
||||
case E_USER_ERROR:
|
||||
case E_USER_WARNING:
|
||||
case E_USER_NOTICE:
|
||||
if (zend_is_compiling(TSRMLS_C)) {
|
||||
error_filename = zend_get_compiled_filename(TSRMLS_C);
|
||||
error_lineno = zend_get_compiled_lineno(TSRMLS_C);
|
||||
} else if (zend_is_executing(TSRMLS_C)) {
|
||||
error_filename = zend_get_executed_filename(TSRMLS_C);
|
||||
error_lineno = zend_get_executed_lineno(TSRMLS_C);
|
||||
} else {
|
||||
error_filename = NULL;
|
||||
error_lineno = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_filename = NULL;
|
||||
error_lineno = 0;
|
||||
break;
|
||||
}
|
||||
if (!error_filename) {
|
||||
error_filename = "Unknown";
|
||||
}
|
||||
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
/* if we don't have a user defined error handler */
|
||||
if (!EG(user_error_handler)) {
|
||||
zend_error_cb(type, error_filename, error_lineno, format, args);
|
||||
} else switch (type) {
|
||||
case E_ERROR:
|
||||
case E_PARSE:
|
||||
case E_CORE_ERROR:
|
||||
case E_CORE_WARNING:
|
||||
case E_COMPILE_ERROR:
|
||||
case E_COMPILE_WARNING:
|
||||
/* The error may not be safe to handle in user-space */
|
||||
zend_error_cb(type, error_filename, error_lineno, format, args);
|
||||
break;
|
||||
default:
|
||||
/* Handle the error in user space */
|
||||
ALLOC_INIT_ZVAL(z_error_message);
|
||||
ALLOC_INIT_ZVAL(z_error_type);
|
||||
ALLOC_INIT_ZVAL(z_error_filename);
|
||||
ALLOC_INIT_ZVAL(z_error_lineno);
|
||||
ALLOC_INIT_ZVAL(z_context);
|
||||
z_error_message->value.str.val = (char *) emalloc(ZEND_ERROR_BUFFER_SIZE);
|
||||
|
||||
#ifdef HAVE_VSNPRINTF
|
||||
z_error_message->value.str.len = vsnprintf(z_error_message->value.str.val, ZEND_ERROR_BUFFER_SIZE, format, args);
|
||||
if (z_error_message->value.str.len > ZEND_ERROR_BUFFER_SIZE-1) {
|
||||
z_error_message->value.str.len = ZEND_ERROR_BUFFER_SIZE-1;
|
||||
}
|
||||
#else
|
||||
strncpy(z_error_message->value.str.val, format, ZEND_ERROR_BUFFER_SIZE);
|
||||
/* This is risky... */
|
||||
/* z_error_message->value.str.len = vsprintf(z_error_message->value.str.val, format, args); */
|
||||
#endif
|
||||
z_error_message->type = IS_STRING;
|
||||
|
||||
z_error_type->value.lval = type;
|
||||
z_error_type->type = IS_LONG;
|
||||
|
||||
if (error_filename) {
|
||||
z_error_filename->value.str.len = strlen(error_filename);
|
||||
z_error_filename->value.str.val = estrndup(error_filename, z_error_filename->value.str.len);
|
||||
z_error_filename->type = IS_STRING;
|
||||
}
|
||||
|
||||
z_error_lineno->value.lval = error_lineno;
|
||||
z_error_lineno->type = IS_LONG;
|
||||
|
||||
z_context->value.ht = EG(active_symbol_table);
|
||||
z_context->type = IS_ARRAY;
|
||||
ZVAL_ADDREF(z_context); /* we don't want this one to be freed */
|
||||
|
||||
params = (zval ***) emalloc(sizeof(zval **)*5);
|
||||
params[0] = &z_error_type;
|
||||
params[1] = &z_error_message;
|
||||
params[2] = &z_error_filename;
|
||||
params[3] = &z_error_lineno;
|
||||
params[4] = &z_context;
|
||||
|
||||
orig_user_error_handler = EG(user_error_handler);
|
||||
EG(user_error_handler) = NULL;
|
||||
if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC)==SUCCESS) {
|
||||
zval_ptr_dtor(&retval);
|
||||
} else {
|
||||
/* The user error handler failed, use built-in error handler */
|
||||
zend_error_cb(type, error_filename, error_lineno, format, args);
|
||||
}
|
||||
EG(user_error_handler) = orig_user_error_handler;
|
||||
|
||||
efree(params);
|
||||
zval_ptr_dtor(&z_error_message);
|
||||
zval_ptr_dtor(&z_error_type);
|
||||
zval_ptr_dtor(&z_error_filename);
|
||||
zval_ptr_dtor(&z_error_lineno);
|
||||
if (ZVAL_REFCOUNT(z_context)==2) {
|
||||
FREE_ZVAL(z_context);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
|
||||
if (type==E_PARSE) {
|
||||
zend_init_compiler_data_structures(TSRMLS_C);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...)
|
||||
{
|
||||
#if ZEND_DEBUG
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
# ifdef ZEND_WIN32
|
||||
{
|
||||
char output_buf[1024];
|
||||
|
||||
vsnprintf(output_buf, 1024, format, args);
|
||||
OutputDebugString(output_buf);
|
||||
OutputDebugString("\n");
|
||||
if (trigger_break && IsDebuggerPresent()) {
|
||||
DebugBreak();
|
||||
}
|
||||
}
|
||||
# else
|
||||
vfprintf(stderr, format, args);
|
||||
fprintf(stderr, "\n");
|
||||
# endif
|
||||
va_end(args);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_execute_scripts(int type TSRMLS_DC, int file_count, ...)
|
||||
{
|
||||
va_list files;
|
||||
int i;
|
||||
zend_file_handle *file_handle;
|
||||
zend_op_array *orig_op_array = EG(active_op_array);
|
||||
|
||||
va_start(files, file_count);
|
||||
for (i=0; i<file_count; i++) {
|
||||
file_handle = va_arg(files, zend_file_handle *);
|
||||
if (!file_handle) {
|
||||
continue;
|
||||
}
|
||||
EG(active_op_array) = zend_compile_file(file_handle, ZEND_INCLUDE TSRMLS_CC);
|
||||
zend_destroy_file_handle(file_handle TSRMLS_CC);
|
||||
if (EG(active_op_array)) {
|
||||
zend_execute(EG(active_op_array) TSRMLS_CC);
|
||||
zval_ptr_dtor(EG(return_value_ptr_ptr));
|
||||
EG(return_value_ptr_ptr) = &EG(global_return_value_ptr);
|
||||
EG(global_return_value_ptr) = NULL;
|
||||
destroy_op_array(EG(active_op_array));
|
||||
efree(EG(active_op_array));
|
||||
} else if (type==ZEND_REQUIRE) {
|
||||
va_end(files);
|
||||
EG(active_op_array) = orig_op_array;
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
va_end(files);
|
||||
EG(active_op_array) = orig_op_array;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
#define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
|
||||
|
||||
ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC)
|
||||
{
|
||||
char *cur_filename;
|
||||
int cur_lineno;
|
||||
char *compiled_string_description;
|
||||
|
||||
if (zend_is_compiling(TSRMLS_C)) {
|
||||
cur_filename = zend_get_compiled_filename(TSRMLS_C);
|
||||
cur_lineno = zend_get_compiled_lineno(TSRMLS_C);
|
||||
} else if (zend_is_executing(TSRMLS_C)) {
|
||||
cur_filename = zend_get_executed_filename(TSRMLS_C);
|
||||
cur_lineno = zend_get_executed_lineno(TSRMLS_C);
|
||||
} else {
|
||||
cur_filename = "Unknown";
|
||||
cur_lineno = 0;
|
||||
}
|
||||
|
||||
compiled_string_description = emalloc(sizeof(COMPILED_STRING_DESCRIPTION_FORMAT)+strlen(name)+strlen(cur_filename)+MAX_LENGTH_OF_LONG);
|
||||
sprintf(compiled_string_description, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name);
|
||||
return compiled_string_description;
|
||||
}
|
||||
|
||||
|
||||
void free_estring(char **str_p)
|
||||
{
|
||||
efree(*str_p);
|
||||
}
|
||||
+499
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_H
|
||||
#define ZEND_H
|
||||
|
||||
#define ZEND_VERSION "1.0.7"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define BEGIN_EXTERN_C() extern "C" {
|
||||
#define END_EXTERN_C() }
|
||||
#else
|
||||
#define BEGIN_EXTERN_C()
|
||||
#define END_EXTERN_C()
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* general definitions
|
||||
*/
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
# include "zend_config.w32.h"
|
||||
# define ZEND_PATHS_SEPARATOR ';'
|
||||
#else
|
||||
# include "zend_config.h"
|
||||
# define ZEND_PATHS_SEPARATOR ':'
|
||||
#endif
|
||||
|
||||
/* all HAVE_XXX test have to be after the include of zend_config above */
|
||||
|
||||
#ifdef HAVE_UNIX_H
|
||||
# include <unix.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
# include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LIBDL)
|
||||
|
||||
# ifndef RTLD_LAZY
|
||||
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
|
||||
# endif
|
||||
|
||||
# ifndef RTLD_GLOBAL
|
||||
# define RTLD_GLOBAL 0
|
||||
# endif
|
||||
|
||||
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
|
||||
# define DL_UNLOAD dlclose
|
||||
# define DL_FETCH_SYMBOL dlsym
|
||||
# define DL_HANDLE void *
|
||||
# define ZEND_EXTENSIONS_SUPPORT 1
|
||||
#elif defined(ZEND_WIN32)
|
||||
# define DL_LOAD(libname) LoadLibrary(libname)
|
||||
# define DL_FETCH_SYMBOL GetProcAddress
|
||||
# define DL_UNLOAD FreeLibrary
|
||||
# define DL_HANDLE HMODULE
|
||||
# define ZEND_EXTENSIONS_SUPPORT 1
|
||||
#else
|
||||
# define DL_HANDLE void *
|
||||
# define ZEND_EXTENSIONS_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32))
|
||||
# define do_alloca(p) alloca(p)
|
||||
# define free_alloca(p)
|
||||
#else
|
||||
# define do_alloca(p) emalloc(p)
|
||||
# define free_alloca(p) efree(p)
|
||||
#endif
|
||||
|
||||
#if ZEND_DEBUG
|
||||
#define ZEND_FILE_LINE_D char *__zend_filename, uint __zend_lineno
|
||||
#define ZEND_FILE_LINE_DC , ZEND_FILE_LINE_D
|
||||
#define ZEND_FILE_LINE_ORIG_D char *__zend_orig_filename, uint __zend_orig_lineno
|
||||
#define ZEND_FILE_LINE_ORIG_DC , ZEND_FILE_LINE_ORIG_D
|
||||
#define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
|
||||
#define ZEND_FILE_LINE_RELAY_CC , ZEND_FILE_LINE_RELAY_C
|
||||
#define ZEND_FILE_LINE_C __FILE__, __LINE__
|
||||
#define ZEND_FILE_LINE_CC , ZEND_FILE_LINE_C
|
||||
#define ZEND_FILE_LINE_EMPTY_C NULL, 0
|
||||
#define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C
|
||||
#define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno
|
||||
#define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C
|
||||
#else
|
||||
#define ZEND_FILE_LINE_D
|
||||
#define ZEND_FILE_LINE_DC
|
||||
#define ZEND_FILE_LINE_ORIG_D
|
||||
#define ZEND_FILE_LINE_ORIG_DC
|
||||
#define ZEND_FILE_LINE_RELAY_C
|
||||
#define ZEND_FILE_LINE_RELAY_CC
|
||||
#define ZEND_FILE_LINE_C
|
||||
#define ZEND_FILE_LINE_CC
|
||||
#define ZEND_FILE_LINE_EMPTY_C
|
||||
#define ZEND_FILE_LINE_EMPTY_CC
|
||||
#define ZEND_FILE_LINE_ORIG_RELAY_C
|
||||
#define ZEND_FILE_LINE_ORIG_RELAY_CC
|
||||
#endif /* ZEND_DEBUG */
|
||||
|
||||
#ifdef ZTS
|
||||
#define ZTS_V 1
|
||||
#else
|
||||
#define ZTS_V 0
|
||||
#endif
|
||||
|
||||
#include "zend_errors.h"
|
||||
#include "zend_alloc.h"
|
||||
|
||||
typedef unsigned char zend_bool;
|
||||
typedef unsigned char zend_uchar;
|
||||
typedef unsigned int zend_uint;
|
||||
typedef unsigned long zend_ulong;
|
||||
typedef unsigned short zend_ushort;
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MAX
|
||||
#define LONG_MAX 2147483647L
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MIN
|
||||
#define LONG_MIN (- LONG_MAX - 1)
|
||||
#endif
|
||||
|
||||
#undef SUCCESS
|
||||
#undef FAILURE
|
||||
#define SUCCESS 0
|
||||
#define FAILURE -1 /* this MUST stay a negative number, or it may affect functions! */
|
||||
|
||||
|
||||
#include "zend_hash.h"
|
||||
#include "zend_llist.h"
|
||||
|
||||
#define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval *this_ptr, int return_value_used TSRMLS_DC
|
||||
#define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, this_ptr, return_value_used TSRMLS_CC
|
||||
|
||||
/*
|
||||
* zval
|
||||
*/
|
||||
typedef struct _zval_struct zval;
|
||||
typedef struct _zend_class_entry zend_class_entry;
|
||||
|
||||
typedef struct _zend_object {
|
||||
zend_class_entry *ce;
|
||||
HashTable *properties;
|
||||
} zend_object;
|
||||
|
||||
typedef union _zvalue_value {
|
||||
long lval; /* long value */
|
||||
double dval; /* double value */
|
||||
struct {
|
||||
char *val;
|
||||
int len;
|
||||
} str;
|
||||
HashTable *ht; /* hash table value */
|
||||
zend_object obj;
|
||||
} zvalue_value;
|
||||
|
||||
|
||||
struct _zval_struct {
|
||||
/* Variable information */
|
||||
zvalue_value value; /* value */
|
||||
zend_uchar type; /* active type */
|
||||
zend_uchar is_ref;
|
||||
zend_ushort refcount;
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct _zend_function_entry {
|
||||
char *fname;
|
||||
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
|
||||
unsigned char *func_arg_types;
|
||||
} zend_function_entry;
|
||||
|
||||
|
||||
typedef struct _zend_property_reference {
|
||||
int type; /* read, write or r/w */
|
||||
zval *object;
|
||||
zend_llist *elements_list;
|
||||
} zend_property_reference;
|
||||
|
||||
|
||||
|
||||
typedef struct _zend_overloaded_element {
|
||||
int type; /* array offset or object proprety */
|
||||
zval element;
|
||||
} zend_overloaded_element;
|
||||
|
||||
/* excpt.h on Digital Unix 4.0 defines function_table */
|
||||
#undef function_table
|
||||
|
||||
struct _zend_class_entry {
|
||||
char type;
|
||||
char *name;
|
||||
uint name_length;
|
||||
struct _zend_class_entry *parent;
|
||||
int *refcount;
|
||||
zend_bool constants_updated;
|
||||
|
||||
HashTable function_table;
|
||||
HashTable default_properties;
|
||||
zend_function_entry *builtin_functions;
|
||||
|
||||
/* handlers */
|
||||
void (*handle_function_call)(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
||||
zval (*handle_property_get)(zend_property_reference *property_reference);
|
||||
int (*handle_property_set)(zend_property_reference *property_reference, zval *value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct _zend_utility_functions {
|
||||
void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
||||
int (*printf_function)(const char *format, ...);
|
||||
int (*write_function)(const char *str, uint str_length);
|
||||
FILE *(*fopen_function)(const char *filename, char **opened_path);
|
||||
void (*message_handler)(long message, void *data);
|
||||
void (*block_interruptions)(void);
|
||||
void (*unblock_interruptions)(void);
|
||||
int (*get_configuration_directive)(char *name, uint name_length, zval *contents);
|
||||
void (*ticks_function)(int ticks);
|
||||
} zend_utility_functions;
|
||||
|
||||
|
||||
typedef struct _zend_utility_values {
|
||||
char *import_use_extension;
|
||||
uint import_use_extension_length;
|
||||
} zend_utility_values;
|
||||
|
||||
|
||||
typedef int (*zend_write_func_t)(const char *str, uint str_length);
|
||||
|
||||
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define ZEND_STRL(str) (str), (sizeof(str)-1)
|
||||
#define ZEND_STRS(str) (str), (sizeof(str))
|
||||
#define ZEND_NORMALIZE_BOOL(n) \
|
||||
((n) ? (((n)>0) ? 1 : -1) : 0)
|
||||
|
||||
|
||||
/* data types */
|
||||
#define IS_NULL 0
|
||||
#define IS_LONG 1
|
||||
#define IS_DOUBLE 2
|
||||
#define IS_STRING 3
|
||||
#define IS_ARRAY 4
|
||||
#define IS_OBJECT 5
|
||||
#define IS_BOOL 6
|
||||
#define IS_RESOURCE 7
|
||||
#define IS_CONSTANT 8
|
||||
#define IS_CONSTANT_ARRAY 9
|
||||
|
||||
/* Special data type to temporarily mark large numbers */
|
||||
#define FLAG_IS_BC 10 /* for parser internal use only */
|
||||
|
||||
/* Ugly hack to support constants as static array indices */
|
||||
#define IS_CONSTANT_INDEX 0x80
|
||||
|
||||
|
||||
/* overloaded elements data types */
|
||||
#define OE_IS_ARRAY (1<<0)
|
||||
#define OE_IS_OBJECT (1<<1)
|
||||
#define OE_IS_METHOD (1<<2)
|
||||
|
||||
|
||||
/* Argument passing types */
|
||||
#define BYREF_NONE 0
|
||||
#define BYREF_FORCE 1
|
||||
#define BYREF_ALLOW 2
|
||||
#define BYREF_FORCE_REST 3
|
||||
|
||||
int zend_startup(zend_utility_functions *utility_functions, char **extensions, int start_builtin_functions);
|
||||
void zend_shutdown(TSRMLS_D);
|
||||
|
||||
void zend_set_utility_values(zend_utility_values *utility_values);
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void _zend_bailout(char *filename, uint lineno);
|
||||
END_EXTERN_C()
|
||||
|
||||
#define zend_bailout() _zend_bailout(__FILE__, __LINE__)
|
||||
|
||||
#define zend_try \
|
||||
{ \
|
||||
jmp_buf orig_bailout; \
|
||||
zend_bool orig_bailout_set=EG(bailout_set); \
|
||||
\
|
||||
EG(bailout_set) = 1; \
|
||||
memcpy(&orig_bailout, &EG(bailout), sizeof(jmp_buf)); \
|
||||
if (setjmp(EG(bailout))==0)
|
||||
#define zend_catch \
|
||||
else
|
||||
#define zend_end_try() \
|
||||
memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf)); \
|
||||
EG(bailout_set) = orig_bailout_set; \
|
||||
}
|
||||
|
||||
ZEND_API char *get_zend_version(void);
|
||||
ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy);
|
||||
ZEND_API int zend_print_zval(zval *expr, int indent);
|
||||
ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
|
||||
ZEND_API void zend_print_zval_r(zval *expr, int indent);
|
||||
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent);
|
||||
ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...);
|
||||
|
||||
#if ZEND_DEBUG
|
||||
#define Z_DBG(expr) (expr)
|
||||
#else
|
||||
#define Z_DBG(expr)
|
||||
#endif
|
||||
|
||||
ZEND_API extern char *empty_string;
|
||||
|
||||
ZEND_API void free_estring(char **str_p);
|
||||
|
||||
#define STR_FREE(ptr) if (ptr && ptr!=empty_string) { efree(ptr); }
|
||||
#define STR_FREE_REL(ptr) if (ptr && ptr!=empty_string) { efree_rel(ptr); }
|
||||
|
||||
#define STR_REALLOC(ptr, size) \
|
||||
if (ptr!=empty_string) { \
|
||||
ptr = (char *) erealloc(ptr, size); \
|
||||
} else { \
|
||||
ptr = (char *) emalloc(size); \
|
||||
memset(ptr, 0, size); \
|
||||
}
|
||||
|
||||
/* output support */
|
||||
#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
|
||||
#define ZEND_PUTS(str) zend_write((str), strlen((str)))
|
||||
#define ZEND_PUTC(c) zend_write(&(c), 1), (c)
|
||||
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
extern ZEND_API int (*zend_printf)(const char *format, ...);
|
||||
extern ZEND_API zend_write_func_t zend_write;
|
||||
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path);
|
||||
extern ZEND_API void (*zend_block_interruptions)(void);
|
||||
extern ZEND_API void (*zend_unblock_interruptions)(void);
|
||||
extern ZEND_API void (*zend_ticks_function)(int ticks);
|
||||
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
||||
|
||||
|
||||
ZEND_API void zend_error(int type, const char *format, ...);
|
||||
|
||||
void zenderror(char *error);
|
||||
|
||||
extern ZEND_API zend_class_entry zend_standard_class_def;
|
||||
extern zend_utility_values zend_uv;
|
||||
extern ZEND_API zval zval_used_for_init;
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
#define ZEND_UV(name) (zend_uv.name)
|
||||
|
||||
|
||||
#define HANDLE_BLOCK_INTERRUPTIONS() if (zend_block_interruptions) { zend_block_interruptions(); }
|
||||
#define HANDLE_UNBLOCK_INTERRUPTIONS() if (zend_unblock_interruptions) { zend_unblock_interruptions(); }
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void zend_message_dispatcher(long message, void *data);
|
||||
END_EXTERN_C()
|
||||
|
||||
ZEND_API int zend_get_configuration_directive(char *name, uint name_length, zval *contents);
|
||||
|
||||
|
||||
/* Messages for applications of Zend */
|
||||
#define ZMSG_FAILED_INCLUDE_FOPEN 1L
|
||||
#define ZMSG_FAILED_REQUIRE_FOPEN 2L
|
||||
#define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
|
||||
#define ZMSG_MEMORY_LEAK_DETECTED 4L
|
||||
#define ZMSG_MEMORY_LEAK_REPEATED 5L
|
||||
#define ZMSG_LOG_SCRIPT_NAME 6L
|
||||
|
||||
|
||||
#define ZVAL_ADDREF(pz) (++(pz)->refcount)
|
||||
#define ZVAL_DELREF(pz) (--(pz)->refcount)
|
||||
#define ZVAL_REFCOUNT(pz) ((pz)->refcount)
|
||||
|
||||
#define INIT_PZVAL(z) \
|
||||
(z)->refcount = 1; \
|
||||
(z)->is_ref = 0;
|
||||
|
||||
#define INIT_ZVAL(z) z = zval_used_for_init;
|
||||
|
||||
#define ALLOC_INIT_ZVAL(zp) \
|
||||
ALLOC_ZVAL(zp); \
|
||||
INIT_ZVAL(*zp);
|
||||
|
||||
#define MAKE_STD_ZVAL(zv) \
|
||||
ALLOC_ZVAL(zv); \
|
||||
INIT_PZVAL(zv);
|
||||
|
||||
#define PZVAL_IS_REF(z) ((z)->is_ref)
|
||||
|
||||
#define SEPARATE_ZVAL(ppzv) \
|
||||
{ \
|
||||
zval *orig_ptr = *(ppzv); \
|
||||
\
|
||||
if (orig_ptr->refcount>1) { \
|
||||
orig_ptr->refcount--; \
|
||||
ALLOC_ZVAL(*(ppzv)); \
|
||||
**(ppzv) = *orig_ptr; \
|
||||
zval_copy_ctor(*(ppzv)); \
|
||||
(*(ppzv))->refcount=1; \
|
||||
(*(ppzv))->is_ref = 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SEPARATE_ZVAL_IF_NOT_REF(ppzv) \
|
||||
if (!PZVAL_IS_REF(*ppzv)) { \
|
||||
SEPARATE_ZVAL(ppzv); \
|
||||
}
|
||||
|
||||
#define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv) \
|
||||
if (!PZVAL_IS_REF(*ppzv)) { \
|
||||
SEPARATE_ZVAL(ppzv); \
|
||||
(*(ppzv))->is_ref = 1; \
|
||||
}
|
||||
|
||||
#define COPY_PZVAL_TO_ZVAL(zv, pzv) \
|
||||
(zv) = *(pzv); \
|
||||
if ((pzv)->refcount>1) { \
|
||||
zval_copy_ctor(&(zv)); \
|
||||
(pzv)->refcount--; \
|
||||
} else { \
|
||||
FREE_ZVAL(pzv); \
|
||||
} \
|
||||
INIT_PZVAL(&(zv));
|
||||
|
||||
#define REPLACE_ZVAL_VALUE(ppzv_dest,pzv_src,copy) { \
|
||||
int is_ref,refcount; \
|
||||
\
|
||||
SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest); \
|
||||
is_ref = (*ppzv_dest)->is_ref; \
|
||||
refcount = (*ppzv_dest)->refcount; \
|
||||
zval_dtor(*ppzv_dest); \
|
||||
**ppzv_dest = *pzv_src; \
|
||||
if (copy) { \
|
||||
zval_copy_ctor(*ppzv_dest); \
|
||||
} \
|
||||
(*ppzv_dest)->is_ref = is_ref; \
|
||||
(*ppzv_dest)->refcount = refcount; \
|
||||
}
|
||||
|
||||
#define ZEND_MAX_RESERVED_RESOURCES 4
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
/* Only use this macro if you know for sure that all of the switches values
|
||||
are covered by its case statements */
|
||||
#define EMPTY_SWITCH_DEFAULT_CASE() \
|
||||
default: \
|
||||
__assume(0); \
|
||||
break;
|
||||
#else
|
||||
#define EMPTY_SWITCH_DEFAULT_CASE()
|
||||
#endif
|
||||
|
||||
#endif /* ZEND_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
+1377
File diff suppressed because it is too large.
Load diff
+406
@@ -0,0 +1,406 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
| Andrei Zmievski <andrei@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_API_H
|
||||
#define ZEND_API_H
|
||||
|
||||
#include "zend_modules.h"
|
||||
#include "zend_list.h"
|
||||
#include "zend_fast_cache.h"
|
||||
#include "zend_operators.h"
|
||||
#include "zend_variables.h"
|
||||
#include "zend_execute.h"
|
||||
|
||||
#define ZEND_FN(name) zend_if_##name
|
||||
#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
|
||||
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
|
||||
|
||||
#define ZEND_NAMED_FE(zend_name, name, arg_types) { #zend_name, name, arg_types },
|
||||
#define ZEND_FE(name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(name), arg_types)
|
||||
#define ZEND_FALIAS(name, alias, arg_types) ZEND_NAMED_FE(name, ZEND_FN(alias), arg_types)
|
||||
|
||||
#define ZEND_MINIT(module) zend_minit_##module
|
||||
#define ZEND_MSHUTDOWN(module) zend_mshutdown_##module
|
||||
#define ZEND_RINIT(module) zend_rinit_##module
|
||||
#define ZEND_RSHUTDOWN(module) zend_rshutdown_##module
|
||||
#define ZEND_MINFO(module) zend_info_##module
|
||||
|
||||
#define ZEND_MINIT_FUNCTION(module) int ZEND_MINIT(module)(INIT_FUNC_ARGS)
|
||||
#define ZEND_MSHUTDOWN_FUNCTION(module) int ZEND_MSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
|
||||
#define ZEND_RINIT_FUNCTION(module) int ZEND_RINIT(module)(INIT_FUNC_ARGS)
|
||||
#define ZEND_RSHUTDOWN_FUNCTION(module) int ZEND_RSHUTDOWN(module)(SHUTDOWN_FUNC_ARGS)
|
||||
#define ZEND_MINFO_FUNCTION(module) void ZEND_MINFO(module)(ZEND_MODULE_INFO_FUNC_ARGS)
|
||||
|
||||
#define ZEND_GET_MODULE(name) \
|
||||
ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }
|
||||
|
||||
#define ZEND_BEGIN_MODULE_GLOBALS(module_name) \
|
||||
typedef struct _zend_##module_name##_globals {
|
||||
#define ZEND_END_MODULE_GLOBALS(module_name) \
|
||||
} zend_##module_name##_globals;
|
||||
|
||||
#ifdef ZTS
|
||||
|
||||
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
|
||||
ts_rsrc_id module_name##_globals_id;
|
||||
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
|
||||
extern ts_rsrc_id module_name##_globals_id;
|
||||
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
|
||||
ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
|
||||
|
||||
#else
|
||||
|
||||
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
|
||||
zend_##module_name##_globals module_name##_globals;
|
||||
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
|
||||
extern zend_##module_name##_globals module_name##_globals;
|
||||
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
|
||||
globals_ctor(&module_name##_globals);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define INIT_CLASS_ENTRY(class_container, class_name, functions) \
|
||||
{ \
|
||||
class_container.name = strdup(class_name); \
|
||||
class_container.name_length = sizeof(class_name)-1; \
|
||||
class_container.builtin_functions = functions; \
|
||||
class_container.handle_function_call = NULL; \
|
||||
class_container.handle_property_get = NULL; \
|
||||
class_container.handle_property_set = NULL; \
|
||||
}
|
||||
|
||||
#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
|
||||
{ \
|
||||
class_container.name = strdup(class_name); \
|
||||
class_container.name_length = sizeof(class_name)-1; \
|
||||
class_container.builtin_functions = functions; \
|
||||
class_container.handle_function_call = handle_fcall; \
|
||||
class_container.handle_property_get = handle_propget; \
|
||||
class_container.handle_property_set = handle_propset; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
int zend_next_free_module(void);
|
||||
|
||||
ZEND_API int zend_get_parameters(int ht, int param_count, ...);
|
||||
ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument_array TSRMLS_DC);
|
||||
ZEND_API int zend_get_parameters_ex(int param_count, ...);
|
||||
ZEND_API int _zend_get_parameters_array_ex(int param_count, zval ***argument_array TSRMLS_DC);
|
||||
|
||||
#define zend_get_parameters_array(ht, param_count, argument_array) \
|
||||
_zend_get_parameters_array(ht, param_count, argument_array TSRMLS_CC)
|
||||
#define zend_get_parameters_array_ex(param_count, argument_array) \
|
||||
_zend_get_parameters_array_ex(param_count, argument_array TSRMLS_CC)
|
||||
|
||||
|
||||
/* Parameter parsing API -- andrei */
|
||||
|
||||
#define ZEND_PARSE_PARAMS_QUIET 1<<1
|
||||
ZEND_API int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...);
|
||||
ZEND_API int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...);
|
||||
|
||||
/* End of parameter parsing API -- andrei */
|
||||
|
||||
int zend_register_functions(zend_function_entry *functions, HashTable *function_table, int type TSRMLS_DC);
|
||||
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table TSRMLS_DC);
|
||||
ZEND_API int zend_register_module(zend_module_entry *module_entry);
|
||||
|
||||
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC);
|
||||
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
|
||||
|
||||
ZEND_API zend_module_entry *zend_get_module(int module_number);
|
||||
ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC);
|
||||
|
||||
ZEND_API void zend_wrong_param_count(TSRMLS_D);
|
||||
ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name);
|
||||
|
||||
#define getThis() (this_ptr)
|
||||
|
||||
#define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT()
|
||||
#define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
|
||||
#define ARG_COUNT(dummy) (ht)
|
||||
#define ZEND_NUM_ARGS() (ht)
|
||||
#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(TSRMLS_C); return; }
|
||||
#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { zend_wrong_param_count(TSRMLS_C); return ret; }
|
||||
|
||||
#ifndef ZEND_WIN32
|
||||
#define DLEXPORT
|
||||
#endif
|
||||
|
||||
ZEND_API int zend_startup_module(zend_module_entry *module);
|
||||
|
||||
#define array_init(arg) _array_init((arg) ZEND_FILE_LINE_CC)
|
||||
#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
ZEND_API int _array_init(zval *arg ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
|
||||
/* no longer supported */
|
||||
ZEND_API int add_assoc_function(zval *arg, char *key,void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
|
||||
|
||||
ZEND_API int add_assoc_long_ex(zval *arg, char *key, uint key_len, long n);
|
||||
ZEND_API int add_assoc_null_ex(zval *arg, char *key, uint key_len);
|
||||
ZEND_API int add_assoc_bool_ex(zval *arg, char *key, uint key_len, int b);
|
||||
ZEND_API int add_assoc_resource_ex(zval *arg, char *key, uint key_len, int r);
|
||||
ZEND_API int add_assoc_double_ex(zval *arg, char *key, uint key_len, double d);
|
||||
ZEND_API int add_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate);
|
||||
ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate);
|
||||
ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value);
|
||||
|
||||
#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key)+1, __n)
|
||||
#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
|
||||
#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)
|
||||
#define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key)+1, __r)
|
||||
#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key)+1, __d)
|
||||
#define add_assoc_string(__arg, __key, __str, __duplicate) add_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
|
||||
#define add_assoc_stringl(__arg, __key, __str, __length, __duplicate) add_assoc_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
|
||||
#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key)+1, __value)
|
||||
|
||||
/* unset() functions are only suported for legacy modules and null() functions should be used */
|
||||
#define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
|
||||
#define add_index_unset(__arg, __key) add_index_null(__arg, __key)
|
||||
#define add_next_index_unset(__arg) add_next_index_null(__arg)
|
||||
#define add_property_unset(__arg, __key) add_property_null(__arg, __key)
|
||||
|
||||
ZEND_API int add_index_long(zval *arg, uint idx, long n);
|
||||
ZEND_API int add_index_null(zval *arg, uint idx);
|
||||
ZEND_API int add_index_bool(zval *arg, uint idx, int b);
|
||||
ZEND_API int add_index_resource(zval *arg, uint idx, int r);
|
||||
ZEND_API int add_index_double(zval *arg, uint idx, double d);
|
||||
ZEND_API int add_index_string(zval *arg, uint idx, char *str, int duplicate);
|
||||
ZEND_API int add_index_stringl(zval *arg, uint idx, char *str, uint length, int duplicate);
|
||||
ZEND_API int add_index_zval(zval *arg, uint index, zval *value);
|
||||
|
||||
ZEND_API int add_next_index_long(zval *arg, long n);
|
||||
ZEND_API int add_next_index_null(zval *arg);
|
||||
ZEND_API int add_next_index_bool(zval *arg, int b);
|
||||
ZEND_API int add_next_index_resource(zval *arg, int r);
|
||||
ZEND_API int add_next_index_double(zval *arg, double d);
|
||||
ZEND_API int add_next_index_string(zval *arg, char *str, int duplicate);
|
||||
ZEND_API int add_next_index_stringl(zval *arg, char *str, uint length, int duplicate);
|
||||
ZEND_API int add_next_index_zval(zval *arg, zval *value);
|
||||
|
||||
ZEND_API int add_get_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, void **dest, int duplicate);
|
||||
ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, void **dest, int duplicate);
|
||||
|
||||
#define add_get_assoc_string(__arg, __key, __str, __dest, __duplicate) add_get_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __dest, __duplicate)
|
||||
#define add_get_assoc_stringl(__arg, __key, __str, __length, __dest, __duplicate) add_get_assoc_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __dest, __duplicate)
|
||||
|
||||
ZEND_API int add_get_index_long(zval *arg, uint idx, long l, void **dest);
|
||||
ZEND_API int add_get_index_double(zval *arg, uint idx, double d, void **dest);
|
||||
ZEND_API int add_get_index_string(zval *arg, uint idx, char *str, void **dest, int duplicate);
|
||||
ZEND_API int add_get_index_stringl(zval *arg, uint idx, char *str, uint length, void **dest, int duplicate);
|
||||
|
||||
ZEND_API int add_property_long_ex(zval *arg, char *key, uint key_len, long l);
|
||||
ZEND_API int add_property_null_ex(zval *arg, char *key, uint key_len);
|
||||
ZEND_API int add_property_bool_ex(zval *arg, char *key, uint key_len, int b);
|
||||
ZEND_API int add_property_resource_ex(zval *arg, char *key, uint key_len, long r);
|
||||
ZEND_API int add_property_double_ex(zval *arg, char *key, uint key_len, double d);
|
||||
ZEND_API int add_property_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate);
|
||||
ZEND_API int add_property_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate);
|
||||
ZEND_API int add_property_zval_ex(zval *arg, char *key, uint key_len, zval *value);
|
||||
|
||||
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key)+1, __n)
|
||||
#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) + 1)
|
||||
#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key)+1, __b)
|
||||
#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key)+1, __r)
|
||||
#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key)+1, __d)
|
||||
#define add_property_string(__arg, __key, __str, __duplicate) add_property_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
|
||||
#define add_property_stringl(__arg, __key, __str, __length, __duplicate) add_property_stringl_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate)
|
||||
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value)
|
||||
|
||||
ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC);
|
||||
ZEND_API int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table TSRMLS_DC);
|
||||
|
||||
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
|
||||
int is_ref, int num_symbol_tables, ...);
|
||||
|
||||
#define add_method(arg,key,method) add_assoc_function((arg),(key),(method))
|
||||
|
||||
#if ZEND_DEBUG
|
||||
#define CHECK_ZVAL_STRING(z) \
|
||||
if ((z)->value.str.val[ (z)->value.str.len ] != '\0') zend_error(E_WARNING, "String is not zero-terminated (%s)", (z)->value.str.val);
|
||||
#define CHECK_ZVAL_STRING_REL(z) \
|
||||
if ((z)->value.str.val[ (z)->value.str.len ] != '\0') zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", (z)->value.str.val ZEND_FILE_LINE_RELAY_CC);
|
||||
#else
|
||||
#define CHECK_ZVAL_STRING(z)
|
||||
#define CHECK_ZVAL_STRING_REL(z)
|
||||
#endif
|
||||
|
||||
#define ZVAL_RESOURCE(z,l) { \
|
||||
(z)->type = IS_RESOURCE; \
|
||||
(z)->value.lval = l; \
|
||||
}
|
||||
|
||||
#define ZVAL_BOOL(z,b) { \
|
||||
(z)->type = IS_BOOL; \
|
||||
(z)->value.lval = b; \
|
||||
}
|
||||
|
||||
#define ZVAL_NULL(z) { \
|
||||
(z)->type = IS_NULL; \
|
||||
}
|
||||
|
||||
#define ZVAL_LONG(z,l) { \
|
||||
(z)->type = IS_LONG; \
|
||||
(z)->value.lval = l; \
|
||||
}
|
||||
|
||||
#define ZVAL_DOUBLE(z,d) { \
|
||||
(z)->type = IS_DOUBLE; \
|
||||
(z)->value.dval = d; \
|
||||
}
|
||||
|
||||
#define ZVAL_STRING(z,s,duplicate) { \
|
||||
char *__s=(s); \
|
||||
(z)->value.str.len = strlen(__s); \
|
||||
(z)->value.str.val = (duplicate?estrndup(__s,(z)->value.str.len):__s); \
|
||||
(z)->type = IS_STRING; \
|
||||
}
|
||||
|
||||
#define ZVAL_STRINGL(z,s,l,duplicate) { \
|
||||
char *__s=(s); int __l=l; \
|
||||
(z)->value.str.len = __l; \
|
||||
(z)->value.str.val = (duplicate?estrndup(__s,__l):__s); \
|
||||
(z)->type = IS_STRING; \
|
||||
}
|
||||
|
||||
#define ZVAL_EMPTY_STRING(z) { \
|
||||
(z)->value.str.len = 0; \
|
||||
(z)->value.str.val = empty_string; \
|
||||
(z)->type = IS_STRING; \
|
||||
}
|
||||
|
||||
#define ZVAL_FALSE(z) ZVAL_BOOL(z,0)
|
||||
#define ZVAL_TRUE(z) ZVAL_BOOL(z,1)
|
||||
|
||||
#define RETVAL_RESOURCE(l) ZVAL_RESOURCE(return_value,l)
|
||||
#define RETVAL_BOOL(b) ZVAL_BOOL(return_value,b)
|
||||
#define RETVAL_NULL() ZVAL_NULL(return_value)
|
||||
#define RETVAL_LONG(l) ZVAL_LONG(return_value,l)
|
||||
#define RETVAL_DOUBLE(d) ZVAL_DOUBLE(return_value,d)
|
||||
#define RETVAL_STRING(s,duplicate) ZVAL_STRING(return_value,s,duplicate)
|
||||
#define RETVAL_STRINGL(s,l,duplicate) ZVAL_STRINGL(return_value,s,l,duplicate)
|
||||
#define RETVAL_EMPTY_STRING() ZVAL_EMPTY_STRING(return_value)
|
||||
#define RETVAL_FALSE ZVAL_BOOL(return_value,0)
|
||||
#define RETVAL_TRUE ZVAL_BOOL(return_value,1)
|
||||
|
||||
#define RETURN_RESOURCE(l) { RETVAL_RESOURCE(l); return; }
|
||||
#define RETURN_BOOL(b) { RETVAL_BOOL(b); return; }
|
||||
#define RETURN_NULL() { RETVAL_NULL(); return;}
|
||||
#define RETURN_LONG(l) { RETVAL_LONG(l); return; }
|
||||
#define RETURN_DOUBLE(d) { RETVAL_DOUBLE(d); return; }
|
||||
#define RETURN_STRING(s,duplicate) { RETVAL_STRING(s,duplicate); return; }
|
||||
#define RETURN_STRINGL(s,l,duplicate) { RETVAL_STRINGL(s,l,duplicate); return; }
|
||||
#define RETURN_EMPTY_STRING() { RETVAL_EMPTY_STRING(); return; }
|
||||
#define RETURN_FALSE { RETVAL_FALSE; return; }
|
||||
#define RETURN_TRUE { RETVAL_TRUE; return; }
|
||||
|
||||
#define SET_VAR_STRING(n,v) { \
|
||||
{ \
|
||||
zval *var; \
|
||||
ALLOC_ZVAL(var); \
|
||||
ZVAL_STRING(var,v,0); \
|
||||
ZEND_SET_GLOBAL_VAR(n, var); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_VAR_STRINGL(n,v,l) { \
|
||||
{ \
|
||||
zval *var; \
|
||||
ALLOC_ZVAL(var); \
|
||||
ZVAL_STRINGL(var,v,l,0); \
|
||||
ZEND_SET_GLOBAL_VAR(n, var); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_VAR_LONG(n,v) { \
|
||||
{ \
|
||||
zval *var; \
|
||||
ALLOC_ZVAL(var); \
|
||||
ZVAL_LONG(var,v); \
|
||||
ZEND_SET_GLOBAL_VAR(n, var); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SET_VAR_DOUBLE(n,v) { \
|
||||
{ \
|
||||
zval *var; \
|
||||
ALLOC_ZVAL(var); \
|
||||
ZVAL_DOUBLE(var,v); \
|
||||
ZEND_SET_GLOBAL_VAR(n, var); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define ZEND_SET_SYMBOL(symtable, name, var) \
|
||||
{ \
|
||||
char *_name = (name); \
|
||||
\
|
||||
ZEND_SET_SYMBOL_WITH_LENGTH(symtable, _name, strlen(_name)+1, var, 1, 0); \
|
||||
}
|
||||
|
||||
#define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref) \
|
||||
{ \
|
||||
zval **orig_var; \
|
||||
\
|
||||
if (zend_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS \
|
||||
&& PZVAL_IS_REF(*orig_var)) { \
|
||||
(var)->refcount = (*orig_var)->refcount; \
|
||||
(var)->is_ref = 1; \
|
||||
\
|
||||
if (_refcount) { \
|
||||
(var)->refcount += _refcount-1; \
|
||||
} \
|
||||
zval_dtor(*orig_var); \
|
||||
**orig_var = *(var); \
|
||||
FREE_ZVAL(var); \
|
||||
} else { \
|
||||
(var)->is_ref = _is_ref; \
|
||||
if (_refcount) { \
|
||||
(var)->refcount = _refcount; \
|
||||
} \
|
||||
zend_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define ZEND_SET_GLOBAL_VAR(name, var) \
|
||||
ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
|
||||
|
||||
#define ZEND_SET_GLOBAL_VAR_WITH_LENGTH(name, name_length, var, _refcount, _is_ref) \
|
||||
ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), name, name_length, var, _refcount, _is_ref)
|
||||
|
||||
#define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? Z_OBJPROP_P(p) : NULL)))
|
||||
#define ZVAL_IS_NULL(z) ((z)->type==IS_NULL)
|
||||
|
||||
#endif /* ZEND_API_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,769 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_alloc.h"
|
||||
#include "zend_globals.h"
|
||||
#include "zend_fast_cache.h"
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef ZTS
|
||||
ZEND_API zend_alloc_globals alloc_globals;
|
||||
#endif
|
||||
|
||||
|
||||
#define ZEND_DISABLE_MEMORY_CACHE 0
|
||||
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
#define ZEND_DO_MALLOC(size) (AG(memory_heap) ? HeapAlloc(AG(memory_heap), HEAP_NO_SERIALIZE, size) : malloc(size))
|
||||
#define ZEND_DO_FREE(ptr) (AG(memory_heap) ? HeapFree(AG(memory_heap), HEAP_NO_SERIALIZE, ptr) : free(ptr))
|
||||
#define ZEND_DO_REALLOC(ptr, size) (AG(memory_heap) ? HeapReAlloc(AG(memory_heap), HEAP_NO_SERIALIZE, ptr, size) : realloc(ptr, size))
|
||||
#else
|
||||
#define ZEND_DO_MALLOC(size) malloc(size)
|
||||
#define ZEND_DO_FREE(ptr) free(ptr)
|
||||
#define ZEND_DO_REALLOC(ptr, size) realloc(ptr, size)
|
||||
#endif
|
||||
|
||||
#if ZEND_DEBUG
|
||||
# define END_MAGIC_SIZE sizeof(long)
|
||||
static long mem_block_end_magic = MEM_BLOCK_END_MAGIC;
|
||||
#else
|
||||
# define END_MAGIC_SIZE 0
|
||||
#endif
|
||||
|
||||
|
||||
# if MEMORY_LIMIT
|
||||
# if ZEND_DEBUG
|
||||
#define CHECK_MEMORY_LIMIT(s, rs) _CHECK_MEMORY_LIMIT(s, rs, __zend_filename, __zend_lineno)
|
||||
# else
|
||||
#define CHECK_MEMORY_LIMIT(s, rs) _CHECK_MEMORY_LIMIT(s, rs, NULL,0)
|
||||
# endif
|
||||
|
||||
#define _CHECK_MEMORY_LIMIT(s, rs, file, lineno) { AG(allocated_memory) += rs;\
|
||||
if (AG(memory_limit)<AG(allocated_memory)) {\
|
||||
if ((AG(memory_limit)+1048576)<AG(allocated_memory)) { \
|
||||
/* failed to handle this gracefully, exit() */ \
|
||||
exit(1); \
|
||||
} \
|
||||
if (!AG(memory_exhausted)) { \
|
||||
if (!file) { \
|
||||
zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)", AG(memory_limit),s); \
|
||||
} else { \
|
||||
zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)", AG(memory_limit), file, lineno, s); \
|
||||
} \
|
||||
AG(memory_exhausted)=1; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
# endif
|
||||
|
||||
#ifndef CHECK_MEMORY_LIMIT
|
||||
#define CHECK_MEMORY_LIMIT(s, rs)
|
||||
#endif
|
||||
|
||||
|
||||
#define REMOVE_POINTER_FROM_LIST(p) \
|
||||
if (!p->persistent && p==AG(head)) { \
|
||||
AG(head) = p->pNext; \
|
||||
} else if (p->persistent && p==AG(phead)) { \
|
||||
AG(phead) = p->pNext; \
|
||||
} else { \
|
||||
p->pLast->pNext = p->pNext; \
|
||||
} \
|
||||
if (p->pNext) { \
|
||||
p->pNext->pLast = p->pLast; \
|
||||
}
|
||||
|
||||
#define ADD_POINTER_TO_LIST(p) \
|
||||
if (p->persistent) { \
|
||||
p->pNext = AG(phead); \
|
||||
if (AG(phead)) { \
|
||||
AG(phead)->pLast = p; \
|
||||
} \
|
||||
AG(phead) = p; \
|
||||
} else { \
|
||||
p->pNext = AG(head); \
|
||||
if (AG(head)) { \
|
||||
AG(head)->pLast = p; \
|
||||
} \
|
||||
AG(head) = p; \
|
||||
} \
|
||||
p->pLast = (zend_mem_header *) NULL;
|
||||
|
||||
#define DECLARE_CACHE_VARS() \
|
||||
unsigned int real_size; \
|
||||
unsigned int cache_index
|
||||
|
||||
#define REAL_SIZE(size) ((size+7) & ~0x7)
|
||||
|
||||
#define CALCULATE_REAL_SIZE_AND_CACHE_INDEX(size) \
|
||||
real_size = REAL_SIZE(size); \
|
||||
cache_index = real_size >> 3;
|
||||
|
||||
#define SIZE real_size
|
||||
|
||||
#define CACHE_INDEX cache_index
|
||||
|
||||
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
zend_mem_header *p;
|
||||
DECLARE_CACHE_VARS();
|
||||
TSRMLS_FETCH();
|
||||
|
||||
CALCULATE_REAL_SIZE_AND_CACHE_INDEX(size);
|
||||
|
||||
if (!ZEND_DISABLE_MEMORY_CACHE && (CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] > 0)) {
|
||||
p = AG(cache)[CACHE_INDEX][--AG(cache_count)[CACHE_INDEX]];
|
||||
#if ZEND_DEBUG
|
||||
p->filename = __zend_filename;
|
||||
p->lineno = __zend_lineno;
|
||||
p->orig_filename = __zend_orig_filename;
|
||||
p->orig_lineno = __zend_orig_lineno;
|
||||
p->magic = MEM_BLOCK_START_MAGIC;
|
||||
p->reported = 0;
|
||||
/* Setting the thread id should not be necessary, because we fetched this block
|
||||
* from this thread's cache
|
||||
*/
|
||||
AG(cache_stats)[CACHE_INDEX][1]++;
|
||||
memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long));
|
||||
#endif
|
||||
p->persistent = 0;
|
||||
p->cached = 0;
|
||||
p->size = size;
|
||||
return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING);
|
||||
} else {
|
||||
#if ZEND_DEBUG
|
||||
if (CACHE_INDEX<MAX_CACHED_MEMORY) {
|
||||
AG(cache_stats)[CACHE_INDEX][0]++;
|
||||
}
|
||||
#endif
|
||||
p = (zend_mem_header *) ZEND_DO_MALLOC(sizeof(zend_mem_header) + MEM_HEADER_PADDING + SIZE + END_MAGIC_SIZE);
|
||||
}
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
|
||||
if (!p) {
|
||||
fprintf(stderr,"FATAL: emalloc(): Unable to allocate %ld bytes\n", (long) size);
|
||||
#if ZEND_DEBUG && defined(HAVE_KILL) && defined(HAVE_GETPID)
|
||||
kill(getpid(), SIGSEGV);
|
||||
#else
|
||||
exit(1);
|
||||
#endif
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return (void *)p;
|
||||
}
|
||||
p->persistent = p->cached = 0;
|
||||
ADD_POINTER_TO_LIST(p);
|
||||
p->size = size; /* Save real size for correct cache output */
|
||||
#if ZEND_DEBUG
|
||||
p->filename = __zend_filename;
|
||||
p->lineno = __zend_lineno;
|
||||
p->orig_filename = __zend_orig_filename;
|
||||
p->orig_lineno = __zend_orig_lineno;
|
||||
p->magic = MEM_BLOCK_START_MAGIC;
|
||||
p->reported = 0;
|
||||
# ifdef ZTS
|
||||
p->thread_id = tsrm_thread_id();
|
||||
# endif
|
||||
memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long));
|
||||
#endif
|
||||
#if MEMORY_LIMIT
|
||||
CHECK_MEMORY_LIMIT(size, SIZE);
|
||||
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
|
||||
AG(allocated_memory_peak) = AG(allocated_memory);
|
||||
}
|
||||
#endif
|
||||
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
zend_mem_header *p = (zend_mem_header *) ((char *)ptr - sizeof(zend_mem_header) - MEM_HEADER_PADDING);
|
||||
DECLARE_CACHE_VARS();
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if defined(ZTS) && TSRM_DEBUG
|
||||
if (p->thread_id != tsrm_thread_id()) {
|
||||
tsrm_error(TSRM_ERROR_LEVEL_ERROR, "Memory block allocated at %s:(%d) on thread %x freed at %s:(%d) on thread %x, ignoring",
|
||||
p->filename, p->lineno, p->thread_id,
|
||||
__zend_filename, __zend_lineno, tsrm_thread_id());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
CALCULATE_REAL_SIZE_AND_CACHE_INDEX(p->size);
|
||||
#if ZEND_DEBUG
|
||||
if (!_mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC)) {
|
||||
return;
|
||||
}
|
||||
memset(ptr, 0x5a, p->size);
|
||||
#endif
|
||||
|
||||
if (!ZEND_DISABLE_MEMORY_CACHE
|
||||
&& !p->persistent && (CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] < MAX_CACHED_ENTRIES)) {
|
||||
AG(cache)[CACHE_INDEX][AG(cache_count)[CACHE_INDEX]++] = p;
|
||||
p->cached = 1;
|
||||
#if ZEND_DEBUG
|
||||
p->magic = MEM_BLOCK_CACHED_MAGIC;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
REMOVE_POINTER_FROM_LIST(p);
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
AG(allocated_memory) -= SIZE;
|
||||
#endif
|
||||
|
||||
ZEND_DO_FREE(p);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
void *p;
|
||||
int final_size = size*nmemb;
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
p = _emalloc(final_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
if (!p) {
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return (void *) p;
|
||||
}
|
||||
memset(p, 0, final_size);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
zend_mem_header *p;
|
||||
zend_mem_header *orig;
|
||||
DECLARE_CACHE_VARS();
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (!ptr) {
|
||||
return _emalloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
p = orig = (zend_mem_header *) ((char *)ptr-sizeof(zend_mem_header)-MEM_HEADER_PADDING);
|
||||
|
||||
#if defined(ZTS) && TSRM_DEBUG
|
||||
if (p->thread_id != tsrm_thread_id()) {
|
||||
void *new_p;
|
||||
|
||||
tsrm_error(TSRM_ERROR_LEVEL_ERROR, "Memory block allocated at %s:(%d) on thread %x reallocated at %s:(%d) on thread %x, duplicating",
|
||||
p->filename, p->lineno, p->thread_id,
|
||||
__zend_filename, __zend_lineno, tsrm_thread_id());
|
||||
new_p = _emalloc(size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
memcpy(new_p, ptr, p->size);
|
||||
return new_p;
|
||||
}
|
||||
#endif
|
||||
|
||||
CALCULATE_REAL_SIZE_AND_CACHE_INDEX(size);
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
REMOVE_POINTER_FROM_LIST(p);
|
||||
p = (zend_mem_header *) ZEND_DO_REALLOC(p,sizeof(zend_mem_header)+MEM_HEADER_PADDING+SIZE+END_MAGIC_SIZE);
|
||||
if (!p) {
|
||||
if (!allow_failure) {
|
||||
fprintf(stderr,"FATAL: erealloc(): Unable to allocate %ld bytes\n", (long) size);
|
||||
#if ZEND_DEBUG && HAVE_KILL && HAVE_GETPID
|
||||
kill(getpid(), SIGSEGV);
|
||||
#else
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
ADD_POINTER_TO_LIST(orig);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return (void *)NULL;
|
||||
}
|
||||
ADD_POINTER_TO_LIST(p);
|
||||
#if ZEND_DEBUG
|
||||
p->filename = __zend_filename;
|
||||
p->lineno = __zend_lineno;
|
||||
p->magic = MEM_BLOCK_START_MAGIC;
|
||||
memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long));
|
||||
#endif
|
||||
#if MEMORY_LIMIT
|
||||
CHECK_MEMORY_LIMIT(size - p->size, SIZE - REAL_SIZE(p->size));
|
||||
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
|
||||
AG(allocated_memory_peak) = AG(allocated_memory);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->size = size;
|
||||
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return (void *)((char *)p+sizeof(zend_mem_header)+MEM_HEADER_PADDING);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
int length;
|
||||
char *p;
|
||||
|
||||
length = strlen(s)+1;
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
p = (char *) _emalloc(length ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
if (!p) {
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return (char *)NULL;
|
||||
}
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
memcpy(p, s, length);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
char *p;
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
p = (char *) _emalloc(length+1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
if (!p) {
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return (char *)NULL;
|
||||
}
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
memcpy(p, s, length);
|
||||
p[length] = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *zend_strndup(const char *s, uint length)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = (char *) malloc(length+1);
|
||||
if (!p) {
|
||||
return (char *)NULL;
|
||||
}
|
||||
if (length) {
|
||||
memcpy(p, s, length);
|
||||
}
|
||||
p[length] = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_set_memory_limit(unsigned int memory_limit)
|
||||
{
|
||||
#if MEMORY_LIMIT
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AG(memory_limit) = memory_limit;
|
||||
return SUCCESS;
|
||||
#else
|
||||
return FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void start_memory_manager(TSRMLS_D)
|
||||
{
|
||||
#if 0
|
||||
#ifndef ZTS
|
||||
int i, j;
|
||||
void *cached_entries[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
AG(phead) = AG(head) = NULL;
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
AG(memory_limit) = 1<<30; /* rediculous limit, effectively no limit */
|
||||
AG(allocated_memory) = 0;
|
||||
AG(memory_exhausted) = 0;
|
||||
AG(allocated_memory_peak) = 0;
|
||||
#endif
|
||||
|
||||
memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head)));
|
||||
memset(AG(cache_count), 0, sizeof(AG(cache_count)));
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
AG(memory_heap) = HeapCreate(HEAP_NO_SERIALIZE, 256*1024, 0);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifndef ZTS
|
||||
/* Initialize cache, to prevent fragmentation */
|
||||
/* We can't do this in ZTS mode, because calling emalloc() from within start_memory_manager()
|
||||
* will yield an endless recursion calling to alloc_globals_ctor()
|
||||
*/
|
||||
for (i=1; i<MAX_CACHED_MEMORY; i++) {
|
||||
for (j=0; j<PRE_INIT_CACHE_ENTRIES; j++) {
|
||||
cached_entries[i][j] = emalloc(8*i);
|
||||
}
|
||||
}
|
||||
for (i=1; i<MAX_CACHED_MEMORY; i++) {
|
||||
for (j=0; j<PRE_INIT_CACHE_ENTRIES; j++) {
|
||||
efree(cached_entries[i][j]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ZEND_DEBUG
|
||||
memset(AG(cache_stats), 0, sizeof(AG(cache_stats)));
|
||||
memset(AG(fast_cache_stats), 0, sizeof(AG(fast_cache_stats)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
|
||||
{
|
||||
zend_mem_header *p, *t;
|
||||
unsigned int fci, i, j;
|
||||
#if ZEND_DEBUG
|
||||
int had_leaks = 0;
|
||||
#endif
|
||||
zend_fast_cache_list_entry *fast_cache_list_entry, *next_fast_cache_list_entry;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if defined(ZEND_WIN32) && !ZEND_DEBUG
|
||||
if (clean_cache && AG(memory_heap)) {
|
||||
HeapDestroy(AG(memory_heap));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (fci=0; fci<MAX_FAST_CACHE_TYPES; fci++) {
|
||||
fast_cache_list_entry = AG(fast_cache_list_head)[fci];
|
||||
while (fast_cache_list_entry) {
|
||||
next_fast_cache_list_entry = fast_cache_list_entry->next;
|
||||
efree(fast_cache_list_entry);
|
||||
fast_cache_list_entry = next_fast_cache_list_entry;
|
||||
}
|
||||
AG(fast_cache_list_head)[fci] = NULL;
|
||||
}
|
||||
|
||||
if (1 || clean_cache) {
|
||||
zend_mem_header *ptr;
|
||||
|
||||
for (i=1; i<MAX_CACHED_MEMORY; i++) {
|
||||
for (j=0; j<AG(cache_count)[i]; j++) {
|
||||
ptr = (zend_mem_header *) AG(cache)[i][j];
|
||||
#if MEMORY_LIMIT
|
||||
AG(allocated_memory) -= REAL_SIZE(ptr->size);
|
||||
#endif
|
||||
REMOVE_POINTER_FROM_LIST(ptr);
|
||||
ZEND_DO_FREE(ptr);
|
||||
}
|
||||
AG(cache_count)[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
p = AG(head);
|
||||
t = AG(head);
|
||||
while (t) {
|
||||
if (!t->cached) {
|
||||
#if ZEND_DEBUG
|
||||
if (!t->cached && !t->reported) {
|
||||
zend_mem_header *iterator;
|
||||
int total_leak=0, total_leak_count=0;
|
||||
|
||||
had_leaks = 1;
|
||||
if (!silent) {
|
||||
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, t);
|
||||
}
|
||||
t->reported = 1;
|
||||
for (iterator=t->pNext; iterator; iterator=iterator->pNext) {
|
||||
if (!iterator->cached
|
||||
&& iterator->filename==t->filename
|
||||
&& iterator->lineno==t->lineno) {
|
||||
total_leak += iterator->size;
|
||||
total_leak_count++;
|
||||
iterator->reported = 1;
|
||||
}
|
||||
}
|
||||
if (!silent && total_leak_count>0) {
|
||||
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (long) (total_leak_count));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if MEMORY_LIMIT
|
||||
AG(allocated_memory) -= t->size;
|
||||
#endif
|
||||
p = t->pNext;
|
||||
REMOVE_POINTER_FROM_LIST(t);
|
||||
ZEND_DO_FREE(t);
|
||||
t = p;
|
||||
} else {
|
||||
t = t->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
#if MEMORY_LIMIT
|
||||
AG(memory_exhausted)=0;
|
||||
AG(allocated_memory_peak) = 0;
|
||||
#endif
|
||||
|
||||
|
||||
#if (ZEND_DEBUG)
|
||||
do {
|
||||
zval display_memory_cache_stats;
|
||||
int i, j;
|
||||
|
||||
if (clean_cache) {
|
||||
/* we're shutting down completely, don't even touch the INI subsystem */
|
||||
break;
|
||||
}
|
||||
if (zend_get_configuration_directive("display_memory_cache_stats", sizeof("display_memory_cache_stats"), &display_memory_cache_stats)==FAILURE) {
|
||||
break;
|
||||
}
|
||||
if (!atoi(display_memory_cache_stats.value.str.val)) {
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "Memory cache statistics\n"
|
||||
"-----------------------\n\n"
|
||||
"[zval, %2ld]\t\t%d / %d (%.2f%%)\n"
|
||||
"[hash, %2ld]\t\t%d / %d (%.2f%%)\n",
|
||||
(long) sizeof(zval),
|
||||
AG(fast_cache_stats)[ZVAL_CACHE_LIST][1], AG(fast_cache_stats)[ZVAL_CACHE_LIST][0]+AG(fast_cache_stats)[ZVAL_CACHE_LIST][1],
|
||||
((double) AG(fast_cache_stats)[ZVAL_CACHE_LIST][1] / (AG(fast_cache_stats)[ZVAL_CACHE_LIST][0]+AG(fast_cache_stats)[ZVAL_CACHE_LIST][1]))*100,
|
||||
(long) sizeof(HashTable),
|
||||
AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1], AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][0]+AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1],
|
||||
((double) AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1] / (AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][0]+AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1]))*100);
|
||||
|
||||
|
||||
for (i=0; i<MAX_CACHED_MEMORY; i+=2) {
|
||||
fprintf(stderr, "[%2d, %2d]\t\t", i, i+1);
|
||||
for (j=0; j<2; j++) {
|
||||
fprintf(stderr, "%d / %d (%.2f%%)\t\t",
|
||||
AG(cache_stats)[i+j][1], AG(cache_stats)[i+j][0]+AG(cache_stats)[i+j][1],
|
||||
((double) AG(cache_stats)[i+j][1] / (AG(cache_stats)[i+j][0]+AG(cache_stats)[i+j][1]))*100);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
} while (0);
|
||||
|
||||
#if defined(ZEND_WIN32) && ZEND_DEBUG
|
||||
if (clean_cache && AG(memory_heap)) {
|
||||
HeapDestroy(AG(memory_heap));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
void zend_debug_alloc_output(char *format, ...)
|
||||
{
|
||||
char output_buf[256];
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsprintf(output_buf, format, args);
|
||||
va_end(args);
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
OutputDebugString(output_buf);
|
||||
#else
|
||||
fprintf(stderr, "%s", output_buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int _mem_block_check(void *ptr, int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
zend_mem_header *p = (zend_mem_header *) ((char *)ptr - sizeof(zend_mem_header) - MEM_HEADER_PADDING);
|
||||
int no_cache_notice=0;
|
||||
int valid_beginning=1;
|
||||
int had_problems=0;
|
||||
long end_magic;
|
||||
|
||||
if (silent==2) {
|
||||
silent = 1;
|
||||
no_cache_notice = 1;
|
||||
}
|
||||
if (silent==3) {
|
||||
silent = 0;
|
||||
no_cache_notice = 1;
|
||||
}
|
||||
if (!silent) {
|
||||
zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL);
|
||||
zend_debug_alloc_output("---------------------------------------\n");
|
||||
zend_debug_alloc_output("%s(%d) : Block 0x%0.8lX status:\n" ZEND_FILE_LINE_RELAY_CC, (long) p);
|
||||
if (__zend_orig_filename) {
|
||||
zend_debug_alloc_output("%s(%d) : Actual location (location was relayed)\n" ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
zend_debug_alloc_output("%10s\t","Beginning: ");
|
||||
}
|
||||
|
||||
switch (p->magic) {
|
||||
case MEM_BLOCK_START_MAGIC:
|
||||
if (!silent) {
|
||||
zend_debug_alloc_output("OK (allocated on %s:%d, %d bytes)\n", p->filename, p->lineno, p->size);
|
||||
}
|
||||
break; /* ok */
|
||||
case MEM_BLOCK_FREED_MAGIC:
|
||||
if (!silent) {
|
||||
zend_debug_alloc_output("Freed\n");
|
||||
had_problems = 1;
|
||||
} else {
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
break;
|
||||
case MEM_BLOCK_CACHED_MAGIC:
|
||||
if (!silent) {
|
||||
if (!no_cache_notice) {
|
||||
zend_debug_alloc_output("Cached (allocated on %s:%d, %d bytes)\n", p->filename, p->lineno, p->size);
|
||||
had_problems = 1;
|
||||
}
|
||||
} else {
|
||||
if (!no_cache_notice) {
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!silent) {
|
||||
zend_debug_alloc_output("Overrun (magic=0x%0.8lX, expected=0x%0.8lX)\n", p->magic, MEM_BLOCK_START_MAGIC);
|
||||
} else {
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
had_problems = 1;
|
||||
valid_beginning = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
memcpy(&end_magic, (((char *) p)+sizeof(zend_mem_header)+MEM_HEADER_PADDING+p->size), sizeof(long));
|
||||
|
||||
if (valid_beginning && (end_magic != MEM_BLOCK_END_MAGIC)) {
|
||||
char *overflow_ptr, *magic_ptr=(char *) &mem_block_end_magic;
|
||||
int overflows=0;
|
||||
int i;
|
||||
|
||||
if (silent) {
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
had_problems = 1;
|
||||
overflow_ptr = (char *) &end_magic;
|
||||
|
||||
for (i=0; i<sizeof(long); i++) {
|
||||
if (overflow_ptr[i]!=magic_ptr[i]) {
|
||||
overflows++;
|
||||
}
|
||||
}
|
||||
|
||||
zend_debug_alloc_output("%10s\t", "End:");
|
||||
zend_debug_alloc_output("Overflown (magic=0x%0.8lX instead of 0x%0.8lX)\n", end_magic, MEM_BLOCK_END_MAGIC);
|
||||
zend_debug_alloc_output("%10s\t","");
|
||||
if (overflows>=sizeof(long)) {
|
||||
zend_debug_alloc_output("At least %d bytes overflown\n", sizeof(long));
|
||||
} else {
|
||||
zend_debug_alloc_output("%d byte(s) overflown\n", overflows);
|
||||
}
|
||||
} else if (!silent) {
|
||||
zend_debug_alloc_output("%10s\t", "End:");
|
||||
if (valid_beginning) {
|
||||
zend_debug_alloc_output("OK\n");
|
||||
} else {
|
||||
zend_debug_alloc_output("Unknown\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (had_problems) {
|
||||
int foo = 5;
|
||||
|
||||
foo += 1;
|
||||
}
|
||||
|
||||
if (!silent) {
|
||||
zend_debug_alloc_output("---------------------------------------\n");
|
||||
}
|
||||
return ((!had_problems) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
zend_mem_header *p;
|
||||
int errors=0;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
p = AG(head);
|
||||
|
||||
|
||||
zend_debug_alloc_output("------------------------------------------------\n");
|
||||
zend_debug_alloc_output("Full Memory Check at %s:%d\n" ZEND_FILE_LINE_RELAY_CC);
|
||||
|
||||
while (p) {
|
||||
if (!_mem_block_check((void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING), (silent?2:3) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC)) {
|
||||
errors++;
|
||||
}
|
||||
p = p->pNext;
|
||||
}
|
||||
zend_debug_alloc_output("End of full memory check %s:%d (%d errors)\n" ZEND_FILE_LINE_RELAY_CC, errors);
|
||||
zend_debug_alloc_output("------------------------------------------------\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
zend_mem_header *p = (zend_mem_header *) ((char *)ptr-sizeof(zend_mem_header)-MEM_HEADER_PADDING);
|
||||
TSRMLS_FETCH();
|
||||
|
||||
#if ZEND_DEBUG
|
||||
_mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
#endif
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
|
||||
/* remove the block from the non persistent list */
|
||||
REMOVE_POINTER_FROM_LIST(p);
|
||||
|
||||
p->persistent = 1;
|
||||
|
||||
/* add the block to the persistent list */
|
||||
ADD_POINTER_TO_LIST(p);
|
||||
HANDLE_UNBLOCK_INTERRUPTIONS();
|
||||
return REAL_SIZE(p->size)+sizeof(zend_mem_header)+MEM_HEADER_PADDING;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_ALLOC_H
|
||||
#define ZEND_ALLOC_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../TSRM/TSRM.h"
|
||||
#include "zend_globals_macros.h"
|
||||
|
||||
#define MEM_BLOCK_START_MAGIC 0x7312F8DCL
|
||||
#define MEM_BLOCK_END_MAGIC 0x2A8FCC84L
|
||||
#define MEM_BLOCK_FREED_MAGIC 0x99954317L
|
||||
#define MEM_BLOCK_CACHED_MAGIC 0xFB8277DCL
|
||||
|
||||
typedef struct _zend_mem_header {
|
||||
#if ZEND_DEBUG
|
||||
long magic;
|
||||
char *filename;
|
||||
uint lineno;
|
||||
int reported;
|
||||
char *orig_filename;
|
||||
uint orig_lineno;
|
||||
# ifdef ZTS
|
||||
THREAD_T thread_id;
|
||||
# endif
|
||||
#endif
|
||||
struct _zend_mem_header *pNext;
|
||||
struct _zend_mem_header *pLast;
|
||||
unsigned int size:30;
|
||||
unsigned int persistent:1;
|
||||
unsigned int cached:1;
|
||||
} zend_mem_header;
|
||||
|
||||
typedef union _align_test {
|
||||
void *ptr;
|
||||
double dbl;
|
||||
long lng;
|
||||
} align_test;
|
||||
|
||||
#define MAX_CACHED_MEMORY 11
|
||||
#define MAX_CACHED_ENTRIES 256
|
||||
#define PRE_INIT_CACHE_ENTRIES 32
|
||||
|
||||
#if (defined (__GNUC__) && __GNUC__ >= 2)
|
||||
#define PLATFORM_ALIGNMENT (__alignof__ (align_test))
|
||||
#else
|
||||
#define PLATFORM_ALIGNMENT (sizeof(align_test))
|
||||
#endif
|
||||
|
||||
#define MEM_HEADER_PADDING (((PLATFORM_ALIGNMENT-sizeof(zend_mem_header))%PLATFORM_ALIGNMENT+PLATFORM_ALIGNMENT)%PLATFORM_ALIGNMENT)
|
||||
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
|
||||
ZEND_API char *zend_strndup(const char *s, unsigned int length);
|
||||
|
||||
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
|
||||
/* Standard wrapper macros */
|
||||
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define efree(ptr) _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define ecalloc(nmemb,size) _ecalloc((nmemb), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define erealloc(ptr,size) _erealloc((ptr), (size),0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define erealloc_recoverable(ptr,size) _erealloc((ptr), (size),1 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define estrdup(s) _estrdup((s) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define estrndup(s,length) _estrndup((s), (length) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define persist_alloc(p) _persist_alloc((p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
|
||||
/* Relay wrapper macros */
|
||||
#define emalloc_rel(size) _emalloc((size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
#define efree_rel(ptr) _efree((ptr) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
#define ecalloc_rel(nmemb, size) _ecalloc((nmemb), (size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
#define erealloc_rel(ptr, size) _erealloc((ptr), (size), 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
#define erealloc_recoverable_rel(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
#define estrdup_rel(s) _estrdup((s) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
#define estrndup_rel(s, length) _estrndup((s), (length) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
#define persist_alloc_rel(p) _persist_alloc((p) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||
|
||||
/* Selective persistent/non persistent allocation macros */
|
||||
#define pemalloc(size,persistent) ((persistent)?malloc(size):emalloc(size))
|
||||
#define pefree(ptr,persistent) ((persistent)?free(ptr):efree(ptr))
|
||||
#define pecalloc(nmemb,size,persistent) ((persistent)?calloc((nmemb),(size)):ecalloc((nmemb),(size)))
|
||||
#define perealloc(ptr,size,persistent) ((persistent)?realloc((ptr),(size)):erealloc((ptr),(size)))
|
||||
#define perealloc_recoverable(ptr,size,persistent) ((persistent)?realloc((ptr),(size)):erealloc_recoverable((ptr),(size)))
|
||||
#define pestrdup(s,persistent) ((persistent)?strdup(s):estrdup(s))
|
||||
|
||||
#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):(empty_string))
|
||||
#define safe_estrndup(ptr,len) ((ptr)?(estrndup((ptr),(len))):(empty_string))
|
||||
|
||||
ZEND_API int zend_set_memory_limit(unsigned int memory_limit);
|
||||
|
||||
ZEND_API void start_memory_manager(TSRMLS_D);
|
||||
ZEND_API void shutdown_memory_manager(int silent, int clean_cache);
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API int _mem_block_check(void *ptr, int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
void zend_debug_alloc_output(char *format, ...);
|
||||
#define mem_block_check(ptr, silent) _mem_block_check(ptr, silent ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define full_mem_check(silent) _full_mem_check(silent ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#else
|
||||
#define mem_block_check(type, ptr, silent)
|
||||
#define full_mem_check(silent)
|
||||
#endif
|
||||
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_BUILTIN_FUNCTIONS_H
|
||||
#define ZEND_BUILTIN_FUNCTIONS_H
|
||||
|
||||
int zend_startup_builtin_functions(TSRMLS_D);
|
||||
|
||||
#endif /* ZEND_BUILTIN_FUNCTIONS_H */
|
||||
+2399
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,621 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_COMPILE_H
|
||||
#define ZEND_COMPILE_H
|
||||
|
||||
#include "zend.h"
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
# include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <iostream.h>
|
||||
#endif
|
||||
|
||||
#include "zend_llist.h"
|
||||
|
||||
#define DEBUG_ZEND 0
|
||||
|
||||
#define FREE_PNODE(znode) zval_dtor(&znode->u.constant);
|
||||
#define FREE_OP(op, should_free) if (should_free) zval_dtor(&Ts[(op)->u.var].tmp_var);
|
||||
|
||||
#define SET_UNUSED(op) (op).op_type = IS_UNUSED
|
||||
|
||||
#define INC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count++); }
|
||||
#define DEC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count--); }
|
||||
#define HANDLE_INTERACTIVE() if (CG(interactive)) { execute_new_code(TSRMLS_C); }
|
||||
|
||||
typedef struct _zend_op_array zend_op_array;
|
||||
|
||||
typedef struct _znode {
|
||||
int op_type;
|
||||
union {
|
||||
zval constant;
|
||||
|
||||
zend_uint var;
|
||||
zend_uint opline_num; /* Needs to be signed */
|
||||
zend_uint fetch_type;
|
||||
zend_op_array *op_array;
|
||||
struct {
|
||||
zend_uint var; /* dummy */
|
||||
zend_uint type;
|
||||
} EA;
|
||||
} u;
|
||||
} znode;
|
||||
|
||||
|
||||
typedef struct _zend_op {
|
||||
zend_uchar opcode;
|
||||
znode result;
|
||||
znode op1;
|
||||
znode op2;
|
||||
ulong extended_value;
|
||||
uint lineno;
|
||||
} zend_op;
|
||||
|
||||
|
||||
typedef struct _zend_brk_cont_element {
|
||||
int cont;
|
||||
int brk;
|
||||
int parent;
|
||||
} zend_brk_cont_element;
|
||||
|
||||
|
||||
struct _zend_op_array {
|
||||
zend_uchar type; /* MUST be the first element of this struct! */
|
||||
|
||||
zend_uchar *arg_types; /* MUST be the second element of this struct! */
|
||||
char *function_name; /* MUST be the third element of this struct! */
|
||||
|
||||
zend_uint *refcount;
|
||||
|
||||
zend_op *opcodes;
|
||||
zend_uint last, size;
|
||||
|
||||
zend_uint T;
|
||||
|
||||
zend_brk_cont_element *brk_cont_array;
|
||||
zend_uint last_brk_cont;
|
||||
zend_uint current_brk_cont;
|
||||
zend_bool uses_globals;
|
||||
|
||||
/* static variables support */
|
||||
HashTable *static_variables;
|
||||
|
||||
zend_op *start_op;
|
||||
int backpatch_count;
|
||||
|
||||
zend_bool return_reference;
|
||||
zend_bool done_pass_two;
|
||||
|
||||
char *filename;
|
||||
|
||||
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
|
||||
};
|
||||
|
||||
|
||||
typedef struct _zend_internal_function {
|
||||
zend_uchar type; /* MUST be the first element of this struct! */
|
||||
|
||||
zend_uchar *arg_types; /* MUST be the second element of this struct */
|
||||
char *function_name; /* MUST be the third element of this struct */
|
||||
|
||||
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
|
||||
} zend_internal_function;
|
||||
|
||||
|
||||
typedef struct _zend_overloaded_function {
|
||||
zend_uchar type; /* MUST be the first element of this struct! */
|
||||
|
||||
zend_uchar *arg_types; /* MUST be the second element of this struct */
|
||||
char *function_name; /* MUST be the third element of this struct */
|
||||
|
||||
zend_uint var;
|
||||
} zend_overloaded_function;
|
||||
|
||||
|
||||
typedef union _zend_function {
|
||||
zend_uchar type; /* MUST be the first element of this struct! */
|
||||
struct {
|
||||
zend_uchar type; /* never used */
|
||||
zend_uchar *arg_types;
|
||||
char *function_name;
|
||||
} common;
|
||||
|
||||
zend_op_array op_array;
|
||||
zend_internal_function internal_function;
|
||||
zend_overloaded_function overloaded_function;
|
||||
} zend_function;
|
||||
|
||||
|
||||
typedef struct _zend_function_state {
|
||||
HashTable *function_symbol_table;
|
||||
zend_function *function;
|
||||
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
|
||||
} zend_function_state;
|
||||
|
||||
|
||||
typedef struct _zend_switch_entry {
|
||||
znode cond;
|
||||
int default_case;
|
||||
int control_var;
|
||||
} zend_switch_entry;
|
||||
|
||||
|
||||
typedef struct _list_llist_element {
|
||||
znode var;
|
||||
zend_llist dimensions;
|
||||
znode value;
|
||||
} list_llist_element;
|
||||
|
||||
|
||||
typedef struct _zend_file_handle {
|
||||
zend_uchar type;
|
||||
char *filename;
|
||||
char *opened_path;
|
||||
union {
|
||||
int fd;
|
||||
FILE *fp;
|
||||
#ifdef __cplusplus
|
||||
istream *is;
|
||||
#endif
|
||||
} handle;
|
||||
zend_bool free_filename;
|
||||
} zend_file_handle;
|
||||
|
||||
|
||||
|
||||
#define IS_CONST (1<<0)
|
||||
#define IS_TMP_VAR (1<<1)
|
||||
#define IS_VAR (1<<2)
|
||||
#define IS_UNUSED (1<<3) /* Unused variable */
|
||||
|
||||
|
||||
#define EXT_TYPE_UNUSED (1<<0)
|
||||
|
||||
#include "zend_globals.h"
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
|
||||
void init_compiler(TSRMLS_D);
|
||||
void shutdown_compiler(TSRMLS_D);
|
||||
void zend_init_compiler_data_structures(TSRMLS_D);
|
||||
|
||||
extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
|
||||
|
||||
void zend_activate(TSRMLS_D);
|
||||
void zend_deactivate(TSRMLS_D);
|
||||
void zend_activate_modules(TSRMLS_D);
|
||||
void zend_deactivate_modules(TSRMLS_D);
|
||||
|
||||
|
||||
int lex_scan(zval *zendlval TSRMLS_DC);
|
||||
void startup_scanner(TSRMLS_D);
|
||||
void shutdown_scanner(TSRMLS_D);
|
||||
|
||||
ZEND_API char *zend_set_compiled_filename(char *new_compiled_filename TSRMLS_DC);
|
||||
ZEND_API void zend_restore_compiled_filename(char *original_compiled_filename TSRMLS_DC);
|
||||
ZEND_API char *zend_get_compiled_filename(TSRMLS_D);
|
||||
ZEND_API int zend_get_compiled_lineno(TSRMLS_D);
|
||||
|
||||
#ifdef ZTS
|
||||
const char *zend_get_zendtext(TSRMLS_D);
|
||||
int zend_get_zendleng(TSRMLS_D);
|
||||
#endif
|
||||
|
||||
|
||||
/* parser-driven code generators */
|
||||
void zend_do_binary_op(int op, znode *result, znode *op1, znode *op2 TSRMLS_DC);
|
||||
void zend_do_unary_op(int op, znode *result, znode *op1 TSRMLS_DC);
|
||||
void zend_do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 TSRMLS_DC);
|
||||
void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC);
|
||||
void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar TSRMLS_DC);
|
||||
void fetch_simple_variable(znode *result, znode *varname, int bp TSRMLS_DC);
|
||||
void fetch_simple_variable_ex(znode *result, znode *varname, int bp, int op TSRMLS_DC);
|
||||
void zend_do_indirect_references(znode *result, znode *num_references, znode *variable TSRMLS_DC);
|
||||
void zend_do_fetch_global_or_static_variable(znode *varname, znode *static_assignment, int fetch_type TSRMLS_DC);
|
||||
void zend_do_fetch_globals(znode *varname TSRMLS_DC);
|
||||
|
||||
void fetch_array_begin(znode *result, znode *varname, znode *first_dim TSRMLS_DC);
|
||||
void fetch_array_dim(znode *result, znode *parent, znode *dim TSRMLS_DC);
|
||||
void fetch_string_offset(znode *result, znode *parent, znode *offset TSRMLS_DC);
|
||||
void zend_do_print(znode *result, znode *arg TSRMLS_DC);
|
||||
void zend_do_echo(znode *arg TSRMLS_DC);
|
||||
typedef int (*unary_op_type)(zval *, zval *);
|
||||
ZEND_API unary_op_type get_unary_op(int opcode);
|
||||
ZEND_API void *get_binary_op(int opcode);
|
||||
|
||||
void zend_do_while_cond(znode *expr, znode *close_bracket_token TSRMLS_DC);
|
||||
void zend_do_while_end(znode *while_token, znode *close_bracket_token TSRMLS_DC);
|
||||
void zend_do_do_while_begin(TSRMLS_D);
|
||||
void zend_do_do_while_end(znode *do_token, znode *expr_open_bracket, znode *expr TSRMLS_DC);
|
||||
|
||||
|
||||
void zend_do_if_cond(znode *cond, znode *closing_bracket_token TSRMLS_DC);
|
||||
void zend_do_if_after_statement(znode *closing_bracket_token, unsigned char initialize TSRMLS_DC);
|
||||
void zend_do_if_end(TSRMLS_D);
|
||||
|
||||
void zend_do_for_cond(znode *expr, znode *second_semicolon_token TSRMLS_DC);
|
||||
void zend_do_for_before_statement(znode *cond_start, znode *second_semicolon_token TSRMLS_DC);
|
||||
void zend_do_for_end(znode *second_semicolon_token TSRMLS_DC);
|
||||
|
||||
void zend_do_pre_incdec(znode *result, znode *op1, int op TSRMLS_DC);
|
||||
void zend_do_post_incdec(znode *result, znode *op1, int op TSRMLS_DC);
|
||||
|
||||
void zend_do_begin_variable_parse(TSRMLS_D);
|
||||
void zend_do_end_variable_parse(int type, int arg_offset TSRMLS_DC);
|
||||
|
||||
void zend_do_free(znode *op1 TSRMLS_DC);
|
||||
|
||||
void zend_do_init_string(znode *result TSRMLS_DC);
|
||||
void zend_do_add_char(znode *result, znode *op1, znode *op2 TSRMLS_DC);
|
||||
void zend_do_add_string(znode *result, znode *op1, znode *op2 TSRMLS_DC);
|
||||
void zend_do_add_variable(znode *result, znode *op1, znode *op2 TSRMLS_DC);
|
||||
|
||||
void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference TSRMLS_DC);
|
||||
void zend_do_end_function_declaration(znode *function_token TSRMLS_DC);
|
||||
void zend_do_receive_arg(int op, znode *var, znode *offset, znode *initialization, unsigned char pass_type TSRMLS_DC);
|
||||
int zend_do_begin_function_call(znode *function_name TSRMLS_DC);
|
||||
void zend_do_begin_dynamic_function_call(znode *function_name TSRMLS_DC);
|
||||
void zend_do_begin_class_member_function_call(znode *class_name, znode *function_name TSRMLS_DC);
|
||||
void zend_do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC);
|
||||
void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC);
|
||||
ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int compile_time);
|
||||
void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
|
||||
void zend_do_early_binding(TSRMLS_D);
|
||||
|
||||
void zend_do_pass_param(znode *param, int op, int offset TSRMLS_DC);
|
||||
|
||||
|
||||
void zend_do_boolean_or_begin(znode *expr1, znode *op_token TSRMLS_DC);
|
||||
void zend_do_boolean_or_end(znode *result, znode *expr1, znode *expr2, znode *op_token TSRMLS_DC);
|
||||
void zend_do_boolean_and_begin(znode *expr1, znode *op_token TSRMLS_DC);
|
||||
void zend_do_boolean_and_end(znode *result, znode *expr1, znode *expr2, znode *op_token TSRMLS_DC);
|
||||
|
||||
void zend_do_brk_cont(int op, znode *expr TSRMLS_DC);
|
||||
|
||||
void zend_do_switch_cond(znode *cond TSRMLS_DC);
|
||||
void zend_do_switch_end(znode *case_list TSRMLS_DC);
|
||||
void zend_do_case_before_statement(znode *case_list, znode *case_token, znode *case_expr TSRMLS_DC);
|
||||
void zend_do_case_after_statement(znode *result, znode *case_token TSRMLS_DC);
|
||||
void zend_do_default_before_statement(znode *case_list, znode *default_token TSRMLS_DC);
|
||||
|
||||
void zend_do_begin_class_declaration(znode *class_name, znode *parent_class_name TSRMLS_DC);
|
||||
void zend_do_end_class_declaration(TSRMLS_D);
|
||||
void zend_do_declare_property(znode *var_name, znode *value TSRMLS_DC);
|
||||
|
||||
void zend_do_fetch_property(znode *result, znode *object, znode *property TSRMLS_DC);
|
||||
|
||||
|
||||
void zend_do_push_object(znode *object TSRMLS_DC);
|
||||
void zend_do_pop_object(znode *object TSRMLS_DC);
|
||||
|
||||
|
||||
void zend_do_begin_new_object(znode *new_token, znode *class_name TSRMLS_DC);
|
||||
void zend_do_end_new_object(znode *result, znode *class_name, znode *new_token, znode *argument_list TSRMLS_DC);
|
||||
|
||||
void zend_do_fetch_constant(znode *result, znode *constant_name, int mode TSRMLS_DC);
|
||||
|
||||
void zend_do_shell_exec(znode *result, znode *cmd TSRMLS_DC);
|
||||
|
||||
void zend_do_init_array(znode *result, znode *expr, znode *offset, int is_ref TSRMLS_DC);
|
||||
void zend_do_add_array_element(znode *result, znode *expr, znode *offset, int is_ref TSRMLS_DC);
|
||||
void zend_do_add_static_array_element(znode *result, znode *offset, znode *expr);
|
||||
void zend_do_list_init(TSRMLS_D);
|
||||
void zend_do_list_end(znode *result, znode *expr TSRMLS_DC);
|
||||
void zend_do_add_list_element(znode *element TSRMLS_DC);
|
||||
void zend_do_new_list_begin(TSRMLS_D);
|
||||
void zend_do_new_list_end(TSRMLS_D);
|
||||
|
||||
void zend_do_cast(znode *result, znode *expr, int type TSRMLS_DC);
|
||||
void zend_do_include_or_eval(int type, znode *result, znode *op1 TSRMLS_DC);
|
||||
|
||||
void zend_do_unset(znode *variable TSRMLS_DC);
|
||||
void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC);
|
||||
|
||||
void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable TSRMLS_DC);
|
||||
void zend_do_foreach_cont(znode *value, znode *key, znode *as_token TSRMLS_DC);
|
||||
void zend_do_foreach_end(znode *foreach_token, znode *open_brackets_token TSRMLS_DC);
|
||||
|
||||
void zend_do_declare_begin(TSRMLS_D);
|
||||
void zend_do_declare_stmt(znode *var, znode *val TSRMLS_DC);
|
||||
void zend_do_declare_end(TSRMLS_D);
|
||||
|
||||
void zend_do_end_heredoc(TSRMLS_D);
|
||||
|
||||
void zend_do_exit(znode *result, znode *message TSRMLS_DC);
|
||||
|
||||
void zend_do_begin_silence(znode *strudel_token TSRMLS_DC);
|
||||
void zend_do_end_silence(znode *strudel_token TSRMLS_DC);
|
||||
|
||||
void zend_do_begin_qm_op(znode *cond, znode *qm_token TSRMLS_DC);
|
||||
void zend_do_qm_true(znode *true_value, znode *qm_token, znode *colon_token TSRMLS_DC);
|
||||
void zend_do_qm_false(znode *result, znode *false_value, znode *qm_token, znode *colon_token TSRMLS_DC);
|
||||
|
||||
void zend_do_extended_info(TSRMLS_D);
|
||||
void zend_do_extended_fcall_begin(TSRMLS_D);
|
||||
void zend_do_extended_fcall_end(TSRMLS_D);
|
||||
|
||||
void zend_do_ticks(TSRMLS_D);
|
||||
|
||||
ZEND_API void function_add_ref(zend_function *function);
|
||||
|
||||
#define INITIAL_OP_ARRAY_SIZE 64
|
||||
|
||||
|
||||
/* helper functions in zend_language_scanner.l */
|
||||
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC);
|
||||
ZEND_API zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC);
|
||||
ZEND_API zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC);
|
||||
ZEND_API int zend_execute_scripts(int type TSRMLS_DC, int file_count, ...);
|
||||
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC);
|
||||
ZEND_API void init_op_array(zend_op_array *op_array, int type, int initial_ops_size TSRMLS_DC);
|
||||
ZEND_API void destroy_op_array(zend_op_array *op_array);
|
||||
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC);
|
||||
ZEND_API void zend_file_handle_dtor(zend_file_handle *fh);
|
||||
|
||||
ZEND_API void destroy_zend_function(zend_function *function);
|
||||
ZEND_API void destroy_zend_class(zend_class_entry *ce);
|
||||
void zend_class_add_ref(zend_class_entry *ce);
|
||||
|
||||
#define ZEND_FUNCTION_DTOR (void (*)(void *)) destroy_zend_function
|
||||
#define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
|
||||
|
||||
zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC);
|
||||
void init_op(zend_op *op TSRMLS_DC);
|
||||
int get_next_op_number(zend_op_array *op_array);
|
||||
int print_class(zend_class_entry *class_entry TSRMLS_DC);
|
||||
void print_op_array(zend_op_array *op_array, int optimizations);
|
||||
int pass_two(zend_op_array *op_array TSRMLS_DC);
|
||||
zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array);
|
||||
ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
|
||||
ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC);
|
||||
|
||||
int zendlex(znode *zendlval TSRMLS_DC);
|
||||
|
||||
#define ZEND_NOP 0
|
||||
|
||||
#define ZEND_ADD 1
|
||||
#define ZEND_SUB 2
|
||||
#define ZEND_MUL 3
|
||||
#define ZEND_DIV 4
|
||||
#define ZEND_MOD 5
|
||||
#define ZEND_SL 6
|
||||
#define ZEND_SR 7
|
||||
#define ZEND_CONCAT 8
|
||||
#define ZEND_BW_OR 9
|
||||
#define ZEND_BW_AND 10
|
||||
#define ZEND_BW_XOR 11
|
||||
#define ZEND_BW_NOT 12
|
||||
#define ZEND_BOOL_NOT 13
|
||||
#define ZEND_BOOL_XOR 14
|
||||
#define ZEND_IS_IDENTICAL 15
|
||||
#define ZEND_IS_NOT_IDENTICAL 16
|
||||
#define ZEND_IS_EQUAL 17
|
||||
#define ZEND_IS_NOT_EQUAL 18
|
||||
#define ZEND_IS_SMALLER 19
|
||||
#define ZEND_IS_SMALLER_OR_EQUAL 20
|
||||
#define ZEND_CAST 21
|
||||
#define ZEND_QM_ASSIGN 22
|
||||
|
||||
#define ZEND_ASSIGN_ADD 23
|
||||
#define ZEND_ASSIGN_SUB 24
|
||||
#define ZEND_ASSIGN_MUL 25
|
||||
#define ZEND_ASSIGN_DIV 26
|
||||
#define ZEND_ASSIGN_MOD 27
|
||||
#define ZEND_ASSIGN_SL 28
|
||||
#define ZEND_ASSIGN_SR 29
|
||||
#define ZEND_ASSIGN_CONCAT 30
|
||||
#define ZEND_ASSIGN_BW_OR 31
|
||||
#define ZEND_ASSIGN_BW_AND 32
|
||||
#define ZEND_ASSIGN_BW_XOR 33
|
||||
|
||||
#define ZEND_PRE_INC 34
|
||||
#define ZEND_PRE_DEC 35
|
||||
#define ZEND_POST_INC 36
|
||||
#define ZEND_POST_DEC 37
|
||||
|
||||
#define ZEND_ASSIGN 38
|
||||
#define ZEND_ASSIGN_REF 39
|
||||
|
||||
#define ZEND_ECHO 40
|
||||
#define ZEND_PRINT 41
|
||||
|
||||
#define ZEND_JMP 42
|
||||
#define ZEND_JMPZ 43
|
||||
#define ZEND_JMPNZ 44
|
||||
#define ZEND_JMPZNZ 45
|
||||
#define ZEND_JMPZ_EX 46
|
||||
#define ZEND_JMPNZ_EX 47
|
||||
#define ZEND_CASE 48
|
||||
#define ZEND_SWITCH_FREE 49
|
||||
#define ZEND_BRK 50
|
||||
#define ZEND_CONT 51
|
||||
#define ZEND_BOOL 52
|
||||
|
||||
#define ZEND_INIT_STRING 53
|
||||
#define ZEND_ADD_CHAR 54
|
||||
#define ZEND_ADD_STRING 55
|
||||
#define ZEND_ADD_VAR 56
|
||||
|
||||
#define ZEND_BEGIN_SILENCE 57
|
||||
#define ZEND_END_SILENCE 58
|
||||
|
||||
#define ZEND_INIT_FCALL_BY_NAME 59
|
||||
#define ZEND_DO_FCALL 60
|
||||
#define ZEND_DO_FCALL_BY_NAME 61
|
||||
#define ZEND_RETURN 62
|
||||
|
||||
#define ZEND_RECV 63
|
||||
#define ZEND_RECV_INIT 64
|
||||
|
||||
#define ZEND_SEND_VAL 65
|
||||
#define ZEND_SEND_VAR 66
|
||||
#define ZEND_SEND_REF 67
|
||||
|
||||
#define ZEND_NEW 68
|
||||
#define ZEND_JMP_NO_CTOR 69
|
||||
#define ZEND_FREE 70
|
||||
|
||||
#define ZEND_INIT_ARRAY 71
|
||||
#define ZEND_ADD_ARRAY_ELEMENT 72
|
||||
|
||||
#define ZEND_INCLUDE_OR_EVAL 73
|
||||
|
||||
#define ZEND_UNSET_VAR 74
|
||||
#define ZEND_UNSET_DIM_OBJ 75
|
||||
#define ZEND_ISSET_ISEMPTY 76
|
||||
|
||||
#define ZEND_FE_RESET 77
|
||||
#define ZEND_FE_FETCH 78
|
||||
|
||||
#define ZEND_EXIT 79
|
||||
|
||||
|
||||
/* the following 18 opcodes are 6 groups of 3 opcodes each, and must
|
||||
* remain in that order!
|
||||
*/
|
||||
#define ZEND_FETCH_R 80
|
||||
#define ZEND_FETCH_DIM_R 81
|
||||
#define ZEND_FETCH_OBJ_R 82
|
||||
#define ZEND_FETCH_W 83
|
||||
#define ZEND_FETCH_DIM_W 84
|
||||
#define ZEND_FETCH_OBJ_W 85
|
||||
#define ZEND_FETCH_RW 86
|
||||
#define ZEND_FETCH_DIM_RW 87
|
||||
#define ZEND_FETCH_OBJ_RW 88
|
||||
#define ZEND_FETCH_IS 89
|
||||
#define ZEND_FETCH_DIM_IS 90
|
||||
#define ZEND_FETCH_OBJ_IS 91
|
||||
#define ZEND_FETCH_FUNC_ARG 92
|
||||
#define ZEND_FETCH_DIM_FUNC_ARG 93
|
||||
#define ZEND_FETCH_OBJ_FUNC_ARG 94
|
||||
#define ZEND_FETCH_UNSET 95
|
||||
#define ZEND_FETCH_DIM_UNSET 96
|
||||
#define ZEND_FETCH_OBJ_UNSET 97
|
||||
|
||||
#define ZEND_FETCH_DIM_TMP_VAR 98
|
||||
#define ZEND_FETCH_CONSTANT 99
|
||||
|
||||
#define ZEND_DECLARE_FUNCTION_OR_CLASS 100
|
||||
|
||||
#define ZEND_EXT_STMT 101
|
||||
#define ZEND_EXT_FCALL_BEGIN 102
|
||||
#define ZEND_EXT_FCALL_END 103
|
||||
#define ZEND_EXT_NOP 104
|
||||
|
||||
#define ZEND_TICKS 105
|
||||
|
||||
#define ZEND_SEND_VAR_NO_REF 106
|
||||
|
||||
/* end of block */
|
||||
|
||||
|
||||
|
||||
|
||||
/* global/local fetches */
|
||||
#define ZEND_FETCH_GLOBAL 0
|
||||
#define ZEND_FETCH_LOCAL 1
|
||||
#define ZEND_FETCH_STATIC 2
|
||||
|
||||
/* var status for backpatching */
|
||||
#define BP_VAR_R 0
|
||||
#define BP_VAR_W 1
|
||||
#define BP_VAR_RW 2
|
||||
#define BP_VAR_IS 3
|
||||
#define BP_VAR_NA 4 /* if not applicable */
|
||||
#define BP_VAR_FUNC_ARG 5
|
||||
#define BP_VAR_UNSET 6
|
||||
|
||||
|
||||
#define ZEND_INTERNAL_FUNCTION 1
|
||||
#define ZEND_USER_FUNCTION 2
|
||||
#define ZEND_OVERLOADED_FUNCTION 3
|
||||
#define ZEND_EVAL_CODE 4
|
||||
|
||||
#define ZEND_INTERNAL_CLASS 1
|
||||
#define ZEND_USER_CLASS 2
|
||||
|
||||
#define ZEND_EVAL (1<<0)
|
||||
#define ZEND_INCLUDE (1<<1)
|
||||
#define ZEND_INCLUDE_ONCE (1<<2)
|
||||
#define ZEND_REQUIRE (1<<3)
|
||||
#define ZEND_REQUIRE_ONCE (1<<4)
|
||||
|
||||
#define ZEND_ISSET (1<<0)
|
||||
#define ZEND_ISEMPTY (1<<1)
|
||||
|
||||
#define ZEND_CT (1<<0)
|
||||
#define ZEND_RT (1<<1)
|
||||
|
||||
|
||||
#define ZEND_HANDLE_FILENAME 0
|
||||
#define ZEND_HANDLE_FD 1
|
||||
#define ZEND_HANDLE_FP 2
|
||||
#define ZEND_HANDLE_STDIOSTREAM 3
|
||||
#define ZEND_HANDLE_FSTREAM 4
|
||||
|
||||
#define ZEND_DECLARE_CLASS 1
|
||||
#define ZEND_DECLARE_FUNCTION 2
|
||||
#define ZEND_DECLARE_INHERITED_CLASS 3
|
||||
|
||||
#define ZEND_FETCH_STANDARD 0
|
||||
#define ZEND_FETCH_ADD_LOCK 1
|
||||
|
||||
#define ZEND_MEMBER_FUNC_CALL 1<<0
|
||||
#define ZEND_CTOR_CALL 1<<1
|
||||
|
||||
#define ZEND_ARG_SEND_BY_REF (1<<0)
|
||||
#define ZEND_ARG_COMPILE_TIME_BOUND (1<<1)
|
||||
|
||||
#define AI_USE_PTR(ai) \
|
||||
if ((ai).ptr_ptr) { \
|
||||
(ai).ptr = *((ai).ptr_ptr); \
|
||||
(ai).ptr_ptr = &((ai).ptr); \
|
||||
} else { \
|
||||
(ai).ptr = NULL; \
|
||||
}
|
||||
|
||||
/* Lost In Stupid Parentheses */
|
||||
#define ARG_SHOULD_BE_SENT_BY_REF(offset, conduct_check, arg_types) \
|
||||
( \
|
||||
conduct_check \
|
||||
&& arg_types \
|
||||
&& \
|
||||
( \
|
||||
( \
|
||||
offset<=arg_types[0] \
|
||||
&& arg_types[offset]==BYREF_FORCE \
|
||||
) \
|
||||
|| ( \
|
||||
offset>=arg_types[0] \
|
||||
&& arg_types[arg_types[0]]==BYREF_FORCE_REST \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
#define ZEND_RETURN_VAL 0
|
||||
#define ZEND_RETURN_REF 1
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif /* ZEND_COMPILE_H */
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_CONFIG_W32_H
|
||||
#define ZEND_CONFIG_W32_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <float.h>
|
||||
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned int uint;
|
||||
|
||||
#define HAVE_ALLOCA 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#include <malloc.h>
|
||||
|
||||
#undef HAVE_KILL
|
||||
#define HAVE_GETPID 1
|
||||
/* #define HAVE_ALLOCA_H 1 */
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIOSTR_H 1
|
||||
#define HAVE_CLASS_ISTDIOSTREAM
|
||||
#define istdiostream stdiostream
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_SNPRINTF 1
|
||||
#define HAVE_VSNPRINTF 1
|
||||
|
||||
#define vsnprintf _vsnprintf
|
||||
#define zend_isinf(a) 0
|
||||
|
||||
#define zend_sprintf sprintf
|
||||
|
||||
/* This will cause the compilation process to be MUCH longer, but will generate
|
||||
* a much quicker PHP binary
|
||||
*/
|
||||
#undef inline
|
||||
#ifdef ZEND_WIN32_FORCE_INLINE
|
||||
# define inline __forceinline
|
||||
#else
|
||||
# define inline
|
||||
#endif
|
||||
|
||||
#define zend_finite(A) _finite(A)
|
||||
#define zend_isnan(A) _isnan(A)
|
||||
|
||||
#ifdef LIBZEND_EXPORTS
|
||||
# define ZEND_API __declspec(dllexport)
|
||||
#else
|
||||
# define ZEND_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#define ZEND_DLEXPORT __declspec(dllexport)
|
||||
|
||||
/* 0x00200000L is MB_SERVICE_NOTIFICATION, which is only supported under Windows NT
|
||||
* (and requires _WIN32_WINNT to be defined, which prevents the resulting executable
|
||||
* from running under Windows 9x
|
||||
* Windows 9x should silently ignore it, so it's being used here directly
|
||||
*/
|
||||
#ifndef MB_SERVICE_NOTIFICATION
|
||||
#define MB_SERVICE_NOTIFICATION 0x00200000L
|
||||
#endif
|
||||
|
||||
#define ZEND_SERVICE_MB_STYLE (MB_TOPMOST|MB_SERVICE_NOTIFICATION)
|
||||
|
||||
#endif /* ZEND_CONFIG_W32_H */
|
||||
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_constants.h"
|
||||
#include "zend_variables.h"
|
||||
#include "zend_operators.h"
|
||||
#include "zend_globals.h"
|
||||
|
||||
|
||||
void free_zend_constant(zend_constant *c)
|
||||
{
|
||||
if (!(c->flags & CONST_PERSISTENT)) {
|
||||
zval_dtor(&c->value);
|
||||
}
|
||||
free(c->name);
|
||||
}
|
||||
|
||||
|
||||
void copy_zend_constant(zend_constant *c)
|
||||
{
|
||||
c->name = zend_strndup(c->name, c->name_len);
|
||||
if (!(c->flags & CONST_PERSISTENT)) {
|
||||
zval_copy_ctor(&c->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void zend_copy_constants(HashTable *target, HashTable *source)
|
||||
{
|
||||
zend_constant tmp_constant;
|
||||
|
||||
zend_hash_copy(target, source, (copy_ctor_func_t) copy_zend_constant, &tmp_constant, sizeof(zend_constant));
|
||||
}
|
||||
|
||||
|
||||
static int clean_non_persistent_constant(zend_constant *c TSRMLS_DC)
|
||||
{
|
||||
if (c->flags & CONST_PERSISTENT) {
|
||||
return ZEND_HASH_APPLY_STOP;
|
||||
} else {
|
||||
return ZEND_HASH_APPLY_REMOVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int clean_module_constant(zend_constant *c, int *module_number TSRMLS_DC)
|
||||
{
|
||||
if (c->module_number == *module_number) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void clean_module_constants(int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_hash_apply_with_argument(EG(zend_constants), (apply_func_arg_t) clean_module_constant, (void *) &module_number TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
int zend_startup_constants(TSRMLS_D)
|
||||
{
|
||||
#ifdef ZEND_WIN32
|
||||
DWORD dwBuild=0;
|
||||
DWORD dwVersion = GetVersion();
|
||||
DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
||||
#endif
|
||||
|
||||
EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable));
|
||||
|
||||
if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void zend_register_standard_constants(TSRMLS_D)
|
||||
{
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_ERROR", E_ERROR, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_WARNING", E_WARNING, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_PARSE", E_PARSE, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_NOTICE", E_NOTICE, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_CORE_ERROR", E_CORE_ERROR, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_CORE_WARNING", E_CORE_WARNING, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_ERROR", E_COMPILE_ERROR, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_COMPILE_WARNING", E_COMPILE_WARNING, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT | CONST_CS);
|
||||
|
||||
REGISTER_MAIN_LONG_CONSTANT("E_ALL", E_ALL, CONST_PERSISTENT | CONST_CS);
|
||||
|
||||
/* true/false constants */
|
||||
{
|
||||
zend_constant c;
|
||||
|
||||
c.value.type = IS_BOOL;
|
||||
c.flags = CONST_PERSISTENT;
|
||||
c.module_number = 0;
|
||||
|
||||
c.name = zend_strndup(ZEND_STRL("TRUE"));
|
||||
c.name_len = sizeof("TRUE");
|
||||
c.value.value.lval = 1;
|
||||
c.value.type = IS_BOOL;
|
||||
zend_register_constant(&c TSRMLS_CC);
|
||||
|
||||
c.name = zend_strndup(ZEND_STRL("FALSE"));
|
||||
c.name_len = sizeof("FALSE");
|
||||
c.value.value.lval = 0;
|
||||
c.value.type = IS_BOOL;
|
||||
zend_register_constant(&c TSRMLS_CC);
|
||||
|
||||
c.name = zend_strndup(ZEND_STRL("ZEND_THREAD_SAFE"));
|
||||
c.name_len = sizeof("ZEND_THREAD_SAFE");
|
||||
c.value.value.lval = ZTS_V;
|
||||
c.value.type = IS_BOOL;
|
||||
zend_register_constant(&c TSRMLS_CC);
|
||||
|
||||
c.name = zend_strndup(ZEND_STRL("NULL"));
|
||||
c.name_len = sizeof("NULL");
|
||||
c.value.type = IS_NULL;
|
||||
zend_register_constant(&c TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int zend_shutdown_constants(TSRMLS_D)
|
||||
{
|
||||
zend_hash_destroy(EG(zend_constants));
|
||||
free(EG(zend_constants));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void clean_non_persistent_constants(TSRMLS_D)
|
||||
{
|
||||
zend_hash_reverse_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_register_long_constant(char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_constant c;
|
||||
|
||||
c.value.type = IS_LONG;
|
||||
c.value.value.lval = lval;
|
||||
c.flags = flags;
|
||||
c.name = zend_strndup(name,name_len);
|
||||
c.name_len = name_len;
|
||||
c.module_number = module_number;
|
||||
zend_register_constant(&c TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_register_double_constant(char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_constant c;
|
||||
|
||||
c.value.type = IS_DOUBLE;
|
||||
c.value.value.dval = dval;
|
||||
c.flags = flags;
|
||||
c.name = zend_strndup(name,name_len);
|
||||
c.name_len = name_len;
|
||||
c.module_number = module_number;
|
||||
zend_register_constant(&c TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_register_stringl_constant(char *name, uint name_len, char *strval, uint strlen, int flags, int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_constant c;
|
||||
|
||||
c.value.type = IS_STRING;
|
||||
c.value.value.str.val = strval;
|
||||
c.value.value.str.len = strlen;
|
||||
c.flags = flags;
|
||||
c.name = zend_strndup(name,name_len);
|
||||
c.name_len = name_len;
|
||||
c.module_number = module_number;
|
||||
zend_register_constant(&c TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_register_string_constant(char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC)
|
||||
{
|
||||
zend_constant *c;
|
||||
char *lookup_name = estrndup(name,name_len);
|
||||
int retval;
|
||||
|
||||
zend_str_tolower(lookup_name, name_len);
|
||||
|
||||
if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {
|
||||
if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) {
|
||||
retval=0;
|
||||
} else {
|
||||
retval=1;
|
||||
*result = c->value;
|
||||
zval_copy_ctor(result);
|
||||
}
|
||||
} else {
|
||||
retval=0;
|
||||
}
|
||||
|
||||
efree(lookup_name);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC)
|
||||
{
|
||||
char *lowercase_name = zend_strndup(c->name, c->name_len);
|
||||
int ret = SUCCESS;
|
||||
|
||||
#if 0
|
||||
printf("Registering constant for module %d\n",c->module_number);
|
||||
#endif
|
||||
|
||||
zend_str_tolower(lowercase_name, c->name_len);
|
||||
if (zend_hash_add(EG(zend_constants), lowercase_name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
|
||||
free(c->name);
|
||||
zval_dtor(&c->value);
|
||||
zend_error(E_NOTICE,"Constant %s already defined",lowercase_name);
|
||||
ret = FAILURE;
|
||||
}
|
||||
free(lowercase_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_CONSTANTS_H
|
||||
#define ZEND_CONSTANTS_H
|
||||
|
||||
#include "zend_globals.h"
|
||||
|
||||
#define CONST_CS 0x1 /* Case Sensitive */
|
||||
#define CONST_PERSISTENT 0x2
|
||||
|
||||
typedef struct _zend_constant {
|
||||
zval value;
|
||||
int flags;
|
||||
char *name;
|
||||
uint name_len;
|
||||
int module_number;
|
||||
} zend_constant;
|
||||
|
||||
#define REGISTER_LONG_CONSTANT(name,lval,flags) zend_register_long_constant((name),sizeof(name),(lval),(flags),module_number TSRMLS_CC)
|
||||
#define REGISTER_DOUBLE_CONSTANT(name,dval,flags) zend_register_double_constant((name),sizeof(name),(dval),(flags),module_number TSRMLS_CC)
|
||||
#define REGISTER_STRING_CONSTANT(name,str,flags) zend_register_string_constant((name),sizeof(name),(str),(flags),module_number TSRMLS_CC)
|
||||
#define REGISTER_STRINGL_CONSTANT(name,str,len,flags) zend_register_stringl_constant((name),sizeof(name),(str),(len),(flags),module_number TSRMLS_CC)
|
||||
|
||||
#define REGISTER_MAIN_LONG_CONSTANT(name,lval,flags) zend_register_long_constant((name),sizeof(name),(lval),(flags),0 TSRMLS_CC)
|
||||
#define REGISTER_MAIN_DOUBLE_CONSTANT(name,dval,flags) zend_register_double_constant((name),sizeof(name),(dval),(flags),0 TSRMLS_CC)
|
||||
#define REGISTER_MAIN_STRING_CONSTANT(name,str,flags) zend_register_string_constant((name),sizeof(name),(str),(flags),0 TSRMLS_CC)
|
||||
#define REGISTER_MAIN_STRINGL_CONSTANT(name,str,len,flags) zend_register_stringl_constant((name),sizeof(name),(str),(len),(flags),0 TSRMLS_CC)
|
||||
|
||||
void clean_module_constants(int module_number TSRMLS_DC);
|
||||
void free_zend_constant(zend_constant *c);
|
||||
int zend_startup_constants(TSRMLS_D);
|
||||
int zend_shutdown_constants(TSRMLS_D);
|
||||
void zend_register_standard_constants(TSRMLS_D);
|
||||
void clean_non_persistent_constants(TSRMLS_D);
|
||||
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC);
|
||||
ZEND_API void zend_register_long_constant(char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC);
|
||||
ZEND_API void zend_register_double_constant(char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC);
|
||||
ZEND_API void zend_register_string_constant(char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC);
|
||||
ZEND_API void zend_register_stringl_constant(char *name, uint name_len, char *strval, uint strlen, int flags, int module_number TSRMLS_DC);
|
||||
ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC);
|
||||
void zend_copy_constants(HashTable *target, HashTable *sourc);
|
||||
void copy_zend_constant(zend_constant *c);
|
||||
|
||||
#define ZEND_CONSTANT_DTOR (void (*)(void *)) free_zend_constant
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "zend.h"
|
||||
|
||||
typedef struct _dynamic_array {
|
||||
char *array;
|
||||
unsigned int element_size;
|
||||
unsigned int current;
|
||||
unsigned int allocated;
|
||||
} dynamic_array;
|
||||
|
||||
ZEND_API int zend_dynamic_array_init(dynamic_array *da, unsigned int element_size, unsigned int size)
|
||||
{
|
||||
da->element_size = element_size;
|
||||
da->allocated = size;
|
||||
da->current = 0;
|
||||
da->array = (char *) emalloc(size*element_size);
|
||||
if (da->array == NULL) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZEND_API void *zend_dynamic_array_push(dynamic_array *da)
|
||||
{
|
||||
if (da->current == da->allocated) {
|
||||
da->allocated *= 2;
|
||||
da->array = (char *) erealloc(da->array, da->allocated*da->element_size);
|
||||
}
|
||||
return (void *)(da->array+(da->current++)*da->element_size);
|
||||
}
|
||||
|
||||
ZEND_API void *zend_dynamic_array_pop(dynamic_array *da)
|
||||
{
|
||||
return (void *)(da->array+(--(da->current))*da->element_size);
|
||||
|
||||
}
|
||||
|
||||
ZEND_API void *zend_dynamic_array_get_element(dynamic_array *da, unsigned int index)
|
||||
{
|
||||
if (index >= da->current) {
|
||||
return NULL;
|
||||
}
|
||||
return (void *)(da->array+index*da->element_size);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_DYNAMIC_ARRAY_H
|
||||
#define ZEND_DYNAMIC_ARRAY_H
|
||||
|
||||
typedef struct _dynamic_array {
|
||||
char *array;
|
||||
unsigned int element_size;
|
||||
unsigned int last_used;
|
||||
unsigned int allocated;
|
||||
} dynamic_array;
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API int zend_dynamic_array_init(dynamic_array *da);
|
||||
ZEND_API void *zend_dynamic_array_push(dynamic_array *da);
|
||||
ZEND_API void *zend_dynamic_array_pop(dynamic_array *da);
|
||||
ZEND_API void *zend_dynamic_array_get_element(dynamic_array *da, unsigned int index);
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif /* ZEND_DYNAMIC_ARRAY_H */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_ERRORS_H
|
||||
#define ZEND_ERRORS_H
|
||||
|
||||
#define E_ERROR (1<<0L)
|
||||
#define E_WARNING (1<<1L)
|
||||
#define E_PARSE (1<<2L)
|
||||
#define E_NOTICE (1<<3L)
|
||||
#define E_CORE_ERROR (1<<4L)
|
||||
#define E_CORE_WARNING (1<<5L)
|
||||
#define E_COMPILE_ERROR (1<<6L)
|
||||
#define E_COMPILE_WARNING (1<<7L)
|
||||
#define E_USER_ERROR (1<<8L)
|
||||
#define E_USER_WARNING (1<<9L)
|
||||
#define E_USER_NOTICE (1<<10L)
|
||||
|
||||
#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE)
|
||||
#define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
|
||||
|
||||
#endif /* ZEND_ERRORS_H */
|
||||
|
||||
+2418
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_EXECUTE_H
|
||||
#define ZEND_EXECUTE_H
|
||||
|
||||
#include "zend_compile.h"
|
||||
#include "zend_hash.h"
|
||||
#include "zend_variables.h"
|
||||
#include "zend_operators.h"
|
||||
|
||||
typedef union _temp_variable {
|
||||
zval tmp_var;
|
||||
struct {
|
||||
zval **ptr_ptr;
|
||||
zval *ptr;
|
||||
} var;
|
||||
struct {
|
||||
zval tmp_var; /* a dummy */
|
||||
|
||||
union {
|
||||
struct {
|
||||
zval *str;
|
||||
int offset;
|
||||
} str_offset;
|
||||
zend_property_reference overloaded_element;
|
||||
} data;
|
||||
|
||||
unsigned char type;
|
||||
} EA;
|
||||
} temp_variable;
|
||||
|
||||
|
||||
ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC);
|
||||
|
||||
void init_executor(TSRMLS_D);
|
||||
void shutdown_executor(TSRMLS_D);
|
||||
ZEND_API void execute(zend_op_array *op_array TSRMLS_DC);
|
||||
ZEND_API int zend_is_true(zval *op);
|
||||
static inline void safe_free_zval_ptr(zval *p)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (p!=EG(uninitialized_zval_ptr)) {
|
||||
FREE_ZVAL(p);
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
|
||||
static inline int i_zend_is_true(zval *op)
|
||||
{
|
||||
int result;
|
||||
|
||||
switch (op->type) {
|
||||
case IS_NULL:
|
||||
result = 0;
|
||||
break;
|
||||
case IS_LONG:
|
||||
case IS_BOOL:
|
||||
case IS_RESOURCE:
|
||||
result = (op->value.lval?1:0);
|
||||
break;
|
||||
case IS_DOUBLE:
|
||||
result = (op->value.dval ? 1 : 0);
|
||||
break;
|
||||
case IS_STRING:
|
||||
if (op->value.str.len == 0
|
||||
|| (op->value.str.len==1 && op->value.str.val[0]=='0')) {
|
||||
result = 0;
|
||||
} else {
|
||||
result = 1;
|
||||
}
|
||||
break;
|
||||
case IS_ARRAY:
|
||||
result = (zend_hash_num_elements(op->value.ht)?1:0);
|
||||
break;
|
||||
case IS_OBJECT:
|
||||
result = (zend_hash_num_elements(Z_OBJPROP_P(op))?1:0);
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC);
|
||||
|
||||
/* dedicated Zend executor functions - do not use! */
|
||||
static inline void zend_ptr_stack_clear_multiple(TSRMLS_D)
|
||||
{
|
||||
void **p = EG(argument_stack).top_element-2;
|
||||
int delete_count = (ulong) *p;
|
||||
|
||||
EG(argument_stack).top -= (delete_count+2);
|
||||
while (--delete_count>=0) {
|
||||
zval_ptr_dtor((zval **) --p);
|
||||
}
|
||||
EG(argument_stack).top_element = p;
|
||||
}
|
||||
|
||||
static inline int zend_ptr_stack_get_arg(int requested_arg, void **data TSRMLS_DC)
|
||||
{
|
||||
void **p = EG(argument_stack).top_element-2;
|
||||
int arg_count = (ulong) *p;
|
||||
|
||||
if (requested_arg>arg_count) {
|
||||
return FAILURE;
|
||||
}
|
||||
*data = (p-arg_count+requested_arg-1);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void execute_new_code(TSRMLS_D);
|
||||
|
||||
|
||||
/* services */
|
||||
ZEND_API char *get_active_function_name(TSRMLS_D);
|
||||
ZEND_API char *zend_get_executed_filename(TSRMLS_D);
|
||||
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
|
||||
ZEND_API zend_bool zend_is_executing(TSRMLS_D);
|
||||
|
||||
ZEND_API void zend_set_timeout(long seconds);
|
||||
ZEND_API void zend_unset_timeout(TSRMLS_D);
|
||||
ZEND_API void zend_timeout(int dummy);
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
void zend_init_timeout_thread();
|
||||
void zend_shutdown_timeout_thread();
|
||||
#define WM_REGISTER_ZEND_TIMEOUT (WM_USER+1)
|
||||
#define WM_UNREGISTER_ZEND_TIMEOUT (WM_USER+2)
|
||||
#endif
|
||||
|
||||
#define zendi_zval_copy_ctor(p) zval_copy_ctor(&(p))
|
||||
#define zendi_zval_dtor(p) zval_dtor(&(p))
|
||||
|
||||
#define active_opline (*EG(opline_ptr))
|
||||
|
||||
void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts TSRMLS_DC);
|
||||
|
||||
#define IS_OVERLOADED_OBJECT 1
|
||||
#define IS_STRING_OFFSET 2
|
||||
|
||||
#endif /* ZEND_EXECUTE_H */
|
||||
@@ -0,0 +1,803 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_compile.h"
|
||||
#include "zend_execute.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_ptr_stack.h"
|
||||
#include "zend_constants.h"
|
||||
#include "zend_extensions.h"
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
|
||||
ZEND_API void (*zend_execute)(zend_op_array *op_array TSRMLS_DC);
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
#include <process.h>
|
||||
/* true global */
|
||||
static WNDCLASS wc;
|
||||
static HWND timeout_window;
|
||||
static HANDLE timeout_thread_event;
|
||||
static DWORD timeout_thread_id;
|
||||
static int timeout_thread_initialized=0;
|
||||
#endif
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
static void (*original_sigsegv_handler)(int);
|
||||
static void zend_handle_sigsegv(int dummy)
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
if (original_sigsegv_handler==zend_handle_sigsegv) {
|
||||
signal(SIGSEGV, original_sigsegv_handler);
|
||||
} else {
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
}
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
|
||||
active_opline->opcode,
|
||||
active_opline-EG(active_op_array)->opcodes,
|
||||
get_active_function_name(TSRMLS_C),
|
||||
zend_get_executed_filename(TSRMLS_C),
|
||||
zend_get_executed_lineno(TSRMLS_C));
|
||||
}
|
||||
if (original_sigsegv_handler!=zend_handle_sigsegv) {
|
||||
original_sigsegv_handler(dummy);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void zend_extension_activator(zend_extension *extension TSRMLS_DC)
|
||||
{
|
||||
if (extension->activate) {
|
||||
extension->activate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void zend_extension_deactivator(zend_extension *extension TSRMLS_DC)
|
||||
{
|
||||
if (extension->deactivate) {
|
||||
extension->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int is_not_internal_function(zend_function *function TSRMLS_DC)
|
||||
{
|
||||
if (function->type == ZEND_INTERNAL_FUNCTION) {
|
||||
return ZEND_HASH_APPLY_STOP;
|
||||
} else {
|
||||
return ZEND_HASH_APPLY_REMOVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int is_not_internal_class(zend_class_entry *ce TSRMLS_DC)
|
||||
{
|
||||
if (ce->type == ZEND_INTERNAL_CLASS) {
|
||||
return ZEND_HASH_APPLY_STOP;
|
||||
} else {
|
||||
return ZEND_HASH_APPLY_REMOVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_executor(TSRMLS_D)
|
||||
{
|
||||
INIT_ZVAL(EG(uninitialized_zval));
|
||||
INIT_ZVAL(EG(error_zval));
|
||||
EG(uninitialized_zval_ptr)=&EG(uninitialized_zval);
|
||||
EG(error_zval_ptr)=&EG(error_zval);
|
||||
zend_ptr_stack_init(&EG(arg_types_stack));
|
||||
/* destroys stack frame, therefore makes core dumps worthless */
|
||||
#if 0&&ZEND_DEBUG
|
||||
original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);
|
||||
#endif
|
||||
EG(return_value_ptr_ptr) = &EG(global_return_value_ptr);
|
||||
EG(global_return_value_ptr) = NULL;
|
||||
|
||||
EG(symtable_cache_ptr) = EG(symtable_cache)-1;
|
||||
EG(symtable_cache_limit)=EG(symtable_cache)+SYMTABLE_CACHE_SIZE-1;
|
||||
EG(no_extensions)=0;
|
||||
|
||||
EG(function_table) = CG(function_table);
|
||||
EG(class_table) = CG(class_table);
|
||||
|
||||
EG(in_execution) = 0;
|
||||
|
||||
zend_ptr_stack_init(&EG(argument_stack));
|
||||
|
||||
zend_hash_init(&EG(symbol_table), 50, NULL, ZVAL_PTR_DTOR, 0);
|
||||
EG(active_symbol_table) = &EG(symbol_table);
|
||||
|
||||
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC);
|
||||
EG(opline_ptr) = NULL;
|
||||
EG(garbage_ptr) = 0;
|
||||
|
||||
zend_hash_init(&EG(included_files), 5, NULL, NULL, 0);
|
||||
|
||||
EG(ticks_count) = 0;
|
||||
|
||||
EG(user_error_handler) = NULL;
|
||||
|
||||
zend_ptr_stack_init(&EG(user_error_handlers));
|
||||
|
||||
EG(orig_error_reporting) = EG(error_reporting);
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
EG(timed_out) = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void shutdown_executor(TSRMLS_D)
|
||||
{
|
||||
zend_try {
|
||||
zend_ptr_stack_destroy(&EG(arg_types_stack));
|
||||
|
||||
while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
|
||||
zend_hash_destroy(*EG(symtable_cache_ptr));
|
||||
efree(*EG(symtable_cache_ptr));
|
||||
EG(symtable_cache_ptr)--;
|
||||
}
|
||||
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator TSRMLS_CC);
|
||||
|
||||
zend_hash_destroy(&EG(symbol_table));
|
||||
|
||||
while (EG(garbage_ptr)--) {
|
||||
if (EG(garbage)[EG(garbage_ptr)]->refcount==1) {
|
||||
zval_ptr_dtor(&EG(garbage)[EG(garbage_ptr)]);
|
||||
}
|
||||
}
|
||||
|
||||
zend_ptr_stack_destroy(&EG(argument_stack));
|
||||
|
||||
/* Destroy all op arrays */
|
||||
zend_hash_reverse_apply(EG(function_table), (apply_func_t) is_not_internal_function TSRMLS_CC);
|
||||
zend_hash_reverse_apply(EG(class_table), (apply_func_t) is_not_internal_class TSRMLS_CC);
|
||||
} zend_end_try();
|
||||
|
||||
/* The regular list must be destroyed after the main symbol table and
|
||||
* op arrays are destroyed.
|
||||
*/
|
||||
zend_destroy_rsrc_list(&EG(regular_list) TSRMLS_CC);
|
||||
|
||||
zend_try {
|
||||
clean_non_persistent_constants(TSRMLS_C);
|
||||
#if ZEND_DEBUG
|
||||
signal(SIGSEGV, original_sigsegv_handler);
|
||||
#endif
|
||||
|
||||
zend_hash_destroy(&EG(included_files));
|
||||
|
||||
if (EG(user_error_handler)) {
|
||||
zval_dtor(EG(user_error_handler));
|
||||
FREE_ZVAL(EG(user_error_handler));
|
||||
}
|
||||
|
||||
zend_ptr_stack_clean(&EG(user_error_handlers), ZVAL_DESTRUCTOR, 1);
|
||||
zend_ptr_stack_destroy(&EG(user_error_handlers));
|
||||
|
||||
EG(error_reporting) = EG(orig_error_reporting);
|
||||
} zend_end_try();
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *get_active_function_name(TSRMLS_D)
|
||||
{
|
||||
switch(EG(function_state_ptr)->function->type) {
|
||||
case ZEND_USER_FUNCTION: {
|
||||
char *function_name = ((zend_op_array *) EG(function_state_ptr)->function)->function_name;
|
||||
|
||||
if (function_name) {
|
||||
return function_name;
|
||||
} else {
|
||||
return "main";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ZEND_INTERNAL_FUNCTION:
|
||||
return ((zend_internal_function *) EG(function_state_ptr)->function)->function_name;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *zend_get_executed_filename(TSRMLS_D)
|
||||
{
|
||||
if (EG(active_op_array)) {
|
||||
return EG(active_op_array)->filename;
|
||||
} else {
|
||||
return "[no active file]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API uint zend_get_executed_lineno(TSRMLS_D)
|
||||
{
|
||||
if (EG(opline_ptr)) {
|
||||
return active_opline->lineno;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API zend_bool zend_is_executing(TSRMLS_D)
|
||||
{
|
||||
return EG(in_execution);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC)
|
||||
{
|
||||
#if DEBUG_ZEND>=2
|
||||
printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, (*zval_ptr)->refcount, (*zval_ptr)->refcount-1);
|
||||
#endif
|
||||
(*zval_ptr)->refcount--;
|
||||
if ((*zval_ptr)->refcount==0) {
|
||||
zval_dtor(*zval_ptr);
|
||||
safe_free_zval_ptr(*zval_ptr);
|
||||
} else if (((*zval_ptr)->refcount == 1) && ((*zval_ptr)->type != IS_OBJECT)) {
|
||||
(*zval_ptr)->is_ref = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_is_true(zval *op)
|
||||
{
|
||||
return i_zend_is_true(op);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
|
||||
{
|
||||
zval *p = *pp;
|
||||
zend_bool inline_change = (zend_bool) (unsigned long) arg;
|
||||
zval const_value;
|
||||
|
||||
if (p->type == IS_CONSTANT) {
|
||||
int refcount;
|
||||
|
||||
SEPARATE_ZVAL(pp);
|
||||
p = *pp;
|
||||
|
||||
refcount = p->refcount;
|
||||
|
||||
if (!zend_get_constant(p->value.str.val, p->value.str.len, &const_value TSRMLS_CC)) {
|
||||
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
|
||||
p->value.str.val,
|
||||
p->value.str.val);
|
||||
p->type = IS_STRING;
|
||||
if (!inline_change) {
|
||||
zval_copy_ctor(p);
|
||||
}
|
||||
} else {
|
||||
if (inline_change) {
|
||||
STR_FREE(p->value.str.val);
|
||||
}
|
||||
*p = const_value;
|
||||
}
|
||||
INIT_PZVAL(p);
|
||||
p->refcount = refcount;
|
||||
} else if (p->type == IS_CONSTANT_ARRAY) {
|
||||
zval **element;
|
||||
char *str_index;
|
||||
ulong str_index_len, num_index;
|
||||
|
||||
SEPARATE_ZVAL(pp);
|
||||
p = *pp;
|
||||
p->type = IS_ARRAY;
|
||||
|
||||
/* First go over the array and see if there are any constant indices */
|
||||
zend_hash_internal_pointer_reset(p->value.ht);
|
||||
while (zend_hash_get_current_data(p->value.ht, (void **) &element)==SUCCESS) {
|
||||
if (!(Z_TYPE_PP(element) & IS_CONSTANT_INDEX)) {
|
||||
zend_hash_move_forward(p->value.ht);
|
||||
continue;
|
||||
}
|
||||
Z_TYPE_PP(element) &= ~IS_CONSTANT_INDEX;
|
||||
if (zend_hash_get_current_key_ex(p->value.ht, &str_index, &str_index_len, &num_index, 0, NULL)!=HASH_KEY_IS_STRING) {
|
||||
zend_hash_move_forward(p->value.ht);
|
||||
continue;
|
||||
}
|
||||
if (!zend_get_constant(str_index, str_index_len-1, &const_value TSRMLS_CC)) {
|
||||
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", str_index, str_index);
|
||||
zend_hash_move_forward(p->value.ht);
|
||||
continue;
|
||||
}
|
||||
switch (const_value.type) {
|
||||
case IS_STRING:
|
||||
zend_hash_update(p->value.ht, const_value.value.str.val, const_value.value.str.len+1, element, sizeof(zval *), NULL);
|
||||
(*element)->refcount++;
|
||||
break;
|
||||
case IS_LONG:
|
||||
zend_hash_index_update(p->value.ht, const_value.value.lval, element, sizeof(zval *), NULL);
|
||||
(*element)->refcount++;
|
||||
break;
|
||||
}
|
||||
zend_hash_del(p->value.ht, str_index, str_index_len);
|
||||
}
|
||||
zend_hash_apply_with_argument(p->value.ht, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC)
|
||||
{
|
||||
zval ***params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
|
||||
int i;
|
||||
int ex_retval;
|
||||
zval *local_retval_ptr;
|
||||
|
||||
for (i=0; i<param_count; i++) {
|
||||
params_array[i] = ¶ms[i];
|
||||
}
|
||||
ex_retval = call_user_function_ex(function_table, object_pp, function_name, &local_retval_ptr, param_count, params_array, 1, NULL TSRMLS_CC);
|
||||
if (local_retval_ptr) {
|
||||
COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr);
|
||||
} else {
|
||||
INIT_ZVAL(*retval_ptr);
|
||||
}
|
||||
efree(params_array);
|
||||
return ex_retval;
|
||||
}
|
||||
|
||||
|
||||
int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, int param_count, zval **params[], int no_separation, HashTable *symbol_table TSRMLS_DC)
|
||||
{
|
||||
int i;
|
||||
zval **original_return_value;
|
||||
HashTable *calling_symbol_table;
|
||||
zend_function_state function_state;
|
||||
zend_function_state *original_function_state_ptr;
|
||||
zend_op_array *original_op_array;
|
||||
zend_op **original_opline_ptr;
|
||||
int orig_free_op1, orig_free_op2;
|
||||
int (*orig_unary_op)(zval *result, zval *op1);
|
||||
int (*orig_binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
zval function_name_copy;
|
||||
|
||||
*retval_ptr_ptr = NULL;
|
||||
|
||||
if (function_name->type==IS_ARRAY) { /* assume array($obj, $name) couple */
|
||||
zval **tmp_object_ptr, **tmp_real_function_name;
|
||||
|
||||
if (zend_hash_index_find(function_name->value.ht, 0, (void **) &tmp_object_ptr)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
if (zend_hash_index_find(function_name->value.ht, 1, (void **) &tmp_real_function_name)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
function_name = *tmp_real_function_name;
|
||||
SEPARATE_ZVAL_IF_NOT_REF(tmp_object_ptr);
|
||||
object_pp = tmp_object_ptr;
|
||||
(*object_pp)->is_ref = 1;
|
||||
}
|
||||
|
||||
if (object_pp && !*object_pp) {
|
||||
object_pp = NULL;
|
||||
}
|
||||
if (object_pp) {
|
||||
if (Z_TYPE_PP(object_pp) == IS_OBJECT) {
|
||||
function_table = &(*object_pp)->value.obj.ce->function_table;
|
||||
} else if (Z_TYPE_PP(object_pp) == IS_STRING) {
|
||||
zend_class_entry *ce;
|
||||
char *lc_class;
|
||||
int found;
|
||||
|
||||
lc_class = estrndup(Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp));
|
||||
zend_str_tolower(lc_class, Z_STRLEN_PP(object_pp));
|
||||
found = zend_hash_find(EG(class_table), lc_class, Z_STRLEN_PP(object_pp) + 1, (void **) &ce);
|
||||
efree(lc_class);
|
||||
if (found == FAILURE)
|
||||
return FAILURE;
|
||||
|
||||
function_table = &ce->function_table;
|
||||
object_pp = NULL;
|
||||
} else
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (function_name->type!=IS_STRING) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
function_name_copy = *function_name;
|
||||
zval_copy_ctor(&function_name_copy);
|
||||
zend_str_tolower(function_name_copy.value.str.val, function_name_copy.value.str.len);
|
||||
|
||||
original_function_state_ptr = EG(function_state_ptr);
|
||||
if (zend_hash_find(function_table, function_name_copy.value.str.val, function_name_copy.value.str.len+1, (void **) &function_state.function)==FAILURE) {
|
||||
zval_dtor(&function_name_copy);
|
||||
return FAILURE;
|
||||
}
|
||||
zval_dtor(&function_name_copy);
|
||||
|
||||
for (i=0; i<param_count; i++) {
|
||||
zval *param;
|
||||
|
||||
if (function_state.function->common.arg_types
|
||||
&& i<function_state.function->common.arg_types[0]
|
||||
&& function_state.function->common.arg_types[i+1]==BYREF_FORCE
|
||||
&& !PZVAL_IS_REF(*params[i])) {
|
||||
if ((*params[i])->refcount>1) {
|
||||
zval *new_zval;
|
||||
|
||||
if (no_separation) {
|
||||
return FAILURE;
|
||||
}
|
||||
ALLOC_ZVAL(new_zval);
|
||||
*new_zval = **params[i];
|
||||
zval_copy_ctor(new_zval);
|
||||
new_zval->refcount = 1;
|
||||
(*params[i])->refcount--;
|
||||
*params[i] = new_zval;
|
||||
}
|
||||
(*params[i])->refcount++;
|
||||
(*params[i])->is_ref = 1;
|
||||
param = *params[i];
|
||||
} else if (*params[i] != &EG(uninitialized_zval)) {
|
||||
(*params[i])->refcount++;
|
||||
param = *params[i];
|
||||
} else {
|
||||
ALLOC_ZVAL(param);
|
||||
*param = **(params[i]);
|
||||
INIT_PZVAL(param);
|
||||
}
|
||||
zend_ptr_stack_push(&EG(argument_stack), param);
|
||||
}
|
||||
|
||||
zend_ptr_stack_n_push(&EG(argument_stack), 2, (void *) (long) param_count, NULL);
|
||||
|
||||
EG(function_state_ptr) = &function_state;
|
||||
|
||||
if (function_state.function->type == ZEND_USER_FUNCTION) {
|
||||
calling_symbol_table = EG(active_symbol_table);
|
||||
if (symbol_table) {
|
||||
EG(active_symbol_table) = symbol_table;
|
||||
} else {
|
||||
ALLOC_HASHTABLE(EG(active_symbol_table));
|
||||
zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
}
|
||||
if (object_pp) {
|
||||
zval *dummy, **this_ptr;
|
||||
|
||||
ALLOC_ZVAL(dummy);
|
||||
INIT_ZVAL(*dummy);
|
||||
zend_hash_update(EG(active_symbol_table), "this", sizeof("this"), &dummy, sizeof(zval *), (void **) &this_ptr);
|
||||
zend_assign_to_variable_reference(NULL, this_ptr, object_pp, NULL TSRMLS_CC);
|
||||
}
|
||||
original_return_value = EG(return_value_ptr_ptr);
|
||||
original_op_array = EG(active_op_array);
|
||||
EG(return_value_ptr_ptr) = retval_ptr_ptr;
|
||||
EG(active_op_array) = (zend_op_array *) function_state.function;
|
||||
original_opline_ptr = EG(opline_ptr);
|
||||
orig_free_op1 = EG(free_op1);
|
||||
orig_free_op2 = EG(free_op2);
|
||||
orig_unary_op = EG(unary_op);
|
||||
orig_binary_op = EG(binary_op);
|
||||
zend_execute(EG(active_op_array) TSRMLS_CC);
|
||||
if (!symbol_table) {
|
||||
zend_hash_destroy(EG(active_symbol_table));
|
||||
FREE_HASHTABLE(EG(active_symbol_table));
|
||||
}
|
||||
EG(active_symbol_table) = calling_symbol_table;
|
||||
EG(active_op_array) = original_op_array;
|
||||
EG(return_value_ptr_ptr)=original_return_value;
|
||||
EG(opline_ptr) = original_opline_ptr;
|
||||
EG(free_op1) = orig_free_op1;
|
||||
EG(free_op2) = orig_free_op2;
|
||||
EG(unary_op) = orig_unary_op;
|
||||
EG(binary_op) = orig_binary_op;
|
||||
} else {
|
||||
ALLOC_INIT_ZVAL(*retval_ptr_ptr);
|
||||
((zend_internal_function *) function_state.function)->handler(param_count, *retval_ptr_ptr, (object_pp?*object_pp:NULL), 1 TSRMLS_CC);
|
||||
INIT_PZVAL(*retval_ptr_ptr);
|
||||
}
|
||||
zend_ptr_stack_clear_multiple(TSRMLS_C);
|
||||
EG(function_state_ptr) = original_function_state_ptr;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC)
|
||||
{
|
||||
zval pv;
|
||||
zend_op_array *new_op_array;
|
||||
zend_op_array *original_active_op_array = EG(active_op_array);
|
||||
zend_function_state *original_function_state_ptr = EG(function_state_ptr);
|
||||
int original_handle_op_arrays;
|
||||
int retval;
|
||||
|
||||
if (retval_ptr) {
|
||||
pv.value.str.len = strlen(str)+sizeof("return ;")-1;
|
||||
pv.value.str.val = emalloc(pv.value.str.len+1);
|
||||
strcpy(pv.value.str.val, "return ");
|
||||
strcat(pv.value.str.val, str);
|
||||
strcat(pv.value.str.val, " ;");
|
||||
} else {
|
||||
pv.value.str.len = strlen(str);
|
||||
pv.value.str.val = estrndup(str, pv.value.str.len);
|
||||
}
|
||||
pv.type = IS_STRING;
|
||||
|
||||
/*printf("Evaluating '%s'\n", pv.value.str.val);*/
|
||||
|
||||
original_handle_op_arrays = CG(handle_op_arrays);
|
||||
CG(handle_op_arrays) = 0;
|
||||
new_op_array = compile_string(&pv, string_name TSRMLS_CC);
|
||||
CG(handle_op_arrays) = original_handle_op_arrays;
|
||||
|
||||
if (new_op_array) {
|
||||
zval *local_retval_ptr=NULL;
|
||||
zval **original_return_value_ptr_ptr = EG(return_value_ptr_ptr);
|
||||
zend_op **original_opline_ptr = EG(opline_ptr);
|
||||
|
||||
EG(return_value_ptr_ptr) = &local_retval_ptr;
|
||||
EG(active_op_array) = new_op_array;
|
||||
EG(no_extensions)=1;
|
||||
|
||||
zend_execute(new_op_array TSRMLS_CC);
|
||||
|
||||
if (local_retval_ptr) {
|
||||
if (retval_ptr) {
|
||||
COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr);
|
||||
} else {
|
||||
zval_ptr_dtor(&local_retval_ptr);
|
||||
}
|
||||
} else {
|
||||
if (retval_ptr) {
|
||||
INIT_ZVAL(*retval_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
EG(no_extensions)=0;
|
||||
EG(opline_ptr) = original_opline_ptr;
|
||||
EG(active_op_array) = original_active_op_array;
|
||||
EG(function_state_ptr) = original_function_state_ptr;
|
||||
destroy_op_array(new_op_array);
|
||||
efree(new_op_array);
|
||||
EG(return_value_ptr_ptr) = original_return_value_ptr_ptr;
|
||||
retval = SUCCESS;
|
||||
} else {
|
||||
retval = FAILURE;
|
||||
}
|
||||
zval_dtor(&pv);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void execute_new_code(TSRMLS_D)
|
||||
{
|
||||
zend_op *opline, *end;
|
||||
zend_op *ret_opline;
|
||||
|
||||
if (!CG(interactive)
|
||||
|| CG(active_op_array)->backpatch_count>0
|
||||
|| CG(active_op_array)->function_name
|
||||
|| CG(active_op_array)->type!=ZEND_USER_FUNCTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret_opline = get_next_op(CG(active_op_array) TSRMLS_CC);
|
||||
ret_opline->opcode = ZEND_RETURN;
|
||||
ret_opline->op1.op_type = IS_CONST;
|
||||
INIT_ZVAL(ret_opline->op1.u.constant);
|
||||
SET_UNUSED(ret_opline->op2);
|
||||
|
||||
if (!CG(active_op_array)->start_op) {
|
||||
CG(active_op_array)->start_op = CG(active_op_array)->opcodes;
|
||||
}
|
||||
|
||||
opline=CG(active_op_array)->start_op;
|
||||
end=CG(active_op_array)->opcodes+CG(active_op_array)->last;
|
||||
|
||||
while (opline<end) {
|
||||
if (opline->op1.op_type==IS_CONST) {
|
||||
opline->op1.u.constant.is_ref = 1;
|
||||
opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */
|
||||
}
|
||||
if (opline->op2.op_type==IS_CONST) {
|
||||
opline->op2.u.constant.is_ref = 1;
|
||||
opline->op2.u.constant.refcount = 2;
|
||||
}
|
||||
opline++;
|
||||
}
|
||||
|
||||
EG(active_op_array) = CG(active_op_array);
|
||||
zend_execute(CG(active_op_array) TSRMLS_CC);
|
||||
zval_ptr_dtor(EG(return_value_ptr_ptr));
|
||||
CG(active_op_array)->last--; /* get rid of that ZEND_RETURN */
|
||||
CG(active_op_array)->start_op = CG(active_op_array)->opcodes+CG(active_op_array)->last;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_timeout(int dummy)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
/* is there any point in this? we're terminating the request anyway...
|
||||
PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
|
||||
*/
|
||||
zend_error(E_ERROR, "Maximum execution time of %d second%s exceeded",
|
||||
EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
|
||||
}
|
||||
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) {
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case WM_REGISTER_ZEND_TIMEOUT:
|
||||
/* wParam is the thread id pointer, lParam is the timeout amount in seconds */
|
||||
if (lParam==0) {
|
||||
KillTimer(timeout_window, wParam);
|
||||
} else {
|
||||
SetTimer(timeout_window, wParam, lParam*1000, NULL);
|
||||
}
|
||||
break;
|
||||
case WM_UNREGISTER_ZEND_TIMEOUT:
|
||||
/* wParam is the thread id pointer */
|
||||
KillTimer(timeout_window, wParam);
|
||||
break;
|
||||
case WM_TIMER: {
|
||||
#ifdef ZTS
|
||||
void ***tsrm_ls;
|
||||
|
||||
tsrm_ls = ts_resource_ex(0, &wParam);
|
||||
if (!tsrm_ls) {
|
||||
/* Thread died before receiving its timeout? */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
KillTimer(timeout_window, wParam);
|
||||
EG(timed_out) = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd,message,wParam,lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static unsigned __stdcall timeout_thread_proc(void *pArgs)
|
||||
{
|
||||
MSG message;
|
||||
|
||||
wc.style=0;
|
||||
wc.lpfnWndProc = zend_timeout_WndProc;
|
||||
wc.cbClsExtra=0;
|
||||
wc.cbWndExtra=0;
|
||||
wc.hInstance=NULL;
|
||||
wc.hIcon=NULL;
|
||||
wc.hCursor=NULL;
|
||||
wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND + 5);
|
||||
wc.lpszMenuName=NULL;
|
||||
wc.lpszClassName = "Zend Timeout Window";
|
||||
if (!RegisterClass(&wc)) {
|
||||
return -1;
|
||||
}
|
||||
timeout_window = CreateWindow(wc.lpszClassName, wc.lpszClassName, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
|
||||
SetEvent(timeout_thread_event);
|
||||
while (GetMessage(&message, NULL, 0, 0)) {
|
||||
SendMessage(timeout_window, message.message, message.wParam, message.lParam);
|
||||
if (message.message == WM_QUIT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
DestroyWindow(timeout_window);
|
||||
UnregisterClass(wc.lpszClassName, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void zend_init_timeout_thread()
|
||||
{
|
||||
timeout_thread_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
_beginthreadex(NULL, 0, timeout_thread_proc, NULL, 0, &timeout_thread_id);
|
||||
WaitForSingleObject(timeout_thread_event, INFINITE);
|
||||
}
|
||||
|
||||
|
||||
void zend_shutdown_timeout_thread()
|
||||
{
|
||||
if (!timeout_thread_initialized) {
|
||||
return;
|
||||
}
|
||||
PostThreadMessage(timeout_thread_id, WM_QUIT, 0, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* This one doesn't exists on QNX */
|
||||
#ifndef SIGPROF
|
||||
#define SIGPROF 27
|
||||
#endif
|
||||
|
||||
void zend_set_timeout(long seconds)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
EG(timeout_seconds) = seconds;
|
||||
#ifdef ZEND_WIN32
|
||||
if (timeout_thread_initialized==0 && InterlockedIncrement(&timeout_thread_initialized)==1) {
|
||||
/* We start up this process-wide thread here and not in zend_startup(), because if Zend
|
||||
* is initialized inside a DllMain(), you're not supposed to start threads from it.
|
||||
*/
|
||||
zend_init_timeout_thread();
|
||||
}
|
||||
PostThreadMessage(timeout_thread_id, WM_REGISTER_ZEND_TIMEOUT, (WPARAM) GetCurrentThreadId(), (LPARAM) seconds);
|
||||
#else
|
||||
# ifdef HAVE_SETITIMER
|
||||
{
|
||||
struct itimerval t_r; /* timeout requested */
|
||||
sigset_t sigset;
|
||||
|
||||
t_r.it_value.tv_sec = seconds;
|
||||
t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;
|
||||
|
||||
setitimer(ITIMER_PROF, &t_r, NULL);
|
||||
signal(SIGPROF, zend_timeout);
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGPROF);
|
||||
sigprocmask(SIG_UNBLOCK,&sigset,NULL);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void zend_unset_timeout(TSRMLS_D)
|
||||
{
|
||||
#ifdef ZEND_WIN32
|
||||
PostThreadMessage(timeout_thread_id, WM_UNREGISTER_ZEND_TIMEOUT, (WPARAM) GetCurrentThreadId(), (LPARAM) 0);
|
||||
#else
|
||||
# ifdef HAVE_SETITIMER
|
||||
{
|
||||
struct itimerval no_timeout;
|
||||
|
||||
no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
|
||||
|
||||
setitimer(ITIMER_PROF, &no_timeout, NULL);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef ZEND_EXECUTE_LOCKS_H
|
||||
#define ZEND_EXECUTE_LOCKS_H
|
||||
|
||||
#define PZVAL_LOCK(z) zend_pzval_lock_func(z)
|
||||
|
||||
static inline void zend_pzval_lock_func(zval *z)
|
||||
{
|
||||
((z)->refcount++);
|
||||
}
|
||||
|
||||
#define PZVAL_UNLOCK(z) zend_pzval_unlock_func(z TSRMLS_CC)
|
||||
|
||||
static inline void zend_pzval_unlock_func(zval *z TSRMLS_DC)
|
||||
{
|
||||
((z)->refcount--);
|
||||
if (!(z)->refcount) {
|
||||
(z)->refcount = 1;
|
||||
(z)->is_ref = 0;
|
||||
EG(garbage)[EG(garbage_ptr)++] = (z);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void zend_clean_garbage(TSRMLS_D)
|
||||
{
|
||||
while (EG(garbage_ptr)) {
|
||||
zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]);
|
||||
}
|
||||
}
|
||||
|
||||
#define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(pzv); }
|
||||
|
||||
#endif /* ZEND_EXECUTE_LOCKS_H */
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "zend_extensions.h"
|
||||
|
||||
ZEND_API zend_llist zend_extensions;
|
||||
static int last_resource_number;
|
||||
|
||||
int zend_load_extension(char *path)
|
||||
{
|
||||
#if ZEND_EXTENSIONS_SUPPORT
|
||||
DL_HANDLE handle;
|
||||
zend_extension *new_extension;
|
||||
zend_extension_version_info *extension_version_info;
|
||||
|
||||
handle = DL_LOAD(path);
|
||||
if (!handle) {
|
||||
#ifndef ZEND_WIN32
|
||||
fprintf(stderr, "Failed loading %s: %s\n", path, dlerror());
|
||||
#else
|
||||
fprintf(stderr, "Failed loading %s\n", path);
|
||||
#endif
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
extension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, "extension_version_info");
|
||||
new_extension = (zend_extension *) DL_FETCH_SYMBOL(handle, "zend_extension_entry");
|
||||
if (!extension_version_info || !new_extension) {
|
||||
fprintf(stderr, "%s doesn't appear to be a valid Zend extension\n", path);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/* allow extension to proclaim compatibility with any Zend version */
|
||||
if (extension_version_info->zend_extension_api_no != ZEND_EXTENSION_API_NO &&(!new_extension->api_no_check || new_extension->api_no_check(ZEND_EXTENSION_API_NO) != SUCCESS)) {
|
||||
if (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) {
|
||||
fprintf(stderr, "%s requires Zend Engine API version %d\n"
|
||||
"The installed Zend Engine API version is %d\n\n",
|
||||
new_extension->name,
|
||||
extension_version_info->zend_extension_api_no,
|
||||
ZEND_EXTENSION_API_NO);
|
||||
DL_UNLOAD(handle);
|
||||
return FAILURE;
|
||||
} else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) {
|
||||
fprintf(stderr, "%s designed to be used with the Zend Engine API %d is outdated\n"
|
||||
"It requires a more recent version of the Zend Engine\n"
|
||||
"The installed Zend Engine API version is %d\n"
|
||||
"Contact %s at %s for a later version of this module.\n\n",
|
||||
new_extension->name,
|
||||
extension_version_info->zend_extension_api_no,
|
||||
ZEND_EXTENSION_API_NO,
|
||||
new_extension->author,
|
||||
new_extension->URL);
|
||||
DL_UNLOAD(handle);
|
||||
return FAILURE;
|
||||
}
|
||||
} else if (ZTS_V!=extension_version_info->thread_safe) {
|
||||
fprintf(stderr, "Cannot load %s - it %s thread safe, whereas Zend %s\n",
|
||||
new_extension->name,
|
||||
(extension_version_info->thread_safe?"is":"isn't"),
|
||||
(ZTS_V?"is":"isn't"));
|
||||
DL_UNLOAD(handle);
|
||||
return FAILURE;
|
||||
} else if (ZEND_DEBUG!=extension_version_info->debug) {
|
||||
fprintf(stderr, "Cannot load %s - it %s debug information, whereas Zend %s\n",
|
||||
new_extension->name,
|
||||
(extension_version_info->debug?"contains":"does not contain"),
|
||||
(ZEND_DEBUG?"does":"does not"));
|
||||
DL_UNLOAD(handle);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return zend_register_extension(new_extension, handle);
|
||||
#else
|
||||
fprintf(stderr, "Extensions are not supported on this platform.\n");
|
||||
return FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle)
|
||||
{
|
||||
#if ZEND_EXTENSIONS_SUPPORT
|
||||
zend_extension extension;
|
||||
|
||||
extension = *new_extension;
|
||||
extension.handle = handle;
|
||||
|
||||
zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension);
|
||||
|
||||
zend_llist_add_element(&zend_extensions, &extension);
|
||||
|
||||
/*fprintf(stderr, "Loaded %s, version %s\n", extension.name, extension.version);*/
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void zend_extension_shutdown(zend_extension *extension TSRMLS_DC)
|
||||
{
|
||||
#if ZEND_EXTENSIONS_SUPPORT
|
||||
if (extension->shutdown) {
|
||||
extension->shutdown(extension);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int zend_extension_startup(zend_extension *extension)
|
||||
{
|
||||
#if ZEND_EXTENSIONS_SUPPORT
|
||||
if (extension->startup) {
|
||||
if (extension->startup(extension)!=SUCCESS) {
|
||||
return 1;
|
||||
}
|
||||
zend_append_version_info(extension);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int zend_startup_extensions_mechanism()
|
||||
{
|
||||
/* Startup extensions mechanism */
|
||||
zend_llist_init(&zend_extensions, sizeof(zend_extension), (void (*)(void *)) zend_extension_dtor, 1);
|
||||
last_resource_number = 0;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int zend_startup_extensions()
|
||||
{
|
||||
zend_llist_apply_with_del(&zend_extensions, (int (*)(void *)) zend_extension_startup);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void zend_shutdown_extensions(TSRMLS_D)
|
||||
{
|
||||
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_shutdown TSRMLS_CC);
|
||||
zend_llist_destroy(&zend_extensions);
|
||||
}
|
||||
|
||||
|
||||
void zend_extension_dtor(zend_extension *extension)
|
||||
{
|
||||
#if ZEND_EXTENSIONS_SUPPORT && !ZEND_DEBUG
|
||||
if (extension->handle) {
|
||||
DL_UNLOAD(extension->handle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void zend_extension_message_dispatcher(zend_extension *extension, int num_args, va_list args TSRMLS_DC)
|
||||
{
|
||||
int message;
|
||||
void *arg;
|
||||
|
||||
if (!extension->message_handler || num_args!=2) {
|
||||
return;
|
||||
}
|
||||
message = va_arg(args, int);
|
||||
arg = va_arg(args, void *);
|
||||
extension->message_handler(message, arg);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_extension_dispatch_message(int message, void *arg)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
zend_llist_apply_with_arguments(&zend_extensions, (llist_apply_with_args_func_t) zend_extension_message_dispatcher TSRMLS_CC, 2, message, arg);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_get_resource_handle(zend_extension *extension)
|
||||
{
|
||||
if (last_resource_number<ZEND_MAX_RESERVED_RESOURCES) {
|
||||
extension->resource_number = last_resource_number;
|
||||
return last_resource_number++;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API zend_extension *zend_get_extension(char *extension_name)
|
||||
{
|
||||
zend_llist_element *element;
|
||||
|
||||
for (element = zend_extensions.head; element; element = element->next) {
|
||||
zend_extension *extension = (zend_extension *) element->data;
|
||||
|
||||
if (!strcmp(extension->name, extension_name)) {
|
||||
return extension;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_EXTENSIONS_H
|
||||
#define ZEND_EXTENSIONS_H
|
||||
|
||||
#include "zend_compile.h"
|
||||
|
||||
#define ZEND_EXTENSION_API_NO 20010710
|
||||
|
||||
typedef struct _zend_extension_version_info {
|
||||
int zend_extension_api_no;
|
||||
char *required_zend_version;
|
||||
unsigned char thread_safe;
|
||||
unsigned char debug;
|
||||
} zend_extension_version_info;
|
||||
|
||||
|
||||
typedef struct _zend_extension zend_extension;
|
||||
|
||||
/* Typedef's for zend_extension function pointers */
|
||||
typedef int (*startup_func_t)(zend_extension *extension);
|
||||
typedef void (*shutdown_func_t)(zend_extension *extension);
|
||||
typedef void (*activate_func_t)(void);
|
||||
typedef void (*deactivate_func_t)(void);
|
||||
|
||||
typedef void (*message_handler_func_t)(int message, void *arg);
|
||||
|
||||
typedef void (*op_array_handler_func_t)(zend_op_array *op_array);
|
||||
|
||||
typedef void (*statement_handler_func_t)(zend_op_array *op_array);
|
||||
typedef void (*fcall_begin_handler_func_t)(zend_op_array *op_array);
|
||||
typedef void (*fcall_end_handler_func_t)(zend_op_array *op_array);
|
||||
|
||||
typedef void (*op_array_ctor_func_t)(zend_op_array *op_array);
|
||||
typedef void (*op_array_dtor_func_t)(zend_op_array *op_array);
|
||||
|
||||
struct _zend_extension {
|
||||
char *name;
|
||||
char *version;
|
||||
char *author;
|
||||
char *URL;
|
||||
char *copyright;
|
||||
|
||||
startup_func_t startup;
|
||||
shutdown_func_t shutdown;
|
||||
activate_func_t activate;
|
||||
deactivate_func_t deactivate;
|
||||
|
||||
message_handler_func_t message_handler;
|
||||
|
||||
op_array_handler_func_t op_array_handler;
|
||||
|
||||
statement_handler_func_t statement_handler;
|
||||
fcall_begin_handler_func_t fcall_begin_handler;
|
||||
fcall_end_handler_func_t fcall_end_handler;
|
||||
|
||||
op_array_ctor_func_t op_array_ctor;
|
||||
op_array_dtor_func_t op_array_dtor;
|
||||
|
||||
int (*api_no_check)(int api_no);
|
||||
void *reserved2;
|
||||
void *reserved3;
|
||||
void *reserved4;
|
||||
void *reserved5;
|
||||
void *reserved6;
|
||||
void *reserved7;
|
||||
void *reserved8;
|
||||
|
||||
DL_HANDLE handle;
|
||||
int resource_number;
|
||||
};
|
||||
|
||||
|
||||
ZEND_API int zend_get_resource_handle(zend_extension *extension);
|
||||
ZEND_API void zend_extension_dispatch_message(int message, void *arg);
|
||||
|
||||
#define ZEND_EXTMSG_NEW_EXTENSION 1
|
||||
|
||||
|
||||
#define ZEND_EXTENSION() \
|
||||
ZEND_EXT_API zend_extension_version_info extension_version_info = { ZEND_EXTENSION_API_NO, ZEND_VERSION, ZTS_V, ZEND_DEBUG }
|
||||
|
||||
#define STANDARD_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
|
||||
#define COMPAT_ZEND_EXTENSION_PROPERTIES NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1
|
||||
|
||||
|
||||
ZEND_API extern zend_llist zend_extensions;
|
||||
|
||||
void zend_extension_dtor(zend_extension *extension);
|
||||
ZEND_API int zend_load_extension(char *path);
|
||||
ZEND_API int zend_register_extension(zend_extension *new_extension, DL_HANDLE handle);
|
||||
void zend_append_version_info(zend_extension *extension);
|
||||
int zend_startup_extensions_mechanism(void);
|
||||
int zend_startup_extensions(void);
|
||||
void zend_shutdown_extensions(TSRMLS_D);
|
||||
ZEND_API zend_extension *zend_get_extension(char *extension_name);
|
||||
|
||||
#endif /* ZEND_EXTENSIONS_H */
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_FAST_CACHE_H
|
||||
#define ZEND_FAST_CACHE_H
|
||||
|
||||
#ifndef ZEND_ENABLE_FAST_CACHE
|
||||
# if ZEND_DEBUG
|
||||
# define ZEND_ENABLE_FAST_CACHE 0
|
||||
# else
|
||||
# define ZEND_ENABLE_FAST_CACHE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct _zend_fast_cache_list_entry {
|
||||
struct _zend_fast_cache_list_entry *next;
|
||||
} zend_fast_cache_list_entry;
|
||||
|
||||
#define MAX_FAST_CACHE_TYPES 4
|
||||
|
||||
|
||||
#define ZVAL_CACHE_LIST 0
|
||||
#define HASHTABLE_CACHE_LIST 1
|
||||
|
||||
#if ZEND_ENABLE_FAST_CACHE
|
||||
|
||||
|
||||
#include "zend_globals.h"
|
||||
#include "zend_globals_macros.h"
|
||||
#include "zend_alloc.h"
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
# define RECORD_ZVAL_CACHE_HIT(fc_type) AG(fast_cache_stats)[fc_type][1]++;
|
||||
# define RECORD_ZVAL_CACHE_MISS(fc_type) AG(fast_cache_stats)[fc_type][0]++;
|
||||
#else
|
||||
# define RECORD_ZVAL_CACHE_HIT(fc_type)
|
||||
# define RECORD_ZVAL_CACHE_MISS(fc_type)
|
||||
#endif
|
||||
|
||||
|
||||
#define ZEND_FAST_ALLOC(p, type, fc_type) \
|
||||
{ \
|
||||
TSRMLS_FETCH(); \
|
||||
\
|
||||
if (((p) = (type *) AG(fast_cache_list_head)[fc_type])) { \
|
||||
AG(fast_cache_list_head)[fc_type] = ((zend_fast_cache_list_entry *) AG(fast_cache_list_head)[fc_type])->next; \
|
||||
RECORD_ZVAL_CACHE_HIT(fc_type); \
|
||||
} else { \
|
||||
(p) = (type *) emalloc(sizeof(type)); \
|
||||
RECORD_ZVAL_CACHE_MISS(fc_type); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define ZEND_FAST_FREE(p, fc_type) \
|
||||
{ \
|
||||
TSRMLS_FETCH(); \
|
||||
\
|
||||
((zend_fast_cache_list_entry *) (p))->next = (zend_fast_cache_list_entry *) AG(fast_cache_list_head)[fc_type]; \
|
||||
AG(fast_cache_list_head)[fc_type] = (zend_fast_cache_list_entry *) (p); \
|
||||
}
|
||||
|
||||
#define ZEND_FAST_ALLOC_REL(p, type, fc_type) \
|
||||
ZEND_FAST_ALLOC(p, type, fc_type)
|
||||
|
||||
#define ZEND_FAST_FREE_REL(p, fc_type) \
|
||||
ZEND_FAST_FREE(p, fc_type)
|
||||
|
||||
|
||||
#else /* !ZEND_ENABLE_FAST_CACHE */
|
||||
|
||||
#define ZEND_FAST_ALLOC(p, type, fc_type) \
|
||||
(p) = (type *) emalloc(sizeof(type))
|
||||
|
||||
#define ZEND_FAST_FREE(p, fc_type) \
|
||||
efree(p)
|
||||
|
||||
#define ZEND_FAST_ALLOC_REL(p, type, fc_type) \
|
||||
(p) = (type *) emalloc_rel(sizeof(type))
|
||||
|
||||
#define ZEND_FAST_FREE_REL(p, fc_type) \
|
||||
efree_rel(p)
|
||||
|
||||
#endif /* ZEND_ENABLE_FAST_CACHE */
|
||||
|
||||
|
||||
|
||||
|
||||
/* fast cache for zval's */
|
||||
#define ALLOC_ZVAL(z) \
|
||||
ZEND_FAST_ALLOC(z, zval, ZVAL_CACHE_LIST)
|
||||
|
||||
#define FREE_ZVAL(z) \
|
||||
ZEND_FAST_FREE(z, ZVAL_CACHE_LIST)
|
||||
|
||||
#define ALLOC_ZVAL_REL(z) \
|
||||
ZEND_FAST_ALLOC_REL(z, zval, ZVAL_CACHE_LIST)
|
||||
|
||||
#define FREE_ZVAL_REL(z) \
|
||||
ZEND_FAST_FREE_REL(z, ZVAL_CACHE_LIST)
|
||||
|
||||
/* fast cache for HashTables */
|
||||
#define ALLOC_HASHTABLE(ht) \
|
||||
ZEND_FAST_ALLOC(ht, HashTable, HASHTABLE_CACHE_LIST)
|
||||
|
||||
#define FREE_HASHTABLE(ht) \
|
||||
ZEND_FAST_FREE(ht, HASHTABLE_CACHE_LIST)
|
||||
|
||||
#define ALLOC_HASHTABLE_REL(ht) \
|
||||
ZEND_FAST_ALLOC_REL(ht, HashTable, HASHTABLE_CACHE_LIST)
|
||||
|
||||
#define FREE_HASHTABLE_REL(ht) \
|
||||
ZEND_FAST_FREE_REL(ht, HASHTABLE_CACHE_LIST)
|
||||
|
||||
#endif /* ZEND_FAST_CACHE_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_GLOBALS_H
|
||||
#define ZEND_GLOBALS_H
|
||||
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include "zend_globals_macros.h"
|
||||
|
||||
#include "zend_stack.h"
|
||||
#include "zend_ptr_stack.h"
|
||||
#include "zend_hash.h"
|
||||
#include "zend_llist.h"
|
||||
#include "zend_fast_cache.h"
|
||||
|
||||
/* Define ZTS if you want a thread-safe Zend */
|
||||
/*#undef ZTS*/
|
||||
|
||||
#ifdef ZTS
|
||||
#ifdef __cplusplus
|
||||
class ZendFlexLexer;
|
||||
class ZendIniFlexLexer;
|
||||
#endif
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API extern int compiler_globals_id;
|
||||
ZEND_API extern int executor_globals_id;
|
||||
ZEND_API extern int alloc_globals_id;
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif
|
||||
|
||||
#define SYMTABLE_CACHE_SIZE 32
|
||||
|
||||
|
||||
#include "zend_compile.h"
|
||||
|
||||
/* excpt.h on Digital Unix 4.0 defines function_table */
|
||||
#undef function_table
|
||||
|
||||
|
||||
typedef struct _zend_declarables {
|
||||
zval ticks;
|
||||
} zend_declarables;
|
||||
|
||||
|
||||
struct _zend_compiler_globals {
|
||||
zend_stack bp_stack;
|
||||
zend_stack switch_cond_stack;
|
||||
zend_stack foreach_copy_stack;
|
||||
zend_stack object_stack;
|
||||
zend_stack declare_stack;
|
||||
|
||||
zend_class_entry class_entry, *active_class_entry;
|
||||
zval active_ce_parent_class_name;
|
||||
|
||||
/* variables for list() compilation */
|
||||
zend_llist list_llist;
|
||||
zend_llist dimension_llist;
|
||||
zend_stack list_stack;
|
||||
|
||||
zend_stack function_call_stack;
|
||||
|
||||
char *compiled_filename;
|
||||
|
||||
int zend_lineno;
|
||||
int comment_start_line;
|
||||
char *heredoc;
|
||||
int heredoc_len;
|
||||
|
||||
zend_op_array *active_op_array;
|
||||
|
||||
HashTable *function_table; /* function symbol table */
|
||||
HashTable *class_table; /* class table */
|
||||
|
||||
HashTable filenames_table;
|
||||
|
||||
zend_bool in_compilation;
|
||||
zend_bool short_tags;
|
||||
zend_bool asp_tags;
|
||||
zend_bool allow_call_time_pass_reference;
|
||||
|
||||
zend_declarables declarables;
|
||||
|
||||
/* For extensions support */
|
||||
zend_bool extended_info; /* generate extension information for debugger/profiler */
|
||||
zend_bool handle_op_arrays; /* run op_arrays through op_array handlers */
|
||||
|
||||
zend_bool unclean_shutdown;
|
||||
|
||||
zend_bool ini_parser_unbuffered_errors;
|
||||
|
||||
zend_llist open_files;
|
||||
|
||||
#if defined(ZTS) && defined(__cplusplus)
|
||||
ZendFlexLexer *ZFL;
|
||||
ZendIniFlexLexer *ini_scanner;
|
||||
#else
|
||||
void *ZFL;
|
||||
void *ini_parser;
|
||||
#endif
|
||||
|
||||
struct _zend_ini_parser_param *ini_parser_param;
|
||||
|
||||
int interactive;
|
||||
|
||||
zend_bool increment_lineno;
|
||||
};
|
||||
|
||||
|
||||
struct _zend_executor_globals {
|
||||
zval **return_value_ptr_ptr;
|
||||
|
||||
zval uninitialized_zval;
|
||||
zval *uninitialized_zval_ptr;
|
||||
|
||||
zval error_zval;
|
||||
zval *error_zval_ptr;
|
||||
|
||||
zend_function_state *function_state_ptr;
|
||||
zend_ptr_stack arg_types_stack;
|
||||
|
||||
/* for global return() support */
|
||||
zval *global_return_value_ptr;
|
||||
|
||||
/* symbol table cache */
|
||||
HashTable *symtable_cache[SYMTABLE_CACHE_SIZE];
|
||||
HashTable **symtable_cache_limit;
|
||||
HashTable **symtable_cache_ptr;
|
||||
|
||||
zend_op **opline_ptr;
|
||||
|
||||
HashTable *active_symbol_table;
|
||||
HashTable symbol_table; /* main symbol table */
|
||||
|
||||
HashTable included_files; /* files already included */
|
||||
|
||||
jmp_buf bailout;
|
||||
|
||||
int error_reporting;
|
||||
int orig_error_reporting;
|
||||
int exit_status;
|
||||
|
||||
zend_op_array *active_op_array;
|
||||
|
||||
HashTable *function_table; /* function symbol table */
|
||||
HashTable *class_table; /* class table */
|
||||
HashTable *zend_constants; /* constants table */
|
||||
|
||||
long precision;
|
||||
|
||||
int ticks_count;
|
||||
|
||||
zend_bool in_execution;
|
||||
zend_bool bailout_set;
|
||||
|
||||
/* for extended information support */
|
||||
zend_bool no_extensions;
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
zend_bool timed_out;
|
||||
#endif
|
||||
|
||||
HashTable regular_list;
|
||||
HashTable persistent_list;
|
||||
|
||||
zend_ptr_stack argument_stack;
|
||||
int free_op1, free_op2;
|
||||
int (*unary_op)(zval *result, zval *op1);
|
||||
int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
|
||||
zval *garbage[2];
|
||||
int garbage_ptr;
|
||||
|
||||
zval *user_error_handler;
|
||||
zend_ptr_stack user_error_handlers;
|
||||
|
||||
/* timeout support */
|
||||
int timeout_seconds;
|
||||
|
||||
int lambda_count;
|
||||
|
||||
HashTable ini_directives;
|
||||
|
||||
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
|
||||
};
|
||||
|
||||
|
||||
struct _zend_alloc_globals {
|
||||
zend_mem_header *head; /* standard list */
|
||||
zend_mem_header *phead; /* persistent list */
|
||||
void *cache[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES];
|
||||
unsigned int cache_count[MAX_CACHED_MEMORY];
|
||||
void *fast_cache_list_head[MAX_FAST_CACHE_TYPES];
|
||||
|
||||
#ifdef ZEND_WIN32
|
||||
HANDLE memory_heap;
|
||||
#endif
|
||||
|
||||
#if ZEND_DEBUG
|
||||
/* for performance tuning */
|
||||
int cache_stats[MAX_CACHED_MEMORY][2];
|
||||
int fast_cache_stats[MAX_FAST_CACHE_TYPES][2];
|
||||
#endif
|
||||
#if MEMORY_LIMIT
|
||||
unsigned int memory_limit;
|
||||
unsigned int allocated_memory;
|
||||
unsigned int allocated_memory_peak;
|
||||
unsigned char memory_exhausted;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct _zend_scanner_globals {
|
||||
FILE *yyin;
|
||||
FILE *yyout;
|
||||
int yy_leng;
|
||||
char *yy_text;
|
||||
struct yy_buffer_state *current_buffer;
|
||||
char *c_buf_p;
|
||||
int init;
|
||||
int start;
|
||||
};
|
||||
|
||||
#endif /* ZEND_GLOBALS_H */
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_GLOBALS_MACROS_H
|
||||
#define ZEND_GLOBALS_MACROS_H
|
||||
|
||||
typedef struct _zend_compiler_globals zend_compiler_globals;
|
||||
typedef struct _zend_executor_globals zend_executor_globals;
|
||||
typedef struct _zend_alloc_globals zend_alloc_globals;
|
||||
typedef struct _zend_scanner_globals zend_scanner_globals;
|
||||
|
||||
/* Compiler */
|
||||
#ifdef ZTS
|
||||
# define CG(v) TSRMG(compiler_globals_id, zend_compiler_globals *, v)
|
||||
BEGIN_EXTERN_C()
|
||||
int zendparse(void *compiler_globals);
|
||||
END_EXTERN_C()
|
||||
#else
|
||||
# define CG(v) (compiler_globals.v)
|
||||
extern ZEND_API struct _zend_compiler_globals compiler_globals;
|
||||
int zendparse(void);
|
||||
#endif
|
||||
|
||||
|
||||
/* Executor */
|
||||
#ifdef ZTS
|
||||
# define EG(v) TSRMG(executor_globals_id, zend_executor_globals *, v)
|
||||
#else
|
||||
# define EG(v) (executor_globals.v)
|
||||
extern ZEND_API zend_executor_globals executor_globals;
|
||||
#endif
|
||||
|
||||
|
||||
/* Memory Manager */
|
||||
#ifdef ZTS
|
||||
# define AG(v) TSRMG(alloc_globals_id, zend_alloc_globals *, v)
|
||||
#else
|
||||
# define AG(v) (alloc_globals.v)
|
||||
extern ZEND_API zend_alloc_globals alloc_globals;
|
||||
#endif
|
||||
|
||||
|
||||
/* Language Scanner */
|
||||
#ifdef ZTS
|
||||
# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_scanner_globals *, v)
|
||||
extern ZEND_API ts_rsrc_id language_scanner_globals_id;
|
||||
#else
|
||||
# define LANG_SCNG(v) (language_scanner_globals.v)
|
||||
extern ZEND_API zend_scanner_globals language_scanner_globals;
|
||||
#endif
|
||||
|
||||
|
||||
/* INI Scanner */
|
||||
#ifdef ZTS
|
||||
# define INI_SCNG(v) TSRMG(ini_scanner_globals_id, zend_scanner_globals *, v)
|
||||
extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
|
||||
#else
|
||||
# define INI_SCNG(v) (ini_scanner_globals.v)
|
||||
extern ZEND_API zend_scanner_globals ini_scanner_globals;
|
||||
#endif
|
||||
|
||||
|
||||
/* For limited downwards source compatibility */
|
||||
#define CLS_FETCH()
|
||||
#define ELS_FETCH()
|
||||
#define ALS_FETCH()
|
||||
#define PLS_FETCH()
|
||||
#define SLS_FETCH()
|
||||
#define CLS_D
|
||||
#define ELS_D
|
||||
#define ALS_D
|
||||
#define PLS_D
|
||||
#define SLS_D
|
||||
#define CLS_DC
|
||||
#define ELS_DC
|
||||
#define ALS_DC
|
||||
#define PLS_DC
|
||||
#define SLS_DC
|
||||
#define CLS_C
|
||||
#define ELS_C
|
||||
#define ALS_C
|
||||
#define PLS_C
|
||||
#define SLS_C
|
||||
#define CLS_CC
|
||||
#define ELS_CC
|
||||
#define ALS_CC
|
||||
#define PLS_CC
|
||||
#define SLS_CC
|
||||
|
||||
|
||||
#endif /* ZEND_GLOBALS_MACROS_H */
|
||||
|
||||
+1307
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef ZEND_HASH_H
|
||||
#define ZEND_HASH_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define HASH_KEY_IS_STRING 1
|
||||
#define HASH_KEY_IS_LONG 2
|
||||
#define HASH_KEY_NON_EXISTANT 3
|
||||
|
||||
#define HASH_UPDATE (1<<0)
|
||||
#define HASH_ADD (1<<1)
|
||||
#define HASH_NEXT_INSERT (1<<2)
|
||||
|
||||
#define HASH_DEL_KEY 0
|
||||
#define HASH_DEL_INDEX 1
|
||||
|
||||
typedef ulong (*hash_func_t)(char *arKey, uint nKeyLength);
|
||||
typedef int (*compare_func_t)(const void *, const void *);
|
||||
typedef void (*sort_func_t)(void *, size_t, register size_t, compare_func_t);
|
||||
typedef void (*dtor_func_t)(void *pDest);
|
||||
typedef void (*copy_ctor_func_t)(void *pElement);
|
||||
|
||||
struct _hashtable;
|
||||
|
||||
typedef struct bucket {
|
||||
ulong h; /* Used for numeric indexing */
|
||||
uint nKeyLength;
|
||||
void *pData;
|
||||
void *pDataPtr;
|
||||
struct bucket *pListNext;
|
||||
struct bucket *pListLast;
|
||||
struct bucket *pNext;
|
||||
struct bucket *pLast;
|
||||
char arKey[1]; /* Must be last element */
|
||||
} Bucket;
|
||||
|
||||
typedef struct _hashtable {
|
||||
uint nTableSize;
|
||||
uint nTableMask;
|
||||
uint nNumOfElements;
|
||||
ulong nNextFreeElement;
|
||||
Bucket *pInternalPointer; /* Used for element traversal */
|
||||
Bucket *pListHead;
|
||||
Bucket *pListTail;
|
||||
Bucket **arBuckets;
|
||||
dtor_func_t pDestructor;
|
||||
zend_bool persistent;
|
||||
unsigned char nApplyCount;
|
||||
zend_bool bApplyProtection;
|
||||
#if ZEND_DEBUG
|
||||
int inconsistent;
|
||||
#endif
|
||||
} HashTable;
|
||||
|
||||
typedef Bucket* HashPosition;
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
|
||||
/* startup/shutdown */
|
||||
ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, int persistent);
|
||||
ZEND_API int zend_hash_init_ex(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, int persistent, zend_bool bApplyProtection);
|
||||
ZEND_API void zend_hash_destroy(HashTable *ht);
|
||||
ZEND_API void zend_hash_clean(HashTable *ht);
|
||||
|
||||
/* additions/updates/changes */
|
||||
ZEND_API int zend_hash_add_or_update(HashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest,int flag);
|
||||
#define zend_hash_update(ht,arKey,nKeyLength,pData,nDataSize,pDest) \
|
||||
zend_hash_add_or_update(ht,arKey,nKeyLength,pData,nDataSize,pDest,HASH_UPDATE)
|
||||
#define zend_hash_add(ht,arKey,nKeyLength,pData,nDataSize,pDest) \
|
||||
zend_hash_add_or_update(ht,arKey,nKeyLength,pData,nDataSize,pDest,HASH_ADD)
|
||||
|
||||
ZEND_API int zend_hash_quick_add_or_update(HashTable *ht, char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest,int flag);
|
||||
#define zend_hash_quick_update(ht,arKey,nKeyLength,h,pData,nDataSize,pDest) \
|
||||
zend_hash_quick_add_or_update(ht,arKey,nKeyLength,h,pData,nDataSize,pDest,HASH_UPDATE)
|
||||
#define zend_hash_quick_add(ht,arKey,nKeyLength,h,pData,nDataSize,pDest) \
|
||||
zend_hash_quick_add_or_update(ht,arKey,nKeyLength,h,pData,nDataSize,pDest,HASH_ADD)
|
||||
|
||||
ZEND_API int zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, void *pData, uint nDataSize, void **pDest, int flag);
|
||||
#define zend_hash_index_update(ht,h,pData,nDataSize,pDest) \
|
||||
zend_hash_index_update_or_next_insert(ht,h,pData,nDataSize,pDest,HASH_UPDATE)
|
||||
#define zend_hash_next_index_insert(ht,pData,nDataSize,pDest) \
|
||||
zend_hash_index_update_or_next_insert(ht,0,pData,nDataSize,pDest,HASH_NEXT_INSERT)
|
||||
|
||||
ZEND_API int zend_hash_add_empty_element(HashTable *ht, char *arKey, uint nKeyLength);
|
||||
|
||||
|
||||
#define ZEND_HASH_APPLY_KEEP 0
|
||||
#define ZEND_HASH_APPLY_REMOVE 1<<0
|
||||
#define ZEND_HASH_APPLY_STOP 1<<1
|
||||
|
||||
typedef struct _zend_hash_key {
|
||||
char *arKey;
|
||||
uint nKeyLength;
|
||||
ulong h;
|
||||
} zend_hash_key;
|
||||
|
||||
|
||||
typedef int (*apply_func_t)(void *pDest TSRMLS_DC);
|
||||
typedef int (*apply_func_arg_t)(void *pDest, void *argument TSRMLS_DC);
|
||||
typedef int (*apply_func_args_t)(void *pDest, int num_args, va_list args, zend_hash_key *hash_key);
|
||||
|
||||
ZEND_API void zend_hash_graceful_destroy(HashTable *ht);
|
||||
ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC);
|
||||
ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void * TSRMLS_DC);
|
||||
ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);
|
||||
|
||||
/* This function should be used with special care (in other words,
|
||||
* it should usually not be used). When used with the ZEND_HASH_APPLY_STOP
|
||||
* return value, it assumes things about the order of the elements in the hash.
|
||||
* Also, it does not provide the same kind of reentrancy protection that
|
||||
* the standard apply functions do.
|
||||
*/
|
||||
ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC);
|
||||
|
||||
|
||||
/* Deletes */
|
||||
ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLength, ulong h, int flag);
|
||||
#define zend_hash_del(ht,arKey,nKeyLength) \
|
||||
zend_hash_del_key_or_index(ht,arKey,nKeyLength,0,HASH_DEL_KEY)
|
||||
#define zend_hash_index_del(ht,h) \
|
||||
zend_hash_del_key_or_index(ht,NULL,0,h,HASH_DEL_INDEX)
|
||||
|
||||
ZEND_API ulong zend_get_hash_value(HashTable *ht, char *arKey, uint nKeyLength);
|
||||
|
||||
/* Data retreival */
|
||||
ZEND_API int zend_hash_find(HashTable *ht, char *arKey, uint nKeyLength, void **pData);
|
||||
ZEND_API int zend_hash_quick_find(HashTable *ht, char *arKey, uint nKeyLength, ulong h, void **pData);
|
||||
ZEND_API int zend_hash_index_find(HashTable *ht, ulong h, void **pData);
|
||||
|
||||
/* Misc */
|
||||
ZEND_API int zend_hash_exists(HashTable *ht, char *arKey, uint nKeyLength);
|
||||
ZEND_API int zend_hash_index_exists(HashTable *ht, ulong h);
|
||||
ZEND_API ulong zend_hash_next_free_element(HashTable *ht);
|
||||
|
||||
/* traversing */
|
||||
ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos);
|
||||
ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos);
|
||||
ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, ulong *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos);
|
||||
ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos);
|
||||
ZEND_API int zend_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos);
|
||||
ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos);
|
||||
ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos);
|
||||
|
||||
#define zend_hash_move_forward(ht) \
|
||||
zend_hash_move_forward_ex(ht, NULL)
|
||||
#define zend_hash_move_backwards(ht) \
|
||||
zend_hash_move_backwards_ex(ht, NULL)
|
||||
#define zend_hash_get_current_key(ht, str_index, num_index, duplicate) \
|
||||
zend_hash_get_current_key_ex(ht, str_index, NULL, num_index, duplicate, NULL)
|
||||
#define zend_hash_get_current_key_type(ht) \
|
||||
zend_hash_get_current_key_type_ex(ht, NULL)
|
||||
#define zend_hash_get_current_data(ht, pData) \
|
||||
zend_hash_get_current_data_ex(ht, pData, NULL)
|
||||
#define zend_hash_internal_pointer_reset(ht) \
|
||||
zend_hash_internal_pointer_reset_ex(ht, NULL)
|
||||
#define zend_hash_internal_pointer_end(ht) \
|
||||
zend_hash_internal_pointer_end_ex(ht, NULL)
|
||||
|
||||
/* Copying, merging and sorting */
|
||||
ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size);
|
||||
ZEND_API void zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite);
|
||||
ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, uint size, zend_bool (*pReplaceOrig)(void *orig, void *p_new));
|
||||
ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber);
|
||||
ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC);
|
||||
ZEND_API int zend_hash_minmax(HashTable *ht, int (*compar)(const void *, const void *), int flag, void **pData);
|
||||
|
||||
ZEND_API int zend_hash_num_elements(HashTable *ht);
|
||||
|
||||
ZEND_API int zend_hash_rehash(HashTable *ht);
|
||||
|
||||
static inline ulong zend_inline_hash_func(char *arKey, uint nKeyLength)
|
||||
{
|
||||
ulong h = 5381;
|
||||
char *arEnd = arKey + nKeyLength;
|
||||
|
||||
while (arKey < arEnd) {
|
||||
h += (h << 5);
|
||||
h ^= (ulong) *arKey++;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength);
|
||||
|
||||
#if ZEND_DEBUG
|
||||
/* debug */
|
||||
void zend_hash_display_pListTail(HashTable *ht);
|
||||
void zend_hash_display(HashTable *ht);
|
||||
#endif
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
#define ZEND_INIT_SYMTABLE(ht) \
|
||||
ZEND_INIT_SYMTABLE_EX(ht, 2, 0)
|
||||
|
||||
#define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \
|
||||
zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
|
||||
|
||||
|
||||
#endif /* ZEND_HASH_H */
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_language_parser.h"
|
||||
#include "zend_compile.h"
|
||||
#include "zend_highlight.h"
|
||||
#include "zend_ptr_stack.h"
|
||||
#include "zend_globals.h"
|
||||
|
||||
ZEND_API void zend_html_putc(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '\n':
|
||||
ZEND_PUTS("<br />");
|
||||
break;
|
||||
case '<':
|
||||
ZEND_PUTS("<");
|
||||
break;
|
||||
case '>':
|
||||
ZEND_PUTS(">");
|
||||
break;
|
||||
case '&':
|
||||
ZEND_PUTS("&");
|
||||
break;
|
||||
case ' ':
|
||||
ZEND_PUTS(" ");
|
||||
break;
|
||||
case '\t':
|
||||
ZEND_PUTS(" ");
|
||||
break;
|
||||
default:
|
||||
ZEND_PUTC(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_html_puts(char *s, uint len)
|
||||
{
|
||||
register char *ptr=s, *end=s+len;
|
||||
|
||||
while (ptr<end) {
|
||||
if (*ptr==' '
|
||||
&& len>1
|
||||
&& !(((ptr+1)>=end) || (*(ptr+1)==' ')) /* next is not a space */
|
||||
&& !((ptr==s) || (*(ptr-1)==' '))) /* last is not a space */ {
|
||||
char c = *ptr++;
|
||||
|
||||
ZEND_PUTC(c);
|
||||
continue;
|
||||
}
|
||||
zend_html_putc(*ptr++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC)
|
||||
{
|
||||
zval token;
|
||||
int token_type;
|
||||
char *last_color = syntax_highlighter_ini->highlight_html;
|
||||
char *next_color;
|
||||
int in_string=0;
|
||||
|
||||
zend_printf("<code>");
|
||||
zend_printf("<font color=\"%s\">\n", last_color);
|
||||
/* highlight stuff coming back from zendlex() */
|
||||
token.type = 0;
|
||||
while ((token_type=lex_scan(&token TSRMLS_CC))) {
|
||||
switch (token_type) {
|
||||
case T_INLINE_HTML:
|
||||
next_color = syntax_highlighter_ini->highlight_html;
|
||||
break;
|
||||
case T_COMMENT:
|
||||
next_color = syntax_highlighter_ini->highlight_comment;
|
||||
break;
|
||||
case T_OPEN_TAG:
|
||||
case T_OPEN_TAG_WITH_ECHO:
|
||||
next_color = syntax_highlighter_ini->highlight_default;
|
||||
break;
|
||||
case T_CLOSE_TAG:
|
||||
next_color = syntax_highlighter_ini->highlight_default;
|
||||
break;
|
||||
case T_CONSTANT_ENCAPSED_STRING:
|
||||
next_color = syntax_highlighter_ini->highlight_string;
|
||||
break;
|
||||
case '"':
|
||||
next_color = syntax_highlighter_ini->highlight_string;
|
||||
in_string = !in_string;
|
||||
break;
|
||||
case T_WHITESPACE:
|
||||
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); /* no color needed */
|
||||
token.type = 0;
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
if (token.type==0) {
|
||||
next_color = syntax_highlighter_ini->highlight_keyword;
|
||||
} else {
|
||||
if (in_string) {
|
||||
next_color = syntax_highlighter_ini->highlight_string;
|
||||
} else {
|
||||
next_color = syntax_highlighter_ini->highlight_default;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (last_color != next_color) {
|
||||
if (last_color != syntax_highlighter_ini->highlight_html) {
|
||||
zend_printf("</font>");
|
||||
}
|
||||
last_color = next_color;
|
||||
if (last_color != syntax_highlighter_ini->highlight_html) {
|
||||
zend_printf("<font color=\"%s\">", last_color);
|
||||
}
|
||||
}
|
||||
switch (token_type) {
|
||||
case T_END_HEREDOC:
|
||||
zend_html_puts(token.value.str.val, token.value.str.len);
|
||||
break;
|
||||
default:
|
||||
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
break;
|
||||
}
|
||||
|
||||
if (token.type == IS_STRING) {
|
||||
switch (token_type) {
|
||||
case T_OPEN_TAG:
|
||||
case T_OPEN_TAG_WITH_ECHO:
|
||||
case T_CLOSE_TAG:
|
||||
case T_WHITESPACE:
|
||||
case T_COMMENT:
|
||||
break;
|
||||
default:
|
||||
efree(token.value.str.val);
|
||||
break;
|
||||
}
|
||||
} else if (token_type == T_END_HEREDOC) {
|
||||
zend_bool has_semicolon=(strchr(token.value.str.val, ';')?1:0);
|
||||
|
||||
efree(token.value.str.val);
|
||||
if (has_semicolon) {
|
||||
/* the following semicolon was unput(), ignore it */
|
||||
lex_scan(&token TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
token.type = 0;
|
||||
}
|
||||
if (last_color != syntax_highlighter_ini->highlight_html) {
|
||||
zend_printf("</font>\n");
|
||||
}
|
||||
zend_printf("</font>\n");
|
||||
zend_printf("</code>");
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_HIGHLIGHT_H
|
||||
#define ZEND_HIGHLIGHT_H
|
||||
|
||||
#define HL_COMMENT_COLOR "#FF8000" /* orange */
|
||||
#define HL_DEFAULT_COLOR "#0000BB" /* blue */
|
||||
#define HL_HTML_COLOR "#000000" /* black */
|
||||
#define HL_STRING_COLOR "#DD0000" /* red */
|
||||
#define HL_BG_COLOR "#FFFFFF" /* white */
|
||||
#define HL_KEYWORD_COLOR "#007700" /* green */
|
||||
|
||||
|
||||
typedef struct _zend_syntax_highlighter_ini {
|
||||
char *highlight_html;
|
||||
char *highlight_comment;
|
||||
char *highlight_default;
|
||||
char *highlight_string;
|
||||
char *highlight_keyword;
|
||||
} zend_syntax_highlighter_ini;
|
||||
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC);
|
||||
ZEND_API int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC);
|
||||
ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC);
|
||||
ZEND_API void zend_html_putc(char c);
|
||||
ZEND_API void zend_html_puts(char *s, uint len);
|
||||
END_EXTERN_C()
|
||||
|
||||
extern zend_syntax_highlighter_ini syntax_highlighter_ini;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/* This indenter doesn't really work, it's here for no particular reason. */
|
||||
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_language_parser.h"
|
||||
#include "zend_compile.h"
|
||||
#include "zend_indent.h"
|
||||
|
||||
#define zendtext LANG_SCNG(yy_text)
|
||||
#define zendleng LANG_SCNG(yy_leng)
|
||||
|
||||
|
||||
static void handle_whitespace(int *emit_whitespace)
|
||||
{
|
||||
unsigned char c;
|
||||
int i;
|
||||
|
||||
for (c=0; c<128; c++) {
|
||||
if (emit_whitespace[c]>0) {
|
||||
for (i=0; i<emit_whitespace[c]; i++) {
|
||||
zend_write((char *) &c, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
memset(emit_whitespace, 0, sizeof(int)*256);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_indent()
|
||||
{
|
||||
zval token;
|
||||
int token_type;
|
||||
int in_string=0;
|
||||
int nest_level=0;
|
||||
int emit_whitespace[256];
|
||||
int i;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
memset(emit_whitespace, 0, sizeof(int)*256);
|
||||
|
||||
/* highlight stuff coming back from zendlex() */
|
||||
token.type = 0;
|
||||
while ((token_type=lex_scan(&token TSRMLS_CC))) {
|
||||
switch (token_type) {
|
||||
case T_INLINE_HTML:
|
||||
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
break;
|
||||
case T_WHITESPACE: {
|
||||
token.type = 0;
|
||||
/* eat whitespace, emit newlines */
|
||||
for (i=0; i<LANG_SCNG(yy_leng); i++) {
|
||||
emit_whitespace[(unsigned char) LANG_SCNG(yy_text)[i]]++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case '"':
|
||||
in_string = !in_string;
|
||||
/* break missing intentionally */
|
||||
default:
|
||||
if (token.type==0) {
|
||||
/* keyword */
|
||||
switch(token_type) {
|
||||
case ',':
|
||||
ZEND_PUTS(", ");
|
||||
goto dflt_printout;
|
||||
break;
|
||||
case '{':
|
||||
nest_level++;
|
||||
if (emit_whitespace['\n']>0) {
|
||||
ZEND_PUTS(" {\n");
|
||||
memset(emit_whitespace, 0, sizeof(int)*256);
|
||||
} else {
|
||||
ZEND_PUTS("{");
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
nest_level--;
|
||||
if (emit_whitespace['\n']==0) {
|
||||
ZEND_PUTS("\n");
|
||||
}
|
||||
for (i=0; i<nest_level; i++) {
|
||||
ZEND_PUTS(" ");
|
||||
}
|
||||
goto dflt_printout;
|
||||
break;
|
||||
dflt_printout:
|
||||
default:
|
||||
if (emit_whitespace['\n']>0) {
|
||||
for (i=0; i<emit_whitespace['\n']; i++) {
|
||||
ZEND_PUTS("\n");
|
||||
}
|
||||
memset(emit_whitespace, 0, sizeof(int)*256);
|
||||
for (i=0; i<nest_level; i++) {
|
||||
ZEND_PUTS(" ");
|
||||
}
|
||||
} else {
|
||||
handle_whitespace(emit_whitespace);
|
||||
}
|
||||
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
handle_whitespace(emit_whitespace);
|
||||
if (in_string) {
|
||||
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
/* a part of a string */
|
||||
} else {
|
||||
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (token.type == IS_STRING) {
|
||||
switch (token_type) {
|
||||
case T_OPEN_TAG:
|
||||
case T_CLOSE_TAG:
|
||||
case T_WHITESPACE:
|
||||
break;
|
||||
default:
|
||||
efree(token.value.str.val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
token.type = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_INDENT_H
|
||||
#define ZEND_INDENT_H
|
||||
|
||||
ZEND_API void zend_indent(void);
|
||||
|
||||
#endif /* ZEND_INDENT_H */
|
||||
+486
@@ -0,0 +1,486 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_ini.h"
|
||||
#include "zend_alloc.h"
|
||||
#include "zend_operators.h"
|
||||
|
||||
static HashTable *registered_zend_ini_directives;
|
||||
|
||||
|
||||
/*
|
||||
* hash_apply functions
|
||||
*/
|
||||
static int zend_remove_ini_entries(zend_ini_entry *ini_entry, int *module_number TSRMLS_DC)
|
||||
{
|
||||
if (ini_entry->module_number == *module_number) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS_DC)
|
||||
{
|
||||
if (ini_entry->modified) {
|
||||
if (ini_entry->on_modify) {
|
||||
ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC);
|
||||
}
|
||||
efree(ini_entry->value);
|
||||
ini_entry->value = ini_entry->orig_value;
|
||||
ini_entry->value_length = ini_entry->orig_value_length;
|
||||
ini_entry->modified = 0;
|
||||
ini_entry->orig_value = NULL;
|
||||
ini_entry->orig_value_length = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Startup / shutdown
|
||||
*/
|
||||
ZEND_API int zend_ini_startup(TSRMLS_D)
|
||||
{
|
||||
registered_zend_ini_directives = &EG(ini_directives);
|
||||
if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, NULL, 1, 0)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_ini_shutdown(TSRMLS_D)
|
||||
{
|
||||
zend_hash_destroy(&EG(ini_directives));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_ini_deactivate(TSRMLS_D)
|
||||
{
|
||||
zend_hash_apply_with_argument(&EG(ini_directives), (apply_func_arg_t) zend_restore_ini_entry_cb, (void *) ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_copy_ini_directives(TSRMLS_D)
|
||||
{
|
||||
zend_ini_entry ini_entry;
|
||||
|
||||
if (zend_hash_init_ex(&EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
zend_hash_copy(&EG(ini_directives), registered_zend_ini_directives, NULL, &ini_entry, sizeof(zend_ini_entry));
|
||||
zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int ini_key_compare(const void *a, const void *b)
|
||||
{
|
||||
Bucket *f;
|
||||
Bucket *s;
|
||||
|
||||
f = *((Bucket **) a);
|
||||
s = *((Bucket **) b);
|
||||
|
||||
if (f->nKeyLength==0 && s->nKeyLength==0) { /* both numeric */
|
||||
return ZEND_NORMALIZE_BOOL(f->nKeyLength - s->nKeyLength);
|
||||
} else if (f->nKeyLength==0) { /* f is numeric, s is not */
|
||||
return -1;
|
||||
} else if (s->nKeyLength==0) { /* s is numeric, f is not */
|
||||
return 1;
|
||||
} else { /* both strings */
|
||||
return zend_binary_strcasecmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_ini_sort_entries(TSRMLS_D)
|
||||
{
|
||||
zend_hash_sort(&EG(ini_directives), qsort, ini_key_compare, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Registration / unregistration
|
||||
*/
|
||||
|
||||
ZEND_API int zend_register_ini_entries(zend_ini_entry *ini_entry, int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_ini_entry *p = ini_entry;
|
||||
zend_ini_entry *hashed_ini_entry;
|
||||
zval default_value;
|
||||
|
||||
while (p->name) {
|
||||
p->module_number = module_number;
|
||||
if (zend_hash_add(registered_zend_ini_directives, p->name, p->name_length, p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry)==FAILURE) {
|
||||
zend_unregister_ini_entries(module_number TSRMLS_CC);
|
||||
return FAILURE;
|
||||
}
|
||||
if ((zend_get_configuration_directive(p->name, p->name_length, &default_value))==SUCCESS) {
|
||||
if (!hashed_ini_entry->on_modify
|
||||
|| hashed_ini_entry->on_modify(hashed_ini_entry, default_value.value.str.val, default_value.value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC)==SUCCESS) {
|
||||
hashed_ini_entry->value = default_value.value.str.val;
|
||||
hashed_ini_entry->value_length = default_value.value.str.len;
|
||||
}
|
||||
} else {
|
||||
if (hashed_ini_entry->on_modify) {
|
||||
hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_hash_apply_with_argument(registered_zend_ini_directives, (apply_func_arg_t) zend_remove_ini_entries, (void *) &module_number TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
static int zend_ini_refresh_cache(zend_ini_entry *p, int stage TSRMLS_DC)
|
||||
{
|
||||
if (p->on_modify) {
|
||||
p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage TSRMLS_CC);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC)
|
||||
{
|
||||
zend_hash_apply_with_argument(&EG(ini_directives), (apply_func_arg_t) zend_ini_refresh_cache, (void *)(long) stage TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage)
|
||||
{
|
||||
zend_ini_entry *ini_entry;
|
||||
char *duplicate;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_find(&EG(ini_directives), name, name_length, (void **) &ini_entry)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (!(ini_entry->modifyable & modify_type)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
duplicate = estrndup(new_value, new_value_length);
|
||||
|
||||
if (!ini_entry->on_modify
|
||||
|| ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC)==SUCCESS) {
|
||||
if (!ini_entry->modified) {
|
||||
ini_entry->orig_value = ini_entry->value;
|
||||
ini_entry->orig_value_length = ini_entry->value_length;
|
||||
} else { /* we already changed the value, free the changed value */
|
||||
efree(ini_entry->value);
|
||||
}
|
||||
ini_entry->value = duplicate;
|
||||
ini_entry->value_length = new_value_length;
|
||||
ini_entry->modified = 1;
|
||||
} else {
|
||||
efree(duplicate);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage)
|
||||
{
|
||||
zend_ini_entry *ini_entry;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_find(&EG(ini_directives), name, name_length, (void **) &ini_entry)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type))
|
||||
{
|
||||
zend_ini_entry *ini_entry;
|
||||
|
||||
if (zend_hash_find(registered_zend_ini_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
ini_entry->displayer = displayer;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Data retrieval
|
||||
*/
|
||||
|
||||
ZEND_API long zend_ini_long(char *name, uint name_length, int orig)
|
||||
{
|
||||
zend_ini_entry *ini_entry;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_find(&EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) {
|
||||
if (orig && ini_entry->modified) {
|
||||
return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0);
|
||||
} else if (ini_entry->value) {
|
||||
return strtol(ini_entry->value, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API double zend_ini_double(char *name, uint name_length, int orig)
|
||||
{
|
||||
zend_ini_entry *ini_entry;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_find(&EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) {
|
||||
if (orig && ini_entry->modified) {
|
||||
return (double) (ini_entry->orig_value ? strtod(ini_entry->orig_value, NULL) : 0.0);
|
||||
} else if (ini_entry->value) {
|
||||
return (double) strtod(ini_entry->value, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API char *zend_ini_string(char *name, uint name_length, int orig)
|
||||
{
|
||||
zend_ini_entry *ini_entry;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_find(&EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) {
|
||||
if (orig && ini_entry->modified) {
|
||||
return ini_entry->orig_value;
|
||||
} else {
|
||||
return ini_entry->value;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
|
||||
{
|
||||
if (ini_entry->displayer) {
|
||||
ini_entry->displayer(ini_entry, type);
|
||||
} else {
|
||||
char *display_string;
|
||||
uint display_string_length;
|
||||
|
||||
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
||||
if (ini_entry->orig_value) {
|
||||
display_string = ini_entry->orig_value;
|
||||
display_string_length = ini_entry->orig_value_length;
|
||||
} else {
|
||||
display_string = "<i>no value</i>";
|
||||
display_string_length = sizeof("<i>no value</i>")-1;
|
||||
}
|
||||
} else if (ini_entry->value && ini_entry->value[0]) {
|
||||
display_string = ini_entry->value;
|
||||
display_string_length = ini_entry->value_length;
|
||||
} else {
|
||||
display_string = "<i>no value</i>";
|
||||
display_string_length = sizeof("<i>no value</i>")-1;
|
||||
}
|
||||
ZEND_WRITE(display_string, display_string_length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_INI_DISP(zend_ini_boolean_displayer_cb)
|
||||
{
|
||||
int value;
|
||||
|
||||
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
||||
value = (ini_entry->orig_value ? atoi(ini_entry->orig_value) : 0);
|
||||
} else if (ini_entry->value) {
|
||||
value = atoi(ini_entry->value);
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
if (value) {
|
||||
ZEND_PUTS("On");
|
||||
} else {
|
||||
ZEND_PUTS("Off");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_INI_DISP(zend_ini_color_displayer_cb)
|
||||
{
|
||||
char *value;
|
||||
|
||||
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
||||
value = ini_entry->orig_value;
|
||||
} else if (ini_entry->value) {
|
||||
value = ini_entry->value;
|
||||
} else {
|
||||
value = NULL;
|
||||
}
|
||||
if (value) {
|
||||
zend_printf("<font color=\"%s\">%s</font>", value, value);
|
||||
} else {
|
||||
ZEND_PUTS("<i>no value</i>;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_INI_DISP(display_link_numbers)
|
||||
{
|
||||
char *value;
|
||||
|
||||
if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
|
||||
value = ini_entry->orig_value;
|
||||
} else if (ini_entry->value) {
|
||||
value = ini_entry->value;
|
||||
} else {
|
||||
value = NULL;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
if (atoi(value)==-1) {
|
||||
ZEND_PUTS("Unlimited");
|
||||
} else {
|
||||
zend_printf("%s", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Standard message handlers */
|
||||
|
||||
ZEND_API ZEND_INI_MH(OnUpdateBool)
|
||||
{
|
||||
zend_bool *p;
|
||||
#ifndef ZTS
|
||||
char *base = (char *) mh_arg2;
|
||||
#else
|
||||
char *base;
|
||||
|
||||
base = (char *) ts_resource(*((int *) mh_arg2));
|
||||
#endif
|
||||
|
||||
p = (zend_bool *) (base+(size_t) mh_arg1);
|
||||
|
||||
*p = (zend_bool) atoi(new_value);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API ZEND_INI_MH(OnUpdateInt)
|
||||
{
|
||||
long *p;
|
||||
#ifndef ZTS
|
||||
char *base = (char *) mh_arg2;
|
||||
#else
|
||||
char *base;
|
||||
|
||||
base = (char *) ts_resource(*((int *) mh_arg2));
|
||||
#endif
|
||||
|
||||
p = (long *) (base+(size_t) mh_arg1);
|
||||
|
||||
*p = zend_atoi(new_value, new_value_length);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API ZEND_INI_MH(OnUpdateReal)
|
||||
{
|
||||
double *p;
|
||||
#ifndef ZTS
|
||||
char *base = (char *) mh_arg2;
|
||||
#else
|
||||
char *base;
|
||||
|
||||
base = (char *) ts_resource(*((int *) mh_arg2));
|
||||
#endif
|
||||
|
||||
p = (double *) (base+(size_t) mh_arg1);
|
||||
|
||||
*p = strtod(new_value, NULL);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API ZEND_INI_MH(OnUpdateString)
|
||||
{
|
||||
char **p;
|
||||
#ifndef ZTS
|
||||
char *base = (char *) mh_arg2;
|
||||
#else
|
||||
char *base;
|
||||
|
||||
base = (char *) ts_resource(*((int *) mh_arg2));
|
||||
#endif
|
||||
|
||||
p = (char **) (base+(size_t) mh_arg1);
|
||||
|
||||
*p = new_value;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty)
|
||||
{
|
||||
char **p;
|
||||
#ifndef ZTS
|
||||
char *base = (char *) mh_arg2;
|
||||
#else
|
||||
char *base;
|
||||
|
||||
base = (char *) ts_resource(*((int *) mh_arg2));
|
||||
#endif
|
||||
|
||||
if (new_value && !new_value[0]) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
p = (char **) (base+(size_t) mh_arg1);
|
||||
|
||||
*p = new_value;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_INI_H
|
||||
#define ZEND_INI_H
|
||||
|
||||
#define ZEND_INI_USER (1<<0)
|
||||
#define ZEND_INI_PERDIR (1<<1)
|
||||
#define ZEND_INI_SYSTEM (1<<2)
|
||||
|
||||
#define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)
|
||||
|
||||
#ifndef XtOffsetOf
|
||||
# if defined(CRAY) || (defined(__arm) && !defined(LINUX))
|
||||
# ifdef __STDC__
|
||||
# define XtOffset(p_type,field) _Offsetof(p_type,field)
|
||||
# else
|
||||
# ifdef CRAY2
|
||||
# define XtOffset(p_type,field) \
|
||||
(sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
|
||||
|
||||
# else /* !CRAY2 */
|
||||
|
||||
# define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
|
||||
|
||||
# endif /* !CRAY2 */
|
||||
# endif /* __STDC__ */
|
||||
# else /* ! (CRAY || __arm) */
|
||||
|
||||
# define XtOffset(p_type,field) \
|
||||
((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
|
||||
|
||||
# endif /* !CRAY */
|
||||
|
||||
# ifdef offsetof
|
||||
# define XtOffsetOf(s_type,field) offsetof(s_type,field)
|
||||
# else
|
||||
# define XtOffsetOf(s_type,field) XtOffset(s_type*,field)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct _zend_ini_entry zend_ini_entry;
|
||||
|
||||
#define ZEND_INI_MH(name) int name(zend_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage TSRMLS_DC)
|
||||
#define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type)
|
||||
|
||||
struct _zend_ini_entry {
|
||||
int module_number;
|
||||
int modifyable;
|
||||
char *name;
|
||||
uint name_length;
|
||||
ZEND_INI_MH((*on_modify));
|
||||
void *mh_arg1;
|
||||
void *mh_arg2;
|
||||
void *mh_arg3;
|
||||
|
||||
char *value;
|
||||
uint value_length;
|
||||
|
||||
char *orig_value;
|
||||
uint orig_value_length;
|
||||
int modified;
|
||||
|
||||
void (*displayer)(zend_ini_entry *ini_entry, int type);
|
||||
};
|
||||
|
||||
|
||||
ZEND_API int zend_ini_startup(TSRMLS_D);
|
||||
ZEND_API int zend_ini_shutdown(TSRMLS_D);
|
||||
ZEND_API int zend_ini_deactivate(TSRMLS_D);
|
||||
|
||||
ZEND_API int zend_copy_ini_directives(TSRMLS_D);
|
||||
|
||||
ZEND_API void zend_ini_sort_entries(TSRMLS_D);
|
||||
|
||||
ZEND_API int zend_register_ini_entries(zend_ini_entry *ini_entry, int module_number TSRMLS_DC);
|
||||
ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC);
|
||||
ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC);
|
||||
ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage);
|
||||
ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage);
|
||||
ZEND_API void display_ini_entries(zend_module_entry *module);
|
||||
|
||||
ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
|
||||
ZEND_API double zend_ini_double(char *name, uint name_length, int orig);
|
||||
ZEND_API char *zend_ini_string(char *name, uint name_length, int orig);
|
||||
|
||||
ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));
|
||||
|
||||
ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb);
|
||||
ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb);
|
||||
ZEND_API ZEND_INI_DISP(display_link_numbers);
|
||||
|
||||
#define ZEND_INI_BEGIN() static zend_ini_entry ini_entries[] = {
|
||||
#define ZEND_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL } };
|
||||
|
||||
#define ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, displayer) \
|
||||
{ 0, modifyable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, displayer },
|
||||
|
||||
#define ZEND_INI_ENTRY3(name, default_value, modifyable, on_modify, arg1, arg2, arg3) \
|
||||
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, NULL)
|
||||
|
||||
#define ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, displayer) \
|
||||
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL, displayer)
|
||||
|
||||
#define ZEND_INI_ENTRY2(name, default_value, modifyable, on_modify, arg1, arg2) \
|
||||
ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL)
|
||||
|
||||
#define ZEND_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, displayer) \
|
||||
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, NULL, NULL, displayer)
|
||||
|
||||
#define ZEND_INI_ENTRY1(name, default_value, modifyable, on_modify, arg1) \
|
||||
ZEND_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, NULL)
|
||||
|
||||
#define ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, displayer) \
|
||||
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, NULL, NULL, NULL, displayer)
|
||||
|
||||
#define ZEND_INI_ENTRY(name, default_value, modifyable, on_modify) \
|
||||
ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, NULL)
|
||||
|
||||
#ifdef ZTS
|
||||
#define STD_ZEND_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
|
||||
ZEND_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
|
||||
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, displayer) \
|
||||
ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
|
||||
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
|
||||
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, zend_ini_boolean_displayer_cb)
|
||||
#else
|
||||
#define STD_ZEND_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
|
||||
ZEND_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
|
||||
#define STD_ZEND_INI_ENTRY_EX(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr, displayer) \
|
||||
ZEND_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
|
||||
#define STD_ZEND_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
|
||||
ZEND_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb)
|
||||
#endif
|
||||
|
||||
#define INI_INT(name) zend_ini_long((name), sizeof(name), 0)
|
||||
#define INI_FLT(name) zend_ini_double((name), sizeof(name), 0)
|
||||
#define INI_STR(name) zend_ini_string((name), sizeof(name), 0)
|
||||
#define INI_BOOL(name) ((zend_bool) INI_INT(name))
|
||||
|
||||
#define INI_ORIG_INT(name) zend_ini_long((name), sizeof(name), 1)
|
||||
#define INI_ORIG_FLT(name) zend_ini_double((name), sizeof(name), 1)
|
||||
#define INI_ORIG_STR(name) zend_ini_string((name), sizeof(name), 1)
|
||||
#define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name))
|
||||
|
||||
|
||||
#define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number TSRMLS_CC)
|
||||
#define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number TSRMLS_CC)
|
||||
#define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
|
||||
|
||||
#define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), sizeof(name), displayer)
|
||||
#define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, zend_ini_boolean_displayer_cb)
|
||||
|
||||
/* Standard message handlers */
|
||||
ZEND_API ZEND_INI_MH(OnUpdateBool);
|
||||
ZEND_API ZEND_INI_MH(OnUpdateInt);
|
||||
ZEND_API ZEND_INI_MH(OnUpdateReal);
|
||||
ZEND_API ZEND_INI_MH(OnUpdateString);
|
||||
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
|
||||
|
||||
|
||||
#define ZEND_INI_DISPLAY_ORIG 1
|
||||
#define ZEND_INI_DISPLAY_ACTIVE 2
|
||||
|
||||
#define ZEND_INI_STAGE_STARTUP (1<<0)
|
||||
#define ZEND_INI_STAGE_SHUTDOWN (1<<1)
|
||||
#define ZEND_INI_STAGE_ACTIVATE (1<<2)
|
||||
#define ZEND_INI_STAGE_DEACTIVATE (1<<3)
|
||||
#define ZEND_INI_STAGE_RUNTIME (1<<4)
|
||||
|
||||
/* INI parsing engine */
|
||||
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, int callback_type, void *arg);
|
||||
int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg);
|
||||
#define ZEND_INI_PARSER_ENTRY 1
|
||||
#define ZEND_INI_PARSER_SECTION 2
|
||||
|
||||
typedef struct _zend_ini_parser_param {
|
||||
zend_ini_parser_cb_t ini_parser_cb;
|
||||
void *arg;
|
||||
} zend_ini_parser_param;
|
||||
|
||||
#endif /* ZEND_INI_H */
|
||||
@@ -0,0 +1,236 @@
|
||||
%{
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#define DEBUG_CFG_PARSER 0
|
||||
#include "zend.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_ini.h"
|
||||
#include "zend_constants.h"
|
||||
#include "zend_ini_scanner.h"
|
||||
#include "zend_extensions.h"
|
||||
|
||||
|
||||
#if WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#define YYSTYPE zval
|
||||
|
||||
#ifdef ZTS
|
||||
#define YYPARSE_PARAM tsrm_ls
|
||||
#define YYLEX_PARAM tsrm_ls
|
||||
#endif
|
||||
|
||||
#define ZEND_INI_PARSER_CB (CG(ini_parser_param))->ini_parser_cb
|
||||
#define ZEND_INI_PARSER_ARG (CG(ini_parser_param))->arg
|
||||
|
||||
int ini_lex(zval *ini_lval TSRMLS_DC);
|
||||
#ifdef ZTS
|
||||
int ini_parse(void *arg);
|
||||
#else
|
||||
int ini_parse(void);
|
||||
#endif
|
||||
|
||||
zval yylval;
|
||||
|
||||
#ifndef ZTS
|
||||
extern int ini_lex(zval *ini_lval TSRMLS_DC);
|
||||
extern FILE *ini_in;
|
||||
extern int ini_lineno;
|
||||
extern void init_cfg_scanner(void);
|
||||
#endif
|
||||
|
||||
void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2)
|
||||
{
|
||||
int i_result;
|
||||
int i_op1, i_op2;
|
||||
char str_result[MAX_LENGTH_OF_LONG];
|
||||
|
||||
i_op1 = atoi(op1->value.str.val);
|
||||
free(op1->value.str.val);
|
||||
if (op2) {
|
||||
i_op2 = atoi(op2->value.str.val);
|
||||
free(op2->value.str.val);
|
||||
} else {
|
||||
i_op2 = 0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case '|':
|
||||
i_result = i_op1 | i_op2;
|
||||
break;
|
||||
case '&':
|
||||
i_result = i_op1 & i_op2;
|
||||
break;
|
||||
case '~':
|
||||
i_result = ~i_op1;
|
||||
break;
|
||||
case '!':
|
||||
i_result = !i_op1;
|
||||
break;
|
||||
default:
|
||||
i_result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
result->value.str.len = zend_sprintf(str_result, "%d", i_result);
|
||||
result->value.str.val = (char *) malloc(result->value.str.len+1);
|
||||
memcpy(result->value.str.val, str_result, result->value.str.len);
|
||||
result->value.str.val[result->value.str.len] = 0;
|
||||
result->type = IS_STRING;
|
||||
}
|
||||
|
||||
|
||||
void zend_ini_get_constant(zval *result, zval *name)
|
||||
{
|
||||
zval z_constant;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_get_constant(name->value.str.val, name->value.str.len, &z_constant TSRMLS_CC)) {
|
||||
/* z_constant is emalloc()'d */
|
||||
convert_to_string(&z_constant);
|
||||
result->value.str.val = zend_strndup(z_constant.value.str.val, z_constant.value.str.len);
|
||||
result->value.str.len = z_constant.value.str.len;
|
||||
result->type = z_constant.type;
|
||||
zval_dtor(&z_constant);
|
||||
free(name->value.str.val);
|
||||
} else {
|
||||
*result = *name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void ini_error(char *str)
|
||||
{
|
||||
char *error_buf;
|
||||
int error_buf_len;
|
||||
char *currently_parsed_filename;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
currently_parsed_filename = zend_ini_scanner_get_filename(TSRMLS_C);
|
||||
error_buf_len = 128+strlen(currently_parsed_filename); /* should be more than enough */
|
||||
error_buf = (char *) emalloc(error_buf_len);
|
||||
|
||||
sprintf(error_buf, "Error parsing %s on line %d\n", currently_parsed_filename, zend_ini_scanner_get_lineno(TSRMLS_C));
|
||||
|
||||
if (CG(ini_parser_unbuffered_errors)) {
|
||||
#ifdef PHP_WIN32
|
||||
MessageBox(NULL, error_buf, "PHP Error", MB_OK|MB_TOPMOST|0x00200000L);
|
||||
#else
|
||||
fprintf(stderr, "PHP: %s", error_buf);
|
||||
#endif
|
||||
} else {
|
||||
zend_error(E_CORE_WARNING, error_buf);
|
||||
}
|
||||
efree(error_buf);
|
||||
}
|
||||
|
||||
|
||||
int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg)
|
||||
{
|
||||
int retval;
|
||||
zend_ini_parser_param ini_parser_param;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
ini_parser_param.ini_parser_cb = ini_parser_cb;
|
||||
ini_parser_param.arg = arg;
|
||||
|
||||
CG(ini_parser_param) = &ini_parser_param;
|
||||
if (zend_ini_open_file_for_scanning(fh TSRMLS_CC)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
CG(ini_parser_unbuffered_errors) = unbuffered_errors;
|
||||
retval = ini_parse(TSRMLS_C);
|
||||
|
||||
zend_ini_close_file(fh TSRMLS_CC);
|
||||
|
||||
if (retval==0) {
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%}
|
||||
|
||||
%pure_parser
|
||||
%token TC_STRING
|
||||
%token TC_ENCAPSULATED_STRING
|
||||
%token SECTION
|
||||
%token CFG_TRUE
|
||||
%token CFG_FALSE
|
||||
%left '|' '&'
|
||||
%right '~' '!'
|
||||
|
||||
%%
|
||||
|
||||
statement_list:
|
||||
statement_list statement
|
||||
| /* empty */
|
||||
;
|
||||
|
||||
statement:
|
||||
TC_STRING '=' string_or_value {
|
||||
#if DEBUG_CFG_PARSER
|
||||
printf("'%s' = '%s'\n", $1.value.str.val, $3.value.str.val);
|
||||
#endif
|
||||
ZEND_INI_PARSER_CB(&$1, &$3, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG);
|
||||
free($1.value.str.val);
|
||||
free($3.value.str.val);
|
||||
}
|
||||
| TC_STRING { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_ENTRY, ZEND_INI_PARSER_ARG); free($1.value.str.val); }
|
||||
| SECTION { ZEND_INI_PARSER_CB(&$1, NULL, ZEND_INI_PARSER_SECTION, ZEND_INI_PARSER_ARG); free($1.value.str.val); }
|
||||
| '\n'
|
||||
;
|
||||
|
||||
|
||||
string_or_value:
|
||||
expr { $$ = $1; }
|
||||
| TC_ENCAPSULATED_STRING { $$ = $1; }
|
||||
| CFG_TRUE { $$ = $1; }
|
||||
| CFG_FALSE { $$ = $1; }
|
||||
| '\n' { $$.value.str.val = strdup(""); $$.value.str.len=0; $$.type = IS_STRING; }
|
||||
| '\0' { $$.value.str.val = strdup(""); $$.value.str.len=0; $$.type = IS_STRING; }
|
||||
;
|
||||
|
||||
expr:
|
||||
constant_string { $$ = $1; }
|
||||
| expr '|' expr { zend_ini_do_op('|', &$$, &$1, &$3); }
|
||||
| expr '&' expr { zend_ini_do_op('&', &$$, &$1, &$3); }
|
||||
| '~' expr { zend_ini_do_op('~', &$$, &$2, NULL); }
|
||||
| '!' expr { zend_ini_do_op('!', &$$, &$2, NULL); }
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
constant_string:
|
||||
TC_STRING { zend_ini_get_constant(&$$, &$1); }
|
||||
;
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef _ZEND_INI_SCANNER_H
|
||||
#define _ZEND_INI_SCANNER_H
|
||||
|
||||
#if defined(ZTS) && defined(__cplusplus)
|
||||
class ZendIniFlexLexer : public yyFlexLexer
|
||||
{
|
||||
public:
|
||||
virtual ~ZendIniFlexLexer();
|
||||
int lex_scan(zval *zendlval);
|
||||
void BeginState(int state);
|
||||
|
||||
char *filename;
|
||||
};
|
||||
#endif /* ZTS && __cplusplus */
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
int zend_ini_scanner_get_lineno(TSRMLS_D);
|
||||
char *zend_ini_scanner_get_filename(TSRMLS_D);
|
||||
int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC);
|
||||
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC);
|
||||
int ini_lex(zval *ini_lval TSRMLS_DC);
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif /* _ZEND_INI_SCANNER_H */
|
||||
@@ -0,0 +1,289 @@
|
||||
%{
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_globals.h"
|
||||
#include "zend_ini_parser.h"
|
||||
#include "zend_ini_scanner.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
# ifdef HAVE_STDIOSTR_H
|
||||
# include <stdiostr.h>
|
||||
# endif
|
||||
# ifdef HAVE_STDIOSTREAM_H
|
||||
# include <stdiostream.h>
|
||||
# endif
|
||||
# ifdef ZEND_WIN32
|
||||
# include <strstrea.h>
|
||||
# else
|
||||
# include <strstream.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#undef YYSTYPE
|
||||
#define YYSTYPE zval
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define YY_DECL int ZendIniFlexLexer::lex_scan(zval *ini_lval TSRMLS_DC)
|
||||
#else
|
||||
#define YY_DECL int ini_lex(zval *ini_lval TSRMLS_DC)
|
||||
#endif
|
||||
|
||||
/* Globals Macros */
|
||||
#define SCNG INI_SCNG
|
||||
#ifdef ZTS
|
||||
ZEND_API ts_rsrc_id ini_scanner_globals_id;
|
||||
#else
|
||||
ZEND_API zend_scanner_globals ini_scanner_globals;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
static char *ini_filename;
|
||||
|
||||
void init_ini_scanner()
|
||||
{
|
||||
ini_lineno=1;
|
||||
}
|
||||
|
||||
|
||||
int zend_ini_scanner_get_lineno(TSRMLS_D)
|
||||
{
|
||||
return ini_lineno;
|
||||
}
|
||||
|
||||
|
||||
char *zend_ini_scanner_get_filename(TSRMLS_D)
|
||||
{
|
||||
return ini_filename;
|
||||
}
|
||||
|
||||
#else /* ZTS */
|
||||
|
||||
int zend_ini_scanner_get_lineno(TSRMLS_D)
|
||||
{
|
||||
return CG(ini_scanner)->lineno();
|
||||
}
|
||||
|
||||
char *zend_ini_scanner_get_filename(TSRMLS_D)
|
||||
{
|
||||
return CG(ini_scanner)->filename;
|
||||
}
|
||||
|
||||
int ini_lex(zval *ini_lval)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
return CG(ini_scanner)->lex_scan(ini_lval);
|
||||
}
|
||||
|
||||
ZendIniFlexLexer::~ZendIniFlexLexer()
|
||||
{
|
||||
if (yy_start_stack) {
|
||||
yy_flex_free(yy_start_stack);
|
||||
}
|
||||
}
|
||||
|
||||
int yyFlexLexer::yylex()
|
||||
{
|
||||
fprintf(stderr, "Error: yyFlexLexer::yylex() called\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
switch (fh->type) {
|
||||
case ZEND_HANDLE_FP:
|
||||
fp = fh->handle.fp;
|
||||
break;
|
||||
case ZEND_HANDLE_FILENAME:
|
||||
fp = zend_fopen(fh->filename, NULL);
|
||||
fh->type = ZEND_HANDLE_FP;
|
||||
break;
|
||||
default:
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
if (!fp) {
|
||||
return FAILURE;
|
||||
}
|
||||
fh->handle.is = new istdiostream(fp);
|
||||
fh->type = ZEND_HANDLE_STDIOSTREAM;
|
||||
|
||||
CG(ini_scanner) = new ZendIniFlexLexer;
|
||||
CG(ini_scanner)->switch_streams(fh->handle.is, &cout);
|
||||
CG(ini_scanner)->filename = fh->filename;
|
||||
#else
|
||||
init_ini_scanner();
|
||||
yyin = fp;
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE TSRMLS_CC) TSRMLS_CC);
|
||||
ini_filename = fh->filename;
|
||||
#endif
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC)
|
||||
{
|
||||
switch (fh->type) {
|
||||
case ZEND_HANDLE_FP:
|
||||
fclose(fh->handle.fp);
|
||||
break;
|
||||
#ifdef __cplusplus
|
||||
case ZEND_HANDLE_STDIOSTREAM: {
|
||||
TSRMLS_FETCH();
|
||||
delete CG(ini_scanner);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
NEWLINE ("\r"|"\n"|"\r\n")
|
||||
|
||||
%option noyywrap
|
||||
%option yylineno
|
||||
|
||||
%%
|
||||
|
||||
|
||||
<INITIAL>[ ]*("true"|"on"|"yes")[ ]* {
|
||||
ini_lval->value.str.val = zend_strndup("1",1);
|
||||
ini_lval->value.str.len = 1;
|
||||
ini_lval->type = IS_STRING;
|
||||
return CFG_TRUE;
|
||||
}
|
||||
|
||||
|
||||
<INITIAL>[ ]*("false"|"off"|"no"|"none")[ ]* {
|
||||
ini_lval->value.str.val = zend_strndup("",0);
|
||||
ini_lval->value.str.len = 0;
|
||||
ini_lval->type = IS_STRING;
|
||||
return CFG_FALSE;
|
||||
}
|
||||
|
||||
<INITIAL>[[][^[]+[\]]{NEWLINE}? {
|
||||
/* SECTION */
|
||||
|
||||
/* eat trailng ] */
|
||||
while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']')) {
|
||||
yyleng--;
|
||||
yytext[yyleng]=0;
|
||||
}
|
||||
|
||||
/* eat leading [ */
|
||||
yytext++;
|
||||
yyleng--;
|
||||
|
||||
ini_lval->value.str.val = zend_strndup(yytext,yyleng);
|
||||
ini_lval->value.str.len = yyleng;
|
||||
ini_lval->type = IS_STRING;
|
||||
return SECTION;
|
||||
}
|
||||
|
||||
|
||||
<INITIAL>["][^\n\r"]*["] {
|
||||
/* ENCAPSULATED TC_STRING */
|
||||
|
||||
/* eat trailing " */
|
||||
yytext[yyleng-1]=0;
|
||||
|
||||
/* eat leading " */
|
||||
yytext++;
|
||||
|
||||
ini_lval->value.str.val = zend_strndup(yytext, yyleng - 2);
|
||||
ini_lval->value.str.len = yyleng - 2;
|
||||
ini_lval->type = IS_STRING;
|
||||
return TC_ENCAPSULATED_STRING;
|
||||
}
|
||||
|
||||
<INITIAL>[&|~()!] {
|
||||
return yytext[0];
|
||||
}
|
||||
|
||||
|
||||
<INITIAL>[^=\n\r\t;|&~()!"]+ {
|
||||
/* STRING */
|
||||
register int i;
|
||||
|
||||
/* eat trailing whitespace */
|
||||
for (i=yyleng-1; i>=0; i--) {
|
||||
if (yytext[i]==' ' || yytext[i]=='\t') {
|
||||
yytext[i]=0;
|
||||
yyleng--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* eat leading whitespace */
|
||||
while (yytext[0]) {
|
||||
if (yytext[0]==' ' || yytext[0]=='\t') {
|
||||
yytext++;
|
||||
yyleng--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (yyleng!=0) {
|
||||
ini_lval->value.str.val = zend_strndup(yytext,yyleng);
|
||||
ini_lval->value.str.len = yyleng;
|
||||
ini_lval->type = IS_STRING;
|
||||
return TC_STRING;
|
||||
} else {
|
||||
/* whitespace */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
<INITIAL>[=\n] {
|
||||
return yytext[0];
|
||||
}
|
||||
|
||||
<INITIAL>{NEWLINE} {
|
||||
return '\n';
|
||||
}
|
||||
|
||||
<INITIAL>[;][^\r\n]*{NEWLINE}? {
|
||||
/* comment */
|
||||
return '\n';
|
||||
}
|
||||
|
||||
<INITIAL>[ \t] {
|
||||
/* eat whitespace */
|
||||
}
|
||||
|
||||
<INITIAL>. {
|
||||
#if DEBUG
|
||||
php_error(E_NOTICE,"Unexpected character on line %d: '%s' (ASCII %d)\n",yylineno,yytext,yytext[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER TSRMLS_CC);
|
||||
yyterminate();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef _ZEND_STDIOSTREAM
|
||||
#define _ZEND_STDIOSTREAM
|
||||
|
||||
#if defined(ZTS) && !defined(HAVE_CLASS_ISTDIOSTREAM)
|
||||
class istdiostream : public istream
|
||||
{
|
||||
private:
|
||||
stdiobuf _file;
|
||||
public:
|
||||
istdiostream (FILE* __f) : istream(), _file(__f) { init(&_file); }
|
||||
stdiobuf* rdbuf()/* const */ { return &_file; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,722 @@
|
||||
%{
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/*
|
||||
* LALR shift/reduce conflicts and how they are resolved:
|
||||
*
|
||||
* - 2 shift/reduce conflicts due to the dangeling elseif/else ambiguity. Solved by shift.
|
||||
* - 1 shift/reduce conflict due to arrays within encapsulated strings. Solved by shift.
|
||||
* - 1 shift/reduce conflict due to objects within encapsulated strings. Solved by shift.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "zend_compile.h"
|
||||
#include "zend.h"
|
||||
#include "zend_list.h"
|
||||
#include "zend_globals.h"
|
||||
#include "zend_API.h"
|
||||
|
||||
#define YYERROR_VERBOSE
|
||||
#define YYSTYPE znode
|
||||
#ifdef ZTS
|
||||
# define YYPARSE_PARAM tsrm_ls
|
||||
# define YYLEX_PARAM tsrm_ls
|
||||
#endif
|
||||
|
||||
|
||||
%}
|
||||
|
||||
%pure_parser
|
||||
%expect 4
|
||||
|
||||
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
|
||||
%left ','
|
||||
%left T_LOGICAL_OR
|
||||
%left T_LOGICAL_XOR
|
||||
%left T_LOGICAL_AND
|
||||
%right T_PRINT
|
||||
%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL
|
||||
%left '?' ':'
|
||||
%left T_BOOLEAN_OR
|
||||
%left T_BOOLEAN_AND
|
||||
%left '|'
|
||||
%left '^'
|
||||
%left '&'
|
||||
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
|
||||
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
|
||||
%left T_SL T_SR
|
||||
%left '+' '-' '.'
|
||||
%left '*' '/' '%'
|
||||
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
|
||||
%right '['
|
||||
%nonassoc T_NEW
|
||||
%token T_EXIT
|
||||
%token T_IF
|
||||
%left T_ELSEIF
|
||||
%left T_ELSE
|
||||
%left T_ENDIF
|
||||
%token T_LNUMBER
|
||||
%token T_DNUMBER
|
||||
%token T_STRING
|
||||
%token T_STRING_VARNAME
|
||||
%token T_VARIABLE
|
||||
%token T_NUM_STRING
|
||||
%token T_INLINE_HTML
|
||||
%token T_CHARACTER
|
||||
%token T_BAD_CHARACTER
|
||||
%token T_ENCAPSED_AND_WHITESPACE
|
||||
%token T_CONSTANT_ENCAPSED_STRING
|
||||
%token T_ECHO
|
||||
%token T_DO
|
||||
%token T_WHILE
|
||||
%token T_ENDWHILE
|
||||
%token T_FOR
|
||||
%token T_ENDFOR
|
||||
%token T_FOREACH
|
||||
%token T_ENDFOREACH
|
||||
%token T_DECLARE
|
||||
%token T_ENDDECLARE
|
||||
%token T_AS
|
||||
%token T_SWITCH
|
||||
%token T_ENDSWITCH
|
||||
%token T_CASE
|
||||
%token T_DEFAULT
|
||||
%token T_BREAK
|
||||
%token T_CONTINUE
|
||||
%token T_OLD_FUNCTION
|
||||
%token T_FUNCTION
|
||||
%token T_CONST
|
||||
%token T_RETURN
|
||||
%token T_USE
|
||||
%token T_GLOBAL
|
||||
%token T_STATIC
|
||||
%token T_VAR
|
||||
%token T_UNSET
|
||||
%token T_ISSET
|
||||
%token T_EMPTY
|
||||
%token T_CLASS
|
||||
%token T_EXTENDS
|
||||
%token T_OBJECT_OPERATOR
|
||||
%token T_DOUBLE_ARROW
|
||||
%token T_LIST
|
||||
%token T_ARRAY
|
||||
%token T_LINE
|
||||
%token T_FILE
|
||||
%token T_COMMENT
|
||||
%token T_ML_COMMENT
|
||||
%token T_OPEN_TAG
|
||||
%token T_OPEN_TAG_WITH_ECHO
|
||||
%token T_CLOSE_TAG
|
||||
%token T_WHITESPACE
|
||||
%token T_START_HEREDOC
|
||||
%token T_END_HEREDOC
|
||||
%token T_DOLLAR_OPEN_CURLY_BRACES
|
||||
%token T_CURLY_OPEN
|
||||
%token T_PAAMAYIM_NEKUDOTAYIM
|
||||
|
||||
%% /* Rules */
|
||||
|
||||
start:
|
||||
top_statement_list
|
||||
;
|
||||
|
||||
top_statement_list:
|
||||
top_statement_list { zend_do_extended_info(TSRMLS_C); } top_statement { HANDLE_INTERACTIVE(); }
|
||||
| /* empty */
|
||||
;
|
||||
|
||||
|
||||
top_statement:
|
||||
statement
|
||||
| declaration_statement { zend_do_early_binding(TSRMLS_C); }
|
||||
;
|
||||
|
||||
|
||||
inner_statement_list:
|
||||
inner_statement_list { zend_do_extended_info(TSRMLS_C); } inner_statement { HANDLE_INTERACTIVE(); }
|
||||
| /* empty */
|
||||
;
|
||||
|
||||
|
||||
inner_statement:
|
||||
statement
|
||||
| declaration_statement
|
||||
;
|
||||
|
||||
|
||||
statement:
|
||||
unticked_statement { zend_do_ticks(TSRMLS_C); }
|
||||
;
|
||||
|
||||
|
||||
unticked_statement:
|
||||
'{' inner_statement_list '}'
|
||||
| T_IF '(' expr ')' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } statement { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); }
|
||||
| T_IF '(' expr ')' ':' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(TSRMLS_C); }
|
||||
| T_WHILE '(' { $1.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' { zend_do_while_cond(&$4, &$5 TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$5 TSRMLS_CC); }
|
||||
| T_DO { $1.u.opline_num = get_next_op_number(CG(active_op_array)); zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE '(' { $5.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' ';' { zend_do_do_while_end(&$1, &$5, &$7 TSRMLS_CC); }
|
||||
| T_FOR
|
||||
'('
|
||||
for_expr
|
||||
';' { zend_do_free(&$3 TSRMLS_CC); $4.u.opline_num = get_next_op_number(CG(active_op_array)); }
|
||||
for_expr
|
||||
';' { zend_do_extended_info(TSRMLS_C); zend_do_for_cond(&$6, &$7 TSRMLS_CC); }
|
||||
for_expr
|
||||
')' { zend_do_free(&$9 TSRMLS_CC); zend_do_for_before_statement(&$4, &$7 TSRMLS_CC); }
|
||||
for_statement { zend_do_for_end(&$7 TSRMLS_CC); }
|
||||
| T_SWITCH '(' expr ')' { zend_do_switch_cond(&$3 TSRMLS_CC); } switch_case_list { zend_do_switch_end(&$6 TSRMLS_CC); }
|
||||
| T_BREAK ';' { zend_do_brk_cont(ZEND_BRK, NULL TSRMLS_CC); }
|
||||
| T_BREAK expr ';' { zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); }
|
||||
| T_CONTINUE ';' { zend_do_brk_cont(ZEND_CONT, NULL TSRMLS_CC); }
|
||||
| T_CONTINUE expr ';' { zend_do_brk_cont(ZEND_CONT, &$2 TSRMLS_CC); }
|
||||
| T_RETURN ';' { zend_do_return(NULL, 0 TSRMLS_CC); }
|
||||
| T_RETURN expr_without_variable ';' { zend_do_return(&$2, 0 TSRMLS_CC); }
|
||||
| T_RETURN cvar ';' { zend_do_return(&$2, 1 TSRMLS_CC); }
|
||||
| T_GLOBAL global_var_list ';'
|
||||
| T_STATIC static_var_list ';'
|
||||
| T_ECHO echo_expr_list ';'
|
||||
| T_INLINE_HTML { zend_do_echo(&$1 TSRMLS_CC); }
|
||||
| expr ';' { zend_do_free(&$1 TSRMLS_CC); }
|
||||
| T_USE use_filename ';' { zend_error(E_COMPILE_ERROR,"use: Not yet supported. Please use include_once() or require_once()"); zval_dtor(&$2.u.constant); }
|
||||
| T_UNSET '(' unset_variables ')' ';'
|
||||
| T_FOREACH '(' w_cvar T_AS { zend_do_foreach_begin(&$1, &$3, &$2, &$4, 1 TSRMLS_CC); } w_cvar foreach_optional_arg ')' { zend_do_foreach_cont(&$6, &$7, &$4 TSRMLS_CC); } foreach_statement { zend_do_foreach_end(&$1, &$2 TSRMLS_CC); }
|
||||
| T_FOREACH '(' expr_without_variable T_AS { zend_do_foreach_begin(&$1, &$3, &$2, &$4, 0 TSRMLS_CC); } w_cvar foreach_optional_arg ')' { zend_do_foreach_cont(&$6, &$7, &$4 TSRMLS_CC); } foreach_statement { zend_do_foreach_end(&$1, &$2 TSRMLS_CC); }
|
||||
| T_DECLARE { zend_do_declare_begin(TSRMLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end(TSRMLS_C); }
|
||||
| ';' /* empty statement */
|
||||
;
|
||||
|
||||
unset_variables:
|
||||
unset_variable
|
||||
| unset_variables ',' unset_variable
|
||||
;
|
||||
|
||||
unset_variable:
|
||||
cvar { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
use_filename:
|
||||
T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
|
||||
| '(' T_CONSTANT_ENCAPSED_STRING ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
||||
declaration_statement:
|
||||
unticked_declaration_statement { zend_do_ticks(TSRMLS_C); }
|
||||
;
|
||||
|
||||
|
||||
unticked_declaration_statement:
|
||||
T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 0, $3.op_type TSRMLS_CC); }
|
||||
'(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
|
||||
| T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 0, $3.op_type TSRMLS_CC); }
|
||||
parameter_list '(' inner_statement_list ')' ';' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
|
||||
| T_CLASS T_STRING { zend_do_begin_class_declaration(&$2, NULL TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(TSRMLS_C); }
|
||||
| T_CLASS T_STRING T_EXTENDS T_STRING { zend_do_begin_class_declaration(&$2, &$4 TSRMLS_CC); } '{' class_statement_list '}' { zend_do_end_class_declaration(TSRMLS_C); }
|
||||
;
|
||||
|
||||
|
||||
foreach_optional_arg:
|
||||
/* empty */ { $$.op_type = IS_UNUSED; }
|
||||
| T_DOUBLE_ARROW w_cvar { $$ = $2; }
|
||||
;
|
||||
|
||||
|
||||
for_statement:
|
||||
statement
|
||||
| ':' inner_statement_list T_ENDFOR ';'
|
||||
;
|
||||
|
||||
|
||||
foreach_statement:
|
||||
statement
|
||||
| ':' inner_statement_list T_ENDFOREACH ';'
|
||||
;
|
||||
|
||||
|
||||
declare_statement:
|
||||
statement
|
||||
| ':' inner_statement_list T_ENDDECLARE ';'
|
||||
;
|
||||
|
||||
|
||||
declare_list:
|
||||
T_STRING '=' static_scalar { zend_do_declare_stmt(&$1, &$3 TSRMLS_CC); }
|
||||
| declare_list ',' T_STRING '=' static_scalar { zend_do_declare_stmt(&$3, &$5 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
switch_case_list:
|
||||
'{' case_list '}' { $$ = $2; }
|
||||
| '{' ';' case_list '}' { $$ = $3; }
|
||||
| ':' case_list T_ENDSWITCH ';' { $$ = $2; }
|
||||
| ':' ';' case_list T_ENDSWITCH ';' { $$ = $3; }
|
||||
;
|
||||
|
||||
|
||||
case_list:
|
||||
/* empty */ { $$.op_type = IS_UNUSED; }
|
||||
| case_list T_CASE expr case_separator { zend_do_extended_info(TSRMLS_C); zend_do_case_before_statement(&$1, &$2, &$3 TSRMLS_CC); } inner_statement_list { zend_do_case_after_statement(&$$, &$2 TSRMLS_CC); $$.op_type = IS_CONST }
|
||||
| case_list T_DEFAULT case_separator { zend_do_extended_info(TSRMLS_C); zend_do_default_before_statement(&$1, &$2 TSRMLS_CC); } inner_statement_list { zend_do_case_after_statement(&$$, &$2 TSRMLS_CC); $$.op_type = IS_CONST; }
|
||||
;
|
||||
|
||||
|
||||
case_separator:
|
||||
':'
|
||||
| ';'
|
||||
;
|
||||
|
||||
|
||||
while_statement:
|
||||
statement
|
||||
| ':' inner_statement_list T_ENDWHILE ';'
|
||||
;
|
||||
|
||||
|
||||
|
||||
elseif_list:
|
||||
/* empty */
|
||||
| elseif_list T_ELSEIF '(' expr ')' { zend_do_if_cond(&$4, &$5 TSRMLS_CC); } statement { zend_do_if_after_statement(&$5, 0 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
new_elseif_list:
|
||||
/* empty */
|
||||
| new_elseif_list T_ELSEIF '(' expr ')' ':' { zend_do_if_cond(&$4, &$5 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$5, 0 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
else_single:
|
||||
/* empty */
|
||||
| T_ELSE statement
|
||||
;
|
||||
|
||||
|
||||
new_else_single:
|
||||
/* empty */
|
||||
| T_ELSE ':' inner_statement_list
|
||||
;
|
||||
|
||||
|
||||
parameter_list:
|
||||
non_empty_parameter_list
|
||||
| /* empty */
|
||||
;
|
||||
|
||||
|
||||
non_empty_parameter_list:
|
||||
T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$1, 0 TSRMLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE TSRMLS_CC); }
|
||||
| '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$2, 0 TSRMLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_FORCE TSRMLS_CC); }
|
||||
| T_CONST T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$2, 0 TSRMLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE TSRMLS_CC); }
|
||||
| T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$1, 0 TSRMLS_CC); $$.op_type = IS_CONST; $$.u.constant.value.lval=1; $$.u.constant.type=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$3, BYREF_NONE TSRMLS_CC); }
|
||||
| non_empty_parameter_list ',' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$3, 0 TSRMLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE TSRMLS_CC); }
|
||||
| non_empty_parameter_list ',' '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$4, 0 TSRMLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_FORCE TSRMLS_CC); }
|
||||
| non_empty_parameter_list ',' T_CONST T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$4, 0 TSRMLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, BYREF_NONE TSRMLS_CC); }
|
||||
| non_empty_parameter_list ',' T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$3, 0 TSRMLS_CC); $$=$1; $$.u.constant.value.lval++; zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$5, BYREF_NONE TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
function_call_parameter_list:
|
||||
non_empty_function_call_parameter_list { $$ = $1; }
|
||||
| /* empty */ { $$.u.constant.value.lval = 0; }
|
||||
;
|
||||
|
||||
|
||||
non_empty_function_call_parameter_list:
|
||||
expr_without_variable { $$.u.constant.value.lval = 1; zend_do_pass_param(&$1, ZEND_SEND_VAL, $$.u.constant.value.lval TSRMLS_CC); }
|
||||
| cvar { $$.u.constant.value.lval = 1; zend_do_pass_param(&$1, ZEND_SEND_VAR, $$.u.constant.value.lval TSRMLS_CC); }
|
||||
| '&' w_cvar { $$.u.constant.value.lval = 1; zend_do_pass_param(&$2, ZEND_SEND_REF, $$.u.constant.value.lval TSRMLS_CC); }
|
||||
| non_empty_function_call_parameter_list ',' expr_without_variable { $$.u.constant.value.lval=$1.u.constant.value.lval+1; zend_do_pass_param(&$3, ZEND_SEND_VAL, $$.u.constant.value.lval TSRMLS_CC); }
|
||||
| non_empty_function_call_parameter_list ',' cvar { $$.u.constant.value.lval=$1.u.constant.value.lval+1; zend_do_pass_param(&$3, ZEND_SEND_VAR, $$.u.constant.value.lval TSRMLS_CC); }
|
||||
| non_empty_function_call_parameter_list ',' '&' w_cvar { $$.u.constant.value.lval=$1.u.constant.value.lval+1; zend_do_pass_param(&$4, ZEND_SEND_REF, $$.u.constant.value.lval TSRMLS_CC); }
|
||||
;
|
||||
|
||||
global_var_list:
|
||||
global_var_list ',' global_var { zend_do_fetch_global_or_static_variable(&$3, NULL, ZEND_FETCH_GLOBAL TSRMLS_CC); }
|
||||
| global_var { zend_do_fetch_global_or_static_variable(&$1, NULL, ZEND_FETCH_GLOBAL TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
global_var:
|
||||
T_VARIABLE { $$ = $1; }
|
||||
| '$' r_cvar { $$ = $2; }
|
||||
| '$' '{' expr '}' { $$ = $3; }
|
||||
;
|
||||
|
||||
|
||||
static_var_list:
|
||||
static_var_list ',' T_VARIABLE { zend_do_fetch_global_or_static_variable(&$3, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
|
||||
| static_var_list ',' T_VARIABLE '=' static_scalar { zend_do_fetch_global_or_static_variable(&$3, &$5, ZEND_FETCH_STATIC TSRMLS_CC); }
|
||||
| T_VARIABLE { zend_do_fetch_global_or_static_variable(&$1, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
|
||||
| T_VARIABLE '=' static_scalar { zend_do_fetch_global_or_static_variable(&$1, &$3, ZEND_FETCH_STATIC TSRMLS_CC); }
|
||||
|
||||
;
|
||||
|
||||
|
||||
class_statement_list:
|
||||
class_statement_list class_statement
|
||||
| /* empty */
|
||||
;
|
||||
|
||||
|
||||
class_statement:
|
||||
T_VAR class_variable_decleration ';'
|
||||
| T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type TSRMLS_CC); } '('
|
||||
parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
|
||||
| T_OLD_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 1, $3.op_type TSRMLS_CC); }
|
||||
parameter_list '(' inner_statement_list ')' ';' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
|
||||
|
||||
;
|
||||
|
||||
is_reference:
|
||||
/* empty */ { $$.op_type = ZEND_RETURN_VAL; }
|
||||
| '&' { $$.op_type = ZEND_RETURN_REF; }
|
||||
|
||||
class_variable_decleration:
|
||||
class_variable_decleration ',' T_VARIABLE { zend_do_declare_property(&$3, NULL TSRMLS_CC); }
|
||||
| class_variable_decleration ',' T_VARIABLE '=' static_scalar { zend_do_declare_property(&$3, &$5 TSRMLS_CC); }
|
||||
| T_VARIABLE { zend_do_declare_property(&$1, NULL TSRMLS_CC); }
|
||||
| T_VARIABLE '=' static_scalar { zend_do_declare_property(&$1, &$3 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
echo_expr_list:
|
||||
| echo_expr_list ',' expr { zend_do_echo(&$3 TSRMLS_CC); }
|
||||
| expr { zend_do_echo(&$1 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
for_expr:
|
||||
/* empty */ { $$.op_type = IS_CONST; $$.u.constant.type = IS_BOOL; $$.u.constant.value.lval = 1; }
|
||||
| non_empty_for_expr { $$ = $1; }
|
||||
;
|
||||
|
||||
non_empty_for_expr:
|
||||
non_empty_for_expr ',' { zend_do_free(&$1 TSRMLS_CC); } expr { $$ = $4; }
|
||||
| expr { $$ = $1; }
|
||||
;
|
||||
|
||||
|
||||
expr_without_variable:
|
||||
T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 TSRMLS_CC); }
|
||||
| cvar '=' expr { zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign(&$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar '=' '&' w_cvar { zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$4 TSRMLS_CC); }
|
||||
| cvar '=' '&' function_call { zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$4 TSRMLS_CC); }
|
||||
| cvar '=' '&' T_NEW static_or_variable_string { zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$4, &$5 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$3, &$5, &$4, &$7 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$3 TSRMLS_CC); }
|
||||
| T_NEW static_or_variable_string { zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$1, &$2 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$$, &$2, &$1, &$4 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
|
||||
| cvar T_PLUS_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_ADD, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_MINUS_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SUB, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_MUL_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_MUL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_DIV_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_DIV, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_CONCAT_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_CONCAT, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_MOD_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_MOD, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_AND_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_AND, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_OR_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_OR, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_XOR_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_XOR, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_SL_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| cvar T_SR_EQUAL expr { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SR, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| rw_cvar T_INC { zend_do_post_incdec(&$$, &$1, ZEND_POST_INC TSRMLS_CC); }
|
||||
| T_INC rw_cvar { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_INC TSRMLS_CC); }
|
||||
| rw_cvar T_DEC { zend_do_post_incdec(&$$, &$1, ZEND_POST_DEC TSRMLS_CC); }
|
||||
| T_DEC rw_cvar { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_DEC TSRMLS_CC); }
|
||||
| expr T_BOOLEAN_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
|
||||
| expr T_BOOLEAN_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
|
||||
| expr T_LOGICAL_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
|
||||
| expr T_LOGICAL_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
|
||||
| expr T_LOGICAL_XOR expr { zend_do_binary_op(ZEND_BOOL_XOR, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr '|' expr { zend_do_binary_op(ZEND_BW_OR, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr '&' expr { zend_do_binary_op(ZEND_BW_AND, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr '^' expr { zend_do_binary_op(ZEND_BW_XOR, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr '.' expr { zend_do_binary_op(ZEND_CONCAT,&$$,&$1,&$3 TSRMLS_CC); }
|
||||
| expr '+' expr { zend_do_binary_op(ZEND_ADD,&$$,&$1,&$3 TSRMLS_CC); }
|
||||
| expr '-' expr { zend_do_binary_op(ZEND_SUB,&$$,&$1,&$3 TSRMLS_CC); }
|
||||
| expr '*' expr { zend_do_binary_op(ZEND_MUL,&$$,&$1,&$3 TSRMLS_CC); }
|
||||
| expr '/' expr { zend_do_binary_op(ZEND_DIV,&$$,&$1,&$3 TSRMLS_CC); }
|
||||
| expr '%' expr { zend_do_binary_op(ZEND_MOD,&$$,&$1,&$3 TSRMLS_CC); }
|
||||
| expr T_SL expr { zend_do_binary_op(ZEND_SL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr T_SR expr { zend_do_binary_op(ZEND_SR, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| '+' expr { $1.u.constant.value.lval=0; $1.u.constant.type=IS_LONG; $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); zend_do_binary_op(ZEND_ADD, &$$, &$1, &$2 TSRMLS_CC); }
|
||||
| '-' expr { $1.u.constant.value.lval=0; $1.u.constant.type=IS_LONG; $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); zend_do_binary_op(ZEND_SUB, &$$, &$1, &$2 TSRMLS_CC); }
|
||||
| '!' expr { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$2 TSRMLS_CC); }
|
||||
| '~' expr { zend_do_unary_op(ZEND_BW_NOT, &$$, &$2 TSRMLS_CC); }
|
||||
| expr T_IS_IDENTICAL expr { zend_do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr T_IS_NOT_IDENTICAL expr { zend_do_binary_op(ZEND_IS_NOT_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr T_IS_EQUAL expr { zend_do_binary_op(ZEND_IS_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr T_IS_NOT_EQUAL expr { zend_do_binary_op(ZEND_IS_NOT_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr '<' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr T_IS_SMALLER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
|
||||
| expr '>' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 TSRMLS_CC); }
|
||||
| expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); }
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
| expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
|
||||
expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
|
||||
expr { zend_do_qm_false(&$$, &$7, &$2, &$5 TSRMLS_CC); }
|
||||
| function_call { $$ = $1; }
|
||||
| internal_functions_in_yacc { $$ = $1; }
|
||||
| T_INT_CAST expr { zend_do_cast(&$$, &$2, IS_LONG TSRMLS_CC); }
|
||||
| T_DOUBLE_CAST expr { zend_do_cast(&$$, &$2, IS_DOUBLE TSRMLS_CC); }
|
||||
| T_STRING_CAST expr { zend_do_cast(&$$, &$2, IS_STRING TSRMLS_CC); }
|
||||
| T_ARRAY_CAST expr { zend_do_cast(&$$, &$2, IS_ARRAY TSRMLS_CC); }
|
||||
| T_OBJECT_CAST expr { zend_do_cast(&$$, &$2, IS_OBJECT TSRMLS_CC); }
|
||||
| T_BOOL_CAST expr { zend_do_cast(&$$, &$2, IS_BOOL TSRMLS_CC); }
|
||||
| T_UNSET_CAST expr { zend_do_cast(&$$, &$2, IS_NULL TSRMLS_CC); }
|
||||
| T_EXIT exit_expr { zend_do_exit(&$$, &$2 TSRMLS_CC); }
|
||||
| '@' { zend_do_begin_silence(&$1 TSRMLS_CC); } expr { zend_do_end_silence(&$1 TSRMLS_CC); $$ = $3; }
|
||||
| scalar { $$ = $1; }
|
||||
| T_ARRAY '(' array_pair_list ')' { $$ = $3; }
|
||||
| '`' encaps_list '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); }
|
||||
| T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
function_call:
|
||||
T_STRING '(' { $2.u.opline_num = zend_do_begin_function_call(&$1 TSRMLS_CC); }
|
||||
function_call_parameter_list
|
||||
')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
|
||||
| cvar '(' { zend_do_begin_dynamic_function_call(&$1 TSRMLS_CC); }
|
||||
function_call_parameter_list
|
||||
')' { zend_do_end_function_call(&$1, &$$, &$4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
|
||||
| T_STRING T_PAAMAYIM_NEKUDOTAYIM static_or_variable_string '(' { zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
|
||||
function_call_parameter_list
|
||||
')' { zend_do_end_function_call(&$3, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
|
||||
;
|
||||
|
||||
|
||||
static_or_variable_string:
|
||||
T_STRING { $$ = $1; }
|
||||
| r_cvar { $$ = $1; }
|
||||
;
|
||||
|
||||
|
||||
exit_expr:
|
||||
/* empty */ { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
|
||||
| '(' ')' { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
||||
ctor_arguments:
|
||||
/* empty */ { $$.u.constant.value.lval=0; }
|
||||
| '(' function_call_parameter_list ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
||||
common_scalar:
|
||||
T_LNUMBER { $$ = $1; }
|
||||
| T_DNUMBER { $$ = $1; }
|
||||
| T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
|
||||
| T_LINE { $$ = $1; }
|
||||
| T_FILE { $$ = $1; }
|
||||
;
|
||||
|
||||
|
||||
static_scalar: /* compile-time evaluated scalars */
|
||||
common_scalar { $$ = $1; }
|
||||
| T_STRING { zend_do_fetch_constant(&$$, &$1, ZEND_CT TSRMLS_CC); }
|
||||
| '+' static_scalar { $$ = $1; }
|
||||
| '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC); $$ = $2; }
|
||||
| T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; }
|
||||
;
|
||||
|
||||
|
||||
scalar:
|
||||
T_STRING { zend_do_fetch_constant(&$$, &$1, ZEND_RT TSRMLS_CC); }
|
||||
| T_STRING_VARNAME { $$ = $1; }
|
||||
| common_scalar { $$ = $1; }
|
||||
| '"' encaps_list '"' { $$ = $2; }
|
||||
| '\'' encaps_list '\'' { $$ = $2; }
|
||||
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; zend_do_end_heredoc(TSRMLS_C); }
|
||||
;
|
||||
|
||||
|
||||
static_array_pair_list:
|
||||
/* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); }
|
||||
| non_empty_static_array_pair_list possible_comma { $$ = $1; }
|
||||
;
|
||||
|
||||
possible_comma:
|
||||
/* empty */
|
||||
| ','
|
||||
;
|
||||
|
||||
non_empty_static_array_pair_list:
|
||||
non_empty_static_array_pair_list ',' static_scalar T_DOUBLE_ARROW static_scalar { zend_do_add_static_array_element(&$$, &$3, &$5); }
|
||||
| non_empty_static_array_pair_list ',' static_scalar { zend_do_add_static_array_element(&$$, NULL, &$3); }
|
||||
| static_scalar T_DOUBLE_ARROW static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, &$1, &$3); }
|
||||
| static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, NULL, &$1); }
|
||||
;
|
||||
|
||||
expr:
|
||||
r_cvar { $$ = $1; }
|
||||
| expr_without_variable { $$ = $1; }
|
||||
;
|
||||
|
||||
|
||||
r_cvar:
|
||||
cvar { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); $$ = $1; }
|
||||
;
|
||||
|
||||
|
||||
w_cvar:
|
||||
cvar { zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); $$ = $1; }
|
||||
;
|
||||
|
||||
|
||||
rw_cvar:
|
||||
cvar { zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); $$ = $1; }
|
||||
;
|
||||
|
||||
|
||||
cvar:
|
||||
cvar_without_objects { $$ = $1; }
|
||||
| cvar_without_objects T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); } ref_list { $$ = $4; }
|
||||
;
|
||||
|
||||
|
||||
cvar_without_objects:
|
||||
reference_variable { $$ = $1; }
|
||||
| simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
reference_variable:
|
||||
reference_variable '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
|
||||
| reference_variable '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
|
||||
| compound_variable { zend_do_fetch_globals(&$1 TSRMLS_CC); zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
compound_variable:
|
||||
T_VARIABLE { $$ = $1; }
|
||||
| '$' '{' expr '}' { $$ = $3; }
|
||||
;
|
||||
|
||||
dim_offset:
|
||||
/* empty */ { $$.op_type = IS_UNUSED; }
|
||||
| expr { $$ = $1; }
|
||||
;
|
||||
|
||||
ref_list:
|
||||
object_property { $$ = $1; }
|
||||
| ref_list T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); } object_property { $$ = $4; }
|
||||
;
|
||||
|
||||
object_property:
|
||||
object_dim_list { $$ = $1; }
|
||||
| cvar_without_objects { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); } { znode tmp_znode; zend_do_pop_object(&tmp_znode TSRMLS_CC); zend_do_fetch_property(&$$, &tmp_znode, &$1 TSRMLS_CC);}
|
||||
;
|
||||
|
||||
object_dim_list:
|
||||
object_dim_list '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
|
||||
| object_dim_list '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
|
||||
| variable_name { znode tmp_znode; zend_do_pop_object(&tmp_znode TSRMLS_CC); zend_do_fetch_property(&$$, &tmp_znode, &$1 TSRMLS_CC);}
|
||||
;
|
||||
|
||||
variable_name:
|
||||
T_STRING { $$ = $1; }
|
||||
| '{' expr '}' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
||||
simple_indirect_reference:
|
||||
'$' { $$.u.constant.value.lval = 1; }
|
||||
| simple_indirect_reference '$' { $$.u.constant.value.lval++; }
|
||||
;
|
||||
|
||||
assignment_list:
|
||||
assignment_list ',' assignment_list_element
|
||||
| assignment_list_element
|
||||
;
|
||||
|
||||
|
||||
assignment_list_element:
|
||||
cvar { zend_do_add_list_element(&$1 TSRMLS_CC); }
|
||||
| T_LIST '(' { zend_do_new_list_begin(TSRMLS_C); } assignment_list ')' { zend_do_new_list_end(TSRMLS_C); }
|
||||
| /* empty */ { zend_do_add_list_element(NULL TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
array_pair_list:
|
||||
/* empty */ { zend_do_init_array(&$$, NULL, NULL, 0 TSRMLS_CC); }
|
||||
| non_empty_array_pair_list possible_comma { $$ = $1; }
|
||||
;
|
||||
|
||||
non_empty_array_pair_list:
|
||||
non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr { zend_do_add_array_element(&$$, &$5, &$3, 0 TSRMLS_CC); }
|
||||
| non_empty_array_pair_list ',' expr { zend_do_add_array_element(&$$, &$3, NULL, 0 TSRMLS_CC); }
|
||||
| expr T_DOUBLE_ARROW expr { zend_do_init_array(&$$, &$3, &$1, 0 TSRMLS_CC); }
|
||||
| expr { zend_do_init_array(&$$, &$1, NULL, 0 TSRMLS_CC); }
|
||||
| non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_cvar { zend_do_add_array_element(&$$, &$6, &$3, 1 TSRMLS_CC); }
|
||||
| non_empty_array_pair_list ',' '&' w_cvar { zend_do_add_array_element(&$$, &$4, NULL, 1 TSRMLS_CC); }
|
||||
| expr T_DOUBLE_ARROW '&' w_cvar { zend_do_init_array(&$$, &$4, &$1, 1 TSRMLS_CC); }
|
||||
| '&' w_cvar { zend_do_init_array(&$$, &$2, NULL, 1 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
encaps_list:
|
||||
encaps_list encaps_var { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_add_variable(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list T_STRING { zend_do_add_string(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list T_NUM_STRING { zend_do_add_string(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list T_ENCAPSED_AND_WHITESPACE { zend_do_add_string(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list T_CHARACTER { zend_do_add_char(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list T_BAD_CHARACTER { zend_do_add_string(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list '[' { $2.u.constant.value.lval = (long) '['; zend_do_add_char(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list ']' { $2.u.constant.value.lval = (long) ']'; zend_do_add_char(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list '{' { $2.u.constant.value.lval = (long) '{'; zend_do_add_char(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list '}' { $2.u.constant.value.lval = (long) '}'; zend_do_add_char(&$$, &$1, &$2 TSRMLS_CC); }
|
||||
| encaps_list T_OBJECT_OPERATOR { znode tmp; $2.u.constant.value.lval = (long) '-'; zend_do_add_char(&tmp, &$1, &$2 TSRMLS_CC); $2.u.constant.value.lval = (long) '>'; zend_do_add_char(&$$, &tmp, &$2 TSRMLS_CC); }
|
||||
| /* empty */ { zend_do_init_string(&$$ TSRMLS_CC); }
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
encaps_var:
|
||||
T_VARIABLE { zend_do_fetch_globals(&$1 TSRMLS_CC); zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
|
||||
| T_VARIABLE '[' { zend_do_begin_variable_parse(TSRMLS_C); } encaps_var_offset ']' { zend_do_fetch_globals(&$1 TSRMLS_CC); fetch_array_begin(&$$, &$1, &$4 TSRMLS_CC); }
|
||||
| T_VARIABLE T_OBJECT_OPERATOR T_STRING { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$2, &$1, 1 TSRMLS_CC); zend_do_fetch_property(&$$, &$2, &$3 TSRMLS_CC); }
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES expr '}' { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$2, 1 TSRMLS_CC); }
|
||||
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_begin(&$$, &$2, &$4 TSRMLS_CC); }
|
||||
| T_CURLY_OPEN cvar '}' { $$ = $2; }
|
||||
;
|
||||
|
||||
|
||||
encaps_var_offset:
|
||||
T_STRING { $$ = $1; }
|
||||
| T_NUM_STRING { $$ = $1; }
|
||||
| T_VARIABLE { fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
|
||||
internal_functions_in_yacc:
|
||||
T_ISSET '(' isset_variables ')' { $$ = $3; }
|
||||
| T_EMPTY '(' cvar ')' { zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 TSRMLS_CC); }
|
||||
| T_INCLUDE expr { zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 TSRMLS_CC); }
|
||||
| T_INCLUDE_ONCE expr { zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 TSRMLS_CC); }
|
||||
| T_EVAL '(' expr ')' { zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 TSRMLS_CC); }
|
||||
| T_REQUIRE expr { zend_do_include_or_eval(ZEND_REQUIRE, &$$, &$2 TSRMLS_CC); }
|
||||
| T_REQUIRE_ONCE expr { zend_do_include_or_eval(ZEND_REQUIRE_ONCE, &$$, &$2 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
isset_variables:
|
||||
cvar { zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$1 TSRMLS_CC); }
|
||||
| isset_variables ',' { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } cvar { znode tmp; zend_do_isset_or_isempty(ZEND_ISSET, &tmp, &$4 TSRMLS_CC); zend_do_boolean_and_end(&$$, &$1, &tmp, &$2 TSRMLS_CC); }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_SCANNER_H
|
||||
#define ZEND_SCANNER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
class ZendFlexLexer : public yyFlexLexer
|
||||
{
|
||||
public:
|
||||
virtual ~ZendFlexLexer();
|
||||
int lex_scan(zval *zendlval TSRMLS_DC);
|
||||
void BeginState(int state);
|
||||
};
|
||||
|
||||
#endif /* ZTS */
|
||||
|
||||
|
||||
typedef struct _zend_lex_state {
|
||||
#ifndef __cplusplus
|
||||
YY_BUFFER_STATE buffer_state;
|
||||
int state;
|
||||
FILE *in;
|
||||
#else
|
||||
ZendFlexLexer *ZFL;
|
||||
istream *input_file;
|
||||
#endif
|
||||
uint lineno;
|
||||
char *filename;
|
||||
} zend_lex_state;
|
||||
|
||||
|
||||
void zend_fatal_scanner_error(char *);
|
||||
BEGIN_EXTERN_C()
|
||||
int zend_compare_file_handles(zend_file_handle *fh1, zend_file_handle *fh2);
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
/* resource lists */
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_list.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_globals.h"
|
||||
|
||||
ZEND_API int le_index_ptr;
|
||||
|
||||
/* true global */
|
||||
static HashTable list_destructors;
|
||||
|
||||
|
||||
ZEND_API int zend_list_insert(void *ptr, int type)
|
||||
{
|
||||
int index;
|
||||
zend_rsrc_list_entry le;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
le.ptr=ptr;
|
||||
le.type=type;
|
||||
le.refcount=1;
|
||||
|
||||
index = zend_hash_next_free_element(&EG(regular_list));
|
||||
zend_hash_index_update(&EG(regular_list), index, (void *) &le, sizeof(zend_rsrc_list_entry), NULL);
|
||||
return index;
|
||||
}
|
||||
|
||||
ZEND_API int _zend_list_delete(int id TSRMLS_DC)
|
||||
{
|
||||
zend_rsrc_list_entry *le;
|
||||
|
||||
if (zend_hash_index_find(&EG(regular_list), id, (void **) &le)==SUCCESS) {
|
||||
/* printf("del(%d): %d->%d\n", id, le->refcount, le->refcount-1); */
|
||||
if (--le->refcount<=0) {
|
||||
return zend_hash_index_del(&EG(regular_list), id);
|
||||
} else {
|
||||
return SUCCESS;
|
||||
}
|
||||
} else {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC)
|
||||
{
|
||||
zend_rsrc_list_entry *le;
|
||||
|
||||
if (zend_hash_index_find(&EG(regular_list), id, (void **) &le)==SUCCESS) {
|
||||
*type = le->type;
|
||||
return le->ptr;
|
||||
} else {
|
||||
*type = -1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int _zend_list_addref(int id TSRMLS_DC)
|
||||
{
|
||||
zend_rsrc_list_entry *le;
|
||||
|
||||
if (zend_hash_index_find(&EG(regular_list), id, (void **) &le)==SUCCESS) {
|
||||
/* printf("add(%d): %d->%d\n", id, le->refcount, le->refcount+1); */
|
||||
le->refcount++;
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type)
|
||||
{
|
||||
int rsrc_id;
|
||||
|
||||
rsrc_id = zend_list_insert(rsrc_pointer, rsrc_type);
|
||||
|
||||
if (rsrc_result) {
|
||||
rsrc_result->value.lval = rsrc_id;
|
||||
rsrc_result->type = IS_RESOURCE;
|
||||
}
|
||||
|
||||
return rsrc_id;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...)
|
||||
{
|
||||
int id;
|
||||
int actual_resource_type;
|
||||
void *resource;
|
||||
va_list resource_types;
|
||||
int i;
|
||||
|
||||
if (default_id==-1) { /* use id */
|
||||
if (!passed_id) {
|
||||
if (resource_type_name) {
|
||||
zend_error(E_WARNING, "No %s resource supplied", resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
} else if ((*passed_id)->type != IS_RESOURCE) {
|
||||
if (resource_type_name) {
|
||||
zend_error(E_WARNING, "Supplied argument is not a valid %s resource", resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
id = (*passed_id)->value.lval;
|
||||
} else {
|
||||
id = default_id;
|
||||
}
|
||||
|
||||
resource = zend_list_find(id, &actual_resource_type);
|
||||
if (!resource) {
|
||||
if (resource_type_name) {
|
||||
zend_error(E_WARNING, "%d is not a valid %s resource", id, resource_type_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
va_start(resource_types, num_resource_types);
|
||||
for (i=0; i<num_resource_types; i++) {
|
||||
if (actual_resource_type == va_arg(resource_types, int)) {
|
||||
va_end(resource_types);
|
||||
if (found_resource_type) {
|
||||
*found_resource_type = actual_resource_type;
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
va_end(resource_types);
|
||||
|
||||
if (resource_type_name) {
|
||||
zend_error(E_WARNING, "Supplied resource is not a valid %s resource", resource_type_name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void list_entry_destructor(void *ptr)
|
||||
{
|
||||
zend_rsrc_list_entry *le = (zend_rsrc_list_entry *) ptr;
|
||||
zend_rsrc_list_dtors_entry *ld;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_index_find(&list_destructors, le->type,(void **) &ld)==SUCCESS) {
|
||||
switch (ld->type) {
|
||||
case ZEND_RESOURCE_LIST_TYPE_STD:
|
||||
if (ld->list_dtor) {
|
||||
(ld->list_dtor)(le->ptr);
|
||||
}
|
||||
break;
|
||||
case ZEND_RESOURCE_LIST_TYPE_EX:
|
||||
if (ld->list_dtor_ex) {
|
||||
ld->list_dtor_ex(le TSRMLS_CC);
|
||||
}
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
} else {
|
||||
zend_error(E_WARNING,"Unknown list entry type in request shutdown (%d)",le->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void plist_entry_destructor(void *ptr)
|
||||
{
|
||||
zend_rsrc_list_entry *le = (zend_rsrc_list_entry *) ptr;
|
||||
zend_rsrc_list_dtors_entry *ld;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zend_hash_index_find(&list_destructors, le->type,(void **) &ld)==SUCCESS) {
|
||||
switch (ld->type) {
|
||||
case ZEND_RESOURCE_LIST_TYPE_STD:
|
||||
if (ld->plist_dtor) {
|
||||
(ld->plist_dtor)(le->ptr);
|
||||
}
|
||||
break;
|
||||
case ZEND_RESOURCE_LIST_TYPE_EX:
|
||||
if (ld->plist_dtor_ex) {
|
||||
ld->plist_dtor_ex(le TSRMLS_CC);
|
||||
}
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
} else {
|
||||
zend_error(E_WARNING,"Unknown persistent list entry type in module shutdown (%d)",le->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int zend_init_rsrc_list(TSRMLS_D)
|
||||
{
|
||||
if (zend_hash_init(&EG(regular_list), 0, NULL, list_entry_destructor, 0)==SUCCESS) {
|
||||
EG(regular_list).nNextFreeElement=1; /* we don't want resource id 0 */
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int zend_init_rsrc_plist(TSRMLS_D)
|
||||
{
|
||||
return zend_hash_init_ex(&EG(persistent_list), 0, NULL, plist_entry_destructor, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC)
|
||||
{
|
||||
Bucket *p, *q;
|
||||
|
||||
while (1) {
|
||||
p = ht->pListTail;
|
||||
if (!p) {
|
||||
break;
|
||||
}
|
||||
q = p->pListLast;
|
||||
if (q) {
|
||||
q->pListNext = NULL;
|
||||
}
|
||||
ht->pListTail = q;
|
||||
|
||||
if (ht->pDestructor) {
|
||||
zend_try {
|
||||
ht->pDestructor(p->pData);
|
||||
} zend_end_try();
|
||||
}
|
||||
if (!p->pDataPtr && p->pData) {
|
||||
pefree(p->pData, ht->persistent);
|
||||
}
|
||||
pefree(p, ht->persistent);
|
||||
}
|
||||
pefree(ht->arBuckets, ht->persistent);
|
||||
}
|
||||
|
||||
|
||||
static int clean_module_resource(zend_rsrc_list_entry *le, int *resource_id TSRMLS_DC)
|
||||
{
|
||||
if (le->type == *resource_id) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int zend_clean_module_rsrc_dtors_cb(zend_rsrc_list_dtors_entry *ld, int *module_number TSRMLS_DC)
|
||||
{
|
||||
if (ld->module_number == *module_number) {
|
||||
zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC);
|
||||
zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t) clean_module_resource, (void *) &(ld->resource_id) TSRMLS_CC);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC)
|
||||
{
|
||||
zend_hash_apply_with_argument(&list_destructors, (apply_func_arg_t) zend_clean_module_rsrc_dtors_cb, (void *) &module_number TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number)
|
||||
{
|
||||
zend_rsrc_list_dtors_entry lde;
|
||||
|
||||
#if 0
|
||||
printf("Registering destructors %d for module %d\n", list_destructors.nNextFreeElement, module_number);
|
||||
#endif
|
||||
|
||||
lde.list_dtor=(void (*)(void *)) ld;
|
||||
lde.plist_dtor=(void (*)(void *)) pld;
|
||||
lde.list_dtor_ex = lde.plist_dtor_ex = NULL;
|
||||
lde.module_number = module_number;
|
||||
lde.resource_id = list_destructors.nNextFreeElement;
|
||||
lde.type = ZEND_RESOURCE_LIST_TYPE_STD;
|
||||
lde.type_name = NULL;
|
||||
|
||||
if (zend_hash_next_index_insert(&list_destructors, (void *) &lde, sizeof(zend_rsrc_list_dtors_entry), NULL)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
return list_destructors.nNextFreeElement-1;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number)
|
||||
{
|
||||
zend_rsrc_list_dtors_entry lde;
|
||||
|
||||
#if 0
|
||||
printf("Registering destructors %d for module %d\n", list_destructors.nNextFreeElement, module_number);
|
||||
#endif
|
||||
|
||||
lde.list_dtor = NULL;
|
||||
lde.plist_dtor = NULL;
|
||||
lde.list_dtor_ex = ld;
|
||||
lde.plist_dtor_ex = pld;
|
||||
lde.module_number = module_number;
|
||||
lde.resource_id = list_destructors.nNextFreeElement;
|
||||
lde.type = ZEND_RESOURCE_LIST_TYPE_EX;
|
||||
lde.type_name = type_name;
|
||||
|
||||
if (zend_hash_next_index_insert(&list_destructors,(void *) &lde, sizeof(zend_rsrc_list_dtors_entry),NULL)==FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
return list_destructors.nNextFreeElement-1;
|
||||
}
|
||||
|
||||
ZEND_API int zend_fetch_list_dtor_id(char *type_name)
|
||||
{
|
||||
zend_rsrc_list_dtors_entry *lde;
|
||||
HashPosition pos;
|
||||
|
||||
zend_hash_internal_pointer_reset_ex(&list_destructors, &pos);
|
||||
while(zend_hash_get_current_data_ex(&list_destructors, (void **)&lde, &pos) == SUCCESS) {
|
||||
if(strcmp(type_name, lde->type_name) == 0) {
|
||||
#if 0
|
||||
printf("Found resource id %d for resource type %s\n",(*lde).resource_id,type_name);
|
||||
#endif
|
||||
return lde->resource_id;
|
||||
}
|
||||
zend_hash_move_forward_ex(&list_destructors, &pos);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zend_init_rsrc_list_dtors(void)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = zend_hash_init(&list_destructors, 50, NULL, NULL, 1);
|
||||
list_destructors.nNextFreeElement=1; /* we don't want resource type 0 */
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void zend_destroy_rsrc_list_dtors(void)
|
||||
{
|
||||
zend_hash_destroy(&list_destructors);
|
||||
}
|
||||
|
||||
|
||||
char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC)
|
||||
{
|
||||
zend_rsrc_list_dtors_entry *lde;
|
||||
int rsrc_type;
|
||||
|
||||
if (!zend_list_find(resource, &rsrc_type))
|
||||
return NULL;
|
||||
|
||||
if (zend_hash_index_find(&list_destructors, rsrc_type, (void **) &lde)==SUCCESS) {
|
||||
return lde->type_name;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_LIST_H
|
||||
#define ZEND_LIST_H
|
||||
|
||||
#include "zend_hash.h"
|
||||
#include "zend_globals.h"
|
||||
|
||||
|
||||
#define ZEND_RESOURCE_LIST_TYPE_STD 1
|
||||
#define ZEND_RESOURCE_LIST_TYPE_EX 2
|
||||
|
||||
typedef struct _zend_rsrc_list_entry {
|
||||
void *ptr;
|
||||
int type;
|
||||
int refcount;
|
||||
} zend_rsrc_list_entry;
|
||||
|
||||
typedef void (*rsrc_dtor_func_t)(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||
#define ZEND_RSRC_DTOR_FUNC(name) void name(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
|
||||
typedef struct _zend_rsrc_list_dtors_entry {
|
||||
/* old style destructors */
|
||||
void (*list_dtor)(void *);
|
||||
void (*plist_dtor)(void *);
|
||||
|
||||
/* new style destructors */
|
||||
rsrc_dtor_func_t list_dtor_ex;
|
||||
rsrc_dtor_func_t plist_dtor_ex;
|
||||
|
||||
char *type_name;
|
||||
|
||||
int module_number;
|
||||
int resource_id;
|
||||
unsigned char type;
|
||||
} zend_rsrc_list_dtors_entry;
|
||||
|
||||
|
||||
#define register_list_destructors(ld, pld) zend_register_list_destructors((void (*)(void *))ld, (void (*)(void *))pld, module_number);
|
||||
ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number);
|
||||
ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number);
|
||||
|
||||
enum list_entry_type {
|
||||
LE_DB=1000
|
||||
};
|
||||
|
||||
void list_entry_destructor(void *ptr);
|
||||
void plist_entry_destructor(void *ptr);
|
||||
|
||||
void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC);
|
||||
int zend_init_rsrc_list(TSRMLS_D);
|
||||
int zend_init_rsrc_plist(TSRMLS_D);
|
||||
void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC);
|
||||
int zend_init_rsrc_list_dtors(void);
|
||||
void zend_destroy_rsrc_list_dtors(void);
|
||||
|
||||
ZEND_API int zend_list_insert(void *ptr, int type);
|
||||
ZEND_API int _zend_list_addref(int id TSRMLS_DC);
|
||||
ZEND_API int _zend_list_delete(int id TSRMLS_DC);
|
||||
ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC);
|
||||
|
||||
#define zend_list_addref(id) _zend_list_addref(id TSRMLS_CC)
|
||||
#define zend_list_delete(id) _zend_list_delete(id TSRMLS_CC)
|
||||
#define zend_list_find(id, type) _zend_list_find(id, type TSRMLS_CC)
|
||||
|
||||
ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
|
||||
ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
|
||||
|
||||
ZEND_API char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC);
|
||||
ZEND_API int zend_fetch_list_dtor_id(char *type_name);
|
||||
|
||||
extern ZEND_API int le_index_ptr; /* list entry type for index pointers */
|
||||
|
||||
#define ZEND_VERIFY_RESOURCE(rsrc) \
|
||||
if (!rsrc) { \
|
||||
RETURN_NULL(); \
|
||||
}
|
||||
|
||||
#define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \
|
||||
rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type); \
|
||||
ZEND_VERIFY_RESOURCE(rsrc);
|
||||
|
||||
#define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1,resource_type2) \
|
||||
rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2); \
|
||||
ZEND_VERIFY_RESOURCE(rsrc);
|
||||
|
||||
#define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type) \
|
||||
zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
|
||||
|
||||
#define ZEND_GET_RESOURCE_TYPE_ID(le_id, le_type_name) \
|
||||
if (le_id == 0) { \
|
||||
le_id = zend_fetch_list_dtor_id(le_type_name); \
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_llist.h"
|
||||
|
||||
ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent)
|
||||
{
|
||||
l->head = NULL;
|
||||
l->tail = NULL;
|
||||
l->size = size;
|
||||
l->dtor = dtor;
|
||||
l->persistent = persistent;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_add_element(zend_llist *l, void *element)
|
||||
{
|
||||
zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent);
|
||||
|
||||
tmp->prev = l->tail;
|
||||
tmp->next = NULL;
|
||||
if (l->tail) {
|
||||
l->tail->next = tmp;
|
||||
} else {
|
||||
l->head = tmp;
|
||||
}
|
||||
l->tail = tmp;
|
||||
memcpy(tmp->data, element, l->size);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element)
|
||||
{
|
||||
zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent);
|
||||
|
||||
tmp->next = l->head;
|
||||
tmp->prev = NULL;
|
||||
if (l->head) {
|
||||
l->head->prev = tmp;
|
||||
} else {
|
||||
l->tail = tmp;
|
||||
}
|
||||
l->head = tmp;
|
||||
memcpy(tmp->data, element, l->size);
|
||||
}
|
||||
|
||||
|
||||
#define DEL_LLIST_ELEMENT(current,l) \
|
||||
if (current->prev) {\
|
||||
current->prev->next = current->next;\
|
||||
} else {\
|
||||
l->head = current->next;\
|
||||
}\
|
||||
if (current->next) {\
|
||||
current->next->prev = current->prev;\
|
||||
} else {\
|
||||
l->tail = current->prev;\
|
||||
}\
|
||||
if (l->dtor) {\
|
||||
l->dtor(current->data);\
|
||||
pefree(current, l->persistent);\
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2))
|
||||
{
|
||||
zend_llist_element *current=l->head;
|
||||
|
||||
while (current) {
|
||||
if (compare(current->data, element)) {
|
||||
DEL_LLIST_ELEMENT(current,l);
|
||||
break;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_destroy(zend_llist *l)
|
||||
{
|
||||
zend_llist_element *current=l->head, *next;
|
||||
|
||||
while (current) {
|
||||
next = current->next;
|
||||
if (l->dtor) {
|
||||
l->dtor(current->data);
|
||||
}
|
||||
pefree(current, l->persistent);
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_clean(zend_llist *l)
|
||||
{
|
||||
zend_llist_destroy(l);
|
||||
l->head = l->tail = NULL;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_remove_tail(zend_llist *l)
|
||||
{
|
||||
zend_llist_element *old_tail;
|
||||
|
||||
if ((old_tail = l->tail)) {
|
||||
if (l->tail->prev) {
|
||||
l->tail->prev->next = NULL;
|
||||
}
|
||||
l->tail = l->tail->prev;
|
||||
pefree(old_tail, l->persistent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src)
|
||||
{
|
||||
zend_llist_element *ptr;
|
||||
|
||||
zend_llist_init(dst, src->size, src->dtor, src->persistent);
|
||||
ptr = src->head;
|
||||
while (ptr) {
|
||||
zend_llist_add_element(dst, ptr->data);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data))
|
||||
{
|
||||
zend_llist_element *element, *next;
|
||||
|
||||
element=l->head;
|
||||
while (element) {
|
||||
next = element->next;
|
||||
if (func(element->data)) {
|
||||
DEL_LLIST_ELEMENT(element,l);
|
||||
}
|
||||
element = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC)
|
||||
{
|
||||
zend_llist_element *element;
|
||||
|
||||
for (element=l->head; element; element=element->next) {
|
||||
func(element->data TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func)
|
||||
{
|
||||
int list_size=0, i;
|
||||
|
||||
zend_llist_element **elements;
|
||||
zend_llist_element *element, **ptr;
|
||||
|
||||
for (element=l->head; element; element=element->next) {
|
||||
list_size++;
|
||||
}
|
||||
|
||||
if (list_size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
elements = (zend_llist_element **) emalloc(list_size*sizeof(zend_llist_element *));
|
||||
|
||||
ptr = &elements[0];
|
||||
|
||||
for (element=l->head; element; element=element->next) {
|
||||
*ptr++ = element;
|
||||
}
|
||||
|
||||
qsort(elements, list_size, sizeof(zend_llist_element *), (int (*)(const void *, const void *)) comp_func);
|
||||
|
||||
l->head = elements[0];
|
||||
elements[0]->prev = NULL;
|
||||
|
||||
for (i=1; i<list_size; i++) {
|
||||
elements[i]->prev = elements[i-1];
|
||||
elements[i-1]->next = elements[i];
|
||||
}
|
||||
elements[i-1]->next = NULL;
|
||||
l->tail = elements[i-1];
|
||||
efree(elements);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg TSRMLS_DC)
|
||||
{
|
||||
zend_llist_element *element;
|
||||
|
||||
for (element=l->head; element; element=element->next) {
|
||||
func(element->data, arg TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func TSRMLS_DC, int num_args, ...)
|
||||
{
|
||||
zend_llist_element *element;
|
||||
va_list args;
|
||||
|
||||
va_start(args, num_args);
|
||||
for (element=l->head; element; element=element->next) {
|
||||
func(element->data, num_args, args TSRMLS_CC);
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_llist_count(zend_llist *l)
|
||||
{
|
||||
zend_llist_element *element;
|
||||
int element_count=0;
|
||||
|
||||
for (element=l->head; element; element=element->next) {
|
||||
element_count++;
|
||||
}
|
||||
return element_count;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos)
|
||||
{
|
||||
zend_llist_position *current = pos ? pos : &l->traverse_ptr;
|
||||
|
||||
*current = l->head;
|
||||
if (*current) {
|
||||
return (*current)->data;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *zend_llist_get_last_ex(zend_llist *l, zend_llist_position *pos)
|
||||
{
|
||||
zend_llist_position *current = pos ? pos : &l->traverse_ptr;
|
||||
|
||||
*current = l->tail;
|
||||
if (*current) {
|
||||
return (*current)->data;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos)
|
||||
{
|
||||
zend_llist_position *current = pos ? pos : &l->traverse_ptr;
|
||||
|
||||
if (*current) {
|
||||
*current = (*current)->next;
|
||||
if (*current) {
|
||||
return (*current)->data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *zend_llist_get_prev_ex(zend_llist *l, zend_llist_position *pos)
|
||||
{
|
||||
zend_llist_position *current = pos ? pos : &l->traverse_ptr;
|
||||
|
||||
if (*current) {
|
||||
*current = (*current)->prev;
|
||||
if (*current) {
|
||||
return (*current)->data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_LLIST_H
|
||||
#define ZEND_LLIST_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct _zend_llist_element {
|
||||
struct _zend_llist_element *next;
|
||||
struct _zend_llist_element *prev;
|
||||
char data[1]; /* Needs to always be last in the struct */
|
||||
} zend_llist_element;
|
||||
|
||||
typedef void (*llist_dtor_func_t)(void *);
|
||||
typedef int (*llist_compare_func_t)(const zend_llist_element *, const zend_llist_element *);
|
||||
typedef void (*llist_apply_with_args_func_t)(void *data, int num_args, va_list args TSRMLS_DC);
|
||||
typedef void (*llist_apply_with_arg_func_t)(void *data, void *arg TSRMLS_DC);
|
||||
typedef void (*llist_apply_func_t)(void * TSRMLS_DC);
|
||||
|
||||
typedef struct _zend_llist {
|
||||
zend_llist_element *head;
|
||||
zend_llist_element *tail;
|
||||
size_t size;
|
||||
llist_dtor_func_t dtor;
|
||||
unsigned char persistent;
|
||||
zend_llist_element *traverse_ptr;
|
||||
} zend_llist;
|
||||
|
||||
typedef zend_llist_element* zend_llist_position;
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char persistent);
|
||||
ZEND_API void zend_llist_add_element(zend_llist *l, void *element);
|
||||
ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element);
|
||||
ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, void *element2));
|
||||
ZEND_API void zend_llist_destroy(zend_llist *l);
|
||||
ZEND_API void zend_llist_clean(zend_llist *l);
|
||||
ZEND_API void zend_llist_remove_tail(zend_llist *l);
|
||||
ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src);
|
||||
ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC);
|
||||
ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data));
|
||||
ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void *arg TSRMLS_DC);
|
||||
ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func TSRMLS_DC, int num_args, ...);
|
||||
ZEND_API int zend_llist_count(zend_llist *l);
|
||||
ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func);
|
||||
|
||||
/* traversal */
|
||||
ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos);
|
||||
ZEND_API void *zend_llist_get_last_ex(zend_llist *l, zend_llist_position *pos);
|
||||
ZEND_API void *zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos);
|
||||
ZEND_API void *zend_llist_get_prev_ex(zend_llist *l, zend_llist_position *pos);
|
||||
|
||||
#define zend_llist_get_first(l) zend_llist_get_first_ex(l, NULL)
|
||||
#define zend_llist_get_last(l) zend_llist_get_last_ex(l, NULL)
|
||||
#define zend_llist_get_next(l) zend_llist_get_next_ex(l, NULL)
|
||||
#define zend_llist_get_prev(l) zend_llist_get_prev_ex(l, NULL)
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
#endif /* ZEND_LLIST_H */
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MODULES_H
|
||||
#define MODULES_H
|
||||
|
||||
#include "zend.h"
|
||||
|
||||
#define INIT_FUNC_ARGS int type, int module_number TSRMLS_DC
|
||||
#define INIT_FUNC_ARGS_PASSTHRU type, module_number TSRMLS_CC
|
||||
#define SHUTDOWN_FUNC_ARGS int type, int module_number TSRMLS_DC
|
||||
#define SHUTDOWN_FUNC_ARGS_PASSTHRU type, module_number TSRMLS_CC
|
||||
#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module TSRMLS_DC
|
||||
#define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module TSRMLS_CC
|
||||
#define GINIT_FUNC_ARGS void
|
||||
#define GINIT_FUNC_ARGS_PASSTHRU
|
||||
|
||||
ZEND_API extern unsigned char first_arg_force_ref[];
|
||||
ZEND_API extern unsigned char second_arg_force_ref[];
|
||||
ZEND_API extern unsigned char third_arg_force_ref[];
|
||||
|
||||
#define ZEND_MODULE_API_NO 20001222
|
||||
#ifdef ZTS
|
||||
#define USING_ZTS 1
|
||||
#else
|
||||
#define USING_ZTS 0
|
||||
#endif
|
||||
|
||||
#define STANDARD_MODULE_PROPERTIES_EX 0, 0, 0, NULL, 0, ZEND_DEBUG, USING_ZTS, ZEND_MODULE_API_NO
|
||||
|
||||
#define STANDARD_MODULE_PROPERTIES \
|
||||
NULL, NULL, STANDARD_MODULE_PROPERTIES_EX
|
||||
|
||||
#define MODULE_PERSISTENT 1
|
||||
#define MODULE_TEMPORARY 2
|
||||
|
||||
typedef struct _zend_module_entry zend_module_entry;
|
||||
|
||||
struct _zend_module_entry {
|
||||
char *name;
|
||||
zend_function_entry *functions;
|
||||
int (*module_startup_func)(INIT_FUNC_ARGS);
|
||||
int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS);
|
||||
int (*request_startup_func)(INIT_FUNC_ARGS);
|
||||
int (*request_shutdown_func)(SHUTDOWN_FUNC_ARGS);
|
||||
void (*info_func)(ZEND_MODULE_INFO_FUNC_ARGS);
|
||||
int (*global_startup_func)(void);
|
||||
int (*global_shutdown_func)(void);
|
||||
int globals_id;
|
||||
int module_started;
|
||||
unsigned char type;
|
||||
void *handle;
|
||||
int module_number;
|
||||
unsigned char zend_debug;
|
||||
unsigned char zts;
|
||||
unsigned int zend_api;
|
||||
};
|
||||
|
||||
|
||||
extern ZEND_API HashTable module_registry;
|
||||
|
||||
void module_destructor(zend_module_entry *module);
|
||||
int module_registry_cleanup(zend_module_entry *module TSRMLS_DC);
|
||||
int module_registry_request_startup(zend_module_entry *module TSRMLS_DC);
|
||||
|
||||
#define ZEND_MODULE_DTOR (void (*)(void *)) module_destructor
|
||||
#endif
|
||||
@@ -0,0 +1,395 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_alloc.h"
|
||||
#include "zend_compile.h"
|
||||
#include "zend_extensions.h"
|
||||
#include "zend_API.h"
|
||||
|
||||
|
||||
static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC)
|
||||
{
|
||||
if (extension->op_array_ctor) {
|
||||
extension->op_array_ctor(op_array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC)
|
||||
{
|
||||
if (extension->op_array_dtor) {
|
||||
extension->op_array_dtor(op_array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void op_array_alloc_ops(zend_op_array *op_array)
|
||||
{
|
||||
op_array->opcodes = erealloc(op_array->opcodes, (op_array->size)*sizeof(zend_op));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void init_op_array(zend_op_array *op_array, int type, int initial_ops_size TSRMLS_DC)
|
||||
{
|
||||
op_array->type = type;
|
||||
|
||||
op_array->backpatch_count = 0;
|
||||
if (CG(interactive)) {
|
||||
/* We must avoid a realloc() on the op_array in interactive mode, since pointers to constants
|
||||
* will become invalid
|
||||
*/
|
||||
initial_ops_size = 8192;
|
||||
}
|
||||
|
||||
op_array->refcount = (zend_uint *) emalloc(sizeof(zend_uint));
|
||||
*op_array->refcount = 1;
|
||||
op_array->size = initial_ops_size;
|
||||
op_array->last = 0;
|
||||
op_array->opcodes = NULL;
|
||||
op_array_alloc_ops(op_array);
|
||||
|
||||
op_array->T = 0;
|
||||
|
||||
op_array->function_name = NULL;
|
||||
op_array->filename = zend_get_compiled_filename(TSRMLS_C);
|
||||
|
||||
op_array->arg_types = NULL;
|
||||
|
||||
op_array->brk_cont_array = NULL;
|
||||
op_array->last_brk_cont = 0;
|
||||
op_array->current_brk_cont = -1;
|
||||
|
||||
op_array->static_variables = NULL;
|
||||
|
||||
op_array->uses_globals = 0;
|
||||
|
||||
op_array->return_reference = 0;
|
||||
op_array->done_pass_two = 0;
|
||||
|
||||
op_array->start_op = NULL;
|
||||
|
||||
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_ctor_handler, op_array TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void destroy_zend_function(zend_function *function)
|
||||
{
|
||||
switch (function->type) {
|
||||
case ZEND_USER_FUNCTION:
|
||||
destroy_op_array((zend_op_array *) function);
|
||||
break;
|
||||
case ZEND_INTERNAL_FUNCTION:
|
||||
/* do nothing */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void destroy_zend_class(zend_class_entry *ce)
|
||||
{
|
||||
if (--(*ce->refcount)>0) {
|
||||
return;
|
||||
}
|
||||
switch (ce->type) {
|
||||
case ZEND_USER_CLASS:
|
||||
efree(ce->name);
|
||||
efree(ce->refcount);
|
||||
zend_hash_destroy(&ce->function_table);
|
||||
zend_hash_destroy(&ce->default_properties);
|
||||
break;
|
||||
case ZEND_INTERNAL_CLASS:
|
||||
free(ce->name);
|
||||
free(ce->refcount);
|
||||
zend_hash_destroy(&ce->function_table);
|
||||
zend_hash_destroy(&ce->default_properties);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void zend_class_add_ref(zend_class_entry *ce)
|
||||
{
|
||||
(*ce->refcount)++;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void destroy_op_array(zend_op_array *op_array)
|
||||
{
|
||||
zend_op *opline = op_array->opcodes;
|
||||
zend_op *end = op_array->opcodes+op_array->last;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (op_array->static_variables) {
|
||||
zend_hash_destroy(op_array->static_variables);
|
||||
FREE_HASHTABLE(op_array->static_variables);
|
||||
}
|
||||
|
||||
if (--(*op_array->refcount)>0) {
|
||||
return;
|
||||
}
|
||||
|
||||
efree(op_array->refcount);
|
||||
|
||||
while (opline<end) {
|
||||
if (opline->op1.op_type==IS_CONST) {
|
||||
#if DEBUG_ZEND>2
|
||||
printf("Reducing refcount for %x 1=>0 (destroying)\n", &opline->op1.u.constant);
|
||||
#endif
|
||||
zval_dtor(&opline->op1.u.constant);
|
||||
}
|
||||
if (opline->op2.op_type==IS_CONST) {
|
||||
#if DEBUG_ZEND>2
|
||||
printf("Reducing refcount for %x 1=>0 (destroying)\n", &opline->op2.u.constant);
|
||||
#endif
|
||||
zval_dtor(&opline->op2.u.constant);
|
||||
}
|
||||
opline++;
|
||||
}
|
||||
efree(op_array->opcodes);
|
||||
if (op_array->function_name) {
|
||||
efree(op_array->function_name);
|
||||
}
|
||||
if (op_array->arg_types) {
|
||||
efree(op_array->arg_types);
|
||||
}
|
||||
if (op_array->brk_cont_array) {
|
||||
efree(op_array->brk_cont_array);
|
||||
}
|
||||
if (op_array->done_pass_two) {
|
||||
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_dtor_handler, op_array TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void init_op(zend_op *op TSRMLS_DC)
|
||||
{
|
||||
memset(&op->result, 0, sizeof(znode));
|
||||
op->lineno = CG(zend_lineno);
|
||||
SET_UNUSED(op->result);
|
||||
op->extended_value = 0;
|
||||
memset(&op->op1, 0, sizeof(znode));
|
||||
memset(&op->op2, 0, sizeof(znode));
|
||||
}
|
||||
|
||||
zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC)
|
||||
{
|
||||
zend_uint next_op_num = op_array->last++;
|
||||
zend_op *next_op;
|
||||
|
||||
if (next_op_num >= op_array->size) {
|
||||
if (CG(interactive)) {
|
||||
/* we messed up */
|
||||
zend_printf("Ran out of opcode space!\n"
|
||||
"You should probably consider writing this huge script into a file!\n");
|
||||
zend_bailout();
|
||||
}
|
||||
op_array->size *= 4;
|
||||
op_array_alloc_ops(op_array);
|
||||
}
|
||||
|
||||
next_op = &(op_array->opcodes[next_op_num]);
|
||||
|
||||
init_op(next_op TSRMLS_CC);
|
||||
|
||||
return next_op;
|
||||
}
|
||||
|
||||
|
||||
int get_next_op_number(zend_op_array *op_array)
|
||||
{
|
||||
return op_array->last;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
zend_brk_cont_element *get_next_brk_cont_element(zend_op_array *op_array)
|
||||
{
|
||||
op_array->last_brk_cont++;
|
||||
op_array->brk_cont_array = erealloc(op_array->brk_cont_array, sizeof(zend_brk_cont_element)*op_array->last_brk_cont);
|
||||
return &op_array->brk_cont_array[op_array->last_brk_cont-1];
|
||||
}
|
||||
|
||||
|
||||
static void zend_update_extended_info(zend_op_array *op_array TSRMLS_DC)
|
||||
{
|
||||
zend_op *opline = op_array->opcodes, *end=opline+op_array->last;
|
||||
|
||||
while (opline<end) {
|
||||
if (opline->opcode == ZEND_EXT_STMT) {
|
||||
if (opline+1<end) {
|
||||
if ((opline+1)->opcode == ZEND_EXT_STMT) {
|
||||
opline->opcode = ZEND_NOP;
|
||||
opline++;
|
||||
continue;
|
||||
}
|
||||
if (opline+1<end) {
|
||||
opline->lineno = (opline+1)->lineno;
|
||||
}
|
||||
} else {
|
||||
opline->opcode = ZEND_NOP;
|
||||
}
|
||||
}
|
||||
opline++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void zend_extension_op_array_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC)
|
||||
{
|
||||
if (extension->op_array_handler) {
|
||||
extension->op_array_handler(op_array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int pass_two(zend_op_array *op_array TSRMLS_DC)
|
||||
{
|
||||
zend_op *opline, *end;
|
||||
|
||||
if (op_array->type!=ZEND_USER_FUNCTION && op_array->type!=ZEND_EVAL_CODE) {
|
||||
return 0;
|
||||
}
|
||||
if (CG(extended_info)) {
|
||||
zend_update_extended_info(op_array TSRMLS_CC);
|
||||
}
|
||||
if (CG(handle_op_arrays)) {
|
||||
zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array TSRMLS_CC);
|
||||
}
|
||||
|
||||
opline = op_array->opcodes;
|
||||
end = opline + op_array->last;
|
||||
while (opline < end) {
|
||||
if (opline->op1.op_type == IS_CONST) {
|
||||
opline->op1.u.constant.is_ref = 1;
|
||||
opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */
|
||||
}
|
||||
if (opline->op2.op_type == IS_CONST) {
|
||||
opline->op2.u.constant.is_ref = 1;
|
||||
opline->op2.u.constant.refcount = 2;
|
||||
}
|
||||
opline++;
|
||||
}
|
||||
op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
|
||||
op_array->size = op_array->last;
|
||||
op_array->done_pass_two = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int print_class(zend_class_entry *class_entry TSRMLS_DC)
|
||||
{
|
||||
printf("Class %s:\n", class_entry->name);
|
||||
zend_hash_apply(&class_entry->function_table, (apply_func_t) pass_two TSRMLS_CC);
|
||||
printf("End of class %s.\n\n", class_entry->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZEND_API unary_op_type get_unary_op(int opcode)
|
||||
{
|
||||
switch(opcode) {
|
||||
case ZEND_BW_NOT:
|
||||
return (unary_op_type) bitwise_not_function;
|
||||
break;
|
||||
case ZEND_BOOL_NOT:
|
||||
return (unary_op_type) boolean_not_function;
|
||||
break;
|
||||
default:
|
||||
return (unary_op_type) NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void *get_binary_op(int opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case ZEND_ADD:
|
||||
case ZEND_ASSIGN_ADD:
|
||||
return (void *) add_function;
|
||||
break;
|
||||
case ZEND_SUB:
|
||||
case ZEND_ASSIGN_SUB:
|
||||
return (void *) sub_function;
|
||||
break;
|
||||
case ZEND_MUL:
|
||||
case ZEND_ASSIGN_MUL:
|
||||
return (void *) mul_function;
|
||||
break;
|
||||
case ZEND_DIV:
|
||||
case ZEND_ASSIGN_DIV:
|
||||
return (void *) div_function;
|
||||
break;
|
||||
case ZEND_MOD:
|
||||
case ZEND_ASSIGN_MOD:
|
||||
return (void *) mod_function;
|
||||
break;
|
||||
case ZEND_SL:
|
||||
case ZEND_ASSIGN_SL:
|
||||
return (void *) shift_left_function;
|
||||
break;
|
||||
case ZEND_SR:
|
||||
case ZEND_ASSIGN_SR:
|
||||
return (void *) shift_right_function;
|
||||
break;
|
||||
case ZEND_CONCAT:
|
||||
case ZEND_ASSIGN_CONCAT:
|
||||
return (void *) concat_function;
|
||||
break;
|
||||
case ZEND_IS_IDENTICAL:
|
||||
return (void *) is_identical_function;
|
||||
break;
|
||||
case ZEND_IS_NOT_IDENTICAL:
|
||||
return (void *) is_not_identical_function;
|
||||
break;
|
||||
case ZEND_IS_EQUAL:
|
||||
return (void *) is_equal_function;
|
||||
break;
|
||||
case ZEND_IS_NOT_EQUAL:
|
||||
return (void *) is_not_equal_function;
|
||||
break;
|
||||
case ZEND_IS_SMALLER:
|
||||
return (void *) is_smaller_function;
|
||||
break;
|
||||
case ZEND_IS_SMALLER_OR_EQUAL:
|
||||
return (void *) is_smaller_or_equal_function;
|
||||
break;
|
||||
case ZEND_BW_OR:
|
||||
case ZEND_ASSIGN_BW_OR:
|
||||
return (void *) bitwise_or_function;
|
||||
break;
|
||||
case ZEND_BW_AND:
|
||||
case ZEND_ASSIGN_BW_AND:
|
||||
return (void *) bitwise_and_function;
|
||||
break;
|
||||
case ZEND_BW_XOR:
|
||||
case ZEND_ASSIGN_BW_XOR:
|
||||
return (void *) bitwise_xor_function;
|
||||
break;
|
||||
default:
|
||||
return (void *) NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_OPERATORS_H
|
||||
#define ZEND_OPERATORS_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if 0&&WITH_BCMATH
|
||||
#include "ext/bcmath/libbcmath/src/bcmath.h"
|
||||
#endif
|
||||
|
||||
#define MAX_LENGTH_OF_LONG 18
|
||||
#define MAX_LENGTH_OF_DOUBLE 32
|
||||
|
||||
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC);
|
||||
ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC);
|
||||
ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
|
||||
ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
|
||||
static inline int is_numeric_string(char *str, int length, long *lval, double *dval)
|
||||
{
|
||||
long local_lval;
|
||||
double local_dval;
|
||||
char *end_ptr;
|
||||
int conv_base=10;
|
||||
|
||||
if (!length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* handle hex numbers */
|
||||
if (length>=2 && str[0]=='0' && (str[1]=='x' || str[1]=='X')) {
|
||||
conv_base=16;
|
||||
}
|
||||
errno=0;
|
||||
local_lval = strtol(str, &end_ptr, conv_base);
|
||||
if (errno!=ERANGE && end_ptr == str+length) { /* integer string */
|
||||
if (lval) {
|
||||
*lval = local_lval;
|
||||
}
|
||||
return IS_LONG;
|
||||
}
|
||||
|
||||
if (conv_base==16) { /* hex string, under UNIX strtod() messes it up */
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno=0;
|
||||
local_dval = strtod(str, &end_ptr);
|
||||
if (errno!=ERANGE && end_ptr == str+length) { /* floating point string */
|
||||
if (! zend_finite(local_dval)) {
|
||||
/* "inf","nan" and maybe other weird ones */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dval) {
|
||||
*dval = local_dval;
|
||||
}
|
||||
#if 0&&WITH_BCMATH
|
||||
if (length>16) {
|
||||
register char *ptr=str, *end=str+length;
|
||||
|
||||
while (ptr<end) {
|
||||
switch(*ptr++) {
|
||||
case 'e':
|
||||
case 'E':
|
||||
/* scientific notation, not handled by the BC library */
|
||||
return IS_DOUBLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FLAG_IS_BC;
|
||||
} else {
|
||||
return IS_DOUBLE;
|
||||
}
|
||||
#else
|
||||
return IS_DOUBLE;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZEND_API int increment_function(zval *op1);
|
||||
ZEND_API int decrement_function(zval *op2);
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC);
|
||||
ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC);
|
||||
ZEND_API void convert_to_long(zval *op);
|
||||
ZEND_API void convert_to_double(zval *op);
|
||||
ZEND_API void convert_to_long_base(zval *op, int base);
|
||||
ZEND_API void convert_to_null(zval *op);
|
||||
ZEND_API void convert_to_boolean(zval *op);
|
||||
ZEND_API void convert_to_array(zval *op);
|
||||
ZEND_API void convert_to_object(zval *op);
|
||||
ZEND_API void multi_convert_to_long_ex(int argc, ...);
|
||||
ZEND_API void multi_convert_to_double_ex(int argc, ...);
|
||||
ZEND_API void multi_convert_to_string_ex(int argc, ...);
|
||||
ZEND_API int add_char_to_string(zval *result, zval *op1, zval *op2);
|
||||
ZEND_API int add_string_to_string(zval *result, zval *op1, zval *op2);
|
||||
#define convert_to_string(op) _convert_to_string((op) ZEND_FILE_LINE_CC)
|
||||
|
||||
ZEND_API double zend_string_to_double(const char *number, zend_uint length);
|
||||
END_EXTERN_C()
|
||||
|
||||
ZEND_API int zval_is_true(zval *op);
|
||||
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
|
||||
|
||||
ZEND_API void zend_str_tolower(char *str, unsigned int length);
|
||||
ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2);
|
||||
ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3);
|
||||
ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2);
|
||||
ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3);
|
||||
ZEND_API int zend_binary_strcmp(char *s1, uint len1, char *s2, uint len2);
|
||||
ZEND_API int zend_binary_strncmp(char *s1, uint len1, char *s2, uint len2, uint length);
|
||||
ZEND_API int zend_binary_strcasecmp(char *s1, uint len1, char *s2, uint len2);
|
||||
ZEND_API int zend_binary_strncasecmp(char *s1, uint len1, char *s2, uint len2, uint length);
|
||||
|
||||
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
|
||||
ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC);
|
||||
ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC);
|
||||
ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC);
|
||||
|
||||
ZEND_API int zend_atoi(const char *str, int str_len);
|
||||
|
||||
#define convert_to_ex_master(ppzv, lower_type, upper_type) \
|
||||
if ((*ppzv)->type!=IS_##upper_type) { \
|
||||
if (!(*ppzv)->is_ref) { \
|
||||
SEPARATE_ZVAL(ppzv); \
|
||||
} \
|
||||
convert_to_##lower_type(*ppzv); \
|
||||
}
|
||||
|
||||
#define convert_to_writable_ex_master(ppzv, lower_type, upper_type) \
|
||||
if ((*ppzv)->type!=IS_##upper_type) { \
|
||||
SEPARATE_ZVAL(ppzv); \
|
||||
convert_to_##lower_type(*ppzv); \
|
||||
}
|
||||
|
||||
|
||||
#define convert_to_boolean_ex(ppzv) convert_to_ex_master(ppzv, boolean, BOOL)
|
||||
#define convert_to_long_ex(ppzv) convert_to_ex_master(ppzv, long, LONG)
|
||||
#define convert_to_double_ex(ppzv) convert_to_ex_master(ppzv, double, DOUBLE)
|
||||
#define convert_to_string_ex(ppzv) convert_to_ex_master(ppzv, string, STRING)
|
||||
#define convert_to_array_ex(ppzv) convert_to_ex_master(ppzv, array, ARRAY)
|
||||
#define convert_to_object_ex(ppzv) convert_to_ex_master(ppzv, object, OBJECT)
|
||||
#define convert_to_null_ex(ppzv) convert_to_ex_master(ppzv, null, NULL)
|
||||
|
||||
#define convert_to_writable_boolean_ex(ppzv) convert_to_writable_ex_master(ppzv, boolean, BOOL)
|
||||
#define convert_to_writable_long_ex(ppzv) convert_to_writable_ex_master(ppzv, long, LONG)
|
||||
#define convert_to_writable_double_ex(ppzv) convert_to_writable_ex_master(ppzv, double, DOUBLE)
|
||||
#define convert_to_writable_string_ex(ppzv) convert_to_writable_ex_master(ppzv, string, STRING)
|
||||
#define convert_to_writable_array_ex(ppzv) convert_to_writable_ex_master(ppzv, array, ARRAY)
|
||||
#define convert_to_writable_object_ex(ppzv) convert_to_writable_ex_master(ppzv, object, OBJECT)
|
||||
#define convert_to_writable_null_ex(ppzv) convert_to_writable_ex_master(ppzv, null, NULL)
|
||||
|
||||
|
||||
#define convert_scalar_to_number_ex(ppzv) \
|
||||
if ((*ppzv)->type!=IS_LONG && (*ppzv)->type!=IS_DOUBLE) { \
|
||||
if (!(*ppzv)->is_ref) { \
|
||||
SEPARATE_ZVAL(ppzv); \
|
||||
} \
|
||||
convert_scalar_to_number(*ppzv TSRMLS_CC); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define Z_LVAL(zval) (zval).value.lval
|
||||
#define Z_BVAL(zval) ((zend_bool)(zval).value.lval)
|
||||
#define Z_DVAL(zval) (zval).value.dval
|
||||
#define Z_STRVAL(zval) (zval).value.str.val
|
||||
#define Z_STRLEN(zval) (zval).value.str.len
|
||||
#define Z_ARRVAL(zval) (zval).value.ht
|
||||
#define Z_OBJ(zval) &(zval).value.obj
|
||||
#define Z_OBJPROP(zval) (zval).value.obj.properties
|
||||
#define Z_OBJCE(zval) (zval).value.obj.ce
|
||||
#define Z_RESVAL(zval) (zval).value.lval
|
||||
|
||||
#define Z_LVAL_P(zval_p) Z_LVAL(*zval_p)
|
||||
#define Z_BVAL_P(zval_p) Z_BVAL(*zval_p)
|
||||
#define Z_DVAL_P(zval_p) Z_DVAL(*zval_p)
|
||||
#define Z_STRVAL_P(zval_p) Z_STRVAL(*zval_p)
|
||||
#define Z_STRLEN_P(zval_p) Z_STRLEN(*zval_p)
|
||||
#define Z_ARRVAL_P(zval_p) Z_ARRVAL(*zval_p)
|
||||
#define Z_OBJ_P(zval_p) Z_OBJ(*zval_p)
|
||||
#define Z_OBJPROP_P(zval_p) Z_OBJPROP(*zval_p)
|
||||
#define Z_OBJCE_P(zval_p) Z_OBJCE(*zval_p)
|
||||
#define Z_RESVAL_P(zval_p) Z_RESVAL(*zval_p)
|
||||
|
||||
#define Z_LVAL_PP(zval_pp) Z_LVAL(**zval_pp)
|
||||
#define Z_BVAL_PP(zval_pp) Z_BVAL(**zval_pp)
|
||||
#define Z_DVAL_PP(zval_pp) Z_DVAL(**zval_pp)
|
||||
#define Z_STRVAL_PP(zval_pp) Z_STRVAL(**zval_pp)
|
||||
#define Z_STRLEN_PP(zval_pp) Z_STRLEN(**zval_pp)
|
||||
#define Z_ARRVAL_PP(zval_pp) Z_ARRVAL(**zval_pp)
|
||||
#define Z_OBJ_PP(zval_pp) Z_OBJ(**zval_pp)
|
||||
#define Z_OBJPROP_PP(zval_pp) Z_OBJPROP(**zval_pp)
|
||||
#define Z_OBJCE_PP(zval_pp) Z_OBJCE(**zval_pp)
|
||||
#define Z_RESVAL_PP(zval_pp) Z_RESVAL(**zval_pp)
|
||||
|
||||
#define Z_TYPE(zval) (zval).type
|
||||
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
|
||||
#define Z_TYPE_PP(zval_pp) Z_TYPE(**zval_pp)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_ptr_stack.h"
|
||||
#ifdef HAVE_STDARG_H
|
||||
# include <stdarg.h>
|
||||
#endif
|
||||
|
||||
ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack)
|
||||
{
|
||||
stack->top_element = stack->elements = (void **) emalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE);
|
||||
stack->max = PTR_STACK_BLOCK_SIZE;
|
||||
stack->top = 0;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...)
|
||||
{
|
||||
va_list ptr;
|
||||
void *elem;
|
||||
|
||||
if (stack->top+count > stack->max) { /* we need to allocate more memory */
|
||||
stack->max *= 2;
|
||||
stack->max += count;
|
||||
stack->elements = (void **) erealloc(stack->elements, (sizeof(void *) * (stack->max)));
|
||||
stack->top_element = stack->elements+stack->top;
|
||||
}
|
||||
va_start(ptr, count);
|
||||
while (count>0) {
|
||||
elem = va_arg(ptr, void *);
|
||||
stack->top++;
|
||||
*(stack->top_element++) = elem;
|
||||
count--;
|
||||
}
|
||||
va_end(ptr);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...)
|
||||
{
|
||||
va_list ptr;
|
||||
void **elem;
|
||||
|
||||
va_start(ptr, count);
|
||||
while (count>0) {
|
||||
elem = va_arg(ptr, void **);
|
||||
*elem = *(--stack->top_element);
|
||||
stack->top--;
|
||||
count--;
|
||||
}
|
||||
va_end(ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack)
|
||||
{
|
||||
if (stack->elements) {
|
||||
efree(stack->elements);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *))
|
||||
{
|
||||
int i = stack->top;
|
||||
|
||||
while (--i >= 0) {
|
||||
func(stack->elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements)
|
||||
{
|
||||
zend_ptr_stack_apply(stack, func);
|
||||
if (free_elements) {
|
||||
int i = stack->top;
|
||||
|
||||
while (--i >= 0) {
|
||||
efree(stack->elements[i]);
|
||||
}
|
||||
}
|
||||
stack->top = 0;
|
||||
stack->top_element = stack->elements;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack)
|
||||
{
|
||||
return stack->top;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_PTR_STACK_H
|
||||
#define ZEND_PTR_STACK_H
|
||||
|
||||
typedef struct _zend_ptr_stack {
|
||||
int top, max;
|
||||
void **elements;
|
||||
void **top_element;
|
||||
} zend_ptr_stack;
|
||||
|
||||
|
||||
#define PTR_STACK_BLOCK_SIZE 64
|
||||
|
||||
ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack);
|
||||
ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...);
|
||||
ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...);
|
||||
ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack);
|
||||
ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *));
|
||||
ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements);
|
||||
ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack);
|
||||
|
||||
static inline void zend_ptr_stack_push(zend_ptr_stack *stack, void *ptr)
|
||||
{
|
||||
if (stack->top >= stack->max) { /* we need to allocate more memory */
|
||||
stack->elements = (void **) erealloc(stack->elements, (sizeof(void *) * (stack->max *= 2 )));
|
||||
stack->top_element = stack->elements+stack->top;
|
||||
}
|
||||
stack->top++;
|
||||
*(stack->top_element++) = ptr;
|
||||
}
|
||||
|
||||
static inline void *zend_ptr_stack_pop(zend_ptr_stack *stack)
|
||||
{
|
||||
stack->top--;
|
||||
return *(--stack->top_element);
|
||||
}
|
||||
|
||||
|
||||
#endif /* ZEND_PTR_STACK_H */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "zend.h"
|
||||
|
||||
#ifdef HAVE_STDARG_H
|
||||
# include <stdarg.h>
|
||||
#endif
|
||||
|
||||
#if ZEND_BROKEN_SPRINTF
|
||||
int zend_sprintf(char *buffer, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsprintf(buffer, format, args);
|
||||
va_end(args);
|
||||
|
||||
return strlen(buffer);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include "zend.h"
|
||||
#include "zend_stack.h"
|
||||
|
||||
ZEND_API int zend_stack_init(zend_stack *stack)
|
||||
{
|
||||
stack->top = 0;
|
||||
stack->elements = (void **) emalloc(sizeof(void **) * STACK_BLOCK_SIZE);
|
||||
if (!stack->elements) {
|
||||
return FAILURE;
|
||||
} else {
|
||||
stack->max = STACK_BLOCK_SIZE;
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API int zend_stack_push(zend_stack *stack, void *element, int size)
|
||||
{
|
||||
if (stack->top >= stack->max) { /* we need to allocate more memory */
|
||||
stack->elements = (void **) erealloc(stack->elements,
|
||||
(sizeof(void **) * (stack->max += STACK_BLOCK_SIZE)));
|
||||
if (!stack->elements) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
stack->elements[stack->top] = (void *) emalloc(size);
|
||||
memcpy(stack->elements[stack->top], element, size);
|
||||
return stack->top++;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_stack_top(zend_stack *stack, void **element)
|
||||
{
|
||||
if (stack->top > 0) {
|
||||
*element = stack->elements[stack->top - 1];
|
||||
return SUCCESS;
|
||||
} else {
|
||||
*element = NULL;
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_stack_del_top(zend_stack *stack)
|
||||
{
|
||||
if (stack->top > 0) {
|
||||
efree(stack->elements[--stack->top]);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_stack_int_top(zend_stack *stack)
|
||||
{
|
||||
int *e;
|
||||
|
||||
if (zend_stack_top(stack, (void **) &e) == FAILURE) {
|
||||
return FAILURE; /* this must be a negative number, since negative numbers can't be address numbers */
|
||||
} else {
|
||||
return *e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_stack_is_empty(zend_stack *stack)
|
||||
{
|
||||
if (stack->top == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_stack_destroy(zend_stack *stack)
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < stack->top; i++) {
|
||||
efree(stack->elements[i]);
|
||||
}
|
||||
|
||||
if (stack->elements) {
|
||||
efree(stack->elements);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void **zend_stack_base(zend_stack *stack)
|
||||
{
|
||||
return stack->elements;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_stack_count(zend_stack *stack)
|
||||
{
|
||||
return stack->top;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element))
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (type) {
|
||||
case ZEND_STACK_APPLY_TOPDOWN:
|
||||
for (i=stack->top-1; i>=0; i--) {
|
||||
if (apply_function(stack->elements[i])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ZEND_STACK_APPLY_BOTTOMUP:
|
||||
for (i=0; i<stack->top; i++) {
|
||||
if (apply_function(stack->elements[i])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (type) {
|
||||
case ZEND_STACK_APPLY_TOPDOWN:
|
||||
for (i=stack->top-1; i>=0; i--) {
|
||||
if (apply_function(stack->elements[i], arg)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ZEND_STACK_APPLY_BOTTOMUP:
|
||||
for (i=0; i<stack->top; i++) {
|
||||
if (apply_function(stack->elements[i], arg)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_STACK_H
|
||||
#define ZEND_STACK_H
|
||||
|
||||
typedef struct _zend_stack {
|
||||
int top, max;
|
||||
void **elements;
|
||||
} zend_stack;
|
||||
|
||||
|
||||
#define STACK_BLOCK_SIZE 64
|
||||
|
||||
ZEND_API int zend_stack_init(zend_stack *stack);
|
||||
ZEND_API int zend_stack_push(zend_stack *stack, void *element, int size);
|
||||
ZEND_API int zend_stack_top(zend_stack *stack, void **element);
|
||||
ZEND_API int zend_stack_del_top(zend_stack *stack);
|
||||
ZEND_API int zend_stack_int_top(zend_stack *stack);
|
||||
ZEND_API int zend_stack_is_empty(zend_stack *stack);
|
||||
ZEND_API int zend_stack_destroy(zend_stack *stack);
|
||||
ZEND_API void **zend_stack_base(zend_stack *stack);
|
||||
ZEND_API int zend_stack_count(zend_stack *stack);
|
||||
ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element));
|
||||
ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg);
|
||||
|
||||
#define ZEND_STACK_APPLY_TOPDOWN 1
|
||||
#define ZEND_STACK_APPLY_BOTTOMUP 2
|
||||
|
||||
#endif /* ZEND_STACK_H */
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "zend_static_allocator.h"
|
||||
|
||||
/* Not checking emalloc() and erealloc() return values as they are supposed to bailout */
|
||||
|
||||
inline static void block_init(Block *block, zend_uint block_size)
|
||||
{
|
||||
block->pos = block->bp = (char *) emalloc(block_size);
|
||||
block->end = block->bp + block_size;
|
||||
}
|
||||
|
||||
inline static char *block_allocate(Block *block, zend_uint size)
|
||||
{
|
||||
char *retval = block->pos;
|
||||
if ((block->pos += size) >= block->end) {
|
||||
return (char *)NULL;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
inline static void block_destroy(Block *block)
|
||||
{
|
||||
efree(block->bp);
|
||||
}
|
||||
|
||||
void static_allocator_init(StaticAllocator *sa)
|
||||
{
|
||||
sa->Blocks = (Block *) emalloc(sizeof(Block));
|
||||
block_init(sa->Blocks, ALLOCATOR_BLOCK_SIZE);
|
||||
sa->num_blocks = 1;
|
||||
sa->current_block = 0;
|
||||
}
|
||||
|
||||
char *static_allocator_allocate(StaticAllocator *sa, zend_uint size)
|
||||
{
|
||||
char *retval;
|
||||
|
||||
retval = block_allocate(&sa->Blocks[sa->current_block], size);
|
||||
if (retval) {
|
||||
return retval;
|
||||
}
|
||||
sa->Blocks = (Block *) erealloc(sa->Blocks, ++sa->num_blocks);
|
||||
sa->current_block++;
|
||||
block_init(&sa->Blocks[sa->current_block], (size > ALLOCATOR_BLOCK_SIZE) ? size : ALLOCATOR_BLOCK_SIZE);
|
||||
retval = block_allocate(&sa->Blocks[sa->current_block], size);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void static_allocator_destroy(StaticAllocator *sa)
|
||||
{
|
||||
zend_uint i;
|
||||
|
||||
for (i=0; i<sa->num_blocks; i++) {
|
||||
block_free(&sa->Blocks[i]);
|
||||
}
|
||||
efree(sa->Blocks);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef ZEND_STATIC_ALLOCATOR_H
|
||||
#define ZEND_STATIC_ALLOCATOR_H
|
||||
|
||||
#define ALLOCATOR_BLOCK_SIZE 400000
|
||||
|
||||
/* Temporary */
|
||||
typedef unsigned int zend_uint;
|
||||
#define emalloc(s) malloc(s)
|
||||
#define efree(p) free(p)
|
||||
|
||||
typedef struct _Block {
|
||||
char *bp;
|
||||
char *pos;
|
||||
char *end;
|
||||
} Block;
|
||||
|
||||
typedef struct _StaticAllocator {
|
||||
Block *Blocks;
|
||||
zend_uint num_blocks;
|
||||
zend_uint current_block;
|
||||
} StaticAllocator;
|
||||
|
||||
void static_allocator_init(StaticAllocator *sa);
|
||||
char *static_allocator_allocate(StaticAllocator *sa, zend_uint size);
|
||||
void static_allocator_destroy(StaticAllocator *sa);
|
||||
|
||||
#endif /* ZEND_STATIC_ALLOCATOR_H */
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "zend.h"
|
||||
#include "zend_API.h"
|
||||
#include "zend_globals.h"
|
||||
#include "zend_constants.h"
|
||||
#include "zend_list.h"
|
||||
|
||||
ZEND_API char *empty_string = ""; /* in order to save emalloc() and efree() time for
|
||||
* empty strings (usually used to denote empty
|
||||
* return values in failed functions).
|
||||
* The macro STR_FREE() will not efree() it.
|
||||
*/
|
||||
|
||||
|
||||
ZEND_API void _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC)
|
||||
{
|
||||
if (zvalue->type==IS_LONG) {
|
||||
return;
|
||||
}
|
||||
switch(zvalue->type) {
|
||||
case IS_STRING:
|
||||
case IS_CONSTANT:
|
||||
CHECK_ZVAL_STRING_REL(zvalue);
|
||||
STR_FREE_REL(zvalue->value.str.val);
|
||||
break;
|
||||
case IS_ARRAY:
|
||||
case IS_CONSTANT_ARRAY: {
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
|
||||
zend_hash_destroy(zvalue->value.ht);
|
||||
FREE_HASHTABLE(zvalue->value.ht);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IS_OBJECT:
|
||||
zend_hash_destroy(zvalue->value.obj.properties);
|
||||
FREE_HASHTABLE(zvalue->value.obj.properties);
|
||||
break;
|
||||
case IS_RESOURCE: {
|
||||
TSRMLS_FETCH();
|
||||
|
||||
/* destroy resource */
|
||||
zend_list_delete(zvalue->value.lval);
|
||||
}
|
||||
break;
|
||||
case IS_LONG:
|
||||
case IS_DOUBLE:
|
||||
case IS_BOOL:
|
||||
case IS_NULL:
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void zval_add_ref(zval **p)
|
||||
{
|
||||
(*p)->refcount++;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
|
||||
{
|
||||
switch (zvalue->type) {
|
||||
case IS_RESOURCE: {
|
||||
TSRMLS_FETCH();
|
||||
|
||||
zend_list_addref(zvalue->value.lval);
|
||||
}
|
||||
break;
|
||||
case IS_BOOL:
|
||||
case IS_LONG:
|
||||
case IS_NULL:
|
||||
break;
|
||||
case IS_CONSTANT:
|
||||
case IS_STRING:
|
||||
if (zvalue->value.str.val) {
|
||||
if (zvalue->value.str.len==0) {
|
||||
zvalue->value.str.val = empty_string;
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
CHECK_ZVAL_STRING_REL(zvalue);
|
||||
zvalue->value.str.val = (char *) estrndup_rel(zvalue->value.str.val, zvalue->value.str.len);
|
||||
break;
|
||||
case IS_ARRAY:
|
||||
case IS_CONSTANT_ARRAY: {
|
||||
zval *tmp;
|
||||
HashTable *original_ht = zvalue->value.ht;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (zvalue->value.ht == &EG(symbol_table)) {
|
||||
return SUCCESS; /* do nothing */
|
||||
}
|
||||
ALLOC_HASHTABLE_REL(zvalue->value.ht);
|
||||
zend_hash_init(zvalue->value.ht, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_copy(zvalue->value.ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
}
|
||||
break;
|
||||
case IS_OBJECT: {
|
||||
zval *tmp;
|
||||
HashTable *original_ht = zvalue->value.obj.properties;
|
||||
|
||||
ALLOC_HASHTABLE_REL(zvalue->value.obj.properties);
|
||||
zend_hash_init(zvalue->value.obj.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_copy(zvalue->value.obj.properties, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int zend_print_variable(zval *var)
|
||||
{
|
||||
return zend_print_zval(var, 0);
|
||||
}
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue)
|
||||
{
|
||||
return zval_copy_ctor(zvalue);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API void _zval_dtor_wrapper(zval *zvalue)
|
||||
{
|
||||
zval_dtor(zvalue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr)
|
||||
{
|
||||
zval_ptr_dtor(zval_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Zend Engine |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1998-2001 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 0.92 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.zend.com/license/0_92.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@zend.com so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ZEND_VARIABLES_H
|
||||
#define ZEND_VARIABLES_H
|
||||
|
||||
|
||||
ZEND_API int zend_print_variable(zval *var);
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC);
|
||||
ZEND_API void _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC);
|
||||
ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
|
||||
#define zval_copy_ctor(zvalue) _zval_copy_ctor((zvalue) ZEND_FILE_LINE_CC)
|
||||
#define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC)
|
||||
#define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC)
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue);
|
||||
ZEND_API void _zval_dtor_wrapper(zval *zvalue);
|
||||
ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr);
|
||||
#define zval_copy_ctor_wrapper _zval_copy_ctor_wrapper
|
||||
#define zval_dtor_wrapper _zval_dtor_wrapper
|
||||
#define zval_ptr_dtor_wrapper _zval_ptr_dtor_wrapper
|
||||
#else
|
||||
#define zval_copy_ctor_wrapper _zval_copy_ctor
|
||||
#define zval_dtor_wrapper _zval_dtor
|
||||
#define zval_ptr_dtor_wrapper _zval_ptr_dtor
|
||||
#endif
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
|
||||
ZEND_API void zval_add_ref(zval **p);
|
||||
|
||||
#define ZVAL_DESTRUCTOR (void (*)(void *)) zval_dtor_wrapper
|
||||
#define ZVAL_PTR_DTOR (void (*)(void *)) zval_ptr_dtor_wrapper
|
||||
#define ZVAL_COPY_CTOR (void (*)(void *)) zval_copy_ctor_wrapper
|
||||
|
||||
#endif
|
||||
@@ -1,19 +0,0 @@
|
||||
Generic hashing framework for PHP
|
||||
|
||||
Simplest usages:
|
||||
|
||||
$digest = hash($algoname, $message);
|
||||
$digest = hash_file($algoname, $filename);
|
||||
|
||||
Examples:
|
||||
|
||||
$digest = hash('md5', 'The quick brown fox jumped over the lazy dog.');
|
||||
|
||||
Feeder usage:
|
||||
|
||||
$context = hash_init($algoname);
|
||||
hash_update($context, $message);
|
||||
$digest = hash_final($context);
|
||||
|
||||
hash(), hash_file(), and hash_final() each support an optional boolean parameter $raw_output which behaves in the same
|
||||
manner as sha1()'s optional parameter.
|
||||
@@ -1,26 +0,0 @@
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension hash
|
||||
|
||||
PHP_ARG_ENABLE(hash, whether to enable hash support,
|
||||
[ --enable-hash Enable hash support])
|
||||
|
||||
if test "$PHP_HASH" != "no"; then
|
||||
AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension])
|
||||
|
||||
AC_CHECK_SIZEOF(short, 2)
|
||||
AC_CHECK_SIZEOF(int, 4)
|
||||
AC_CHECK_SIZEOF(long, 4)
|
||||
AC_CHECK_SIZEOF(long long, 8)
|
||||
|
||||
EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \
|
||||
hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c \
|
||||
hash_crc32.c"
|
||||
EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
|
||||
php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
|
||||
php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h php_hash_types.h"
|
||||
|
||||
PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared)
|
||||
ifdef([PHP_INSTALL_HEADERS], [
|
||||
PHP_INSTALL_HEADERS(ext/hash, $EXT_HASH_HEADERS)
|
||||
])
|
||||
fi
|
||||
@@ -1,12 +0,0 @@
|
||||
// $Id$
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_ENABLE("hash", "enable hash support", "no");
|
||||
|
||||
if (PHP_HASH != "no") {
|
||||
AC_DEFINE('HAVE_HASH_EXT', 1);
|
||||
EXTENSION("hash", "hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c "
|
||||
+ "hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c "
|
||||
+ "hash_adler32.c hash_crc32.c");
|
||||
}
|
||||
|
||||
-660
@@ -1,660 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/file.h"
|
||||
|
||||
static int php_hash_le_hash;
|
||||
HashTable php_hash_hashtable;
|
||||
|
||||
#if (PHP_MAJOR_VERSION >= 5)
|
||||
# define DEFAULT_CONTEXT FG(default_context)
|
||||
#else
|
||||
# define DEFAULT_CONTEXT NULL
|
||||
#endif
|
||||
|
||||
/* Hash Registry Access */
|
||||
|
||||
PHP_HASH_API php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len)
|
||||
{
|
||||
php_hash_ops *ops;
|
||||
char *lower = estrndup(algo, algo_len);
|
||||
|
||||
zend_str_tolower(lower, algo_len);
|
||||
if (SUCCESS != zend_hash_find(&php_hash_hashtable, lower, algo_len + 1, (void**)&ops)) {
|
||||
ops = NULL;
|
||||
}
|
||||
efree(lower);
|
||||
|
||||
return ops;
|
||||
}
|
||||
|
||||
PHP_HASH_API void php_hash_register_algo(const char *algo, php_hash_ops *ops)
|
||||
{
|
||||
int algo_len = strlen(algo);
|
||||
char *lower = estrndup(algo, algo_len);
|
||||
|
||||
zend_str_tolower(lower, algo_len);
|
||||
zend_hash_add(&php_hash_hashtable, lower, algo_len + 1, ops, sizeof(php_hash_ops), NULL);
|
||||
efree(lower);
|
||||
}
|
||||
|
||||
/* Userspace */
|
||||
|
||||
static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename)
|
||||
{
|
||||
char *algo, *data, *digest;
|
||||
int algo_len, data_len;
|
||||
zend_bool raw_output = 0;
|
||||
php_hash_ops *ops;
|
||||
void *context;
|
||||
php_stream *stream = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &algo, &algo_len, &data, &data_len, &raw_output) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ops = php_hash_fetch_ops(algo, algo_len);
|
||||
if (!ops) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (isfilename) {
|
||||
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL, DEFAULT_CONTEXT);
|
||||
if (!stream) {
|
||||
/* Stream will report errors opening file */
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
context = emalloc(ops->context_size);
|
||||
ops->hash_init(context);
|
||||
|
||||
if (isfilename) {
|
||||
char buf[1024];
|
||||
int n;
|
||||
|
||||
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
|
||||
ops->hash_update(context, buf, n);
|
||||
}
|
||||
php_stream_close(stream);
|
||||
} else {
|
||||
ops->hash_update(context, data, data_len);
|
||||
}
|
||||
|
||||
digest = emalloc(ops->digest_size + 1);
|
||||
ops->hash_final(digest, context);
|
||||
efree(context);
|
||||
|
||||
if (raw_output) {
|
||||
digest[ops->digest_size] = 0;
|
||||
RETURN_STRINGL(digest, ops->digest_size, 0);
|
||||
} else {
|
||||
char *hex_digest = safe_emalloc(ops->digest_size, 2, 1);
|
||||
|
||||
php_hash_bin2hex(hex_digest, digest, ops->digest_size);
|
||||
hex_digest[2 * ops->digest_size] = 0;
|
||||
efree(digest);
|
||||
RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* {{{ proto string hash(string algo, string data[, bool raw_output = false])
|
||||
Generate a hash of a given input string
|
||||
Returns lowercase hexits by default */
|
||||
PHP_FUNCTION(hash) {
|
||||
php_hash_do_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string hash_file(string algo, string filename[, bool raw_output = false])
|
||||
Generate a hash of a given file
|
||||
Returns lowercase hexits by default */
|
||||
PHP_FUNCTION(hash_file) {
|
||||
php_hash_do_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename)
|
||||
{
|
||||
char *algo, *data, *digest, *key, *K;
|
||||
int algo_len, data_len, key_len, i;
|
||||
zend_bool raw_output = 0;
|
||||
php_hash_ops *ops;
|
||||
void *context;
|
||||
php_stream *stream = NULL;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|b", &algo, &algo_len, &data, &data_len,
|
||||
&key, &key_len, &raw_output) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ops = php_hash_fetch_ops(algo, algo_len);
|
||||
if (!ops) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (isfilename) {
|
||||
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL, DEFAULT_CONTEXT);
|
||||
if (!stream) {
|
||||
/* Stream will report errors opening file */
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
context = emalloc(ops->context_size);
|
||||
ops->hash_init(context);
|
||||
|
||||
K = emalloc(ops->block_size);
|
||||
memset(K, 0, ops->block_size);
|
||||
|
||||
if (key_len > ops->block_size) {
|
||||
/* Reduce the key first */
|
||||
ops->hash_update(context, key, key_len);
|
||||
ops->hash_final(K, context);
|
||||
/* Make the context ready to start over */
|
||||
ops->hash_init(context);
|
||||
} else {
|
||||
memcpy(K, key, key_len);
|
||||
}
|
||||
|
||||
/* XOR ipad */
|
||||
for(i=0; i < ops->block_size; i++) {
|
||||
K[i] ^= 0x36;
|
||||
}
|
||||
ops->hash_update(context, K, ops->block_size);
|
||||
|
||||
if (isfilename) {
|
||||
char buf[1024];
|
||||
int n;
|
||||
|
||||
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
|
||||
ops->hash_update(context, buf, n);
|
||||
}
|
||||
php_stream_close(stream);
|
||||
} else {
|
||||
ops->hash_update(context, data, data_len);
|
||||
}
|
||||
|
||||
digest = emalloc(ops->digest_size + 1);
|
||||
ops->hash_final(digest, context);
|
||||
|
||||
/* Convert K to opad -- 0x6A = 0x36 ^ 0x5C */
|
||||
for(i=0; i < ops->block_size; i++) {
|
||||
K[i] ^= 0x6A;
|
||||
}
|
||||
|
||||
/* Feed this result into the outter hash */
|
||||
ops->hash_init(context);
|
||||
ops->hash_update(context, K, ops->block_size);
|
||||
ops->hash_update(context, digest, ops->digest_size);
|
||||
ops->hash_final(digest, context);
|
||||
|
||||
/* Zero the key */
|
||||
memset(K, 0, ops->block_size);
|
||||
efree(K);
|
||||
efree(context);
|
||||
|
||||
if (raw_output) {
|
||||
digest[ops->digest_size] = 0;
|
||||
RETURN_STRINGL(digest, ops->digest_size, 0);
|
||||
} else {
|
||||
char *hex_digest = safe_emalloc(ops->digest_size, 2, 1);
|
||||
|
||||
php_hash_bin2hex(hex_digest, digest, ops->digest_size);
|
||||
hex_digest[2 * ops->digest_size] = 0;
|
||||
efree(digest);
|
||||
RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* {{{ proto string hash_hmac(string algo, string data, string key[, bool raw_output = false])
|
||||
Generate a hash of a given input string with a key using HMAC
|
||||
Returns lowercase hexits by default */
|
||||
PHP_FUNCTION(hash_hmac) {
|
||||
php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string hash_hmac_file(string algo, string filename, string key[, bool raw_output = false])
|
||||
Generate a hash of a given file with a key using HMAC
|
||||
Returns lowercase hexits by default */
|
||||
PHP_FUNCTION(hash_hmac_file) {
|
||||
php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto resource hash_init(string algo[, int options, string key])
|
||||
Initialize a hashing context */
|
||||
PHP_FUNCTION(hash_init)
|
||||
{
|
||||
char *algo, *key = NULL;
|
||||
int algo_len, key_len = 0, argc = ZEND_NUM_ARGS();
|
||||
long options = 0;
|
||||
void *context;
|
||||
php_hash_ops *ops;
|
||||
php_hash_data *hash;
|
||||
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "s|ls", &algo, &algo_len, &options, &key, &key_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ops = php_hash_fetch_ops(algo, algo_len);
|
||||
if (!ops) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing algorithm: %s", algo);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (options & PHP_HASH_HMAC &&
|
||||
key_len <= 0) {
|
||||
/* Note: a zero length key is no key at all */
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "HMAC requested without a key");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
context = emalloc(ops->context_size);
|
||||
ops->hash_init(context);
|
||||
|
||||
hash = emalloc(sizeof(php_hash_data));
|
||||
hash->ops = ops;
|
||||
hash->context = context;
|
||||
hash->options = options;
|
||||
hash->key = NULL;
|
||||
|
||||
if (options & PHP_HASH_HMAC) {
|
||||
char *K = emalloc(ops->block_size);
|
||||
int i;
|
||||
|
||||
memset(K, 0, ops->block_size);
|
||||
|
||||
if (key_len > ops->block_size) {
|
||||
/* Reduce the key first */
|
||||
ops->hash_update(context, key, key_len);
|
||||
ops->hash_final(K, context);
|
||||
/* Make the context ready to start over */
|
||||
ops->hash_init(context);
|
||||
} else {
|
||||
memcpy(K, key, key_len);
|
||||
}
|
||||
|
||||
/* XOR ipad */
|
||||
for(i=0; i < ops->block_size; i++) {
|
||||
K[i] ^= 0x36;
|
||||
}
|
||||
ops->hash_update(context, K, ops->block_size);
|
||||
hash->key = K;
|
||||
}
|
||||
|
||||
ZEND_REGISTER_RESOURCE(return_value, hash, php_hash_le_hash);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool hash_update(resource context, string data)
|
||||
Pump data into the hashing algorithm */
|
||||
PHP_FUNCTION(hash_update)
|
||||
{
|
||||
zval *zhash;
|
||||
php_hash_data *hash;
|
||||
char *data;
|
||||
int data_len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zhash, &data, &data_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, &zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
|
||||
hash->ops->hash_update(hash->context, data, data_len);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int hash_update_stream(resource context, resource handle[, integer length])
|
||||
Pump data into the hashing algorithm from an open stream */
|
||||
PHP_FUNCTION(hash_update_stream)
|
||||
{
|
||||
zval *zhash, *zstream;
|
||||
php_hash_data *hash;
|
||||
php_stream *stream = NULL;
|
||||
long length = -1, didread = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &zhash, &zstream, &length) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, &zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
php_stream_from_zval(stream, &zstream);
|
||||
|
||||
while (length) {
|
||||
char buf[1024];
|
||||
long n, toread = 1024;
|
||||
|
||||
if (length > 0 && toread > length) {
|
||||
toread = length;
|
||||
}
|
||||
|
||||
if ((n = php_stream_read(stream, buf, toread)) <= 0) {
|
||||
/* Nada mas */
|
||||
RETURN_LONG(didread);
|
||||
}
|
||||
hash->ops->hash_update(hash->context, buf, n);
|
||||
length -= n;
|
||||
didread += n;
|
||||
}
|
||||
|
||||
RETURN_LONG(didread);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool hash_update_file(resource context, string filename[, resource context])
|
||||
Pump data into the hashing algorithm from a file */
|
||||
PHP_FUNCTION(hash_update_file)
|
||||
{
|
||||
zval *zhash, *zcontext = NULL;
|
||||
php_hash_data *hash;
|
||||
php_stream_context *context;
|
||||
php_stream *stream;
|
||||
char *filename, buf[1024];
|
||||
int filename_len, n;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, &zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
context = php_stream_context_from_zval(zcontext, 0);
|
||||
|
||||
stream = php_stream_open_wrapper_ex(filename, "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL, context);
|
||||
if (!stream) {
|
||||
/* Stream will report errors opening file */
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
|
||||
hash->ops->hash_update(hash->context, buf, n);
|
||||
}
|
||||
php_stream_close(stream);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string hash_final(resource context[, bool raw_output=false])
|
||||
Output resulting digest */
|
||||
PHP_FUNCTION(hash_final)
|
||||
{
|
||||
zval *zhash;
|
||||
php_hash_data *hash;
|
||||
zend_bool raw_output = 0;
|
||||
zend_rsrc_list_entry *le;
|
||||
char *digest;
|
||||
int digest_len;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &zhash, &raw_output) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
ZEND_FETCH_RESOURCE(hash, php_hash_data*, &zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
|
||||
|
||||
digest_len = hash->ops->digest_size;
|
||||
digest = emalloc(digest_len + 1);
|
||||
hash->ops->hash_final(digest, hash->context);
|
||||
if (hash->options & PHP_HASH_HMAC) {
|
||||
int i;
|
||||
|
||||
/* Convert K to opad -- 0x6A = 0x36 ^ 0x5C */
|
||||
for(i=0; i < hash->ops->block_size; i++) {
|
||||
hash->key[i] ^= 0x6A;
|
||||
}
|
||||
|
||||
/* Feed this result into the outter hash */
|
||||
hash->ops->hash_init(hash->context);
|
||||
hash->ops->hash_update(hash->context, hash->key, hash->ops->block_size);
|
||||
hash->ops->hash_update(hash->context, digest, hash->ops->digest_size);
|
||||
hash->ops->hash_final(digest, hash->context);
|
||||
|
||||
/* Zero the key */
|
||||
memset(hash->key, 0, hash->ops->block_size);
|
||||
efree(hash->key);
|
||||
hash->key = NULL;
|
||||
}
|
||||
digest[digest_len] = 0;
|
||||
efree(hash->context);
|
||||
hash->context = NULL;
|
||||
|
||||
/* zend_list_REAL_delete() */
|
||||
if (zend_hash_index_find(&EG(regular_list), Z_RESVAL_P(zhash), (void **) &le)==SUCCESS) {
|
||||
/* This is a hack to avoid letting the resource hide elsewhere (like in separated vars)
|
||||
FETCH_RESOURCE is intelligent enough to handle dealing with any issues this causes */
|
||||
le->refcount = 1;
|
||||
} /* FAILURE is not an option */
|
||||
zend_list_delete(Z_RESVAL_P(zhash));
|
||||
|
||||
if (raw_output) {
|
||||
RETURN_STRINGL(digest, digest_len, 0);
|
||||
} else {
|
||||
char *hex_digest = safe_emalloc(digest_len,2,1);
|
||||
|
||||
php_hash_bin2hex(hex_digest, digest, digest_len);
|
||||
hex_digest[2 * digest_len] = 0;
|
||||
efree(digest);
|
||||
RETURN_STRINGL(hex_digest, 2 * digest_len, 0);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array hash_algos(void)
|
||||
Return a list of registered hashing algorithms */
|
||||
PHP_FUNCTION(hash_algos)
|
||||
{
|
||||
HashPosition pos;
|
||||
char *str;
|
||||
int str_len;
|
||||
long idx, type;
|
||||
|
||||
array_init(return_value);
|
||||
for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos);
|
||||
(type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, &str_len, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT;
|
||||
zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) {
|
||||
add_next_index_stringl(return_value, str, str_len-1, 1);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Module Housekeeping */
|
||||
|
||||
static void php_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||
{
|
||||
php_hash_data *hash = (php_hash_data*)rsrc->ptr;
|
||||
|
||||
/* Just in case the algo has internally allocated resources */
|
||||
if (hash->context) {
|
||||
char *dummy = emalloc(hash->ops->digest_size);
|
||||
hash->ops->hash_final(dummy, hash->context);
|
||||
efree(dummy);
|
||||
efree(hash->context);
|
||||
}
|
||||
|
||||
if (hash->key) {
|
||||
memset(hash->key, 0, hash->ops->block_size);
|
||||
efree(hash->key);
|
||||
}
|
||||
efree(hash);
|
||||
}
|
||||
|
||||
#define PHP_HASH_HAVAL_REGISTER(p,b) php_hash_register_algo("haval" #b "," #p , &php_hash_##p##haval##b##_ops);
|
||||
|
||||
/* {{{ PHP_MINIT_FUNCTION
|
||||
*/
|
||||
PHP_MINIT_FUNCTION(hash)
|
||||
{
|
||||
php_hash_le_hash = zend_register_list_destructors_ex(php_hash_dtor, NULL, PHP_HASH_RESNAME, module_number);
|
||||
|
||||
zend_hash_init(&php_hash_hashtable, 35, NULL, NULL, 1);
|
||||
|
||||
php_hash_register_algo("md4", &php_hash_md4_ops);
|
||||
php_hash_register_algo("md5", &php_hash_md5_ops);
|
||||
php_hash_register_algo("sha1", &php_hash_sha1_ops);
|
||||
php_hash_register_algo("sha256", &php_hash_sha256_ops);
|
||||
php_hash_register_algo("sha384", &php_hash_sha384_ops);
|
||||
php_hash_register_algo("sha512", &php_hash_sha512_ops);
|
||||
php_hash_register_algo("ripemd128", &php_hash_ripemd128_ops);
|
||||
php_hash_register_algo("ripemd160", &php_hash_ripemd160_ops);
|
||||
php_hash_register_algo("whirlpool", &php_hash_whirlpool_ops);
|
||||
php_hash_register_algo("tiger128,3", &php_hash_3tiger128_ops);
|
||||
php_hash_register_algo("tiger160,3", &php_hash_3tiger160_ops);
|
||||
php_hash_register_algo("tiger192,3", &php_hash_3tiger192_ops);
|
||||
php_hash_register_algo("tiger128,4", &php_hash_4tiger128_ops);
|
||||
php_hash_register_algo("tiger160,4", &php_hash_4tiger160_ops);
|
||||
php_hash_register_algo("tiger192,4", &php_hash_4tiger192_ops);
|
||||
php_hash_register_algo("snefru", &php_hash_snefru_ops);
|
||||
php_hash_register_algo("gost", &php_hash_gost_ops);
|
||||
php_hash_register_algo("adler32", &php_hash_adler32_ops);
|
||||
php_hash_register_algo("crc32", &php_hash_crc32_ops);
|
||||
php_hash_register_algo("crc32b", &php_hash_crc32b_ops);
|
||||
|
||||
PHP_HASH_HAVAL_REGISTER(3,128);
|
||||
PHP_HASH_HAVAL_REGISTER(3,160);
|
||||
PHP_HASH_HAVAL_REGISTER(3,192);
|
||||
PHP_HASH_HAVAL_REGISTER(3,224);
|
||||
PHP_HASH_HAVAL_REGISTER(3,256);
|
||||
|
||||
PHP_HASH_HAVAL_REGISTER(4,128);
|
||||
PHP_HASH_HAVAL_REGISTER(4,160);
|
||||
PHP_HASH_HAVAL_REGISTER(4,192);
|
||||
PHP_HASH_HAVAL_REGISTER(4,224);
|
||||
PHP_HASH_HAVAL_REGISTER(4,256);
|
||||
|
||||
PHP_HASH_HAVAL_REGISTER(5,128);
|
||||
PHP_HASH_HAVAL_REGISTER(5,160);
|
||||
PHP_HASH_HAVAL_REGISTER(5,192);
|
||||
PHP_HASH_HAVAL_REGISTER(5,224);
|
||||
PHP_HASH_HAVAL_REGISTER(5,256);
|
||||
|
||||
REGISTER_LONG_CONSTANT("HASH_HMAC", PHP_HASH_HMAC, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MSHUTDOWN_FUNCTION
|
||||
*/
|
||||
PHP_MSHUTDOWN_FUNCTION(hash)
|
||||
{
|
||||
zend_hash_destroy(&php_hash_hashtable);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINFO_FUNCTION
|
||||
*/
|
||||
PHP_MINFO_FUNCTION(hash)
|
||||
{
|
||||
HashPosition pos;
|
||||
char buffer[2048];
|
||||
char *s = buffer, *e = s + sizeof(buffer), *str;
|
||||
long idx, type;
|
||||
|
||||
for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos);
|
||||
(type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT;
|
||||
zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) {
|
||||
s += snprintf(s, e - s, "%s ", str);
|
||||
}
|
||||
*s = 0;
|
||||
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "hash support", "enabled");
|
||||
php_info_print_table_header(2, "Hashing Engines", buffer);
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ hash_functions[]
|
||||
*/
|
||||
zend_function_entry hash_functions[] = {
|
||||
PHP_FE(hash, NULL)
|
||||
PHP_FE(hash_file, NULL)
|
||||
|
||||
PHP_FE(hash_hmac, NULL)
|
||||
PHP_FE(hash_hmac_file, NULL)
|
||||
|
||||
PHP_FE(hash_init, NULL)
|
||||
PHP_FE(hash_update, NULL)
|
||||
PHP_FE(hash_update_stream, NULL)
|
||||
PHP_FE(hash_update_file, NULL)
|
||||
PHP_FE(hash_final, NULL)
|
||||
|
||||
PHP_FE(hash_algos, NULL)
|
||||
|
||||
/* BC Land */
|
||||
#ifdef PHP_HASH_MD5_NOT_IN_CORE
|
||||
PHP_NAMED_FE(md5, php_if_md5, NULL)
|
||||
PHP_NAMED_FE(md5_file, php_if_md5_file, NULL)
|
||||
#endif /* PHP_HASH_MD5_NOT_IN_CORE */
|
||||
|
||||
#ifdef PHP_HASH_SHA1_NOT_IN_CORE
|
||||
PHP_NAMED_FE(sha1, php_if_sha1, NULL)
|
||||
PHP_NAMED_FE(sha1_file, php_if_sha1_file, NULL)
|
||||
#endif /* PHP_HASH_SHA1_NOT_IN_CORE */
|
||||
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ hash_module_entry
|
||||
*/
|
||||
zend_module_entry hash_module_entry = {
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
STANDARD_MODULE_HEADER,
|
||||
#endif
|
||||
PHP_HASH_EXTNAME,
|
||||
hash_functions,
|
||||
PHP_MINIT(hash),
|
||||
PHP_MSHUTDOWN(hash),
|
||||
NULL, /* RINIT */
|
||||
NULL, /* RSHUTDOWN */
|
||||
PHP_MINFO(hash),
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
PHP_HASH_EXTVER, /* Replace with version number for your extension */
|
||||
#endif
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
#ifdef COMPILE_DL_HASH
|
||||
ZEND_GET_MODULE(hash)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Michael Wallner <mike@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_adler32.h"
|
||||
|
||||
PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context)
|
||||
{
|
||||
context->state = 1;
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
php_hash_uint32 i, s[2] = { context->state & 0xffff, (context->state >> 16) & 0xffff };
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
s[0] = (s[0] + input[i]) % 65521;
|
||||
s[1] = (s[1] + s[0]) % 65521;
|
||||
}
|
||||
context->state = s[0] + (s[1] << 16);
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_ADLER32Final(unsigned char digest[4], PHP_ADLER32_CTX *context)
|
||||
{
|
||||
digest[3] = (unsigned char) ((context->state >> 24) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state >> 16) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state >> 8) & 0xff);
|
||||
digest[0] = (unsigned char) (context->state & 0xff);
|
||||
context->state = 0;
|
||||
}
|
||||
|
||||
php_hash_ops php_hash_adler32_ops = {
|
||||
(php_hash_init_func_t) PHP_ADLER32Init,
|
||||
(php_hash_update_func_t) PHP_ADLER32Update,
|
||||
(php_hash_final_func_t) PHP_ADLER32Final,
|
||||
4, /* what to say here? */
|
||||
4,
|
||||
sizeof(PHP_ADLER32_CTX)
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Michael Wallner <mike@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_crc32.h"
|
||||
#include "php_hash_crc32_tables.h"
|
||||
|
||||
PHP_HASH_API void PHP_CRC32Init(PHP_CRC32_CTX *context)
|
||||
{
|
||||
context->state = ~0;
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_CRC32Update(PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
context->state = (context->state << 8) ^ crc32_table[(context->state >> 24) ^ (input[i] & 0xff)];
|
||||
}
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_CRC32BUpdate(PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
context->state = (context->state >> 8) ^ crc32b_table[(context->state ^ input[i]) & 0xff];
|
||||
}
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_CRC32Final(unsigned char digest[4], PHP_CRC32_CTX *context)
|
||||
{
|
||||
context->state=~context->state;
|
||||
digest[3] = (unsigned char) ((context->state >> 24) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state >> 16) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state >> 8) & 0xff);
|
||||
digest[0] = (unsigned char) (context->state & 0xff);
|
||||
context->state = 0;
|
||||
}
|
||||
|
||||
php_hash_ops php_hash_crc32_ops = {
|
||||
(php_hash_init_func_t) PHP_CRC32Init,
|
||||
(php_hash_update_func_t) PHP_CRC32Update,
|
||||
(php_hash_final_func_t) PHP_CRC32Final,
|
||||
4, /* what to say here? */
|
||||
4,
|
||||
sizeof(PHP_CRC32_CTX)
|
||||
};
|
||||
|
||||
php_hash_ops php_hash_crc32b_ops = {
|
||||
(php_hash_init_func_t) PHP_CRC32Init,
|
||||
(php_hash_update_func_t) PHP_CRC32BUpdate,
|
||||
(php_hash_final_func_t) PHP_CRC32Final,
|
||||
4, /* what to say here? */
|
||||
4,
|
||||
sizeof(PHP_CRC32_CTX)
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,321 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Michael Wallner <mike@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_gost.h"
|
||||
#include "php_hash_gost_tables.h"
|
||||
|
||||
/* {{{ Gost()
|
||||
* derived from gost_compress() by Markku-Juhani Saarinen <mjos@ssh.fi>
|
||||
*/
|
||||
|
||||
#define round(k1, k2) \
|
||||
t = (k1) + r; \
|
||||
l ^= tables[0][t & 0xff] ^ tables[1][(t >> 8) & 0xff] ^ \
|
||||
tables[2][(t >> 16) & 0xff] ^ tables[3][t >> 24]; \
|
||||
t = (k2) + l; \
|
||||
r ^= tables[0][t & 0xff] ^ tables[1][(t >> 8) & 0xff] ^ \
|
||||
tables[2][(t >> 16) & 0xff] ^ tables[3][t >> 24];
|
||||
|
||||
#define R(key, h, i, t, l, r) \
|
||||
r = h[i]; \
|
||||
l = h[i + 1]; \
|
||||
round(key[0], key[1]) \
|
||||
round(key[2], key[3]) \
|
||||
round(key[4], key[5]) \
|
||||
round(key[6], key[7]) \
|
||||
round(key[0], key[1]) \
|
||||
round(key[2], key[3]) \
|
||||
round(key[4], key[5]) \
|
||||
round(key[6], key[7]) \
|
||||
round(key[0], key[1]) \
|
||||
round(key[2], key[3]) \
|
||||
round(key[4], key[5]) \
|
||||
round(key[6], key[7]) \
|
||||
round(key[7], key[6]) \
|
||||
round(key[5], key[4]) \
|
||||
round(key[3], key[2]) \
|
||||
round(key[1], key[0]) \
|
||||
t = r; \
|
||||
r = l; \
|
||||
l = t; \
|
||||
|
||||
#define X(w, u, v) \
|
||||
w[0] = u[0] ^ v[0]; \
|
||||
w[1] = u[1] ^ v[1]; \
|
||||
w[2] = u[2] ^ v[2]; \
|
||||
w[3] = u[3] ^ v[3]; \
|
||||
w[4] = u[4] ^ v[4]; \
|
||||
w[5] = u[5] ^ v[5]; \
|
||||
w[6] = u[6] ^ v[6]; \
|
||||
w[7] = u[7] ^ v[7];
|
||||
|
||||
#define P(key, w) \
|
||||
key[0] = (w[0] & 0x000000ff) | ((w[2] & 0x000000ff) << 8) | \
|
||||
((w[4] & 0x000000ff) << 16) | ((w[6] & 0x000000ff) << 24); \
|
||||
key[1] = ((w[0] & 0x0000ff00) >> 8) | (w[2] & 0x0000ff00) | \
|
||||
((w[4] & 0x0000ff00) << 8) | ((w[6] & 0x0000ff00) << 16); \
|
||||
key[2] = ((w[0] & 0x00ff0000) >> 16) | ((w[2] & 0x00ff0000) >> 8) | \
|
||||
(w[4] & 0x00ff0000) | ((w[6] & 0x00ff0000) << 8); \
|
||||
key[3] = ((w[0] & 0xff000000) >> 24) | ((w[2] & 0xff000000) >> 16) | \
|
||||
((w[4] & 0xff000000) >> 8) | (w[6] & 0xff000000); \
|
||||
key[4] = (w[1] & 0x000000ff) | ((w[3] & 0x000000ff) << 8) | \
|
||||
((w[5] & 0x000000ff) << 16) | ((w[7] & 0x000000ff) << 24); \
|
||||
key[5] = ((w[1] & 0x0000ff00) >> 8) | (w[3] & 0x0000ff00) | \
|
||||
((w[5] & 0x0000ff00) << 8) | ((w[7] & 0x0000ff00) << 16); \
|
||||
key[6] = ((w[1] & 0x00ff0000) >> 16) | ((w[3] & 0x00ff0000) >> 8) | \
|
||||
(w[5] & 0x00ff0000) | ((w[7] & 0x00ff0000) << 8); \
|
||||
key[7] = ((w[1] & 0xff000000) >> 24) | ((w[3] & 0xff000000) >> 16) | \
|
||||
((w[5] & 0xff000000) >> 8) | (w[7] & 0xff000000);
|
||||
|
||||
#define A(x, l, r) \
|
||||
l = x[0] ^ x[2]; \
|
||||
r = x[1] ^ x[3]; \
|
||||
x[0] = x[2]; \
|
||||
x[1] = x[3]; \
|
||||
x[2] = x[4]; \
|
||||
x[3] = x[5]; \
|
||||
x[4] = x[6]; \
|
||||
x[5] = x[7]; \
|
||||
x[6] = l; \
|
||||
x[7] = r;
|
||||
|
||||
#define AA(x, l, r) \
|
||||
l = x[0]; \
|
||||
r = x[2]; \
|
||||
x[0] = x[4]; \
|
||||
x[2] = x[6]; \
|
||||
x[4] = l ^ r; \
|
||||
x[6] = x[0] ^ r; \
|
||||
l = x[1]; \
|
||||
r = x[3]; \
|
||||
x[1] = x[5]; \
|
||||
x[3] = x[7]; \
|
||||
x[5] = l ^ r; \
|
||||
x[7] = x[1] ^ r;
|
||||
|
||||
#define C(x) \
|
||||
x[0] ^= 0xff00ff00; \
|
||||
x[1] ^= 0xff00ff00; \
|
||||
x[2] ^= 0x00ff00ff; \
|
||||
x[3] ^= 0x00ff00ff; \
|
||||
x[4] ^= 0x00ffff00; \
|
||||
x[5] ^= 0xff0000ff; \
|
||||
x[6] ^= 0x000000ff; \
|
||||
x[7] ^= 0xff00ffff;
|
||||
|
||||
#define S(s, l, r) \
|
||||
s[i] = r; \
|
||||
s[i + 1] = l;
|
||||
|
||||
#define SHIFT12(u, m, s) \
|
||||
u[0] = m[0] ^ s[6]; \
|
||||
u[1] = m[1] ^ s[7]; \
|
||||
u[2] = m[2] ^ (s[0] << 16) ^ (s[0] >> 16) ^ (s[0] & 0xffff) ^ \
|
||||
(s[1] & 0xffff) ^ (s[1] >> 16) ^ (s[2] << 16) ^ s[6] ^ (s[6] << 16) ^ \
|
||||
(s[7] & 0xffff0000) ^ (s[7] >> 16); \
|
||||
u[3] = m[3] ^ (s[0] & 0xffff) ^ (s[0] << 16) ^ (s[1] & 0xffff) ^ \
|
||||
(s[1] << 16) ^ (s[1] >> 16) ^ (s[2] << 16) ^ (s[2] >> 16) ^ \
|
||||
(s[3] << 16) ^ s[6] ^ (s[6] << 16) ^ (s[6] >> 16) ^ (s[7] & 0xffff) ^ \
|
||||
(s[7] << 16) ^ (s[7] >> 16); \
|
||||
u[4] = m[4] ^ \
|
||||
(s[0] & 0xffff0000) ^ (s[0] << 16) ^ (s[0] >> 16) ^ \
|
||||
(s[1] & 0xffff0000) ^ (s[1] >> 16) ^ (s[2] << 16) ^ (s[2] >> 16) ^ \
|
||||
(s[3] << 16) ^ (s[3] >> 16) ^ (s[4] << 16) ^ (s[6] << 16) ^ \
|
||||
(s[6] >> 16) ^(s[7] & 0xffff) ^ (s[7] << 16) ^ (s[7] >> 16); \
|
||||
u[5] = m[5] ^ (s[0] << 16) ^ (s[0] >> 16) ^ (s[0] & 0xffff0000) ^ \
|
||||
(s[1] & 0xffff) ^ s[2] ^ (s[2] >> 16) ^ (s[3] << 16) ^ (s[3] >> 16) ^ \
|
||||
(s[4] << 16) ^ (s[4] >> 16) ^ (s[5] << 16) ^ (s[6] << 16) ^ \
|
||||
(s[6] >> 16) ^ (s[7] & 0xffff0000) ^ (s[7] << 16) ^ (s[7] >> 16); \
|
||||
u[6] = m[6] ^ s[0] ^ (s[1] >> 16) ^ (s[2] << 16) ^ s[3] ^ (s[3] >> 16) ^ \
|
||||
(s[4] << 16) ^ (s[4] >> 16) ^ (s[5] << 16) ^ (s[5] >> 16) ^ s[6] ^ \
|
||||
(s[6] << 16) ^ (s[6] >> 16) ^ (s[7] << 16); \
|
||||
u[7] = m[7] ^ (s[0] & 0xffff0000) ^ (s[0] << 16) ^ (s[1] & 0xffff) ^ \
|
||||
(s[1] << 16) ^ (s[2] >> 16) ^ (s[3] << 16) ^ s[4] ^ (s[4] >> 16) ^ \
|
||||
(s[5] << 16) ^ (s[5] >> 16) ^ (s[6] >> 16) ^ (s[7] & 0xffff) ^ \
|
||||
(s[7] << 16) ^ (s[7] >> 16);
|
||||
|
||||
#define SHIFT16(h, v, u) \
|
||||
v[0] = h[0] ^ (u[1] << 16) ^ (u[0] >> 16); \
|
||||
v[1] = h[1] ^ (u[2] << 16) ^ (u[1] >> 16); \
|
||||
v[2] = h[2] ^ (u[3] << 16) ^ (u[2] >> 16); \
|
||||
v[3] = h[3] ^ (u[4] << 16) ^ (u[3] >> 16); \
|
||||
v[4] = h[4] ^ (u[5] << 16) ^ (u[4] >> 16); \
|
||||
v[5] = h[5] ^ (u[6] << 16) ^ (u[5] >> 16); \
|
||||
v[6] = h[6] ^ (u[7] << 16) ^ (u[6] >> 16); \
|
||||
v[7] = h[7] ^ (u[0] & 0xffff0000) ^ (u[0] << 16) ^ (u[7] >> 16) ^ \
|
||||
(u[1] & 0xffff0000) ^ (u[1] << 16) ^ (u[6] << 16) ^ (u[7] & 0xffff0000);
|
||||
|
||||
#define SHIFT61(h, v) \
|
||||
h[0] = (v[0] & 0xffff0000) ^ (v[0] << 16) ^ (v[0] >> 16) ^ (v[1] >> 16) ^ \
|
||||
(v[1] & 0xffff0000) ^ (v[2] << 16) ^ (v[3] >> 16) ^ (v[4] << 16) ^ \
|
||||
(v[5] >> 16) ^ v[5] ^ (v[6] >> 16) ^ (v[7] << 16) ^ (v[7] >> 16) ^ \
|
||||
(v[7] & 0xffff); \
|
||||
h[1] = (v[0] << 16) ^ (v[0] >> 16) ^ (v[0] & 0xffff0000) ^ (v[1] & 0xffff) ^ \
|
||||
v[2] ^ (v[2] >> 16) ^ (v[3] << 16) ^ (v[4] >> 16) ^ (v[5] << 16) ^ \
|
||||
(v[6] << 16) ^ v[6] ^ (v[7] & 0xffff0000) ^ (v[7] >> 16); \
|
||||
h[2] = (v[0] & 0xffff) ^ (v[0] << 16) ^ (v[1] << 16) ^ (v[1] >> 16) ^ \
|
||||
(v[1] & 0xffff0000) ^ (v[2] << 16) ^ (v[3] >> 16) ^ v[3] ^ (v[4] << 16) ^ \
|
||||
(v[5] >> 16) ^ v[6] ^ (v[6] >> 16) ^ (v[7] & 0xffff) ^ (v[7] << 16) ^ \
|
||||
(v[7] >> 16); \
|
||||
h[3] = (v[0] << 16) ^ (v[0] >> 16) ^ (v[0] & 0xffff0000) ^ \
|
||||
(v[1] & 0xffff0000) ^ (v[1] >> 16) ^ (v[2] << 16) ^ (v[2] >> 16) ^ v[2] ^ \
|
||||
(v[3] << 16) ^ (v[4] >> 16) ^ v[4] ^ (v[5] << 16) ^ (v[6] << 16) ^ \
|
||||
(v[7] & 0xffff) ^ (v[7] >> 16); \
|
||||
h[4] = (v[0] >> 16) ^ (v[1] << 16) ^ v[1] ^ (v[2] >> 16) ^ v[2] ^ \
|
||||
(v[3] << 16) ^ (v[3] >> 16) ^ v[3] ^ (v[4] << 16) ^ (v[5] >> 16) ^ \
|
||||
v[5] ^ (v[6] << 16) ^ (v[6] >> 16) ^ (v[7] << 16); \
|
||||
h[5] = (v[0] << 16) ^ (v[0] & 0xffff0000) ^ (v[1] << 16) ^ (v[1] >> 16) ^ \
|
||||
(v[1] & 0xffff0000) ^ (v[2] << 16) ^ v[2] ^ (v[3] >> 16) ^ v[3] ^ \
|
||||
(v[4] << 16) ^ (v[4] >> 16) ^ v[4] ^ (v[5] << 16) ^ (v[6] << 16) ^ \
|
||||
(v[6] >> 16) ^ v[6] ^ (v[7] << 16) ^ (v[7] >> 16) ^ (v[7] & 0xffff0000); \
|
||||
h[6] = v[0] ^ v[2] ^ (v[2] >> 16) ^ v[3] ^ (v[3] << 16) ^ v[4] ^ \
|
||||
(v[4] >> 16) ^ (v[5] << 16) ^ (v[5] >> 16) ^ v[5] ^ (v[6] << 16) ^ \
|
||||
(v[6] >> 16) ^ v[6] ^ (v[7] << 16) ^ v[7]; \
|
||||
h[7] = v[0] ^ (v[0] >> 16) ^ (v[1] << 16) ^ (v[1] >> 16) ^ (v[2] << 16) ^ \
|
||||
(v[3] >> 16) ^ v[3] ^ (v[4] << 16) ^ v[4] ^ (v[5] >> 16) ^ v[5] ^ \
|
||||
(v[6] << 16) ^ (v[6] >> 16) ^ (v[7] << 16) ^ v[7];
|
||||
|
||||
#define PASS \
|
||||
X(w, u, v); \
|
||||
P(key, w); \
|
||||
R(key, h, i, t, l, r); \
|
||||
S(s, l, r); \
|
||||
if (i != 6) { \
|
||||
A(u, l, r); \
|
||||
if (i == 2) { \
|
||||
C(u); \
|
||||
} \
|
||||
AA(v, l, r); \
|
||||
}
|
||||
|
||||
static inline void Gost(php_hash_uint32 state[8], php_hash_uint32 data[8])
|
||||
{
|
||||
int i;
|
||||
php_hash_uint32 l, r, t, key[8], u[8], v[8], w[8], s[8], *h = state, *m = data;
|
||||
|
||||
memcpy(u, state, sizeof(u));
|
||||
memcpy(v, data, sizeof(v));
|
||||
|
||||
for (i = 0; i < 8; i += 2) {
|
||||
PASS;
|
||||
}
|
||||
SHIFT12(u, m, s);
|
||||
SHIFT16(h, v, u);
|
||||
SHIFT61(h, v);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32])
|
||||
{
|
||||
int i, j;
|
||||
php_hash_uint32 data[8], temp = 0, save = 0;
|
||||
|
||||
for (i = 0, j = 0; i < 8; ++i, j += 4) {
|
||||
data[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) |
|
||||
(((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
|
||||
save = context->state[i + 8];
|
||||
context->state[i + 8] += data[i] + temp;
|
||||
temp = ((context->state[i + 8] < data[i]) || (context->state[i + 8] < save)) ? 1 : 0;
|
||||
}
|
||||
|
||||
Gost(context->state, data);
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
static const php_hash_uint32 MAX32 = 0xffffffffLU;
|
||||
|
||||
PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
if ((MAX32 - context->count[0]) < (len * 8)) {
|
||||
context->count[1]++;
|
||||
context->count[0] = MAX32 - context->count[0];
|
||||
context->count[0] = (len * 8) - context->count[0];
|
||||
} else {
|
||||
context->count[0] += len * 8;
|
||||
}
|
||||
|
||||
if (context->length + len < 32) {
|
||||
memcpy(&context->buffer[context->length], input, len);
|
||||
context->length += len;
|
||||
} else {
|
||||
size_t i = 0, r = (context->length + len) % 32;
|
||||
|
||||
if (context->length) {
|
||||
i = 32 - context->length;
|
||||
memcpy(&context->buffer[context->length], input, i);
|
||||
GostTransform(context, context->buffer);
|
||||
}
|
||||
|
||||
for (; i + 32 <= len; i += 32) {
|
||||
GostTransform(context, input + i);
|
||||
}
|
||||
|
||||
memcpy(context->buffer, input + i, r);
|
||||
memset(&context->buffer[r], 0, 32 - r);
|
||||
context->length = r;
|
||||
}
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context)
|
||||
{
|
||||
php_hash_uint32 i, j, l[8] = {0};
|
||||
|
||||
if (context->length) {
|
||||
GostTransform(context, context->buffer);
|
||||
}
|
||||
|
||||
memcpy(l, context->count, sizeof(context->count));
|
||||
Gost(context->state, l);
|
||||
memcpy(l, &context->state[8], sizeof(l));
|
||||
Gost(context->state, l);
|
||||
|
||||
for (i = 0, j = 0; j < 32; i++, j += 4) {
|
||||
digest[j] = (unsigned char) (context->state[i] & 0xff);
|
||||
digest[j + 1] = (unsigned char) ((context->state[i] >> 8) & 0xff);
|
||||
digest[j + 2] = (unsigned char) ((context->state[i] >> 16) & 0xff);
|
||||
digest[j + 3] = (unsigned char) ((context->state[i] >> 24) & 0xff);
|
||||
}
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
php_hash_ops php_hash_gost_ops = {
|
||||
(php_hash_init_func_t) PHP_GOSTInit,
|
||||
(php_hash_update_func_t) PHP_GOSTUpdate,
|
||||
(php_hash_final_func_t) PHP_GOSTFinal,
|
||||
32,
|
||||
32,
|
||||
sizeof(PHP_GOST_CTX)
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,550 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_haval.h"
|
||||
|
||||
static unsigned char PADDING[128] ={
|
||||
1, 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,
|
||||
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, 0 };
|
||||
|
||||
static php_hash_uint32 D0[8] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89 };
|
||||
|
||||
static php_hash_uint32 K2[32] = {
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
|
||||
0x9216D5D9, 0x8979FB1B, 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96,
|
||||
0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16, 0x636920D8, 0x71574E69,
|
||||
0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE, 0x7B54A41D, 0xC25A59B5 };
|
||||
|
||||
static php_hash_uint32 K3[32] = {
|
||||
0x9C30D539, 0x2AF26013, 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF, 0x8E79DCB0, 0x603A180E,
|
||||
0x6C9E0E8B, 0xB01E8A3E, 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60, 0xE65525F3, 0xAA55AB94,
|
||||
0x57489862, 0x63E81440, 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE, 0xA15486AF, 0x7C72E993,
|
||||
0xB3EE1411, 0x636FBC2A, 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E, 0xAFD6BA33, 0x6C24CF5C };
|
||||
|
||||
static php_hash_uint32 K4[32] = {
|
||||
0x7A325381, 0x28958677, 0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193, 0x61D809CC, 0xFB21A991,
|
||||
0x487CAC60, 0x5DEC8032, 0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88, 0x23893E81, 0xD396ACC5,
|
||||
0x0F6D6FF3, 0x83F44239, 0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E, 0x21C66842, 0xF6E96C9A,
|
||||
0x670C9C61, 0xABD388F0, 0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3, 0x6EEF0B6C, 0x137A3BE4 };
|
||||
|
||||
static php_hash_uint32 K5[32] = {
|
||||
0xBA3BF050, 0x7EFB2A98, 0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88, 0x8CEE8619, 0x456F9FB4,
|
||||
0x7D84A5C3, 0x3B8B5EBE, 0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6, 0x4ED3AA62, 0x363F7706,
|
||||
0x1BFEDF72, 0x429B023D, 0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B, 0x075372C9, 0x80991B7B,
|
||||
0x25D479D8, 0xF6E8DEF7, 0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA, 0xC1A94FB6, 0x409F60C4 };
|
||||
|
||||
static short I2[32] = { 5, 14, 26, 18, 11, 28, 7, 16, 0, 23, 20, 22, 1, 10, 4, 8,
|
||||
30, 3, 21, 9, 17, 24, 29, 6, 19, 12, 15, 13, 2, 25, 31, 27 };
|
||||
|
||||
static short I3[32] = { 19, 9, 4, 20, 28, 17, 8, 22, 29, 14, 25, 12, 24, 30, 16, 26,
|
||||
31, 15, 7, 3, 1, 0, 18, 27, 13, 6, 21, 10, 23, 11, 5, 2 };
|
||||
|
||||
static short I4[32] = { 24, 4, 0, 14, 2, 7, 28, 23, 26, 6, 30, 20, 18, 25, 19, 3,
|
||||
22, 11, 31, 21, 8, 27, 12, 9, 1, 29, 5, 15, 17, 10, 16, 13 };
|
||||
|
||||
static short I5[32] = { 27, 3, 21, 26, 17, 11, 20, 29, 19, 0, 12, 7, 13, 8, 31, 10,
|
||||
5, 9, 14, 30, 18, 6, 28, 24, 2, 23, 16, 22, 4, 1, 25, 15 };
|
||||
|
||||
static short M0[32] = { 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1,
|
||||
0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1 };
|
||||
|
||||
static short M1[32] = { 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2,
|
||||
1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2 };
|
||||
|
||||
static short M2[32] = { 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3,
|
||||
2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3 };
|
||||
|
||||
static short M3[32] = { 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4,
|
||||
3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4 };
|
||||
|
||||
static short M4[32] = { 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5,
|
||||
4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5 };
|
||||
|
||||
static short M5[32] = { 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6,
|
||||
5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6 };
|
||||
|
||||
static short M6[32] = { 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7,
|
||||
6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7 };
|
||||
|
||||
static short M7[32] = { 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0,
|
||||
7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0 };
|
||||
|
||||
/* {{{ Encode
|
||||
Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void Encode(unsigned char *output, php_hash_uint32 *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||
output[j] = (unsigned char) (input[i] & 0xff);
|
||||
output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
|
||||
output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
|
||||
output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Decode
|
||||
Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void Decode(php_hash_uint32 *output, const unsigned char *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||
output[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) |
|
||||
(((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#define F1(x6,x5,x4,x3,x2,x1,x0) ( ((x1) & (x4)) ^ ((x2) & (x5)) ^ ((x3) & (x6)) ^ ((x0) & (x1)) ^ (x0) )
|
||||
#define F2(x6,x5,x4,x3,x2,x1,x0) ( ((x1) & (x2) & (x3)) ^ ((x2) & (x4) & (x5)) ^ ((x1) & (x2)) ^ ((x1) & (x4)) ^ \
|
||||
((x2) & (x6)) ^ ((x3) & (x5)) ^ ((x4) & (x5)) ^ ((x0) & (x2)) ^ (x0) )
|
||||
#define F3(x6,x5,x4,x3,x2,x1,x0) ( ((x1) & (x2) & (x3)) ^ ((x1) & (x4)) ^ ((x2) & (x5)) ^ ((x3) & (x6)) ^ ((x0) & (x3)) ^ (x0) )
|
||||
#define F4(x6,x5,x4,x3,x2,x1,x0) ( ((x1) & (x2) & (x3)) ^ ((x2) & (x4) & (x5)) ^ ((x3) & (x4) & (x6)) ^ \
|
||||
((x1) & (x4)) ^ ((x2) & (x6)) ^ ((x3) & (x4)) ^ ((x3) & (x5)) ^ \
|
||||
((x3) & (x6)) ^ ((x4) & (x5)) ^ ((x4) & (x6)) ^ ((x0) & (x4)) ^ (x0) )
|
||||
#define F5(x6,x5,x4,x3,x2,x1,x0) ( ((x1) & (x4)) ^ ((x2) & (x5)) ^ ((x3) & (x6)) ^ \
|
||||
((x0) & (x1) & (x2) & (x3)) ^ ((x0) & (x5)) ^ (x0) )
|
||||
|
||||
#define ROTR(x,n) (((x) >> (n)) | ((x) << (32 - (n))))
|
||||
|
||||
|
||||
/* {{{ PHP_3HAVALTransform
|
||||
*/
|
||||
static void PHP_3HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128])
|
||||
{
|
||||
php_hash_uint32 E[8];
|
||||
php_hash_uint32 x[32];
|
||||
int i;
|
||||
|
||||
Decode(x, block, 128);
|
||||
|
||||
for(i = 0; i < 8; i++) {
|
||||
E[i] = state[i];
|
||||
}
|
||||
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F1(E[M1[i]],E[M0[i]],E[M3[i]],E[M5[i]],E[M6[i]],E[M2[i]],E[M4[i]]),7) + ROTR(E[M7[i]],11) + x[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F2(E[M4[i]],E[M2[i]],E[M1[i]],E[M0[i]],E[M5[i]],E[M3[i]],E[M6[i]]),7) + ROTR(E[M7[i]],11) + x[I2[i]] + K2[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F3(E[M6[i]],E[M1[i]],E[M2[i]],E[M3[i]],E[M4[i]],E[M5[i]],E[M0[i]]),7) + ROTR(E[M7[i]],11) + x[I3[i]] + K3[i];
|
||||
}
|
||||
|
||||
/* Update digest */
|
||||
for(i = 0; i < 8; i++) {
|
||||
state[i] += E[i];
|
||||
}
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset((unsigned char*) x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_4HAVALTransform
|
||||
*/
|
||||
static void PHP_4HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128])
|
||||
{
|
||||
php_hash_uint32 E[8];
|
||||
php_hash_uint32 x[32];
|
||||
int i;
|
||||
|
||||
Decode(x, block, 128);
|
||||
|
||||
for(i = 0; i < 8; i++) {
|
||||
E[i] = state[i];
|
||||
}
|
||||
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F1(E[M2[i]],E[M6[i]],E[M1[i]],E[M4[i]],E[M5[i]],E[M3[i]],E[M0[i]]),7) + ROTR(E[M7[i]],11) + x[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F2(E[M3[i]],E[M5[i]],E[M2[i]],E[M0[i]],E[M1[i]],E[M6[i]],E[M4[i]]),7) + ROTR(E[M7[i]],11) + x[I2[i]] + K2[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F3(E[M1[i]],E[M4[i]],E[M3[i]],E[M6[i]],E[M0[i]],E[M2[i]],E[M5[i]]),7) + ROTR(E[M7[i]],11) + x[I3[i]] + K3[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F4(E[M6[i]],E[M4[i]],E[M0[i]],E[M5[i]],E[M2[i]],E[M1[i]],E[M3[i]]),7) + ROTR(E[M7[i]],11) + x[I4[i]] + K4[i];
|
||||
}
|
||||
|
||||
/* Update digest */
|
||||
for(i = 0; i < 8; i++) {
|
||||
state[i] += E[i];
|
||||
}
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset((unsigned char*) x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_5HAVALTransform
|
||||
*/
|
||||
static void PHP_5HAVALTransform(php_hash_uint32 state[8], const unsigned char block[128])
|
||||
{
|
||||
php_hash_uint32 E[8];
|
||||
php_hash_uint32 x[32];
|
||||
int i;
|
||||
|
||||
Decode(x, block, 128);
|
||||
|
||||
for(i = 0; i < 8; i++) {
|
||||
E[i] = state[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F1(E[M3[i]],E[M4[i]],E[M1[i]],E[M0[i]],E[M5[i]],E[M2[i]],E[M6[i]]),7) + ROTR(E[M7[i]],11) + x[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F2(E[M6[i]],E[M2[i]],E[M1[i]],E[M0[i]],E[M3[i]],E[M4[i]],E[M5[i]]),7) + ROTR(E[M7[i]],11) + x[I2[i]] + K2[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F3(E[M2[i]],E[M6[i]],E[M0[i]],E[M4[i]],E[M3[i]],E[M1[i]],E[M5[i]]),7) + ROTR(E[M7[i]],11) + x[I3[i]] + K3[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F4(E[M1[i]],E[M5[i]],E[M3[i]],E[M2[i]],E[M0[i]],E[M4[i]],E[M6[i]]),7) + ROTR(E[M7[i]],11) + x[I4[i]] + K4[i];
|
||||
}
|
||||
for(i = 0; i < 32; i++) {
|
||||
E[7 - (i % 8)] = ROTR(F5(E[M2[i]],E[M5[i]],E[M0[i]],E[M6[i]],E[M4[i]],E[M3[i]],E[M1[i]]),7) + ROTR(E[M7[i]],11) + x[I5[i]] + K5[i];
|
||||
}
|
||||
|
||||
/* Update digest */
|
||||
for(i = 0; i < 8; i++) {
|
||||
state[i] += E[i];
|
||||
}
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset((unsigned char*) x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#define PHP_HASH_HAVAL_INIT(p,b) \
|
||||
php_hash_ops php_hash_##p##haval##b##_ops = { \
|
||||
(php_hash_init_func_t) PHP_##p##HAVAL##b##Init, \
|
||||
(php_hash_update_func_t) PHP_HAVALUpdate, \
|
||||
(php_hash_final_func_t) PHP_HAVAL##b##Final, \
|
||||
((b) / 8), 128, sizeof(PHP_HAVAL_CTX) }; \
|
||||
PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *context) \
|
||||
{ int i; context->count[0] = context->count[1] = 0; \
|
||||
for(i = 0; i < 8; i++) context->state[i] = D0[i]; \
|
||||
context->passes = p; context->output = b; \
|
||||
context->Transform = PHP_##p##HAVALTransform; }
|
||||
|
||||
PHP_HASH_HAVAL_INIT(3,128)
|
||||
PHP_HASH_HAVAL_INIT(3,160)
|
||||
PHP_HASH_HAVAL_INIT(3,192)
|
||||
PHP_HASH_HAVAL_INIT(3,224)
|
||||
PHP_HASH_HAVAL_INIT(3,256)
|
||||
|
||||
PHP_HASH_HAVAL_INIT(4,128)
|
||||
PHP_HASH_HAVAL_INIT(4,160)
|
||||
PHP_HASH_HAVAL_INIT(4,192)
|
||||
PHP_HASH_HAVAL_INIT(4,224)
|
||||
PHP_HASH_HAVAL_INIT(4,256)
|
||||
|
||||
PHP_HASH_HAVAL_INIT(5,128)
|
||||
PHP_HASH_HAVAL_INIT(5,160)
|
||||
PHP_HASH_HAVAL_INIT(5,192)
|
||||
PHP_HASH_HAVAL_INIT(5,224)
|
||||
PHP_HASH_HAVAL_INIT(5,256)
|
||||
|
||||
/* {{{ PHP_HAVALUpdate
|
||||
*/
|
||||
PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *context, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 128 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7F);
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
|
||||
context->count[1]++;
|
||||
}
|
||||
context->count[1] += ((php_hash_uint32) inputLen >> 29);
|
||||
|
||||
partLen = 128 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
context->Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 127 < inputLen; i += 128) {
|
||||
context->Transform(context->state, &input[i]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy((unsigned char*) &context->buffer[index], (unsigned char*) &input[i], inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#define PHP_HASH_HAVAL_VERSION 0x01
|
||||
|
||||
/* {{{ PHP_HAVAL128Final
|
||||
*/
|
||||
PHP_HASH_API void PHP_HAVAL128Final(unsigned char *digest, PHP_HAVAL_CTX * context)
|
||||
{
|
||||
unsigned char bits[10];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Version, Passes, and Digest Length */
|
||||
bits[0] = (PHP_HASH_HAVAL_VERSION & 0x07) |
|
||||
((context->passes & 0x07) << 3) |
|
||||
((context->output & 0x03) << 6);
|
||||
bits[1] = (context->output >> 2);
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(bits + 2, context->count, 8);
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
/* Append version, passes, digest length, and message length */
|
||||
PHP_HAVALUpdate(context, bits, 10);
|
||||
|
||||
/* Store state in digest */
|
||||
context->state[3] += (context->state[7] & 0xFF000000) |
|
||||
(context->state[6] & 0x00FF0000) |
|
||||
(context->state[5] & 0x0000FF00) |
|
||||
(context->state[4] & 0x000000FF);
|
||||
|
||||
context->state[2] += (((context->state[7] & 0x00FF0000) |
|
||||
(context->state[6] & 0x0000FF00) |
|
||||
(context->state[5] & 0x000000FF)) << 8) |
|
||||
((context->state[4] & 0xFF000000) >> 24);
|
||||
|
||||
context->state[1] += (((context->state[7] & 0x0000FF00) |
|
||||
(context->state[6] & 0x000000FF)) << 16) |
|
||||
(((context->state[5] & 0xFF000000) |
|
||||
(context->state[4] & 0x00FF0000)) >> 16);
|
||||
|
||||
context->state[0] += ((context->state[7] & 0x000000FF) << 24) |
|
||||
(((context->state[6] & 0xFF000000) |
|
||||
(context->state[5] & 0x00FF0000) |
|
||||
(context->state[4] & 0x0000FF00)) >> 8);
|
||||
|
||||
Encode(digest, context->state, 16);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_HAVAL160Final
|
||||
*/
|
||||
PHP_HASH_API void PHP_HAVAL160Final(unsigned char *digest, PHP_HAVAL_CTX * context)
|
||||
{
|
||||
unsigned char bits[10];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Version, Passes, and Digest Length */
|
||||
bits[0] = (PHP_HASH_HAVAL_VERSION & 0x07) |
|
||||
((context->passes & 0x07) << 3) |
|
||||
((context->output & 0x03) << 6);
|
||||
bits[1] = (context->output >> 2);
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(bits + 2, context->count, 8);
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
/* Append version, passes, digest length, and message length */
|
||||
PHP_HAVALUpdate(context, bits, 10);
|
||||
|
||||
/* Store state in digest */
|
||||
context->state[4] += ((context->state[7] & 0xFE000000) |
|
||||
(context->state[6] & 0x01F80000) |
|
||||
(context->state[5] & 0x0007F000)) >> 12;
|
||||
|
||||
context->state[3] += ((context->state[7] & 0x01F80000) |
|
||||
(context->state[6] & 0x0007F000) |
|
||||
(context->state[5] & 0x00000FC0)) >> 6;
|
||||
|
||||
context->state[2] += (context->state[7] & 0x0007F000) |
|
||||
(context->state[6] & 0x00000FC0) |
|
||||
(context->state[5] & 0x0000003F);
|
||||
|
||||
context->state[1] += ROTR((context->state[7] & 0x00000FC0) |
|
||||
(context->state[6] & 0x0000003F) |
|
||||
(context->state[5] & 0xFE000000), 25);
|
||||
|
||||
context->state[0] += ROTR((context->state[7] & 0x0000003F) |
|
||||
(context->state[6] & 0xFE000000) |
|
||||
(context->state[5] & 0x01F80000), 19);
|
||||
|
||||
Encode(digest, context->state, 20);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_HAVAL192Final
|
||||
*/
|
||||
PHP_HASH_API void PHP_HAVAL192Final(unsigned char *digest, PHP_HAVAL_CTX * context)
|
||||
{
|
||||
unsigned char bits[10];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Version, Passes, and Digest Length */
|
||||
bits[0] = (PHP_HASH_HAVAL_VERSION & 0x07) |
|
||||
((context->passes & 0x07) << 3) |
|
||||
((context->output & 0x03) << 6);
|
||||
bits[1] = (context->output >> 2);
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(bits + 2, context->count, 8);
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
/* Append version, passes, digest length, and message length */
|
||||
PHP_HAVALUpdate(context, bits, 10);
|
||||
|
||||
/* Store state in digest */
|
||||
context->state[5] += ((context->state[7] & 0xFC000000) | (context->state[6] & 0x03E00000)) >> 21;
|
||||
context->state[4] += ((context->state[7] & 0x03E00000) | (context->state[6] & 0x001F0000)) >> 16;
|
||||
context->state[3] += ((context->state[7] & 0x001F0000) | (context->state[6] & 0x0000FC00)) >> 10;
|
||||
context->state[2] += ((context->state[7] & 0x0000FC00) | (context->state[6] & 0x000003E0)) >> 5;
|
||||
context->state[1] += (context->state[7] & 0x000003E0) | (context->state[6] & 0x0000001F);
|
||||
context->state[0] += ROTR((context->state[7] & 0x0000001F) | (context->state[6] & 0xFC000000), 26);
|
||||
Encode(digest, context->state, 24);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_HAVAL224Final
|
||||
*/
|
||||
PHP_HASH_API void PHP_HAVAL224Final(unsigned char *digest, PHP_HAVAL_CTX * context)
|
||||
{
|
||||
unsigned char bits[10];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Version, Passes, and Digest Length */
|
||||
bits[0] = (PHP_HASH_HAVAL_VERSION & 0x07) |
|
||||
((context->passes & 0x07) << 3) |
|
||||
((context->output & 0x03) << 6);
|
||||
bits[1] = (context->output >> 2);
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(bits + 2, context->count, 8);
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
/* Append version, passes, digest length, and message length */
|
||||
PHP_HAVALUpdate(context, bits, 10);
|
||||
|
||||
/* Store state in digest */
|
||||
context->state[6] += context->state[7] & 0x0000000F;
|
||||
context->state[5] += (context->state[7] >> 4) & 0x0000001F;
|
||||
context->state[4] += (context->state[7] >> 9) & 0x0000000F;
|
||||
context->state[3] += (context->state[7] >> 13) & 0x0000001F;
|
||||
context->state[2] += (context->state[7] >> 18) & 0x0000000F;
|
||||
context->state[1] += (context->state[7] >> 22) & 0x0000001F;
|
||||
context->state[0] += (context->state[7] >> 27) & 0x0000001F;
|
||||
Encode(digest, context->state, 28);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_HAVAL256Final
|
||||
*/
|
||||
PHP_HASH_API void PHP_HAVAL256Final(unsigned char *digest, PHP_HAVAL_CTX * context)
|
||||
{
|
||||
unsigned char bits[10];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Version, Passes, and Digest Length */
|
||||
bits[0] = (PHP_HASH_HAVAL_VERSION & 0x07) |
|
||||
((context->passes & 0x07) << 3) |
|
||||
((context->output & 0x03) << 6);
|
||||
bits[1] = (context->output >> 2);
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(bits + 2, context->count, 8);
|
||||
|
||||
/* Pad out to 118 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 118) ? (118 - index) : (246 - index);
|
||||
PHP_HAVALUpdate(context, PADDING, padLen);
|
||||
|
||||
/* Append version, passes, digest length, and message length */
|
||||
PHP_HAVALUpdate(context, bits, 10);
|
||||
|
||||
/* Store state in digest */
|
||||
Encode(digest, context->state, 32);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,589 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Taken from: ext/standard/md5.c |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_md.h"
|
||||
|
||||
php_hash_ops php_hash_md5_ops = {
|
||||
(php_hash_init_func_t) PHP_MD5Init,
|
||||
(php_hash_update_func_t) PHP_MD5Update,
|
||||
(php_hash_final_func_t) PHP_MD5Final,
|
||||
16,
|
||||
64,
|
||||
sizeof(PHP_MD5_CTX)
|
||||
};
|
||||
|
||||
php_hash_ops php_hash_md4_ops = {
|
||||
(php_hash_init_func_t) PHP_MD4Init,
|
||||
(php_hash_update_func_t) PHP_MD4Update,
|
||||
(php_hash_final_func_t) PHP_MD4Final,
|
||||
16,
|
||||
64,
|
||||
sizeof(PHP_MD4_CTX)
|
||||
};
|
||||
|
||||
/* MD common stuff */
|
||||
|
||||
static unsigned char PADDING[64] =
|
||||
{
|
||||
0x80, 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
|
||||
};
|
||||
|
||||
/* {{{ Encode
|
||||
Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void Encode(unsigned char *output, php_hash_uint32 *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||
output[j] = (unsigned char) (input[i] & 0xff);
|
||||
output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
|
||||
output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
|
||||
output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Decode
|
||||
Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void Decode(php_hash_uint32 *output, const unsigned char *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
output[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) |
|
||||
(((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#ifdef PHP_HASH_MD5_NOT_IN_CORE
|
||||
|
||||
/* MD5 */
|
||||
|
||||
PHP_HASH_API void make_digest(char *md5str, unsigned char *digest)
|
||||
{
|
||||
php_hash_bin2hex(md5str, digest, 16);
|
||||
md5str[32] = '\0';
|
||||
}
|
||||
|
||||
/* {{{ proto string md5(string str, [ bool raw_output])
|
||||
Calculate the md5 hash of a string */
|
||||
PHP_NAMED_FUNCTION(php_if_md5)
|
||||
{
|
||||
char *arg;
|
||||
int arg_len;
|
||||
zend_bool raw_output = 0;
|
||||
char md5str[33];
|
||||
PHP_MD5_CTX context;
|
||||
unsigned char digest[16];
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
md5str[0] = '\0';
|
||||
PHP_MD5Init(&context);
|
||||
PHP_MD5Update(&context, arg, arg_len);
|
||||
PHP_MD5Final(digest, &context);
|
||||
if (raw_output) {
|
||||
RETURN_STRINGL(digest, 16, 1);
|
||||
} else {
|
||||
make_digest(md5str, digest);
|
||||
RETVAL_STRING(md5str, 1);
|
||||
}
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string md5_file(string filename [, bool raw_output])
|
||||
Calculate the md5 hash of given filename */
|
||||
PHP_NAMED_FUNCTION(php_if_md5_file)
|
||||
{
|
||||
char *arg;
|
||||
int arg_len;
|
||||
zend_bool raw_output = 0;
|
||||
char md5str[33];
|
||||
unsigned char buf[1024];
|
||||
unsigned char digest[16];
|
||||
PHP_MD5_CTX context;
|
||||
int n;
|
||||
php_stream *stream;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL);
|
||||
if (!stream) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
PHP_MD5Init(&context);
|
||||
|
||||
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
|
||||
PHP_MD5Update(&context, buf, n);
|
||||
}
|
||||
|
||||
PHP_MD5Final(digest, &context);
|
||||
|
||||
php_stream_close(stream);
|
||||
|
||||
if (n<0) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (raw_output) {
|
||||
RETURN_STRINGL(digest, 16, 1);
|
||||
} else {
|
||||
make_digest(md5str, digest);
|
||||
RETVAL_STRING(md5str, 1);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* The remaining code is the reference MD5 code (md5c.c) from rfc1321
|
||||
*/
|
||||
/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
*/
|
||||
|
||||
/* Constants for MD5Transform routine.
|
||||
*/
|
||||
|
||||
#define S11 7
|
||||
#define S12 12
|
||||
#define S13 17
|
||||
#define S14 22
|
||||
#define S21 5
|
||||
#define S22 9
|
||||
#define S23 14
|
||||
#define S24 20
|
||||
#define S31 4
|
||||
#define S32 11
|
||||
#define S33 16
|
||||
#define S34 23
|
||||
#define S41 6
|
||||
#define S42 10
|
||||
#define S43 15
|
||||
#define S44 21
|
||||
|
||||
static void MD5Transform(php_hash_uint32[4], const unsigned char[64]);
|
||||
|
||||
/* F, G, H and I are basic MD5 functions.
|
||||
*/
|
||||
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
|
||||
/* ROTATE_LEFT rotates x left n bits.
|
||||
*/
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||
|
||||
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
||||
Rotation is separate from addition to prevent recomputation.
|
||||
*/
|
||||
#define FF(a, b, c, d, x, s, ac) { \
|
||||
(a) += F ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define GG(a, b, c, d, x, s, ac) { \
|
||||
(a) += G ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define HH(a, b, c, d, x, s, ac) { \
|
||||
(a) += H ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define II(a, b, c, d, x, s, ac) { \
|
||||
(a) += I ((b), (c), (d)) + (x) + (php_hash_uint32)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
/* {{{ PHP_MD5Init
|
||||
* MD5 initialization. Begins an MD5 operation, writing a new context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_MD5Init(PHP_MD5_CTX * context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xefcdab89;
|
||||
context->state[2] = 0x98badcfe;
|
||||
context->state[3] = 0x10325476;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MD5Update
|
||||
MD5 block update operation. Continues an MD5 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX * context, const unsigned char *input,
|
||||
unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint32) inputLen << 3))
|
||||
< ((php_hash_uint32) inputLen << 3))
|
||||
context->count[1]++;
|
||||
context->count[1] += ((php_hash_uint32) inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy
|
||||
((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
MD5Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
||||
MD5Transform(context->state, &input[i]);
|
||||
|
||||
index = 0;
|
||||
} else
|
||||
i = 0;
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy
|
||||
((unsigned char*) & context->buffer[index], (unsigned char*) & input[i],
|
||||
inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MD5Final
|
||||
MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_MD5Final(unsigned char digest[16], PHP_MD5_CTX * context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(bits, context->count, 8);
|
||||
|
||||
/* Pad out to 56 mod 64.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
PHP_MD5Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_MD5Update(context, bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
Encode(digest, context->state, 16);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ MD5Transform
|
||||
* MD5 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void MD5Transform(state, block)
|
||||
php_hash_uint32 state[4];
|
||||
const unsigned char block[64];
|
||||
{
|
||||
php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
|
||||
Decode(x, block, 64);
|
||||
|
||||
/* Round 1 */
|
||||
FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
|
||||
FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
|
||||
FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */
|
||||
FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
|
||||
FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
|
||||
FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
|
||||
FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
|
||||
FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
|
||||
FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
|
||||
FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
|
||||
FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
||||
FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
||||
FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
||||
FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
||||
FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
||||
FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
||||
|
||||
/* Round 2 */
|
||||
GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
|
||||
GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
|
||||
GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
||||
GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
|
||||
GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
|
||||
GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
||||
GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
||||
GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
|
||||
GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
|
||||
GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
||||
GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
|
||||
GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
|
||||
GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
||||
GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
|
||||
GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
|
||||
GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
||||
|
||||
/* Round 3 */
|
||||
HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
|
||||
HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
|
||||
HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
||||
HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
||||
HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
|
||||
HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
|
||||
HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
|
||||
HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
||||
HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
||||
HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
|
||||
HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
|
||||
HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
|
||||
HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
|
||||
HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
||||
HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
||||
HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
|
||||
|
||||
/* Round 4 */
|
||||
II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
|
||||
II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
|
||||
II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
||||
II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
|
||||
II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
||||
II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
|
||||
II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
||||
II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
|
||||
II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
|
||||
II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
||||
II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
|
||||
II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
||||
II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
|
||||
II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
||||
II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
|
||||
II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
|
||||
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset((unsigned char*) x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#endif /* PHP_HASH_MD5_NOT_IN_CORE */
|
||||
|
||||
/* MD4 */
|
||||
|
||||
#define MD4_F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
||||
#define MD4_G(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
||||
#define MD4_H(x,y,z) ((x) ^ (y) ^ (z))
|
||||
|
||||
#define ROTL32(s,v) (((v) << (s)) | ((v) >> (32 - (s))))
|
||||
|
||||
#define MD4_R1(a,b,c,d,k,s) a = ROTL32(s, a + MD4_F(b,c,d) + x[k])
|
||||
#define MD4_R2(a,b,c,d,k,s) a = ROTL32(s, a + MD4_G(b,c,d) + x[k] + 0x5A827999)
|
||||
#define MD4_R3(a,b,c,d,k,s) a = ROTL32(s, a + MD4_H(b,c,d) + x[k] + 0x6ED9EBA1)
|
||||
|
||||
static void MD4Transform(php_hash_uint32 state[4], const unsigned char block[64])
|
||||
{
|
||||
php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||
|
||||
Decode(x, block, 64);
|
||||
|
||||
/* Round 1 */
|
||||
MD4_R1(a,b,c,d, 0, 3);
|
||||
MD4_R1(d,a,b,c, 1, 7);
|
||||
MD4_R1(c,d,a,b, 2,11);
|
||||
MD4_R1(b,c,d,a, 3,19);
|
||||
MD4_R1(a,b,c,d, 4, 3);
|
||||
MD4_R1(d,a,b,c, 5, 7);
|
||||
MD4_R1(c,d,a,b, 6,11);
|
||||
MD4_R1(b,c,d,a, 7,19);
|
||||
MD4_R1(a,b,c,d, 8, 3);
|
||||
MD4_R1(d,a,b,c, 9, 7);
|
||||
MD4_R1(c,d,a,b,10,11);
|
||||
MD4_R1(b,c,d,a,11,19);
|
||||
MD4_R1(a,b,c,d,12, 3);
|
||||
MD4_R1(d,a,b,c,13, 7);
|
||||
MD4_R1(c,d,a,b,14,11);
|
||||
MD4_R1(b,c,d,a,15,19);
|
||||
|
||||
/* Round 2 */
|
||||
MD4_R2(a,b,c,d, 0, 3);
|
||||
MD4_R2(d,a,b,c, 4, 5);
|
||||
MD4_R2(c,d,a,b, 8, 9);
|
||||
MD4_R2(b,c,d,a,12,13);
|
||||
MD4_R2(a,b,c,d, 1, 3);
|
||||
MD4_R2(d,a,b,c, 5, 5);
|
||||
MD4_R2(c,d,a,b, 9, 9);
|
||||
MD4_R2(b,c,d,a,13,13);
|
||||
MD4_R2(a,b,c,d, 2, 3);
|
||||
MD4_R2(d,a,b,c, 6, 5);
|
||||
MD4_R2(c,d,a,b,10, 9);
|
||||
MD4_R2(b,c,d,a,14,13);
|
||||
MD4_R2(a,b,c,d, 3, 3);
|
||||
MD4_R2(d,a,b,c, 7, 5);
|
||||
MD4_R2(c,d,a,b,11, 9);
|
||||
MD4_R2(b,c,d,a,15,13);
|
||||
|
||||
/* Round 3 */
|
||||
MD4_R3(a,b,c,d, 0, 3);
|
||||
MD4_R3(d,a,b,c, 8, 9);
|
||||
MD4_R3(c,d,a,b, 4,11);
|
||||
MD4_R3(b,c,d,a,12,15);
|
||||
MD4_R3(a,b,c,d, 2, 3);
|
||||
MD4_R3(d,a,b,c,10, 9);
|
||||
MD4_R3(c,d,a,b, 6,11);
|
||||
MD4_R3(b,c,d,a,14,15);
|
||||
MD4_R3(a,b,c,d, 1, 3);
|
||||
MD4_R3(d,a,b,c, 9, 9);
|
||||
MD4_R3(c,d,a,b, 5,11);
|
||||
MD4_R3(b,c,d,a,13,15);
|
||||
MD4_R3(a,b,c,d, 3, 3);
|
||||
MD4_R3(d,a,b,c,11, 9);
|
||||
MD4_R3(c,d,a,b, 7,11);
|
||||
MD4_R3(b,c,d,a,15,15);
|
||||
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
}
|
||||
|
||||
/* {{{ PHP_MD4Update
|
||||
MD4 block update operation. Continues an MD5 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX * context, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint32) inputLen << 3))
|
||||
< ((php_hash_uint32) inputLen << 3))
|
||||
context->count[1]++;
|
||||
context->count[1] += ((php_hash_uint32) inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
MD4Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64) {
|
||||
MD4Transform(context->state, &input[i]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MD4Final
|
||||
MD4 finalization. Ends an MD4 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_MD4Final(unsigned char digest[16], PHP_MD4_CTX * context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
Encode(bits, context->count, 8);
|
||||
|
||||
/* Pad out to 56 mod 64.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
PHP_MD4Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_MD4Update(context, bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
Encode(digest, context->state, 16);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,433 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Heavily borrowed from md5.c & sha1.c of PHP archival fame
|
||||
Note that ripemd laughs in the face of logic and uses
|
||||
little endian byte ordering */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_ripemd.h"
|
||||
|
||||
php_hash_ops php_hash_ripemd128_ops = {
|
||||
(php_hash_init_func_t) PHP_RIPEMD128Init,
|
||||
(php_hash_update_func_t) PHP_RIPEMD128Update,
|
||||
(php_hash_final_func_t) PHP_RIPEMD128Final,
|
||||
16,
|
||||
64,
|
||||
sizeof(PHP_RIPEMD128_CTX)
|
||||
};
|
||||
|
||||
php_hash_ops php_hash_ripemd160_ops = {
|
||||
(php_hash_init_func_t) PHP_RIPEMD160Init,
|
||||
(php_hash_update_func_t) PHP_RIPEMD160Update,
|
||||
(php_hash_final_func_t) PHP_RIPEMD160Final,
|
||||
20,
|
||||
64,
|
||||
sizeof(PHP_RIPEMD160_CTX)
|
||||
};
|
||||
|
||||
/* {{{ PHP_RIPEMD128Init
|
||||
* ripemd128 initialization. Begins a ripemd128 operation, writing a new context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_RIPEMD128Init(PHP_RIPEMD128_CTX * context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xEFCDAB89;
|
||||
context->state[2] = 0x98BADCFE;
|
||||
context->state[3] = 0x10325476;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_RIPEMD160Init
|
||||
* ripemd128 initialization. Begins a ripemd128 operation, writing a new context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX * context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xEFCDAB89;
|
||||
context->state[2] = 0x98BADCFE;
|
||||
context->state[3] = 0x10325476;
|
||||
context->state[4] = 0xC3D2E1F0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Basic ripemd function */
|
||||
#define F0(x,y,z) ((x) ^ (y) ^ (z))
|
||||
#define F1(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
||||
#define F2(x,y,z) (((x) | (~(y))) ^ (z))
|
||||
#define F3(x,y,z) (((x) & (z)) | ((y) & (~(z))))
|
||||
#define F4(x,y,z) ((x) ^ ((y) | (~(z))))
|
||||
|
||||
static php_hash_uint32 K_values[5] = { 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E };
|
||||
static php_hash_uint32 KK_values[4] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x00000000 };
|
||||
static php_hash_uint32 KK160_values[5] = { 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000 };
|
||||
|
||||
#define K(n) K_values[ (n) >> 4]
|
||||
#define KK(n) KK_values[(n) >> 4]
|
||||
#define KK160(n) KK160_values[(n) >> 4]
|
||||
|
||||
static unsigned char R[80] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
||||
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
|
||||
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
|
||||
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 };
|
||||
|
||||
static unsigned char RR[80] = {
|
||||
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
|
||||
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
|
||||
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
|
||||
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
|
||||
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 };
|
||||
|
||||
static unsigned char S[80] = {
|
||||
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
|
||||
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
|
||||
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
|
||||
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
|
||||
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 };
|
||||
|
||||
static unsigned char SS[80] = {
|
||||
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
|
||||
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
|
||||
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
|
||||
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
|
||||
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 };
|
||||
|
||||
#define ROLS(j, x) (((x) << S[j]) | ((x) >> (32 - S[j])))
|
||||
#define ROLSS(j, x) (((x) << SS[j]) | ((x) >> (32 - SS[j])))
|
||||
#define ROL(n, x) (((x) << n) | ((x) >> (32 - n)))
|
||||
|
||||
/* {{{ RIPEMDDecode
|
||||
Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void RIPEMDDecode(php_hash_uint32 *output, const unsigned char *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
output[i] = ((php_hash_uint32) input[j + 0]) | (((php_hash_uint32) input[j + 1]) << 8) |
|
||||
(((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ RIPEMD128Transform
|
||||
* ripemd128 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void RIPEMD128Transform(php_hash_uint32 state[4], const unsigned char block[64])
|
||||
{
|
||||
php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3];
|
||||
php_hash_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3];
|
||||
php_hash_uint32 tmp, x[16];
|
||||
int j;
|
||||
|
||||
RIPEMDDecode(x, block, 64);
|
||||
|
||||
for(j = 0; j < 16; j++) {
|
||||
tmp = ROLS( j, a + F0(b, c, d) + x[R[j]] + K(j));
|
||||
a = d; d = c; c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F3(bb, cc, dd) + x[RR[j]] + KK(j));
|
||||
aa = dd; dd = cc; cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
for(j = 16; j < 32; j++) {
|
||||
tmp = ROLS( j, a + F1(b, c, d) + x[R[j]] + K(j));
|
||||
a = d; d = c; c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F2(bb, cc, dd) + x[RR[j]] + KK(j));
|
||||
aa = dd; dd = cc; cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
for(j = 32; j < 48; j++) {
|
||||
tmp = ROLS( j, a + F2(b, c, d) + x[R[j]] + K(j));
|
||||
a = d; d = c; c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F1(bb, cc, dd) + x[RR[j]] + KK(j));
|
||||
aa = dd; dd = cc; cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
for(j = 48; j < 64; j++) {
|
||||
tmp = ROLS( j, a + F3(b, c, d) + x[R[j]] + K(j));
|
||||
a = d; d = c; c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F0(bb, cc, dd) + x[RR[j]] + KK(j));
|
||||
aa = dd; dd = cc; cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
tmp = state[1] + c + dd;
|
||||
state[1] = state[2] + d + aa;
|
||||
state[2] = state[3] + a + bb;
|
||||
state[3] = state[0] + b + cc;
|
||||
state[0] = tmp;
|
||||
|
||||
tmp = 0;
|
||||
memset(x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_RIPEMD128Update
|
||||
ripemd128 block update operation. Continues a ripemd128 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX * context, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
|
||||
context->count[1]++;
|
||||
}
|
||||
context->count[1] += ((php_hash_uint32) inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
RIPEMD128Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64) {
|
||||
RIPEMD128Transform(context->state, &input[i]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ RIPEMD160Transform
|
||||
* ripemd160 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void RIPEMD160Transform(php_hash_uint32 state[5], const unsigned char block[64])
|
||||
{
|
||||
php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3], e = state[4];
|
||||
php_hash_uint32 aa = state[0], bb = state[1], cc = state[2], dd = state[3], ee = state[4];
|
||||
php_hash_uint32 tmp, x[16];
|
||||
int j;
|
||||
|
||||
RIPEMDDecode(x, block, 64);
|
||||
|
||||
for(j = 0; j < 16; j++) {
|
||||
tmp = ROLS( j, a + F0(b, c, d) + x[R[j]] + K(j)) + e;
|
||||
a = e; e = d; d = ROL(10, c); c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F4(bb, cc, dd) + x[RR[j]] + KK160(j)) + ee;
|
||||
aa = ee; ee = dd; dd = ROL(10, cc); cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
for(j = 16; j < 32; j++) {
|
||||
tmp = ROLS( j, a + F1(b, c, d) + x[R[j]] + K(j)) + e;
|
||||
a = e; e = d; d = ROL(10, c); c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F3(bb, cc, dd) + x[RR[j]] + KK160(j)) + ee;
|
||||
aa = ee; ee = dd; dd = ROL(10, cc); cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
for(j = 32; j < 48; j++) {
|
||||
tmp = ROLS( j, a + F2(b, c, d) + x[R[j]] + K(j)) + e;
|
||||
a = e; e = d; d = ROL(10, c); c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F2(bb, cc, dd) + x[RR[j]] + KK160(j)) + ee;
|
||||
aa = ee; ee = dd; dd = ROL(10, cc); cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
for(j = 48; j < 64; j++) {
|
||||
tmp = ROLS( j, a + F3(b, c, d) + x[R[j]] + K(j)) + e;
|
||||
a = e; e = d; d = ROL(10, c); c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F1(bb, cc, dd) + x[RR[j]] + KK160(j)) + ee;
|
||||
aa = ee; ee = dd; dd = ROL(10, cc); cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
for(j = 64; j < 80; j++) {
|
||||
tmp = ROLS( j, a + F4(b, c, d) + x[R[j]] + K(j)) + e;
|
||||
a = e; e = d; d = ROL(10, c); c = b; b = tmp;
|
||||
tmp = ROLSS(j, aa + F0(bb, cc, dd) + x[RR[j]] + KK160(j)) + ee;
|
||||
aa = ee; ee = dd; dd = ROL(10, cc); cc = bb; bb = tmp;
|
||||
}
|
||||
|
||||
tmp = state[1] + c + dd;
|
||||
state[1] = state[2] + d + ee;
|
||||
state[2] = state[3] + e + aa;
|
||||
state[3] = state[4] + a + bb;
|
||||
state[4] = state[0] + b + cc;
|
||||
state[0] = tmp;
|
||||
|
||||
tmp = 0;
|
||||
memset(x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_RIPEMD160Update
|
||||
ripemd160 block update operation. Continues a ripemd128 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX * context, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
|
||||
context->count[1]++;
|
||||
}
|
||||
context->count[1] += ((php_hash_uint32) inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
RIPEMD160Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64) {
|
||||
RIPEMD160Transform(context->state, &input[i]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static unsigned char PADDING[64] =
|
||||
{
|
||||
0x80, 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
|
||||
};
|
||||
|
||||
/* {{{ RIPEMDEncode
|
||||
Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void RIPEMDEncode(unsigned char *output, php_hash_uint32 *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||
output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff);
|
||||
output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff);
|
||||
output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff);
|
||||
output[j + 0] = (unsigned char) (input[i] & 0xff);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_RIPEMD128Final
|
||||
ripemd128 finalization. Ends a ripemd128 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_RIPEMD128Final(unsigned char digest[16], PHP_RIPEMD128_CTX * context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
bits[0] = (unsigned char) (context->count[0] & 0xFF);
|
||||
bits[1] = (unsigned char) ((context->count[0] >> 8) & 0xFF);
|
||||
bits[2] = (unsigned char) ((context->count[0] >> 16) & 0xFF);
|
||||
bits[3] = (unsigned char) ((context->count[0] >> 24) & 0xFF);
|
||||
bits[4] = (unsigned char) (context->count[1] & 0xFF);
|
||||
bits[5] = (unsigned char) ((context->count[1] >> 8) & 0xFF);
|
||||
bits[6] = (unsigned char) ((context->count[1] >> 16) & 0xFF);
|
||||
bits[7] = (unsigned char) ((context->count[1] >> 24) & 0xFF);
|
||||
|
||||
/* Pad out to 56 mod 64.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
PHP_RIPEMD128Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_RIPEMD128Update(context, bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
RIPEMDEncode(digest, context->state, 16);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_RIPEMD160Final
|
||||
ripemd160 finalization. Ends a ripemd160 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_RIPEMD160Final(unsigned char digest[20], PHP_RIPEMD160_CTX * context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
bits[0] = (unsigned char) (context->count[0] & 0xFF);
|
||||
bits[1] = (unsigned char) ((context->count[0] >> 8) & 0xFF);
|
||||
bits[2] = (unsigned char) ((context->count[0] >> 16) & 0xFF);
|
||||
bits[3] = (unsigned char) ((context->count[0] >> 24) & 0xFF);
|
||||
bits[4] = (unsigned char) (context->count[1] & 0xFF);
|
||||
bits[5] = (unsigned char) ((context->count[1] >> 8) & 0xFF);
|
||||
bits[6] = (unsigned char) ((context->count[1] >> 16) & 0xFF);
|
||||
bits[7] = (unsigned char) ((context->count[1] >> 24) & 0xFF);
|
||||
|
||||
/* Pad out to 56 mod 64.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
PHP_RIPEMD160Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_RIPEMD160Update(context, bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
RIPEMDEncode(digest, context->state, 20);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,934 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Steffan Esser <sesser@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_sha.h"
|
||||
|
||||
static unsigned char PADDING[128] =
|
||||
{
|
||||
0x80, 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,
|
||||
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, 0
|
||||
};
|
||||
|
||||
/* {{{ SHAEncode32
|
||||
Encodes input (php_hash_uint32) into output (unsigned char). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void SHAEncode32(unsigned char *output, php_hash_uint32 *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4) {
|
||||
output[j] = (unsigned char) ((input[i] >> 24) & 0xff);
|
||||
output[j + 1] = (unsigned char) ((input[i] >> 16) & 0xff);
|
||||
output[j + 2] = (unsigned char) ((input[i] >> 8) & 0xff);
|
||||
output[j + 3] = (unsigned char) (input[i] & 0xff);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ SHADecode32
|
||||
Decodes input (unsigned char) into output (php_hash_uint32). Assumes len is
|
||||
a multiple of 4.
|
||||
*/
|
||||
static void SHADecode32(php_hash_uint32 *output, const unsigned char *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 4)
|
||||
output[i] = ((php_hash_uint32) input[j + 3]) | (((php_hash_uint32) input[j + 2]) << 8) |
|
||||
(((php_hash_uint32) input[j + 1]) << 16) | (((php_hash_uint32) input[j]) << 24);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
php_hash_ops php_hash_sha1_ops = {
|
||||
(php_hash_init_func_t) PHP_SHA1Init,
|
||||
(php_hash_update_func_t) PHP_SHA1Update,
|
||||
(php_hash_final_func_t) PHP_SHA1Final,
|
||||
20,
|
||||
64,
|
||||
sizeof(PHP_SHA1_CTX)
|
||||
};
|
||||
|
||||
#ifdef PHP_HASH_SHA1_NOT_IN_CORE
|
||||
|
||||
PHP_HASH_API void make_sha1_digest(char *sha1str, unsigned char *digest)
|
||||
{
|
||||
php_hash_bin2hex(sha1str, digest, 20);
|
||||
sha1str[40] = '\0';
|
||||
}
|
||||
|
||||
/* {{{ proto string sha1(string str [, bool raw_output])
|
||||
Calculate the sha1 hash of a string */
|
||||
PHP_FUNCTION(sha1)
|
||||
{
|
||||
char *arg;
|
||||
int arg_len;
|
||||
zend_bool raw_output = 0;
|
||||
char sha1str[41];
|
||||
PHP_SHA1_CTX context;
|
||||
unsigned char digest[20];
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
sha1str[0] = '\0';
|
||||
PHP_SHA1Init(&context);
|
||||
PHP_SHA1Update(&context, arg, arg_len);
|
||||
PHP_SHA1Final(digest, &context);
|
||||
if (raw_output) {
|
||||
RETURN_STRINGL(digest, 20, 1);
|
||||
} else {
|
||||
make_sha1_digest(sha1str, digest);
|
||||
RETVAL_STRING(sha1str, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string sha1_file(string filename [, bool raw_output])
|
||||
Calculate the sha1 hash of given filename */
|
||||
PHP_FUNCTION(sha1_file)
|
||||
{
|
||||
char *arg;
|
||||
int arg_len;
|
||||
zend_bool raw_output = 0;
|
||||
char sha1str[41];
|
||||
unsigned char buf[1024];
|
||||
unsigned char digest[20];
|
||||
PHP_SHA1_CTX context;
|
||||
int n;
|
||||
php_stream *stream;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS | ENFORCE_SAFE_MODE, NULL);
|
||||
if (!stream) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
PHP_SHA1Init(&context);
|
||||
|
||||
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
|
||||
PHP_SHA1Update(&context, buf, n);
|
||||
}
|
||||
|
||||
PHP_SHA1Final(digest, &context);
|
||||
|
||||
php_stream_close(stream);
|
||||
|
||||
if (n<0) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (raw_output) {
|
||||
RETURN_STRINGL(digest, 20, 1);
|
||||
} else {
|
||||
make_sha1_digest(sha1str, digest);
|
||||
RETVAL_STRING(sha1str, 1);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* F, G, H and I are basic SHA1 functions.
|
||||
*/
|
||||
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
|
||||
#define G(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define H(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
|
||||
#define I(x, y, z) ((x) ^ (y) ^ (z))
|
||||
|
||||
/* ROTATE_LEFT rotates x left n bits.
|
||||
*/
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||
|
||||
/* W[i]
|
||||
*/
|
||||
#define W(i) ( tmp=x[(i-3)&15]^x[(i-8)&15]^x[(i-14)&15]^x[i&15], \
|
||||
(x[i&15]=ROTATE_LEFT(tmp, 1)) )
|
||||
|
||||
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
||||
*/
|
||||
#define FF(a, b, c, d, e, w) { \
|
||||
(e) += F ((b), (c), (d)) + (w) + (php_hash_uint32)(0x5A827999); \
|
||||
(e) += ROTATE_LEFT ((a), 5); \
|
||||
(b) = ROTATE_LEFT((b), 30); \
|
||||
}
|
||||
#define GG(a, b, c, d, e, w) { \
|
||||
(e) += G ((b), (c), (d)) + (w) + (php_hash_uint32)(0x6ED9EBA1); \
|
||||
(e) += ROTATE_LEFT ((a), 5); \
|
||||
(b) = ROTATE_LEFT((b), 30); \
|
||||
}
|
||||
#define HH(a, b, c, d, e, w) { \
|
||||
(e) += H ((b), (c), (d)) + (w) + (php_hash_uint32)(0x8F1BBCDC); \
|
||||
(e) += ROTATE_LEFT ((a), 5); \
|
||||
(b) = ROTATE_LEFT((b), 30); \
|
||||
}
|
||||
#define II(a, b, c, d, e, w) { \
|
||||
(e) += I ((b), (c), (d)) + (w) + (php_hash_uint32)(0xCA62C1D6); \
|
||||
(e) += ROTATE_LEFT ((a), 5); \
|
||||
(b) = ROTATE_LEFT((b), 30); \
|
||||
}
|
||||
|
||||
|
||||
/* {{{ PHP_SHA1Init
|
||||
* SHA1 initialization. Begins an SHA1 operation, writing a new context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA1Init(PHP_SHA1_CTX * context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
context->state[0] = 0x67452301;
|
||||
context->state[1] = 0xefcdab89;
|
||||
context->state[2] = 0x98badcfe;
|
||||
context->state[3] = 0x10325476;
|
||||
context->state[4] = 0xc3d2e1f0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ SHA1Transform
|
||||
* SHA1 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void SHA1Transform(php_hash_uint32 state[5], const unsigned char block[64])
|
||||
{
|
||||
php_hash_uint32 a = state[0], b = state[1], c = state[2];
|
||||
php_hash_uint32 d = state[3], e = state[4], x[16], tmp;
|
||||
|
||||
SHADecode32(x, block, 64);
|
||||
|
||||
/* Round 1 */
|
||||
FF(a, b, c, d, e, x[0]); /* 1 */
|
||||
FF(e, a, b, c, d, x[1]); /* 2 */
|
||||
FF(d, e, a, b, c, x[2]); /* 3 */
|
||||
FF(c, d, e, a, b, x[3]); /* 4 */
|
||||
FF(b, c, d, e, a, x[4]); /* 5 */
|
||||
FF(a, b, c, d, e, x[5]); /* 6 */
|
||||
FF(e, a, b, c, d, x[6]); /* 7 */
|
||||
FF(d, e, a, b, c, x[7]); /* 8 */
|
||||
FF(c, d, e, a, b, x[8]); /* 9 */
|
||||
FF(b, c, d, e, a, x[9]); /* 10 */
|
||||
FF(a, b, c, d, e, x[10]); /* 11 */
|
||||
FF(e, a, b, c, d, x[11]); /* 12 */
|
||||
FF(d, e, a, b, c, x[12]); /* 13 */
|
||||
FF(c, d, e, a, b, x[13]); /* 14 */
|
||||
FF(b, c, d, e, a, x[14]); /* 15 */
|
||||
FF(a, b, c, d, e, x[15]); /* 16 */
|
||||
FF(e, a, b, c, d, W(16)); /* 17 */
|
||||
FF(d, e, a, b, c, W(17)); /* 18 */
|
||||
FF(c, d, e, a, b, W(18)); /* 19 */
|
||||
FF(b, c, d, e, a, W(19)); /* 20 */
|
||||
|
||||
/* Round 2 */
|
||||
GG(a, b, c, d, e, W(20)); /* 21 */
|
||||
GG(e, a, b, c, d, W(21)); /* 22 */
|
||||
GG(d, e, a, b, c, W(22)); /* 23 */
|
||||
GG(c, d, e, a, b, W(23)); /* 24 */
|
||||
GG(b, c, d, e, a, W(24)); /* 25 */
|
||||
GG(a, b, c, d, e, W(25)); /* 26 */
|
||||
GG(e, a, b, c, d, W(26)); /* 27 */
|
||||
GG(d, e, a, b, c, W(27)); /* 28 */
|
||||
GG(c, d, e, a, b, W(28)); /* 29 */
|
||||
GG(b, c, d, e, a, W(29)); /* 30 */
|
||||
GG(a, b, c, d, e, W(30)); /* 31 */
|
||||
GG(e, a, b, c, d, W(31)); /* 32 */
|
||||
GG(d, e, a, b, c, W(32)); /* 33 */
|
||||
GG(c, d, e, a, b, W(33)); /* 34 */
|
||||
GG(b, c, d, e, a, W(34)); /* 35 */
|
||||
GG(a, b, c, d, e, W(35)); /* 36 */
|
||||
GG(e, a, b, c, d, W(36)); /* 37 */
|
||||
GG(d, e, a, b, c, W(37)); /* 38 */
|
||||
GG(c, d, e, a, b, W(38)); /* 39 */
|
||||
GG(b, c, d, e, a, W(39)); /* 40 */
|
||||
|
||||
/* Round 3 */
|
||||
HH(a, b, c, d, e, W(40)); /* 41 */
|
||||
HH(e, a, b, c, d, W(41)); /* 42 */
|
||||
HH(d, e, a, b, c, W(42)); /* 43 */
|
||||
HH(c, d, e, a, b, W(43)); /* 44 */
|
||||
HH(b, c, d, e, a, W(44)); /* 45 */
|
||||
HH(a, b, c, d, e, W(45)); /* 46 */
|
||||
HH(e, a, b, c, d, W(46)); /* 47 */
|
||||
HH(d, e, a, b, c, W(47)); /* 48 */
|
||||
HH(c, d, e, a, b, W(48)); /* 49 */
|
||||
HH(b, c, d, e, a, W(49)); /* 50 */
|
||||
HH(a, b, c, d, e, W(50)); /* 51 */
|
||||
HH(e, a, b, c, d, W(51)); /* 52 */
|
||||
HH(d, e, a, b, c, W(52)); /* 53 */
|
||||
HH(c, d, e, a, b, W(53)); /* 54 */
|
||||
HH(b, c, d, e, a, W(54)); /* 55 */
|
||||
HH(a, b, c, d, e, W(55)); /* 56 */
|
||||
HH(e, a, b, c, d, W(56)); /* 57 */
|
||||
HH(d, e, a, b, c, W(57)); /* 58 */
|
||||
HH(c, d, e, a, b, W(58)); /* 59 */
|
||||
HH(b, c, d, e, a, W(59)); /* 60 */
|
||||
|
||||
/* Round 4 */
|
||||
II(a, b, c, d, e, W(60)); /* 61 */
|
||||
II(e, a, b, c, d, W(61)); /* 62 */
|
||||
II(d, e, a, b, c, W(62)); /* 63 */
|
||||
II(c, d, e, a, b, W(63)); /* 64 */
|
||||
II(b, c, d, e, a, W(64)); /* 65 */
|
||||
II(a, b, c, d, e, W(65)); /* 66 */
|
||||
II(e, a, b, c, d, W(66)); /* 67 */
|
||||
II(d, e, a, b, c, W(67)); /* 68 */
|
||||
II(c, d, e, a, b, W(68)); /* 69 */
|
||||
II(b, c, d, e, a, W(69)); /* 70 */
|
||||
II(a, b, c, d, e, W(70)); /* 71 */
|
||||
II(e, a, b, c, d, W(71)); /* 72 */
|
||||
II(d, e, a, b, c, W(72)); /* 73 */
|
||||
II(c, d, e, a, b, W(73)); /* 74 */
|
||||
II(b, c, d, e, a, W(74)); /* 75 */
|
||||
II(a, b, c, d, e, W(75)); /* 76 */
|
||||
II(e, a, b, c, d, W(76)); /* 77 */
|
||||
II(d, e, a, b, c, W(77)); /* 78 */
|
||||
II(c, d, e, a, b, W(78)); /* 79 */
|
||||
II(b, c, d, e, a, W(79)); /* 80 */
|
||||
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset((unsigned char*) x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA1Update
|
||||
SHA1 block update operation. Continues an SHA1 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX * context, const unsigned char *input,
|
||||
unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint32) inputLen << 3))
|
||||
< ((php_hash_uint32) inputLen << 3))
|
||||
context->count[1]++;
|
||||
context->count[1] += ((php_hash_uint32) inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy
|
||||
((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
SHA1Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
||||
SHA1Transform(context->state, &input[i]);
|
||||
|
||||
index = 0;
|
||||
} else
|
||||
i = 0;
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy
|
||||
((unsigned char*) & context->buffer[index], (unsigned char*) & input[i],
|
||||
inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA1Final
|
||||
SHA1 finalization. Ends an SHA1 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA1Final(unsigned char digest[20], PHP_SHA1_CTX * context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
bits[7] = context->count[0] & 0xFF;
|
||||
bits[6] = (context->count[0] >> 8) & 0xFF;
|
||||
bits[5] = (context->count[0] >> 16) & 0xFF;
|
||||
bits[4] = (context->count[0] >> 24) & 0xFF;
|
||||
bits[3] = context->count[1] & 0xFF;
|
||||
bits[2] = (context->count[1] >> 8) & 0xFF;
|
||||
bits[1] = (context->count[1] >> 16) & 0xFF;
|
||||
bits[0] = (context->count[1] >> 24) & 0xFF;
|
||||
|
||||
/* Pad out to 56 mod 64.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
PHP_SHA1Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_SHA1Update(context, bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
SHAEncode32(digest, context->state, 20);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#endif /* PHP_HASH_SHA1_NOT_IN_CORE */
|
||||
|
||||
/* sha256 */
|
||||
|
||||
php_hash_ops php_hash_sha256_ops = {
|
||||
(php_hash_init_func_t) PHP_SHA256Init,
|
||||
(php_hash_update_func_t) PHP_SHA256Update,
|
||||
(php_hash_final_func_t) PHP_SHA256Final,
|
||||
32,
|
||||
64,
|
||||
sizeof(PHP_SHA256_CTX)
|
||||
};
|
||||
|
||||
#define ROTR32(b,x) ((x >> b) | (x << (32 - b)))
|
||||
#define ROTR64(b,x) ((x >> b) | (x << (64 - b)))
|
||||
#define SHR(b, x) (x >> b)
|
||||
|
||||
/* Ch */
|
||||
#define SHA256_F0(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
|
||||
/* Maj */
|
||||
#define SHA256_F1(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
||||
/* SUM0 */
|
||||
#define SHA256_F2(x) (ROTR32( 2,(x)) ^ ROTR32(13,(x)) ^ ROTR32(22,(x)))
|
||||
/* SUM1 */
|
||||
#define SHA256_F3(x) (ROTR32( 6,(x)) ^ ROTR32(11,(x)) ^ ROTR32(25,(x)))
|
||||
/* OM0 */
|
||||
#define SHA256_F4(x) (ROTR32( 7,(x)) ^ ROTR32(18,(x)) ^ SHR( 3,(x)))
|
||||
/* OM1 */
|
||||
#define SHA256_F5(x) (ROTR32(17,(x)) ^ ROTR32(19,(x)) ^ SHR(10,(x)))
|
||||
|
||||
static php_hash_uint32 SHA256_K[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 };
|
||||
|
||||
/* {{{ PHP_SHA256Init
|
||||
* SHA256 initialization. Begins an SHA256 operation, writing a new context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX * context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
context->state[0] = 0x6a09e667;
|
||||
context->state[1] = 0xbb67ae85;
|
||||
context->state[2] = 0x3c6ef372;
|
||||
context->state[3] = 0xa54ff53a;
|
||||
context->state[4] = 0x510e527f;
|
||||
context->state[5] = 0x9b05688c;
|
||||
context->state[6] = 0x1f83d9ab;
|
||||
context->state[7] = 0x5be0cd19;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ SHA256Transform
|
||||
* SHA256 basic transformation. Transforms state based on block.
|
||||
*/
|
||||
static void SHA256Transform(php_hash_uint32 state[8], const unsigned char block[64])
|
||||
{
|
||||
php_hash_uint32 a = state[0], b = state[1], c = state[2], d = state[3];
|
||||
php_hash_uint32 e = state[4], f = state[5], g = state[6], h = state[7];
|
||||
php_hash_uint32 x[16], T1, T2, W[64];
|
||||
int i;
|
||||
|
||||
SHADecode32(x, block, 64);
|
||||
|
||||
/* Schedule */
|
||||
for(i = 0; i < 16; i++) {
|
||||
W[i] = x[i];
|
||||
}
|
||||
for(i = 16; i < 64; i++) {
|
||||
W[i] = SHA256_F5(W[i-2]) + W[i-7] + SHA256_F4(W[i-15]) + W[i-16];
|
||||
}
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
T1 = h + SHA256_F3(e) + SHA256_F0(e,f,g) + SHA256_K[i] + W[i];
|
||||
T2 = SHA256_F2(a) + SHA256_F1(a,b,c);
|
||||
h = g; g = f; f = e; e = d + T1;
|
||||
d = c; c = b; b = a; a = T1 + T2;
|
||||
}
|
||||
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
state[5] += f;
|
||||
state[6] += g;
|
||||
state[7] += h;
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset((unsigned char*) x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA256Update
|
||||
SHA256 block update operation. Continues an SHA256 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX * context, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < ((php_hash_uint32) inputLen << 3)) {
|
||||
context->count[1]++;
|
||||
}
|
||||
context->count[1] += ((php_hash_uint32) inputLen >> 29);
|
||||
|
||||
partLen = 64 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
SHA256Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 63 < inputLen; i += 64) {
|
||||
SHA256Transform(context->state, &input[i]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA256Final
|
||||
SHA256 finalization. Ends an SHA256 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA256Final(unsigned char digest[32], PHP_SHA256_CTX * context)
|
||||
{
|
||||
unsigned char bits[8];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
bits[7] = (unsigned char) (context->count[0] & 0xFF);
|
||||
bits[6] = (unsigned char) ((context->count[0] >> 8) & 0xFF);
|
||||
bits[5] = (unsigned char) ((context->count[0] >> 16) & 0xFF);
|
||||
bits[4] = (unsigned char) ((context->count[0] >> 24) & 0xFF);
|
||||
bits[3] = (unsigned char) (context->count[1] & 0xFF);
|
||||
bits[2] = (unsigned char) ((context->count[1] >> 8) & 0xFF);
|
||||
bits[1] = (unsigned char) ((context->count[1] >> 16) & 0xFF);
|
||||
bits[0] = (unsigned char) ((context->count[1] >> 24) & 0xFF);
|
||||
|
||||
/* Pad out to 56 mod 64.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x3f);
|
||||
padLen = (index < 56) ? (56 - index) : (120 - index);
|
||||
PHP_SHA256Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_SHA256Update(context, bits, 8);
|
||||
|
||||
/* Store state in digest */
|
||||
SHAEncode32(digest, context->state, 32);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* sha384/sha512 */
|
||||
|
||||
/* Ch */
|
||||
#define SHA512_F0(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
|
||||
/* Maj */
|
||||
#define SHA512_F1(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
||||
/* SUM0 */
|
||||
#define SHA512_F2(x) (ROTR64(28, x) ^ ROTR64(34, x) ^ ROTR64(39, x))
|
||||
/* SUM1 */
|
||||
#define SHA512_F3(x) (ROTR64(14, x) ^ ROTR64(18, x) ^ ROTR64(41, x))
|
||||
/* OM0 */
|
||||
#define SHA512_F4(x) (ROTR64( 1, x) ^ ROTR64( 8, x) ^ SHR(7, x))
|
||||
/* OM1 */
|
||||
#define SHA512_F5(x) (ROTR64(19, x) ^ ROTR64(61, x) ^ SHR(6, x))
|
||||
|
||||
static php_hash_uint64 SHA512_K[128] = {
|
||||
L64(0x428a2f98d728ae22), L64(0x7137449123ef65cd), L64(0xb5c0fbcfec4d3b2f), L64(0xe9b5dba58189dbbc),
|
||||
L64(0x3956c25bf348b538), L64(0x59f111f1b605d019), L64(0x923f82a4af194f9b), L64(0xab1c5ed5da6d8118),
|
||||
L64(0xd807aa98a3030242), L64(0x12835b0145706fbe), L64(0x243185be4ee4b28c), L64(0x550c7dc3d5ffb4e2),
|
||||
L64(0x72be5d74f27b896f), L64(0x80deb1fe3b1696b1), L64(0x9bdc06a725c71235), L64(0xc19bf174cf692694),
|
||||
L64(0xe49b69c19ef14ad2), L64(0xefbe4786384f25e3), L64(0x0fc19dc68b8cd5b5), L64(0x240ca1cc77ac9c65),
|
||||
L64(0x2de92c6f592b0275), L64(0x4a7484aa6ea6e483), L64(0x5cb0a9dcbd41fbd4), L64(0x76f988da831153b5),
|
||||
L64(0x983e5152ee66dfab), L64(0xa831c66d2db43210), L64(0xb00327c898fb213f), L64(0xbf597fc7beef0ee4),
|
||||
L64(0xc6e00bf33da88fc2), L64(0xd5a79147930aa725), L64(0x06ca6351e003826f), L64(0x142929670a0e6e70),
|
||||
L64(0x27b70a8546d22ffc), L64(0x2e1b21385c26c926), L64(0x4d2c6dfc5ac42aed), L64(0x53380d139d95b3df),
|
||||
L64(0x650a73548baf63de), L64(0x766a0abb3c77b2a8), L64(0x81c2c92e47edaee6), L64(0x92722c851482353b),
|
||||
L64(0xa2bfe8a14cf10364), L64(0xa81a664bbc423001), L64(0xc24b8b70d0f89791), L64(0xc76c51a30654be30),
|
||||
L64(0xd192e819d6ef5218), L64(0xd69906245565a910), L64(0xf40e35855771202a), L64(0x106aa07032bbd1b8),
|
||||
L64(0x19a4c116b8d2d0c8), L64(0x1e376c085141ab53), L64(0x2748774cdf8eeb99), L64(0x34b0bcb5e19b48a8),
|
||||
L64(0x391c0cb3c5c95a63), L64(0x4ed8aa4ae3418acb), L64(0x5b9cca4f7763e373), L64(0x682e6ff3d6b2b8a3),
|
||||
L64(0x748f82ee5defb2fc), L64(0x78a5636f43172f60), L64(0x84c87814a1f0ab72), L64(0x8cc702081a6439ec),
|
||||
L64(0x90befffa23631e28), L64(0xa4506cebde82bde9), L64(0xbef9a3f7b2c67915), L64(0xc67178f2e372532b),
|
||||
L64(0xca273eceea26619c), L64(0xd186b8c721c0c207), L64(0xeada7dd6cde0eb1e), L64(0xf57d4f7fee6ed178),
|
||||
L64(0x06f067aa72176fba), L64(0x0a637dc5a2c898a6), L64(0x113f9804bef90dae), L64(0x1b710b35131c471b),
|
||||
L64(0x28db77f523047d84), L64(0x32caab7b40c72493), L64(0x3c9ebe0a15c9bebc), L64(0x431d67c49c100d4c),
|
||||
L64(0x4cc5d4becb3e42b6), L64(0x597f299cfc657e2a), L64(0x5fcb6fab3ad6faec), L64(0x6c44198c4a475817) };
|
||||
|
||||
/* {{{ SHAEncode64
|
||||
Encodes input (php_hash_uint64) into output (unsigned char). Assumes len is
|
||||
a multiple of 8.
|
||||
*/
|
||||
static void SHAEncode64(unsigned char *output, php_hash_uint64 *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 8) {
|
||||
output[j] = (unsigned char) ((input[i] >> 56) & 0xff);
|
||||
output[j + 1] = (unsigned char) ((input[i] >> 48) & 0xff);
|
||||
output[j + 2] = (unsigned char) ((input[i] >> 40) & 0xff);
|
||||
output[j + 3] = (unsigned char) ((input[i] >> 32) & 0xff);
|
||||
output[j + 4] = (unsigned char) ((input[i] >> 24) & 0xff);
|
||||
output[j + 5] = (unsigned char) ((input[i] >> 16) & 0xff);
|
||||
output[j + 6] = (unsigned char) ((input[i] >> 8) & 0xff);
|
||||
output[j + 7] = (unsigned char) (input[i] & 0xff);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ SHADecode64
|
||||
Decodes input (unsigned char) into output (php_hash_uint64). Assumes len is
|
||||
a multiple of 8.
|
||||
*/
|
||||
static void SHADecode64(php_hash_uint64 *output, const unsigned char *input, unsigned int len)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
for (i = 0, j = 0; j < len; i++, j += 8)
|
||||
output[i] =
|
||||
((php_hash_uint64) input[j + 7]) | (((php_hash_uint64) input[j + 6]) << 8) |
|
||||
(((php_hash_uint64) input[j + 5]) << 16) | (((php_hash_uint64) input[j + 4]) << 24) |
|
||||
(((php_hash_uint64) input[j + 3]) << 32) | (((php_hash_uint64) input[j + 2]) << 40) |
|
||||
(((php_hash_uint64) input[j + 1]) << 48) | (((php_hash_uint64) input[j]) << 56);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA384Init
|
||||
* SHA384 initialization. Begins an SHA384 operation, writing a new context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA384Init(PHP_SHA384_CTX * context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
context->state[0] = L64(0xcbbb9d5dc1059ed8);
|
||||
context->state[1] = L64(0x629a292a367cd507);
|
||||
context->state[2] = L64(0x9159015a3070dd17);
|
||||
context->state[3] = L64(0x152fecd8f70e5939);
|
||||
context->state[4] = L64(0x67332667ffc00b31);
|
||||
context->state[5] = L64(0x8eb44a8768581511);
|
||||
context->state[6] = L64(0xdb0c2e0d64f98fa7);
|
||||
context->state[7] = L64(0x47b5481dbefa4fa4);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ SHA512Transform
|
||||
* SHA512 basic transformation. Transforms state based on block.
|
||||
* SHA384 uses the exact same algorithm
|
||||
*/
|
||||
static void SHA512Transform(php_hash_uint64 state[8], const unsigned char block[128])
|
||||
{
|
||||
php_hash_uint64 a = state[0], b = state[1], c = state[2], d = state[3];
|
||||
php_hash_uint64 e = state[4], f = state[5], g = state[6], h = state[7];
|
||||
php_hash_uint64 x[16], T1, T2, W[80];
|
||||
int i;
|
||||
|
||||
SHADecode64(x, block, 128);
|
||||
|
||||
/* Schedule */
|
||||
for(i = 0; i < 16; i++) {
|
||||
W[i] = x[i];
|
||||
}
|
||||
for(i = 16; i < 80; i++) {
|
||||
W[i] = SHA512_F5(W[i-2]) + W[i-7] + SHA512_F4(W[i-15]) + W[i-16];
|
||||
}
|
||||
|
||||
for (i = 0; i < 80; i++) {
|
||||
T1 = h + SHA512_F3(e) + SHA512_F0(e,f,g) + SHA512_K[i] + W[i];
|
||||
T2 = SHA512_F2(a) + SHA512_F1(a,b,c);
|
||||
h = g; g = f; f = e; e = d + T1;
|
||||
d = c; c = b; b = a; a = T1 + T2;
|
||||
}
|
||||
|
||||
state[0] += a;
|
||||
state[1] += b;
|
||||
state[2] += c;
|
||||
state[3] += d;
|
||||
state[4] += e;
|
||||
state[5] += f;
|
||||
state[6] += g;
|
||||
state[7] += h;
|
||||
|
||||
/* Zeroize sensitive information. */
|
||||
memset((unsigned char*) x, 0, sizeof(x));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA384Update
|
||||
SHA384 block update operation. Continues an SHA384 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX * context, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 128 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint64) inputLen << 3)) < ((php_hash_uint64) inputLen << 3)) {
|
||||
context->count[1]++;
|
||||
}
|
||||
context->count[1] += ((php_hash_uint64) inputLen >> 61);
|
||||
|
||||
partLen = 128 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
SHA512Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 127 < inputLen; i += 128) {
|
||||
SHA512Transform(context->state, &input[i]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA384Final
|
||||
SHA384 finalization. Ends an SHA384 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA384Final(unsigned char digest[48], PHP_SHA384_CTX * context)
|
||||
{
|
||||
unsigned char bits[16];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
bits[15] = (unsigned char) (context->count[0] & 0xFF);
|
||||
bits[14] = (unsigned char) ((context->count[0] >> 8) & 0xFF);
|
||||
bits[13] = (unsigned char) ((context->count[0] >> 16) & 0xFF);
|
||||
bits[12] = (unsigned char) ((context->count[0] >> 24) & 0xFF);
|
||||
bits[11] = (unsigned char) ((context->count[0] >> 32) & 0xFF);
|
||||
bits[10] = (unsigned char) ((context->count[0] >> 40) & 0xFF);
|
||||
bits[9] = (unsigned char) ((context->count[0] >> 48) & 0xFF);
|
||||
bits[8] = (unsigned char) ((context->count[0] >> 56) & 0xFF);
|
||||
bits[7] = (unsigned char) (context->count[1] & 0xFF);
|
||||
bits[6] = (unsigned char) ((context->count[1] >> 8) & 0xFF);
|
||||
bits[5] = (unsigned char) ((context->count[1] >> 16) & 0xFF);
|
||||
bits[4] = (unsigned char) ((context->count[1] >> 24) & 0xFF);
|
||||
bits[3] = (unsigned char) ((context->count[1] >> 32) & 0xFF);
|
||||
bits[2] = (unsigned char) ((context->count[1] >> 40) & 0xFF);
|
||||
bits[1] = (unsigned char) ((context->count[1] >> 48) & 0xFF);
|
||||
bits[0] = (unsigned char) ((context->count[1] >> 56) & 0xFF);
|
||||
|
||||
/* Pad out to 112 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7f);
|
||||
padLen = (index < 112) ? (112 - index) : (240 - index);
|
||||
PHP_SHA384Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_SHA384Update(context, bits, 16);
|
||||
|
||||
/* Store state in digest */
|
||||
SHAEncode64(digest, context->state, 48);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
php_hash_ops php_hash_sha384_ops = {
|
||||
(php_hash_init_func_t) PHP_SHA384Init,
|
||||
(php_hash_update_func_t) PHP_SHA384Update,
|
||||
(php_hash_final_func_t) PHP_SHA384Final,
|
||||
48,
|
||||
128,
|
||||
sizeof(PHP_SHA384_CTX)
|
||||
};
|
||||
|
||||
/* {{{ PHP_SHA512Init
|
||||
* SHA512 initialization. Begins an SHA512 operation, writing a new context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA512Init(PHP_SHA512_CTX * context)
|
||||
{
|
||||
context->count[0] = context->count[1] = 0;
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
context->state[0] = L64(0x6a09e667f3bcc908);
|
||||
context->state[1] = L64(0xbb67ae8584caa73b);
|
||||
context->state[2] = L64(0x3c6ef372fe94f82b);
|
||||
context->state[3] = L64(0xa54ff53a5f1d36f1);
|
||||
context->state[4] = L64(0x510e527fade682d1);
|
||||
context->state[5] = L64(0x9b05688c2b3e6c1f);
|
||||
context->state[6] = L64(0x1f83d9abfb41bd6b);
|
||||
context->state[7] = L64(0x5be0cd19137e2179);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA512Update
|
||||
SHA512 block update operation. Continues an SHA512 message-digest
|
||||
operation, processing another message block, and updating the
|
||||
context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX * context, const unsigned char *input, unsigned int inputLen)
|
||||
{
|
||||
unsigned int i, index, partLen;
|
||||
|
||||
/* Compute number of bytes mod 128 */
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7F);
|
||||
|
||||
/* Update number of bits */
|
||||
if ((context->count[0] += ((php_hash_uint64) inputLen << 3)) < ((php_hash_uint64) inputLen << 3)) {
|
||||
context->count[1]++;
|
||||
}
|
||||
context->count[1] += ((php_hash_uint64) inputLen >> 61);
|
||||
|
||||
partLen = 128 - index;
|
||||
|
||||
/* Transform as many times as possible.
|
||||
*/
|
||||
if (inputLen >= partLen) {
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) input, partLen);
|
||||
SHA512Transform(context->state, context->buffer);
|
||||
|
||||
for (i = partLen; i + 127 < inputLen; i += 128) {
|
||||
SHA512Transform(context->state, &input[i]);
|
||||
}
|
||||
|
||||
index = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
|
||||
/* Buffer remaining input */
|
||||
memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & input[i], inputLen - i);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_SHA512Final
|
||||
SHA512 finalization. Ends an SHA384 message-digest operation, writing the
|
||||
the message digest and zeroizing the context.
|
||||
*/
|
||||
PHP_HASH_API void PHP_SHA512Final(unsigned char digest[48], PHP_SHA512_CTX * context)
|
||||
{
|
||||
unsigned char bits[16];
|
||||
unsigned int index, padLen;
|
||||
|
||||
/* Save number of bits */
|
||||
bits[15] = (unsigned char) (context->count[0] & 0xFF);
|
||||
bits[14] = (unsigned char) ((context->count[0] >> 8) & 0xFF);
|
||||
bits[13] = (unsigned char) ((context->count[0] >> 16) & 0xFF);
|
||||
bits[12] = (unsigned char) ((context->count[0] >> 24) & 0xFF);
|
||||
bits[11] = (unsigned char) ((context->count[0] >> 32) & 0xFF);
|
||||
bits[10] = (unsigned char) ((context->count[0] >> 40) & 0xFF);
|
||||
bits[9] = (unsigned char) ((context->count[0] >> 48) & 0xFF);
|
||||
bits[8] = (unsigned char) ((context->count[0] >> 56) & 0xFF);
|
||||
bits[7] = (unsigned char) (context->count[1] & 0xFF);
|
||||
bits[6] = (unsigned char) ((context->count[1] >> 8) & 0xFF);
|
||||
bits[5] = (unsigned char) ((context->count[1] >> 16) & 0xFF);
|
||||
bits[4] = (unsigned char) ((context->count[1] >> 24) & 0xFF);
|
||||
bits[3] = (unsigned char) ((context->count[1] >> 32) & 0xFF);
|
||||
bits[2] = (unsigned char) ((context->count[1] >> 40) & 0xFF);
|
||||
bits[1] = (unsigned char) ((context->count[1] >> 48) & 0xFF);
|
||||
bits[0] = (unsigned char) ((context->count[1] >> 56) & 0xFF);
|
||||
|
||||
/* Pad out to 112 mod 128.
|
||||
*/
|
||||
index = (unsigned int) ((context->count[0] >> 3) & 0x7f);
|
||||
padLen = (index < 112) ? (112 - index) : (240 - index);
|
||||
PHP_SHA512Update(context, PADDING, padLen);
|
||||
|
||||
/* Append length (before padding) */
|
||||
PHP_SHA512Update(context, bits, 16);
|
||||
|
||||
/* Store state in digest */
|
||||
SHAEncode64(digest, context->state, 64);
|
||||
|
||||
/* Zeroize sensitive information.
|
||||
*/
|
||||
memset((unsigned char*) context, 0, sizeof(*context));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
php_hash_ops php_hash_sha512_ops = {
|
||||
(php_hash_init_func_t) PHP_SHA512Init,
|
||||
(php_hash_update_func_t) PHP_SHA512Update,
|
||||
(php_hash_final_func_t) PHP_SHA512Final,
|
||||
64,
|
||||
128,
|
||||
sizeof(PHP_SHA512_CTX)
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Michael Wallner <mike@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_snefru.h"
|
||||
#include "php_hash_snefru_tables.h"
|
||||
|
||||
#define round(L, C, N, SB) \
|
||||
SBE = SB[C & 0xff]; \
|
||||
L ^= SBE; \
|
||||
N ^= SBE
|
||||
|
||||
#ifndef DBG_SNEFRU
|
||||
#define DBG_SNEFRU 0
|
||||
#endif
|
||||
|
||||
#if DBG_SNEFRU
|
||||
void ph(php_hash_uint32 h[16])
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
printf ("%08lx", h[i]); printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void Snefru(php_hash_uint32 input[16])
|
||||
{
|
||||
static int shifts[4] = {16, 8, 16, 24};
|
||||
int b, index, rshift, lshift;
|
||||
const php_hash_uint32 *t0,*t1;
|
||||
php_hash_uint32 SBE,B00,B01,B02,B03,B04,B05,B06,B07,B08,B09,B10,B11,B12,B13,B14,B15;
|
||||
|
||||
B00 = input[0];
|
||||
B01 = input[1];
|
||||
B02 = input[2];
|
||||
B03 = input[3];
|
||||
B04 = input[4];
|
||||
B05 = input[5];
|
||||
B06 = input[6];
|
||||
B07 = input[7];
|
||||
B08 = input[8];
|
||||
B09 = input[9];
|
||||
B10 = input[10];
|
||||
B11 = input[11];
|
||||
B12 = input[12];
|
||||
B13 = input[13];
|
||||
B14 = input[14];
|
||||
B15 = input[15];
|
||||
|
||||
for (index = 0; index < 8; index++) {
|
||||
t0 = tables[2*index+0];
|
||||
t1 = tables[2*index+1];
|
||||
for (b = 0; b < 4; b++) {
|
||||
round(B15, B00, B01, t0);
|
||||
round(B00, B01, B02, t0);
|
||||
round(B01, B02, B03, t1);
|
||||
round(B02, B03, B04, t1);
|
||||
round(B03, B04, B05, t0);
|
||||
round(B04, B05, B06, t0);
|
||||
round(B05, B06, B07, t1);
|
||||
round(B06, B07, B08, t1);
|
||||
round(B07, B08, B09, t0);
|
||||
round(B08, B09, B10, t0);
|
||||
round(B09, B10, B11, t1);
|
||||
round(B10, B11, B12, t1);
|
||||
round(B11, B12, B13, t0);
|
||||
round(B12, B13, B14, t0);
|
||||
round(B13, B14, B15, t1);
|
||||
round(B14, B15, B00, t1);
|
||||
|
||||
rshift = shifts[b];
|
||||
lshift = 32-rshift;
|
||||
|
||||
B00 = (B00 >> rshift) | (B00 << lshift);
|
||||
B01 = (B01 >> rshift) | (B01 << lshift);
|
||||
B02 = (B02 >> rshift) | (B02 << lshift);
|
||||
B03 = (B03 >> rshift) | (B03 << lshift);
|
||||
B04 = (B04 >> rshift) | (B04 << lshift);
|
||||
B05 = (B05 >> rshift) | (B05 << lshift);
|
||||
B06 = (B06 >> rshift) | (B06 << lshift);
|
||||
B07 = (B07 >> rshift) | (B07 << lshift);
|
||||
B08 = (B08 >> rshift) | (B08 << lshift);
|
||||
B09 = (B09 >> rshift) | (B09 << lshift);
|
||||
B10 = (B10 >> rshift) | (B10 << lshift);
|
||||
B11 = (B11 >> rshift) | (B11 << lshift);
|
||||
B12 = (B12 >> rshift) | (B12 << lshift);
|
||||
B13 = (B13 >> rshift) | (B13 << lshift);
|
||||
B14 = (B14 >> rshift) | (B14 << lshift);
|
||||
B15 = (B15 >> rshift) | (B15 << lshift);
|
||||
}
|
||||
}
|
||||
input[0] ^= B15;
|
||||
input[1] ^= B14;
|
||||
input[2] ^= B13;
|
||||
input[3] ^= B12;
|
||||
input[4] ^= B11;
|
||||
input[5] ^= B10;
|
||||
input[6] ^= B09;
|
||||
input[7] ^= B08;
|
||||
#if DBG_SNEFRU
|
||||
ph(input);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void SnefruTransform(PHP_SNEFRU_CTX *context, const unsigned char input[32])
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0, j = 0; i < 32; i += 4, ++j) {
|
||||
context->state[8+j] = ((input[i] & 0xff) << 24) | ((input[i+1] & 0xff) << 16) |
|
||||
((input[i+2] & 0xff) << 8) | (input[i+3] & 0xff);
|
||||
}
|
||||
Snefru(context->state);
|
||||
memset(&context->state[8], 0, sizeof(php_hash_uint32) * 8);
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
static const php_hash_uint32 MAX32 = 0xffffffffLU;
|
||||
|
||||
PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
if ((MAX32 - context->count[1]) < (len * 8)) {
|
||||
context->count[0]++;
|
||||
context->count[1] = MAX32 - context->count[1];
|
||||
context->count[1] = (len * 8) - context->count[1];
|
||||
} else {
|
||||
context->count[1] += len * 8;
|
||||
}
|
||||
|
||||
if (context->length + len < 32) {
|
||||
memcpy(&context->buffer[context->length], input, len);
|
||||
context->length += len;
|
||||
} else {
|
||||
size_t i = 0, r = (context->length + len) % 32;
|
||||
|
||||
if (context->length) {
|
||||
i = 32 - context->length;
|
||||
memcpy(&context->buffer[context->length], input, i);
|
||||
SnefruTransform(context, context->buffer);
|
||||
}
|
||||
|
||||
for (; i + 32 <= len; i += 32) {
|
||||
SnefruTransform(context, input + i);
|
||||
}
|
||||
|
||||
memcpy(context->buffer, input + i, r);
|
||||
memset(&context->buffer[r], 0, 32 - r);
|
||||
context->length = r;
|
||||
}
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_SNEFRUFinal(unsigned char digest[32], PHP_SNEFRU_CTX *context)
|
||||
{
|
||||
php_hash_uint32 i, j;
|
||||
|
||||
if (context->length) {
|
||||
SnefruTransform(context, context->buffer);
|
||||
}
|
||||
|
||||
context->state[14] = context->count[0];
|
||||
context->state[15] = context->count[1];
|
||||
Snefru(context->state);
|
||||
|
||||
for (i = 0, j = 0; j < 32; i++, j += 4) {
|
||||
digest[j] = (unsigned char) ((context->state[i] >> 24) & 0xff);
|
||||
digest[j + 1] = (unsigned char) ((context->state[i] >> 16) & 0xff);
|
||||
digest[j + 2] = (unsigned char) ((context->state[i] >> 8) & 0xff);
|
||||
digest[j + 3] = (unsigned char) (context->state[i] & 0xff);
|
||||
}
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
php_hash_ops php_hash_snefru_ops = {
|
||||
(php_hash_init_func_t) PHP_SNEFRUInit,
|
||||
(php_hash_update_func_t) PHP_SNEFRUUpdate,
|
||||
(php_hash_final_func_t) PHP_SNEFRUFinal,
|
||||
32,
|
||||
32,
|
||||
sizeof(PHP_SNEFRU_CTX)
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,285 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Michael Wallner <mike@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
#include "php_hash_tiger.h"
|
||||
#include "php_hash_tiger_tables.h"
|
||||
|
||||
/* {{{ */
|
||||
#define save_abc \
|
||||
aa = a; \
|
||||
bb = b; \
|
||||
cc = c;
|
||||
|
||||
#define round(a,b,c,x,mul) \
|
||||
c ^= x; \
|
||||
a -= t1[(unsigned char)(c)] ^ \
|
||||
t2[(unsigned char)(((php_hash_uint32)(c))>>(2*8))] ^ \
|
||||
t3[(unsigned char)((c)>>(4*8))] ^ \
|
||||
t4[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(2*8))] ; \
|
||||
b += t4[(unsigned char)(((php_hash_uint32)(c))>>(1*8))] ^ \
|
||||
t3[(unsigned char)(((php_hash_uint32)(c))>>(3*8))] ^ \
|
||||
t2[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(1*8))] ^ \
|
||||
t1[(unsigned char)(((php_hash_uint32)((c)>>(4*8)))>>(3*8))]; \
|
||||
b *= mul;
|
||||
|
||||
#define pass(a,b,c,mul) \
|
||||
round(a,b,c,x0,mul) \
|
||||
round(b,c,a,x1,mul) \
|
||||
round(c,a,b,x2,mul) \
|
||||
round(a,b,c,x3,mul) \
|
||||
round(b,c,a,x4,mul) \
|
||||
round(c,a,b,x5,mul) \
|
||||
round(a,b,c,x6,mul) \
|
||||
round(b,c,a,x7,mul)
|
||||
|
||||
#define key_schedule \
|
||||
x0 -= x7 ^ L64(0xA5A5A5A5A5A5A5A5); \
|
||||
x1 ^= x0; \
|
||||
x2 += x1; \
|
||||
x3 -= x2 ^ ((~x1)<<19); \
|
||||
x4 ^= x3; \
|
||||
x5 += x4; \
|
||||
x6 -= x5 ^ ((~x4)>>23); \
|
||||
x7 ^= x6; \
|
||||
x0 += x7; \
|
||||
x1 -= x0 ^ ((~x7)<<19); \
|
||||
x2 ^= x1; \
|
||||
x3 += x2; \
|
||||
x4 -= x3 ^ ((~x2)>>23); \
|
||||
x5 ^= x4; \
|
||||
x6 += x5; \
|
||||
x7 -= x6 ^ L64(0x0123456789ABCDEF);
|
||||
|
||||
#define feedforward \
|
||||
a ^= aa; \
|
||||
b -= bb; \
|
||||
c += cc;
|
||||
|
||||
#define compress(passes) \
|
||||
save_abc \
|
||||
pass(a,b,c,5) \
|
||||
key_schedule \
|
||||
pass(c,a,b,7) \
|
||||
key_schedule \
|
||||
pass(b,c,a,9) \
|
||||
for(pass_no=0; pass_no<passes; pass_no++) { \
|
||||
key_schedule \
|
||||
pass(a,b,c,9) \
|
||||
tmpa=a; a=c; c=b; b=tmpa; \
|
||||
} \
|
||||
feedforward
|
||||
|
||||
#define tiger_compress(passes, str, state) \
|
||||
{ \
|
||||
register php_hash_uint64 a, b, c, tmpa, x0, x1, x2, x3, x4, x5, x6, x7; \
|
||||
php_hash_uint64 aa, bb, cc; \
|
||||
int pass_no; \
|
||||
\
|
||||
a = state[0]; \
|
||||
b = state[1]; \
|
||||
c = state[2]; \
|
||||
\
|
||||
x0=str[0]; x1=str[1]; x2=str[2]; x3=str[3]; \
|
||||
x4=str[4]; x5=str[5]; x6=str[6]; x7=str[7]; \
|
||||
\
|
||||
compress(passes); \
|
||||
\
|
||||
state[0] = a; \
|
||||
state[1] = b; \
|
||||
state[2] = c; \
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static inline void TigerFinalize(PHP_TIGER_CTX *context)
|
||||
{
|
||||
context->passed += (php_hash_uint64) context->length << 3;
|
||||
|
||||
context->buffer[context->length++] = 0x1;
|
||||
if (context->length % 8) {
|
||||
memset(&context->buffer[context->length], 0, 8-context->length%8);
|
||||
context->length += 8-context->length%8;
|
||||
}
|
||||
|
||||
if (context->length > 56) {
|
||||
memset(&context->buffer[context->length], 0, 64 - context->length);
|
||||
tiger_compress(context->passes, ((php_hash_uint64 *) context->buffer), context->state);
|
||||
memset(context->buffer, 0, 56);
|
||||
} else {
|
||||
memset(&context->buffer[context->length], 0, 56 - context->length);
|
||||
}
|
||||
|
||||
memcpy(&context->buffer[56], &context->passed, sizeof(php_hash_uint64));
|
||||
tiger_compress(context->passes, ((php_hash_uint64 *) context->buffer), context->state);
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
context->state[0] = L64(0x0123456789ABCDEF);
|
||||
context->state[1] = L64(0xFEDCBA9876543210);
|
||||
context->state[2] = L64(0xF096A5B4C3B2E187);
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_4TIGERInit(PHP_TIGER_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
context->passes = 1;
|
||||
context->state[0] = L64(0x0123456789ABCDEF);
|
||||
context->state[1] = L64(0xFEDCBA9876543210);
|
||||
context->state[2] = L64(0xF096A5B4C3B2E187);
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
if (context->length + len < 64) {
|
||||
memcpy(&context->buffer[context->length], input, len);
|
||||
context->length += len;
|
||||
} else {
|
||||
size_t i = 0, r = (context->length + len) % 64;
|
||||
|
||||
if (context->length) {
|
||||
i = 64 - context->length;
|
||||
memcpy(&context->buffer[context->length], input, i);
|
||||
tiger_compress(context->passes, ((const php_hash_uint64 *) context->buffer), context->state);
|
||||
memset(context->buffer, 0, 64);
|
||||
context->passed += 512;
|
||||
}
|
||||
|
||||
for (; i + 64 <= len; i += 64) {
|
||||
tiger_compress(context->passes, ((const php_hash_uint64 *) (input + i)), context->state);
|
||||
context->passed += 512;
|
||||
}
|
||||
|
||||
memcpy(context->buffer, input + i, r);
|
||||
context->length = r;
|
||||
}
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_TIGER128Final(unsigned char digest[16], PHP_TIGER_CTX *context)
|
||||
{
|
||||
TigerFinalize(context);
|
||||
|
||||
digest[0] = (unsigned char) ((context->state[0] >> 56) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state[0] >> 48) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state[0] >> 40) & 0xff);
|
||||
digest[3] = (unsigned char) ((context->state[0] >> 32) & 0xff);
|
||||
digest[4] = (unsigned char) ((context->state[0] >> 24) & 0xff);
|
||||
digest[5] = (unsigned char) ((context->state[0] >> 16) & 0xff);
|
||||
digest[6] = (unsigned char) ((context->state[0] >> 8) & 0xff);
|
||||
digest[7] = (unsigned char) (context->state[0] & 0xff);
|
||||
digest[8] = (unsigned char) ((context->state[1] >> 56) & 0xff);
|
||||
digest[9] = (unsigned char) ((context->state[1] >> 48) & 0xff);
|
||||
digest[10] = (unsigned char) ((context->state[1] >> 40) & 0xff);
|
||||
digest[11] = (unsigned char) ((context->state[1] >> 32) & 0xff);
|
||||
digest[12] = (unsigned char) ((context->state[1] >> 24) & 0xff);
|
||||
digest[13] = (unsigned char) ((context->state[1] >> 16) & 0xff);
|
||||
digest[14] = (unsigned char) ((context->state[1] >> 8) & 0xff);
|
||||
digest[15] = (unsigned char) (context->state[1] & 0xff);
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_TIGER160Final(unsigned char digest[20], PHP_TIGER_CTX *context)
|
||||
{
|
||||
TigerFinalize(context);
|
||||
|
||||
digest[0] = (unsigned char) ((context->state[0] >> 56) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state[0] >> 48) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state[0] >> 40) & 0xff);
|
||||
digest[3] = (unsigned char) ((context->state[0] >> 32) & 0xff);
|
||||
digest[4] = (unsigned char) ((context->state[0] >> 24) & 0xff);
|
||||
digest[5] = (unsigned char) ((context->state[0] >> 16) & 0xff);
|
||||
digest[6] = (unsigned char) ((context->state[0] >> 8) & 0xff);
|
||||
digest[7] = (unsigned char) (context->state[0] & 0xff);
|
||||
digest[8] = (unsigned char) ((context->state[1] >> 56) & 0xff);
|
||||
digest[9] = (unsigned char) ((context->state[1] >> 48) & 0xff);
|
||||
digest[10] = (unsigned char) ((context->state[1] >> 40) & 0xff);
|
||||
digest[11] = (unsigned char) ((context->state[1] >> 32) & 0xff);
|
||||
digest[12] = (unsigned char) ((context->state[1] >> 24) & 0xff);
|
||||
digest[13] = (unsigned char) ((context->state[1] >> 16) & 0xff);
|
||||
digest[14] = (unsigned char) ((context->state[1] >> 8) & 0xff);
|
||||
digest[15] = (unsigned char) (context->state[1] & 0xff);
|
||||
digest[16] = (unsigned char) ((context->state[2] >> 56) & 0xff);
|
||||
digest[17] = (unsigned char) ((context->state[2] >> 48) & 0xff);
|
||||
digest[18] = (unsigned char) ((context->state[2] >> 40) & 0xff);
|
||||
digest[19] = (unsigned char) ((context->state[2] >> 32) & 0xff);
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_TIGER192Final(unsigned char digest[24], PHP_TIGER_CTX *context)
|
||||
{
|
||||
TigerFinalize(context);
|
||||
|
||||
digest[0] = (unsigned char) ((context->state[0] >> 56) & 0xff);
|
||||
digest[1] = (unsigned char) ((context->state[0] >> 48) & 0xff);
|
||||
digest[2] = (unsigned char) ((context->state[0] >> 40) & 0xff);
|
||||
digest[3] = (unsigned char) ((context->state[0] >> 32) & 0xff);
|
||||
digest[4] = (unsigned char) ((context->state[0] >> 24) & 0xff);
|
||||
digest[5] = (unsigned char) ((context->state[0] >> 16) & 0xff);
|
||||
digest[6] = (unsigned char) ((context->state[0] >> 8) & 0xff);
|
||||
digest[7] = (unsigned char) (context->state[0] & 0xff);
|
||||
digest[8] = (unsigned char) ((context->state[1] >> 56) & 0xff);
|
||||
digest[9] = (unsigned char) ((context->state[1] >> 48) & 0xff);
|
||||
digest[10] = (unsigned char) ((context->state[1] >> 40) & 0xff);
|
||||
digest[11] = (unsigned char) ((context->state[1] >> 32) & 0xff);
|
||||
digest[12] = (unsigned char) ((context->state[1] >> 24) & 0xff);
|
||||
digest[13] = (unsigned char) ((context->state[1] >> 16) & 0xff);
|
||||
digest[14] = (unsigned char) ((context->state[1] >> 8) & 0xff);
|
||||
digest[15] = (unsigned char) (context->state[1] & 0xff);
|
||||
digest[16] = (unsigned char) ((context->state[2] >> 56) & 0xff);
|
||||
digest[17] = (unsigned char) ((context->state[2] >> 48) & 0xff);
|
||||
digest[18] = (unsigned char) ((context->state[2] >> 40) & 0xff);
|
||||
digest[19] = (unsigned char) ((context->state[2] >> 32) & 0xff);
|
||||
digest[20] = (unsigned char) ((context->state[2] >> 24) & 0xff);
|
||||
digest[21] = (unsigned char) ((context->state[2] >> 16) & 0xff);
|
||||
digest[22] = (unsigned char) ((context->state[2] >> 8) & 0xff);
|
||||
digest[23] = (unsigned char) (context->state[2] & 0xff);
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
#define PHP_HASH_TIGER_OPS(p, b) \
|
||||
php_hash_ops php_hash_##p##tiger##b##_ops = { \
|
||||
(php_hash_init_func_t) PHP_##p##TIGERInit, \
|
||||
(php_hash_update_func_t) PHP_TIGERUpdate, \
|
||||
(php_hash_final_func_t) PHP_TIGER##b##Final, \
|
||||
b/8, \
|
||||
64, \
|
||||
sizeof(PHP_TIGER_CTX) \
|
||||
}
|
||||
|
||||
PHP_HASH_TIGER_OPS(3, 128);
|
||||
PHP_HASH_TIGER_OPS(3, 160);
|
||||
PHP_HASH_TIGER_OPS(3, 192);
|
||||
PHP_HASH_TIGER_OPS(4, 128);
|
||||
PHP_HASH_TIGER_OPS(4, 160);
|
||||
PHP_HASH_TIGER_OPS(4, 192);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,452 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Michael Wallner <mike@php.net> |
|
||||
| Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php_hash.h"
|
||||
|
||||
/*
|
||||
* TODO: simplify Update and Final, those look ridiculously complex
|
||||
* Mike, 2005-11-23
|
||||
*/
|
||||
|
||||
#include "php_hash_whirlpool.h"
|
||||
#include "php_hash_whirlpool_tables.h"
|
||||
|
||||
#define DIGESTBYTES 64
|
||||
#define DIGESTBITS (8*DIGESTBYTES) /* 512 */
|
||||
|
||||
#define WBLOCKBYTES 64
|
||||
#define WBLOCKBITS (8*WBLOCKBYTES) /* 512 */
|
||||
|
||||
#define LENGTHBYTES 32
|
||||
#define LENGTHBITS (8*LENGTHBYTES) /* 256 */
|
||||
|
||||
static void WhirlpoolTransform(PHP_WHIRLPOOL_CTX *context)
|
||||
{
|
||||
int i, r;
|
||||
php_hash_uint64 K[8]; /* the round key */
|
||||
php_hash_uint64 block[8]; /* mu(buffer) */
|
||||
php_hash_uint64 state[8]; /* the cipher state */
|
||||
php_hash_uint64 L[8];
|
||||
unsigned char *buffer = context->buffer.data;
|
||||
|
||||
/*
|
||||
* map the buffer to a block:
|
||||
*/
|
||||
for (i = 0; i < 8; i++, buffer += 8) {
|
||||
block[i] =
|
||||
(((php_hash_uint64)buffer[0] ) << 56) ^
|
||||
(((php_hash_uint64)buffer[1] & 0xffL) << 48) ^
|
||||
(((php_hash_uint64)buffer[2] & 0xffL) << 40) ^
|
||||
(((php_hash_uint64)buffer[3] & 0xffL) << 32) ^
|
||||
(((php_hash_uint64)buffer[4] & 0xffL) << 24) ^
|
||||
(((php_hash_uint64)buffer[5] & 0xffL) << 16) ^
|
||||
(((php_hash_uint64)buffer[6] & 0xffL) << 8) ^
|
||||
(((php_hash_uint64)buffer[7] & 0xffL) );
|
||||
}
|
||||
/*
|
||||
* compute and apply K^0 to the cipher state:
|
||||
*/
|
||||
state[0] = block[0] ^ (K[0] = context->state[0]);
|
||||
state[1] = block[1] ^ (K[1] = context->state[1]);
|
||||
state[2] = block[2] ^ (K[2] = context->state[2]);
|
||||
state[3] = block[3] ^ (K[3] = context->state[3]);
|
||||
state[4] = block[4] ^ (K[4] = context->state[4]);
|
||||
state[5] = block[5] ^ (K[5] = context->state[5]);
|
||||
state[6] = block[6] ^ (K[6] = context->state[6]);
|
||||
state[7] = block[7] ^ (K[7] = context->state[7]);
|
||||
/*
|
||||
* iterate over all rounds:
|
||||
*/
|
||||
for (r = 1; r <= R; r++) {
|
||||
/*
|
||||
* compute K^r from K^{r-1}:
|
||||
*/
|
||||
L[0] =
|
||||
C0[(int)(K[0] >> 56) ] ^
|
||||
C1[(int)(K[7] >> 48) & 0xff] ^
|
||||
C2[(int)(K[6] >> 40) & 0xff] ^
|
||||
C3[(int)(K[5] >> 32) & 0xff] ^
|
||||
C4[(int)(K[4] >> 24) & 0xff] ^
|
||||
C5[(int)(K[3] >> 16) & 0xff] ^
|
||||
C6[(int)(K[2] >> 8) & 0xff] ^
|
||||
C7[(int)(K[1] ) & 0xff] ^
|
||||
rc[r];
|
||||
L[1] =
|
||||
C0[(int)(K[1] >> 56) ] ^
|
||||
C1[(int)(K[0] >> 48) & 0xff] ^
|
||||
C2[(int)(K[7] >> 40) & 0xff] ^
|
||||
C3[(int)(K[6] >> 32) & 0xff] ^
|
||||
C4[(int)(K[5] >> 24) & 0xff] ^
|
||||
C5[(int)(K[4] >> 16) & 0xff] ^
|
||||
C6[(int)(K[3] >> 8) & 0xff] ^
|
||||
C7[(int)(K[2] ) & 0xff];
|
||||
L[2] =
|
||||
C0[(int)(K[2] >> 56) ] ^
|
||||
C1[(int)(K[1] >> 48) & 0xff] ^
|
||||
C2[(int)(K[0] >> 40) & 0xff] ^
|
||||
C3[(int)(K[7] >> 32) & 0xff] ^
|
||||
C4[(int)(K[6] >> 24) & 0xff] ^
|
||||
C5[(int)(K[5] >> 16) & 0xff] ^
|
||||
C6[(int)(K[4] >> 8) & 0xff] ^
|
||||
C7[(int)(K[3] ) & 0xff];
|
||||
L[3] =
|
||||
C0[(int)(K[3] >> 56) ] ^
|
||||
C1[(int)(K[2] >> 48) & 0xff] ^
|
||||
C2[(int)(K[1] >> 40) & 0xff] ^
|
||||
C3[(int)(K[0] >> 32) & 0xff] ^
|
||||
C4[(int)(K[7] >> 24) & 0xff] ^
|
||||
C5[(int)(K[6] >> 16) & 0xff] ^
|
||||
C6[(int)(K[5] >> 8) & 0xff] ^
|
||||
C7[(int)(K[4] ) & 0xff];
|
||||
L[4] =
|
||||
C0[(int)(K[4] >> 56) ] ^
|
||||
C1[(int)(K[3] >> 48) & 0xff] ^
|
||||
C2[(int)(K[2] >> 40) & 0xff] ^
|
||||
C3[(int)(K[1] >> 32) & 0xff] ^
|
||||
C4[(int)(K[0] >> 24) & 0xff] ^
|
||||
C5[(int)(K[7] >> 16) & 0xff] ^
|
||||
C6[(int)(K[6] >> 8) & 0xff] ^
|
||||
C7[(int)(K[5] ) & 0xff];
|
||||
L[5] =
|
||||
C0[(int)(K[5] >> 56) ] ^
|
||||
C1[(int)(K[4] >> 48) & 0xff] ^
|
||||
C2[(int)(K[3] >> 40) & 0xff] ^
|
||||
C3[(int)(K[2] >> 32) & 0xff] ^
|
||||
C4[(int)(K[1] >> 24) & 0xff] ^
|
||||
C5[(int)(K[0] >> 16) & 0xff] ^
|
||||
C6[(int)(K[7] >> 8) & 0xff] ^
|
||||
C7[(int)(K[6] ) & 0xff];
|
||||
L[6] =
|
||||
C0[(int)(K[6] >> 56) ] ^
|
||||
C1[(int)(K[5] >> 48) & 0xff] ^
|
||||
C2[(int)(K[4] >> 40) & 0xff] ^
|
||||
C3[(int)(K[3] >> 32) & 0xff] ^
|
||||
C4[(int)(K[2] >> 24) & 0xff] ^
|
||||
C5[(int)(K[1] >> 16) & 0xff] ^
|
||||
C6[(int)(K[0] >> 8) & 0xff] ^
|
||||
C7[(int)(K[7] ) & 0xff];
|
||||
L[7] =
|
||||
C0[(int)(K[7] >> 56) ] ^
|
||||
C1[(int)(K[6] >> 48) & 0xff] ^
|
||||
C2[(int)(K[5] >> 40) & 0xff] ^
|
||||
C3[(int)(K[4] >> 32) & 0xff] ^
|
||||
C4[(int)(K[3] >> 24) & 0xff] ^
|
||||
C5[(int)(K[2] >> 16) & 0xff] ^
|
||||
C6[(int)(K[1] >> 8) & 0xff] ^
|
||||
C7[(int)(K[0] ) & 0xff];
|
||||
K[0] = L[0];
|
||||
K[1] = L[1];
|
||||
K[2] = L[2];
|
||||
K[3] = L[3];
|
||||
K[4] = L[4];
|
||||
K[5] = L[5];
|
||||
K[6] = L[6];
|
||||
K[7] = L[7];
|
||||
/*
|
||||
* apply the r-th round transformation:
|
||||
*/
|
||||
L[0] =
|
||||
C0[(int)(state[0] >> 56) ] ^
|
||||
C1[(int)(state[7] >> 48) & 0xff] ^
|
||||
C2[(int)(state[6] >> 40) & 0xff] ^
|
||||
C3[(int)(state[5] >> 32) & 0xff] ^
|
||||
C4[(int)(state[4] >> 24) & 0xff] ^
|
||||
C5[(int)(state[3] >> 16) & 0xff] ^
|
||||
C6[(int)(state[2] >> 8) & 0xff] ^
|
||||
C7[(int)(state[1] ) & 0xff] ^
|
||||
K[0];
|
||||
L[1] =
|
||||
C0[(int)(state[1] >> 56) ] ^
|
||||
C1[(int)(state[0] >> 48) & 0xff] ^
|
||||
C2[(int)(state[7] >> 40) & 0xff] ^
|
||||
C3[(int)(state[6] >> 32) & 0xff] ^
|
||||
C4[(int)(state[5] >> 24) & 0xff] ^
|
||||
C5[(int)(state[4] >> 16) & 0xff] ^
|
||||
C6[(int)(state[3] >> 8) & 0xff] ^
|
||||
C7[(int)(state[2] ) & 0xff] ^
|
||||
K[1];
|
||||
L[2] =
|
||||
C0[(int)(state[2] >> 56) ] ^
|
||||
C1[(int)(state[1] >> 48) & 0xff] ^
|
||||
C2[(int)(state[0] >> 40) & 0xff] ^
|
||||
C3[(int)(state[7] >> 32) & 0xff] ^
|
||||
C4[(int)(state[6] >> 24) & 0xff] ^
|
||||
C5[(int)(state[5] >> 16) & 0xff] ^
|
||||
C6[(int)(state[4] >> 8) & 0xff] ^
|
||||
C7[(int)(state[3] ) & 0xff] ^
|
||||
K[2];
|
||||
L[3] =
|
||||
C0[(int)(state[3] >> 56) ] ^
|
||||
C1[(int)(state[2] >> 48) & 0xff] ^
|
||||
C2[(int)(state[1] >> 40) & 0xff] ^
|
||||
C3[(int)(state[0] >> 32) & 0xff] ^
|
||||
C4[(int)(state[7] >> 24) & 0xff] ^
|
||||
C5[(int)(state[6] >> 16) & 0xff] ^
|
||||
C6[(int)(state[5] >> 8) & 0xff] ^
|
||||
C7[(int)(state[4] ) & 0xff] ^
|
||||
K[3];
|
||||
L[4] =
|
||||
C0[(int)(state[4] >> 56) ] ^
|
||||
C1[(int)(state[3] >> 48) & 0xff] ^
|
||||
C2[(int)(state[2] >> 40) & 0xff] ^
|
||||
C3[(int)(state[1] >> 32) & 0xff] ^
|
||||
C4[(int)(state[0] >> 24) & 0xff] ^
|
||||
C5[(int)(state[7] >> 16) & 0xff] ^
|
||||
C6[(int)(state[6] >> 8) & 0xff] ^
|
||||
C7[(int)(state[5] ) & 0xff] ^
|
||||
K[4];
|
||||
L[5] =
|
||||
C0[(int)(state[5] >> 56) ] ^
|
||||
C1[(int)(state[4] >> 48) & 0xff] ^
|
||||
C2[(int)(state[3] >> 40) & 0xff] ^
|
||||
C3[(int)(state[2] >> 32) & 0xff] ^
|
||||
C4[(int)(state[1] >> 24) & 0xff] ^
|
||||
C5[(int)(state[0] >> 16) & 0xff] ^
|
||||
C6[(int)(state[7] >> 8) & 0xff] ^
|
||||
C7[(int)(state[6] ) & 0xff] ^
|
||||
K[5];
|
||||
L[6] =
|
||||
C0[(int)(state[6] >> 56) ] ^
|
||||
C1[(int)(state[5] >> 48) & 0xff] ^
|
||||
C2[(int)(state[4] >> 40) & 0xff] ^
|
||||
C3[(int)(state[3] >> 32) & 0xff] ^
|
||||
C4[(int)(state[2] >> 24) & 0xff] ^
|
||||
C5[(int)(state[1] >> 16) & 0xff] ^
|
||||
C6[(int)(state[0] >> 8) & 0xff] ^
|
||||
C7[(int)(state[7] ) & 0xff] ^
|
||||
K[6];
|
||||
L[7] =
|
||||
C0[(int)(state[7] >> 56) ] ^
|
||||
C1[(int)(state[6] >> 48) & 0xff] ^
|
||||
C2[(int)(state[5] >> 40) & 0xff] ^
|
||||
C3[(int)(state[4] >> 32) & 0xff] ^
|
||||
C4[(int)(state[3] >> 24) & 0xff] ^
|
||||
C5[(int)(state[2] >> 16) & 0xff] ^
|
||||
C6[(int)(state[1] >> 8) & 0xff] ^
|
||||
C7[(int)(state[0] ) & 0xff] ^
|
||||
K[7];
|
||||
state[0] = L[0];
|
||||
state[1] = L[1];
|
||||
state[2] = L[2];
|
||||
state[3] = L[3];
|
||||
state[4] = L[4];
|
||||
state[5] = L[5];
|
||||
state[6] = L[6];
|
||||
state[7] = L[7];
|
||||
}
|
||||
/*
|
||||
* apply the Miyaguchi-Preneel compression function:
|
||||
*/
|
||||
context->state[0] ^= state[0] ^ block[0];
|
||||
context->state[1] ^= state[1] ^ block[1];
|
||||
context->state[2] ^= state[2] ^ block[2];
|
||||
context->state[3] ^= state[3] ^ block[3];
|
||||
context->state[4] ^= state[4] ^ block[4];
|
||||
context->state[5] ^= state[5] ^ block[5];
|
||||
context->state[6] ^= state[6] ^ block[6];
|
||||
context->state[7] ^= state[7] ^ block[7];
|
||||
|
||||
memset(state, 0, sizeof(state));
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_WHIRLPOOLInit(PHP_WHIRLPOOL_CTX *context)
|
||||
{
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_WHIRLPOOLUpdate(PHP_WHIRLPOOL_CTX *context, const unsigned char *input, size_t len)
|
||||
{
|
||||
php_hash_uint64 sourceBits = len * 8;
|
||||
int sourcePos = 0; /* index of leftmost source unsigned char containing data (1 to 8 bits). */
|
||||
int sourceGap = (8 - ((int)sourceBits & 7)) & 7; /* space on source[sourcePos]. */
|
||||
int bufferRem = context->buffer.bits & 7; /* occupied bits on buffer[bufferPos]. */
|
||||
const unsigned char *source = input;
|
||||
unsigned char *buffer = context->buffer.data;
|
||||
unsigned char *bitLength = context->bitlength;
|
||||
int bufferBits = context->buffer.bits;
|
||||
int bufferPos = context->buffer.pos;
|
||||
php_hash_uint32 b, carry;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* tally the length of the added data:
|
||||
*/
|
||||
php_hash_uint64 value = sourceBits;
|
||||
for (i = 31, carry = 0; i >= 0 && (carry != 0 || value != L64(0)); i--) {
|
||||
carry += bitLength[i] + ((php_hash_uint32)value & 0xff);
|
||||
bitLength[i] = (unsigned char)carry;
|
||||
carry >>= 8;
|
||||
value >>= 8;
|
||||
}
|
||||
/*
|
||||
* process data in chunks of 8 bits (a more efficient approach would be to take whole-word chunks):
|
||||
*/
|
||||
while (sourceBits > 8) {
|
||||
/* N.B. at least source[sourcePos] and source[sourcePos+1] contain data. */
|
||||
/*
|
||||
* take a byte from the source:
|
||||
*/
|
||||
b = ((source[sourcePos] << sourceGap) & 0xff) |
|
||||
((source[sourcePos + 1] & 0xff) >> (8 - sourceGap));
|
||||
/*
|
||||
* process this byte:
|
||||
*/
|
||||
buffer[bufferPos++] |= (unsigned char)(b >> bufferRem);
|
||||
bufferBits += 8 - bufferRem; /* bufferBits = 8*bufferPos; */
|
||||
if (bufferBits == DIGESTBITS) {
|
||||
/*
|
||||
* process data block:
|
||||
*/
|
||||
WhirlpoolTransform(context);
|
||||
/*
|
||||
* reset buffer:
|
||||
*/
|
||||
bufferBits = bufferPos = 0;
|
||||
}
|
||||
buffer[bufferPos] = (unsigned char) (b << (8 - bufferRem));
|
||||
bufferBits += bufferRem;
|
||||
/*
|
||||
* proceed to remaining data:
|
||||
*/
|
||||
sourceBits -= 8;
|
||||
sourcePos++;
|
||||
}
|
||||
/* now 0 <= sourceBits <= 8;
|
||||
* furthermore, all data (if any is left) is in source[sourcePos].
|
||||
*/
|
||||
if (sourceBits > 0) {
|
||||
b = (source[sourcePos] << sourceGap) & 0xff; /* bits are left-justified on b. */
|
||||
/*
|
||||
* process the remaining bits:
|
||||
*/
|
||||
buffer[bufferPos] |= b >> bufferRem;
|
||||
} else {
|
||||
b = 0;
|
||||
}
|
||||
if (bufferRem + sourceBits < 8) {
|
||||
/*
|
||||
* all remaining data fits on buffer[bufferPos],
|
||||
* and there still remains some space.
|
||||
*/
|
||||
bufferBits += (int) sourceBits;
|
||||
} else {
|
||||
/*
|
||||
* buffer[bufferPos] is full:
|
||||
*/
|
||||
bufferPos++;
|
||||
bufferBits += 8 - bufferRem; /* bufferBits = 8*bufferPos; */
|
||||
sourceBits -= 8 - bufferRem;
|
||||
/* now 0 <= sourceBits < 8;
|
||||
* furthermore, all data (if any is left) is in source[sourcePos].
|
||||
*/
|
||||
if (bufferBits == DIGESTBITS) {
|
||||
/*
|
||||
* process data block:
|
||||
*/
|
||||
WhirlpoolTransform(context);
|
||||
/*
|
||||
* reset buffer:
|
||||
*/
|
||||
bufferBits = bufferPos = 0;
|
||||
}
|
||||
buffer[bufferPos] = (unsigned char) (b << (8 - bufferRem));
|
||||
bufferBits += (int)sourceBits;
|
||||
}
|
||||
context->buffer.bits = bufferBits;
|
||||
context->buffer.pos = bufferPos;
|
||||
}
|
||||
|
||||
PHP_HASH_API void PHP_WHIRLPOOLFinal(unsigned char digest[64], PHP_WHIRLPOOL_CTX *context)
|
||||
{
|
||||
int i;
|
||||
unsigned char *buffer = context->buffer.data;
|
||||
unsigned char *bitLength = context->bitlength;
|
||||
int bufferBits = context->buffer.bits;
|
||||
int bufferPos = context->buffer.pos;
|
||||
|
||||
/*
|
||||
* append a '1'-bit:
|
||||
*/
|
||||
buffer[bufferPos] |= 0x80U >> (bufferBits & 7);
|
||||
bufferPos++; /* all remaining bits on the current unsigned char are set to zero. */
|
||||
/*
|
||||
* pad with zero bits to complete (N*WBLOCKBITS - LENGTHBITS) bits:
|
||||
*/
|
||||
if (bufferPos > WBLOCKBYTES - LENGTHBYTES) {
|
||||
if (bufferPos < WBLOCKBYTES) {
|
||||
memset(&buffer[bufferPos], 0, WBLOCKBYTES - bufferPos);
|
||||
}
|
||||
/*
|
||||
* process data block:
|
||||
*/
|
||||
WhirlpoolTransform(context);
|
||||
/*
|
||||
* reset buffer:
|
||||
*/
|
||||
bufferPos = 0;
|
||||
}
|
||||
if (bufferPos < WBLOCKBYTES - LENGTHBYTES) {
|
||||
memset(&buffer[bufferPos], 0, (WBLOCKBYTES - LENGTHBYTES) - bufferPos);
|
||||
}
|
||||
bufferPos = WBLOCKBYTES - LENGTHBYTES;
|
||||
/*
|
||||
* append bit length of hashed data:
|
||||
*/
|
||||
memcpy(&buffer[WBLOCKBYTES - LENGTHBYTES], bitLength, LENGTHBYTES);
|
||||
/*
|
||||
* process data block:
|
||||
*/
|
||||
WhirlpoolTransform(context);
|
||||
/*
|
||||
* return the completed message digest:
|
||||
*/
|
||||
for (i = 0; i < DIGESTBYTES/8; i++) {
|
||||
digest[0] = (unsigned char)(context->state[i] >> 56);
|
||||
digest[1] = (unsigned char)(context->state[i] >> 48);
|
||||
digest[2] = (unsigned char)(context->state[i] >> 40);
|
||||
digest[3] = (unsigned char)(context->state[i] >> 32);
|
||||
digest[4] = (unsigned char)(context->state[i] >> 24);
|
||||
digest[5] = (unsigned char)(context->state[i] >> 16);
|
||||
digest[6] = (unsigned char)(context->state[i] >> 8);
|
||||
digest[7] = (unsigned char)(context->state[i] );
|
||||
digest += 8;
|
||||
}
|
||||
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
php_hash_ops php_hash_whirlpool_ops = {
|
||||
(php_hash_init_func_t) PHP_WHIRLPOOLInit,
|
||||
(php_hash_update_func_t) PHP_WHIRLPOOLUpdate,
|
||||
(php_hash_final_func_t) PHP_WHIRLPOOLFinal,
|
||||
64,
|
||||
64,
|
||||
sizeof(PHP_WHIRLPOOL_CTX)
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,95 +0,0 @@
|
||||
<package version="1.0">
|
||||
<name>hash</name>
|
||||
<summary>pHASH Message Digest Framework</summary>
|
||||
<description>
|
||||
Native implementations of common message digest algorithms using a generic factory method
|
||||
</description>
|
||||
<license>PHP</license>
|
||||
<maintainers>
|
||||
<maintainer>
|
||||
<user>pollita</user>
|
||||
<name>Sara Golemon</name>
|
||||
<email>pollita@php.net</email>
|
||||
<role>lead</role>
|
||||
</maintainer>
|
||||
<maintainer>
|
||||
<user>mike</user>
|
||||
<name>Michael Wallner</name>
|
||||
<email>mike@php.net</email>
|
||||
<role>lead</role>
|
||||
</maintainer>
|
||||
</maintainers>
|
||||
|
||||
<release>
|
||||
<version>1.1</version>
|
||||
<state>stable</state>
|
||||
<date>2005-12-00</date>
|
||||
<notes>
|
||||
Fixed PECL bug #6183 - haval source file entries missing in package.xml
|
||||
|
||||
Supported Algorithms:
|
||||
* md4, md5
|
||||
* sha1, sha256, sha384, sha512
|
||||
* ripemd128, ripemd160
|
||||
* tiger128, tiger160, tiger192 (3 and 4 passes)
|
||||
* haval128, haval160, haval192, haval224, haval256 (3, 4 and 5 passes)
|
||||
* crc32, crc32b, adler32, gost, snefru, whirlpool
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<filelist>
|
||||
<file role="src" name="config.m4"/>
|
||||
<file role="src" name="config.w32"/>
|
||||
<file role="src" name="hash.c"/>
|
||||
<file role="src" name="php_hash.h"/>
|
||||
<file role="src" name="php_hash_types.h"/>
|
||||
<file role="src" name="hash_md.c"/>
|
||||
<file role="src" name="php_hash_md.h"/>
|
||||
<file role="src" name="hash_sha.c"/>
|
||||
<file role="src" name="php_hash_sha.h"/>
|
||||
<file role="src" name="hash_ripemd.c"/>
|
||||
<file role="src" name="php_hash_ripemd.h"/>
|
||||
<file role="src" name="hash_whirlpool.c"/>
|
||||
<file role="src" name="php_hash_whirlpool.h"/>
|
||||
<file role="src" name="php_hash_whirlpool_tables.h"/>
|
||||
<file role="src" name="hash_tiger.c"/>
|
||||
<file role="src" name="php_hash_tiger.h"/>
|
||||
<file role="src" name="php_hash_tiger_tables.h"/>
|
||||
<file role="src" name="hash_snefru.c"/>
|
||||
<file role="src" name="php_hash_snefru.h"/>
|
||||
<file role="src" name="php_hash_snefru_tables.h"/>
|
||||
<file role="src" name="hash_gost.c"/>
|
||||
<file role="src" name="php_hash_gost.h"/>
|
||||
<file role="src" name="php_hash_gost_tables.h"/>
|
||||
<file role="src" name="hash_adler32.c"/>
|
||||
<file role="src" name="php_hash_adler32.h"/>
|
||||
<file role="src" name="hash_crc32.c"/>
|
||||
<file role="src" name="php_hash_crc32.h"/>
|
||||
<file role="src" name="php_hash_crc32_tables.h"/>
|
||||
<file role="src" name="hash_haval.c"/>
|
||||
<file role="src" name="php_hash_haval.h"/>
|
||||
<file role="doc" name="README"/>
|
||||
<dir role="test" name="tests">
|
||||
<file role="test" name="hmac-md5.phpt"/>
|
||||
<file role="test" name="md4.phpt"/>
|
||||
<file role="test" name="md5.phpt"/>
|
||||
<file role="test" name="sha1.phpt"/>
|
||||
<file role="test" name="sha256.phpt"/>
|
||||
<file role="test" name="sha384.phpt"/>
|
||||
<file role="test" name="sha512.phpt"/>
|
||||
<file role="test" name="ripemd128.phpt"/>
|
||||
<file role="test" name="ripemd160.phpt"/>
|
||||
<file role="test" name="haval.phpt"/>
|
||||
<file role="test" name="tiger.phpt"/>
|
||||
<file role="test" name="whirlpool.phpt"/>
|
||||
<file role="test" name="gost.phpt"/>
|
||||
<file role="test" name="snefru.phpt"/>
|
||||
<file role="test" name="crc32.phpt"/>
|
||||
<file role="test" name="adler32.phpt"/>
|
||||
</dir>
|
||||
</filelist>
|
||||
|
||||
</package>
|
||||
<!--
|
||||
vim: et ts=1 sw=1
|
||||
-->
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_H
|
||||
#define PHP_HASH_H
|
||||
|
||||
#include "php.h"
|
||||
#include "php_hash_types.h"
|
||||
|
||||
#define PHP_HASH_EXTNAME "hash"
|
||||
#define PHP_HASH_EXTVER "1.0"
|
||||
#define PHP_HASH_RESNAME "Hash Context"
|
||||
|
||||
#define PHP_HASH_HMAC 0x0001
|
||||
|
||||
typedef void (*php_hash_init_func_t)(void *context);
|
||||
typedef void (*php_hash_update_func_t)(void *context, const unsigned char *buf, unsigned int count);
|
||||
typedef void (*php_hash_final_func_t)(unsigned char *digest, void *context);
|
||||
|
||||
typedef struct _php_hash_ops {
|
||||
php_hash_init_func_t hash_init;
|
||||
php_hash_update_func_t hash_update;
|
||||
php_hash_final_func_t hash_final;
|
||||
|
||||
int digest_size;
|
||||
int block_size;
|
||||
int context_size;
|
||||
} php_hash_ops;
|
||||
|
||||
typedef struct _php_hash_data {
|
||||
php_hash_ops *ops;
|
||||
void *context;
|
||||
|
||||
long options;
|
||||
unsigned char *key;
|
||||
} php_hash_data;
|
||||
|
||||
extern php_hash_ops php_hash_md4_ops;
|
||||
extern php_hash_ops php_hash_md5_ops;
|
||||
extern php_hash_ops php_hash_sha1_ops;
|
||||
extern php_hash_ops php_hash_sha256_ops;
|
||||
extern php_hash_ops php_hash_sha384_ops;
|
||||
extern php_hash_ops php_hash_sha512_ops;
|
||||
extern php_hash_ops php_hash_ripemd128_ops;
|
||||
extern php_hash_ops php_hash_ripemd160_ops;
|
||||
extern php_hash_ops php_hash_whirlpool_ops;
|
||||
extern php_hash_ops php_hash_3tiger128_ops;
|
||||
extern php_hash_ops php_hash_3tiger160_ops;
|
||||
extern php_hash_ops php_hash_3tiger192_ops;
|
||||
extern php_hash_ops php_hash_4tiger128_ops;
|
||||
extern php_hash_ops php_hash_4tiger160_ops;
|
||||
extern php_hash_ops php_hash_4tiger192_ops;
|
||||
extern php_hash_ops php_hash_snefru_ops;
|
||||
extern php_hash_ops php_hash_gost_ops;
|
||||
extern php_hash_ops php_hash_adler32_ops;
|
||||
extern php_hash_ops php_hash_crc32_ops;
|
||||
extern php_hash_ops php_hash_crc32b_ops;
|
||||
|
||||
#define PHP_HASH_HAVAL_OPS(p,b) extern php_hash_ops php_hash_##p##haval##b##_ops;
|
||||
|
||||
PHP_HASH_HAVAL_OPS(3,128)
|
||||
PHP_HASH_HAVAL_OPS(3,160)
|
||||
PHP_HASH_HAVAL_OPS(3,192)
|
||||
PHP_HASH_HAVAL_OPS(3,224)
|
||||
PHP_HASH_HAVAL_OPS(3,256)
|
||||
|
||||
PHP_HASH_HAVAL_OPS(4,128)
|
||||
PHP_HASH_HAVAL_OPS(4,160)
|
||||
PHP_HASH_HAVAL_OPS(4,192)
|
||||
PHP_HASH_HAVAL_OPS(4,224)
|
||||
PHP_HASH_HAVAL_OPS(4,256)
|
||||
|
||||
PHP_HASH_HAVAL_OPS(5,128)
|
||||
PHP_HASH_HAVAL_OPS(5,160)
|
||||
PHP_HASH_HAVAL_OPS(5,192)
|
||||
PHP_HASH_HAVAL_OPS(5,224)
|
||||
PHP_HASH_HAVAL_OPS(5,256)
|
||||
|
||||
extern zend_module_entry hash_module_entry;
|
||||
#define phpext_hash_ptr &hash_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_HASH_API __declspec(dllexport)
|
||||
#else
|
||||
#define PHP_HASH_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(hash);
|
||||
PHP_FUNCTION(hash_file);
|
||||
PHP_FUNCTION(hash_hmac);
|
||||
PHP_FUNCTION(hash_hmac_file);
|
||||
PHP_FUNCTION(hash_init);
|
||||
PHP_FUNCTION(hash_update);
|
||||
PHP_FUNCTION(hash_update_stream);
|
||||
PHP_FUNCTION(hash_update_file);
|
||||
PHP_FUNCTION(hash_final);
|
||||
PHP_FUNCTION(hash_algos);
|
||||
|
||||
PHP_HASH_API php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len);
|
||||
PHP_HASH_API void php_hash_register_algo(const char *algo, php_hash_ops *ops);
|
||||
|
||||
static inline void php_hash_bin2hex(char *out, const unsigned char *in, int in_len)
|
||||
{
|
||||
static const char hexits[16] = "0123456789abcdef";
|
||||
int i;
|
||||
|
||||
for(i = 0; i < in_len; i++) {
|
||||
out[i * 2] = hexits[in[i] >> 4];
|
||||
out[(i * 2) + 1] = hexits[in[i] & 0x0F];
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PHP_HASH_H */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_ADLER32_H
|
||||
#define PHP_HASH_ADLER32_H
|
||||
|
||||
#include "ext/standard/basic_functions.h"
|
||||
|
||||
typedef struct {
|
||||
php_hash_uint32 state;
|
||||
} PHP_ADLER32_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context);
|
||||
PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len);
|
||||
PHP_HASH_API void PHP_ADLER32Final(unsigned char digest[4], PHP_ADLER32_CTX *context);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_CRC32_H
|
||||
#define PHP_HASH_CRC32_H
|
||||
|
||||
#include "ext/standard/basic_functions.h"
|
||||
|
||||
typedef struct {
|
||||
php_hash_uint32 state;
|
||||
} PHP_CRC32_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_CRC32Init(PHP_CRC32_CTX *context);
|
||||
PHP_HASH_API void PHP_CRC32Update(PHP_CRC32_CTX *context, const unsigned char *input, size_t len);
|
||||
PHP_HASH_API void PHP_CRC32BUpdate(PHP_CRC32_CTX *context, const unsigned char *input, size_t len);
|
||||
PHP_HASH_API void PHP_CRC32Final(unsigned char digest[4], PHP_CRC32_CTX *context);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
static const php_hash_uint32 crc32_table[] = { 0x0,
|
||||
0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
|
||||
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
|
||||
0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
||||
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,
|
||||
0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f,
|
||||
0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a,
|
||||
0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
|
||||
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58,
|
||||
0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033,
|
||||
0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe,
|
||||
0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
||||
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4,
|
||||
0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
|
||||
0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5,
|
||||
0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
|
||||
0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07,
|
||||
0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c,
|
||||
0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,
|
||||
0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
||||
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b,
|
||||
0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698,
|
||||
0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d,
|
||||
0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
|
||||
0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f,
|
||||
0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
|
||||
0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80,
|
||||
0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
||||
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a,
|
||||
0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629,
|
||||
0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c,
|
||||
0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
|
||||
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,
|
||||
0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65,
|
||||
0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8,
|
||||
0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
||||
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2,
|
||||
0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
|
||||
0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74,
|
||||
0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
|
||||
0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21,
|
||||
0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a,
|
||||
0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087,
|
||||
0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
||||
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d,
|
||||
0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce,
|
||||
0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,
|
||||
0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
|
||||
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09,
|
||||
0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
|
||||
0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf,
|
||||
0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
||||
};
|
||||
|
||||
static const php_hash_uint32 crc32b_table[] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
||||
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
||||
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
||||
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
|
||||
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
||||
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
|
||||
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
|
||||
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
|
||||
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
||||
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
||||
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
|
||||
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
|
||||
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
|
||||
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
||||
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
|
||||
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
||||
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
||||
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
|
||||
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
||||
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
|
||||
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
|
||||
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
||||
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
|
||||
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
||||
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
||||
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
|
||||
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
||||
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
|
||||
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
|
||||
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
|
||||
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
||||
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
||||
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
|
||||
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
|
||||
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
|
||||
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
||||
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
|
||||
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
||||
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
||||
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
|
||||
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
||||
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
|
||||
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
|
||||
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
||||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_GOST_H
|
||||
#define PHP_HASH_GOST_H
|
||||
|
||||
#include "ext/standard/basic_functions.h"
|
||||
|
||||
/* GOST context */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[16];
|
||||
php_hash_uint32 count[2];
|
||||
unsigned char length;
|
||||
unsigned char buffer[32];
|
||||
} PHP_GOST_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *);
|
||||
PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *, const unsigned char *, size_t);
|
||||
PHP_HASH_API void PHP_GOSTFinal(unsigned char[64], PHP_GOST_CTX *);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,138 +0,0 @@
|
||||
static const php_hash_uint32 tables[4][256] = {
|
||||
{ /* table 1 */
|
||||
0x00072000LU, 0x00075000LU, 0x00074800LU, 0x00071000LU, 0x00076800LU, 0x00074000LU, 0x00070000LU, 0x00077000LU,
|
||||
0x00073000LU, 0x00075800LU, 0x00070800LU, 0x00076000LU, 0x00073800LU, 0x00077800LU, 0x00072800LU, 0x00071800LU,
|
||||
0x0005A000LU, 0x0005D000LU, 0x0005C800LU, 0x00059000LU, 0x0005E800LU, 0x0005C000LU, 0x00058000LU, 0x0005F000LU,
|
||||
0x0005B000LU, 0x0005D800LU, 0x00058800LU, 0x0005E000LU, 0x0005B800LU, 0x0005F800LU, 0x0005A800LU, 0x00059800LU,
|
||||
0x00022000LU, 0x00025000LU, 0x00024800LU, 0x00021000LU, 0x00026800LU, 0x00024000LU, 0x00020000LU, 0x00027000LU,
|
||||
0x00023000LU, 0x00025800LU, 0x00020800LU, 0x00026000LU, 0x00023800LU, 0x00027800LU, 0x00022800LU, 0x00021800LU,
|
||||
0x00062000LU, 0x00065000LU, 0x00064800LU, 0x00061000LU, 0x00066800LU, 0x00064000LU, 0x00060000LU, 0x00067000LU,
|
||||
0x00063000LU, 0x00065800LU, 0x00060800LU, 0x00066000LU, 0x00063800LU, 0x00067800LU, 0x00062800LU, 0x00061800LU,
|
||||
0x00032000LU, 0x00035000LU, 0x00034800LU, 0x00031000LU, 0x00036800LU, 0x00034000LU, 0x00030000LU, 0x00037000LU,
|
||||
0x00033000LU, 0x00035800LU, 0x00030800LU, 0x00036000LU, 0x00033800LU, 0x00037800LU, 0x00032800LU, 0x00031800LU,
|
||||
0x0006A000LU, 0x0006D000LU, 0x0006C800LU, 0x00069000LU, 0x0006E800LU, 0x0006C000LU, 0x00068000LU, 0x0006F000LU,
|
||||
0x0006B000LU, 0x0006D800LU, 0x00068800LU, 0x0006E000LU, 0x0006B800LU, 0x0006F800LU, 0x0006A800LU, 0x00069800LU,
|
||||
0x0007A000LU, 0x0007D000LU, 0x0007C800LU, 0x00079000LU, 0x0007E800LU, 0x0007C000LU, 0x00078000LU, 0x0007F000LU,
|
||||
0x0007B000LU, 0x0007D800LU, 0x00078800LU, 0x0007E000LU, 0x0007B800LU, 0x0007F800LU, 0x0007A800LU, 0x00079800LU,
|
||||
0x00052000LU, 0x00055000LU, 0x00054800LU, 0x00051000LU, 0x00056800LU, 0x00054000LU, 0x00050000LU, 0x00057000LU,
|
||||
0x00053000LU, 0x00055800LU, 0x00050800LU, 0x00056000LU, 0x00053800LU, 0x00057800LU, 0x00052800LU, 0x00051800LU,
|
||||
0x00012000LU, 0x00015000LU, 0x00014800LU, 0x00011000LU, 0x00016800LU, 0x00014000LU, 0x00010000LU, 0x00017000LU,
|
||||
0x00013000LU, 0x00015800LU, 0x00010800LU, 0x00016000LU, 0x00013800LU, 0x00017800LU, 0x00012800LU, 0x00011800LU,
|
||||
0x0001A000LU, 0x0001D000LU, 0x0001C800LU, 0x00019000LU, 0x0001E800LU, 0x0001C000LU, 0x00018000LU, 0x0001F000LU,
|
||||
0x0001B000LU, 0x0001D800LU, 0x00018800LU, 0x0001E000LU, 0x0001B800LU, 0x0001F800LU, 0x0001A800LU, 0x00019800LU,
|
||||
0x00042000LU, 0x00045000LU, 0x00044800LU, 0x00041000LU, 0x00046800LU, 0x00044000LU, 0x00040000LU, 0x00047000LU,
|
||||
0x00043000LU, 0x00045800LU, 0x00040800LU, 0x00046000LU, 0x00043800LU, 0x00047800LU, 0x00042800LU, 0x00041800LU,
|
||||
0x0000A000LU, 0x0000D000LU, 0x0000C800LU, 0x00009000LU, 0x0000E800LU, 0x0000C000LU, 0x00008000LU, 0x0000F000LU,
|
||||
0x0000B000LU, 0x0000D800LU, 0x00008800LU, 0x0000E000LU, 0x0000B800LU, 0x0000F800LU, 0x0000A800LU, 0x00009800LU,
|
||||
0x00002000LU, 0x00005000LU, 0x00004800LU, 0x00001000LU, 0x00006800LU, 0x00004000LU, 0x00000000LU, 0x00007000LU,
|
||||
0x00003000LU, 0x00005800LU, 0x00000800LU, 0x00006000LU, 0x00003800LU, 0x00007800LU, 0x00002800LU, 0x00001800LU,
|
||||
0x0003A000LU, 0x0003D000LU, 0x0003C800LU, 0x00039000LU, 0x0003E800LU, 0x0003C000LU, 0x00038000LU, 0x0003F000LU,
|
||||
0x0003B000LU, 0x0003D800LU, 0x00038800LU, 0x0003E000LU, 0x0003B800LU, 0x0003F800LU, 0x0003A800LU, 0x00039800LU,
|
||||
0x0002A000LU, 0x0002D000LU, 0x0002C800LU, 0x00029000LU, 0x0002E800LU, 0x0002C000LU, 0x00028000LU, 0x0002F000LU,
|
||||
0x0002B000LU, 0x0002D800LU, 0x00028800LU, 0x0002E000LU, 0x0002B800LU, 0x0002F800LU, 0x0002A800LU, 0x00029800LU,
|
||||
0x0004A000LU, 0x0004D000LU, 0x0004C800LU, 0x00049000LU, 0x0004E800LU, 0x0004C000LU, 0x00048000LU, 0x0004F000LU,
|
||||
0x0004B000LU, 0x0004D800LU, 0x00048800LU, 0x0004E000LU, 0x0004B800LU, 0x0004F800LU, 0x0004A800LU, 0x00049800LU,
|
||||
},
|
||||
{ /* table 2 */
|
||||
0x03A80000LU, 0x03C00000LU, 0x03880000LU, 0x03E80000LU, 0x03D00000LU, 0x03980000LU, 0x03A00000LU, 0x03900000LU,
|
||||
0x03F00000LU, 0x03F80000LU, 0x03E00000LU, 0x03B80000LU, 0x03B00000LU, 0x03800000LU, 0x03C80000LU, 0x03D80000LU,
|
||||
0x06A80000LU, 0x06C00000LU, 0x06880000LU, 0x06E80000LU, 0x06D00000LU, 0x06980000LU, 0x06A00000LU, 0x06900000LU,
|
||||
0x06F00000LU, 0x06F80000LU, 0x06E00000LU, 0x06B80000LU, 0x06B00000LU, 0x06800000LU, 0x06C80000LU, 0x06D80000LU,
|
||||
0x05280000LU, 0x05400000LU, 0x05080000LU, 0x05680000LU, 0x05500000LU, 0x05180000LU, 0x05200000LU, 0x05100000LU,
|
||||
0x05700000LU, 0x05780000LU, 0x05600000LU, 0x05380000LU, 0x05300000LU, 0x05000000LU, 0x05480000LU, 0x05580000LU,
|
||||
0x00A80000LU, 0x00C00000LU, 0x00880000LU, 0x00E80000LU, 0x00D00000LU, 0x00980000LU, 0x00A00000LU, 0x00900000LU,
|
||||
0x00F00000LU, 0x00F80000LU, 0x00E00000LU, 0x00B80000LU, 0x00B00000LU, 0x00800000LU, 0x00C80000LU, 0x00D80000LU,
|
||||
0x00280000LU, 0x00400000LU, 0x00080000LU, 0x00680000LU, 0x00500000LU, 0x00180000LU, 0x00200000LU, 0x00100000LU,
|
||||
0x00700000LU, 0x00780000LU, 0x00600000LU, 0x00380000LU, 0x00300000LU, 0x00000000LU, 0x00480000LU, 0x00580000LU,
|
||||
0x04280000LU, 0x04400000LU, 0x04080000LU, 0x04680000LU, 0x04500000LU, 0x04180000LU, 0x04200000LU, 0x04100000LU,
|
||||
0x04700000LU, 0x04780000LU, 0x04600000LU, 0x04380000LU, 0x04300000LU, 0x04000000LU, 0x04480000LU, 0x04580000LU,
|
||||
0x04A80000LU, 0x04C00000LU, 0x04880000LU, 0x04E80000LU, 0x04D00000LU, 0x04980000LU, 0x04A00000LU, 0x04900000LU,
|
||||
0x04F00000LU, 0x04F80000LU, 0x04E00000LU, 0x04B80000LU, 0x04B00000LU, 0x04800000LU, 0x04C80000LU, 0x04D80000LU,
|
||||
0x07A80000LU, 0x07C00000LU, 0x07880000LU, 0x07E80000LU, 0x07D00000LU, 0x07980000LU, 0x07A00000LU, 0x07900000LU,
|
||||
0x07F00000LU, 0x07F80000LU, 0x07E00000LU, 0x07B80000LU, 0x07B00000LU, 0x07800000LU, 0x07C80000LU, 0x07D80000LU,
|
||||
0x07280000LU, 0x07400000LU, 0x07080000LU, 0x07680000LU, 0x07500000LU, 0x07180000LU, 0x07200000LU, 0x07100000LU,
|
||||
0x07700000LU, 0x07780000LU, 0x07600000LU, 0x07380000LU, 0x07300000LU, 0x07000000LU, 0x07480000LU, 0x07580000LU,
|
||||
0x02280000LU, 0x02400000LU, 0x02080000LU, 0x02680000LU, 0x02500000LU, 0x02180000LU, 0x02200000LU, 0x02100000LU,
|
||||
0x02700000LU, 0x02780000LU, 0x02600000LU, 0x02380000LU, 0x02300000LU, 0x02000000LU, 0x02480000LU, 0x02580000LU,
|
||||
0x03280000LU, 0x03400000LU, 0x03080000LU, 0x03680000LU, 0x03500000LU, 0x03180000LU, 0x03200000LU, 0x03100000LU,
|
||||
0x03700000LU, 0x03780000LU, 0x03600000LU, 0x03380000LU, 0x03300000LU, 0x03000000LU, 0x03480000LU, 0x03580000LU,
|
||||
0x06280000LU, 0x06400000LU, 0x06080000LU, 0x06680000LU, 0x06500000LU, 0x06180000LU, 0x06200000LU, 0x06100000LU,
|
||||
0x06700000LU, 0x06780000LU, 0x06600000LU, 0x06380000LU, 0x06300000LU, 0x06000000LU, 0x06480000LU, 0x06580000LU,
|
||||
0x05A80000LU, 0x05C00000LU, 0x05880000LU, 0x05E80000LU, 0x05D00000LU, 0x05980000LU, 0x05A00000LU, 0x05900000LU,
|
||||
0x05F00000LU, 0x05F80000LU, 0x05E00000LU, 0x05B80000LU, 0x05B00000LU, 0x05800000LU, 0x05C80000LU, 0x05D80000LU,
|
||||
0x01280000LU, 0x01400000LU, 0x01080000LU, 0x01680000LU, 0x01500000LU, 0x01180000LU, 0x01200000LU, 0x01100000LU,
|
||||
0x01700000LU, 0x01780000LU, 0x01600000LU, 0x01380000LU, 0x01300000LU, 0x01000000LU, 0x01480000LU, 0x01580000LU,
|
||||
0x02A80000LU, 0x02C00000LU, 0x02880000LU, 0x02E80000LU, 0x02D00000LU, 0x02980000LU, 0x02A00000LU, 0x02900000LU,
|
||||
0x02F00000LU, 0x02F80000LU, 0x02E00000LU, 0x02B80000LU, 0x02B00000LU, 0x02800000LU, 0x02C80000LU, 0x02D80000LU,
|
||||
0x01A80000LU, 0x01C00000LU, 0x01880000LU, 0x01E80000LU, 0x01D00000LU, 0x01980000LU, 0x01A00000LU, 0x01900000LU,
|
||||
0x01F00000LU, 0x01F80000LU, 0x01E00000LU, 0x01B80000LU, 0x01B00000LU, 0x01800000LU, 0x01C80000LU, 0x01D80000LU,
|
||||
},
|
||||
{ /* table 3 */
|
||||
0x30000002LU, 0x60000002LU, 0x38000002LU, 0x08000002LU, 0x28000002LU, 0x78000002LU, 0x68000002LU, 0x40000002LU,
|
||||
0x20000002LU, 0x50000002LU, 0x48000002LU, 0x70000002LU, 0x00000002LU, 0x18000002LU, 0x58000002LU, 0x10000002LU,
|
||||
0xB0000005LU, 0xE0000005LU, 0xB8000005LU, 0x88000005LU, 0xA8000005LU, 0xF8000005LU, 0xE8000005LU, 0xC0000005LU,
|
||||
0xA0000005LU, 0xD0000005LU, 0xC8000005LU, 0xF0000005LU, 0x80000005LU, 0x98000005LU, 0xD8000005LU, 0x90000005LU,
|
||||
0x30000005LU, 0x60000005LU, 0x38000005LU, 0x08000005LU, 0x28000005LU, 0x78000005LU, 0x68000005LU, 0x40000005LU,
|
||||
0x20000005LU, 0x50000005LU, 0x48000005LU, 0x70000005LU, 0x00000005LU, 0x18000005LU, 0x58000005LU, 0x10000005LU,
|
||||
0x30000000LU, 0x60000000LU, 0x38000000LU, 0x08000000LU, 0x28000000LU, 0x78000000LU, 0x68000000LU, 0x40000000LU,
|
||||
0x20000000LU, 0x50000000LU, 0x48000000LU, 0x70000000LU, 0x00000000LU, 0x18000000LU, 0x58000000LU, 0x10000000LU,
|
||||
0xB0000003LU, 0xE0000003LU, 0xB8000003LU, 0x88000003LU, 0xA8000003LU, 0xF8000003LU, 0xE8000003LU, 0xC0000003LU,
|
||||
0xA0000003LU, 0xD0000003LU, 0xC8000003LU, 0xF0000003LU, 0x80000003LU, 0x98000003LU, 0xD8000003LU, 0x90000003LU,
|
||||
0x30000001LU, 0x60000001LU, 0x38000001LU, 0x08000001LU, 0x28000001LU, 0x78000001LU, 0x68000001LU, 0x40000001LU,
|
||||
0x20000001LU, 0x50000001LU, 0x48000001LU, 0x70000001LU, 0x00000001LU, 0x18000001LU, 0x58000001LU, 0x10000001LU,
|
||||
0xB0000000LU, 0xE0000000LU, 0xB8000000LU, 0x88000000LU, 0xA8000000LU, 0xF8000000LU, 0xE8000000LU, 0xC0000000LU,
|
||||
0xA0000000LU, 0xD0000000LU, 0xC8000000LU, 0xF0000000LU, 0x80000000LU, 0x98000000LU, 0xD8000000LU, 0x90000000LU,
|
||||
0xB0000006LU, 0xE0000006LU, 0xB8000006LU, 0x88000006LU, 0xA8000006LU, 0xF8000006LU, 0xE8000006LU, 0xC0000006LU,
|
||||
0xA0000006LU, 0xD0000006LU, 0xC8000006LU, 0xF0000006LU, 0x80000006LU, 0x98000006LU, 0xD8000006LU, 0x90000006LU,
|
||||
0xB0000001LU, 0xE0000001LU, 0xB8000001LU, 0x88000001LU, 0xA8000001LU, 0xF8000001LU, 0xE8000001LU, 0xC0000001LU,
|
||||
0xA0000001LU, 0xD0000001LU, 0xC8000001LU, 0xF0000001LU, 0x80000001LU, 0x98000001LU, 0xD8000001LU, 0x90000001LU,
|
||||
0x30000003LU, 0x60000003LU, 0x38000003LU, 0x08000003LU, 0x28000003LU, 0x78000003LU, 0x68000003LU, 0x40000003LU,
|
||||
0x20000003LU, 0x50000003LU, 0x48000003LU, 0x70000003LU, 0x00000003LU, 0x18000003LU, 0x58000003LU, 0x10000003LU,
|
||||
0x30000004LU, 0x60000004LU, 0x38000004LU, 0x08000004LU, 0x28000004LU, 0x78000004LU, 0x68000004LU, 0x40000004LU,
|
||||
0x20000004LU, 0x50000004LU, 0x48000004LU, 0x70000004LU, 0x00000004LU, 0x18000004LU, 0x58000004LU, 0x10000004LU,
|
||||
0xB0000002LU, 0xE0000002LU, 0xB8000002LU, 0x88000002LU, 0xA8000002LU, 0xF8000002LU, 0xE8000002LU, 0xC0000002LU,
|
||||
0xA0000002LU, 0xD0000002LU, 0xC8000002LU, 0xF0000002LU, 0x80000002LU, 0x98000002LU, 0xD8000002LU, 0x90000002LU,
|
||||
0xB0000004LU, 0xE0000004LU, 0xB8000004LU, 0x88000004LU, 0xA8000004LU, 0xF8000004LU, 0xE8000004LU, 0xC0000004LU,
|
||||
0xA0000004LU, 0xD0000004LU, 0xC8000004LU, 0xF0000004LU, 0x80000004LU, 0x98000004LU, 0xD8000004LU, 0x90000004LU,
|
||||
0x30000006LU, 0x60000006LU, 0x38000006LU, 0x08000006LU, 0x28000006LU, 0x78000006LU, 0x68000006LU, 0x40000006LU,
|
||||
0x20000006LU, 0x50000006LU, 0x48000006LU, 0x70000006LU, 0x00000006LU, 0x18000006LU, 0x58000006LU, 0x10000006LU,
|
||||
0xB0000007LU, 0xE0000007LU, 0xB8000007LU, 0x88000007LU, 0xA8000007LU, 0xF8000007LU, 0xE8000007LU, 0xC0000007LU,
|
||||
0xA0000007LU, 0xD0000007LU, 0xC8000007LU, 0xF0000007LU, 0x80000007LU, 0x98000007LU, 0xD8000007LU, 0x90000007LU,
|
||||
0x30000007LU, 0x60000007LU, 0x38000007LU, 0x08000007LU, 0x28000007LU, 0x78000007LU, 0x68000007LU, 0x40000007LU,
|
||||
0x20000007LU, 0x50000007LU, 0x48000007LU, 0x70000007LU, 0x00000007LU, 0x18000007LU, 0x58000007LU, 0x10000007LU,
|
||||
},
|
||||
{ /* table 4 */
|
||||
0x000000E8LU, 0x000000D8LU, 0x000000A0LU, 0x00000088LU, 0x00000098LU, 0x000000F8LU, 0x000000A8LU, 0x000000C8LU,
|
||||
0x00000080LU, 0x000000D0LU, 0x000000F0LU, 0x000000B8LU, 0x000000B0LU, 0x000000C0LU, 0x00000090LU, 0x000000E0LU,
|
||||
0x000007E8LU, 0x000007D8LU, 0x000007A0LU, 0x00000788LU, 0x00000798LU, 0x000007F8LU, 0x000007A8LU, 0x000007C8LU,
|
||||
0x00000780LU, 0x000007D0LU, 0x000007F0LU, 0x000007B8LU, 0x000007B0LU, 0x000007C0LU, 0x00000790LU, 0x000007E0LU,
|
||||
0x000006E8LU, 0x000006D8LU, 0x000006A0LU, 0x00000688LU, 0x00000698LU, 0x000006F8LU, 0x000006A8LU, 0x000006C8LU,
|
||||
0x00000680LU, 0x000006D0LU, 0x000006F0LU, 0x000006B8LU, 0x000006B0LU, 0x000006C0LU, 0x00000690LU, 0x000006E0LU,
|
||||
0x00000068LU, 0x00000058LU, 0x00000020LU, 0x00000008LU, 0x00000018LU, 0x00000078LU, 0x00000028LU, 0x00000048LU,
|
||||
0x00000000LU, 0x00000050LU, 0x00000070LU, 0x00000038LU, 0x00000030LU, 0x00000040LU, 0x00000010LU, 0x00000060LU,
|
||||
0x000002E8LU, 0x000002D8LU, 0x000002A0LU, 0x00000288LU, 0x00000298LU, 0x000002F8LU, 0x000002A8LU, 0x000002C8LU,
|
||||
0x00000280LU, 0x000002D0LU, 0x000002F0LU, 0x000002B8LU, 0x000002B0LU, 0x000002C0LU, 0x00000290LU, 0x000002E0LU,
|
||||
0x000003E8LU, 0x000003D8LU, 0x000003A0LU, 0x00000388LU, 0x00000398LU, 0x000003F8LU, 0x000003A8LU, 0x000003C8LU,
|
||||
0x00000380LU, 0x000003D0LU, 0x000003F0LU, 0x000003B8LU, 0x000003B0LU, 0x000003C0LU, 0x00000390LU, 0x000003E0LU,
|
||||
0x00000568LU, 0x00000558LU, 0x00000520LU, 0x00000508LU, 0x00000518LU, 0x00000578LU, 0x00000528LU, 0x00000548LU,
|
||||
0x00000500LU, 0x00000550LU, 0x00000570LU, 0x00000538LU, 0x00000530LU, 0x00000540LU, 0x00000510LU, 0x00000560LU,
|
||||
0x00000268LU, 0x00000258LU, 0x00000220LU, 0x00000208LU, 0x00000218LU, 0x00000278LU, 0x00000228LU, 0x00000248LU,
|
||||
0x00000200LU, 0x00000250LU, 0x00000270LU, 0x00000238LU, 0x00000230LU, 0x00000240LU, 0x00000210LU, 0x00000260LU,
|
||||
0x000004E8LU, 0x000004D8LU, 0x000004A0LU, 0x00000488LU, 0x00000498LU, 0x000004F8LU, 0x000004A8LU, 0x000004C8LU,
|
||||
0x00000480LU, 0x000004D0LU, 0x000004F0LU, 0x000004B8LU, 0x000004B0LU, 0x000004C0LU, 0x00000490LU, 0x000004E0LU,
|
||||
0x00000168LU, 0x00000158LU, 0x00000120LU, 0x00000108LU, 0x00000118LU, 0x00000178LU, 0x00000128LU, 0x00000148LU,
|
||||
0x00000100LU, 0x00000150LU, 0x00000170LU, 0x00000138LU, 0x00000130LU, 0x00000140LU, 0x00000110LU, 0x00000160LU,
|
||||
0x000001E8LU, 0x000001D8LU, 0x000001A0LU, 0x00000188LU, 0x00000198LU, 0x000001F8LU, 0x000001A8LU, 0x000001C8LU,
|
||||
0x00000180LU, 0x000001D0LU, 0x000001F0LU, 0x000001B8LU, 0x000001B0LU, 0x000001C0LU, 0x00000190LU, 0x000001E0LU,
|
||||
0x00000768LU, 0x00000758LU, 0x00000720LU, 0x00000708LU, 0x00000718LU, 0x00000778LU, 0x00000728LU, 0x00000748LU,
|
||||
0x00000700LU, 0x00000750LU, 0x00000770LU, 0x00000738LU, 0x00000730LU, 0x00000740LU, 0x00000710LU, 0x00000760LU,
|
||||
0x00000368LU, 0x00000358LU, 0x00000320LU, 0x00000308LU, 0x00000318LU, 0x00000378LU, 0x00000328LU, 0x00000348LU,
|
||||
0x00000300LU, 0x00000350LU, 0x00000370LU, 0x00000338LU, 0x00000330LU, 0x00000340LU, 0x00000310LU, 0x00000360LU,
|
||||
0x000005E8LU, 0x000005D8LU, 0x000005A0LU, 0x00000588LU, 0x00000598LU, 0x000005F8LU, 0x000005A8LU, 0x000005C8LU,
|
||||
0x00000580LU, 0x000005D0LU, 0x000005F0LU, 0x000005B8LU, 0x000005B0LU, 0x000005C0LU, 0x00000590LU, 0x000005E0LU,
|
||||
0x00000468LU, 0x00000458LU, 0x00000420LU, 0x00000408LU, 0x00000418LU, 0x00000478LU, 0x00000428LU, 0x00000448LU,
|
||||
0x00000400LU, 0x00000450LU, 0x00000470LU, 0x00000438LU, 0x00000430LU, 0x00000440LU, 0x00000410LU, 0x00000460LU,
|
||||
0x00000668LU, 0x00000658LU, 0x00000620LU, 0x00000608LU, 0x00000618LU, 0x00000678LU, 0x00000628LU, 0x00000648LU,
|
||||
0x00000600LU, 0x00000650LU, 0x00000670LU, 0x00000638LU, 0x00000630LU, 0x00000640LU, 0x00000610LU, 0x00000660LU,
|
||||
},
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_HAVAL_H
|
||||
#define PHP_HASH_HAVAL_H
|
||||
|
||||
#include "ext/standard/basic_functions.h"
|
||||
/* HAVAL context. */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[8];
|
||||
php_hash_uint32 count[2];
|
||||
unsigned char buffer[128];
|
||||
|
||||
char passes;
|
||||
short output;
|
||||
void (*Transform)(php_hash_uint32 state[8], const unsigned char block[128]);
|
||||
} PHP_HAVAL_CTX;
|
||||
|
||||
#define PHP_HASH_HAVAL_INIT_DECL(p,b) PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *); \
|
||||
PHP_HASH_API void PHP_HAVAL##b##Final(unsigned char*, PHP_HAVAL_CTX *);
|
||||
|
||||
PHP_HASH_API void PHP_HAVALUpdate(PHP_HAVAL_CTX *, const unsigned char *, unsigned int);
|
||||
|
||||
PHP_HASH_HAVAL_INIT_DECL(3,128)
|
||||
PHP_HASH_HAVAL_INIT_DECL(3,160)
|
||||
PHP_HASH_HAVAL_INIT_DECL(3,192)
|
||||
PHP_HASH_HAVAL_INIT_DECL(3,224)
|
||||
PHP_HASH_HAVAL_INIT_DECL(3,256)
|
||||
|
||||
PHP_HASH_HAVAL_INIT_DECL(4,128)
|
||||
PHP_HASH_HAVAL_INIT_DECL(4,160)
|
||||
PHP_HASH_HAVAL_INIT_DECL(4,192)
|
||||
PHP_HASH_HAVAL_INIT_DECL(4,224)
|
||||
PHP_HASH_HAVAL_INIT_DECL(4,256)
|
||||
|
||||
PHP_HASH_HAVAL_INIT_DECL(5,128)
|
||||
PHP_HASH_HAVAL_INIT_DECL(5,160)
|
||||
PHP_HASH_HAVAL_INIT_DECL(5,192)
|
||||
PHP_HASH_HAVAL_INIT_DECL(5,224)
|
||||
PHP_HASH_HAVAL_INIT_DECL(5,256)
|
||||
|
||||
#endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Original Author: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
|
||||
| Modified for pHASH by: Sara Golemon <pollita@php.net>
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_MD_H
|
||||
#define PHP_HASH_MD_H
|
||||
|
||||
/* When SHA is removed from Core,
|
||||
the ext/standard/sha1.c file can be removed
|
||||
and the ext/standard/sha1.h file can be reduced to:
|
||||
#define PHP_HASH_SHA1_NOT_IN_CORE
|
||||
#include "ext/hash/php_hash_sha.h"
|
||||
Don't forget to remove md5() and md5_file() entries from basic_functions.c
|
||||
*/
|
||||
|
||||
#include "ext/standard/md5.h"
|
||||
|
||||
#ifdef PHP_HASH_MD5_NOT_IN_CORE
|
||||
/* MD5.H - header file for MD5C.C
|
||||
*/
|
||||
|
||||
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
License to copy and use this software is granted provided that it
|
||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
||||
Algorithm" in all material mentioning or referencing this software
|
||||
or this function.
|
||||
|
||||
License is also granted to make and use derivative works provided
|
||||
that such works are identified as "derived from the RSA Data
|
||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
||||
mentioning or referencing the derived work.
|
||||
|
||||
RSA Data Security, Inc. makes no representations concerning either
|
||||
the merchantability of this software or the suitability of this
|
||||
software for any particular purpose. It is provided "as is"
|
||||
without express or implied warranty of any kind.
|
||||
|
||||
These notices must be retained in any copies of any part of this
|
||||
documentation and/or software.
|
||||
*/
|
||||
|
||||
/* MD5 context. */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[4]; /* state (ABCD) */
|
||||
php_hash_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} PHP_MD5_CTX;
|
||||
|
||||
PHP_HASH_API void make_digest(char *md5str, unsigned char *digest);
|
||||
PHP_HASH_API void PHP_MD5Init(PHP_MD5_CTX *);
|
||||
PHP_HASH_API void PHP_MD5Update(PHP_MD5_CTX *, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_MD5Final(unsigned char[16], PHP_MD5_CTX *);
|
||||
|
||||
PHP_NAMED_FUNCTION(php_if_md5);
|
||||
PHP_NAMED_FUNCTION(php_if_md5_file);
|
||||
#endif /* PHP_HASH_MD5_NOT_IN_CORE */
|
||||
|
||||
/* MD4 context */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[4];
|
||||
php_hash_uint32 count[2];
|
||||
unsigned char buffer[64];
|
||||
} PHP_MD4_CTX;
|
||||
|
||||
#define PHP_MD4Init PHP_MD5Init
|
||||
PHP_HASH_API void PHP_MD4Update(PHP_MD4_CTX *context, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_MD4Final(unsigned char[16], PHP_MD4_CTX *);
|
||||
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_RIPEMD_H
|
||||
#define PHP_HASH_RIPEMD_H
|
||||
#include "ext/standard/basic_functions.h"
|
||||
|
||||
/* RIPEMD context. */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[4]; /* state (ABCD) */
|
||||
php_hash_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} PHP_RIPEMD128_CTX;
|
||||
|
||||
typedef struct {
|
||||
php_hash_uint32 state[5]; /* state (ABCD) */
|
||||
php_hash_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} PHP_RIPEMD160_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_RIPEMD128Init(PHP_RIPEMD128_CTX *);
|
||||
PHP_HASH_API void PHP_RIPEMD128Update(PHP_RIPEMD128_CTX *, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_RIPEMD128Final(unsigned char[16], PHP_RIPEMD128_CTX *);
|
||||
|
||||
PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX *);
|
||||
PHP_HASH_API void PHP_RIPEMD160Update(PHP_RIPEMD160_CTX *, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_RIPEMD160Final(unsigned char[20], PHP_RIPEMD160_CTX *);
|
||||
|
||||
#endif /* PHP_HASH_RIPEMD_H */
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| SHA1 Author: Stefan Esser <sesser@php.net> |
|
||||
| SHA256 Author: Sara Golemon <pollita@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_SHA_H
|
||||
#define PHP_HASH_SHA_H
|
||||
|
||||
/* When SHA is removed from Core,
|
||||
the ext/standard/sha1.c file can be removed
|
||||
and the ext/standard/sha1.h file can be reduced to:
|
||||
#define PHP_HASH_SHA1_NOT_IN_CORE
|
||||
#include "ext/hash/php_hash_sha.h"
|
||||
Don't forget to remove sha1() and sha1_file() from basic_functions.c
|
||||
*/
|
||||
#include "ext/standard/sha1.h"
|
||||
#include "ext/standard/basic_functions.h"
|
||||
|
||||
#ifdef PHP_HASH_SHA1_NOT_IN_CORE
|
||||
|
||||
/* SHA1 context. */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[5]; /* state (ABCD) */
|
||||
php_hash_uint32 count[2]; /* number of bits, modulo 2^64 */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} PHP_SHA1_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_SHA1Init(PHP_SHA1_CTX *);
|
||||
PHP_HASH_API void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *);
|
||||
|
||||
PHP_FUNCTION(sha1);
|
||||
PHP_FUNCTION(sha1_file);
|
||||
|
||||
#endif /* PHP_HASH_SHA1_NOT_IN_CORE */
|
||||
|
||||
/* SHA256 context. */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[8]; /* state */
|
||||
php_hash_uint32 count[2]; /* number of bits, modulo 2^64 */
|
||||
unsigned char buffer[64]; /* input buffer */
|
||||
} PHP_SHA256_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_SHA256Init(PHP_SHA256_CTX *);
|
||||
PHP_HASH_API void PHP_SHA256Update(PHP_SHA256_CTX *, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_SHA256Final(unsigned char[32], PHP_SHA256_CTX *);
|
||||
|
||||
/* SHA384 context */
|
||||
typedef struct {
|
||||
php_hash_uint64 state[8]; /* state */
|
||||
php_hash_uint64 count[2]; /* number of bits, modulo 2^128 */
|
||||
unsigned char buffer[128]; /* input buffer */
|
||||
} PHP_SHA384_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_SHA384Init(PHP_SHA384_CTX *);
|
||||
PHP_HASH_API void PHP_SHA384Update(PHP_SHA384_CTX *, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_SHA384Final(unsigned char[48], PHP_SHA384_CTX *);
|
||||
|
||||
/* SHA512 context */
|
||||
typedef struct {
|
||||
php_hash_uint64 state[8]; /* state */
|
||||
php_hash_uint64 count[2]; /* number of bits, modulo 2^128 */
|
||||
unsigned char buffer[128]; /* input buffer */
|
||||
} PHP_SHA512_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_SHA512Init(PHP_SHA512_CTX *);
|
||||
PHP_HASH_API void PHP_SHA512Update(PHP_SHA512_CTX *, const unsigned char *, unsigned int);
|
||||
PHP_HASH_API void PHP_SHA512Final(unsigned char[64], PHP_SHA512_CTX *);
|
||||
|
||||
#endif /* PHP_HASH_SHA_H */
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_SNEFRU_H
|
||||
#define PHP_HASH_SNEFRU_H
|
||||
|
||||
/* SNEFRU-2.5a with 8 passes and 256 bit hash output
|
||||
* AKA "Xerox Secure Hash Function"
|
||||
*/
|
||||
|
||||
#include "ext/standard/basic_functions.h"
|
||||
|
||||
/* SNEFRU context */
|
||||
typedef struct {
|
||||
php_hash_uint32 state[16];
|
||||
php_hash_uint32 count[2];
|
||||
unsigned char length;
|
||||
unsigned char buffer[32];
|
||||
} PHP_SNEFRU_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *);
|
||||
PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *, const unsigned char *, size_t);
|
||||
PHP_HASH_API void PHP_SNEFRUFinal(unsigned char[32], PHP_SNEFRU_CTX *);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,942 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
static const php_hash_uint32 tables[16][256]= {
|
||||
|
||||
{ /* Start of S Box 0 */
|
||||
|
||||
/* 0*/ 0x64f9001bL,0xfeddcdf6L,0x7c8ff1e2L,0x11d71514L,0x8b8c18d3L,
|
||||
/* 5*/ 0xdddf881eL,0x6eab5056L,0x88ced8e1L,0x49148959L,0x69c56fd5L,
|
||||
/* 10*/ 0xb7994f03L,0x0fbcee3eL,0x3c264940L,0x21557e58L,0xe14b3fc2L,
|
||||
/* 15*/ 0x2e5cf591L,0xdceff8ceL,0x092a1648L,0xbe812936L,0xff7b0c6aL,
|
||||
/* 20*/ 0xd5251037L,0xafa448f1L,0x7dafc95aL,0x1ea69c3fL,0xa417abe7L,
|
||||
/* 25*/ 0x5890e423L,0xb0cb70c0L,0xc85025f7L,0x244d97e3L,0x1ff3595fL,
|
||||
/* 30*/ 0xc4ec6396L,0x59181e17L,0xe635b477L,0x354e7dbfL,0x796f7753L,
|
||||
/* 35*/ 0x66eb52ccL,0x77c3f995L,0x32e3a927L,0x80ccaed6L,0x4e2be89dL,
|
||||
/* 40*/ 0x375bbd28L,0xad1a3d05L,0x2b1b42b3L,0x16c44c71L,0x4d54bfa8L,
|
||||
/* 45*/ 0xe57ddc7aL,0xec6d8144L,0x5a71046bL,0xd8229650L,0x87fc8f24L,
|
||||
/* 50*/ 0xcbc60e09L,0xb6390366L,0xd9f76092L,0xd393a70bL,0x1d31a08aL,
|
||||
/* 55*/ 0x9cd971c9L,0x5c1ef445L,0x86fab694L,0xfdb44165L,0x8eaafcbeL,
|
||||
/* 60*/ 0x4bcac6ebL,0xfb7a94e5L,0x5789d04eL,0xfa13cf35L,0x236b8da9L,
|
||||
/* 65*/ 0x4133f000L,0x6224261cL,0xf412f23bL,0xe75e56a4L,0x30022116L,
|
||||
/* 70*/ 0xbaf17f1fL,0xd09872f9L,0xc1a3699cL,0xf1e802aaL,0x0dd145dcL,
|
||||
/* 75*/ 0x4fdce093L,0x8d8412f0L,0x6cd0f376L,0x3de6b73dL,0x84ba737fL,
|
||||
/* 80*/ 0xb43a30f2L,0x44569f69L,0x00e4eacaL,0xb58de3b0L,0x959113c8L,
|
||||
/* 85*/ 0xd62efee9L,0x90861f83L,0xced69874L,0x2f793ceeL,0xe8571c30L,
|
||||
/* 90*/ 0x483665d1L,0xab07b031L,0x914c844fL,0x15bf3be8L,0x2c3f2a9aL,
|
||||
/* 95*/ 0x9eb95fd4L,0x92e7472dL,0x2297cc5bL,0xee5f2782L,0x5377b562L,
|
||||
/* 100*/ 0xdb8ebbcfL,0xf961deddL,0xc59b5c60L,0x1bd3910dL,0x26d206adL,
|
||||
/* 105*/ 0xb28514d8L,0x5ecf6b52L,0x7fea78bbL,0x504879acL,0xed34a884L,
|
||||
/* 110*/ 0x36e51d3cL,0x1753741dL,0x8c47caedL,0x9d0a40efL,0x3145e221L,
|
||||
/* 115*/ 0xda27eb70L,0xdf730ba3L,0x183c8789L,0x739ac0a6L,0x9a58dfc6L,
|
||||
/* 120*/ 0x54b134c1L,0xac3e242eL,0xcc493902L,0x7b2dda99L,0x8f15bc01L,
|
||||
/* 125*/ 0x29fd38c7L,0x27d5318fL,0x604aaff5L,0xf29c6818L,0xc38aa2ecL,
|
||||
/* 130*/ 0x1019d4c3L,0xa8fb936eL,0x20ed7b39L,0x0b686119L,0x89a0906fL,
|
||||
/* 135*/ 0x1cc7829eL,0x9952ef4bL,0x850e9e8cL,0xcd063a90L,0x67002f8eL,
|
||||
/* 140*/ 0xcfac8cb7L,0xeaa24b11L,0x988b4e6cL,0x46f066dfL,0xca7eec08L,
|
||||
/* 145*/ 0xc7bba664L,0x831d17bdL,0x63f575e6L,0x9764350eL,0x47870d42L,
|
||||
/* 150*/ 0x026ca4a2L,0x8167d587L,0x61b6adabL,0xaa6564d2L,0x70da237bL,
|
||||
/* 155*/ 0x25e1c74aL,0xa1c901a0L,0x0eb0a5daL,0x7670f741L,0x51c05aeaL,
|
||||
/* 160*/ 0x933dfa32L,0x0759ff1aL,0x56010ab8L,0x5fdecb78L,0x3f32edf8L,
|
||||
/* 165*/ 0xaebedbb9L,0x39f8326dL,0xd20858c5L,0x9b638be4L,0xa572c80aL,
|
||||
/* 170*/ 0x28e0a19fL,0x432099fcL,0x3a37c3cdL,0xbf95c585L,0xb392c12aL,
|
||||
/* 175*/ 0x6aa707d7L,0x52f66a61L,0x12d483b1L,0x96435b5eL,0x3e75802bL,
|
||||
/* 180*/ 0x3ba52b33L,0xa99f51a5L,0xbda1e157L,0x78c2e70cL,0xfcae7ce0L,
|
||||
/* 185*/ 0xd1602267L,0x2affac4dL,0x4a510947L,0x0ab2b83aL,0x7a04e579L,
|
||||
/* 190*/ 0x340dfd80L,0xb916e922L,0xe29d5e9bL,0xf5624af4L,0x4ca9d9afL,
|
||||
/* 195*/ 0x6bbd2cfeL,0xe3b7f620L,0xc2746e07L,0x5b42b9b6L,0xa06919bcL,
|
||||
/* 200*/ 0xf0f2c40fL,0x72217ab5L,0x14c19df3L,0xf3802daeL,0xe094beb4L,
|
||||
/* 205*/ 0xa2101affL,0x0529575dL,0x55cdb27cL,0xa33bddb2L,0x6528b37dL,
|
||||
/* 210*/ 0x740c05dbL,0xe96a62c4L,0x40782846L,0x6d30d706L,0xbbf48e2cL,
|
||||
/* 215*/ 0xbce2d3deL,0x049e37faL,0x01b5e634L,0x2d886d8dL,0x7e5a2e7eL,
|
||||
/* 220*/ 0xd7412013L,0x06e90f97L,0xe45d3ebaL,0xb8ad3386L,0x13051b25L,
|
||||
/* 225*/ 0x0c035354L,0x71c89b75L,0xc638fbd0L,0x197f11a1L,0xef0f08fbL,
|
||||
/* 230*/ 0xf8448651L,0x38409563L,0x452f4443L,0x5d464d55L,0x03d8764cL,
|
||||
/* 235*/ 0xb1b8d638L,0xa70bba2fL,0x94b3d210L,0xeb6692a7L,0xd409c2d9L,
|
||||
/* 240*/ 0x68838526L,0xa6db8a15L,0x751f6c98L,0xde769a88L,0xc9ee4668L,
|
||||
/* 245*/ 0x1a82a373L,0x0896aa49L,0x42233681L,0xf62c55cbL,0x9f1c5404L,
|
||||
/* 250*/ 0xf74fb15cL,0xc06e4312L,0x6ffe5d72L,0x8aa8678bL,0x337cd129L,
|
||||
/* 255*/ 0x8211cefdL
|
||||
/* End of S Box 0 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 1 */
|
||||
|
||||
/* 0*/ 0x074a1d09L,0x52a10e5aL,0x9275a3f8L,0x4b82506cL,0x37df7e1bL,
|
||||
/* 5*/ 0x4c78b3c5L,0xcefab1daL,0xf472267eL,0xb63045f6L,0xd66a1fc0L,
|
||||
/* 10*/ 0x400298e3L,0x27e60c94L,0x87d2f1b8L,0xdf9e56ccL,0x45cd1803L,
|
||||
/* 15*/ 0x1d35e098L,0xcce7c736L,0x03483bf1L,0x1f7307d7L,0xc6e8f948L,
|
||||
/* 20*/ 0xe613c111L,0x3955c6ffL,0x1170ed7cL,0x8e95da41L,0x99c31bf4L,
|
||||
/* 25*/ 0xa4da8021L,0x7b5f94fbL,0xdd0da51fL,0x6562aa77L,0x556bcb23L,
|
||||
/* 30*/ 0xdb1bacc6L,0x798040b9L,0xbfe5378fL,0x731d55e6L,0xdaa5bfeeL,
|
||||
/* 35*/ 0x389bbc60L,0x1b33fba4L,0x9c567204L,0x36c26c68L,0x77ee9d69L,
|
||||
/* 40*/ 0x8aeb3e88L,0x2d50b5ceL,0x9579e790L,0x42b13cfcL,0x33fbd32bL,
|
||||
/* 45*/ 0xee0503a7L,0xb5862824L,0x15e41eadL,0xc8412ef7L,0x9d441275L,
|
||||
/* 50*/ 0x2fcec582L,0x5ff483b7L,0x8f3931dfL,0x2e5d2a7bL,0x49467bf9L,
|
||||
/* 55*/ 0x0653dea9L,0x2684ce35L,0x7e655e5cL,0xf12771d8L,0xbb15cc67L,
|
||||
/* 60*/ 0xab097ca1L,0x983dcf52L,0x10ddf026L,0x21267f57L,0x2c58f6b4L,
|
||||
/* 65*/ 0x31043265L,0x0bab8c01L,0xd5492099L,0xacaae619L,0x944ce54aL,
|
||||
/* 70*/ 0xf2d13d39L,0xadd3fc32L,0xcda08a40L,0xe2b0d451L,0x9efe08aeL,
|
||||
/* 75*/ 0xb9d50fd2L,0xea5cd7fdL,0xc9a749ddL,0x13ea2253L,0x832debaaL,
|
||||
/* 80*/ 0x24be640fL,0xe03e926aL,0x29e01cdeL,0x8bf59f18L,0x0f9d00b6L,
|
||||
/* 85*/ 0xe1238b46L,0x1e7d8e34L,0x93619adbL,0x76b32f9fL,0xbd972cecL,
|
||||
/* 90*/ 0xe31fa976L,0xa68fbb10L,0xfb3ba49dL,0x8587c41dL,0xa5add1d0L,
|
||||
/* 95*/ 0xf3cf84bfL,0xd4e11150L,0xd9ffa6bcL,0xc3f6018cL,0xaef10572L,
|
||||
/* 100*/ 0x74a64b2fL,0xe7dc9559L,0x2aae35d5L,0x5b6f587fL,0xa9e353feL,
|
||||
/* 105*/ 0xca4fb674L,0x04ba24a8L,0xe5c6875fL,0xdcbc6266L,0x6bc5c03fL,
|
||||
/* 110*/ 0x661eef02L,0xed740babL,0x058e34e4L,0xb7e946cfL,0x88698125L,
|
||||
/* 115*/ 0x72ec48edL,0xb11073a3L,0xa13485ebL,0xa2a2429cL,0xfa407547L,
|
||||
/* 120*/ 0x50b76713L,0x5418c37dL,0x96192da5L,0x170bb04bL,0x518a021eL,
|
||||
/* 125*/ 0xb0ac13d1L,0x0963fa2aL,0x4a6e10e1L,0x58472bdcL,0xf7f8d962L,
|
||||
/* 130*/ 0x979139eaL,0x8d856538L,0xc0997042L,0x48324d7aL,0x447623cbL,
|
||||
/* 135*/ 0x8cbbe364L,0x6e0c6b0eL,0xd36d63b0L,0x3f244c84L,0x3542c971L,
|
||||
/* 140*/ 0x2b228dc1L,0xcb0325bbL,0xf8c0d6e9L,0xde11066bL,0xa8649327L,
|
||||
/* 145*/ 0xfc31f83eL,0x7dd80406L,0xf916dd61L,0xd89f79d3L,0x615144c2L,
|
||||
/* 150*/ 0xebb45d31L,0x28002958L,0x56890a37L,0xf05b3808L,0x123ae844L,
|
||||
/* 155*/ 0x86839e16L,0x914b0d83L,0xc506b43cL,0xcf3cba5eL,0x7c60f5c9L,
|
||||
/* 160*/ 0x22deb2a0L,0x5d9c2715L,0xc77ba0efL,0x4f45360bL,0xc1017d8bL,
|
||||
/* 165*/ 0xe45adc29L,0xa759909bL,0x412cd293L,0xd7d796b1L,0x00c8ff30L,
|
||||
/* 170*/ 0x23a34a80L,0x4ec15c91L,0x714e78b5L,0x47b9e42eL,0x78f3ea4dL,
|
||||
/* 175*/ 0x7f078f5bL,0x346c593aL,0xa3a87a1aL,0x9bcbfe12L,0x3d439963L,
|
||||
/* 180*/ 0xb2ef6d8eL,0xb8d46028L,0x6c2fd5caL,0x62675256L,0x01f2a2f3L,
|
||||
/* 185*/ 0xbc96ae0aL,0x709a8920L,0xb4146e87L,0x6308b9e2L,0x64bda7baL,
|
||||
/* 190*/ 0xafed6892L,0x6037f2a2L,0xf52969e0L,0x0adb43a6L,0x82811400L,
|
||||
/* 195*/ 0x90d0bdf0L,0x19c9549eL,0x203f6a73L,0x1accaf4fL,0x89714e6dL,
|
||||
/* 200*/ 0x164d4705L,0x67665f07L,0xec206170L,0x0c2182b2L,0xa02b9c81L,
|
||||
/* 205*/ 0x53289722L,0xf6a97686L,0x140e4179L,0x9f778849L,0x9a88e15dL,
|
||||
/* 210*/ 0x25cadb54L,0xd157f36fL,0x32a421c3L,0xb368e98aL,0x5a92cd0dL,
|
||||
/* 215*/ 0x757aa8d4L,0xc20ac278L,0x08b551c7L,0x849491e8L,0x4dc75ad6L,
|
||||
/* 220*/ 0x697c33beL,0xbaf0ca33L,0x46125b4eL,0x59d677b3L,0x30d9c8f2L,
|
||||
/* 225*/ 0xd0af860cL,0x1c7fd0faL,0xfe0ff72cL,0x5c8d6f43L,0x57fdec3bL,
|
||||
/* 230*/ 0x6ab6ad97L,0xd22adf89L,0x18171785L,0x02bfe22dL,0x6db80917L,
|
||||
/* 235*/ 0x80b216afL,0xe85e4f9aL,0x7a1c306eL,0x6fc49bf5L,0x3af7a11cL,
|
||||
/* 240*/ 0x81e215e7L,0x68363fcdL,0x3e9357c8L,0xef52fd55L,0x3b8bab4cL,
|
||||
/* 245*/ 0x3c8cf495L,0xbefceebdL,0xfd25b714L,0xc498d83dL,0x0d2e1a8dL,
|
||||
/* 250*/ 0xe9f966acL,0x0e387445L,0x435419e5L,0x5e7ebec4L,0xaa90b8d9L,
|
||||
/* 255*/ 0xff1a3a96L
|
||||
/* End of S Box 1 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 2 */
|
||||
|
||||
/* 0*/ 0x4a8fe4e3L,0xf27d99cdL,0xd04a40caL,0xcb5ff194L,0x3668275aL,
|
||||
/* 5*/ 0xff4816beL,0xa78b394cL,0x4c6be9dbL,0x4eec38d2L,0x4296ec80L,
|
||||
/* 10*/ 0xcdce96f8L,0x888c2f38L,0xe75508f5L,0x7b916414L,0x060aa14aL,
|
||||
/* 15*/ 0xa214f327L,0xbe608dafL,0x1ebbdec2L,0x61f98ce9L,0xe92156feL,
|
||||
/* 20*/ 0x4f22d7a3L,0x3f76a8d9L,0x559a4b33L,0x38ad2959L,0xf3f17e9eL,
|
||||
/* 25*/ 0x85e1ba91L,0xe5eba6fbL,0x73dcd48cL,0xf5c3ff78L,0x481b6058L,
|
||||
/* 30*/ 0x8a3297f7L,0x8f1f3bf4L,0x93785ab2L,0x477a4a5bL,0x6334eb5dL,
|
||||
/* 35*/ 0x6d251b2eL,0x74a9102dL,0x07e38ffaL,0x915c9c62L,0xccc275eaL,
|
||||
/* 40*/ 0x6be273ecL,0x3ebddd70L,0xd895796cL,0xdc54a91bL,0xc9afdf81L,
|
||||
/* 45*/ 0x23633f73L,0x275119b4L,0xb19f6b67L,0x50756e22L,0x2bb152e2L,
|
||||
/* 50*/ 0x76ea46a2L,0xa353e232L,0x2f596ad6L,0x0b1edb0bL,0x02d3d9a4L,
|
||||
/* 55*/ 0x78b47843L,0x64893e90L,0x40f0caadL,0xf68d3ad7L,0x46fd1707L,
|
||||
/* 60*/ 0x1c9c67efL,0xb5e086deL,0x96ee6ca6L,0x9aa34774L,0x1ba4f48aL,
|
||||
/* 65*/ 0x8d01abfdL,0x183ee1f6L,0x5ff8aa7aL,0x17e4faaeL,0x303983b0L,
|
||||
/* 70*/ 0x6c08668bL,0xd4ac4382L,0xe6c5849fL,0x92fefb53L,0xc1cac4ceL,
|
||||
/* 75*/ 0x43501388L,0x441118cfL,0xec4fb308L,0x53a08e86L,0x9e0fe0c5L,
|
||||
/* 80*/ 0xf91c1525L,0xac45be05L,0xd7987cb5L,0x49ba1487L,0x57938940L,
|
||||
/* 85*/ 0xd5877648L,0xa958727fL,0x58dfe3c3L,0xf436cf77L,0x399e4d11L,
|
||||
/* 90*/ 0xf0a5bfa9L,0xef61a33bL,0xa64cac60L,0x04a8d0baL,0x030dd572L,
|
||||
/* 95*/ 0xb83d320fL,0xcab23045L,0xe366f2f0L,0x815d008dL,0xc897a43aL,
|
||||
/* 100*/ 0x1d352df3L,0xb9cc571dL,0x8bf38744L,0x72209092L,0xeba124ebL,
|
||||
/* 105*/ 0xfb99ce5eL,0x3bb94293L,0x28da549cL,0xaab8a228L,0xa4197785L,
|
||||
/* 110*/ 0x33c70296L,0x25f6259bL,0x5c85da21L,0xdf15bdeeL,0x15b7c7e8L,
|
||||
/* 115*/ 0xe2abef75L,0xfcc19bc1L,0x417ff868L,0x14884434L,0x62825179L,
|
||||
/* 120*/ 0xc6d5c11cL,0x0e4705dcL,0x22700de0L,0xd3d2af18L,0x9be822a0L,
|
||||
/* 125*/ 0x35b669f1L,0xc42bb55cL,0x0a801252L,0x115bf0fcL,0x3cd7d856L,
|
||||
/* 130*/ 0xb43f5f9dL,0xc2306516L,0xa1231c47L,0xf149207eL,0x5209a795L,
|
||||
/* 135*/ 0x34b3ccd8L,0x67aefe54L,0x2c83924eL,0x6662cbacL,0x5eedd161L,
|
||||
/* 140*/ 0x84e681aaL,0x5d57d26bL,0xfa465cc4L,0x7e3ac3a8L,0xbf7c0cc6L,
|
||||
/* 145*/ 0xe18a9aa1L,0xc32f0a6fL,0xb22cc00dL,0x3d280369L,0x994e554fL,
|
||||
/* 150*/ 0x68f480d3L,0xadcff5e6L,0x3a8eb265L,0x83269831L,0xbd568a09L,
|
||||
/* 155*/ 0x4bc8ae6aL,0x69f56d2bL,0x0f17eac8L,0x772eb6c7L,0x9f41343cL,
|
||||
/* 160*/ 0xab1d0742L,0x826a6f50L,0xfea2097cL,0x1912c283L,0xce185899L,
|
||||
/* 165*/ 0xe4444839L,0x2d8635d5L,0x65d0b1ffL,0x865a7f17L,0x326d9fb1L,
|
||||
/* 170*/ 0x59e52820L,0x0090ade1L,0x753c7149L,0x9ddd8b98L,0xa5a691daL,
|
||||
/* 175*/ 0x0d0382bbL,0x8904c930L,0x086cb000L,0x6e69d3bdL,0x24d4e7a7L,
|
||||
/* 180*/ 0x05244fd0L,0x101a5e0cL,0x6a947dcbL,0xe840f77bL,0x7d0c5003L,
|
||||
/* 185*/ 0x7c370f1fL,0x805245edL,0xe05e3d3fL,0x7906880eL,0xbabfcd35L,
|
||||
/* 190*/ 0x1a7ec697L,0x8c052324L,0x0c6ec8dfL,0xd129a589L,0xc7a75b02L,
|
||||
/* 195*/ 0x12d81de7L,0xd9be2a66L,0x1f4263abL,0xde73fdb6L,0x2a00680aL,
|
||||
/* 200*/ 0x56649e36L,0x3133ed55L,0x90fa0bf2L,0x2910a02aL,0x949d9d46L,
|
||||
/* 205*/ 0xa0d1dcddL,0xcfc9b7d4L,0xd2677be5L,0x95cb36b3L,0x13cd9410L,
|
||||
/* 210*/ 0xdbf73313L,0xb7c6e8c0L,0xf781414bL,0x510b016dL,0xb0de1157L,
|
||||
/* 215*/ 0xd6b0f62cL,0xbb074eccL,0x7f1395b7L,0xee792cf9L,0xea6fd63eL,
|
||||
/* 220*/ 0x5bd6938eL,0xaf02fc64L,0xdab57ab8L,0x8edb3784L,0x8716318fL,
|
||||
/* 225*/ 0x164d1a01L,0x26f26141L,0xb372e6b9L,0xf8fc2b06L,0x7ac00e04L,
|
||||
/* 230*/ 0x3727b89aL,0x97e9bca5L,0x9c2a742fL,0xbc3b1f7dL,0x7165b471L,
|
||||
/* 235*/ 0x609b4c29L,0x20925351L,0x5ae72112L,0x454be5d1L,0xc0ffb95fL,
|
||||
/* 240*/ 0xdd0ef919L,0x6f2d70c9L,0x0974c5bfL,0x98aa6263L,0x01d91e4dL,
|
||||
/* 245*/ 0x2184bb6eL,0x70c43c1eL,0x4d435915L,0xae7b8523L,0xb6fb06bcL,
|
||||
/* 250*/ 0x5431ee76L,0xfdbc5d26L,0xed77493dL,0xc5712ee4L,0xa8380437L,
|
||||
/* 255*/ 0x2eef261aL
|
||||
/* End of S Box 2 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 3 */
|
||||
|
||||
/* 0*/ 0x5a79392bL,0xb8af32c2L,0x41f7720aL,0x833a61ecL,0x13dfedacL,
|
||||
/* 5*/ 0xc4990bc4L,0xdc0f54bcL,0xfedd5e88L,0x80da1881L,0x4dea1afdL,
|
||||
/* 10*/ 0xfd402cc6L,0xae67cc7aL,0xc5238525L,0x8ea01254L,0xb56b9bd5L,
|
||||
/* 15*/ 0x862fbd6dL,0xac8575d3L,0x6fba3714L,0xda7ebf46L,0x59cd5238L,
|
||||
/* 20*/ 0x8ac9dbfeL,0x353729fcL,0xe497d7f2L,0xc3ab84e0L,0xf05a114bL,
|
||||
/* 25*/ 0x7b887a75L,0xedc603ddL,0x5e6fe680L,0x2c84b399L,0x884eb1daL,
|
||||
/* 30*/ 0x1cb8c8bfL,0xaa51098aL,0xc862231cL,0x8bac2221L,0x21b387e5L,
|
||||
/* 35*/ 0x208a430dL,0x2a3f0f8bL,0xa5ff9cd2L,0x6012a2eaL,0x147a9ee7L,
|
||||
/* 40*/ 0xf62a501dL,0xb4b2e51aL,0x3ef3484cL,0xc0253c59L,0x2b82b536L,
|
||||
/* 45*/ 0x0aa9696bL,0xbe0c109bL,0xc70b7929L,0xce3e8a19L,0x2f66950eL,
|
||||
/* 50*/ 0x459f1c2cL,0xe68fb93dL,0xa3c3ff3eL,0x62b45c62L,0x300991cbL,
|
||||
/* 55*/ 0x01914c57L,0x7f7bc06aL,0x182831f5L,0xe7b74bcaL,0xfa50f6d0L,
|
||||
/* 60*/ 0x523caa61L,0xe3a7cf05L,0xe9e41311L,0x280a21d1L,0x6a4297e1L,
|
||||
/* 65*/ 0xf24dc67eL,0xfc3189e6L,0xb72bf34fL,0x4b1e67afL,0x543402ceL,
|
||||
/* 70*/ 0x79a59867L,0x0648e02aL,0x00a3ac17L,0xc6208d35L,0x6e7f5f76L,
|
||||
/* 75*/ 0xa45bb4beL,0xf168fa63L,0x3f4125f3L,0xf311406fL,0x02706565L,
|
||||
/* 80*/ 0xbfe58022L,0x0cfcfdd9L,0x0735a7f7L,0x8f049092L,0xd98edc27L,
|
||||
/* 85*/ 0xf5c5d55cL,0xe0f201dbL,0x0dcafc9aL,0x7727fb79L,0xaf43abf4L,
|
||||
/* 90*/ 0x26e938c1L,0x401b26a6L,0x900720faL,0x2752d97bL,0xcff1d1b3L,
|
||||
/* 95*/ 0xa9d9e424L,0x42db99abL,0x6cf8be5fL,0xe82cebe3L,0x3afb733bL,
|
||||
/* 100*/ 0x6b734eb6L,0x1036414aL,0x975f667cL,0x049d6377L,0xba587c60L,
|
||||
/* 105*/ 0xb1d10483L,0xde1aefccL,0x1129d055L,0x72051e91L,0x6946d623L,
|
||||
/* 110*/ 0xf9e86ea7L,0x48768c00L,0xb0166c93L,0x9956bbf0L,0x1f1f6d84L,
|
||||
/* 115*/ 0xfb15e18eL,0x033b495dL,0x56e3362eL,0x4f44c53cL,0x747cba51L,
|
||||
/* 120*/ 0x89d37872L,0x5d9c331bL,0xd2ef9fa8L,0x254917f8L,0x1b106f47L,
|
||||
/* 125*/ 0x37d75553L,0xb3f053b0L,0x7dccd8efL,0xd30eb802L,0x5889f42dL,
|
||||
/* 130*/ 0x610206d7L,0x1a7d34a1L,0x92d87dd8L,0xe5f4a315L,0xd1cf0e71L,
|
||||
/* 135*/ 0xb22dfe45L,0xb901e8ebL,0x0fc0ce5eL,0x2efa60c9L,0x2de74290L,
|
||||
/* 140*/ 0x36d0c906L,0x381c70e4L,0x4c6da5b5L,0x3d81a682L,0x7e381f34L,
|
||||
/* 145*/ 0x396c4f52L,0x95ad5901L,0x1db50c5aL,0x29982e9eL,0x1557689fL,
|
||||
/* 150*/ 0x3471ee42L,0xd7e2f7c0L,0x8795a1e2L,0xbc324d8dL,0xe224c3c8L,
|
||||
/* 155*/ 0x12837e39L,0xcdee3d74L,0x7ad2143fL,0x0e13d40cL,0x78bd4a68L,
|
||||
/* 160*/ 0xa2eb194dL,0xdb9451f9L,0x859b71dcL,0x5c4f5b89L,0xca14a8a4L,
|
||||
/* 165*/ 0xef92f003L,0x16741d98L,0x33aa4444L,0x9e967fbbL,0x092e3020L,
|
||||
/* 170*/ 0xd86a35b8L,0x8cc17b10L,0xe1bf08aeL,0x55693fc5L,0x7680ad13L,
|
||||
/* 175*/ 0x1e6546e8L,0x23b6e7b9L,0xee77a4b2L,0x08ed0533L,0x44fd2895L,
|
||||
/* 180*/ 0xb6393b69L,0x05d6cacfL,0x9819b209L,0xecbbb72fL,0x9a75779cL,
|
||||
/* 185*/ 0xeaec0749L,0x94a65aeeL,0xbdf52dc3L,0xd6a25d04L,0x82008e4eL,
|
||||
/* 190*/ 0xa6de160fL,0x9b036afbL,0x228b3a66L,0x5fb10a70L,0xcc338b58L,
|
||||
/* 195*/ 0x5378a9dfL,0xc908bca9L,0x4959e25bL,0x46909a97L,0x66ae8f6eL,
|
||||
/* 200*/ 0xdd0683e9L,0x65f994b4L,0x6426cda5L,0xc24b8840L,0x32539da0L,
|
||||
/* 205*/ 0x63175650L,0xd0c815ffL,0x50cbc41eL,0xf7c774a3L,0x31b0c231L,
|
||||
/* 210*/ 0x8d0d8116L,0x24bef16cL,0xd555d256L,0xdf47ea8cL,0x6d21eccdL,
|
||||
/* 215*/ 0xa887a012L,0x84542aedL,0xa7b9c1bdL,0x914c1bb1L,0xa0d5b67dL,
|
||||
/* 220*/ 0x438ce937L,0x7030f873L,0x71f6b0c7L,0x574576baL,0xf8bc4541L,
|
||||
/* 225*/ 0x9c61d348L,0x1960579dL,0x17c4daadL,0x96a4cb0bL,0xc193f2f6L,
|
||||
/* 230*/ 0x756eafa2L,0x7c1d2f94L,0xf4fe2b43L,0xcb86e33aL,0xebd4c728L,
|
||||
/* 235*/ 0x9d18ae64L,0x9fe13e30L,0x3ce0f5deL,0xaba1f985L,0xaddc2718L,
|
||||
/* 240*/ 0x68ce6278L,0xd45e241fL,0xa15c82b7L,0x3b2293d4L,0x739edd32L,
|
||||
/* 245*/ 0x674a6bf1L,0x5b5d587fL,0x4772deaaL,0x4a63968fL,0x0be68686L,
|
||||
/* 250*/ 0x513d6426L,0x939a4787L,0xbba89296L,0x4ec20007L,0x818d0d08L,
|
||||
/* 255*/ 0xff64dfd6L
|
||||
/* End of S Box 3 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 4 */
|
||||
|
||||
/* 0*/ 0xcb2297cbL,0xdb48a144L,0xa16cbe4bL,0xbbea1d6cL,0x5af6b6b7L,
|
||||
/* 5*/ 0x8a8110b6L,0xf9236ef9L,0xc98f83e6L,0x0f9c65b8L,0x252d4a89L,
|
||||
/* 10*/ 0xa497f068L,0xa5d7ed2dL,0x94c22845L,0x9da1c8c4L,0xe27c2e2eL,
|
||||
/* 15*/ 0x6e8ba2b4L,0xc3dd17fbL,0x498cd482L,0x0dfe6a9fL,0xb0705829L,
|
||||
/* 20*/ 0x9a1e6dc1L,0xf829717cL,0x07bb8e3aL,0xda3c0b02L,0x1af82fc7L,
|
||||
/* 25*/ 0x73b70955L,0x7a04379cL,0x5ee20a28L,0x83712ae5L,0xf4c47c6dL,
|
||||
/* 30*/ 0xdf72ba56L,0xd794858dL,0x8c0cf709L,0x18f0f390L,0xb6c69b35L,
|
||||
/* 35*/ 0xbf2f01dbL,0x2fa74dcaL,0xd0cd9127L,0xbde66cecL,0x3deebd46L,
|
||||
/* 40*/ 0x57c88fc3L,0xcee1406fL,0x0066385aL,0xf3c3444fL,0x3a79d5d5L,
|
||||
/* 45*/ 0x75751eb9L,0x3e7f8185L,0x521c2605L,0xe1aaab6eL,0x38ebb80fL,
|
||||
/* 50*/ 0xbee7e904L,0x61cb9647L,0xea54904eL,0x05ae00e4L,0x2d7ac65fL,
|
||||
/* 55*/ 0x087751a1L,0xdcd82915L,0x0921ee16L,0xdd86d33bL,0xd6bd491aL,
|
||||
/* 60*/ 0x40fbadf0L,0x4232cbd2L,0x33808d10L,0x39098c42L,0x193f3199L,
|
||||
/* 65*/ 0x0bc1e47aL,0x4a82b149L,0x02b65a8aL,0x104cdc8eL,0x24a8f52cL,
|
||||
/* 70*/ 0x685c6077L,0xc79f95c9L,0x1d11fe50L,0xc08dafcdL,0x7b1a9a03L,
|
||||
/* 75*/ 0x1c1f11d8L,0x84250e7fL,0x979db248L,0xebdc0501L,0xb9553395L,
|
||||
/* 80*/ 0xe3c05ea8L,0xb1e51c4cL,0x13b0e681L,0x3b407766L,0x36db3087L,
|
||||
/* 85*/ 0xee17c9fcL,0x6c53ecf2L,0xadccc58fL,0xc427660bL,0xefd5867dL,
|
||||
/* 90*/ 0x9b6d54a5L,0x6ff1aeffL,0x8e787952L,0x9e2bffe0L,0x8761d034L,
|
||||
/* 95*/ 0xe00bdbadL,0xae99a8d3L,0xcc03f6e2L,0xfd0ed807L,0x0e508ae3L,
|
||||
/* 100*/ 0xb74182abL,0x4349245dL,0xd120a465L,0xb246a641L,0xaf3b7ab0L,
|
||||
/* 105*/ 0x2a6488bbL,0x4b3a0d1fL,0xe7c7e58cL,0x3faff2ebL,0x90445ffdL,
|
||||
/* 110*/ 0xcf38c393L,0x995d07e7L,0xf24f1b36L,0x356f6891L,0x6d6ebcbeL,
|
||||
/* 115*/ 0x8da9e262L,0x50fd520eL,0x5bca9e1eL,0x37472cf3L,0x69075057L,
|
||||
/* 120*/ 0x7ec5fdedL,0x0cab892aL,0xfb2412baL,0x1728debfL,0xa000a988L,
|
||||
/* 125*/ 0xd843ce79L,0x042e20ddL,0x4fe8f853L,0x56659c3cL,0x2739d119L,
|
||||
/* 130*/ 0xa78a6120L,0x80960375L,0x70420611L,0x85e09f78L,0xabd17e96L,
|
||||
/* 135*/ 0x1b513eafL,0x1e01eb63L,0x26ad2133L,0xa890c094L,0x7613cf60L,
|
||||
/* 140*/ 0x817e781bL,0xa39113d7L,0xe957fa58L,0x4131b99eL,0x28b1efdaL,
|
||||
/* 145*/ 0x66acfba7L,0xff68944aL,0x77a44fd1L,0x7f331522L,0x59ffb3faL,
|
||||
/* 150*/ 0xa6df935bL,0xfa12d9dfL,0xc6bf6f3fL,0x89520cf6L,0x659edd6aL,
|
||||
/* 155*/ 0x544da739L,0x8b052538L,0x7c30ea21L,0xc2345525L,0x15927fb2L,
|
||||
/* 160*/ 0x144a436bL,0xba107b8bL,0x1219ac97L,0x06730432L,0x31831ab3L,
|
||||
/* 165*/ 0xc55a5c24L,0xaa0fcd3eL,0xe5606be8L,0x5c88f19bL,0x4c0841eeL,
|
||||
/* 170*/ 0x1fe37267L,0x11f9c4f4L,0x9f1b9daeL,0x864e76d0L,0xe637c731L,
|
||||
/* 175*/ 0xd97d23a6L,0x32f53d5cL,0xb8161980L,0x93fa0f84L,0xcaef0870L,
|
||||
/* 180*/ 0x8874487eL,0x98f2cc73L,0x645fb5c6L,0xcd853659L,0x2062470dL,
|
||||
/* 185*/ 0x16ede8e9L,0x6b06dab5L,0x78b43900L,0xfc95b786L,0x5d8e7de1L,
|
||||
/* 190*/ 0x465b5954L,0xfe7ba014L,0xf7d23f7bL,0x92bc8b18L,0x03593592L,
|
||||
/* 195*/ 0x55cef4f7L,0x74b27317L,0x79de1fc2L,0xc8a0bfbdL,0x229398ccL,
|
||||
/* 200*/ 0x62a602ceL,0xbcb94661L,0x5336d206L,0xd2a375feL,0x6a6ab483L,
|
||||
/* 205*/ 0x4702a5a4L,0xa2e9d73dL,0x23a2e0f1L,0x9189140aL,0x581d18dcL,
|
||||
/* 210*/ 0xb39a922bL,0x82356212L,0xd5f432a9L,0xd356c2a3L,0x5f765b4dL,
|
||||
/* 215*/ 0x450afcc8L,0x4415e137L,0xe8ecdfbcL,0xed0de3eaL,0x60d42b13L,
|
||||
/* 220*/ 0xf13df971L,0x71fc5da2L,0xc1455340L,0xf087742fL,0xf55e5751L,
|
||||
/* 225*/ 0x67b3c1f8L,0xac6b8774L,0x7dcfaaacL,0x95983bc0L,0x489bb0b1L,
|
||||
/* 230*/ 0x2c184223L,0x964b6726L,0x2bd3271cL,0x72266472L,0xded64530L,
|
||||
/* 235*/ 0x0a2aa343L,0xd4f716a0L,0xb4dad6d9L,0x2184345eL,0x512c990cL,
|
||||
/* 240*/ 0x29d92d08L,0x2ebe709aL,0x01144c69L,0x34584b9dL,0xe4634ed6L,
|
||||
/* 245*/ 0xecc963cfL,0x3c6984aaL,0x4ed056efL,0x9ca56976L,0x8f3e80d4L,
|
||||
/* 250*/ 0xb5bae7c5L,0x30b5caf5L,0x63f33a64L,0xa9e4bbdeL,0xf6b82298L,
|
||||
/* 255*/ 0x4d673c1dL
|
||||
/* End of S Box 4 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 5 */
|
||||
|
||||
/* 0*/ 0x4b4f1121L,0xba183081L,0xc784f41fL,0xd17d0bacL,0x083d2267L,
|
||||
/* 5*/ 0x37b1361eL,0x3581ad05L,0xfda2f6bcL,0x1e892cddL,0xb56d3c3aL,
|
||||
/* 10*/ 0x32140e46L,0x138d8aabL,0xe14773d4L,0x5b0e71dfL,0x5d1fe055L,
|
||||
/* 15*/ 0x3fb991d3L,0xf1f46c71L,0xa325988cL,0x10f66e80L,0xb1006348L,
|
||||
/* 20*/ 0x726a9f60L,0x3b67f8baL,0x4e114ef4L,0x05c52115L,0x4c5ca11cL,
|
||||
/* 25*/ 0x99e1efd8L,0x471b83b3L,0xcbf7e524L,0x43ad82f5L,0x690ca93bL,
|
||||
/* 30*/ 0xfaa61bb2L,0x12a832b5L,0xb734f943L,0xbd22aea7L,0x88fec626L,
|
||||
/* 35*/ 0x5e80c3e7L,0xbe3eaf5eL,0x44617652L,0xa5724475L,0xbb3b9695L,
|
||||
/* 40*/ 0x7f3fee8fL,0x964e7debL,0x518c052dL,0x2a0bbc2bL,0xc2175f5cL,
|
||||
/* 45*/ 0x9a7b3889L,0xa70d8d0cL,0xeaccdd29L,0xcccd6658L,0x34bb25e6L,
|
||||
/* 50*/ 0xb8391090L,0xf651356fL,0x52987c9eL,0x0c16c1cdL,0x8e372d3cL,
|
||||
/* 55*/ 0x2fc6ebbdL,0x6e5da3e3L,0xb0e27239L,0x5f685738L,0x45411786L,
|
||||
/* 60*/ 0x067f65f8L,0x61778b40L,0x81ab2e65L,0x14c8f0f9L,0xa6b7b4ceL,
|
||||
/* 65*/ 0x4036eaecL,0xbf62b00aL,0xecfd5e02L,0x045449a6L,0xb20afd28L,
|
||||
/* 70*/ 0x2166d273L,0x0d13a863L,0x89508756L,0xd51a7530L,0x2d653f7aL,
|
||||
/* 75*/ 0x3cdbdbc3L,0x80c9df4fL,0x3d5812d9L,0x53fbb1f3L,0xc0f185c0L,
|
||||
/* 80*/ 0x7a3c3d7eL,0x68646410L,0x857607a0L,0x1d12622eL,0x97f33466L,
|
||||
/* 85*/ 0xdb4c9917L,0x6469607cL,0x566e043dL,0x79ef1edbL,0x2c05898dL,
|
||||
/* 90*/ 0xc9578e25L,0xcd380101L,0x46e04377L,0x7d1cc7a9L,0x6552b837L,
|
||||
/* 95*/ 0x20192608L,0xb97500c5L,0xed296b44L,0x368648b4L,0x62995cd5L,
|
||||
/* 100*/ 0x82731400L,0xf9aebd8bL,0x3844c0c7L,0x7c2de794L,0x33a1a770L,
|
||||
/* 105*/ 0x8ae528c2L,0x5a2be812L,0x1f8f4a07L,0x2b5ed7caL,0x937eb564L,
|
||||
/* 110*/ 0x6fda7e11L,0xe49b5d6cL,0xb4b3244eL,0x18aa53a4L,0x3a061334L,
|
||||
/* 115*/ 0x4d6067a3L,0x83ba5868L,0x9bdf4dfeL,0x7449f261L,0x709f8450L,
|
||||
/* 120*/ 0xcad133cbL,0xde941c3fL,0xf52ae484L,0x781d77edL,0x7e4395f0L,
|
||||
/* 125*/ 0xae103b59L,0x922331bbL,0x42ce50c8L,0xe6f08153L,0xe7d941d0L,
|
||||
/* 130*/ 0x5028ed6bL,0xb3d2c49bL,0xad4d9c3eL,0xd201fb6eL,0xa45bd5beL,
|
||||
/* 135*/ 0xffcb7f4bL,0x579d7806L,0xf821bb5bL,0x59d592adL,0xd0be0c31L,
|
||||
/* 140*/ 0xd4e3b676L,0x0107165aL,0x0fe939d2L,0x49bcaafdL,0x55ffcfe5L,
|
||||
/* 145*/ 0x2ec1f783L,0xf39a09a5L,0x3eb42772L,0x19b55a5dL,0x024a0679L,
|
||||
/* 150*/ 0x8c83b3f7L,0x8642ba1dL,0xacacd9eaL,0x87d352c4L,0x60931f45L,
|
||||
/* 155*/ 0xa05f97d7L,0x1cecd42cL,0xe2fcc87bL,0xb60f94e2L,0x67a34b0bL,
|
||||
/* 160*/ 0xfcdd40c9L,0x0b150a27L,0xd3ee9e04L,0x582e29e9L,0x4ac22b41L,
|
||||
/* 165*/ 0x6ac4e1b8L,0xbccaa51aL,0x237af30eL,0xebc3b709L,0xc4a59d19L,
|
||||
/* 170*/ 0x284bc98aL,0xe9d41a93L,0x6bfa2018L,0x73b2d651L,0x11f9a2faL,
|
||||
/* 175*/ 0xce09bff1L,0x41a470aaL,0x25888f22L,0x77e754e8L,0xf7330d8eL,
|
||||
/* 180*/ 0x158eab16L,0xc5d68842L,0xc685a6f6L,0xe5b82fdeL,0x09ea3a96L,
|
||||
/* 185*/ 0x6dde1536L,0x4fa919daL,0x26c0be9fL,0x9eed6f69L,0xf05555f2L,
|
||||
/* 190*/ 0xe06fc285L,0x9cd76d23L,0xaf452a92L,0xefc74cb7L,0x9d6b4732L,
|
||||
/* 195*/ 0x8be408eeL,0x22401d0dL,0xee6c459dL,0x7587cb82L,0xe8746862L,
|
||||
/* 200*/ 0x5cbdde87L,0x98794278L,0x31afb94dL,0xc11e0f2fL,0x30e8fc2aL,
|
||||
/* 205*/ 0xcf3261efL,0x1a3023e1L,0xaa2f86cfL,0xf202e24aL,0x8d08dcffL,
|
||||
/* 210*/ 0x764837c6L,0xa26374ccL,0x9f7c3e88L,0x949cc57dL,0xdd26a07fL,
|
||||
/* 215*/ 0xc39efab0L,0xc8f879a1L,0xdce67bb9L,0xf4b0a435L,0x912c9ae0L,
|
||||
/* 220*/ 0xd85603e4L,0x953a9bbfL,0xfb8290d6L,0x0aebcd5fL,0x16206a9aL,
|
||||
/* 225*/ 0x6c787a14L,0xd9a0f16aL,0x29bf4f74L,0x8f8bce91L,0x0e5a9354L,
|
||||
/* 230*/ 0xab038cb1L,0x1b8ad11bL,0xe327ff49L,0x0053da20L,0x90cf51dcL,
|
||||
/* 235*/ 0xda92fe6dL,0x0390ca47L,0xa8958097L,0xa9dc5bafL,0x3931e3c1L,
|
||||
/* 240*/ 0x840446b6L,0x63d069fbL,0xd7460299L,0x7124ecd1L,0x0791e613L,
|
||||
/* 245*/ 0x485918fcL,0xd635d04cL,0xdf96ac33L,0x66f2d303L,0x247056aeL,
|
||||
/* 250*/ 0xa1a7b2a8L,0x27d8cc9cL,0x17b6e998L,0x7bf5590fL,0xfe97f557L,
|
||||
/* 255*/ 0x5471d8a2L
|
||||
/* End of S Box 5 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 6 */
|
||||
|
||||
/* 0*/ 0x83a327a1L,0x9f379f51L,0x40a7d007L,0x11307423L,0x224587c1L,
|
||||
/* 5*/ 0xac27d63bL,0x3b7e64eaL,0x2e1cbfa6L,0x09996000L,0x03bc0e2cL,
|
||||
/* 10*/ 0xd4c4478aL,0x4542e0abL,0xfeda26d4L,0xc1d10fcbL,0x8252f596L,
|
||||
/* 15*/ 0x4494eb5cL,0xa362f314L,0xf5ba81fdL,0x75c3a376L,0x4ca214caL,
|
||||
/* 20*/ 0xe164deddL,0x5088fa97L,0x4b0930e0L,0x2fcfb7e8L,0x33a6f4b2L,
|
||||
/* 25*/ 0xc7e94211L,0x2d66c774L,0x43be8baeL,0xc663d445L,0x908eb130L,
|
||||
/* 30*/ 0xf4e3be15L,0x63b9d566L,0x529396b5L,0x1e1be743L,0x4d5ff63fL,
|
||||
/* 35*/ 0x985e4a83L,0x71ab9df7L,0xc516c6f5L,0x85c19ab4L,0x1f4daee4L,
|
||||
/* 40*/ 0xf2973431L,0xb713dc5eL,0x3f2e159aL,0xc824da16L,0x06bf376aL,
|
||||
/* 45*/ 0xb2fe23ecL,0xe39b1c22L,0xf1eecb5fL,0x08e82d52L,0x565686c2L,
|
||||
/* 50*/ 0xab0aea93L,0xfd47219fL,0xebdbabd7L,0x2404a185L,0x8c7312b9L,
|
||||
/* 55*/ 0xa8f2d828L,0x0c8902daL,0x65b42b63L,0xc0bbef62L,0x4e3e4cefL,
|
||||
/* 60*/ 0x788f8018L,0xee1ebab7L,0x93928f9dL,0x683d2903L,0xd3b60689L,
|
||||
/* 65*/ 0xafcb0ddcL,0x88a4c47aL,0xf6dd9c3dL,0x7ea5fca0L,0x8a6d7244L,
|
||||
/* 70*/ 0xbe11f120L,0x04ff91b8L,0x8d2dc8c0L,0x27f97fdbL,0x7f9e1f47L,
|
||||
/* 75*/ 0x1734f0c7L,0x26f3ed8eL,0x0df8f2bfL,0xb0833d9eL,0xe420a4e5L,
|
||||
/* 80*/ 0xa423cae6L,0x95616772L,0x9ae6c049L,0x075941f2L,0xd8e12812L,
|
||||
/* 85*/ 0x000f6f4fL,0x3c0d6b05L,0x6cef921cL,0xb82bc264L,0x396cb008L,
|
||||
/* 90*/ 0x5d608a6fL,0x6d7782c8L,0x186550aaL,0x6b6fec09L,0x28e70b13L,
|
||||
/* 95*/ 0x57ce5688L,0xecd3af84L,0x23335a95L,0x91f40cd2L,0x7b6a3b26L,
|
||||
/* 100*/ 0xbd32b3b6L,0x3754a6fbL,0x8ed088f0L,0xf867e87cL,0x20851746L,
|
||||
/* 105*/ 0x6410f9c6L,0x35380442L,0xc2ca10a7L,0x1adea27fL,0x76bddd79L,
|
||||
/* 110*/ 0x92742cf4L,0x0e98f7eeL,0x164e931dL,0xb9c835b3L,0x69060a99L,
|
||||
/* 115*/ 0xb44c531eL,0xfa7b66feL,0xc98a5b53L,0x7d95aae9L,0x302f467bL,
|
||||
/* 120*/ 0x74b811deL,0xf3866abdL,0xb5b3d32dL,0xfc3157a4L,0xd251fe19L,
|
||||
/* 125*/ 0x0b5d8eacL,0xda71ffd5L,0x47ea05a3L,0x05c6a9e1L,0xca0ee958L,
|
||||
/* 130*/ 0x9939034dL,0x25dc5edfL,0x79083cb1L,0x86768450L,0xcf757d6dL,
|
||||
/* 135*/ 0x5972b6bcL,0xa78d59c9L,0xc4ad8d41L,0x2a362ad3L,0xd1179991L,
|
||||
/* 140*/ 0x601407ffL,0xdcf50917L,0x587069d0L,0xe0821ed6L,0xdbb59427L,
|
||||
/* 145*/ 0x73911a4bL,0x7c904fc3L,0x844afb92L,0x6f8c955dL,0xe8c0c5bbL,
|
||||
/* 150*/ 0xb67ab987L,0xa529d96cL,0xf91f7181L,0x618b1b06L,0xe718bb0cL,
|
||||
/* 155*/ 0x8bd7615bL,0xd5a93a59L,0x54aef81bL,0x772136e3L,0xce44fd9cL,
|
||||
/* 160*/ 0x10cda57eL,0x87d66e0bL,0x3d798967L,0x1b2c1804L,0x3edfbd68L,
|
||||
/* 165*/ 0x15f6e62bL,0xef68b854L,0x3896db35L,0x12b7b5e2L,0xcb489029L,
|
||||
/* 170*/ 0x9e4f98a5L,0x62eb77a8L,0x217c24a2L,0x964152f6L,0x49b2080aL,
|
||||
/* 175*/ 0x53d23ee7L,0x48fb6d69L,0x1903d190L,0x9449e494L,0xbf6e7886L,
|
||||
/* 180*/ 0xfb356cfaL,0x3a261365L,0x424bc1ebL,0xa1192570L,0x019ca782L,
|
||||
/* 185*/ 0x9d3f7e0eL,0x9c127575L,0xedf02039L,0xad57bcceL,0x5c153277L,
|
||||
/* 190*/ 0x81a84540L,0xbcaa7356L,0xccd59b60L,0xa62a629bL,0xa25ccd10L,
|
||||
/* 195*/ 0x2b5b65cfL,0x1c535832L,0x55fd4e3aL,0x31d9790dL,0xf06bc37dL,
|
||||
/* 200*/ 0x4afc1d71L,0xaeed5533L,0xba461634L,0xbb694b78L,0x5f3a5c73L,
|
||||
/* 205*/ 0x6a3c764aL,0x8fb0cca9L,0xf725684cL,0x4fe5382fL,0x1d0163afL,
|
||||
/* 210*/ 0x5aa07a8fL,0xe205a8edL,0xc30bad38L,0xff22cf1fL,0x72432e2eL,
|
||||
/* 215*/ 0x32c2518bL,0x3487ce4eL,0x7ae0ac02L,0x709fa098L,0x0a3b395aL,
|
||||
/* 220*/ 0x5b4043f8L,0xa9e48c36L,0x149a8521L,0xd07dee6bL,0x46acd2f3L,
|
||||
/* 225*/ 0x8958dffcL,0xb3a1223cL,0xb11d31c4L,0xcd7f4d3eL,0x0f28e3adL,
|
||||
/* 230*/ 0xe5b100beL,0xaac54824L,0xe9c9d7baL,0x9bd47001L,0x80f149b0L,
|
||||
/* 235*/ 0x66022f0fL,0x020c4048L,0x6efa192aL,0x67073f8dL,0x13ec7bf9L,
|
||||
/* 240*/ 0x3655011aL,0xe6afe157L,0xd9845f6eL,0xdecc4425L,0x511ae2ccL,
|
||||
/* 245*/ 0xdf81b4d8L,0xd7809e55L,0xd6d883d9L,0x2cc7978cL,0x5e787cc5L,
|
||||
/* 250*/ 0xdd0033d1L,0xa050c937L,0x97f75dcdL,0x299de580L,0x41e2b261L,
|
||||
/* 255*/ 0xea5a54f1L
|
||||
/* End of S Box 6 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 7 */
|
||||
|
||||
/* 0*/ 0x7e672590L,0xbea513bbL,0x2c906fe6L,0x86029c2bL,0x55dc4f74L,
|
||||
/* 5*/ 0x0553398eL,0x63e09647L,0xcafd0babL,0x264c37dfL,0x8272210fL,
|
||||
/* 10*/ 0x67afa669L,0x12d98a5fL,0x8cab23c4L,0x75c68bd1L,0xc3370470L,
|
||||
/* 15*/ 0x33f37f4eL,0x283992ffL,0xe73a3a67L,0x1032f283L,0xf5ad9fc2L,
|
||||
/* 20*/ 0x963f0c5dL,0x664fbc45L,0x202ba41cL,0xc7c02d80L,0x54731e84L,
|
||||
/* 25*/ 0x8a1085f5L,0x601d80fbL,0x2f968e55L,0x35e96812L,0xe45a8f78L,
|
||||
/* 30*/ 0xbd7de662L,0x3b6e6eadL,0x8097c5efL,0x070b6781L,0xb1e508f3L,
|
||||
/* 35*/ 0x24e4fae3L,0xb81a7805L,0xec0fc918L,0x43c8774bL,0x9b2512a9L,
|
||||
/* 40*/ 0x2b05ad04L,0x32c2536fL,0xedf236e0L,0x8bc4b0cfL,0xbaceb837L,
|
||||
/* 45*/ 0x4535b289L,0x0d0e94c3L,0xa5a371d0L,0xad695a58L,0x39e3437dL,
|
||||
/* 50*/ 0x9186bffcL,0x21038c3bL,0x0aa9dff9L,0x5d1f06ceL,0x62def8a4L,
|
||||
/* 55*/ 0xf740a2b4L,0xa2575868L,0x682683c1L,0xdbb30facL,0x61fe1928L,
|
||||
/* 60*/ 0x468a6511L,0xc61cd5f4L,0xe54d9800L,0x6b98d7f7L,0x8418b6a5L,
|
||||
/* 65*/ 0x5f09a5d2L,0x90b4e80bL,0x49b2c852L,0x69f11c77L,0x17412b7eL,
|
||||
/* 70*/ 0x7f6fc0edL,0x56838dccL,0x6e9546a2L,0xd0758619L,0x087b9b9aL,
|
||||
/* 75*/ 0xd231a01dL,0xaf46d415L,0x097060fdL,0xd920f657L,0x882d3f9fL,
|
||||
/* 80*/ 0x3ae7c3c9L,0xe8a00d9bL,0x4fe67ebeL,0x2ef80eb2L,0xc1916b0cL,
|
||||
/* 85*/ 0xf4dffea0L,0xb97eb3ebL,0xfdff84ddL,0xff8b14f1L,0xe96b0572L,
|
||||
/* 90*/ 0xf64b508cL,0xae220a6eL,0x4423ae5aL,0xc2bece5eL,0xde27567cL,
|
||||
/* 95*/ 0xfc935c63L,0x47075573L,0xe65b27f0L,0xe121fd22L,0xf2668753L,
|
||||
/* 100*/ 0x2debf5d7L,0x8347e08dL,0xac5eda03L,0x2a7cebe9L,0x3fe8d92eL,
|
||||
/* 105*/ 0x23542fe4L,0x1fa7bd50L,0xcf9b4102L,0x9d0dba39L,0x9cb8902aL,
|
||||
/* 110*/ 0xa7249d8bL,0x0f6d667aL,0x5ebfa9ecL,0x6a594df2L,0x79600938L,
|
||||
/* 115*/ 0x023b7591L,0xea2c79c8L,0xc99d07eaL,0x64cb5ee1L,0x1a9cab3dL,
|
||||
/* 120*/ 0x76db9527L,0xc08e012fL,0x3dfb481aL,0x872f22e7L,0x2948d15cL,
|
||||
/* 125*/ 0xa4782c79L,0x6f50d232L,0x78f0728aL,0x5a87aab1L,0xc4e2c19cL,
|
||||
/* 130*/ 0xee767387L,0x1b2a1864L,0x7b8d10d3L,0xd1713161L,0x0eeac456L,
|
||||
/* 135*/ 0xd8799e06L,0xb645b548L,0x4043cb65L,0xa874fb29L,0x4b12d030L,
|
||||
/* 140*/ 0x7d687413L,0x18ef9a1fL,0xd7631d4cL,0x5829c7daL,0xcdfa30faL,
|
||||
/* 145*/ 0xc5084bb0L,0x92cd20e2L,0xd4c16940L,0x03283ec0L,0xa917813fL,
|
||||
/* 150*/ 0x9a587d01L,0x70041f8fL,0xdc6ab1dcL,0xddaee3d5L,0x31829742L,
|
||||
/* 155*/ 0x198c022dL,0x1c9eafcbL,0x5bbc6c49L,0xd3d3293aL,0x16d50007L,
|
||||
/* 160*/ 0x04bb8820L,0x3c5c2a41L,0x37ee7af8L,0x8eb04025L,0x9313ecbaL,
|
||||
/* 165*/ 0xbffc4799L,0x8955a744L,0xef85d633L,0x504499a7L,0xa6ca6a86L,
|
||||
/* 170*/ 0xbb3d3297L,0xb34a8236L,0x6dccbe4fL,0x06143394L,0xce19fc7bL,
|
||||
/* 175*/ 0xccc3c6c6L,0xe36254aeL,0x77b7eda1L,0xa133dd9eL,0xebf9356aL,
|
||||
/* 180*/ 0x513ccf88L,0xe2a1b417L,0x972ee5bdL,0x853824cdL,0x5752f4eeL,
|
||||
/* 185*/ 0x6c1142e8L,0x3ea4f309L,0xb2b5934aL,0xdfd628aaL,0x59acea3eL,
|
||||
/* 190*/ 0xa01eb92cL,0x389964bcL,0xda305dd4L,0x019a59b7L,0x11d2ca93L,
|
||||
/* 195*/ 0xfaa6d3b9L,0x4e772ecaL,0x72651776L,0xfb4e5b0eL,0xa38f91a8L,
|
||||
/* 200*/ 0x1d0663b5L,0x30f4f192L,0xb50051b6L,0xb716ccb3L,0x4abd1b59L,
|
||||
/* 205*/ 0x146c5f26L,0xf134e2deL,0x00f67c6cL,0xb0e1b795L,0x98aa4ec7L,
|
||||
/* 210*/ 0x0cc73b34L,0x654276a3L,0x8d1ba871L,0x740a5216L,0xe0d01a23L,
|
||||
/* 215*/ 0x9ed161d6L,0x9f36a324L,0x993ebb7fL,0xfeb9491bL,0x365ddcdbL,
|
||||
/* 220*/ 0x810cffc5L,0x71ec0382L,0x2249e7bfL,0x48817046L,0xf3a24a5bL,
|
||||
/* 225*/ 0x4288e4d9L,0x0bf5c243L,0x257fe151L,0x95b64c0dL,0x4164f066L,
|
||||
/* 230*/ 0xaaf7db08L,0x73b1119dL,0x8f9f7bb8L,0xd6844596L,0xf07a34a6L,
|
||||
/* 235*/ 0x53943d0aL,0xf9dd166dL,0x7a8957afL,0xf8ba3ce5L,0x27c9621eL,
|
||||
/* 240*/ 0x5cdae910L,0xc8518998L,0x941538feL,0x136115d8L,0xaba8443cL,
|
||||
/* 245*/ 0x4d01f931L,0x34edf760L,0xb45f266bL,0xd5d4de14L,0x52d8ac35L,
|
||||
/* 250*/ 0x15cfd885L,0xcbc5cd21L,0x4cd76d4dL,0x7c80ef54L,0xbc92ee75L,
|
||||
/* 255*/ 0x1e56a1f6L
|
||||
/* End of S Box 7 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 8 */
|
||||
|
||||
/* 0*/ 0xbaa20b6cL,0x9ffbad26L,0xe1f7d738L,0x794aec8dL,0xc9e9cf3cL,
|
||||
/* 5*/ 0x8a9a7846L,0xc57c4685L,0xb9a92fedL,0x29cb141fL,0x52f9ddb7L,
|
||||
/* 10*/ 0xf68ba6bcL,0x19ccc020L,0x4f584aaaL,0x3bf6a596L,0x003b7cf7L,
|
||||
/* 15*/ 0x54f0ce9aL,0xa7ec4303L,0x46cf0077L,0x78d33aa1L,0x215247d9L,
|
||||
/* 20*/ 0x74bcdf91L,0x08381d30L,0xdac43e40L,0x64872531L,0x0beffe5fL,
|
||||
/* 25*/ 0xb317f457L,0xaebb12daL,0xd5d0d67bL,0x7d75c6b4L,0x42a6d241L,
|
||||
/* 30*/ 0x1502d0a9L,0x3fd97fffL,0xc6c3ed28L,0x81868d0aL,0x92628bc5L,
|
||||
/* 35*/ 0x86679544L,0xfd1867afL,0x5ca3ea61L,0x568d5578L,0x4a2d71f4L,
|
||||
/* 40*/ 0x43c9d549L,0x8d95de2bL,0x6e5c74a0L,0x9120ffc7L,0x0d05d14aL,
|
||||
/* 45*/ 0xa93049d3L,0xbfa80e17L,0xf4096810L,0x043f5ef5L,0xa673b4f1L,
|
||||
/* 50*/ 0x6d780298L,0xa4847783L,0x5ee726fbL,0x9934c281L,0x220a588cL,
|
||||
/* 55*/ 0x384e240fL,0x933d5c69L,0x39e5ef47L,0x26e8b8f3L,0x4c1c6212L,
|
||||
/* 60*/ 0x8040f75dL,0x074b7093L,0x6625a8d7L,0x36298945L,0x76285088L,
|
||||
/* 65*/ 0x651d37c3L,0x24f5274dL,0xdbca3dabL,0x186b7ee1L,0xd80f8182L,
|
||||
/* 70*/ 0x14210c89L,0x943a3075L,0x4e6e11c4L,0x4d7e6badL,0xf05064c8L,
|
||||
/* 75*/ 0x025dcd97L,0x4bc10302L,0x7cede572L,0x8f90a970L,0xab88eebaL,
|
||||
/* 80*/ 0xb5998029L,0x5124d839L,0xb0eeb6a3L,0x89ddabdcL,0xe8074d76L,
|
||||
/* 85*/ 0xa1465223L,0x32518cf2L,0x9d39d4ebL,0xc0d84524L,0xe35e6ea8L,
|
||||
/* 90*/ 0x7abf3804L,0x113e2348L,0x9ae6069dL,0xb4dfdabbL,0xa8c5313fL,
|
||||
/* 95*/ 0x23ea3f79L,0x530e36a2L,0xa5fd228bL,0x95d1d350L,0x2b14cc09L,
|
||||
/* 100*/ 0x40042956L,0x879d05ccL,0x2064b9caL,0xacaca40eL,0xb29c846eL,
|
||||
/* 105*/ 0x9676c9e3L,0x752b7b8aL,0x7be2bcc2L,0x6bd58f5eL,0xd48f4c32L,
|
||||
/* 110*/ 0x606835e4L,0x9cd7c364L,0x2c269b7aL,0x3a0d079cL,0x73b683feL,
|
||||
/* 115*/ 0x45374f1eL,0x10afa242L,0x577f8666L,0xddaa10f6L,0xf34f561cL,
|
||||
/* 120*/ 0x3d355d6bL,0xe47048aeL,0xaa13c492L,0x050344fdL,0x2aab5151L,
|
||||
/* 125*/ 0xf5b26ae5L,0xed919a59L,0x5ac67900L,0xf1cde380L,0x0c79a11bL,
|
||||
/* 130*/ 0x351533fcL,0xcd4d8e36L,0x1f856005L,0x690b9fddL,0xe736dccfL,
|
||||
/* 135*/ 0x1d47bf6aL,0x7f66c72aL,0x85f21b7fL,0x983cbdb6L,0x01ebbebfL,
|
||||
/* 140*/ 0x035f3b99L,0xeb111f34L,0x28cefdc6L,0x5bfc9ecdL,0xf22eacb0L,
|
||||
/* 145*/ 0x9e41cbb2L,0xe0f8327cL,0x82e3e26fL,0xfc43fc86L,0xd0ba66dfL,
|
||||
/* 150*/ 0x489ef2a7L,0xd9e0c81dL,0x68690d52L,0xcc451367L,0xc2232e16L,
|
||||
/* 155*/ 0xe95a7335L,0x0fdae19bL,0xff5b962cL,0x97596527L,0xc46db333L,
|
||||
/* 160*/ 0x3ed4c562L,0xc14c9d9eL,0x5d6faa21L,0x638e940dL,0xf9316d58L,
|
||||
/* 165*/ 0x47b3b0eaL,0x30ffcad2L,0xce1bba7dL,0x1e6108e6L,0x2e1ea33dL,
|
||||
/* 170*/ 0x507bf05bL,0xfafef94bL,0xd17de8e2L,0x5598b214L,0x1663f813L,
|
||||
/* 175*/ 0x17d25a2dL,0xeefa5ff9L,0x582f4e37L,0x12128773L,0xfef17ab8L,
|
||||
/* 180*/ 0x06005322L,0xbb32bbc9L,0x8c898508L,0x592c15f0L,0xd38a4054L,
|
||||
/* 185*/ 0x4957b7d6L,0xd2b891dbL,0x37bd2d3eL,0x34ad20cbL,0x622288e9L,
|
||||
/* 190*/ 0x2dc7345aL,0xafb416c0L,0x1cf459b1L,0xdc7739faL,0x0a711a25L,
|
||||
/* 195*/ 0x13e18a0cL,0x5f72af4cL,0x6ac8db11L,0xbe53c18eL,0x1aa569b9L,
|
||||
/* 200*/ 0xef551ea4L,0xa02a429fL,0xbd16e790L,0x7eb9171aL,0x77d693d8L,
|
||||
/* 205*/ 0x8e06993aL,0x9bde7560L,0xe5801987L,0xc37a09beL,0xb8db76acL,
|
||||
/* 210*/ 0xe2087294L,0x6c81616dL,0xb7f30fe7L,0xbc9b82bdL,0xfba4e4d4L,
|
||||
/* 215*/ 0xc7b1012fL,0xa20c043bL,0xde9febd0L,0x2f9297ceL,0xe610aef8L,
|
||||
/* 220*/ 0x70b06f19L,0xc86ae00bL,0x0e01988fL,0x41192ae0L,0x448c1cb5L,
|
||||
/* 225*/ 0xadbe92eeL,0x7293a007L,0x1b54b5b3L,0xd61f63d1L,0xeae40a74L,
|
||||
/* 230*/ 0x61a72b55L,0xec83a7d5L,0x88942806L,0x90a07da5L,0xd7424b95L,
|
||||
/* 235*/ 0x67745b4eL,0xa31a1853L,0xca6021efL,0xdfb56c4fL,0xcbc2d915L,
|
||||
/* 240*/ 0x3c48e918L,0x8bae3c63L,0x6f659c71L,0xf8b754c1L,0x2782f3deL,
|
||||
/* 245*/ 0xf796f168L,0x71492c84L,0x33c0f5a6L,0x3144f6ecL,0x25dc412eL,
|
||||
/* 250*/ 0xb16c5743L,0x83a1fa7eL,0x0997b101L,0xb627e6e8L,0xcf33905cL,
|
||||
/* 255*/ 0x8456fb65L
|
||||
/* End of S Box 8 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 9 */
|
||||
|
||||
/* 0*/ 0xb29bea74L,0xc35da605L,0x305c1ca3L,0xd2e9f5bcL,0x6fd5bff4L,
|
||||
/* 5*/ 0xff347703L,0xfc45b163L,0xf498e068L,0xb71229fcL,0x81acc3fbL,
|
||||
/* 10*/ 0x78538a8bL,0x984ecf81L,0xa5da47a4L,0x8f259eefL,0x6475dc65L,
|
||||
/* 15*/ 0x081865b9L,0x49e14a3cL,0x19e66079L,0xd382e91bL,0x5b109794L,
|
||||
/* 20*/ 0x3f9f81e1L,0x4470a388L,0x41601abeL,0xaaf9f407L,0x8e175ef6L,
|
||||
/* 25*/ 0xed842297L,0x893a4271L,0x1790839aL,0xd566a99eL,0x6b417deeL,
|
||||
/* 30*/ 0x75c90d23L,0x715edb31L,0x723553f7L,0x9afb50c9L,0xfbc5f600L,
|
||||
/* 35*/ 0xcd3b6a4eL,0x97ed0fbaL,0x29689aecL,0x63135c8eL,0xf0e26c7eL,
|
||||
/* 40*/ 0x0692ae7fL,0xdbb208ffL,0x2ede3e9bL,0x6a65bebdL,0xd40867e9L,
|
||||
/* 45*/ 0xc954afc5L,0x73b08201L,0x7ffdf809L,0x1195c24fL,0x1ca5adcaL,
|
||||
/* 50*/ 0x74bd6d1fL,0xb393c455L,0xcadfd3faL,0x99f13011L,0x0ebca813L,
|
||||
/* 55*/ 0x60e791b8L,0x6597ac7aL,0x18a7e46bL,0x09cb49d3L,0x0b27df6dL,
|
||||
/* 60*/ 0xcfe52f87L,0xcef66837L,0xe6328035L,0xfa87c592L,0x37baff93L,
|
||||
/* 65*/ 0xd71fcc99L,0xdcab205cL,0x4d7a5638L,0x48012510L,0x62797558L,
|
||||
/* 70*/ 0xb6cf1fe5L,0xbc311834L,0x9c2373acL,0x14ec6175L,0xa439cbdfL,
|
||||
/* 75*/ 0x54afb0eaL,0xd686960bL,0xfdd0d47bL,0x7b063902L,0x8b78bac3L,
|
||||
/* 80*/ 0x26c6a4d5L,0x5c0055b6L,0x2376102eL,0x0411783eL,0x2aa3f1cdL,
|
||||
/* 85*/ 0x51fc6ea8L,0x701ce243L,0x9b2a0abbL,0x0ad93733L,0x6e80d03dL,
|
||||
/* 90*/ 0xaf6295d1L,0xf629896fL,0xa30b0648L,0x463d8dd4L,0x963f84cbL,
|
||||
/* 95*/ 0x01ff94f8L,0x8d7fefdcL,0x553611c0L,0xa97c1719L,0xb96af759L,
|
||||
/* 100*/ 0xe0e3c95eL,0x0528335bL,0x21fe5925L,0x821a5245L,0x807238b1L,
|
||||
/* 105*/ 0x67f23db5L,0xea6b4eabL,0x0da6f985L,0xab1bc85aL,0xef8c90e4L,
|
||||
/* 110*/ 0x4526230eL,0x38eb8b1cL,0x1b91cd91L,0x9fce5f0cL,0xf72cc72bL,
|
||||
/* 115*/ 0xc64f2617L,0xdaf7857dL,0x7d373cf1L,0x28eaedd7L,0x203887d0L,
|
||||
/* 120*/ 0xc49a155fL,0xa251b3b0L,0xf2d47ae3L,0x3d9ef267L,0x4a94ab2fL,
|
||||
/* 125*/ 0x7755a222L,0x0205e329L,0xc28fa7a7L,0xaec1fe51L,0x270f164cL,
|
||||
/* 130*/ 0x8c6d01bfL,0x53b5bc98L,0xc09d3febL,0x834986ccL,0x4309a12cL,
|
||||
/* 135*/ 0x578b2a96L,0x3bb74b86L,0x69561b4aL,0x037e32f3L,0xde335b08L,
|
||||
/* 140*/ 0xc5156be0L,0xe7ef09adL,0x93b834c7L,0xa7719352L,0x59302821L,
|
||||
/* 145*/ 0xe3529d26L,0xf961da76L,0xcb142c44L,0xa0f3b98dL,0x76502457L,
|
||||
/* 150*/ 0x945a414bL,0x078eeb12L,0xdff8de69L,0xeb6c8c2dL,0xbda90c4dL,
|
||||
/* 155*/ 0xe9c44d16L,0x168dfd66L,0xad64763bL,0xa65fd764L,0x95a29c06L,
|
||||
/* 160*/ 0x32d7713fL,0x40f0b277L,0x224af08fL,0x004cb5e8L,0x92574814L,
|
||||
/* 165*/ 0x8877d827L,0x3e5b2d04L,0x68c2d5f2L,0x86966273L,0x1d433adaL,
|
||||
/* 170*/ 0x8774988aL,0x3c0e0bfeL,0xddad581dL,0x2fd654edL,0x0f4769fdL,
|
||||
/* 175*/ 0xc181ee9dL,0x5fd88f61L,0x341dbb3aL,0x528543f9L,0xd92235cfL,
|
||||
/* 180*/ 0x1ea82eb4L,0xb5cd790fL,0x91d24f1eL,0xa869e6c2L,0x61f474d2L,
|
||||
/* 185*/ 0xcc205addL,0x0c7bfba9L,0xbf2b0489L,0xb02d72d8L,0x2b46ece6L,
|
||||
/* 190*/ 0xe4dcd90aL,0xb8a11440L,0xee8a63b7L,0x854dd1a1L,0xd1e00583L,
|
||||
/* 195*/ 0x42b40e24L,0x9e8964deL,0xb4b35d78L,0xbec76f6eL,0x24b9c620L,
|
||||
/* 200*/ 0xd8d399a6L,0x5adb2190L,0x2db12730L,0x3a5866afL,0x58c8fadbL,
|
||||
/* 205*/ 0x5d8844e7L,0x8a4bf380L,0x15a01d70L,0x79f5c028L,0x66be3b8cL,
|
||||
/* 210*/ 0xf3e42b53L,0x56990039L,0x2c0c3182L,0x5e16407cL,0xecc04515L,
|
||||
/* 215*/ 0x6c440284L,0x4cb6701aL,0x13bfc142L,0x9d039f6aL,0x4f6e92c8L,
|
||||
/* 220*/ 0xa1407c62L,0x8483a095L,0xc70ae1c4L,0xe20213a2L,0xbacafc41L,
|
||||
/* 225*/ 0x4ecc12b3L,0x4bee3646L,0x1fe807aeL,0x25217f9cL,0x35dde5f5L,
|
||||
/* 230*/ 0x7a7dd6ceL,0xf89cce50L,0xac07b718L,0x7e73d2c6L,0xe563e76cL,
|
||||
/* 235*/ 0x123ca536L,0x3948ca56L,0x9019dd49L,0x10aa88d9L,0xc82451e2L,
|
||||
/* 240*/ 0x473eb6d6L,0x506fe854L,0xe8bb03a5L,0x332f4c32L,0xfe1e1e72L,
|
||||
/* 245*/ 0xb1ae572aL,0x7c0d7bc1L,0xe1c37eb2L,0xf542aa60L,0xf1a48ea0L,
|
||||
/* 250*/ 0xd067b89fL,0xbbfa195dL,0x1a049b0dL,0x315946aaL,0x36d1b447L,
|
||||
/* 255*/ 0x6d2ebdf0L
|
||||
/* End of S Box 9 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 10 */
|
||||
|
||||
/* 0*/ 0x0d188a6dL,0x12cea0dbL,0x7e63740eL,0x6a444821L,0x253d234fL,
|
||||
/* 5*/ 0x6ffc6597L,0x94a6bdefL,0x33ee1b2fL,0x0a6c00c0L,0x3aa336b1L,
|
||||
/* 10*/ 0x5af55d17L,0x265fb3dcL,0x0e89cf4dL,0x0786b008L,0xc80055b8L,
|
||||
/* 15*/ 0x6b17c3ceL,0x72b05a74L,0xd21a8d78L,0xa6b70840L,0xfe8eae77L,
|
||||
/* 20*/ 0xed69565cL,0x55e1bcf4L,0x585c2f60L,0xe06f1a62L,0xad67c0cdL,
|
||||
/* 25*/ 0x7712af88L,0x9cc26acaL,0x1888053dL,0x37eb853eL,0x9215abd7L,
|
||||
/* 30*/ 0xde30adfcL,0x1f1038e6L,0x70c51c8aL,0x8d586c26L,0xf72bdd90L,
|
||||
/* 35*/ 0x4dc3ce15L,0x68eaeefaL,0xd0e9c8b9L,0x200f9c44L,0xddd141baL,
|
||||
/* 40*/ 0x024bf1d3L,0x0f64c9d4L,0xc421e9e9L,0x9d11c14cL,0x9a0dd9e4L,
|
||||
/* 45*/ 0x5f92ec19L,0x1b980df0L,0x1dcc4542L,0xb8fe8c56L,0x0c9c9167L,
|
||||
/* 50*/ 0x4e81eb49L,0xca368f27L,0xe3603b37L,0xea08acccL,0xac516992L,
|
||||
/* 55*/ 0xc34f513bL,0x804d100dL,0x6edca4c4L,0xfc912939L,0x29d219b0L,
|
||||
/* 60*/ 0x278aaa3cL,0x4868da7dL,0x54e890b7L,0xb46d735aL,0x514589aaL,
|
||||
/* 65*/ 0xd6c630afL,0x4980dfe8L,0xbe3ccc55L,0x59d41202L,0x650c078bL,
|
||||
/* 70*/ 0xaf3a9e7bL,0x3ed9827aL,0x9e79fc6eL,0xaadbfbaeL,0xc5f7d803L,
|
||||
/* 75*/ 0x3daf7f50L,0x67b4f465L,0x73406e11L,0x39313f8cL,0x8a6e6686L,
|
||||
/* 80*/ 0xd8075f1fL,0xd3cbfed1L,0x69c7e49cL,0x930581e0L,0xe4b1a5a8L,
|
||||
/* 85*/ 0xbbc45472L,0x09ddbf58L,0xc91d687eL,0xbdbffda5L,0x88c08735L,
|
||||
/* 90*/ 0xe9e36bf9L,0xdb5ea9b6L,0x95559404L,0x08f432fbL,0xe24ea281L,
|
||||
/* 95*/ 0x64663579L,0x000b8010L,0x7914e7d5L,0x32fd0473L,0xd1a7f0a4L,
|
||||
/* 100*/ 0x445ab98eL,0xec72993fL,0xa29a4d32L,0xb77306d8L,0xc7c97cf6L,
|
||||
/* 105*/ 0x7b6ab645L,0xf5ef7adfL,0xfb2e15f7L,0xe747f757L,0x5e944354L,
|
||||
/* 110*/ 0x234a2669L,0x47e46359L,0x9b9d11a9L,0x40762cedL,0x56f1de98L,
|
||||
/* 115*/ 0x11334668L,0x890a9a70L,0x1a296113L,0xb3bd4af5L,0x163b7548L,
|
||||
/* 120*/ 0xd51b4f84L,0xb99b2abcL,0x3cc1dc30L,0xa9f0b56cL,0x812272b2L,
|
||||
/* 125*/ 0x0b233a5fL,0xb650dbf2L,0xf1a0771bL,0x36562b76L,0xdc037b0fL,
|
||||
/* 130*/ 0x104c97ffL,0xc2ec98d2L,0x90596f22L,0x28b6620bL,0xdf42b212L,
|
||||
/* 135*/ 0xfdbc4243L,0xf3fb175eL,0x4a2d8b00L,0xe8f3869bL,0x30d69bc3L,
|
||||
/* 140*/ 0x853714c8L,0xa7751d2eL,0x31e56deaL,0xd4840b0cL,0x9685d783L,
|
||||
/* 145*/ 0x068c9333L,0x8fba032cL,0x76d7bb47L,0x6d0ee22bL,0xb546794bL,
|
||||
/* 150*/ 0xd971b894L,0x8b09d253L,0xa0ad5761L,0xee77ba06L,0x46359f31L,
|
||||
/* 155*/ 0x577cc7ecL,0x52825efdL,0xa4beed95L,0x9825c52aL,0xeb48029aL,
|
||||
/* 160*/ 0xbaae59f8L,0xcf490ee1L,0xbc990164L,0x8ca49dfeL,0x4f38a6e7L,
|
||||
/* 165*/ 0x2ba98389L,0x8228f538L,0x199f64acL,0x01a1cac5L,0xa8b51641L,
|
||||
/* 170*/ 0x5ce72d01L,0x8e5df26bL,0x60f28e1eL,0xcd5be125L,0xe5b376bfL,
|
||||
/* 175*/ 0x1c8d3116L,0x7132cbb3L,0xcb7ae320L,0xc0fa5366L,0xd7653e34L,
|
||||
/* 180*/ 0x971c88c2L,0xc62c7dd0L,0x34d0a3daL,0x868f6709L,0x7ae6fa8fL,
|
||||
/* 185*/ 0x22bbd523L,0x66cd3d5bL,0x1ef9288dL,0xf9cf58c1L,0x5b784e80L,
|
||||
/* 190*/ 0x7439a191L,0xae134c36L,0x9116c463L,0x2e9e1396L,0xf8611f3aL,
|
||||
/* 195*/ 0x2d2f3307L,0x247f37ddL,0xc1e2ff9dL,0x43c821e5L,0x05ed5cabL,
|
||||
/* 200*/ 0xef74e80aL,0x4cca6028L,0xf0ac3cbdL,0x5d874b29L,0x6c62f6a6L,
|
||||
/* 205*/ 0x4b2a2ef3L,0xb1aa2087L,0x62a5d0a3L,0x0327221cL,0xb096b4c6L,
|
||||
/* 210*/ 0x417ec693L,0xaba840d6L,0x789725ebL,0xf4b9e02dL,0xe6e00975L,
|
||||
/* 215*/ 0xcc04961aL,0x63f624bbL,0x7fa21ecbL,0x2c01ea7fL,0xb2415005L,
|
||||
/* 220*/ 0x2a8bbeb5L,0x83b2b14eL,0xa383d1a7L,0x5352f96aL,0x043ecdadL,
|
||||
/* 225*/ 0xce1918a1L,0xfa6be6c9L,0x50def36fL,0xf6b80ce2L,0x4543ef7cL,
|
||||
/* 230*/ 0x9953d651L,0xf257955dL,0x87244914L,0xda1e0a24L,0xffda4785L,
|
||||
/* 235*/ 0x14d327a2L,0x3b93c29fL,0x840684b4L,0x61ab71a0L,0x9f7b784aL,
|
||||
/* 240*/ 0x2fd570cfL,0x15955bdeL,0x38f8d471L,0x3534a718L,0x133fb71dL,
|
||||
/* 245*/ 0x3fd80f52L,0x4290a8beL,0x75ff44c7L,0xa554e546L,0xe1023499L,
|
||||
/* 250*/ 0xbf2652e3L,0x7d20399eL,0xa1df7e82L,0x177092eeL,0x217dd3f1L,
|
||||
/* 255*/ 0x7c1ff8d9L
|
||||
/* End of S Box 10 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 11 */
|
||||
|
||||
/* 0*/ 0x12113f2eL,0xbfbd0785L,0xf11793fbL,0xa5bff566L,0x83c7b0e5L,
|
||||
/* 5*/ 0x72fb316bL,0x75526a9aL,0x41e0e612L,0x7156ba09L,0x53ce7deeL,
|
||||
/* 10*/ 0x0aa26881L,0xa43e0d7dL,0x3da73ca3L,0x182761edL,0xbd5077ffL,
|
||||
/* 15*/ 0x56db4aa0L,0xe792711cL,0xf0a4eb1dL,0x7f878237L,0xec65c4e8L,
|
||||
/* 20*/ 0x08dc8d43L,0x0f8ce142L,0x8258abdaL,0xf4154e16L,0x49dec2fdL,
|
||||
/* 25*/ 0xcd8d5705L,0x6c2c3a0fL,0x5c12bb88L,0xeff3cdb6L,0x2c89ed8cL,
|
||||
/* 30*/ 0x7beba967L,0x2a142157L,0xc6d0836fL,0xb4f97e96L,0x6931e969L,
|
||||
/* 35*/ 0x514e6c7cL,0xa7792600L,0x0bbbf780L,0x59671bbdL,0x0707b676L,
|
||||
/* 40*/ 0x37482d93L,0x80af1479L,0x3805a60dL,0xe1f4cac1L,0x580b3074L,
|
||||
/* 45*/ 0x30b8d6ceL,0x05a304beL,0xd176626dL,0xebca97f3L,0xbb201f11L,
|
||||
/* 50*/ 0x6a1afe23L,0xffaa86e4L,0x62b4da49L,0x1b6629f5L,0xf5d9e092L,
|
||||
/* 55*/ 0xf37f3dd1L,0x619bd45bL,0xa6ec8e4fL,0x29c80939L,0x0c7c0c34L,
|
||||
/* 60*/ 0x9cfe6e48L,0xe65fd3acL,0x73613b65L,0xb3c669f9L,0xbe2e8a9eL,
|
||||
/* 65*/ 0x286f9678L,0x5797fd13L,0x99805d75L,0xcfb641c5L,0xa91074baL,
|
||||
/* 70*/ 0x6343af47L,0x6403cb46L,0x8894c8dbL,0x2663034cL,0x3c40dc5eL,
|
||||
/* 75*/ 0x00995231L,0x96789aa2L,0x2efde4b9L,0x7dc195e1L,0x547dadd5L,
|
||||
/* 80*/ 0x06a8ea04L,0xf2347a63L,0x5e0dc6f7L,0x8462dfc2L,0x1e6b2c3cL,
|
||||
/* 85*/ 0x9bd275b3L,0x91d419e2L,0xbcefd17eL,0xb9003924L,0xd07e7320L,
|
||||
/* 90*/ 0xdef0495cL,0xc36ad00eL,0x1785b1abL,0x92e20bcfL,0xb139f0e9L,
|
||||
/* 95*/ 0x675bb9a1L,0xaecfa4afL,0x132376cbL,0xe84589d3L,0x79a05456L,
|
||||
/* 100*/ 0xa2f860bcL,0x1ae4f8b5L,0x20df4db4L,0xa1e1428bL,0x3bf60a1aL,
|
||||
/* 105*/ 0x27ff7bf1L,0xcb44c0e7L,0xf7f587c4L,0x1f3b9b21L,0x94368f01L,
|
||||
/* 110*/ 0x856e23a4L,0x6f93de3fL,0x773f5bbfL,0x8b22056eL,0xdf41f654L,
|
||||
/* 115*/ 0xb8246ff4L,0x8d57bff2L,0xd57167eaL,0xc5699f22L,0x40734ba7L,
|
||||
/* 120*/ 0x5d5c2772L,0x033020a8L,0xe30a7c4dL,0xadc40fd6L,0x76353441L,
|
||||
/* 125*/ 0x5aa5229bL,0x81516590L,0xda49f14eL,0x4fa672a5L,0x4d9fac5fL,
|
||||
/* 130*/ 0x154be230L,0x8a7a5cc0L,0xce3d2f84L,0xcca15514L,0x5221360cL,
|
||||
/* 135*/ 0xaf0fb81eL,0x5bdd5873L,0xf6825f8fL,0x1113d228L,0x70ad996cL,
|
||||
/* 140*/ 0x93320051L,0x60471c53L,0xe9ba567bL,0x3a462ae3L,0x5f55e72dL,
|
||||
/* 145*/ 0x1d3c5ad7L,0xdcfc45ecL,0x34d812efL,0xfa96ee1bL,0x369d1ef8L,
|
||||
/* 150*/ 0xc9b1a189L,0x7c1d3555L,0x50845edcL,0x4bb31877L,0x8764a060L,
|
||||
/* 155*/ 0x8c9a9415L,0x230e1a3aL,0xb05e9133L,0x242b9e03L,0xa3b99db7L,
|
||||
/* 160*/ 0xc2d7fb0aL,0x3333849dL,0xd27278d4L,0xb5d3efa6L,0x78ac28adL,
|
||||
/* 165*/ 0xc7b2c135L,0x0926ecf0L,0xc1374c91L,0x74f16d98L,0x2274084aL,
|
||||
/* 170*/ 0x3f6d9cfaL,0x7ac0a383L,0xb73aff1fL,0x3909a23dL,0x9f1653aeL,
|
||||
/* 175*/ 0x4e2f3e71L,0xca5ab22aL,0xe01e3858L,0x90c5a7ebL,0x3e4a17dfL,
|
||||
/* 180*/ 0xaa987fb0L,0x488bbd62L,0xb625062bL,0x2d776bb8L,0x43b5fc08L,
|
||||
/* 185*/ 0x1490d532L,0xd6d12495L,0x44e89845L,0x2fe60118L,0x9d9ef950L,
|
||||
/* 190*/ 0xac38133eL,0xd3864329L,0x017b255aL,0xfdc2dd26L,0x256851e6L,
|
||||
/* 195*/ 0x318e7086L,0x2bfa4861L,0x89eac706L,0xee5940c6L,0x68c3bc2fL,
|
||||
/* 200*/ 0xe260334bL,0x98da90bbL,0xf818f270L,0x4706d897L,0x212d3799L,
|
||||
/* 205*/ 0x4cf7e5d0L,0xd9c9649fL,0xa85db5cdL,0x35e90e82L,0x6b881152L,
|
||||
/* 210*/ 0xab1c02c7L,0x46752b02L,0x664f598eL,0x45ab2e64L,0xc4cdb4b2L,
|
||||
/* 215*/ 0xba42107fL,0xea2a808aL,0x971bf3deL,0x4a54a836L,0x4253aeccL,
|
||||
/* 220*/ 0x1029be68L,0x6dcc9225L,0xe4bca56aL,0xc0ae50b1L,0x7e011d94L,
|
||||
/* 225*/ 0xe59c162cL,0xd8e5c340L,0xd470fa0bL,0xb2be79ddL,0xd783889cL,
|
||||
/* 230*/ 0x1cede8f6L,0x8f4c817aL,0xddb785c9L,0x860232d8L,0x198aaad9L,
|
||||
/* 235*/ 0xa0814738L,0x3219cffcL,0x169546d2L,0xfc0cb759L,0x55911510L,
|
||||
/* 240*/ 0x04d5cec3L,0xed08cc3bL,0x0d6cf427L,0xc8e38ccaL,0x0eeee3feL,
|
||||
/* 245*/ 0x9ee7d7c8L,0xf9f24fa9L,0xdb04b35dL,0x9ab0c9e0L,0x651f4417L,
|
||||
/* 250*/ 0x028f8b07L,0x6e28d9aaL,0xfba96319L,0x8ed66687L,0xfecbc58dL,
|
||||
/* 255*/ 0x954ddb44L
|
||||
/* End of S Box 11 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 12 */
|
||||
|
||||
/* 0*/ 0x7b0bdffeL,0x865d16b1L,0x49a058c0L,0x97abaa3fL,0xcaacc75dL,
|
||||
/* 5*/ 0xaba6c17dL,0xf8746f92L,0x6f48aeedL,0x8841d4b5L,0xf36a146aL,
|
||||
/* 10*/ 0x73c390abL,0xe6fb558fL,0x87b1019eL,0x26970252L,0x246377b2L,
|
||||
/* 15*/ 0xcbf676aeL,0xf923db06L,0xf7389116L,0x14c81a90L,0x83114eb4L,
|
||||
/* 20*/ 0x8b137559L,0x95a86a7aL,0xd5b8da8cL,0xc4df780eL,0x5a9cb3e2L,
|
||||
/* 25*/ 0xe44d4062L,0xe8dc8ef6L,0x9d180845L,0x817ad18bL,0xc286c85bL,
|
||||
/* 30*/ 0x251f20deL,0xee6d5933L,0xf6edef81L,0xd4d16c1eL,0xc94a0c32L,
|
||||
/* 35*/ 0x8437fd22L,0x3271ee43L,0x42572aeeL,0x5f91962aL,0x1c522d98L,
|
||||
/* 40*/ 0x59b23f0cL,0xd86b8804L,0x08c63531L,0x2c0d7a40L,0xb97c4729L,
|
||||
/* 45*/ 0x04964df9L,0x13c74a17L,0x5878362fL,0x4c808cd6L,0x092cb1e0L,
|
||||
/* 50*/ 0x6df02885L,0xa0c2105eL,0x8aba9e68L,0x64e03057L,0xe5d61325L,
|
||||
/* 55*/ 0x0e43a628L,0x16dbd62bL,0x2733d90bL,0x3ae57283L,0xc0c1052cL,
|
||||
/* 60*/ 0x4b6fb620L,0x37513953L,0xfc898bb3L,0x471b179fL,0xdf6e66b8L,
|
||||
/* 65*/ 0xd32142f5L,0x9b30fafcL,0x4ed92549L,0x105c6d99L,0x4acd69ffL,
|
||||
/* 70*/ 0x2b1a27d3L,0x6bfcc067L,0x6301a278L,0xad36e6f2L,0xef3ff64eL,
|
||||
/* 75*/ 0x56b3cadbL,0x0184bb61L,0x17beb9fdL,0xfaec6109L,0xa2e1ffa1L,
|
||||
/* 80*/ 0x2fd224f8L,0x238f5be6L,0x8f8570cfL,0xaeb5f25aL,0x4f1d3e64L,
|
||||
/* 85*/ 0x4377eb24L,0x1fa45346L,0xb2056386L,0x52095e76L,0xbb7b5adcL,
|
||||
/* 90*/ 0x3514e472L,0xdde81e6eL,0x7acea9c4L,0xac15cc48L,0x71c97d93L,
|
||||
/* 95*/ 0x767f941cL,0x911052a2L,0xffea09bfL,0xfe3ddcf0L,0x15ebf3aaL,
|
||||
/* 100*/ 0x9235b8bcL,0x75408615L,0x9a723437L,0xe1a1bd38L,0x33541b7eL,
|
||||
/* 105*/ 0x1bdd6856L,0xb307e13eL,0x90814bb0L,0x51d7217bL,0x0bb92219L,
|
||||
/* 110*/ 0x689f4500L,0xc568b01fL,0x5df3d2d7L,0x3c0ecd0dL,0x2a0244c8L,
|
||||
/* 115*/ 0x852574e8L,0xe72f23a9L,0x8e26ed02L,0x2d92cbddL,0xdabc0458L,
|
||||
/* 120*/ 0xcdf5feb6L,0x9e4e8dccL,0xf4f1e344L,0x0d8c436dL,0x4427603bL,
|
||||
/* 125*/ 0xbdd37fdaL,0x80505f26L,0x8c7d2b8eL,0xb73273c5L,0x397362eaL,
|
||||
/* 130*/ 0x618a3811L,0x608bfb88L,0x06f7d714L,0x212e4677L,0x28efceadL,
|
||||
/* 135*/ 0x076c0371L,0x36a3a4d9L,0x5487b455L,0x3429a365L,0x65d467acL,
|
||||
/* 140*/ 0x78ee7eebL,0x99bf12b7L,0x4d129896L,0x772a5601L,0xcce284c7L,
|
||||
/* 145*/ 0x2ed85c21L,0xd099e8a4L,0xa179158aL,0x6ac0ab1aL,0x299a4807L,
|
||||
/* 150*/ 0xbe67a58dL,0xdc19544aL,0xb8949b54L,0x8d315779L,0xb6f849c1L,
|
||||
/* 155*/ 0x53c5ac34L,0x66de92a5L,0xf195dd13L,0x318d3a73L,0x301ec542L,
|
||||
/* 160*/ 0x0cc40da6L,0xf253ade4L,0x467ee566L,0xea5585ecL,0x3baf19bbL,
|
||||
/* 165*/ 0x7de9f480L,0x79006e7cL,0xa9b7a197L,0xa44bd8f1L,0xfb2ba739L,
|
||||
/* 170*/ 0xec342fd4L,0xed4fd32dL,0x3d1789baL,0x400f5d7fL,0xc798f594L,
|
||||
/* 175*/ 0x4506a847L,0x034c0a95L,0xe2162c9dL,0x55a9cfd0L,0x692d832eL,
|
||||
/* 180*/ 0xcf9db2caL,0x5e2287e9L,0xd2610ef3L,0x1ae7ecc2L,0x48399ca0L,
|
||||
/* 185*/ 0xa7e4269bL,0x6ee3a0afL,0x7065bfe1L,0xa6ffe708L,0x2256804cL,
|
||||
/* 190*/ 0x7476e21bL,0x41b0796cL,0x7c243b05L,0x000a950fL,0x1858416bL,
|
||||
/* 195*/ 0xf5a53c89L,0xe9fef823L,0x3f443275L,0xe0cbf091L,0x0af27b84L,
|
||||
/* 200*/ 0x3ebb0f27L,0x1de6f7f4L,0xc31c29f7L,0xb166de3dL,0x12932ec3L,
|
||||
/* 205*/ 0x9c0c0674L,0x5cda81b9L,0xd1bd9d12L,0xaffd7c82L,0x8962bca7L,
|
||||
/* 210*/ 0xa342c4a8L,0x62457151L,0x82089f03L,0xeb49c670L,0x5b5f6530L,
|
||||
/* 215*/ 0x7e28bad2L,0x20880ba3L,0xf0faafcdL,0xce82b56fL,0x0275335cL,
|
||||
/* 220*/ 0xc18e8afbL,0xde601d69L,0xba9b820aL,0xc8a2be4fL,0xd7cac335L,
|
||||
/* 225*/ 0xd9a73741L,0x115e974dL,0x7f5ac21dL,0x383bf9c6L,0xbcaeb75fL,
|
||||
/* 230*/ 0xfd0350ceL,0xb5d06b87L,0x9820e03cL,0x72d5f163L,0xe3644fc9L,
|
||||
/* 235*/ 0xa5464c4bL,0x57048fcbL,0x9690c9dfL,0xdbf9eafaL,0xbff4649aL,
|
||||
/* 240*/ 0x053c00e3L,0xb4b61136L,0x67593dd1L,0x503ee960L,0x9fb4993aL,
|
||||
/* 245*/ 0x19831810L,0xc670d518L,0xb05b51d8L,0x0f3a1ce5L,0x6caa1f9cL,
|
||||
/* 250*/ 0xaacc31beL,0x949ed050L,0x1ead07e7L,0xa8479abdL,0xd6cffcd5L,
|
||||
/* 255*/ 0x936993efL
|
||||
/* End of S Box 12 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 13 */
|
||||
|
||||
/* 0*/ 0x472e91cbL,0x5444b5b6L,0x62be5861L,0x1be102c7L,0x63e4b31eL,
|
||||
/* 5*/ 0xe81f71b7L,0x9e2317c9L,0x39a408aeL,0x518024f4L,0x1731c66fL,
|
||||
/* 10*/ 0x68cbc918L,0x71fb0c9eL,0xd03b7fddL,0x7d6222ebL,0x9057eda3L,
|
||||
/* 15*/ 0x1a34a407L,0x8cc2253dL,0xb6f6979dL,0x835675dcL,0xf319be9fL,
|
||||
/* 20*/ 0xbe1cd743L,0x4d32fee4L,0x77e7d887L,0x37e9ebfdL,0x15f851e8L,
|
||||
/* 25*/ 0x23dc3706L,0x19d78385L,0xbd506933L,0xa13ad4a6L,0x913f1a0eL,
|
||||
/* 30*/ 0xdde560b9L,0x9a5f0996L,0xa65a0435L,0x48d34c4dL,0xe90839a7L,
|
||||
/* 35*/ 0x8abba54eL,0x6fd13ce1L,0xc7eebd3cL,0x0e297602L,0x58b9bbb4L,
|
||||
/* 40*/ 0xef7901e6L,0x64a28a62L,0xa509875aL,0xf8834442L,0x2702c709L,
|
||||
/* 45*/ 0x07353f31L,0x3b39f665L,0xf5b18b49L,0x4010ae37L,0x784de00bL,
|
||||
/* 50*/ 0x7a1121e9L,0xde918ed3L,0xc8529dcdL,0x816a5d05L,0x02ed8298L,
|
||||
/* 55*/ 0x04e3dd84L,0xfd2bc3e2L,0xaf167089L,0x96af367eL,0xa4da6232L,
|
||||
/* 60*/ 0x18ff7325L,0x05f9a9f1L,0x4fefb9f9L,0xcd94eaa5L,0xbfaa5069L,
|
||||
/* 65*/ 0xa0b8c077L,0x60d86f57L,0xfe71c813L,0x29ebd2c8L,0x4ca86538L,
|
||||
/* 70*/ 0x6bf1a030L,0xa237b88aL,0xaa8af41dL,0xe1f7b6ecL,0xe214d953L,
|
||||
/* 75*/ 0x33057879L,0x49caa736L,0xfa45cff3L,0xc063b411L,0xba7e27d0L,
|
||||
/* 80*/ 0x31533819L,0x2a004ac1L,0x210efc3fL,0x2646885eL,0x66727dcfL,
|
||||
/* 85*/ 0x9d7fbf54L,0xa8dd0ea8L,0x3447caceL,0x3f0c14dbL,0xb8382aacL,
|
||||
/* 90*/ 0x4ace3539L,0x0a518d51L,0x95178981L,0x35aee2caL,0x73f0f7e3L,
|
||||
/* 95*/ 0x94281140L,0x59d0e523L,0xd292cb88L,0x565d1b27L,0x7ec8fbafL,
|
||||
/* 100*/ 0x069af08dL,0xc127fd24L,0x0bc77b10L,0x5f03e7efL,0x453e99baL,
|
||||
/* 105*/ 0xeed9ff7fL,0x87b55215L,0x7915ab4cL,0xd389a358L,0x5e75ce6dL,
|
||||
/* 110*/ 0x28d655c0L,0xdad26c73L,0x2e2510ffL,0x9fa7eeccL,0x1d0629c3L,
|
||||
/* 115*/ 0xdc9c9c46L,0x2d67ecd7L,0xe75e94bdL,0x3d649e2aL,0x6c413a2bL,
|
||||
/* 120*/ 0x706f0d7cL,0xdfb0127bL,0x4e366b55L,0x2c825650L,0x24205720L,
|
||||
/* 125*/ 0xb5c998f7L,0x3e95462cL,0x756e5c72L,0x3259488fL,0x11e8771aL,
|
||||
/* 130*/ 0xa7c0a617L,0x577663e5L,0x089b6401L,0x8eab1941L,0xae55ef8cL,
|
||||
/* 135*/ 0x3aac5460L,0xd4e6262fL,0x5d979a47L,0xb19823b0L,0x7f8d6a0cL,
|
||||
/* 140*/ 0xffa08683L,0x0170cd0fL,0x858cd5d8L,0x53961c90L,0xc4c61556L,
|
||||
/* 145*/ 0x41f2f226L,0xcfcd062dL,0xf24c03b8L,0xea81df5bL,0x7be2fa52L,
|
||||
/* 150*/ 0xb361f98bL,0xc2901316L,0x55ba4bbcL,0x93b234a9L,0x0fbc6603L,
|
||||
/* 155*/ 0x80a96822L,0x6d60491fL,0x22bd00f8L,0xbcad5aadL,0x52f3f13bL,
|
||||
/* 160*/ 0x42fd2b28L,0xb41dd01cL,0xc52c93bfL,0xfc663094L,0x8f58d100L,
|
||||
/* 165*/ 0x43fecc08L,0xc6331e5dL,0xe6480f66L,0xca847204L,0x4bdf1da0L,
|
||||
/* 170*/ 0x30cc2efbL,0x13e02deaL,0xfb49ac45L,0xf9d4434fL,0xf47c5b9cL,
|
||||
/* 175*/ 0x148879c2L,0x039fc234L,0xa3db9bfcL,0xd1a1dc5cL,0x763d7cd4L,
|
||||
/* 180*/ 0xed6d2f93L,0xab13af6eL,0x1e8e054aL,0xd68f4f9aL,0xc30484b3L,
|
||||
/* 185*/ 0xd7d50afaL,0x6930855fL,0xcc07db95L,0xce746db1L,0x744e967dL,
|
||||
/* 190*/ 0xf16cf575L,0x8643e8b5L,0xf0eae38eL,0xe52de1d1L,0x6587dae0L,
|
||||
/* 195*/ 0x0c4b8121L,0x1c7ac567L,0xac0db20aL,0x36c3a812L,0x5b1a4514L,
|
||||
/* 200*/ 0xa9a3f868L,0xb9263baaL,0xcb3ce9d2L,0xe44fb1a4L,0x9221bc82L,
|
||||
/* 205*/ 0xb29390feL,0x6ab41863L,0x974a3e2eL,0x89f531c5L,0x255ca13eL,
|
||||
/* 210*/ 0x8b65d348L,0xec248f78L,0xd8fc16f0L,0x50ecdeeeL,0x09010792L,
|
||||
/* 215*/ 0x3c7d1fb2L,0xeba5426bL,0x847b417aL,0x468b40d9L,0x8dc4e680L,
|
||||
/* 220*/ 0x7cc1f391L,0x2f1eb086L,0x6e5baa6aL,0xe0b395daL,0xe31b2cf6L,
|
||||
/* 225*/ 0xd9690b0dL,0x729ec464L,0x38403ddeL,0x610b80a2L,0x5cf433abL,
|
||||
/* 230*/ 0xb0785fc4L,0xd512e4c6L,0xbbb7d699L,0x5a86591bL,0x10cf5376L,
|
||||
/* 235*/ 0x12bf9f4bL,0x980fbaa1L,0x992a4e70L,0x20fa7ae7L,0xf7996ebbL,
|
||||
/* 240*/ 0xc918a2beL,0x82de74f2L,0xad54209bL,0xf66b4d74L,0x1fc5b771L,
|
||||
/* 245*/ 0x169d9229L,0x887761dfL,0x00b667d5L,0xdb425e59L,0xb72f2844L,
|
||||
/* 250*/ 0x9b0ac1f5L,0x9c737e3aL,0x2b85476cL,0x6722add6L,0x44a63297L,
|
||||
/* 255*/ 0x0d688cedL
|
||||
/* End of S Box 13 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 14 */
|
||||
|
||||
/* 0*/ 0xabc59484L,0x4107778aL,0x8ad94c6fL,0xfe83df90L,0x0f64053fL,
|
||||
/* 5*/ 0xd1292e9dL,0xc5744356L,0x8dd1abb4L,0x4c4e7667L,0xfb4a7fc1L,
|
||||
/* 10*/ 0x74f402cbL,0x70f06afdL,0xa82286f2L,0x918dd076L,0x7a97c5ceL,
|
||||
/* 15*/ 0x48f7bde3L,0x6a04d11dL,0xac243ef7L,0x33ac10caL,0x2f7a341eL,
|
||||
/* 20*/ 0x5f75157aL,0xf4773381L,0x591c870eL,0x78df8cc8L,0x22f3adb0L,
|
||||
/* 25*/ 0x251a5993L,0x09fbef66L,0x796942a8L,0x97541d2eL,0x2373daa9L,
|
||||
/* 30*/ 0x1bd2f142L,0xb57e8eb2L,0xe1a5bfdbL,0x7d0efa92L,0xb3442c94L,
|
||||
/* 35*/ 0xd2cb6447L,0x386ac97eL,0x66d61805L,0xbdada15eL,0x11bc1aa7L,
|
||||
/* 40*/ 0x14e9f6eaL,0xe533a0c0L,0xf935ee0aL,0x8fee8a04L,0x810d6d85L,
|
||||
/* 45*/ 0x7c68b6d6L,0x4edc9aa2L,0x956e897dL,0xed87581aL,0x264be9d7L,
|
||||
/* 50*/ 0xff4ddb29L,0x823857c2L,0xe005a9a0L,0xf1cc2450L,0x6f9951e1L,
|
||||
/* 55*/ 0xaade2310L,0xe70c75f5L,0x83e1a31fL,0x4f7dde8eL,0xf723b563L,
|
||||
/* 60*/ 0x368e0928L,0x86362b71L,0x21e8982dL,0xdfb3f92bL,0x44676352L,
|
||||
/* 65*/ 0x99efba31L,0x2eab4e1cL,0xfc6ca5e7L,0x0ebe5d4eL,0xa0717d0cL,
|
||||
/* 70*/ 0xb64f8199L,0x946b31a1L,0x5656cbc6L,0xcffec3efL,0x622766c9L,
|
||||
/* 75*/ 0xfa211e35L,0x52f98b89L,0x6d01674bL,0x4978a802L,0xf651f701L,
|
||||
/* 80*/ 0x15b0d43dL,0xd6ff4683L,0x3463855fL,0x672ba29cL,0xbc128312L,
|
||||
/* 85*/ 0x4626a70dL,0xc8927a5aL,0xb8481cf9L,0x1c962262L,0xa21196baL,
|
||||
/* 90*/ 0xbaba5ee9L,0x5bb162d0L,0x69943bd1L,0x0c47e35cL,0x8cc9619aL,
|
||||
/* 95*/ 0xe284d948L,0x271bf264L,0xc27fb398L,0x4bc70897L,0x60cf202cL,
|
||||
/* 100*/ 0x7f42d6aaL,0xa5a13506L,0x5d3e8860L,0xcea63d3cL,0x63bf0a8fL,
|
||||
/* 105*/ 0xf02e9efaL,0xb17b0674L,0xb072b1d3L,0x06e5723bL,0x3737e436L,
|
||||
/* 110*/ 0x24aa49c7L,0x0ded0d18L,0xdb256b14L,0x58b27877L,0xecb49f54L,
|
||||
/* 115*/ 0x6c40256aL,0x6ea92ffbL,0x3906aa4cL,0xc9866fd5L,0x4549323eL,
|
||||
/* 120*/ 0xa7b85fabL,0x1918cc27L,0x7308d7b5L,0x1e16c7adL,0x71850b37L,
|
||||
/* 125*/ 0x3095fd78L,0xa63b70e6L,0xd880e2aeL,0x3e282769L,0xa39ba6bcL,
|
||||
/* 130*/ 0x98700fa3L,0xf34c53e8L,0x288af426L,0xb99d930fL,0xf5b99df1L,
|
||||
/* 135*/ 0xe9d0c8cfL,0x5ac8405dL,0x50e7217bL,0x511fbbbeL,0x2ca2e639L,
|
||||
/* 140*/ 0xc020301bL,0x356dbc00L,0x8e43ddb9L,0x4d327b4aL,0xf20ff3edL,
|
||||
/* 145*/ 0x1dbb29bdL,0x43d44779L,0xa1b68f70L,0x6114455bL,0xe63d280bL,
|
||||
/* 150*/ 0x6bf6ff65L,0x10fc39e5L,0x3dae126eL,0xc1d7cf11L,0xcb60b795L,
|
||||
/* 155*/ 0x1789d5b3L,0x9bca36b7L,0x08306075L,0x84615608L,0x8b3a0186L,
|
||||
/* 160*/ 0xe88fbecdL,0x7ba47c4dL,0x2de44dacL,0x653fe58dL,0xcca0b968L,
|
||||
/* 165*/ 0xd7fa0e72L,0x93901780L,0x1f2c26ccL,0xae595b6bL,0xa9ecea9bL,
|
||||
/* 170*/ 0xe3dbf8c4L,0x319cc130L,0x12981196L,0x01a3a4deL,0x32c454b6L,
|
||||
/* 175*/ 0x755bd817L,0x3cd871e4L,0xa48bb8daL,0x02fdec09L,0xfd2dc2e2L,
|
||||
/* 180*/ 0x9e578088L,0x9a9f916dL,0x4065fe6cL,0x1853999eL,0xc7793f23L,
|
||||
/* 185*/ 0xdc1016bbL,0x969355ffL,0x7ef292f6L,0xcdce4adcL,0x05e24416L,
|
||||
/* 190*/ 0x85c16c46L,0xd441d37fL,0x57bd6855L,0x8746f54fL,0x9ca773dfL,
|
||||
/* 195*/ 0x770bae22L,0x54828413L,0xb75e4b19L,0x04c35c03L,0xbf7cca07L,
|
||||
/* 200*/ 0x2955c4ddL,0x721db041L,0xb2394f33L,0x03f51387L,0x89b73c9fL,
|
||||
/* 205*/ 0x0b1737f3L,0x07e69024L,0x9231d245L,0x76193861L,0x88159c15L,
|
||||
/* 210*/ 0xdeb552d9L,0xd9767e40L,0x20c6c0c3L,0x4281977cL,0xf8afe1e0L,
|
||||
/* 215*/ 0xd32a0751L,0x3fc27432L,0xddf1dcc5L,0x68581f34L,0x3bcd5025L,
|
||||
/* 220*/ 0x0091b2eeL,0x4aeb6944L,0x1602e743L,0xea09eb58L,0xef0a2a8bL,
|
||||
/* 225*/ 0x641e03a5L,0xeb50e021L,0x5c8ccef8L,0x802ff0b8L,0xd5e3edfeL,
|
||||
/* 230*/ 0xc4dd1b49L,0x5334cd2aL,0x13f82d2fL,0x47450c20L,0x55dafbd2L,
|
||||
/* 235*/ 0xbec0c6f4L,0xb45d7959L,0x3ad36e8cL,0x0aa8ac57L,0x1a3c8d73L,
|
||||
/* 240*/ 0xe45aafb1L,0x9f664838L,0xc6880053L,0xd0039bbfL,0xee5f19ebL,
|
||||
/* 245*/ 0xca0041d8L,0xbbea3aafL,0xda628291L,0x9d5c95d4L,0xadd504a6L,
|
||||
/* 250*/ 0xc39ab482L,0x5e9e14a4L,0x2be065f0L,0x2a13fc3aL,0x9052e8ecL,
|
||||
/* 255*/ 0xaf6f5afcL
|
||||
/* End of S Box 14 */ },
|
||||
|
||||
|
||||
{ /* Start of S Box 15 */
|
||||
|
||||
/* 0*/ 0x519aa8b5L,0xbb303da9L,0xe00e2b10L,0xdfa6c1dbL,0x2e6b952eL,
|
||||
/* 5*/ 0xee10dc23L,0x37936d09L,0x1fc42e92L,0x39b25a9fL,0x13ff89f4L,
|
||||
/* 10*/ 0xc8f53feaL,0x18500bc7L,0x95a0379dL,0x98f751c2L,0x2289c42fL,
|
||||
/* 15*/ 0xa21e4098L,0x6f391f41L,0xf27e7e58L,0x0d0df887L,0x4b79d540L,
|
||||
/* 20*/ 0x8e8409aaL,0x71fe46f8L,0x688a9b29L,0x3f08b548L,0x84abe03aL,
|
||||
/* 25*/ 0x5e91b6c1L,0xfde4c2aeL,0x251d0e72L,0x92d4fee5L,0xf9371967L,
|
||||
/* 30*/ 0x9175108fL,0xe6e81835L,0x8c8cb8eeL,0xb55a67b3L,0xcef138ccL,
|
||||
/* 35*/ 0x8b256268L,0x00d815f5L,0xe8810812L,0x77826189L,0xea73267dL,
|
||||
/* 40*/ 0x19b90f8dL,0x45c33bb4L,0x82477056L,0xe1770075L,0x09467aa6L,
|
||||
/* 45*/ 0xa7c6f54aL,0x79768742L,0x61b86bcaL,0xd6644a44L,0xe33f0171L,
|
||||
/* 50*/ 0xc229fbcdL,0x41b08febL,0xd1903e30L,0x65ec9080L,0x563d6fbdL,
|
||||
/* 55*/ 0xf56da488L,0xebf64cd8L,0x4934426bL,0x7c8592fcL,0x6aca8cf2L,
|
||||
/* 60*/ 0x1cea111bL,0x3a57ee7aL,0xace11c0dL,0x9942d85eL,0xc4613407L,
|
||||
/* 65*/ 0xfa8e643bL,0x327fc701L,0x4ca9be82L,0x3352526dL,0x2c047f63L,
|
||||
/* 70*/ 0xf3a8f7ddL,0x1a4a98a8L,0x762ed4d1L,0x27c75008L,0xbdf497c0L,
|
||||
/* 75*/ 0x7a7b84dfL,0x315c28abL,0x801f93e3L,0xf19b0ca1L,0x8f14e46aL,
|
||||
/* 80*/ 0xe48ba333L,0x9605e625L,0xf03ecb60L,0x60385f2dL,0x902845baL,
|
||||
/* 85*/ 0x7f96d66fL,0x24bff05cL,0x2820730bL,0x947133cbL,0xd444828aL,
|
||||
/* 90*/ 0xb343f6f1L,0x0bef4705L,0x8da574f9L,0x01e25d6cL,0x1732793eL,
|
||||
/* 95*/ 0x4f0f7b27L,0x364b7117L,0xb2d1da77L,0xa6c5f1e9L,0x574ca5b1L,
|
||||
/* 100*/ 0x386a3076L,0xad6894d6L,0x1156d7faL,0xa48d1d9aL,0x4794c0afL,
|
||||
/* 105*/ 0x150c0aa0L,0x26d348acL,0x29fdeabeL,0xa5dede53L,0x81671e8eL,
|
||||
/* 110*/ 0x594ee3bfL,0xa96c56e6L,0x3426a726L,0xc5976579L,0xbc22e5e4L,
|
||||
/* 115*/ 0xc1006319L,0xdaafdd2aL,0xa1a1aa83L,0x3badd0e7L,0xc3b14981L,
|
||||
/* 120*/ 0xd770b155L,0xccd7c693L,0x42e944c5L,0x03e0064fL,0xca95b4efL,
|
||||
/* 125*/ 0x3dee81c3L,0xfbbcd98cL,0x1e07e15bL,0x667ce949L,0xe7d6773fL,
|
||||
/* 130*/ 0x21b6124bL,0x6b2a6ef7L,0xd3278a9cL,0x9a988304L,0x75d2ae9bL,
|
||||
/* 135*/ 0xfe49e2ffL,0x9bc24f46L,0x74cc2cf6L,0xa3139f36L,0x6c9ef35aL,
|
||||
/* 140*/ 0x9fc1dffeL,0x9e5facdcL,0xaadc8bbbL,0x5abdbc5fL,0x44b3b390L,
|
||||
/* 145*/ 0xf754efa7L,0x5fe3bdb7L,0x4e59c886L,0x06a4c984L,0xa0338878L,
|
||||
/* 150*/ 0xcd513cd7L,0x63ebd27eL,0x8aba80adL,0x50da144eL,0x5d9f4e97L,
|
||||
/* 155*/ 0x025b751cL,0x2d580200L,0xb6c05837L,0x580aa15dL,0x54022a6eL,
|
||||
/* 160*/ 0xb41a5415L,0x4863fab6L,0xb0b79957L,0x46d0d159L,0xdc2b8650L,
|
||||
/* 165*/ 0x20a7bb0cL,0x4a032974L,0xec8636a2L,0x8548f24cL,0xf6a2bf16L,
|
||||
/* 170*/ 0x1088f4b0L,0x0c2f3a94L,0x525dc396L,0x14065785L,0x2b4dca52L,
|
||||
/* 175*/ 0x08aeed39L,0xabedfc99L,0xb1dbcf18L,0x87f85bbcL,0xae3aff61L,
|
||||
/* 180*/ 0x433ccd70L,0x5b23cc64L,0x7b453213L,0x5355c545L,0x9318ec0aL,
|
||||
/* 185*/ 0x78692d31L,0x0a21693dL,0xd5666814L,0x05fb59d9L,0xc71985b2L,
|
||||
/* 190*/ 0x2abb8e0eL,0xcf6e6c91L,0xd9cfe7c6L,0xefe7132cL,0x9711ab28L,
|
||||
/* 195*/ 0x3ce52732L,0x12d516d2L,0x7209a0d0L,0xd278d306L,0x70fa4b7bL,
|
||||
/* 200*/ 0x1d407dd3L,0xdb0beba4L,0xbfd97621L,0xa8be21e1L,0x1b6f1b66L,
|
||||
/* 205*/ 0x30650ddaL,0xba7ddbb9L,0x7df953fbL,0x9d1c3902L,0xedf0e8d5L,
|
||||
/* 210*/ 0xb8741ae0L,0x0f240565L,0x62cd438bL,0xc616a924L,0xaf7a96a3L,
|
||||
/* 215*/ 0x35365538L,0xe583af4dL,0x73415eb8L,0x23176a47L,0xfc9ccee8L,
|
||||
/* 220*/ 0x7efc9de2L,0x695e03cfL,0xf8ce66d4L,0x88b4781dL,0x67dd9c03L,
|
||||
/* 225*/ 0x3e8f9e73L,0xc0c95c51L,0xbe314d22L,0x55aa0795L,0xcb1bb011L,
|
||||
/* 230*/ 0xe980fdc8L,0x9c62b7ceL,0xde2d239eL,0x042cadf3L,0xffdf04deL,
|
||||
/* 235*/ 0x5ce6a60fL,0xd8c831edL,0xb7b5b9ecL,0xb9cbf962L,0xe253b254L,
|
||||
/* 240*/ 0x0735ba1fL,0x16ac917fL,0xdd607c2bL,0x64a335c4L,0x40159a7cL,
|
||||
/* 245*/ 0x869222f0L,0x6ef21769L,0x839d20a5L,0xd03b24c9L,0xf412601eL,
|
||||
/* 250*/ 0x6d72a243L,0x0e018dfdL,0x89f3721aL,0xc94f4134L,0x2f992f20L,
|
||||
/* 255*/ 0x4d87253cL
|
||||
/* End of S Box 15 */ }
|
||||
};
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_0.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_HASH_TIGER_H
|
||||
#define PHP_HASH_TIGER_H
|
||||
|
||||
/* TIGER context */
|
||||
typedef struct {
|
||||
php_hash_uint64 state[3];
|
||||
php_hash_uint64 passed;
|
||||
unsigned char passes:1;
|
||||
unsigned char length:7;
|
||||
unsigned char buffer[64];
|
||||
} PHP_TIGER_CTX;
|
||||
|
||||
PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context);
|
||||
PHP_HASH_API void PHP_4TIGERInit(PHP_TIGER_CTX *context);
|
||||
PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *input, size_t len);
|
||||
PHP_HASH_API void PHP_TIGER128Final(unsigned char digest[16], PHP_TIGER_CTX *context);
|
||||
PHP_HASH_API void PHP_TIGER160Final(unsigned char digest[20], PHP_TIGER_CTX *context);
|
||||
PHP_HASH_API void PHP_TIGER192Final(unsigned char digest[24], PHP_TIGER_CTX *context);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
Loaded 100 of 291 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user