2012-11-09 13:08 UTC+0100 Viktor Szakats (vszakats syenar.net)

* contrib/xhb/hbcompat.ch
  * contrib/xhb/htmutil.prg
  * contrib/xhb/stream.prg
  * contrib/xhb/tedit.prg
  * contrib/xhb/tfile.prg
  * contrib/xhb/tframe.prg
  * contrib/xhb/thtm.prg
  * contrib/xhb/trpc.prg
  * contrib/xhb/ttable.prg
  * contrib/xhb/xcstr.prg
  * contrib/xhb/xdbmodst.prg
  * contrib/xhb/xthrow.c
  * extras/httpsrv/modules/cookie.prg
  * extras/httpsrv/modules/info.prg
  * extras/httpsrv/modules/showcounter.prg
  * extras/httpsrv/modules/tableservletdb.prg
  * src/rdd/usrrdd/rdds/arrayrdd.prg
    * cleanups
This commit is contained in:
Viktor Szakats
2012-11-09 12:09:56 +00:00
parent f520d1766c
commit 6b54d5e45d
18 changed files with 109 additions and 129 deletions

View File

@@ -50,13 +50,8 @@
*
*/
#include "hbclass.ch"
MEMVAR _REQUEST
#xcommand TEXT INTO <v> => #pragma __cstream|<v>+=%s
// #pragma escapedstrings = on
FUNCTION HRBMAIN()
LOCAL cHtml := ""
@@ -70,7 +65,7 @@ FUNCTION HRBMAIN()
hb_default( @cAction, "" )
// Sample page embedded
TEXT INTO cHtml
#pragma __cstream | cHtml += %s
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@@ -95,7 +90,7 @@ Pressing button you will redirect to /info page. Look at COOKIE values.
</body>
</html>
ENDTEXT
#pragma __endtext
IF Empty( cAction )
// Set a simple cookie

View File

@@ -50,14 +50,6 @@
*
*/
/*
Show internal variables.
Call it with: /info
*/
#include "hbclass.ch"
MEMVAR _SERVER, _REQUEST, _GET, _POST, _COOKIE, _SESSION, _HTTP_REQUEST, _HTTP_RESPONSE
FUNCTION HRBMAIN()

View File

@@ -78,13 +78,9 @@ FUNCTION HRBMAIN()
uhttpd_SetHeader( "Content-Type", "text/html" )
uhttpd_Write( "<h1>Error: No image created</h1>" )
ENDIF
ELSE
uhttpd_SetHeader( "Content-Type", "text/html" )
uhttpd_Write( "<h1>Error: no parameters passed</h1>" )
ENDIF
RETURN .T.
@@ -93,22 +89,19 @@ STATIC FUNCTION CreateCounter( cValue, cBaseImage )
LOCAL oI, oIDigits, nWidth, nHeight, nDigits, nNumWidth, oTemp
// LOCAL black, white, blue, red, green, cyan, gray
// LOCAL white
#if 0
LOCAL black, white, blue, red, green, cyan, gray
LOCAL white
#endif
LOCAL aNumberImages := {}
LOCAL n, nValue
// LOCAL cFile
// A value if not passed
hb_default( @cValue , Str( hb_RandomInt( 1, 10 ^ DISPLAY_NUM ), DISPLAY_NUM ) )
hb_default( @cValue, Str( hb_RandomInt( 1, 10 ^ DISPLAY_NUM ), DISPLAY_NUM ) )
hb_default( @cBaseImage, "57chevy.gif" )
IF ! hb_FileExists( IMAGES_IN + cBaseImage )
// hb_ToOutDebug( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' not found" )
// THROW( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' not found" )
RETURN NIL
// ELSE
// hb_ToOutDebug( "ERROR: Base Image File '" + IMAGES_IN + cBaseImage + "' FOUND" )
ENDIF
nValue := Val( cValue )
@@ -120,14 +113,14 @@ STATIC FUNCTION CreateCounter( cValue, cBaseImage )
cValue := StrZero( nValue, DISPLAY_NUM )
// ? "Value = ", cValue
#if 0
? "Value = ", cValue
// Check output directory
/*
IF ! hb_DirExists( IMAGES_OUT )
DirMake( IMAGES_OUT )
ENDIF
*/
#endif
/* Load a digits image in memory from file */
oIDigits := GDImage():LoadFromGif( IMAGES_IN + cBaseImage )
@@ -151,12 +144,13 @@ STATIC FUNCTION CreateCounter( cValue, cBaseImage )
ENDCASE
nNumWidth := nWidth / nDigits
// ? "nNumWidth, nWidth, nHeight, nDigits = ", nNumWidth, nWidth, nHeight, nDigits
#if 0
? "nNumWidth, nWidth, nHeight, nDigits = ", nNumWidth, nWidth, nHeight, nDigits
#endif
/* extracts single digits */
FOR n := 1 TO nDigits
oTemp := oIDigits:Copy( ( n - 1 ) * nNumWidth, 0, nNumWidth, nHeight )
// oTemp:SaveGif( IMAGES_OUT + StrZero( n - 1, 2 ) + ".gif" )
// Here I have to clone the image, otherwise on var destruction I loose
// the image in memory
AAdd( aNumberImages, oTemp:Clone() )
@@ -164,20 +158,22 @@ STATIC FUNCTION CreateCounter( cValue, cBaseImage )
/* Create counter image in memory */
oI := GDImage():New( nNumWidth * DISPLAY_NUM, nHeight ) // the counter
// ? "Image dimensions: ", oI:Width(), oI:Height()
#if 0
? "Image dimensions: ", oI:Width(), oI:Height()
/* Allocate background */
// white := oI:SetColor( 255, 255, 255 )
white := oI:SetColor( 255, 255, 255 )
/* Allocate drawing color */
// black := oI:SetColor( 0, 0, 0 )
// blue := oI:SetColor( 0, 0, 255 )
// red := oI:SetColor( 255, 0, 0 )
// green := oI:SetColor( 0, 255, 0 )
// cyan := oI:SetColor( 0, 255, 255 )
black := oI:SetColor( 0, 0, 0 )
blue := oI:SetColor( 0, 0, 255 )
red := oI:SetColor( 255, 0, 0 )
green := oI:SetColor( 0, 255, 0 )
cyan := oI:SetColor( 0, 255, 255 )
/* Draw rectangle */
// oI:Rectangle( 0, 0, 200, 30, , blue )
oI:Rectangle( 0, 0, 200, 30,, blue )
#endif
/* Draw Digits */
FOR n := 1 TO Len( cValue )
@@ -191,18 +187,14 @@ STATIC FUNCTION CreateCounter( cValue, cBaseImage )
oI:Rectangle( ( n - 1 ) * nNumWidth, 0, ( n - 1 ) * nNumWidth + nNumWidth, nHeight, .T., gdTiled )
NEXT
#if 0
/* Write Final Counter Image */
// cFile := "counter" + StrZero( hb_RandomInt( 1, 99 ), 2 ) + ".gif"
// oI:SaveGif( IMAGES_OUT + cFile )
oI:SaveGif( IMAGES_OUT + "counter" + StrZero( hb_RandomInt( 1, 99 ), 2 ) + ".gif" )
/* Destroy images in memory */
// Class does it automatically
// ?
// ? "Look at " + IMAGES_OUT + " folder for output images"
// ?
// RETURN cFile
?
? "Look at " + IMAGES_OUT + " folder for output images"
?
#endif
RETURN oI:ToStringGif()

