Hi All,In a database which I’ve built I used some API code to change the schedule of a scheduled agent (many thanks to Rod Whiteley in this forum for the code!). This code works great, but now I have to move this database to a Domino server which is running on Linux. I figured out that I have to change the platform API to use “libnotes.so” instead of “nnotes.dll”, but the script also uses the msvcrt.dll to change the value of the AssistInfo in memory to the wanted values and here I don’t know how to translate that for Linux. Both my knowledge of the Linux platform as of API code are quite limited which doesn’t help.
Is there any way to rewrite this code, so that I don’t have to use the msvcrt.dll and if not, how would I rewrite this code for Linux?
The (simplified) code:
Dim session As NotesSession
Const wAPIModule = “NNOTES” ’ Windows/32
Const linAPIModule = “libnotes.so” 'Linux
Const NOTE_CLASS_FILTER = &H0200
Type AssistInfo
Version As Integer
TriggerType As Integer ' 0 none, 1 schedule, 2 new mail, 3 paste, 4 manual, 5 update, 6 router
SearchType As Integer ' 0 none, 1 all, 2 new, 3 new/mod, 4 selected, 5 view, 6 unread, 7 prompt, 8 UI
IntervalType As Integer ' 0 none, 1 minutes, 2 days, 3 weeks, 4 months
Interval As Integer
Time1 As Variant ' Start time (ms since midnight)
Time2 As Variant ' Long (weekday or day of month) or end time (ms since midnight)
StartTime As Variant ' Time/Date
EndTime As Variant ' Time/Date
Flags As Long ' 1 hidden, 2 no weekends, 4 store highlights, 8 mail/paste, 16 choose server
Spare(15) As Long
End Type
Type BlockID
hPool As Long
Block As Integer
End Type
Declare Function ConvertTIMEDATEToText Lib wAPIModule Alias “ConvertTIMEDATEToText” ( Byval zI As Long, Byval zT As Long, Byval T As Long, Byval S As String, Byval nS As Integer, nT As Integer) As Integer
Declare Function ConvertTextToTIMEDATE Lib wAPIModule Alias “ConvertTextToTIMEDATE” ( Byval zI As Long, Byval zT As Long, pS As Long, Byval nS As Integer, Byval T As Long) As Integer
Declare Private Function NSFDbOpen Lib wAPIModule Alias “NSFDbOpen” ( Byval PathName As String, DbHandle As Long) As Integer
Declare Private Function NSFDbClose Lib wAPIModule Alias “NSFDbClose” ( Byval DbHandle As Long) As Integer
Declare Private Function NIFFindDesignNote Lib wAPIModule Alias “NIFFindDesignNote” ( Byval hDB As Long, Byval S As String, Byval C As Integer, N As Long) As Integer
Declare Private Function NSFNoteOpen Lib wAPIModule Alias “NSFNoteOpen” ( Byval hDB As Long, Byval NoteID As Long, Byval F As Integer, hNT As Long) As Integer
Declare Private Function NSFNoteClose Lib wAPIModule Alias “NSFNoteClose” ( Byval hNT As Long) As Integer
Declare Function NSFItemInfo Lib wAPIModule Alias “NSFItemInfo” ( Byval hNT As Long, Byval N As String, Byval nN As Integer, iB As BlockID, D As Integer, vB As BlockID, nV As Long) As Integer
Declare Private Function NSFNoteUpdate Lib wAPIModule Alias “NSFNoteUpdate” ( Byval hNT As Long, Byval F As Integer) As Integer
Declare Function NSFItemDelete Lib wAPIModule Alias “NSFItemDelete” ( Byval hNT As Long, Byval N As String, Byval nN As Integer) As Integer
Declare Private Function OSMemAlloc Lib wAPIModule Alias “OSMemAlloc” ( Byval T As Integer, Byval N As Long, hM As Long) As Long
Declare Private Function OSMemFree Lib wAPIModule Alias “OSMemFree” ( Byval hM As Long) As Long
Declare Private Function OSLockObject Lib wAPIModule Alias “OSLockObject” ( Byval H As Long) As Long
Declare Private Sub OSUnlockObject Lib wAPIModule Alias “OSUnlockObject” ( Byval H As Long)
Declare Private Function OSPathNetConstruct Lib wAPIModule Alias “OSPathNetConstruct” ( Byval NullPort As Long, Byval Server As String, Byval FIle As String, Byval PathNet As String) As Integer
Declare Private Sub Peek Lib “MSVCRT” Alias “memcpy” ( D As Any, Byval P As Long, Byval N As Long)
Declare Private Sub Poke Lib “MSVCRT” Alias “memcpy” ( Byval D As Long, D As Any, Byval N As Long)
Declare Private Sub PokeString Lib “MSVCRT” Alias “memcpy” ( Byval D As Long, Byval S As String, Byval N As Long)
Sub Initialize
Dim hDB As Long ' Handle to the Database
Dim nID As Long ' NoteID
Dim hNT As Long ' NoteHandle
Dim iB As BlockID ' Item BlockID
Dim vB As BlockID ' Value BlockID
Dim dt As Integer ' Data Type
Dim nv As Long ' Value Length
Dim OSPath As String
Dim info As AssistInfo
Dim agentname As String
Dim hM As Long
Set session = New NotesSession
Set db = session.CurrentDatabase
' For demo's sake. These values are determined by a profile doc in the real agent
agentname = "agSendInvites"
info.Version = 0
info.TriggerType = 1
info.SearchType = 1
info.IntervalType = 3
info.Interval = 4
info.Time1 = 3600000
info.Time2 = 2
info.StartTime =Null
info.EndTime = Null
info.Flags = 0
OSPath = Space(1024)
OSPathNetConstruct 0, db.Server, db.FilePath, OSPath
NSFDbOpen OSPath, hDB
NIFFindDesignNote hDB, agentname, NOTE_CLASS_FILTER, nID
NSFNoteOpen hDB, nID, 0, hNT
NSFItemInfo hNT, "$AssistInfo", 11, iB, dt, vB, nv
’ Here starts the sneaky part for which the Linux port is a bit difficult. The script takes the current value for AssistInfo and replaces its components in memory with the new values.
If Not vB.hPool = 0 Then
p& = OSLockObject(vB.hPool) + vB.Block
Poke p& + 2, info.Version, 2
Poke p& + 4, info.TriggerType, 2
Poke p& + 6, info.SearchType, 2
Poke p& + 8, info.IntervalType, 2
Poke p& + 10, info.Interval, 2
If Isdate(info.Time1) Then Poke p& + 12, Clng(Cdbl(info.Time1) * 24 * 60 * 60 * 100), 4 _
Else Poke p& + 12, Clng(info.Time1), 4
If Isdate(info.Time2) Then Poke p& + 16, Clng(Cdbl(info.Time2) * 24 * 60 * 60 * 100), 4 _
Else Poke p& + 16, Clng(info.Time2), 4
OSMemAlloc 0, 81, hM
b& = OSLockObject(hM)
If Isdate(info.StartTime) Then
t$ = Cstr(info.StartTime) & Chr$(0)
PokeString b&, t$, Len(t$)
ConvertTextToTIMEDATE 0, 0, b&, 81, p& + 20
Else
Poke p& + 20, 0&, 4
Poke p& + 24, 0&, 4
End If
If Isdate(info.EndTime) Then
t$ = Cstr(info.EndTime) & Chr$(0)
PokeString b&, t$, Len(t$)
ConvertTextToTIMEDATE 0, 0, b&, 81, p& + 28
Else
Poke p& + 28, 0&, 4
Poke p& + 32, 0&, 4
End If
Poke p& + 36, info.Flags, 4
OSUnlockObject hM
OSMemFree hM
OSUnlockObject vB.hPool
End If
NSFNoteUpdate hNT, 0
NSFNoteClose hNT
NSFDbClose hDB
End Sub