Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

Function GetDriverName
        Push $R1   
                ReadRegStr $R1 HKLM "SOFTWARE\ERG Transit Systems\GUA" DriverName                       
        Exch $R1
FunctionEnd

Function GetDriversODBC
   Push $R1
   StrCpy $0 0
   loop:
                ;lecture de la $0 eme valeur
                EnumRegValue $1 HKLM "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" $0               
                StrCmp $1 "" done
        
                ; on concatene | nompilote
                StrCmp $R1 "" +2
                StrCpy $R1 "$R1|"
                StrCpy $R1 "$R1$1"

                ; on passe a l'indice suivant
                IntOp $0 $0 + 1
                Goto loop
        done:
        ;MessageBox MB_OK|MB_ICONQUESTION "ODBC drivers : $R1"
        Exch $R1
FunctionEnd

; Trim
;   Removes leading & trailing whitespace from a string
; Usage:
;   Push 
;   Call Trim
;   Pop 
Function Trim
        Exch $R1 ; Original string
        Push $R2
 
Loop:
        StrCpy $R2 "$R1" 1
        StrCmp "$R2" " " TrimLeft
        StrCmp "$R2" "$\r" TrimLeft
        StrCmp "$R2" "$\n" TrimLeft
        StrCmp "$R2" "$\t" TrimLeft
        GoTo Loop2
TrimLeft:       
        StrCpy $R1 "$R1" "" 1
        Goto Loop
 
Loop2:
        StrCpy $R2 "$R1" 1 -1
        StrCmp "$R2" " " TrimRight
        StrCmp "$R2" "$\r" TrimRight
        StrCmp "$R2" "$\n" TrimRight
        StrCmp "$R2" "$\t" TrimRight
        GoTo Done
TrimRight:      
        StrCpy $R1 "$R1" -1
        Goto Loop2
 
Done:
        Pop $R2
        Exch $R1
FunctionEnd

;
; Gets the name of the default Oracle Home path in 64 bit env
;
; Usage:
;
;    Call GetOracleDefaultHomePath64
;    Pop $0
;
Function GetOracleDefaultHomePath64
  Push $R1
  Push $R2
        ; parcourir la cle oracle a la recherche de KEY_xxxxx
   StrCpy $0 0
loop:
        ;lecture de la $0 eme valeur
        EnumRegKey $1 HKLM "SOFTWARE\Wow6432Node\ORACLE" $0             
        StrCmp $1 "" bad_home
    
        ; on concatene | nompilote
        StrCpy $R1 "SOFTWARE\Wow6432Node\ORACLE\$1"
        ReadRegStr $R1 HKLM  $R1 "ORACLE_HOME"
        StrCmp $R1 "" +2
        Goto done
        ; on passe a l'indice suivant
        IntOp $0 $0 + 1
        Goto loop
        
bad_home:
  StrCpy $R1 ""

done:
  Pop $R2
  Exch $R1
FunctionEnd

;
; Gets the name of the default Oracle Home path
;
; Usage:
;
;    Call GetOracleDefaultHomePath
;    Pop $0
;
Function GetOracleDefaultHomePath
  Push $R1
  Push $R2
;Wow6432Node 
  ; Get the name of the default home
  ReadRegStr $R1 HKLM "SOFTWARE\ORACLE\OracleMTSRecoveryService\Setup\Current Version" "HOME"
  ReadRegStr $R1 HKLM  $R1 "ORACLE_HOME"
  
  StrCmp $R1 "" GetBis
;VerifHome:
  IfFileExists $R1 0 bad_home
  Goto done
GetBis:
        ; parcourir la cle oracle a la recherche de KEY_xxxxx
   StrCpy $0 0
loop:
        ;lecture de la $0 eme valeur
        EnumRegKey $1 HKLM "SOFTWARE\ORACLE" $0         
        StrCmp $1 "" test64
    
        ; on concatene | nompilote
        StrCpy $R1 "SOFTWARE\ORACLE\$1"
        ;MessageBox MB_OK|MB_ICONQUESTION "ORACLE : $R1"
        ReadRegStr $R1 HKLM  $R1 "ORACLE_HOME"
        ;MessageBox MB_OK|MB_ICONQUESTION "ORACLE : $R1"
        StrCmp $R1 "" +2
        Goto done
        ; on passe a l'indice suivant
        IntOp $0 $0 + 1
        Goto loop