View File

@@ -61,9 +61,7 @@ FUNCTION HRBMAIN()
LOCAL cXml, cPage, cCount, nCount
LOCAL oTM
LOCAL hGets
hGets := _REQUEST
LOCAL hGets := _REQUEST
hb_default( @hGets, { => } )
@@ -71,15 +69,11 @@ FUNCTION HRBMAIN()
cPage := hGets[ "page" ]
oTM := TableManager():New()
oTM := TableManager():New()
IF oTM:Open()
oTM:Read()
cXml := oTM:getXmlData( Val( cPage ) )
oTM:Close()
ENDIF
ELSEIF hb_HHasKey( hGets, "count" )
@@ -87,37 +81,25 @@ FUNCTION HRBMAIN()
cCount := hGets[ "count" ]
IF cCount == "true"
oTM := TableManager():New()
IF ( oTM:Open() )
IF oTM:Open()
nCount := oTM:getLastRec()
cXml := oTM:getXmlCount( nCount )
oTM:Close()
ENDIF
ENDIF
ENDIF
IF ! Empty( cXml )
uhttpd_SetHeader( "Content-Type", "text/xml" )
// cache control
uhttpd_SetHeader( "Cache-Control", "no-cache, must-revalidate" )
uhttpd_SetHeader( "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" )
uhttpd_Write( cXml )
ELSE
uhttpd_SetHeader( "Content-Type", "text/xml" )
uhttpd_Write( '<?xml version="1.0" encoding="ISO-8859-1"?>' )
uhttpd_Write( "<pages><page>No Data</page></pages>" )
ENDIF
RETURN .T. // I Handle HTML Output
@@ -126,7 +108,7 @@ FUNCTION HRBMAIN()
TableManager
*/
CLASS TableManager
CREATE CLASS TableManager
CLASS VAR ROWS_PER_PAGE INIT 23
@@ -137,8 +119,8 @@ CLASS TableManager
METHOD New()
METHOD Open()
METHOD CLOSE() INLINE iif( ::lOpened, ( table->( dbCloseArea() ), ::lOpened := .F. ), )
METHOD READ()
METHOD Close() INLINE iif( ::lOpened, ( table->( dbCloseArea() ), ::lOpened := .F. ), )
METHOD Read()
METHOD getLastRec() INLINE table->( LastRec() )
METHOD getXmlData( page )
METHOD getXmlCount( ncount )
@@ -169,12 +151,11 @@ METHOD Open() CLASS TableManager
RETURN ::lOpened
METHOD READ() CLASS TableManager
METHOD Read() CLASS TableManager
LOCAL hMap, lOk := .F.
#ifdef SIMULATE_SLOW_REPLY
// force slow connection to simulate long reply
hb_idleSleep( 0.5 )
#endif
@@ -391,12 +372,12 @@ METHOD xmlEncode( input ) CLASS TableManager
RETURN out
CLASS BasicXML
CREATE CLASS BasicXML
VAR aData INIT {}
METHOD New() CONSTRUCTOR
METHOD APPEND( cString ) INLINE AAdd( ::aData, cString )
METHOD append( cString ) INLINE AAdd( ::aData, cString )
METHOD ToString()
ENDCLASS