예제 #1
0
STATUS NF_Command(char *server ,char* szcommand,char * szResult)
{
	HANDLE hRetInfo;
	STATUS nError;
	char *pBuffer;
        
	nError = NotesInitExtended (0, NULL);
	if (nError)
		return ERR(nError);
	
	nError = NSFRemoteConsole (server, szcommand, &hRetInfo);
	if (nError != NOERROR)
	{
		OSLoadString(NULLHANDLE, ERR(nError), szResult, 1024);
		CutFlag(szResult,0x13);
		NotesTerm();
		return (ERR(nError));
	}
	
	pBuffer = OSLock (char, hRetInfo);
	strcpy(szResult,pBuffer);
	OSUnlock (hRetInfo);
	OSMemFree (hRetInfo);
	NotesTerm();
	
	return (NOERROR);
}
예제 #2
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;
}
예제 #3
0
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
		// called when DLL is first mapped into calling process's address space
		case DLL_PROCESS_ATTACH:
		// Initialize the C API.
		NotesInitExtended((int)0, (char**)NULL); // not using command line args
		break;

		// called when DLL is un-mapped from calling process's address space
		case DLL_PROCESS_DETACH:
		// Terminate the API.
		NotesTerm();
		break;

	}
	return TRUE;
}
예제 #4
0
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;
}
예제 #5
0
extern "C" _declspec (dllexport) BOOL Init(const char * strParas, char * szRet, int& nSize)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	STATUS nStatus = NOERROR;

	CString strServerName=_T("");
	CString strUserAccount=_T("");
	CString strPassWord=_T("");

	CStringList lstParas;
	MakeStringListByChar(lstParas,strParas);

	strServerName = GetValueFromList("_ServerName",lstParas);
	strUserAccount = GetValueFromList("_UserAccount",lstParas);	
	strPassWord = GetValueFromList("_PassWord",lstParas);

	char szResult[1024*10]={0};
	char szServer[1024]={0};
	strcpy(szServer,strServerName);
	
	HANDLE hhandle =CreateMutex(NULL,FALSE,"Global\\SiteView-Lotus-Montior");
	if(hhandle ==NULL)
	{
		DWORD nlast;
		nlast =GetLastError();
		sprintf(szRet,"error=CreateMutex Failed code is %d", nlast);
		nSize = static_cast<int>(strlen(szRet));
		return FALSE;
	}
	WaitForSingleObject(hhandle,INFINITE);

	WritePassword(strPassWord);

	nStatus = NotesInitExtended (0, NULL);
    if (nStatus != NOERROR)
    {
		ReleaseMutex(hhandle);
		CloseHandle(hhandle);
		OSLoadString(NULLHANDLE, ERR(nStatus), szResult, 1024);
		CutFlag(szResult,0x13);
		sprintf(szRet,"error=Can't Init Notes Extended:%s", szResult);
		nSize = static_cast<int>(strlen(szRet));
        return FALSE;
    }

	nStatus=NF_Command(szServer,"show server",szResult);
	if(nStatus != NOERROR)
	{
		ReleaseMutex(hhandle);
		CloseHandle(hhandle);
		sprintf(szRet,"error=Can't Connect to Server:%s", szResult);
		nSize = static_cast<int>(strlen(szRet));
		NotesTerm();
		return FALSE;
	}
	
	NotesTerm();
	sprintf(szRet,"Connected to Server[%s]", szServer);
	nSize = static_cast<int>(strlen(szRet));
	
	ReleaseMutex(hhandle);
	CloseHandle(hhandle);

	return TRUE;
}
예제 #6
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;
}
예제 #7
0
_declspec ( dllexport) void ThreadInitialize() {
	NotesInitExtended((int)0, (char**)NULL);
}