Beispiel #1
0
void RenderGraph::BeginPass(int i) const
{
	// Provided required input textures
	for (const ColorTargetInputInfo& inputInfo : GetPass(i).GetColorTargetInputInfos())
	{
		if (!inputInfo.semantic.empty())
		{
			const auto& it = m_availableSemantics.find(inputInfo.semantic);
			DogeAssert(it != m_availableSemantics.end());

			auto colorTargetFrom = it->second;

			DogeAssert(colorTargetFrom.passIndexFrom < i);

			BindTextureAndSamplerToSlot(
				GetPass(colorTargetFrom.passIndexFrom).m_glColorTexIds[colorTargetFrom.slot], 
				G_RENDERER2.GetDefaultPointSamplerId(), 
				inputInfo.slot);
		}
		else
		{
			DogeAssert(i > 0);
			DogeAssert(GetPass(i - 1).m_glColorTexIds.size() > 0);

			BindTextureAndSamplerToSlot(
				GetPass(i - 1).m_glColorTexIds[0],
				G_RENDERER2.GetDefaultPointSamplerId(),
				inputInfo.slot);
		}
	}

	GetPass(i).PreRender();
}
Beispiel #2
0
void CCore::ConnectToServer(CString strHost, unsigned short usPort, CString strPass)
{
	// Declare our basic network connection
	SetHost(strHost);
	SetClientPort(usPort);
	SetPass(strPass);

	// Connect to the network
	CHECK_VALID_VOID(m_pNetworkManager)
		m_pNetworkManager->Connect(GetHost(), (unsigned short) GetPort(), GetPass());
}
Beispiel #3
0
Pass* Technique::CreatePass(StringHash type)
{
    Pass* oldPass = GetPass(type);
    if (oldPass)
        return oldPass;
    
    SharedPtr<Pass> newPass(new Pass(type));
    passes_.Insert(type.Value(), newPass);
    
    return newPass;
}
QString GlobalPasswordProvider::Get()
{
    if(pass.isEmpty())
    {
        auto dialog = new PassDialog(nullptr);
        dialog->exec();
        pass = dialog->GetPass();
        delete dialog;
    }

    return pass;
}
Beispiel #5
0
Pass* Technique::CreatePass(StringHash type)
{
    /// \todo Memory use is not tracked when creating passes programmatically due to HashTable not returning the element count
    Pass* oldPass = GetPass(type);
    if (oldPass)
        return oldPass;
    
    SharedPtr<Pass> newPass(new Pass(type));
    passes_.Insert(type.Value(), newPass);
    
    return newPass;
}
NzDeferredRenderPass* NzDeferredRenderTechnique::ResetPass(nzRenderPassType renderPass, int position)
{
	std::unique_ptr<NzDeferredRenderPass> smartPtr; // Nous évite un leak en cas d'exception

	switch (renderPass)
	{
		case nzRenderPassType_AA:
			smartPtr.reset(new NzDeferredFXAAPass);
			break;

		case nzRenderPassType_Bloom:
			smartPtr.reset(new NzDeferredBloomPass);
			break;

		case nzRenderPassType_DOF:
			smartPtr.reset(new NzDeferredDOFPass);
			break;

		case nzRenderPassType_Final:
			smartPtr.reset(new NzDeferredFinalPass);
			break;

		case nzRenderPassType_Fog:
			smartPtr.reset(new NzDeferredFogPass);
			break;

		case nzRenderPassType_Forward:
			smartPtr.reset(new NzDeferredForwardPass);
			break;

		case nzRenderPassType_Geometry:
			smartPtr.reset(new NzDeferredGeometryPass);
			break;

		case nzRenderPassType_Lighting:
			smartPtr.reset(new NzDeferredPhongLightingPass);
			break;

		case nzRenderPassType_SSAO:
			//smartPtr.reset(new NzDeferredSSAOPass);
			break;
	}

	NzDeferredRenderPass* oldPass = GetPass(renderPass, position);
	if (oldPass && !oldPass->IsEnabled())
		smartPtr->Enable(false);

    SetPass(renderPass, position, smartPtr.get());
    return smartPtr.release();
}
void LoginForm::SaveSettings()
{
    QSettings settings(QSettings::defaultFormat(), QSettings::UserScope, "qutim/qutim."+m_profileName, "mrimsettings");
    QStringList accounts = settings.value("accounts/list").toStringList();
    QString email = GetEmail(), pass = GetPass();

    if( !accounts.contains(email) )
    {
        accounts<<email;
        accounts.sort();
        settings.setValue("accounts/list", accounts);
    }
    QSettings account_settings(QSettings::defaultFormat(), QSettings::UserScope, "qutim/qutim."+m_profileName+"/mrim."+email, "accountsettings");
    account_settings.setValue("main/login", email);
    account_settings.setValue("main/password", pass);
}
Beispiel #8
0
Mailbox::Mailbox(char* name, unsigned numSubjects):
	mail()
{
	// Copy args
	strcpy(sName, name);
	iSubjects = numSubjects;
	
	// Copy the rest of the args derived from the mailbox name
	strcpy(sSetting, name);
	strcat(sSetting, "server");
	if(GetRCString(sSetting, sServer, NULL, MAX_LINE_LENGTH))
	{
		strcpy(sSetting, name);
		strcat(sSetting, "type");
		GetRCString(sSetting, sType, "pop3", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "user");
		GetRCString(sSetting, sUser, "anonymous", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "port");
		if (!strcmp("imap", sType)) GetRCString(sSetting, sPort, "143", MAX_LINE_LENGTH);
		else GetRCString(sSetting, sPort, "110", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "password");
		GetRCString(sSetting, sPass, "", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "folder");
		GetRCString(sSetting, sFolder, "inbox", MAX_LINE_LENGTH);

		// If no password was found in config, get it from database/dialog
		if (!(*sPass)) GetPass();

		// Set evars
		strcpy(sEvar, "AcidMail");
		strcat(sEvar, name);
		LSSetVariable(sEvar, "0");
		strcpy(sErrorVar, sEvar);
		strcat(sErrorVar, "Error");
		LSSetVariable(sErrorVar, "none");		
	}
	else
	{
		ErrorHandler(Error(false, LOG_ERROR, "No host found in config files", NULL));
		mail.bError = true;		
	}
}
Beispiel #9
0
Pass* Technique::CreatePass(const ea::string& name)
{
    Pass* oldPass = GetPass(name);
    if (oldPass)
        return oldPass;

    ea::shared_ptr<Pass> newPass(new Pass(name));
    unsigned passIndex = newPass->GetIndex();
    if (passIndex >= passes_.size())
        passes_.resize(passIndex + 1);
    passes_[passIndex] = newPass;

    // Calculate memory use now
    SetMemoryUse((unsigned)(sizeof(Technique) + GetNumPasses() * sizeof(Pass)));

    return newPass;
}
Beispiel #10
0
char SqlTableUsers::IsUserReg( char* _pcL, char* _pcP, uint32_t& _nID )
{
	TVecChar vecP;
	if( !GetPass( _pcL, &vecP ) )
		return ERRBADLOGIN;

	// TODO - convert to one 'if' !
        if( strlen(_pcP) == vecP.size() )
        {
		if( strncmp( _pcP, &vecP[0], vecP.size() ) )
			return ERRBADPASS;
	}
	else
		return ERRBADPASS;

	if( !GetID( _pcL, _nID ) )
		return ERRBADLOGIN;

	return NOERR;
}
Beispiel #11
0
char SqlTableUsers::DoUserReg( char* _pcL, char* _pcP, uint32_t& _nID )
{
	int nSize = strlen( _pcL );

	if( ( nSize < MIN_USER_LOGIN_LENGTH ) || ( MAX_USER_LOGIN_LENGTH < nSize ) || !CheckCharSet( _pcL ) )
		return ERRBADLOGIN;

	nSize = strlen( _pcP );

	if( ( nSize < MIN_USER_PASSWORD_LENGTH ) || ( MAX_USER_PASSWORD_LENGTH < nSize ) || !CheckCharSet( _pcP ) )
		return ERRBADPASS;

	TVecChar vecP;
	if( GetPass( _pcL, &vecP ) )
		return ERRLOGINEXIST;

	Insert( _pcL, _pcP );

	if( !GetID( _pcL, _nID ) )
		return ERRBADLOGIN;

	return NOERR;
}
Beispiel #12
0
Pass* Technique::GetPass(const ea::string& name) const
{
    auto i = passIndices.find(name.to_lower());
    return i != passIndices.end() ? GetPass(i->second) : nullptr;
}
Beispiel #13
0
Pass* Technique::GetPass(const String& name) const
{
    HashMap<String, unsigned>::ConstIterator i = passIndices.Find(name.ToLower());
    return i != passIndices.End() ? GetPass(i->second_) : 0;
}
Beispiel #14
0
GPASampleResult* DX12GPASample::PopulateSampleResult()
{
    size_t sampleDataBytes = 0u;

    // Validate result space
    sampleDataBytes = GetSampleResultLocation()->GetBufferBytes();

    if (0 != sampleDataBytes)
    {
        if (nullptr != GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer())
        {
            gpa_uint64* pResultBuffer = nullptr;
            gpa_uint64 timingData[2] = {};

            if (GetPass()->IsTimingPass())
            {
                pResultBuffer = timingData;
                sampleDataBytes = sizeof(timingData);
            }
            else
            {
                pResultBuffer = GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer();
            }

            if (CopyResult(sampleDataBytes, pResultBuffer))
            {
                if (GetPass()->IsTimingPass())
                {
                    const GPA_HardwareCounters* pHardwareCounters = GetPass()->GetSessionContextCounterAccessor()->GetHardwareCounters();

                    for (CounterCount i = 0; i < GetPass()->GetEnabledCounterCount(); ++i)
                    {
                        CounterIndex counterIndex;
                        GetPass()->GetCounterByIndexInPass(i, &counterIndex);

                        if (counterIndex == pHardwareCounters->m_gpuTimeBottomToBottomDurationCounterIndex)
                        {
                            GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[i] = timingData[1] - timingData[0];
                        }
                        else if (counterIndex == pHardwareCounters->m_gpuTimeBottomToBottomStartCounterIndex)
                        {
                            GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[i] = timingData[0];
                        }
                        else if (counterIndex == pHardwareCounters->m_gpuTimeBottomToBottomEndCounterIndex)
                        {
                            GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[i] = timingData[1];
                        }
                        else if (counterIndex == pHardwareCounters->m_gpuTimeTopToBottomDurationCounterIndex)
                        {
                            GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[i] = timingData[1] - timingData[0];
                        }
                        else if (counterIndex == pHardwareCounters->m_gpuTimeTopToBottomStartCounterIndex)
                        {
                            GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[i] = timingData[0];
                        }
                        else if (counterIndex == pHardwareCounters->m_gpuTimeTopToBottomEndCounterIndex)
                        {
                            GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[i] = timingData[1];
                        }
                        else
                        {
                            GPA_LogError("Unknown timing counter.");
                            GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[i] = 0;
                        }
                    }
                }

                if (IsSampleContinuing())
                {
                    GPASampleResult* pSampleResult = reinterpret_cast<DX12GPASample*>(GetContinuingSample())->PopulateSampleResult();

                    for (size_t counterIter = 0; counterIter < GetPass()->GetEnabledCounterCount(); counterIter++)
                    {
                        GetSampleResultLocation()->GetAsCounterSampleResult()->GetResultBuffer()[counterIter] += pSampleResult->GetAsCounterSampleResult()->GetResultBuffer()[counterIter];
                    }
                }

                MarkAsCompleted();
            }
            else
            {
                GPA_LogError("Unable to get the result from the driver.");
            }
        }
        else
        {
            GPA_LogError("Incorrect space allocated for sample result.");
        }
    }

    return GetSampleResultLocation();
}
Beispiel #15
0
bool DX12GPASample::CopyResult(size_t sampleDataSize, void* pResultBuffer) const
{
    bool isDataReady = false;
    bool isAnyHardwareCounterEnabled = GetPass()->GetEnabledCounterCount() > 0;

    if (nullptr != pResultBuffer)
    {
        if (isAnyHardwareCounterEnabled)
        {
            DX12GPACommandList* pDX12GpaCmdList = reinterpret_cast<DX12GPACommandList*>(GetCmdList());

            IAmdExtGpaSession* pResultSession = nullptr;

            if (IsCopied())
            {
                pResultSession = pDX12GpaCmdList->GetBundleResultAmdExtSession(GetClientSampleId());
            }
            else
            {
                pResultSession = pDX12GpaCmdList->GetAmdExtSession();
            }

            if (nullptr == pResultSession)
            {
                GPA_LogError("Invalid profiling session encountered while copying results.");
            }
            else
            {
                if (pResultSession->IsReady())
                {
                    size_t sampleDataSizeInDriver = 0u;
                    HRESULT driverResult = pResultSession->GetResults(GetDriverSampleId(), &sampleDataSizeInDriver, nullptr);
                    assert(SUCCEEDED(driverResult));
                    assert(sampleDataSize == sampleDataSizeInDriver);

                    if (SUCCEEDED(driverResult) && sampleDataSize == sampleDataSizeInDriver)
                    {
                        driverResult = pResultSession->GetResults(GetDriverSampleId(), &sampleDataSizeInDriver, pResultBuffer);
                        assert(SUCCEEDED(driverResult));

                        if (SUCCEEDED(driverResult))
                        {
                            isDataReady = true;
                        }
                        else
                        {
                            GPA_LogError("Error occurred while getting sample results from driver.");
                        }
                    }
                    else
                    {
                        GPA_LogError("Error occurred while getting sample result size from driver.");
                    }
                }
            }
        }
        else
        {
            // there is no hardware counter enabled in the driver, put zeros in all result location
            memcpy(pResultBuffer, 0, sampleDataSize);
            isDataReady = true;
        }
    }

    return isDataReady;
}
Beispiel #16
0
CConfig CUser::ToConfig() {
	CConfig config;
	CConfig passConfig;

	CString sHash;
	switch (m_eHashType) {
	case HASH_NONE:
		sHash = "Plain";
		break;
	case HASH_MD5:
		sHash = "MD5";
		break;
	case HASH_SHA256:
		sHash = "SHA256";
		break;
	}
	passConfig.AddKeyValuePair("Salt", m_sPassSalt);
	passConfig.AddKeyValuePair("Method", sHash);
	passConfig.AddKeyValuePair("Hash", GetPass());
	config.AddSubConfig("Pass", "password", passConfig);

	config.AddKeyValuePair("Nick", GetNick());
	config.AddKeyValuePair("AltNick", GetAltNick());
	config.AddKeyValuePair("Ident", GetIdent());
	config.AddKeyValuePair("RealName", GetRealName());
	config.AddKeyValuePair("BindHost", GetBindHost());
	config.AddKeyValuePair("DCCBindHost", GetDCCBindHost());
	config.AddKeyValuePair("QuitMsg", GetQuitMsg());
	if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix())
		config.AddKeyValuePair("StatusPrefix", GetStatusPrefix());
	config.AddKeyValuePair("Skin", GetSkinName());
	config.AddKeyValuePair("Language", GetLanguage());
	config.AddKeyValuePair("ChanModes", GetDefaultChanModes());
	config.AddKeyValuePair("Buffer", CString(GetBufferCount()));
	config.AddKeyValuePair("KeepBuffer", CString(KeepBuffer()));
	config.AddKeyValuePair("MultiClients", CString(MultiClients()));
	config.AddKeyValuePair("DenyLoadMod", CString(DenyLoadMod()));
	config.AddKeyValuePair("Admin", CString(IsAdmin()));
	config.AddKeyValuePair("DenySetBindHost", CString(DenySetBindHost()));
	config.AddKeyValuePair("TimestampFormat", GetTimestampFormat());
	config.AddKeyValuePair("AppendTimestamp", CString(GetTimestampAppend()));
	config.AddKeyValuePair("PrependTimestamp", CString(GetTimestampPrepend()));
	config.AddKeyValuePair("TimezoneOffset", CString(m_fTimezoneOffset));
	config.AddKeyValuePair("JoinTries", CString(m_uMaxJoinTries));
	config.AddKeyValuePair("MaxJoins", CString(m_uMaxJoins));
	config.AddKeyValuePair("IRCConnectEnabled", CString(GetIRCConnectEnabled()));

	// Allow Hosts
	if (!m_ssAllowedHosts.empty()) {
		for (set<CString>::iterator it = m_ssAllowedHosts.begin(); it != m_ssAllowedHosts.end(); ++it) {
			config.AddKeyValuePair("Allow", *it);
		}
	}

	// CTCP Replies
	if (!m_mssCTCPReplies.empty()) {
		for (MCString::const_iterator itb = m_mssCTCPReplies.begin(); itb != m_mssCTCPReplies.end(); ++itb) {
			config.AddKeyValuePair("CTCPReply", itb->first.AsUpper() + " " + itb->second);
		}
	}

	// Modules
	CModules& Mods = GetModules();

	if (!Mods.empty()) {
		for (unsigned int a = 0; a < Mods.size(); a++) {
			CString sArgs = Mods[a]->GetArgs();

			if (!sArgs.empty()) {
				sArgs = " " + sArgs;
			}

			config.AddKeyValuePair("LoadModule", Mods[a]->GetModName() + sArgs);
		}
	}

	// Networks
	for (unsigned int d = 0; d < m_vIRCNetworks.size(); d++) {
		CIRCNetwork *pNetwork = m_vIRCNetworks[d];
		config.AddSubConfig("Network", pNetwork->GetName(), pNetwork->ToConfig());
	}

	return config;
}
Beispiel #17
0
void RenderGraph::EndPass(int i) const
{
	GetPass(i).PostRender();
}
Beispiel #18
0
bool CUser::WriteConfig(CFile& File) {
	File.Write("<User " + GetUserName().FirstLine() + ">\n");

	if (m_eHashType != HASH_NONE) {
		CString sHash = "md5";
		if (m_eHashType == HASH_SHA256)
			sHash = "sha256";
		if (m_sPassSalt.empty()) {
			PrintLine(File, "Pass", sHash + "#" + GetPass());
		} else {
			PrintLine(File, "Pass", sHash + "#" + GetPass() + "#" + m_sPassSalt + "#");
		}
	} else {
		PrintLine(File, "Pass", "plain#" + GetPass());
	}
	PrintLine(File, "Nick", GetNick());
	PrintLine(File, "AltNick", GetAltNick());
	PrintLine(File, "Ident", GetIdent());
	PrintLine(File, "RealName", GetRealName());
	PrintLine(File, "BindHost", GetBindHost());
	PrintLine(File, "DCCBindHost", GetDCCBindHost());
	PrintLine(File, "QuitMsg", GetQuitMsg());
	if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix())
		PrintLine(File, "StatusPrefix", GetStatusPrefix());
	PrintLine(File, "Skin", GetSkinName());
	PrintLine(File, "ChanModes", GetDefaultChanModes());
	PrintLine(File, "Buffer", CString(GetBufferCount()));
	PrintLine(File, "KeepBuffer", CString(KeepBuffer()));
	PrintLine(File, "MultiClients", CString(MultiClients()));
	PrintLine(File, "BounceDCCs", CString(BounceDCCs()));
	PrintLine(File, "DenyLoadMod", CString(DenyLoadMod()));
	PrintLine(File, "Admin", CString(IsAdmin()));
	PrintLine(File, "DenySetBindHost", CString(DenySetBindHost()));
	PrintLine(File, "DCCLookupMethod", CString((UseClientIP()) ? "client" : "default"));
	PrintLine(File, "TimestampFormat", GetTimestampFormat());
	PrintLine(File, "AppendTimestamp", CString(GetTimestampAppend()));
	PrintLine(File, "PrependTimestamp", CString(GetTimestampPrepend()));
	PrintLine(File, "TimezoneOffset", CString(m_fTimezoneOffset));
	PrintLine(File, "JoinTries", CString(m_uMaxJoinTries));
	PrintLine(File, "MaxJoins", CString(m_uMaxJoins));
	PrintLine(File, "IRCConnectEnabled", CString(GetIRCConnectEnabled()));
	File.Write("\n");

	// Allow Hosts
	if (!m_ssAllowedHosts.empty()) {
		for (set<CString>::iterator it = m_ssAllowedHosts.begin(); it != m_ssAllowedHosts.end(); ++it) {
			PrintLine(File, "Allow", *it);
		}

		File.Write("\n");
	}

	// CTCP Replies
	if (!m_mssCTCPReplies.empty()) {
		for (MCString::const_iterator itb = m_mssCTCPReplies.begin(); itb != m_mssCTCPReplies.end(); ++itb) {
			PrintLine(File, "CTCPReply", itb->first.AsUpper() + " " + itb->second);
		}

		File.Write("\n");
	}

	// Modules
	CModules& Mods = GetModules();

	if (!Mods.empty()) {
		for (unsigned int a = 0; a < Mods.size(); a++) {
			CString sArgs = Mods[a]->GetArgs();

			if (!sArgs.empty()) {
				sArgs = " " + sArgs;
			}

			PrintLine(File, "LoadModule", Mods[a]->GetModName() + sArgs);
		}

		File.Write("\n");
	}

	// Servers
	for (unsigned int b = 0; b < m_vServers.size(); b++) {
		PrintLine(File, "Server", m_vServers[b]->GetString());
	}

	// Chans
	for (unsigned int c = 0; c < m_vChans.size(); c++) {
		CChan* pChan = m_vChans[c];
		if (pChan->InConfig()) {
			File.Write("\n");
			if (!pChan->WriteConfig(File)) {
				return false;
			}
		}
	}

	File.Write("</User>\n");

	return true;
}
Beispiel #19
0
int main (int argc, char* argv[])
{
        NWDSCCODE               res;
        nstr8                   UserName   [NW_MAX_USER_NAME_LEN];
        nstr8                   Password   [256];
        nstr8                   Object     [MAX_DN_CHARS+1];
        nstr8                   FileName   [256];
	nstr8			Logfile	   [256];
        nstr8                   ServerName [50];
	NWCONN_HANDLE           ConnHandle;
        FILE*                   BackupFile;
        int                     NonOptArgs;
        BYTE                    OldNameSpace;

        // start off by auto destroying the screen
	AutoDestroyScreen = 0xF;
	
	// increment the thread counter
	ThreadCount++;
	
	// get the main thread group id
	MainThreadGroupId = GetThreadGroupID ();

	// set the signal handler, and disable CTRL-C
	signal (SIGTERM, SigHandler);
	SetCtrlCharCheckMode (FALSE);

	// make sure we've got something to do - i know, this would be more appropriately done in the switch below
	if (argc == 1)
	{
		Usage ();
		return 1;
	}

	clrscr ();
	gotoxy (28, 0);
	printf ("NetWare Rights Utility\n");
	gotoxy (28, 1);
	printf ("(c) 2003  J. Gallimore\n");
	printf ("\n\n");
        
	// create a global context handle
	if ((res = NWDSCreateContextHandle (&NDSContext)) != 0)
        {
                printf ("NWDSCreateContextHandle returned: %d\n", res);
                return 1;
        }

        DoLogin = 0;

        // attempt to retrieve the username and password from the command line
	NonOptArgs = GetOptArgs (argc, argv, UserName, Password, Logfile);

        // login if we need to
	// ask for the username / password, if not specified on the command line
	// if user input is required, don't automatically close the screen
	
	if (!NWIsDSAuthenticated ())
        {
                printf ("Login to NDS\nUsername:"******"") == 0)
       	        {
               	        AutoDestroyScreen = 0x0;
			AwaitingInput = TRUE;
                        gets (UserName);
			AwaitingInput = FALSE;
               	}
                else
       	                printf ("%s\n", UserName);

		// included if the nlm is unloaded whilst inputting details
		if (NlmExiting)
		{
			Cleanup ();
			return 1;
		}

                printf ("Password:"******"") == 0)
       	        {
               	        AutoDestroyScreen = 0x0;
			AwaitingInput = TRUE;
                        GetPass (Password, 256);
			AwaitingInput = FALSE;
               	}
                else
       	                printf ("*\n");

		// included if the nlm is unloaded whilst inputting details
		if (NlmExiting)
		{
			Cleanup ();
			return 1;
		}
                
                if ((res = NWDSLogin (NDSContext, 0, UserName, Password, 0)) != 0)
                {
       	                printf ("NWDSLogin returned: %d\n", res);
               	        Cleanup ();
                       	return 1;
		}
                DoLogin = 1; // if we logged in, we must logout
        }

	// included if the nlm is unloaded whilst inputting details
	if (NlmExiting)
	{
		Cleanup ();
		return 1;
	}

        // open and authenticate a connection to the local box	
	GetFileServerName (0, ServerName);

        if ((res = NWCCOpenConnByName (0, ServerName, NWCC_NAME_FORMAT_NDS, NWCC_OPEN_LICENSED, NWCC_RESERVED, &ConnHandle)) != 0)
        {
                printf ("NWDSOpenConnToNDSServer returned: %d\n", res);
                Cleanup ();
                return 1;
        }
        
        if ((res = NWDSAuthenticateConn (NDSContext, ConnHandle)) != 0)
        {
                printf ("NWDSAuthenticateConn returned: %d\n", res);
                Cleanup ();
                return 1;
        }

        // change to the [Root] context
	if ((res = NWDSSetContext (NDSContext, DCK_NAME_CONTEXT, "[Root]")) != 0)
        {
                printf ("NWDSSetContext returned: %d\n", res);
                Cleanup ();
                return 1;
        }

        // process the command line arguments
	switch (NonOptArgs)
        {
                case 0:
                        Usage ();
                break;

                case 1:
                        Usage ();
                break;

                case 2:
                        if (strncmp (argv [1], "/R=", 3) == 0 || strncmp (argv [1], "/r=", 3) == 0)
                        {
                                if (TrimQuotes (FileName, argv [1] + 3, 256) == 0)
                                {
                                        // perform a restore
					Restore (ConnHandle, FileName, Logfile);
                                }
                        }
                        else
                        {
                                // display trustee rights, don't auto close screen
				AutoDestroyScreen = 0x0;
                                GetTrustees (ConnHandle, 0, argv [1], NW_NS_LONG, 1, NULL);
                        }
                break;

                case 3:
                        if (strncmp (argv [2], "/B=", 3) == 0 || strncmp (argv [2], "/b=", 3) == 0)
                        {
                                // backup the trustee rights to a file
				if (TrimQuotes (FileName, argv[2] + 3, 256) == 0)
                                {
                                        OldNameSpace = SetCurrentNameSpace (NW_NS_LONG);
                                        if ((BackupFile = fopen (FileName, "w")) != NULL)
                                        {
                                                fprintf (BackupFile, "cx [Root]\n");
                                                GetTrustees (ConnHandle, 0, argv [1], NW_NS_LONG, 1, BackupFile);
                                                fclose (BackupFile);
                                        }
                                }
                        }
                break;

                case 4:
                        // set trustee rights or IRF as appropriate
		
			if (strncmp ("/F", argv [3], 2) == 0 || strncmp ("/f", argv [3], 2) == 0)
                        {
                                // inherited rights filter
                                InheritedRights (ConnHandle, 0, argv [1], NW_NS_LONG, argv [2]);
                        }

                        if (strncmp (argv[3], "/NAME=", 6) == 0 || strncmp (argv[3], "/name=", 6) == 0)
                        {
                                // get pointer to name, strip off leading and trailing "
                                if (TrimQuotes (Object, argv [3] + 6, MAX_DN_CHARS+1) == 0)
                                        TrusteeRights (ConnHandle, 0, argv [1], NW_NS_LONG, Object, argv [2]);
                        
                        }

                break;

                default:
                        Usage ();
                break;
        }

        // close local connection and cleanup
	if ((res = NWCCCloseConn (ConnHandle)) != 0)
                printf ("NWCCCloseConn returned: %d\n", res);
        
        Cleanup ();
        return 0;               
}