Und nun noch eine Variante aus der Cloud SDK Suite die SpiderBasic & PureBasic Tauglich ist benötigt aber noch das GEN.pbi für den Debug Bereich...
SYS/GEN/GEN.pbi:
Code: Alles auswählen
;**************************************
;*
;* GEN.pbi
;*
;* Generische Funktionen Makros
;*
;* (c) by Linder Hard- und Software
;*
;This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
;To view a copy of this license,
;visit http://creativecommons.org/licenses/by-sa/4.0/
;OR send a letter To Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
CompilerIf Not Defined(WCS_DEBUG, #PB_Constant)
CompilerError "#WCS_DEBUG Muss Definiert sein"
CompilerEndIf
#Debug_Element = "all"
Macro DebugElement(DebugElements, Lvl)
If #Debug_Element = "all"
CompilerIf #PB_Compiler_OS = #PB_OS_Web
Debug Lvl + DebugElements
CompilerElse
PrintN(Lvl + DebugElements)
CompilerEndIf
ElseIf #Debug_Element = Left(DebugElements, Len(#Debug_Element))
CompilerIf #PB_Compiler_OS = #PB_OS_Web
Debug Lvl + DebugElements
CompilerElse
PrintN(Lvl + DebugElements)
CompilerEndIf
EndIf
EndMacro
Macro DebugLvl0(DebugMSG)
CompilerIf #WCS_DEBUG >= 0
;Debug DebugMSG
DebugElement(DebugMSG , "lvl0:")
CompilerEndIf
EndMacro
Macro DebugLvl1(DebugMSG)
CompilerIf #WCS_DEBUG >= 1
;Debug DebugMSG
DebugElement(DebugMSG , "lvl1:")
CompilerEndIf
EndMacro
Macro DebugLvl2(DebugMSG)
CompilerIf #WCS_DEBUG >= 2
;Debug DebugMSG
DebugElement(DebugMSG , "lvl2:")
CompilerEndIf
EndMacro
Macro DebugLvl3(DebugMSG)
CompilerIf #WCS_DEBUG >= 3
;Debug DebugMSG
DebugElement(DebugMSG , "lvl3:")
CompilerEndIf
EndMacro
SYS/GEN/UUID.pbi
Code: Alles auswählen
;**************************************
;*
;* UUID.pbi
;*
;* (c) by Linder Hard- und Software
;*
;This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
;To view a copy of this license,
;visit http://creativecommons.org/licenses/by-sa/4.0/
;OR send a letter To Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
Enumeration WCS_UUID_Version
#UUID_V1
#UUID_V2
#UUID_V3
#UUID_V4 ; Standard.
#UUID_V5
EndEnumeration
Global WCS_UUID_CryptRandom.i
CompilerIf #PB_Compiler_OS = #PB_OS_Web
WCS_UUID_CryptRandom = 0
CompilerElse
If OpenCryptRandom()
WCS_UUID_CryptRandom = 1
Else
WCS_UUID_CryptRandom = 0
EndIf
CompilerEndIf
Procedure.s CreateUUID(Type.i=#UUID_V4, String.s="")
;[T] CreateUUID(Type.i, String.s="")
;[D] Gibt eine UUID des Entsprechenden Types als String zurück.
;[D] Derzeit nur Version 4 Implementiert.
;[V] 0.0.1
;[M] 0.0.1
Protected P_Type.i = Type.i
Protected P_String.s = String.s
Protected P_UUID.s = ""
Protected Dim P_Numbers.a(16)
;Protected P_Temp.a
Protected P_Count.a
Protected Key
Structure Struc_UUID
low.a
EndStructure
Select P_Type
; Case #UUID_V1
;
; Case #UUID_V2
;
; Case #UUID_V3
;
; Case #UUID_V5
Case 10
Default ;#UUID_V4 RFC 4122 Konform
;xx xx xx xx - xx xx - 4x xx - yx xx - xx xx xx xx xx xx
DebugLvl3("CreateUUID: Start Allocate")
Key = AllocateMemory(16)
;Key = 0
DebugLvl3("CreateUUID: Alocated Address:"+Str(Key))
CompilerIf #PB_Compiler_OS <> #PB_OS_Web
If WCS_UUID_CryptRandom And Key
DebugLvl3("CreateUUID: Randomcrypt.")
CryptRandomData(Key, 16)
For P_Count = 0 To 15
P_Numbers(P_Count) = PeekB(Key+P_Count)
Next P_Count
Else
CompilerElse
If WCS_UUID_CryptRandom = 0
CompilerEndIf
DebugLvl3("CreateUUID: Unsave Random")
For P_Count = 0 To 15
P_Numbers(P_Count) = Random(255)
Next P_Count
EndIf
DebugLvl3("CreateUUID: Memoryfreigabe")
If Key
FreeMemory(Key)
EndIf
DebugLvl3("CreateUUID: P_Numbers")
P_Numbers(6) = Val("$4"+Right(RSet(Hex(P_Numbers(6), #PB_Byte), 2, "0"), 1))
P_Numbers(8) = Val("%10"+Right(RSet(Bin(P_Numbers(8), #PB_Byte), 8, "0"), 6))
DebugLvl3("CreateUUID: Umwandeln zu String")
P_UUID = ""
For P_Count = 0 To 15
If P_Count = 4 Or P_Count = 6 Or P_Count = 8 Or P_Count = 10
P_UUID + "-"
EndIf
P_UUID + RSet(Hex(P_Numbers(P_Count), #PB_Byte), 2, "0")
Next P_Count
EndSelect
DebugLvl3("CreateUUID: Rückgabe:"+P_UUID)
ProcedureReturn P_UUID
EndProcedure
Procedure IsUUID(UUID.s , Type.i = #UUID_V4)
;[T] IsUUID(UUID.s , Type.i = #UUID_V4)
;[D] Prüft ob die UUID entsprechend Version 4 und RFC 4122 Konform ist.
;[V] 0.0.1
;[M] 0.0.1
If Mid(UUID.s, 15,1) = Str(Type+1)
If Left(Bin(Val("$"+Mid(UUID.s, 15,2)), #PB_Byte),2) = "10"
ProcedureReturn #True
EndIf
EndIf
ProcedureReturn #False
EndProcedure
lmon Monitoring Service inkl. Clients
lweb Multi-Threaded Webserver
lbup-server Backup Server applikation
lmanager ERP Applikation.