Programmatically determine if LargeSummary is enabled on a database

A couple of days ago, I wrote about how you can determine which database on a server has LargeSummary enabled using the show dir command from the Domino console.

You can use LS2CAPI to dertermine, if the flag is set. Here is the code

Public Type DBOPTIONS
options (3) As Long
End Type
 
Public Const W32_LIB = {nnotes.dll}
Public Const TUX_LIB = {libnotes.so}
 
Declare Function W32_NSFDbGetOptionsExt Lib W32_LIB Alias {NSFDbGetOptionsExt}_
(ByVal hdb As Long, retDbOptions As DBOPTIONS) As Integer
Declare Function W32_NSFDbOpen Lib W32_LIB Alias {NSFDbOpen}_
(ByVal dbName As String, hDb As Long) As Integer
Declare Function W32_NSFDbClose Lib W32_LIB Alias {NSFDbClose}_
(ByVal hDb As Long) As Integer
 
Declare Function TUX_NSFDbGetOptionsExt Lib TUX_LIB Alias {NSFDbGetOptionsExt}_
(ByVal hdb As Long, retDbOptions As DBOPTIONS) As Integer
Declare Function TUX_NSFDbOpen Lib TUX_LIB Alias {NSFDbOpen}_
(ByVal dbName As String, hDb As Long) As Integer
Declare Function TUX_NSFDbClose Lib TUX_LIB Alias {NSFDbClose}_
(ByVal hDb As Long) As Integer
 
 
Public Function NSFDbGetOptionsExt (hDb As Long, retDbOptions As DBOPTIONS)
    If isDefined("WINDOWS") Then
        NSFDbGetOptionsExt = W32_NSFDbGetOptionsExt(hDb, retDbOptions)
    Else
        NSFDbGetOptionsExt = TUX_NSFDbGetOptionsExt(hDb, retDbOptions)
    End If
End Function
 
Function NSFDbOpen( db As string, hDB As Long) As Integer
    If isDefined("WINDOWS") Then
        NSFDbOpen = W32_NSFDbOpen(db,hDb)
    Else
        NSFDbOpen = TUX_NSFDbOpen(db,hDb)
    End If
End Function
 
Function NSFDBClose (hDb As Long)
    If isDefined("WINDOWS") Then
        NSFDbClose = W32_NSFDbClose(hDb)
    Else
        NSFDbClose = TUX_NSFDbClose(hDb)
    End If
End Function

And here is how you can use the code

Const DBOPTBITS_3 = 3
Const DBOPTBIT_LARGE_BUCKETS_ENABLED = &h104

Sub Click(Source As Button)
	Dim hDb As Long
	Dim rc As Integer
	Dim sDb As String
	
	Dim retDbOptions As DBOPTIONS
	
	sDb = "serv04/singultus!!ua.nsf"
	
	rc = NSFDbOpen(sDb, hDb)
	
	If rc = 0 Then
		rc =  NSFDbGetOptionsExt (hDb, retDbOptions)
		If retDbOptions.options(DBOPTBITS_3) _
		And DBOPTBIT_LARGE_BUCKETS_ENABLED Then
			Msgbox "LargeSummary enabled"
		Else 
			Msgbox "LargeSummary not enabled"
		End If
		rc = NSFDbClose(hDb)
	End If
End Sub

NotesUser Activity Class

The NotesUserActivity Class is a customizable LotusScript library that returns database user activity summary information. The usage statistics for the prior day, week, and month since user activity recording began is provided. The number of documents a user or server has read, added, updated or deleted during each session, with the most recent activity first, is returned.

The class returns information that is available from the Notes user interface via the File/Database/Properties menu item, Information tab, Activity section, User Detail button selection. User activity for the specified database must be enabled for this function to work .

