/******************************************************************************
	Determine whether the specified DB is a condensed directory design
	or not
******************************************************************************/
bool RecipientsHandler::IsCondensedDirectory(char* pszDirectoryPath) 
{
	#define	CONDENSED_DIR_DESIGN "Lightweight Directory"

	bool result = false;
	DBHANDLE	hDB = NULL;
	char		szInfoBuffer[NSF_INFO_SIZE];
	char		szTemplateName[NSF_INFO_SIZE];

	STATUS stat = NSFDbOpen(pszDirectoryPath, &hDB);
	if (NOERROR == stat)
	{
		stat = NSFDbInfoGet(hDB, szInfoBuffer);
		if (NOERROR == stat)
		{
			NSFDbInfoParse(szInfoBuffer, INFOPARSE_DESIGN_CLASS, szTemplateName, NSF_INFO_SIZE - 1);
			if (strlen(szTemplateName) > 0)
			{
				if (_stricmp(szTemplateName, CONDENSED_DIR_DESIGN) == 0)
				{
					result = true;
				}
			}
		}
		NSFDbClose(hDB);
	}
	return result;
}
/** eus_OpenDb( ***
Attempts to open the specified Notes database on the given server. Validates 
that the "database" is not really a subdirectory path, the alternative 
return of NSFDbOpen().

--- parameters & return ----
pc_FILENM: pointer to the extended filename of the Notes database to be 
	opened
pc_SERVERNM: pointer to the name of the server on which the specified Notes 
	database resides
ph: Output. Pointer to the handle variable in which to store the handle to 
	the specified Notes database.  Guaranteed to be null if database could 
	not be validated as a true Notes Mail database.
RETURN: 
	eus_SUCCESS if no error occured
	ERR_DIRECTORY if the specified filename is a directory, not a database
	the Notes API error code otherwise

--- revision history -------
9/12/99 PR: created			*/
STATUS eus_OpenDb( char  pc_FILENM[], 
					char  pc_SERVERNM[], 
					DBHANDLE *const  ph)	{
	char  pc[ MAXPATH];
	DBHANDLE  h;
	WORD  us;
	STATUS  us_err;

	if (!( pc_FILENM && *pc_FILENM && pc_SERVERNM && ph))
		return !eus_SUCCESS;

	*ph = NULL;

	//open the specified database on the given server
	OSPathNetConstruct( NULL, pc_SERVERNM, pc_FILENM, pc);
	if (us_err = NSFDbOpen( pc, &h))
		return us_err;
	if (us_err = NSFDbModeGet( h, &us))
		goto errJump;
	if (us_err = (us != DB_LOADED ? ERR_DIRECTORY : eus_SUCCESS))
		goto errJump;

	*ph = h;
	return eus_SUCCESS;

errJump:
	NSFDbClose( h);

	return us_err;
} //eus_OpenDb(
Exemple #3
0
_declspec ( dllexport ) WORD GetDatabaseNames(const char *port,
											  const char *serverName,
											  char retDatabaseNames[MAX_ENTRIES][MAXPATH]) 
{	
	STATUS error = NO_ERROR;
    char directory[STRING_LENGTH];   /* directory path */
    char full_netpath[MAXPATH] = ""; /* full network path */
    DBHANDLE    dir_handle;          /* handle for directory */
    
	wDatabaseCount = 0;
	//block = (char**)malloc(MAX_ENTRIES * MAXPATH * sizeof(char*));
	
    strcpy_s(directory, full_netpath);

	if (strcmp(serverName, "Local")) 
	{
		if (error = OSPathNetConstruct(port, 
									   serverName, 
									   directory, 
									   full_netpath))		   
		   return 0;									   
	} else
	{
		if (error = OSPathNetConstruct(NULL, "", directory, full_netpath))
            return 0;
	}
	
	
	if (error = NSFDbOpen (full_netpath, &dir_handle))
	{
        return 0;
	}

	if (error = NSFSearch (
        dir_handle,		       // directory handle
        NULLHANDLE,        // selection formula
        NULL,              // title of view in formula
        SEARCH_FILETYPE +  // search for files
        SEARCH_SUMMARY,    // return a summary buffer
        FILE_DBANY +       // find any .NS? file
        FILE_RECURSE +     // find subdirectories
        FILE_NOUPDIRS,     // don't find the ".." dir					
        NULL,              // starting date
        file_action,       // call for each file found
        NULL,              // argument to action routine
        NULL))             // returned ending date (unused)
	
	if (error = NSFDbClose(dir_handle))
		return 0;

	for (int dbIndex=0; dbIndex<(int)wDatabaseCount; dbIndex++)
	{
		strcpy_s(retDatabaseNames[dbIndex], MAXPATH, dblist[dbIndex]);
		//strcpy_s(retDatabaseNames[dbIndex], MAXPATH, block[dbIndex]);
		//free(block[dbIndex]);
	}
	//free(block);
	return wDatabaseCount;
}
/** eus_OpenMailDb( ***
Returns a handle to the Notes Mail database specified on the given server, 
once assured that the database is in fact a Notes Mail database.

--- parameters & return ----
pc_FILENM: pointer to the extended filename of the Notes database to be 
	opened
pc_SERVERNM: pointer to the name of the server on which the specified Notes 
	database should reside
ph: Output. Pointer to the handle variable in which to store the handle to 
	the specified Notes Mail database.  Guaranteed to be null if database 
	could not be validated as a true Notes Mail database.
RETURN: 
	eus_SUCCESS if no error occured
	ERR_DIRECTORY if the specified filename is a directory, not a database
	mi_ERR_NOT_MAIL_DB if a Notes database of the specified name was found, 
		but it doesn't seem to be a Notes Mail template
	the Notes API error code otherwise

--- revision history -------
9/12/99 PR: created			*/
STATUS eus_OpenMailDb( char  pc_FILENM[], 
						char  pc_SERVERNM[], 
						DBHANDLE *const  ph)	{
	char  pc_VIEWNM_TEST1[] = "($VIM23)", pc_VIEWNM_TEST2[] = "($Drafts)", 
			pc_FORMNM_TEST1[] = "(Trace Report)", 
			pc_FORMNM_TEST2[] = "(Personal Stationery)";

	DBHANDLE  h;
	NOTEID  nid;
	STATUS  us_err;

	if (!( pc_FILENM && *pc_FILENM && pc_SERVERNM && ph))
		return !eus_SUCCESS;

	*ph = NULL;

	if (us_err = eus_OpenDb( pc_FILENM, pc_SERVERNM, &h))
		return us_err;

	//ensure that the database is a Notes Mail database
/*	if (us_err = eus_GetDesignNote( h, NOTE_CLASS_VIEW, pc_VIEWNM_TEST1, 
																		&nid))
		goto errJump;
	if (us_err = eus_GetDesignNote( h, NOTE_CLASS_VIEW, pc_VIEWNM_TEST2, 
																		&nid))
		goto errJump;
	if (us_err = eus_GetDesignNote( h, NOTE_CLASS_FORM, pc_FORMNM_TEST1, 
																		&nid))
		goto errJump;
	if (us_err = eus_GetDesignNote( h, NOTE_CLASS_FORM, pc_FORMNM_TEST2, 
																		&nid))
		goto errJump;
*/	if (us_err = NIFFindDesignNote( h, pc_VIEWNM_TEST1, NOTE_CLASS_VIEW, 
																		&nid))
		goto errJump;
	if (us_err = NIFFindDesignNote( h, pc_VIEWNM_TEST2, NOTE_CLASS_VIEW, 
																		&nid))
		goto errJump;
	if (us_err = NIFFindDesignNote( h, pc_FORMNM_TEST1, NOTE_CLASS_FORM, 
																		&nid))
		goto errJump;
	if (us_err = NIFFindDesignNote( h, pc_FORMNM_TEST2, NOTE_CLASS_FORM, 
																		&nid))
		goto errJump;

	*ph = h;
	return eus_SUCCESS;

errJump:
	NSFDbClose( h);

	return ERR( us_err) == ERR_NOT_FOUND ? mi_ERR_NOT_MAIL_DB : us_err;
} //eus_OpenMailDb(
Exemple #5
0
BOOL getDBSpace(CString strServer, CString strDBFile, char *szReturn)
{
	char        szFullNetPath[MAXPATH] = ""; /* full network path */
    DBHANDLE    dir_handle;                  /* handle for directory */
    STATUS      error = NOERROR;             /* return status from API calls */
    DWORD       dwAvalid = 0;
    DWORD       dwFree = 0;

	error = NotesInitExtended (0, NULL);
	if (error)
	{
		sprintf (szReturn, "error=Error initializing Notes.");
		return FALSE;
	}
	
    if(strServer != _T(""))
    {
        /* Compose the full network pathname to the directory. */
        if (error = OSPathNetConstruct(NULL, strServer.GetBuffer(0), strDBFile.GetBuffer(0), szFullNetPath))
	     {
		      OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
			  NotesTerm();
		      return FALSE;
	     }
    }
    
    /* Open the directory. */
    if (error = NSFDbOpen (szFullNetPath, &dir_handle))
    {
        OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
		NotesTerm();
		return FALSE;
    }

    if (error = NSFDbSpaceUsage(dir_handle, &dwAvalid, &dwFree))
    {
        OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
		NotesTerm();
        return FALSE;
    }

    /* Close the directory. */
    if (error = NSFDbClose (dir_handle))
    {
        OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
		NotesTerm();
        return FALSE;
    }

	NotesTerm();
	sprintf(szReturn, "Used=%f$Free=%f$FreePer=%f$", dwAvalid/(1024.0*1024), dwFree/(1024.0*1024), 100.0*dwFree/(dwFree+dwAvalid));
    return TRUE;
}
Exemple #6
0
void NoteDatabase::CloseDatabase(DBHANDLE& handle)
{
	if(!handle)
		return;

	if(NOERROR == NSFDbClose(handle))
	{
		LOG_WS_INFO(L"Database close OK");
		return;
	}
	else
	{
		LOG_WS_ERROR(L"Database closed failed");
		return;
	}
}
/** eus_OpenMailTemplate( ***
Returns a handle to the Notes Mail template specified on the given server, 
once assured that the database is in fact a Notes Mail template.

--- parameters & return ----
pc_FILENM: pointer to the extended filename of the Notes database to be 
	opened
pc_SERVERNM: pointer to the name of the server on which the specified Notes 
	database should reside
ph: Output. Pointer to the handle variable in which to store the handle to 
	the specified Notes Mail template.  Guaranteed to be null if database 
	could not be validated as a true Notes Mail template.
pc_class: Optional Output. Pointer to the buffer to fill with the class 
	(template) name of the specified database, should be of minimum size 
	NSF_INFO_SIZE to be completely safe. Caller may specify NULL for the 
	parameter if the output isn't needed.
RETURN:
	eus_SUCCESS if no error occured
	ERR_DIRECTORY if the specified filename is a sub-directory, not a 
		database
	mi_ERR_NOT_MAIL_DB if a Notes database of the specified name was found, 
		but it doesn't seem to be a Notes Mail database
	mi_ERR_NOT_TEMPLATE if the Notes Mail database has no design class and 
		thus is not considered a template
	the Notes API error code otherwise

--- revision history -------
9/12/99 PR: created			*/
STATUS eus_OpenMailTemplate( char  pc_FILENM[], 
								char  pc_SERVERNM[], 
								DBHANDLE *const  ph, 
								char *const  pc_class)	{
	STATUS  us_err;

	if (!( pc_FILENM && *pc_FILENM && pc_SERVERNM && ph))
		return !eus_SUCCESS;

	if (pc_class)
		*pc_class = NULL;

	//open the specified database and ensure it's a Notes Mail database
	if (us_err = eus_OpenMailDb( pc_FILENM, pc_SERVERNM, ph))
		return us_err;

	if (us_err = eus_TestDbIsTemplate( *ph, pc_class))	{
		NSFDbClose( *ph);
		*ph = NULL;
	}

	return us_err;
} //eus_OpenMailTemplate(
int main(int argc, char *argv[])
{
    DBHANDLE    db_handle;    /* handle of source database */
    STATUS      error = NOERROR;   /* return #Dtatus from API calls */
    
    char        formula[STRING_LENGTH];
    char        database_name[STRING_LENGTH];
    char        username_name[STRING_LENGTH];
    char        *pUserName = username_name;    
    char        *pDbFileName = database_name;  /* pathname of source database */

    ProcessArgs(argc, argv);
    
    // ConfigAgent.exe idfile passwd server dbfile formname

    char *pIDFileName = argv[1]; //"C:\\Program Files\\lotus\\notes\\data\\admin.id";
    char *pPassword = argv[2];    //"mac8.6";
    char *pServer = argv[3];    // benz
    char *pDatabase = argv[4];    // smd\smconf.nsf
    char *pForm = argv[5];    // policy

    if (strncmp(pForm, "*", strlen(pForm)) == 0)
        strncpy(formula, "@All", 5);
    else
    {
        _snprintf(formula, sizeof(formula)-1, "Form=\"%s\"", pForm);
        formula[sizeof(formula)-1] = '\0';
    }

    if (error = NotesInitExtended (argc, argv))
    {
        printf("\n Unable to initialize Notes.\n");
        return CONFIG_AGENT_ERROR_NOTE_INIT_FAIL;
    }

    if (error = OSPathNetConstruct( NULL, pServer, pDatabase, pDbFileName))
    {
        PrintAPIError (error);
        NotesTerm();
        return CONFIG_AGENT_ERROR_PATH_CONSTRUCT_FAIL;
    }

    if (error = SECKFMSwitchToIDFile(pIDFileName, pPassword,
        pUserName, STRING_LENGTH, fKFM_switchid_DontSetEnvVar, NULL))
    {
        printf ("Error: unable to open the id file '%s'\n", pIDFileName);
        PrintAPIError (error);
        NotesTerm();
        if (error == ERR_NOEXIST)
            return CONFIG_AGENT_ERROR_IDFILE_NOT_EXIST;
        else if (error == ERR_BSAFE_BADPASSWORD)
            return CONFIG_AGENT_ERROR_BAD_PASSWORD;
        else
            return CONFIG_AGENT_ERROR_SWITCH_ID_FAIL;
    }
    /* Open the database. */

    if (error = NSFDbOpen (pDbFileName, &db_handle))
    {
        printf ("Error: unable to open database '%s'\n", pDbFileName);
        PrintAPIError (error);
        NotesTerm();
        return CONFIG_AGENT_ERROR_DB_OPEN_FAIL;
    }
    
    /* Compile the selection formula. */

    //char        formula[] = "select form=\"Events\""; /* an ASCII selection formula. */
    FORMULAHANDLE    formula_handle;    /* a compiled selection formula */
    WORD     wdc;                       /* a word we don't care about */
    if (error = NSFFormulaCompile (
                NULL,               /* name of formula (none) */
                (WORD) 0,           /* length of name */
                formula,            /* the ASCII formula */
                (WORD) strlen(formula),    /* length of ASCII formula */
                &formula_handle,    /* handle to compiled formula */
                &wdc,               /* compiled formula length (don't care) */
                &wdc,               /* return code from compile (don't care) */
                &wdc, &wdc, &wdc, &wdc)) /* compile error info (don't care) */
        
    {
        NSFDbClose (db_handle);
        PrintAPIError (error);  
        NotesTerm();
        return CONFIG_AGENT_ERROR_FORMULA_COMPILE_FAIL;
    }
    /*  Call NSFSearch to find all data notes in the database.
        Specify search flag SEARCH_SUMMARY so that the action
        routine gets passed the summary buffer as input.
    */

    if (error = NSFSearch (
        db_handle,          /* database handle */
        formula_handle,         /* selection formula */
        NULL,               /* title of view in selection formula */
        SEARCH_SUMMARY,     /* search flags: get summary data! */
        NOTE_CLASS_DATA,    /* note class to find */
        NULL,               /* starting date (unused) */
        ReadSummaryData,    /* action routine for notes found */
        NULL,               /* argument to action routine */
        NULL))              /* returned ending date (unused) */

    {
        printf ("Error: unable to search database.\n");
        NSFDbClose (db_handle);
        PrintAPIError (error);
        NotesTerm();
        return CONFIG_AGENT_ERROR_DB_SERACH_FAIL;
    }

    /* Close the database. */
    if (error = NSFDbClose (db_handle))
    {
        printf ("Error: unable to close database '%s'\n", pDbFileName);
        PrintAPIError (error);
        NotesTerm();
        return CONFIG_AGENT_ERROR_DB_CLOSE_FAIL;
    }

    /* End of main routine. */
    printf("\nProgram completed successfully.\n");
    NotesTerm();
    return CONFIG_AGENT_ERROR_SUCCESS;
}
/******************************************************************************
	Takes the fullpath to a Domino directory.  Returns the first match
	to 'name' from the '($Users)' view.
	Allows case-insensitive & partial match
	Returns empty string if not found
******************************************************************************/
std::wstring RecipientsHandler::SearchDominoDirectory(char* pszDirectoryPath, const std::wstring &name) 
{
	std::wstring		result;
	WORD				wABCount = 0;
	WORD				wABBufferLength = 0;
	WORD				wSignalFlags;
	WORD				wItemDataType;
	DWORD				dwMatches = 0;
	DWORD				dwEntriesFound = 0;
	HANDLE				hABBuffer = 0;
	HANDLE				hSummaryBuffer = 0;
	DBHANDLE			hdbDirectory = 0;
	HCOLLECTION			hCollection = 0;
	NOTEID				nidLookupView;
	COLLECTIONPOSITION	cp;
	ITEM_VALUE_TABLE*	pivt;
	WORD*				pItemLengthTable;
	BYTE*				pItem;
	LIST*				plHeader;
	char				szBuffer[MAXUSERNAME] = {0};

	STATUS	status = NSFDbOpen(pszDirectoryPath, &hdbDirectory);

	if (NOERROR == status)
	{
		status = NIFFindView(hdbDirectory, USERNAMESSPACE_ALT, &nidLookupView);
		if (NOERROR == status)
		{
			status = NIFOpenCollection(	hdbDirectory,
										hdbDirectory,
										nidLookupView,
										0,
										NULLHANDLE,
										&hCollection,
										NULLHANDLE,
										NULL,
										NULLHANDLE,
										NULLHANDLE);
			if (NOERROR == status)
			{
				status = NIFFindByName(	hCollection,
										Workshare::Conversions::W22LMBCS(name).c_str(),
										FIND_PARTIAL | FIND_CASE_INSENSITIVE,
										&cp,
										&dwMatches);
				if (NOERROR == status && dwMatches > 0)
				{
					do
					{
						status = NIFReadEntries(hCollection,
												&cp,
												NAVIGATE_CURRENT,
												0,
												NAVIGATE_NEXT,
												dwMatches,
												READ_MASK_SUMMARYVALUES,
												&hSummaryBuffer,
												NULL,
												NULL,
												&dwEntriesFound,
												&wSignalFlags);
						if (NOERROR == status && hSummaryBuffer != NULLHANDLE)
						{
							pivt = OSLock(ITEM_VALUE_TABLE, hSummaryBuffer);
							if (dwEntriesFound > 0)
							{
								if (pivt->Items > 0)
								{
									pItemLengthTable = (WORD*)++pivt;
									pivt--;
									pItem = (BYTE*)pItemLengthTable;
									pItem += (pivt->Items * sizeof(WORD));
									// at this point pItemLength -> 1st item length
									// pItem -> 1st item datatype WORD
									wItemDataType = *((WORD*)pItem);
									pItem += sizeof(WORD);			// pItem -> data
									switch (wItemDataType)
									{
										case TYPE_TEXT:
										{
											strncpy_s(szBuffer, sizeof(szBuffer), (char*)pItem, pItemLengthTable[0]);
											result = Workshare::Conversions::LMBCS22W(szBuffer);
											break;
										}
										case TYPE_TEXT_LIST:
										{
											plHeader = (LIST*)pItem;
											if (plHeader->ListEntries > 0)
											{
												pItemLengthTable = (WORD*)++plHeader;
												plHeader--;
												pItem = (BYTE*)plHeader;
												pItem += sizeof(LIST) + plHeader->ListEntries * sizeof(WORD);
												strncpy_s(szBuffer, sizeof(szBuffer), (char*)pItem, pItemLengthTable[0]);
												result = Workshare::Conversions::LMBCS22W(szBuffer);
											}
											break;
										}
										default:
										{
											break;
										}
									}
								}
							}
							OSUnlock(hSummaryBuffer);
							OSMemFree(hSummaryBuffer);
						}
					wSignalFlags = 0;	// to ensure we only go around once
					} while (wSignalFlags & SIGNAL_MORE_TO_DO);
				}
				NIFCloseCollection(hCollection);
			}
		}
		NSFDbClose(hdbDirectory);
	}
	return result;
}
/******************************************************************************
	Searches a CONDENSED directory for the specified name
	Allows case-insensitive & partial match
	Returns empty string if not found
******************************************************************************/
std::wstring RecipientsHandler::SearchCondensedDirectory(char* pszDirectoryPath, const std::wstring &name) 
{
	#define	LOOKUP_VIEW	"Users"
									// Column numbers counting from 0
	#define SEARCH_COLUMN	1		// lookup column
	#define	RETURN_COLUMN	3		// return column(@Subset(FullName;1)
									// lookup column must be < return column

	std::wstring		result;
	std::wstring		columnvalue;
	WORD				wABCount = 0;
	WORD				wABBufferLength = 0;
	WORD				wSignalFlags;
	WORD				wItemDataType;
	WORD				wIVTLength;
	DWORD				dwEntriesFound = 0;
	DWORD				dwEntryIndex;
	HANDLE				hABBuffer = 0;
	HANDLE				hSummaryBuffer = 0;
	DBHANDLE			hdbDirectory = 0;
	HCOLLECTION			hCollection = 0;
	NOTEID				nidLookupView;
	COLLECTIONPOSITION	cp;
	ITEM_VALUE_TABLE*	pivt;
	BYTE*				pSummaryBuffer;
	WORD*				pItemLengthTable;
	BYTE*				pItem;
	int					nColumnCount;
	char				szBuffer[MAXUSERNAME] = {0};

	STATUS	status = NSFDbOpen(pszDirectoryPath, &hdbDirectory);

	if (NOERROR == status)
	{
		status = NIFFindView(hdbDirectory, LOOKUP_VIEW, &nidLookupView);
		if (NOERROR == status)
		{
			status = NIFOpenCollection(	hdbDirectory,
										hdbDirectory,
										nidLookupView,
										0,
										NULLHANDLE,
										&hCollection,
										NULLHANDLE,
										NULL,
										NULLHANDLE,
										NULLHANDLE);
			if (NOERROR == status)
			{
				cp.Level = 0;
				cp.Tumbler[0] = 0;
				do
				{
					status = NIFReadEntries(hCollection,
											&cp,
											NAVIGATE_NEXT,
											1,
											NAVIGATE_NEXT,
											0xffffffff,
											READ_MASK_SUMMARYVALUES,
											&hSummaryBuffer,
											NULL,
											NULL,
											&dwEntriesFound,
											&wSignalFlags);
					if (NOERROR == status && hSummaryBuffer != NULLHANDLE)
					{
						pSummaryBuffer = OSLock(BYTE, hSummaryBuffer);
						wIVTLength = 0;
						for (dwEntryIndex = 0; dwEntryIndex < dwEntriesFound; dwEntryIndex++)
						{	
							pSummaryBuffer += wIVTLength;
							pivt = (ITEM_VALUE_TABLE*)pSummaryBuffer;
							wIVTLength = pivt->Length;

							if (pivt->Items > RETURN_COLUMN)
							{
								pItemLengthTable = (WORD*)++pivt;
								pivt--;
								pItem = (BYTE*)pItemLengthTable;
								pItem += (pivt->Items * sizeof(WORD));
								// at this point pItemLengthTable -> 1st item length
								// pItem -> 1st item datatype WORD

								// bump up to the specified COLUMN_NUMBER
								for (nColumnCount = 0; nColumnCount < SEARCH_COLUMN; nColumnCount++)
								{
									pItem += *pItemLengthTable++;
								}

								wItemDataType = *((WORD*)pItem);
								pItem += sizeof(WORD);			// pItem -> data
								if (wItemDataType == TYPE_TEXT)
								{
									strncpy_s(szBuffer, sizeof(szBuffer), (char*)pItem, pItemLengthTable[0] - sizeof(WORD));
									columnvalue = Workshare::Conversions::LMBCS22W(szBuffer);
									if (_wcsnicmp(columnvalue.c_str(), name.c_str(), name.length()) == 0)
									{
										pItem -= sizeof(WORD);
										// bump up to the column to be returned
										for (nColumnCount = SEARCH_COLUMN; nColumnCount < RETURN_COLUMN; nColumnCount++)
										{
											pItem += *pItemLengthTable++;
										}
										wItemDataType = *((WORD*)pItem);
										pItem += sizeof(WORD);			// pItem -> data
										if (wItemDataType == TYPE_TEXT)
										{
											strncpy_s(szBuffer, sizeof(szBuffer), (char*)pItem, pItemLengthTable[0] - sizeof(WORD));
											result = Workshare::Conversions::LMBCS22W(szBuffer);
											wSignalFlags = 0;	// exits do - while
											break;				// exits for
										}
									}
								}
							}
						} // end for
						OSUnlock(hSummaryBuffer);
						OSMemFree(hSummaryBuffer);
					}
				}
				while (wSignalFlags & SIGNAL_MORE_TO_DO);
				NIFCloseCollection(hCollection);
			}
		}
		NSFDbClose(hdbDirectory);
	}
	return result;
}
Exemple #11
0
BOOL NSF_List(CString strServer, CString strDirectory, CStringList &lstTexts,  CStringList &lstValues, char* szReturn)
{
	char        szFullNetPath[MAXPATH] = ""; /* full network path */
    DBHANDLE    dir_handle;                 /* handle for directory */
    STATUS      error = NOERROR;            /* return status from API calls */

	error = NotesInitExtended (0, NULL);
	if (error)
	{
		OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
		return FALSE;
	}
	
    if (strDirectory != _T(""))
    {
        strcpy(szFullNetPath, strDirectory.GetBuffer(0));
    }
    
    if(strServer != _T(""))
    {
        // Compose the full network pathname to the directory. 
        if (error = OSPathNetConstruct(NULL, strServer.GetBuffer(0), strDirectory.GetBuffer(0), szFullNetPath))
	     {
		      OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
		      NotesTerm();
		      return FALSE;
	     }
    }

    // Open the directory. 
    if (error = NSFDbOpen (szFullNetPath, &dir_handle))
    {
        OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
        NotesTerm();
        return FALSE;
    }

    /* Call NSFSearch to find files in the directory. For each file found,
    call an action routine. */
    if (error = NSFSearch (
        dir_handle,        /* directory handle */
        NULLHANDLE,        /* selection formula */
        NULL,              /* title of view in formula */
        SEARCH_FILETYPE +  /* search for files */
        SEARCH_SUMMARY,    /* return a summary buffer */
        FILE_DBANY +       /* find any .NS? file */
        FILE_DIRS +        /* find subdirectories */
        FILE_NOUPDIRS,     /* don't find the ".." dir */
        NULL,              /* starting date */
        file_action_list,  /* call for each file found */
        &lstTexts,         /* argument to action routine */
        NULL))             /* returned ending date (unused) */

        {
            OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
            NSFDbClose (dir_handle);
            NotesTerm();
            return FALSE;
        }

    /* Close the directory. */
    if (error = NSFDbClose (dir_handle))
    {
        OSLoadString(NULLHANDLE, ERR(error), szReturn, 1024);
        NotesTerm();
        return FALSE;
    }

    /* Terminate Domino and Notes. */
    NotesTerm();
    POSITION pos=NULL;
    pos = lstTexts.GetHeadPosition();
    while(pos)
    {
        lstValues.AddTail(lstTexts.GetNext(pos));        
    }
	return TRUE;
}
Exemple #12
0
_declspec ( dllexport ) WORD GetServerNamesEx(char retServerNames[MAX_SERVERS][MAXPATH])
{
	BOOL status = NOERROR;
	char szLocation[MAXENVVALUE];
	char szPAB[MAXENVVALUE];
	HANDLE db;
	char full_netpath[MAXPATH-1];
	NOTEID view_id;
	HCOLLECTION hCollection;
	COLLECTIONPOSITION pCollPosition;
	HANDLE hBuffer;
	DWORD NumberReturned = 0;
	NOTEID *IdList;
	NOTEHANDLE note;
	char szFieldName[80] = { 0 };
	char szFieldType[80] = { 0 };
	WORD retServerCount = 0;
	bool bUseLocal = false;

	// first, get the name of the current location
	status = OSGetEnvironmentString("Location", szLocation, MAXENVVALUE);
	if (status == TRUE) 
	{
		char *pb = strchr(szLocation, ',');
		if (pb != NULL)
			*pb = 0 ;
	}

	status = OSGetEnvironmentString("MAILSERVER", szPAB, MAXENVVALUE);
	if (status == TRUE) 
	{
		char *pb = strchr(szPAB, ',');
		if (pb != NULL)
			*pb = 0 ;
	}

	if (status = OSPathNetConstruct(NULL, szPAB, _T("names.nsf"), full_netpath))
	{
		printf("unable to open the public NAB %s!!names.nsf\n", szFieldName);
		return 0;
	}

	if (status = NSFDbOpen (full_netpath, &db))
        return 0;

	if (bUseLocal)
	{
		// choose local PAB view
		if (status = NIFFindView(db, _T("Connections"), &view_id))
		{
			NSFDbClose(db);
			return 0;
		}
	} else
	{
		// choose server list from server Directory
		if (status = NIFFindView(db, _T("Servers"), &view_id))
		{
			NSFDbClose(db);
			return 0;
		}
	}

	if (status = NIFOpenCollection( db,	 
									db,	  
		                			view_id,	 
									0,		   
		                			NULLHANDLE,	  
                					&hCollection,	 
		                			NULL,		   
		                			NULL,		
									NULL,	    	
		                			NULL ))	
	{
		NSFDbClose(db);
		return 0;
	}

	pCollPosition.Level = 0;
	pCollPosition.Tumbler[0] = 1;

	 if (status = NIFReadEntries(hCollection,	
							     &pCollPosition,		
							     NAVIGATE_CURRENT,	   
							     1L,		
							     NAVIGATE_NEXT,	   
							     0xFFFFFFFF,		  
							     READ_MASK_NOTEID,	
							     &hBuffer,	  
							     NULL,		 
							     NULL,		 
							     &NumberReturned,	  
							     NULL))		
	 {
		NIFCloseCollection(hCollection);
		NSFDbClose(db);
		return 0;
	 }

	 strcpy_s(retServerNames[retServerCount++], MAXPATH, _T("Local"));
	 if (NumberReturned != 0) 
	 {
		if (hBuffer != NULLHANDLE)
        {
    		IdList = (NOTEID far *)OSLockObject(hBuffer);
    		for (DWORD i=0; i<(DWORD)NumberReturned; i++)
			{
  				if (status = NSFNoteOpen( db, IdList[i], 0, &note))
				{
					// skip categories
				} else
				{
					// scan documents
					WORD lenFieldName = NSFItemGetText(note, 
													  (bUseLocal) ? _T("Destination") : _T("ServerName"), 
													  szFieldName, 
													  sizeof(szFieldName)); 
					strcpy_s(retServerNames[retServerCount++], MAXPATH, szFieldName);
					status = NSFNoteClose(note);
				}
			}
			OSUnlockObject(hBuffer);
            OSMemFree(hBuffer);
		}
	}

	if (status)
	{
		NIFCloseCollection(hCollection);
		NSFDbClose(db);
		return 0;
	}

	if (status = NIFCloseCollection(hCollection))
	{
		NSFDbClose(db);
		return 0;
	}

	if (status = NSFDbClose(db))
		return 0;

	return retServerCount;
}
Exemple #13
0
_declspec ( dllexport ) STATUS ATOM_NSFDbClose(HANDLE hDB)
{
	return NSFDbClose(hDB);
}