DomainPatrolOpenDocument[/projects/pmt.nsf/ProjectView?ReadForm&Query=]

Project: DomainPatrol (Managed by Peter Narlund, anders.nygren@infoware.se)
Subject
Cross platform calling C-API from Lotus Script Example for Win32, Linux, AIX, Solaris and Mac including international characters (LMBCS)
Posted by
Tommy Axlinder on 05/02/2007 at 10:34 AM
Details
This could be useful ! Works great !
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/c080775ea4d6a837c1256dca0038acb7?OpenDocument&Highlight=0,LMBCS
REM W32 Declares
Declare Function W32_NSFRemoteConsole Lib "NNOTES.DLL" Alias "NSFRemoteConsole" (Byval server As Lmbcs String, Byval cmd As Lmbcs String, ret As Long) As Integer
Declare Function W32_OSLockObject Lib "NNOTES.DLL" Alias "OSLockObject" (Byval handle As Long) As Lmbcs String
Declare Sub W32_OSUnlockObject Lib "NNOTES.DLL" Alias "OSUnlockObject" (Byval handle As Long)
Declare Sub W32_OSMemFree Lib "NNOTES.DLL" Alias "OSMemFree" (Byval handle As Long)
Declare Function W32_OSLoadString Lib "NNOTES.DLL" Alias "OSLoadString" (Byval hModule As Long, Byval stringCode As Integer, _
Byval retBuffer As Lmbcs String, Byval bufferLen As Integer) As Integer
REM MAC Declares
Declare Function MAC_NSFRemoteConsole Lib "NotesLib" Alias "NSFRemoteConsole" (Byval server As Lmbcs String, Byval cmd As Lmbcs String, ret As Integer) As Integer
Declare Function MAC_OSLockObject Lib "NotesLib" Alias "OSLockObject" (Byval handle As Integer) As Lmbcs String
Declare Sub MAC_OSUnlockObject Lib "NotesLib" Alias "OSUnlockObject" (Byval handle As Integer)
Declare Sub MAC_OSMemFree Lib "NotesLib" Alias "OSMemFree" (Byval handle As Integer)
Declare Function MAC_OSLoadString Lib "NotesLib" Alias "OSLoadString" (Byval hModule As Integer, Byval stringCode As Integer, _
Byval retBuffer As Lmbcs String, Byval bufferLen As Integer) As Integer
REM Linux Declares
Declare Function LINUX_NSFRemoteConsole Lib "libnotes.so" Alias "NSFRemoteConsole" (Byval server As Lmbcs String, Byval cmd As Lmbcs String, ret As Long) As Integer
Declare Function LINUX_OSLockObject Lib "libnotes.so" Alias "OSLockObject" (Byval handle As Long) As Lmbcs String
Declare Sub LINUX_OSUnlockObject Lib "libnotes.so" Alias "OSUnlockObject" (Byval handle As Long)
Declare Sub LINUX_OSMemFree Lib "libnotes.so" Alias "OSMemFree" (Byval handle As Long)
Declare Function LINUX_OSLoadString Lib "libnotes.so" Alias "OSLoadString" (Byval hModule As Long, Byval stringCode As Integer, _
Byval retBuffer As Lmbcs String, Byval bufferLen As Integer) As Integer
REM AIX Declares
Declare Function AIX_NSFRemoteConsole Lib "libnotes_r.a" Alias "NSFRemoteConsole" (Byval server As Lmbcs String, Byval cmd As Lmbcs String, ret As Integer) As Integer
Declare Function AIX_OSLockObject Lib "libnotes_r.a" Alias "OSLockObject" (Byval handle As Integer) As Lmbcs String
Declare Sub AIX_OSUnlockObject Lib "libnotes_r.a" Alias "OSUnlockObject" (Byval handle As Integer)
Declare Sub AIX_OSMemFree Lib "libnotes_r.a" Alias "OSMemFree" (Byval handle As Integer)
Declare Function AIX_OSLoadString Lib "libnotes_r.a" Alias "OSLoadString" (Byval hModule As Integer, Byval stringCode As Integer, _
Byval retBuffer As Lmbcs String, Byval bufferLen As Integer) As Integer
REM Solaris Declares
Declare Function SOLARIS_NSFRemoteConsole Lib "libnotes.so" Alias "NSFRemoteConsole" (Byval server As Lmbcs String, Byval cmd As Lmbcs String, ret As Integer) As Integer
Declare Function SOLARIS_OSLockObject Lib "libnotes.so" Alias "OSLockObject" (Byval handle As Integer) As Lmbcs String
Declare Sub SOLARIS_OSUnlockObject Lib "libnotes.so" Alias "OSUnlockObject" (Byval handle As Integer)
Declare Sub SOLARIS_OSMemFree Lib "libnotes.so" Alias "OSMemFree" (Byval handle As Integer)
Declare Function SOLARIS_OSLoadString Lib "libnotes.so" Alias "OSLoadString" (Byval hModule As Integer, Byval stringCode As Integer, _
Byval retBuffer As Lmbcs String, Byval bufferLen As Integer) As Integer
Class RemoteConsole
Public IsError As Variant
Private rc As Integer
Private Long_hBuffer As Long
Private Integer_hBuffer As Integer
Private Server As String
Private Command As String
Private Result As String
Sub New (InputServer As String)
If InputServer = "" Then
Me.IsError = True
Else
Me.Server = InputServer
Me.IsError = False
End If
End Sub
Function get_platform () As String
Dim tmp_platform As Variant
Dim lower_platform As String
tmp_platform = Evaluate(|@Implode(@Platform([Specific]);" ")|)
lower_platform = Lcase(Cstr(tmp_platform(0)))
REM Messagebox Cstr(tmp_platform(0))
If (Instr (lower_platform, "aix")) Then
get_platform = "aix"
Elseif (Instr (lower_platform, "solaris")) Then
get_platform = "solaris"
Elseif (Instr (lower_platform, "linux")) Then
get_platform = "linux"
Elseif (Instr (lower_platform, "win")) Then
get_platform = "w32"
Elseif (Instr (lower_platform, "mac")) Then
get_platform = "mac"
Else
Messagebox "Unsupported Platform : >" + lower_platform + "<"
get_platform = ""
End If
End Function
Function Execute (InputCommand As String) As String
Dim StrLen As Integer
Dim errorStr As String * 1024
Dim Session As New NotesSession
Dim platform As String
platform = get_platform
REM Messagebox session.platform
REM Messagebox platform
If Me.Server = "" Then
Me.Execute = "No server specified"
Me.IsError = True
Exit Function
End If
If InputCommand = "" Then
Me.Execute = "No command specified"
Me.IsError = True
Exit Function
End If
Me.command = InputCommand + Chr (0)
Me.server = Me.server + Chr(0)
Select Case platform
Case "w32"
Me.rc = W32_NSFRemoteConsole (Me.Server, Me.Command, Long_hBuffer)
Case "mac"
Me.rc = MAC_NSFRemoteConsole (Me.Server, Me.Command, Integer_hBuffer)
Case "linux"
Me.rc = LINUX_NSFRemoteConsole (Me.Server, Me.Command, Long_hBuffer)
Case "aix"
Me.rc = AIX_NSFRemoteConsole (Me.Server, Me.Command, Integer_hBuffer)
Case "solaris"
Me.rc = SOLARIS_NSFRemoteConsole (Me.Server, Me.Command, Integer_hBuffer)
Case Else
Exit Function
End Select
If (Me.rc <> 0) Then
Me.IsError = True
Select Case platform
Case "w32"
StrLen = w32_OSLoadString(0&, Me.rc, errorStr , Len(errorStr) - 1)
Case "mac"
StrLen = MAC_OSLoadString(0&, Me.rc, errorStr , Len(errorStr) - 1)
Case "linux"
StrLen = LINUX_OSLoadString(0&, Me.rc, errorStr , Len(errorStr) - 1)
Case "aix"
StrLen = AIX_OSLoadString(0&, Me.rc, errorStr , Len(errorStr) - 1)
Case "solaris"
StrLen = SOLARIS_OSLoadString(0&, Me.rc, errorStr , Len(errorStr) - 1)
Case Else
Exit Function
End Select
If (StrLen = 0 ) Then
errorStr = ""
End If
Me.Result= "Error: [" & Cstr (rc) & "] " + errorStr
Else
Select Case platform
Case "w32"
Me.Result = W32_OsLockObject (Long_hBuffer) + Chr (0)
Call W32_OSUnlockObject (Long_hBuffer)
Call W32_OsMemFree (Long_hBuffer)
Case "mac"
Me.Result = MAC_OsLockObject (Integer_hBuffer) + Chr (0)
Call MAC_OSUnlockObject (Integer_hBuffer)
Call MAC_OsMemFree (Integer_hBuffer)
Case "linux"
Me.Result = LINUX_OsLockObject (Long_hBuffer) + Chr (0)
Call LINUX_OSUnlockObject (Long_hBuffer)
Call LINUX_OsMemFree (Long_hBuffer)
Case "aix"
Me.Result = AIX_OsLockObject (Integer_hBuffer) + Chr (0)
Call AIX_OSUnlockObject (Integer_hBuffer)
Call AIX_OsMemFree (Integer_hBuffer)
Case "solaris"
Me.Result = SOLARIS_OsLockObject (Integer_hBuffer) + Chr (0)
Call SOLARIS_OSUnlockObject (Integer_hBuffer)
Call SOLARIS_OsMemFree (Integer_hBuffer)
Case Else
Exit Function
End Select
Me.IsError = False
End If
Me.Execute = Me.Result
End Function
End Class
Modification history
| Entered 02-May-2007 10:34 by Tommy Axlinder. Last Modified <none> by <none>. |
Feedback
Check out other projects
Switch to project:
Anonymous