The class was created by Alex Elliott of AGECOM (http://www.agecom.com.au). Unfortunately it was only availabe for Windows.

I tried to write a Linux port, but I only had a partial success. The code runs without any issues on Windows.

It also runs fine on a Domino V11 Beta1 server on Linux ( CentOS). But it constantly crashes on Domino 10.0.1 ( with or without FP ) on RHEL.

The crash occurs, when the code tries to get the UserName from the ActivityEntry.

pActivityEntry = puActivity + lEntry * 28
		
CopyMemory dt.Innards(0), pActivityEntry , LEN_DWORD
CopyMemory dt.Innards(1), pActivityEntry + 4 , LEN_DWORD
CopyMemory reads, pActivityEntry + 8 , LEN_WORD
CopyMemory adds, pActivityEntry + 10 , LEN_WORD
CopyMemory updates, pActivityEntry + 12 , LEN_WORD
CopyMemory deletes, pActivityEntry + 14 , LEN_WORD
CopyMemory nonDataReads, pActivityEntry + 16 , LEN_WORD
CopyMemory nonDataAdds, pActivityEntry + 18 , LEN_WORD
CopyMemory nonDataUpdates, pActivityEntry + 20 , LEN_WORD
CopyMemory nonDataDeletes, pActivityEntry + 22 , LEN_WORD
CopyMemory nameOffset, pActivityEntry + 24 , LEN_DWORD		

Dim spUsername As String * MAXUSERNAME
spUsername = Space(MAXUSERNAME)

CopyMemoryString spUsername, puActivity + nameOffset, MAXUSERNAME - 2

Dim sUserName As String
sUserName = Trim(spUsername)

CopyMemory and CopyMemoryString are declared as

Declare Sub TUX_CopyMemory Lib "libc.so.6" Alias "memcpy" _
(hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)

Declare Sub TUX_CopyMemoryString Lib "libc.so.6" Alias "memcpy" _
(ByVal hpvDest As LMBCS String, ByVal hpvSource As Long, ByVal cbCopy As Long)

I tried using undocumented method “Cmovmem” from libnotes.so but it also crashes on V10 AND V11. I must admit that I do not really know, how to use Cmovmem. I declared it this way:

Declare Sub CopyMemoryString Lib LIB_TUX Alias "Cmovmem"  _
(Byval lpSrc As Long, Byval lpDest As String, Byval lSize As Long)

You can find the code here.

Any help to get it working on V10 for Linux is appreciated.


Access NotesDatabase Options (extended)

GetOption was introduced to the NotesDatabase class in V6. It allows to determine, if specific options are set or not.

By design, it only accesses $dboptions1 from the database. Other options are stored in $dboptions2 – 4.
Those option bits are not accessible using NotesDatabase.getOption(optionName%).

Here is code to access them.

Public Type DBOPTIONS
options (3) As Long
End Type

Public Const W32_LIB = {nnotes.dll}
Public Const TUX_LIB = {libnotes.so}

Declare Function W32_NSFDbGetOptionsExt Lib W32_LIB Alias {NSFDbGetOptionsExt}_
(ByVal hdb As Long, retDbOptions As DBOPTIONS) As Integer
Declare Function W32_NSFDbOpen Lib W32_LIB Alias {NSFDbOpen}_
(ByVal dbName As String, hDb As Long) As Integer
Declare Function W32_NSFDbClose Lib W32_LIB Alias {NSFDbClose}_
(ByVal hDb As Long) As Integer

Declare Function TUX_NSFDbGetOptionsExt Lib TUX_LIB Alias {NSFDbGetOptionsExt}_
(ByVal hdb As Long, retDbOptions As DBOPTIONS) As Integer
Declare Function TUX_NSFDbOpen Lib TUX_LIB Alias {NSFDbOpen}_
(ByVal dbName As String, hDb As Long) As Integer
Declare Function TUX_NSFDbClose Lib TUX_LIB Alias {NSFDbClose}_
(ByVal hDb As Long) As Integer


Public Function NSFDbGetOptionsExt (hDb As Long, retDbOptions As DBOPTIONS)
	If isDefined("WINDOWS") Then
		NSFDbGetOptionsExt = W32_NSFDbGetOptionsExt(hDb, retDbOptions)
	Else
		NSFDbGetOptionsExt = TUX_NSFDbGetOptionsExt(hDb, retDbOptions)
	End If
End Function

Function NSFDbOpen( db As string, hDB As Long) As Integer
	If isDefined("WINDOWS") Then
		NSFDbOpen = W32_NSFDbOpen(db,hDb)
	Else
		NSFDbOpen = TUX_NSFDbOpen(db,hDb)
	End If
End Function

Function NSFDBClose (hDb As Long)
	If isDefined("WINDOWS") Then
		NSFDbClose = W32_NSFDbClose(hDb)
	Else
		NSFDbClose = TUX_NSFDbClose(hDb)
	End If
End Function

Sample:

Const  DBOPT_IS_IMAP = &h01000000

Sub Initialize
	Dim hDb As Long
	Dim rc As Integer
	Dim sDb As String
	
	Dim retDbOptions As DBOPTIONS
	
	sDb = "serv01/singultus!!mail/buser.nsf"
	
	rc = NSFDbOpen(sDb, hDb)
	
	If rc = 0 Then
		rc =  NSFDbGetOptionsExt (hDb, retDbOptions)
		If retDbOptions.options(1) And DBOPT_IS_IMAP Then
			MsgBox "IMAP enabled"
		Else 
			MsgBox "IMAP not enabled"
		End If
		rc = NSFDbClose(hDb)
	End If
End Sub

I have created an enhancement request for an optional method parameter to access the different optionsStores.
If you think, that this might give you some benefit, pls upvote my idea https://domino.ideas.aha.io/ideas/DDXP-I-508


Programmatically Update /Add Database to DQL Design Catalog

For high speed access to internal information about views and view columns, DQL processing uses design data extracted from view notes. Currently this information will be stored in a new database, named GQFdsgn.cat.

It is created using new updall flags. It does not replicate and is solely used as a fast-path tool to access design data at runtime.

Here is some LotusScript code to add / update the design of a named Notes application to the catalog. The NSFDesignHarvest call is currently undocumented. Use it at your own risk.

'DECLARATIONS

Public Const UPDATE_DESIGN_CATALOG = 0
Public Const ADD_TO_DESIGN_CATALOG = 1

Const NNOTES ="nnotes.dll"
Const LIBNOTES ="libnotes.so"

Declare Public Function WIN_NSFDbOpen Lib NNOTES Alias "NSFDbOpen" _
(ByVal dbName As String, hDb As Long) As Integer
Declare Public Function LIN_NSFDbOpen Lib LIBNOTES Alias "NSFDbOpen" _
(ByVal dbName As String, hDb As Long) As Integer
Declare Public Function WIN_NSFDbClose Lib NNOTES Alias "NSFDbClose" _
(ByVal hDb  As Long) As Integer
Declare Public Function LIN_NSFDbClose Lib LIBNOTES Alias "NSFDbClose" _
(ByVal hDb  As Long) As Integer
Declare Public Function WIN_NSFDesignHarvest Lib NNOTES Alias "NSFDesignHarvest" _
(ByVal hDb  As Long, ByVal flag  As Long) As Integer
Declare Public Function LIN_NSFDesignHarvest Lib LIBNOTES Alias "NSFDesignHarvest" _
(ByVal hDb  As Long, ByVal flag  As Long) As Integer

' API FUNCTIONS
Private Function NSFDbOpen( db As String, hDB As Long) As Integer
	If isDefined("WINDOWS") Then
		NSFDbOpen = WIN_NSFDbOpen(db,hDb)
	ElseIf isDefined("LINUX") Then
		NSFDbOpen = LIN_NSFDbOpen(db,hDb)
	End If
End Function

Private Function NSFDbClose (hDb As Long)
	If isDefined("WINDOWS") Then
		NSFDbClose = WIN_NSFDbClose(hDb)
	ElseIf isDefined("LINUX") Then
		NSFDbClose = LIN_NSFDbClose(hDb)
	End If
End Function

Private Function NSFDesignHarvest (hDb As Long, flag As long) As Integer
	If isDefined("WINDOWS") Then
		NSFDesignHarvest = WIN_NSFDesignHarvest(hDb, flag)
	ElseIf isDefined("LINUX") Then
		NSFDesignHarvest = LIN_NSFDesignHarvest(hDb, flag)
	End If
End Function

Public Function catalogDesign(sDb As String, flag As Long) As Integer
	
	Dim hDb As Long
	Dim rc As Integer
	
	If flag > 1 Then flag = 1
	If flag < 0 Then flag = 0
	
	rc = NSFDbOpen(sDb, hDb)
	
	If rc = 0 Then
		rc = NSFDesignHarvest(hDb, flag)
		rc = NSFDbClose(hDb)
	End If
	
	catalogDesign = rc 
	
End Function