curl fix
This commit is contained in:
17
libcurl.pbi
17
libcurl.pbi
@@ -1049,19 +1049,24 @@ Procedure.s curlGetData()
|
|||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure.s str2curl(string.s)
|
Procedure.s str2curl(string.s)
|
||||||
Protected *curlstring
|
Protected *curlstring, newstring.s
|
||||||
If *curlstring : FreeMemory(*curlstring) : EndIf
|
|
||||||
*curlstring = AllocateMemory(Len(string) + 1)
|
*curlstring = AllocateMemory(Len(string) + 1)
|
||||||
PokeS(*curlstring,string,-1,#PB_Ascii)
|
If *curlstring
|
||||||
ProcedureReturn PeekS(*curlstring,-1)
|
PokeS(*curlstring,string,-1,#PB_Ascii)
|
||||||
|
newstring = PeekS(*curlstring,-1)
|
||||||
|
FreeMemory(*curlstring)
|
||||||
|
ProcedureReturn newstring
|
||||||
|
Else
|
||||||
|
ProcedureReturn ""
|
||||||
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
; IDE Options = PureBasic 5.40 LTS Beta 5 (Windows - x86)
|
; IDE Options = PureBasic 5.40 LTS Beta 5 (Windows - x86)
|
||||||
; EnableUnicode
|
; EnableUnicode
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; EnableBuildCount = 0
|
; EnableBuildCount = 0
|
||||||
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
|
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
|
||||||
; CursorPosition = 1041
|
; CursorPosition = 1057
|
||||||
; FirstLine = 1003
|
; FirstLine = 1008
|
||||||
; Folding = --
|
; Folding = --
|
||||||
; EnableUnicode
|
; EnableUnicode
|
||||||
; EnableXP
|
; EnableXP
|
27
osm.pb
27
osm.pb
@@ -122,7 +122,8 @@ Module OSM
|
|||||||
|
|
||||||
Moving.i
|
Moving.i
|
||||||
Dirty.i ;To signal that drawing need a refresh
|
Dirty.i ;To signal that drawing need a refresh
|
||||||
;CurlMutex.i ;seems that I can't thread curl ! :(((((
|
CurlMutex.i ;CurlMutex.i ;seems that I can't thread curl ! :(((((
|
||||||
|
|
||||||
List TilesThreads.TileThread()
|
List TilesThreads.TileThread()
|
||||||
|
|
||||||
List track.Location() ;to display a GPX track
|
List track.Location() ;to display a GPX track
|
||||||
@@ -242,7 +243,7 @@ Module OSM
|
|||||||
OSM\ZoomMax = 18
|
OSM\ZoomMax = 18
|
||||||
OSM\MoveStartingPoint\x = - 1
|
OSM\MoveStartingPoint\x = - 1
|
||||||
OSM\TileSize = 256
|
OSM\TileSize = 256
|
||||||
;OSM\CurlMutex = CreateMutex()
|
OSM\CurlMutex = CreateMutex()
|
||||||
OSM\Dirty = #False
|
OSM\Dirty = #False
|
||||||
OSM\Drawing\Mutex = CreateMutex()
|
OSM\Drawing\Mutex = CreateMutex()
|
||||||
OSM\Drawing\Semaphore = CreateSemaphore()
|
OSM\Drawing\Semaphore = CreateSemaphore()
|
||||||
@@ -250,7 +251,7 @@ Module OSM
|
|||||||
OSM\Font=LoadFont(#PB_Any, "Comic Sans MS", 20, #PB_Font_Bold)
|
OSM\Font=LoadFont(#PB_Any, "Comic Sans MS", 20, #PB_Font_Bold)
|
||||||
;- Proxy details
|
;- Proxy details
|
||||||
|
|
||||||
Global Proxy = #False
|
Global Proxy = #True
|
||||||
|
|
||||||
;Use this to customize your preferences
|
;Use this to customize your preferences
|
||||||
; Result = CreatePreferences(GetHomeDirectory() + "OSM.prefs")
|
; Result = CreatePreferences(GetHomeDirectory() + "OSM.prefs")
|
||||||
@@ -448,30 +449,30 @@ Module OSM
|
|||||||
Protected TileURL.s = OSM\ServerURL + Str(Zoom) + "/" + Str(XTile) + "/" + Str(YTile) + ".png"
|
Protected TileURL.s = OSM\ServerURL + Str(Zoom) + "/" + Str(XTile) + "/" + Str(YTile) + ".png"
|
||||||
Protected CacheFile.s = "OSM_" + Str(Zoom) + "_" + Str(XTile) + "_" + Str(YTile) + ".png"
|
Protected CacheFile.s = "OSM_" + Str(Zoom) + "_" + Str(XTile) + "_" + Str(YTile) + ".png"
|
||||||
|
|
||||||
; Debug "Check if we have this image on Web"
|
Debug "Check if we have this image on Web"
|
||||||
|
|
||||||
If Proxy
|
If Proxy
|
||||||
;LockMutex(OSM\CurlMutex) ;Seems no more necessary
|
LockMutex(OSM\CurlMutex) ;Seems no more necessary
|
||||||
*Buffer = CurlReceiveHTTPToMemory(TileURL, ProxyURL$, ProxyPort$, ProxyUser$, ProxyPassword$)
|
*Buffer = CurlReceiveHTTPToMemory(TileURL, ProxyURL$, ProxyPort$, ProxyUser$, ProxyPassword$)
|
||||||
;UnlockMutex(OSM\CurlMutex)
|
UnlockMutex(OSM\CurlMutex)
|
||||||
Else
|
Else
|
||||||
*Buffer = ReceiveHTTPMemory(TileURL) ;TODO to thread by using #PB_HTTP_Asynchronous
|
*Buffer = ReceiveHTTPMemory(TileURL) ;TODO to thread by using #PB_HTTP_Asynchronous
|
||||||
EndIf
|
EndIf
|
||||||
; Debug "Image buffer " + Str(*Buffer)
|
Debug "Image buffer " + Str(*Buffer)
|
||||||
|
|
||||||
If *Buffer
|
If *Buffer
|
||||||
nImage = CatchImage(#PB_Any, *Buffer, MemorySize(*Buffer))
|
nImage = CatchImage(#PB_Any, *Buffer, MemorySize(*Buffer))
|
||||||
If IsImage(nImage)
|
If IsImage(nImage)
|
||||||
; Debug "Load from web " + TileURL + " as Tile nb " + nImage
|
Debug "Load from web " + TileURL + " as Tile nb " + nImage
|
||||||
SaveImage(nImage, OSM\HDDCachePath + CacheFile, #PB_ImagePlugin_PNG)
|
SaveImage(nImage, OSM\HDDCachePath + CacheFile, #PB_ImagePlugin_PNG)
|
||||||
FreeMemory(*Buffer)
|
FreeMemory(*Buffer)
|
||||||
Else
|
Else
|
||||||
; Debug "Can't catch image " + TileURL
|
Debug "Can't catch image " + TileURL
|
||||||
nImage = -1
|
nImage = -1
|
||||||
;ShowMemoryViewer(*Buffer, MemorySize(*Buffer))
|
;ShowMemoryViewer(*Buffer, MemorySize(*Buffer))
|
||||||
EndIf
|
EndIf
|
||||||
Else
|
Else
|
||||||
; Debug "Problem loading from web " + TileURL
|
Debug "Problem loading from web " + TileURL
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
ProcedureReturn nImage
|
ProcedureReturn nImage
|
||||||
@@ -1053,9 +1054,9 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
EndIf
|
EndIf
|
||||||
CompilerEndIf
|
CompilerEndIf
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.42 LTS (Windows - x64)
|
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
|
||||||
; CursorPosition = 883
|
; CursorPosition = 245
|
||||||
; FirstLine = 869
|
; FirstLine = 235
|
||||||
; Folding = -------
|
; Folding = -------
|
||||||
; EnableUnicode
|
; EnableUnicode
|
||||||
; EnableThread
|
; EnableThread
|
||||||
|
Reference in New Issue
Block a user