I have written an app in PB8 that makes calls to the Seagate Info 7 SDK. Using the SDK examples as a guide, I have managed to successfully perform the desired SDK functions. Unfortunately, the SDK does not appear to be receiving the values in my structures correctly. As a result, the functions perform the wrong action. Below is the documented code in C along with my implementation in PowerBuilder. Here are some observations. The first field of each structure stores the size of the structure. When I calculate the size manually (I count the full length of char fields), I get a number that is less than the documented length. My calculation is based on 2 bytes for int, unit; 4 bytes for long, ulong; n bytes for char[n]. The lengths of the char fields are always defined as n+1. Not sure if the "+1" is somehow significant. The SDK comes with Init functions for the structures which populate the first field (structsize). The value is always way less than even my manual calculation. I have tried setting the field lenghts to n, n+1, n+2. I have tried setting the structsize to my manual calculation as well as the documented length. Nothing seems to make a difference. I have run out of ideas and would appreciate any suggestions. The code below is of one of the simplier structures. I have structures with sub-structures as well, but I don't want to complicate the issue.
C Code:
#define CI_FOLDER_NAME_BUFFER_SIZE (50 + 1)
#define CI_FOLDER_DESC_BUFFER_SIZE (255 + 1)
#define CI_USER_NAME_BUFFER_SIZE (128 + 1)
typedef short CI_BOOL;
typedef unsigned long CI_SEC_ID;
typedef struct tagCIFolderInfo
{
DWORD StructSize; /* 456 bytes (32-bit), 450 bytes (16-bit) */
char Name [CI_FOLDER_NAME_BUFFER_SIZE];
char Desc [CI_FOLDER_DESC_BUFFER_SIZE];
CI_BOOL IsPrivate;
CI_SEC_ID ParentId;
CI_SEC_ID Id;
char Owner [CI_USER_NAME_BUFFER_SIZE]; /* Output of folder info getting */
} CIFOLDERINFO;
typedef CIFOLDERINFO FAR * LPCIFOLDERINFO;
PB code:
global type str_cifolderinfo from structure
unsignedlong structsize
character foldername[51]
character folderdesc[256]
integer isprivate
unsignedlong parentid
unsignedlong id
character owner[129]
end type
lstr_folderinfo.StructSize = 450
lstr_folderinfo.FolderName = "Test Folder"
lstr_folderinfo.FolderDesc = "This folder was created for testing purposes. Do not publish reports to this folder."
lstr_folderinfo.IsPrivate = 1
lstr_folderinfo.ParentId = nullulong
C Code:
#define CI_FOLDER_NAME_BUFFER_SIZE (50 + 1)
#define CI_FOLDER_DESC_BUFFER_SIZE (255 + 1)
#define CI_USER_NAME_BUFFER_SIZE (128 + 1)
typedef short CI_BOOL;
typedef unsigned long CI_SEC_ID;
typedef struct tagCIFolderInfo
{
DWORD StructSize; /* 456 bytes (32-bit), 450 bytes (16-bit) */
char Name [CI_FOLDER_NAME_BUFFER_SIZE];
char Desc [CI_FOLDER_DESC_BUFFER_SIZE];
CI_BOOL IsPrivate;
CI_SEC_ID ParentId;
CI_SEC_ID Id;
char Owner [CI_USER_NAME_BUFFER_SIZE]; /* Output of folder info getting */
} CIFOLDERINFO;
typedef CIFOLDERINFO FAR * LPCIFOLDERINFO;
PB code:
global type str_cifolderinfo from structure
unsignedlong structsize
character foldername[51]
character folderdesc[256]
integer isprivate
unsignedlong parentid
unsignedlong id
character owner[129]
end type
lstr_folderinfo.StructSize = 450
lstr_folderinfo.FolderName = "Test Folder"
lstr_folderinfo.FolderDesc = "This folder was created for testing purposes. Do not publish reports to this folder."
lstr_folderinfo.IsPrivate = 1
lstr_folderinfo.ParentId = nullulong