test64:
        Call GetOracleDefaultHomePath64
        Pop $R1
        StrCmp $R1 "" bad_home
        Goto done
bad_home:
  StrCpy $R1 ""

done:
  Pop $R2
  Exch $R1
FunctionEnd

;
; Returns the list of Oracle TNS Connection Names separated by the 
; pipe ("|") symbol, suitable for setting the ListItems attribute 
; in an InstallOptions DropList.
;
; Requires: GetDefaultOracleHomePath
; Requires: Trim
;
; Usage:
;
;    Call GetOracleConnections
;    Pop $0
;
Function GetOracleConnections
    ClearErrors
    Push $R1 ;The connection list
    Push $R2 ;Line read from tnsnames.ora
    Push $R3 ;File handle
    Push $R4 ;Flag indicating whether connection name has been captured
    Push $R5 ;Parentheses count
    Push $R6 ;Current connection name
    Push $R7 ;Character being currently processed
    Push $R8 ;Temp var
 
    StrCpy $R1 ""
    Call GetOracleDefaultHomePath
    Pop $R2
    StrCmp $R2 "" done
 
    ; The path of the TNS names file
    StrCpy $R2 "$R2\network\admin\tnsnames.ora"
 
    ; Open the TNS names file
    StrCpy $R3 ""
    FileOpen $R3 $R2 "r"
    StrCmp $R3 "" fileerror
    ClearErrors
    StrCpy $R1 ""
reset:
    ; Reset variables
    StrCpy $R4 "0"
    StrCpy $R5 "0"
    StrCpy $R6 ""
read:
    ; Read a line from the file
    FileRead $R3 $R2
    StrCmp $R2 "" 0 loop
    IfErrors closefile read
 
    ; Loop through the characters in the line just read
loop:
    StrCpy $R7 $R2 1
    StrCmp $R7 "" read
    StrCpy $R2 $R2 "" 1
    StrCmp $R7 "#" comment
    StrCmp $R7 " " whitespace
    StrCmp $R7 "        " whitespace
    StrCmp $R7 "$\t" whitespace
    StrCmp $R7 "$\r" whitespace
    StrCmp $R7 "$\n" whitespace
    StrCmp $R7 "(" openparen
    StrCmp $R7 ")" closeparen
    StrCmp $R7 "," add
    StrCmp $R7 "=" equal
    StrCmp $R4 "1" loop
append:
    StrCmp $R6 "" blank
    StrCpy $R8 $R6 1 -1
    StrCmp $R8 " " syntaxerror
    StrCmp $R8 "    " syntaxerror
    StrCmp $R8 "$\r" syntaxerror
    StrCmp $R8 "$\n" syntaxerror
blank:
    StrCpy $R6 "$R6$R7"
    GoTo loop
comment:
    StrCmp $R6 "" read
    StrCmp $R4 "1" read syntaxerror
whitespace:
    StrCmp $R6 "" loop
    StrCmp $R4 "1" loop append
equal:
    StrCmp $R4 "1" loop
    StrCpy $R4 "1"
    GoTo loop
openparen:
    StrCmp $R4 "1" 0 syntaxerror
    IntOp $R5 $R5 + 1
    GoTo loop
closeparen:
    StrCmp $R4 "1" 0 syntaxerror
    IntOp $R5 $R5 - 1
    IntCmp $R5 0 0 syntaxerror loop
    Push $R1
    Call Trim
    Pop $R1
    StrCmp $R1 "" +2
    StrCpy $R1 "$R1|"
    StrCpy $R1 "$R1$R6"
    GoTo reset
add:
        StrCpy $R1 "$R1|"
        StrCpy $R1 "$R1$R6"
    StrCpy $R4 "0"
    StrCpy $R5 "0"
    StrCpy $R6 ""
        GoTo loop
 closefile:
    FileClose $R3
    GoTo done
fileerror:
    MessageBox MB_OK "File access error: tnsnames.ora."
    StrCpy $R1 ""
    GoTo done
syntaxerror:
    MessageBox MB_OK "File syntax error: tnsnames.ora."
    StrCpy $R1 ""
    StrCmp $R3 "" +2
    FileClose $R3
        GoTo done
done:
    Pop $R8
    Pop $R7
    Pop $R6
    Pop $R5
    Pop $R4
    Pop $R3
    Pop $R2
    Exch $R1

FunctionEnd