From 035a2609a8ee30d580026ba0c8b451e781c6e555 Mon Sep 17 00:00:00 2001
From: David <david@xagasoft.com>
Date: Fri, 18 Feb 2011 00:18:21 +0000
Subject: david - working php gats writer/parser, except doesn't do floats yet

---
 php/int.php | 108 ------------------------------------------------------------
 1 file changed, 108 deletions(-)
 delete mode 100644 php/int.php

(limited to 'php/int.php')

diff --git a/php/int.php b/php/int.php
deleted file mode 100644
index 478af73..0000000
--- a/php/int.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-
-/*
-function writeInta( $iIn )
-{
-	$ret = "";
-	if( $iIn < 0 )
-	{
-		$iIn = -$iIn;
-		$b = ($iIn&0x3f);
-		if( $iIn > $b )
-			$b |= 0x80 | 0x40;
-		else
-			$b |= 0x40;
-	}
-	else
-	{
-		$b = ($iIn&0x3f);
-		if( $iIn > $b )
-			$b |= 0x80;
-	}
-
-	$ret .= chr( $b );
-	$iIn = $iIn >> 6;
-
-	while( $iIn > 0 )
-	{
-		$b = ($iIn&0x7f);
-		if( $iIn > $b )
-			$b |= 0x80;
-		$ret .= chr( $b );
-		$iIn = $iIn >> 7;
-	}
-
-	return $ret;
-} */
-
-function writeInt( $iIn )
-{
-	$ret = "";
-	if( gmp_cmp( $iIn, 0 ) < 0 )
-	{
-		$iIn = gmp_mul( $iIn, -1 );
-		$b = gmp_intval( gmp_and( $iIn, 0x3f ) );
-		if( gmp_cmp( $iIn, $b ) > 0 )
-			$b |= 0x80 | 0x40;
-		else
-			$b |= 0x40;
-	}
-	else
-	{
-		$b = gmp_intval( gmp_and( $iIn, 0x3f ) );
-		if( gmp_cmp( $iIn, $b ) > 0 )
-			$b |= 0x80;
-	}
-
-	$ret .= chr( $b );
-	$iIn = gmp_div( $iIn, 64 );
-
-	while( gmp_cmp( $iIn, 0 ) > 0 )
-	{
-		$b = gmp_intval( gmp_and( $iIn, 0x7f ) );
-		if( gmp_cmp( $iIn, $b ) > 0 )
-			$b |= 0x80;
-		$ret .= chr( $b );
-		$iIn = gmp_div( $iIn, 128 );
-	}
-
-	return $ret;
-}
-
-function readInt( $sIn, &$pos )
-{
-	$neg = false;
-
-	$b = ord($sIn[$pos++]);
-	if( ($b&0x40) == 0x40 )
-		$neg = true;
-	$iOut = gmp_init( $b&0x3f );
-	$mult = gmp_init( 64 );
-	while( ($b&0x80) )
-	{
-		$b = ord($sIn[$pos++]);
-		$iOut = gmp_or( $iOut, gmp_mul( $b&0x7f, $mult ) );
-		$mult = gmp_mul( $mult, 128 );
-	}
-	if( $neg == true )
-		$iOut = gmp_mul( $iOut, -1 );
-
-	return $iOut;
-}
-
-function teststr( $str )
-{
-	$pos = 0;
-	$enc = writeInt( $str );
-	$out = gmp_strval( readInt( $enc, $pos ) );
-	print( $str . " => " . $out );
-	if( $out == $str )
-		print(", correct.\n");
-	else
-		print(", incorrect.\n");
-}
-//print( bin2hex( writeInt("3898993999921") ) . "\n" );
-teststr("-7");
-
-
-?>
-- 
cgit v1.2.3