diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 32e4e0f926..561ee3433a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-15 20:37 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * examples/uhttpd2/uwidgets.prg + * examples/uhttpd2/uhbext.prg + * examples/uhttpd2/app.prg + + examples/uhttpd2/umutex.c + * Embedded C moved to separate file. + % Using Harbour's hb_HGetDef() instead of local version. + 2009-06-15 20:33 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * examples/uhttpd2/socket.c * Minor updates. diff --git a/harbour/examples/uhttpd2/app.prg b/harbour/examples/uhttpd2/app.prg index a0e9310ba9..cb1023883a 100644 --- a/harbour/examples/uhttpd2/app.prg +++ b/harbour/examples/uhttpd2/app.prg @@ -117,9 +117,9 @@ LOCAL cUser, oM, oF, oG ELSEIF cMethod == "POST" DBUSEAREA(.T.,, "users", "users", .T., .T.) OrdSetFocus("user") - cUser := PADR(HGetDef(post, "user", ""), 16) + cUser := PADR(hb_HGetDef(post, "user", ""), 16) IF !EMPTY(cUser) .AND. DBSEEK(cUser, .F.) .AND. ! DELETED() .AND. ; - PADR(HGetDef(post, "password", ""), 16) == FIELD->PASSWORD + PADR(hb_HGetDef(post, "password", ""), 16) == FIELD->PASSWORD session["loggedin"] := cUser URedirect("main") ELSE @@ -157,10 +157,10 @@ LOCAL cUser, cName, cPassword, cPassword2, oM, oF, oG ELSEIF cMethod == "POST" DBUSEAREA(.T.,, "users", "users", .T., .F.) OrdSetFocus("user") - cUser := HGetDef(post, "user", "") - cName := HGetDef(post, "name", "") - cPassword := HGetDef(post, "password", "") - cPassword2 := HGetDef(post, "password2", "") + cUser := hb_HGetDef(post, "user", "") + cName := hb_HGetDef(post, "name", "") + cPassword := hb_HGetDef(post, "password", "") + cPassword2 := hb_HGetDef(post, "password2", "") GetWidgetById("user"):cValue := cUser GetWidgetById("name"):cValue := cName IF EMPTY(cUser) .OR. EMPTY(cName) .OR. EMPTY(cPassword) .OR. EMPTY(cPassword2) @@ -244,9 +244,9 @@ LOCAL cName, cPassword, cPassword2, oM, oG, oF oG:Add( UWSubmitNew("save", "Save"), 5, 2 ) ELSEIF cMethod == "POST" DBSEEK(session["loggedin"], .F.) - cName := HGetDef(post, "name", "") - cPassword := HGetDef(post, "password", "") - cPassword2 := HGetDef(post, "password2", "") + cName := hb_HGetDef(post, "name", "") + cPassword := hb_HGetDef(post, "password", "") + cPassword2 := hb_HGetDef(post, "password2", "") GetWidgetById("name"):cValue := TRIM(cName) IF EMPTY(cName) URedirect("?err=1") diff --git a/harbour/examples/uhttpd2/uhbext.prg b/harbour/examples/uhttpd2/uhbext.prg index 8d56898e85..775eac1380 100644 --- a/harbour/examples/uhttpd2/uhbext.prg +++ b/harbour/examples/uhttpd2/uhbext.prg @@ -9,10 +9,6 @@ *************************************************************/ -FUNC HGetDef(aHash, xKey, xDefault) -RETURN IIF(HB_HHasKey(aHash, xKey), aHash[ xKey ], xDefault) - - FUNC split(cSeparator, cString) LOCAL aRet := {}, nI @@ -37,38 +33,3 @@ LOCAL cRet := "", nI ENDIF NEXT RETURN cRet - - -#pragma begindump -#include "hbapi.h" -#include "hbapiitm.h" -#include "hbthread.h" - -typedef struct _HB_MUTEX -{ - int lock_count; - int lockers; - int waiters; - PHB_ITEM events; - HB_THREAD_ID owner; - HB_RAWCRITICAL_T mutex; - HB_RAWCOND_T cond_l; - HB_RAWCOND_T cond_w; - BOOL fSync; - struct _HB_MUTEX * pNext; - struct _HB_MUTEX * pPrev; -} -HB_MUTEX, * PHB_MUTEX; - - -HB_FUNC( HB_MUTEXWAITERSCOUNT ) -{ - PHB_MUTEX pItem = ( PHB_MUTEX ) hb_param( 1, HB_IT_POINTER ); - - if( pItem ) - hb_retni( ( ( PHB_MUTEX ) hb_itemGetPtr( pItem ) )->waiters ); - else - hb_ret(); -} - -#pragma enddump diff --git a/harbour/examples/uhttpd2/umutex.c b/harbour/examples/uhttpd2/umutex.c new file mode 100644 index 0000000000..e42be082f6 --- /dev/null +++ b/harbour/examples/uhttpd2/umutex.c @@ -0,0 +1,34 @@ +/* + * $Id$ + */ + +#include "hbapi.h" +#include "hbapiitm.h" +#include "hbthread.h" + +typedef struct _HB_MUTEX +{ + int lock_count; + int lockers; + int waiters; + PHB_ITEM events; + HB_THREAD_ID owner; + HB_RAWCRITICAL_T mutex; + HB_RAWCOND_T cond_l; + HB_RAWCOND_T cond_w; + BOOL fSync; + struct _HB_MUTEX * pNext; + struct _HB_MUTEX * pPrev; +} +HB_MUTEX, * PHB_MUTEX; + + +HB_FUNC( HB_MUTEXWAITERSCOUNT ) +{ + PHB_MUTEX pItem = ( PHB_MUTEX ) hb_param( 1, HB_IT_POINTER ); + + if( pItem ) + hb_retni( ( ( PHB_MUTEX ) hb_itemGetPtr( pItem ) )->waiters ); + else + hb_ret(); +} diff --git a/harbour/examples/uhttpd2/uwidgets.prg b/harbour/examples/uhttpd2/uwidgets.prg index f35a14017e..86f7fdb287 100644 --- a/harbour/examples/uhttpd2/uwidgets.prg +++ b/harbour/examples/uhttpd2/uwidgets.prg @@ -431,7 +431,7 @@ LOCAL aStack, aURL, aFrame, cI, nI, nL, lRet ? "cURL:", cURL IF HB_HHasKey(aMap, cURL) // aStack[i] = {url_part, function, variables} - IF (aStack := HGetDef(session, "_ustack")) == NIL + IF (aStack := hb_HGetDef(session, "_ustack")) == NIL session["_ustack"] := aStack := {} ENDIF @@ -496,12 +496,12 @@ RETURN PROC UWDefaultHandler(cMethod) LOCAL cID, oW IF cMethod == "GET" - IF (cID := HGetDef(get, "ajax")) == NIL + IF (cID := hb_HGetDef(get, "ajax")) == NIL session["_uthis", "main"]:Paint() ELSE IF (oW := GetWidgetById(cID)) != NIL UAddHeader("Content-type", "text/html; charset=windows-1257") - oW:Ajax(HGetDef(get, "action")) + oW:Ajax(hb_HGetDef(get, "action")) ENDIF ENDIF ENDIF @@ -517,4 +517,4 @@ RETURN FUNC GetWidgetById(cID) -RETURN HGetDef(session["_uthis", "idhash"], cID) +RETURN hb_HGetDef(session["_uthis", "idhash"], cID)