예제 #1
0
void CNetDDESvrApp::OnDDECreateConversation(CNetDDESvrSocket& oConnection, CNetDDEPacket& oReqPacket)
{
	ASSERT(oReqPacket.DataType() == CNetDDEPacket::DDE_CREATE_CONVERSATION);

	bool bResult = false;

	CString strService;
	CString strTopic;
	HCONV   hConv   = NULL;
	uint32  nConvID = m_nNextConvID++;

	// Decode request message.
	CMemStream oReqStream(oReqPacket.Buffer());

	oReqStream.Open();
	oReqStream.Seek(sizeof(CNetDDEPacket::Header));

	oReqStream >> strService;
	oReqStream >> strTopic;

	oReqStream.Close();

	if (App.m_bTraceConvs)
		App.Trace(TXT("DDE_CREATE_CONVERSATION: %s %s [#%u]"), strService, strTopic, nConvID);

	try
	{
		// Call DDE to create the conversation.
		CDDECltConv* pConv = m_pDDEClient->CreateConversation(strService, strTopic);

		bResult = true;
		hConv   = pConv->Handle();

		// Attach to the connection.
		oConnection.m_aoNetConvs.Add(new CNetDDEConv(pConv, nConvID));

		// Apply settings.
		pConv->SetTimeout(App.m_nDDETimeOut);
	}
	catch (CDDEException& e)
	{
		App.Trace(TXT("DDE_ERROR: %s"), e.twhat());
	}

	// Create response message.
	CBuffer    oRspBuffer;
	CMemStream oRspStream(oRspBuffer);

	oRspStream.Create();

	oRspStream << bResult;
	oRspStream.Write(&hConv, sizeof(hConv));
	oRspStream << nConvID;

	oRspStream.Close();

	// Send response message.
	CNetDDEPacket oRspPacket(CNetDDEPacket::DDE_CREATE_CONVERSATION, oReqPacket.PacketID(), oRspBuffer);

	oConnection.SendPacket(oRspPacket);

	// Update stats.
	++m_nPktsSent;
}
예제 #2
0
static boolean
iter_declaration(
   struct tgsi_iterate_context *iter,
   struct tgsi_full_declaration *decl )
{
   struct dump_ctx *ctx = (struct dump_ctx *)iter;
   boolean patch = decl->Semantic.Name == TGSI_SEMANTIC_PATCH ||
      decl->Semantic.Name == TGSI_SEMANTIC_TESSINNER ||
      decl->Semantic.Name == TGSI_SEMANTIC_TESSOUTER ||
      decl->Semantic.Name == TGSI_SEMANTIC_PRIMID;

   TXT( "DCL " );

   TXT(tgsi_file_name(decl->Declaration.File));

   /* all geometry shader inputs and non-patch tessellation shader inputs are
    * two dimensional
    */
   if (decl->Declaration.File == TGSI_FILE_INPUT &&
       (iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY ||
        (!patch &&
         (iter->processor.Processor == TGSI_PROCESSOR_TESSCTRL ||
          iter->processor.Processor == TGSI_PROCESSOR_TESSEVAL)))) {
      TXT("[]");
   }

   /* all non-patch tess ctrl shader outputs are two dimensional */
   if (decl->Declaration.File == TGSI_FILE_OUTPUT &&
       !patch &&
       iter->processor.Processor == TGSI_PROCESSOR_TESSCTRL) {
      TXT("[]");
   }

   if (decl->Declaration.Dimension) {
      CHR('[');
      SID(decl->Dim.Index2D);
      CHR(']');
   }

   CHR('[');
   SID(decl->Range.First);
   if (decl->Range.First != decl->Range.Last) {
      TXT("..");
      SID(decl->Range.Last);
   }
   CHR(']');

   _dump_writemask(
      ctx,
      decl->Declaration.UsageMask );

   if (decl->Declaration.Array) {
      TXT( ", ARRAY(" );
      SID(decl->Array.ArrayID);
      CHR(')');
   }

   if (decl->Declaration.Local)
      TXT( ", LOCAL" );

   if (decl->Declaration.Semantic) {
      TXT( ", " );
      ENM( decl->Semantic.Name, tgsi_semantic_names );
      if (decl->Semantic.Index != 0 ||
          decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD ||
          decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {
         CHR( '[' );
         UID( decl->Semantic.Index );
         CHR( ']' );
      }
   }

   if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
      TXT(", ");
      ENM(decl->Resource.Resource, tgsi_texture_names);
      if (decl->Resource.Writable)
         TXT(", WR");
      if (decl->Resource.Raw)
         TXT(", RAW");
   }

   if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
      TXT(", ");
      ENM(decl->SamplerView.Resource, tgsi_texture_names);
      TXT(", ");
      if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) &&
          (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) &&
          (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) {
         ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names);
      } else {
         ENM(decl->SamplerView.ReturnTypeX, tgsi_return_type_names);
         TXT(", ");
         ENM(decl->SamplerView.ReturnTypeY, tgsi_return_type_names);
         TXT(", ");
         ENM(decl->SamplerView.ReturnTypeZ, tgsi_return_type_names);
         TXT(", ");
         ENM(decl->SamplerView.ReturnTypeW, tgsi_return_type_names);
      }
   }

   if (decl->Declaration.Interpolate) {
      if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
          decl->Declaration.File == TGSI_FILE_INPUT)
      {
         TXT( ", " );
         ENM( decl->Interp.Interpolate, tgsi_interpolate_names );
      }

      if (decl->Interp.Location != TGSI_INTERPOLATE_LOC_CENTER) {
         TXT( ", " );
         ENM( decl->Interp.Location, tgsi_interpolate_locations );
      }

      if (decl->Interp.CylindricalWrap) {
         TXT(", CYLWRAP_");
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) {
            CHR('X');
         }
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) {
            CHR('Y');
         }
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) {
            CHR('Z');
         }
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) {
            CHR('W');
         }
      }
   }

   if (decl->Declaration.Invariant) {
      TXT( ", INVARIANT" );
   }

   EOL();

   return TRUE;
}
예제 #3
0
inline typename TypedObject<T>::Iterator TypedObject<T>::selectAll(Connection& connection)
{
	tstring query = Core::fmt(TXT("SELECT * FROM %s"), T::WMI_CLASS_NAME);

	return connection.execQuery(query.c_str());
}
예제 #4
0
#include "TheApp.hpp"
#include <WCL/Path.hpp>
#include <WCL/VerInfoReader.hpp>

////////////////////////////////////////////////////////////////////////////////
// The table of command line switches.

enum
{
	USAGE	= 0,	//!< Show the program options syntax.
	VERSION	= 1,	//!< Show the program version and copyright.
};

static Core::CmdLineSwitch s_switches[] = 
{
	{ USAGE,	TXT("?"),	nullptr,		Core::CmdLineSwitch::ONCE,	Core::CmdLineSwitch::NONE,	nullptr,	TXT("Display the program options syntax")	},
	{ USAGE,	TXT("h"),	TXT("help"),	Core::CmdLineSwitch::ONCE,	Core::CmdLineSwitch::NONE,	nullptr,	TXT("Display the program options syntax")	},
	{ VERSION,	TXT("v"),	TXT("version"),	Core::CmdLineSwitch::ONCE,	Core::CmdLineSwitch::NONE,	nullptr,	TXT("Display the program version")			},
};
static size_t s_switchCount = ARRAY_SIZE(s_switches);

////////////////////////////////////////////////////////////////////////////////
//! Default constructor.

TheApp::TheApp()
	: m_parser(s_switches, s_switches+s_switchCount)
{
}

////////////////////////////////////////////////////////////////////////////////
//! Destructor.
예제 #5
0
파일: Writer.cpp 프로젝트: chrisoldwood/XML
namespace XML
{

//! The default indentation style.
const tchar* Writer::DEFAULT_INDENT_STYLE = TXT("\t");

//! The default line terminator.
const tchar* Writer::DEFAULT_TERMINATOR = TXT("\n");
	
////////////////////////////////////////////////////////////////////////////////
//! Default constructor.

Writer::Writer()
	: m_flags(DEFAULT)
	, m_indentStyle(DEFAULT_INDENT_STYLE)
	, m_buffer()
	, m_depth(0)
{
}

////////////////////////////////////////////////////////////////////////////////
//! Constructor.

Writer::Writer(uint flags, const tchar* indentStyle)
	: m_flags(flags)
	, m_indentStyle(indentStyle)
	, m_buffer()
	, m_depth(0)
{
}

////////////////////////////////////////////////////////////////////////////////
//! Destructor.

Writer::~Writer()
{
}

////////////////////////////////////////////////////////////////////////////////
//! Write a document to a string buffer.

tstring Writer::formatDocument(DocumentPtr document)
{
	ASSERT(document.get() != nullptr);

	m_buffer.clear();

	writeContainer(*document.get());

	ASSERT(m_depth == 0);

	return m_buffer;
}

////////////////////////////////////////////////////////////////////////////////
//! Write a document to a string buffer.

tstring Writer::writeDocument(DocumentPtr document, uint flags, const tchar* indentStyle)
{
	XML::Writer writer(flags, indentStyle);

	return writer.formatDocument(document);
}

////////////////////////////////////////////////////////////////////////////////
//! Write a container of nodes to the buffer.

void Writer::writeContainer(const NodeContainer& container)
{
	XML::NodeContainer::const_iterator it = container.beginChild();
	XML::NodeContainer::const_iterator end = container.endChild();

	for (; it != end; ++it)
	{
		if ((*it)->type() == ELEMENT_NODE)
		{
			XML::ElementNodePtr child = Core::dynamic_ptr_cast<XML::ElementNode>(*it);

			writeElement(child);
		}
		else if ((*it)->type() == TEXT_NODE)
		{
			XML::TextNodePtr child = Core::dynamic_ptr_cast<XML::TextNode>(*it);

			m_buffer += child->text();
		}
		else
		{
			ASSERT_FALSE();
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
//! Write the attributes to the buffer.

void Writer::writeAttributes(const Attributes& attributes)
{
	XML::Attributes::const_iterator it = attributes.begin();
	XML::Attributes::const_iterator end = attributes.end();

	for (; it != end; ++it)
	{
		m_buffer += Core::fmt(TXT(" %s=\"%s\""), (*it)->name().c_str(), (*it)->value().c_str());
	}
}

////////////////////////////////////////////////////////////////////////////////
//! Write an element to the buffer.

void Writer::writeElement(ElementNodePtr element)
{
	tstring indentation;
	tstring terminator;

	if (!(m_flags & NO_FORMATTING))
	{
		for (uint i = 0; i != m_depth; ++i)
			indentation += m_indentStyle;

		terminator = DEFAULT_TERMINATOR;
	}

	if (element->hasChildren())
	{
		const bool inlineValue = ( (element->getChildCount() == 1)
								&& (element->getChild(0)->type() == TEXT_NODE) );

		if (!element->getAttributes().isEmpty())
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s"), element->name().c_str());

			writeAttributes(element->getAttributes());

			m_buffer += TXT(">");

			if (!inlineValue)
				m_buffer += terminator;
		}
		else
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s>"), element->name().c_str());

			if (!inlineValue)
				m_buffer += terminator;
		}

		++m_depth;
		writeContainer(*element);
		--m_depth;

		if (!inlineValue)
			m_buffer += indentation;

		m_buffer += Core::fmt(TXT("</%s>"), element->name().c_str());
		m_buffer += terminator;
	}
	else
	{
		if (!element->getAttributes().isEmpty())
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s"), element->name().c_str());

			writeAttributes(element->getAttributes());

			m_buffer += TXT("/>");
			m_buffer += terminator;
		}
		else
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s/>"), element->name().c_str());
			m_buffer += terminator;
		}
	}
}

//namespace XML
}
예제 #6
0
{
	in_addr address = CSocket::Resolve(TXT("localhost"));

	TEST_TRUE(address.S_un.S_addr != 0);
}
TEST_CASE_END

TEST_CASE("failing to resolve a hostname throws")
{
	TEST_THROWS(CSocket::Resolve(TXT("invalid hostname")));
}
TEST_CASE_END

TEST_CASE("a hostname can be resolved to the IP address as a string")
{
	CString address = CSocket::ResolveStr(TXT("localhost"));

	TEST_TRUE(address == TXT("127.0.0.1"));
}
TEST_CASE_END

TEST_CASE("an ip address resolves to the same IP address as a string")
{
	CString address = CSocket::ResolveStr(TXT("127.0.0.1"));

	TEST_TRUE(address == TXT("127.0.0.1"));
}
TEST_CASE_END

TEST_CASE("failing to resolve a hostname to a string throws")
{
예제 #7
0
inline uint64 Win32_LogicalDisk::Size() const
{
	tstring value = getProperty<tstring>(TXT("Size"));

	return Core::parse<uint64>(value);
}
예제 #8
0
DualTracer::DualTracer()
	: COMTraceObject<IDualInterface>(TXT("DualTracer"))
	, COM::IDispatchImpl<DualTracer>(IID_IDualInterface)
{
}
예제 #9
0
파일: chaines.cpp 프로젝트: ProgVal/GOTOPP
/*AIDE Markov
Remplace une partie du texte par une autre et fait éventuellement un GOTO.
\param cible etiquette Où continuer l'exécution si le motif est trouvé.
\param entree reference Une référence sur la chaîne à modifier.
\param borneinf carac La borne inférieure de l'intervalle des caractères interchangeables.
\param bornesup carac La borne supérieure de l'intervalle des caractères interchangeables.
\param motif chaine Le motif à rechercher.
\param remplacerpar chaine La chaîne par laquelle le motif est remplacé.
\desc
Cette fonction est d'une grande importance dans le traitement des chaînes
en GOTO++ et elle remplace avantageusement les expressions régulières (qui
sont tout de même présentes, pour les conservateurs).

Elle travaille sur £entree£ et recherche dedans une sous-chaîne qui correspond
au motif décrit par £motif£. Cette sous-chaîne est alors remplacée par
£remplacerpar£ en tenant compte des informations données par £motif£.

La signification de £motif£ est gouvernée par £borneinf£ et £bornesup£. Tout
caractère du motif qui est compris entre £borneinf£ et £bornesup£ est considéré
comme un caractère interchangeable. C'est à dire qu'il signifie en réalité
« n'importe quel caractère entre £borneinf£ et £bornesup£. » Par ailleurs
si un de ces caractères apparaît plusieurs fois dans le motif, il désignera
une répétition du même caractère (par exemple si a et z sont les bornes, le motif
«ccc» désignera la répétition trois fois de suite d'un même caractère situé
dans ces bornes). Les caractères du motif en dehors des bornes se désignent
eux-même.

Si le motif est trouvé, il est remplacé par £remplacerpar£, en tenant compte
de la signification qui a été donnée aux caractères interchangeables (par
exemple si «c» de £motif£ correspondait à un «e» de £entree£, alors si on
trouve «c» dans £remplacerpar£, le caractère «e» sera inséré).
Suite à quoi, l'exécution
continue à £cible£.

Sinon l'exécution continue à la ligne suivante et la chaîne d'entrée
n'est pas modifiée.
\exemple
GOTO Cet exemple inverse les lettres d'une chaîne
GOTO On utilise le caractère * comme guide pour inverser
GOTO la chaîne et le caractère - pour supprimer ensuite
GOTO ces étoiles.
c=«bonjour»
§1
GOTOPRINTDUTEXTE() ;&c
Markov() %1 c *`a' *`z' «**» «-»
Markov() %1 c *`a' *`z' «-a» «a-»
Markov() %1 c *`a' *`z' «-*» «-»
Markov() %2 c *`a' *`z' «-» «»
Markov() %1 c *`a' *`z' «*ab» «b*a»
Markov() %1 c *`a' *`z' «» «*»
§2
GOTOPRINTDUTEXTE() ;&c
GOTO affiche «roujnob»
*/
void biMarkov(IInterpreteur * _interpreteur)
{
    CInterpreteur * itp=static_cast<CInterpreteur*>(_interpreteur);
    //label chaine* borneinf bornesup gauche droite
    valeur label,chaine,borneinf,bornesup,gauche,droite;
    itp->Pile.Depiler(droite);
    itp->Pile.Depiler(gauche);
    itp->Pile.Depiler(bornesup);
    itp->Pile.Depiler(borneinf);
    itp->Pile.Depiler(chaine);
    itp->Pile.Depiler(label);

    if (label.Type!=TYPE_ETIQUETTE)
        throw "le premier paramètre doit être une étiquette";
    if (borneinf.Type!=TYPE_CARAC)
        throw "la borne inférieure doit être un caractère";
    if (bornesup.Type!=TYPE_CARAC)
        throw "la borne supérieure doit être un caractère";
    if (chaine.Type!=TYPE_REFERENCE)
        throw "le deuxième paramètre doit être une référence";

    valeur * w=itp->Deref(chaine.v.p);
    w->EnChaine();
    const chaineval * v=w->v.c;

    carac binf=(carac)borneinf.v.i;
    carac bsup=(carac)bornesup.v.i;

    const carac * motif;
    gauche.EnChaine();
    motif=gauche.v.c->c;

#define NMAXRAPPELS 32
    carac RappelId[NMAXRAPPELS];
    carac RappelVal[NMAXRAPPELS];

    const carac * q=v->c;
    while (*q)
    {
        const carac * m=motif;
        const carac * p=q;
        int nRappels=0;

        while (*m)
        {
            if (*m>=binf && *m<=bsup)
            {
                bool Rappel=false;
                //On regarde si c'est un rappel
                int z;
                for (z=0; z<nRappels; z++)
                {
                    if (RappelId[z]==*m)
                        Rappel=true;
                }

                if (Rappel)
                {
                    if (*p==RappelVal[z])
                    {
                    }
                    else
                        break;
                }
                else
                {
                    if (*p>=binf && *p<=bsup)
                    {

                        if (nRappels==NMAXRAPPELS)
                            throw TXT("nombre maximal de rappels atteint");
                        RappelId[nRappels]=*m;
                        RappelVal[nRappels++]=*p;
                    }
                    else
                        break;
                }
            }
            else if (*p==*m)
            {

            }
            else
                break;
            m++;
            p++;
        }

        if (!*m)
        {
            //Motif trouvé
            size_t nlong=v->l+droite.v.c->l-gauche.v.c->l;
            chaineval * nv=chaineval::Creer(nlong);
            carac*nouveau=nv->c;
            size_t dep=q-v->c;
            if (dep)
                memcpy(nouveau,v->c,dep*sizeof(carac));
            //On insère le nouveau motif
            const carac *src=droite.v.c->c;
            carac *dest=&nouveau[dep];
            while (*src)
            {
                if (*src>=binf && *src<=bsup)
                {
                    int z;
                    for (z=0; z<nRappels; z++)
                    {
                        if (RappelId[z]==*src)
                            break;
                    }
                    if (z==nRappels)
                        throw TXT("un caractère de rappel dans la chaîne de droite n'est pas présent dans la chaîne de gauche");
                    *(dest++)=RappelVal[z];
                }
                else
                    *(dest++)=*src;
                src++;
            }

            size_t fin=v->l-dep-gauche.v.c->l;
            if (fin)
                memcpy(dest,&v->c[dep+gauche.v.c->l],fin*sizeof(carac));
            nouveau[nlong]=0;
            *w=nv;
            itp->Goto(label.v.et);
            return;
        }
        q++;
    }
    itp->Pile.AjouterIndef();
}
예제 #10
0
파일: dirtest.c 프로젝트: yonathan/sam3demo
void main(void)
{
	EmbeddedFileSystem efs;
	EmbeddedFile file_w;
	unsigned short i;
	unsigned char e;
	unsigned char t;
	signed char err;
	unsigned char offset1;
	unsigned char offset2;
	char path[100];

	debug_init();
	
	DBG((TXT("Welcome (2).\n-------------\n\n")));
	if(efs_init(&efs,0)!=0){
		DBG((TXT("Could not init filesystem.\n")));
		hang();
	}

	for(i=1;i<=4;i++){
		offset1=c2str(1,path);
		path[offset1++]='/';
		for(e=1;e<=12;e++){
			offset2=offset1;
			offset2+=c2str(e,path+offset1);
			DBG((TXT("Dir name: %s.\n"),path));
		}
	}
	/*for(i=1;i<10;i++){	
		path[0]='D';
		path[1]='I';
		path[2]='R';
		path[3]=0x30+((i%10000)/1000);
		path[4]=0x30+((i%1000)/100);
		path[5]=0x30+((i%100)/10);
		path[6]=0x30+((i%10)/1);
		path[7]='\0';
		err=mkdir(&efs.myFs,path);
		if(err!=0){
			DBG((TXT("ERROR: Could not create directory %s (%d) - returned ERR %d.\n"),path,i,err));
			hang();
		}
		DBG((TXT("DIR %s created.\n"),path));
		for(e=1;e<6;e++){
			path[7]='/';
			path[8]=0x40+e;
			path[9]='\0';
			err=mkdir(&efs.myFs,path);
			if(err!=0){
				DBG((TXT("ERROR: Could not create directory %s (%d) - returned ERR %d.\n"),path,i,err));
				hang();
			}
			DBG((TXT("DIR %s created.\n"),path));
			for(t=0;t<26;t++){
				path[9]='/';
				path[10]='t';
				path[11]='e';
				path[12]='s';
				path[13]='t';
				path[14]='-';
				path[15]=0x41+t;
				path[16]='.';
				path[17]='t';
				path[18]='x';
				path[19]='t';
				path[20]='\0';
				if(file_fopen(&file_w,&efs.myFs,path,'w')!=0){
					DBG((TXT("Could not open file %s for writing.\n"),path));		
					hang();
				}
				file_write(&file_w,15,"Dit is een test");
				file_fclose(&file_w);
			}
		}
	}*/

	file_fclose(&file_w);
	fs_umount(&efs.myFs);

	DBG((TXT("Done :-)\n\n")));
	
	hang();
}
예제 #11
0
파일: divers.cpp 프로젝트: Sidoine/gotopp
void biBoum()
{
	throw TXT("boum !");
}
예제 #12
0
void Connection::open(const tstring& host)
{
	open(host, TXT(""), TXT(""), DEFAULT_NAMESPACE);
}
예제 #13
0
void Connection::open()
{
	open(LOCALHOST, TXT(""), TXT(""), DEFAULT_NAMESPACE);
}
예제 #14
0
namespace WMI
{

////////////////////////////////////////////////////////////////////////////////
// Constants.

//! The local computer path.
const tstring Connection::LOCALHOST = TXT(".");
//! The default namespace.
const tstring Connection::DEFAULT_NAMESPACE = TXT("\\root\\cimv2");

////////////////////////////////////////////////////////////////////////////////
//! Default constructor.

Connection::Connection()
{
}

////////////////////////////////////////////////////////////////////////////////
//! Open a connection to a specific host using the current credentials.

Connection::Connection(const tstring& host)
{
	open(host);
}

////////////////////////////////////////////////////////////////////////////////
//! Destructor.

Connection::~Connection()
{
	close();
}

////////////////////////////////////////////////////////////////////////////////
//! Query if the connection is open.

bool Connection::isOpen() const
{
	return ((m_locator.get() != nullptr) && (m_services.get() != nullptr));
}

////////////////////////////////////////////////////////////////////////////////
//! Open a connection to the current host.

void Connection::open()
{
	open(LOCALHOST, TXT(""), TXT(""), DEFAULT_NAMESPACE);
}

////////////////////////////////////////////////////////////////////////////////
//! Open a connection to a specific host using the current credentials.

void Connection::open(const tstring& host)
{
	open(host, TXT(""), TXT(""), DEFAULT_NAMESPACE);
}

////////////////////////////////////////////////////////////////////////////////
//! Open a connection to a specific host.

void Connection::open(const tstring& host, const tstring& login, const tstring& password)
{
	open(host, login, password, DEFAULT_NAMESPACE);
}

////////////////////////////////////////////////////////////////////////////////
//! Open a connection to a specific host and namespace.

void Connection::open(const tstring& host, const tstring& login, const tstring& password, const tstring& nmspace)
{
	ASSERT(!isOpen());

	// Format the full connection path.
	tstring path = host + nmspace;

	if (path.compare(0, 2, TXT("\\\\")) != 0)
		path = TXT("\\\\") + path;

	// Create the connection.
	IWbemServicesPtr	services;
	IWbemLocatorPtr		locator(CLSID_WbemLocator);
	WCL::ComStr			bstrPath(path);
	WCL::ComStr			bstrAuth(TXT(""));
	HRESULT				result;

	if (login.empty())
	{
		result = locator->ConnectServer(bstrPath.Get(), nullptr, nullptr, nullptr, 0,
										bstrAuth.Get(), nullptr, AttachTo(services));
	}
	else
	{
		WCL::ComStr	bstrLogin(login);
		WCL::ComStr	bstrPassword(password);

		result = locator->ConnectServer(bstrPath.Get(), bstrLogin.Get(), bstrPassword.Get(), nullptr, 0,
										bstrAuth.Get(), nullptr, AttachTo(services));
	}

	if (FAILED(result))
		throw Exception(result, locator, Core::fmt(TXT("Failed to connect to the WMI provider on '%s'"), host.c_str()).c_str());

	// Enable impersonation on the connection.
    result = ::CoSetProxyBlanket(services.get(), RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_DEFAULT, nullptr,
									RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE,
									nullptr, EOAC_NONE);

	if (FAILED(result))
		throw Exception(result, locator, TXT("Failed to enable impersonation on the WMI connection"));

	// Update state.
	m_locator  = locator;
	m_services = services;
}

////////////////////////////////////////////////////////////////////////////////
//! Close the connection.

void Connection::close()
{
	m_services.Release();
	m_locator.Release();
}

////////////////////////////////////////////////////////////////////////////////
//! Get a single object using it's unique path.

Object Connection::getObject(const tstring& path) const
{
	const WCL::ComStr objectPath(path);

	IWbemClassObjectPtr object;

	HRESULT result = m_services->GetObject(objectPath.Get(), WBEM_FLAG_RETURN_WBEM_COMPLETE,
											nullptr, AttachTo(object), nullptr);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to get object from path '%s'"), path);
		throw Exception(result, m_services, message.c_str());
	}

	return Object(object, *this);
}

////////////////////////////////////////////////////////////////////////////////
//! Execute the query.

ObjectIterator Connection::execQuery(const tstring& query) const
{
	return execQuery(query.c_str());
}

////////////////////////////////////////////////////////////////////////////////
//! Execute the query.

ObjectIterator Connection::execQuery(const tchar* query) const
{
	ASSERT(isOpen());

	WCL::ComStr	language(L"WQL");
	WCL::ComStr	queryText(query);
	long		flags(WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY);

	IEnumWbemClassObjectPtr enumerator;

	// Execute it.
	HRESULT result = m_services->ExecQuery(language.Get(), queryText.Get(), flags,
											nullptr, AttachTo(enumerator));

	if (FAILED(result))
		throw Exception(result, m_services, TXT("Failed to execute a WMI query"));

	return ObjectIterator(enumerator, *this);
}

////////////////////////////////////////////////////////////////////////////////
//! Execute a method on an object.

void Connection::execMethod(IWbemServicesPtr connection, IWbemClassObjectPtr object,
							const tchar* path, const tchar* method, WCL::Variant& returnValue)
{
	ASSERT(connection.get() != nullptr);

	const WCL::ComStr objectPath(path);
	const WCL::ComStr methodName(method);

	IWbemClassObjectPtr output;

	HRESULT result = connection->ExecMethod(objectPath.Get(), methodName.Get(), 0,
											nullptr, nullptr, AttachTo(output), nullptr);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to execute method '%s' on object '%s'"), method, path);
		throw Exception(result, connection, message.c_str());
	}

	const WCL::ComStr RETURN_VALUE(TXT("ReturnValue"));

    result = output->Get(RETURN_VALUE.Get(), 0, &returnValue, NULL, 0);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to get '%s' method return value"), method);
		throw Exception(result, connection, message.c_str());
	}
}

////////////////////////////////////////////////////////////////////////////////
//! Execute a method on the object.

void Connection::execMethod(IWbemServicesPtr connection, IWbemClassObjectPtr object,
							const tchar* path, const tchar* method, IWbemClassObjectPtr arguments, WCL::Variant& returnValue)
{
	ASSERT(connection.get() != nullptr);

	const WCL::ComStr objectPath(path);
	const WCL::ComStr methodName(method);

	IWbemClassObjectPtr output;

	HRESULT result = connection->ExecMethod(objectPath.Get(), methodName.Get(), 0,
											nullptr, arguments.get(), AttachTo(output), nullptr);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to execute method '%s' on object '%s'"), method, path);
		throw Exception(result, connection, message.c_str());
	}

	const WCL::ComStr RETURN_VALUE(TXT("ReturnValue"));

    result = output->Get(RETURN_VALUE.Get(), 0, &returnValue, NULL, 0);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to get '%s' method return value"), method);
		throw Exception(result, connection, message.c_str());
	}
}

//namespace WMI
}
예제 #15
0
void
tgsi_dump_c(
   const struct tgsi_token *tokens,
   uint flags )
{
   struct tgsi_parse_context parse;
   struct tgsi_full_instruction fi;
   struct tgsi_full_declaration fd;
   uint ignored = flags & TGSI_DUMP_C_IGNORED;
   uint deflt = flags & TGSI_DUMP_C_DEFAULT;

   tgsi_parse_init( &parse, tokens );

   TXT( "tgsi-dump begin -----------------" );

   TXT( "\nMajorVersion: " );
   UID( parse.FullVersion.Version.MajorVersion );
   TXT( "\nMinorVersion: " );
   UID( parse.FullVersion.Version.MinorVersion );
   EOL();

   TXT( "\nHeaderSize: " );
   UID( parse.FullHeader.Header.HeaderSize );
   TXT( "\nBodySize  : " );
   UID( parse.FullHeader.Header.BodySize );
   TXT( "\nProcessor : " );
   ENM( parse.FullHeader.Processor.Processor, TGSI_PROCESSOR_TYPES );
   EOL();

   fi = tgsi_default_full_instruction();
   fd = tgsi_default_full_declaration();

   while( !tgsi_parse_end_of_tokens( &parse ) ) {
      tgsi_parse_token( &parse );

      TXT( "\nType       : " );
      ENM( parse.FullToken.Token.Type, TGSI_TOKEN_TYPES );
      if( ignored ) {
         TXT( "\nSize       : " );
         UID( parse.FullToken.Token.NrTokens );
         if( deflt || parse.FullToken.Token.Extended ) {
            TXT( "\nExtended   : " );
            UID( parse.FullToken.Token.Extended );
         }
      }

      switch( parse.FullToken.Token.Type ) {
      case TGSI_TOKEN_TYPE_DECLARATION:
         dump_declaration_verbose(
            &parse.FullToken.FullDeclaration,
            ignored,
            deflt,
            &fd );
         break;

      case TGSI_TOKEN_TYPE_IMMEDIATE:
         dump_immediate_verbose(
            &parse.FullToken.FullImmediate,
            ignored );
         break;

      case TGSI_TOKEN_TYPE_INSTRUCTION:
         dump_instruction_verbose(
            &parse.FullToken.FullInstruction,
            ignored,
            deflt,
            &fi );
         break;

      default:
         assert( 0 );
      }

      EOL();
   }

   TXT( "\ntgsi-dump end -------------------\n" );

   tgsi_parse_free( &parse );
}
예제 #16
0
#include <Core/StringUtils.hpp>
#include <Core/ParseException.hpp>
#include <WCL/DateTime.hpp>
#include <WCL/Win32Exception.hpp>
#include <malloc.h>

#if __GNUC__
// missing initializer for member 'X'
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif

////////////////////////////////////////////////////////////////////////////////
// Constants.

//! The default single-item format.
const tstring ValueFormatter::DEFAULT_SINGLE_ITEM_FORMAT = TXT("%v");
//! The default multi-item format.
const tstring ValueFormatter::DEFAULT_MULTI_ITEM_FORMAT = TXT("%i: %v");

//! The default timestamp date format.
const tstring ValueFormatter::DEFAULT_DATE_FORMAT = TXT("yyyy'-'MM'-'dd");
//! The default timestamp time format.
const tstring ValueFormatter::DEFAULT_TIME_FORMAT = TXT("hh':'mm':'ss");

////////////////////////////////////////////////////////////////////////////////
//! Full constructor.

ValueFormatter::ValueFormatter(const tstring& valueFormat,
							   bool           trimValue,
							   const tstring& dateFormat,
							   const tstring& timeFormat)
예제 #17
0
*/

#include "Common.hpp"
#include "DDELink.hpp"
#include "DDEConv.hpp"
#include <WCL/Clipboard.hpp>
#include <Core/AnsiWide.hpp>

/******************************************************************************
**
** Local variables.
**
*******************************************************************************
*/

static uint s_nLinkFormat = CClipboard::RegisterFormat(TXT("Link"));

/******************************************************************************
** Method:		Constructor.
**
** Description:	.
**
** Parameters:	None.
**
** Returns:		Nothing.
**
*******************************************************************************
*/

CDDELink::CDDELink(CDDEConv* pConv, const tchar* pszItem, uint nFormat)
	: m_nRefCount(0)
예제 #18
0
tstring ValueFormatter::format(const tstring& server,
							   const tstring& topic,
							   const tstring& item,
							   const tstring& value) const
{
	typedef tstring::const_iterator citer;

	tstring result;

	result.reserve(m_valueFormat.length() + item.length() + value.length());

	for (citer it = m_valueFormat.begin(); it != m_valueFormat.end(); ++it)
	{
		if (*it == TXT('%'))
		{
			citer variableIt = it+1;

			if (variableIt == m_valueFormat.end())
				throw Core::ParseException(Core::fmt(TXT("Invalid output format: '%s'"), m_valueFormat.c_str()));

			const tchar variable = *variableIt;

			if (variable == TXT('%'))
			{
				result += TXT('%');
			}
			else if (variable == TXT('v'))
			{
				if (m_trimValue)
					result += Core::trimCopy(value);
				else
					result += value;
			}
			else if (variable == TXT('s'))
			{
				result += server;
			}
			else if (variable == TXT('t'))
			{
				result += topic;
			}
			else if (variable == TXT('i'))
			{
				result += item;
			}
			else if (variable == TXT('d'))
			{
				result += formatTimestamp(m_dateFormat, m_timeFormat);
			}
			else
			{
				throw Core::ParseException(Core::fmt(TXT("Invalid output variable: '%%%c'"), variable));
			}

			++it;
		}
		else
		{
			result += *it;
		}
	}

	return result;
}
예제 #19
0
inline tstring Win32_LogicalDisk::DeviceID() const
{
	return getProperty<tstring>(TXT("DeviceID"));
}
예제 #20
0
int main( int argc, char* argv[] )
{
	//I sometimes use this to give me an opportunity to attach a debugger.
	//__asm int 3;
	
	GetPot cl( argc, argv );

	
	
	
	//Test if we are using curses output
	bool UseCurses = false;
	if( cl.search( 2, "--curses", "-c" ) ) UseCurses = 1;
	
	Console* pCON = UseCurses ?
					(Console*)new CursesConsole : (Console*)new StdConsole;
	Console& CON = *pCON;

	//Win32 doesn't really support this right now.
#if defined(PLAT_WIN32)
	if( !UseCurses ) CON.UseColor( false );
#endif
	
	//Test if we should print help message and quit
	if( cl.search( 2, "--help", "-h" ) )
	{
		CON << TXT("SS Console Interpreter, \n");
		CON << TXT("Usage: storyscript [OPTIONS] FILE\n");
		CON << TXT("Options are:\n");
		CON << TXT(" -u, -ungodly-verbose    Rediculously verbose output.\n");
		CON << TXT(" -b, -block BLOCKNAME    Specifies the starting block.\n");
		CON << TXT(" -h, --help              Prints the message you are looking at right now.\n");
		CON << TXT(" -c, --curses            Use curses for output (ie. Fancy, colorful text).\n");
		CON << TXT("                         Currently a little buggy, but works well for files.\n");
		CON << TXT(" -n, --no-color          Don't print any color at all.\n");
		CON << TXT(" -v, --verbose       	 Adds some extra info, mainly with error output.\n");
		CON << TXT(" --version               Prints the version number, contact info, etc.\n");
		
		delete pCON;
		exit(0);	
	}
	
	//Test if we should print the version and exit
	if( cl.search( "--version" ) )
	{
		CON << TXT("SS Console Interpreter\n");
		CON << TXT("Copyright (c) 2004-2006 Daniel Jones ([email protected])\n");
		CON << SS::GetVersionString();
		CON << TXT("\n");
		//CON << TXT("\nPlease send comments and report bugs to: [email protected].\n");
		
		delete pCON;
		exit(0);
	}
	
	//Test for gcc-styles errors or not (I'm defaulting to yes, just because they look so much better).
	bool GCCErrors = true;
	bool Quiet = true;
	if( cl.search(2, "--verbose", "-v") )
	{
		Quiet = false;
		GCCErrors = false;
	}
	
	//Test for ungoldly verbosity
	bool Verbose = false;
	if( cl.search( 2, "--ungodly-verbose", "-u" ) )
	{
		Verbose = true;
		Quiet = false;
		GCCErrors = false;
	}
	
	//Shall we use color?
	//bool NoColor = false;
	if( cl.search( 2, "--no-color", "-n" ) ){
		CON.UseColor( false );		
	}
	
	//Test for block name
	SS::String BlockName;
	if( cl.search( 2, "--block", "-b" ) )
	{
		BlockName = SS::NormalizeString( cl.next("") );
	}
	
	//Try to get a file name
	SS::String FileName;
	if( cl.size() > 1 ){
		const char* Temp = cl[ cl.size() - 1];
		if( Temp[0] != '-' ) FileName = SS::NormalizeString( Temp );
	}
	
	
	

	CON.SetBackgroundFull( ColorPair( ColorCyan, ColorBlack ), ' ' );
	
	SS::Interpreter* pI = new SS::Interpreter;
	ConsoleInterface Test( CON, *pI, !Quiet );
	
	if( GCCErrors ) Test.SetGCCStyleErrors();
	

	if( Verbose ) Test.GetInterpreter().SetVerbose( true );
		
	Test.StartConversation( FileName, BlockName );

	
	CON.SetTextFGColor( ColorCyan );
	
	if( !Quiet || UseCurses )
	{
		CON << TXT("\nTotal run time: ") << (float)(((double)clock()) / ((double)CLOCKS_PER_SEC)) << TXT(" seconds.\n\n");


		//This is ridiculous that I need this much code for something so trivial.
		CON << TXT("Press [Enter] to continue...");
		if( UseCurses ){
			SS::String Dummy;
			CON >> Dummy;
		}
		else{
예제 #21
0
//移动===============================================================
void MOVE()
{
    char c;
    c=getch();
    switch(c)
    {
    case 72://上
    {
        if(y>7) {
            gotoxy(x0,y);
            printf(" ");
            y--;
            Arrow();
        }
        break;
    }
    case 80://下
    {
        if(y<11) {
            gotoxy(x0,y);
            printf(" ");
            y++;
            Arrow();
        }
        break;
    }
    case 77://右
    {
        if(x0==15)
        {
            gotoxy(x0,y);
            printf(" ");
            x0=45;
            Arrow();
            no_TXT(10,30,5,12);
            TXT(40,60,5,12);
            gotoxy(0,0);
        }
        break;
    }
    case 75://左
    {
        if(x0==45)
        {
            gotoxy(x0,y);
            printf(" ");
            x0=15;
            Arrow();
            no_TXT(40,60,5,12);
            TXT(10,30,5,12);
            gotoxy(0,0);
        }
        break;
    }
    case 13:
    case 32:
    {
        if(y==11)shut=1;
        if(x0==15&&y!=11)
        {
            Menu(2);
            CLR(2);
            gotoxy(x0+2,y);
            puts(txt[y-7]);
            CLR(3);
            chos_in=1;
            in=y-7;
        }
        else if(y!=11)
        {
            Menu(3);
            CLR(2);
            gotoxy(x0+2,y);
            puts(txt[y-7]);
            CLR(3);
            chos_out=1;
            out=y-7;
        }
        break;
    }
    }
}
예제 #22
0
    /// Get the package loader to use to load the object with the given path, creating it if necessary.
    ///
    /// @param[in] path  Asset path.
    ///
    /// @return  Package loader to use to load the specified object.
    LoosePackageLoader* LoosePackageLoaderMap::GetPackageLoader( AssetPath path )
    {
        HELIUM_ASSERT( !path.IsEmpty() );

        // Resolve the object's package.
        AssetPath packagePath = path;
        while( !packagePath.IsPackage() )
        {
            packagePath = packagePath.GetParent();
            if( packagePath.IsEmpty() )
            {
                HELIUM_TRACE(
                    TraceLevels::Error,
                    ( TXT( "LoosePackageLoaderMap::GetPackageLoader(): Cannot resolve package loader for \"%s\", as it " )
                    TXT( "is not located in a package.\n" ) ),
                    *path.ToString() );

                return NULL;
            }
        }

        // Locate an existing package loader.
        ConcurrentHashMap< AssetPath, LoosePackageLoader* >::ConstAccessor constMapAccessor;
        if( m_packageLoaderMap.Find( constMapAccessor, packagePath ) )
        {
            LoosePackageLoader* pLoader = constMapAccessor->Second();
            HELIUM_ASSERT( pLoader );

            return pLoader;
        }

        // Add a new package loader entry.
        ConcurrentHashMap< AssetPath, LoosePackageLoader* >::Accessor mapAccessor;
        bool bInserted = m_packageLoaderMap.Insert(
            mapAccessor,
            KeyValue< AssetPath, LoosePackageLoader* >( packagePath, NULL ) );
        if( bInserted )
        {
            // Entry added, so create and initialize the package loader.
            LoosePackageLoader* pLoader = new LoosePackageLoader;
            HELIUM_ASSERT( pLoader );

            bool bInitResult = pLoader->Initialize( packagePath );
            HELIUM_ASSERT( bInitResult );
            if( !bInitResult )
            {
                HELIUM_TRACE(
                    TraceLevels::Error,
                    TXT( "LoosePackageLoaderMap::GetPackageLoader(): Failed to initialize package loader for \"%s\".\n" ),
                    *packagePath.ToString() );

                m_packageLoaderMap.Remove( mapAccessor );

                return NULL;
            }

            HELIUM_VERIFY( pLoader->BeginPreload() );

            mapAccessor->Second() = pLoader;
        }

        // PMD: I am not 100% sure this is all thread safe. I think it could break if:
        // - Thread 1 inserts a key/value of path and NULL, as above
        // - Thread 2 returns false from the insert so we come straight here
        //   - Thread 2 tries to use pLoader before thread 1 assigns ploader to the value of the key
        // Note: If we did not do this assert here, we could potentially get nulls from this same thread later when
        // trying to find pLoader.
        //
        // Leaving it alone for now since I'm not sure, but if this assert gets tripped, we need to revisit this.
        // Easy fix may be to allocate and construct (but don't completely init) an LoosePackageLoader, and try
        // to insert that directly rather than the null above. If insert succeeds, finish, else ditch our loader
        // and grab the one out of the array
        LoosePackageLoader* pLoader = mapAccessor->Second();
        HELIUM_ASSERT( pLoader );

        return pLoader;
    }
예제 #23
0
tstring TheApp::applicationName() const
{
	return TXT("AppCmd");
}
예제 #24
0
static boolean
iter_declaration(
   struct tgsi_iterate_context *iter,
   struct tgsi_full_declaration *decl )
{
   struct dump_ctx *ctx = (struct dump_ctx *)iter;

   TXT( "DCL " );

   ENM(decl->Declaration.File, tgsi_file_names);

   /* all geometry shader inputs are two dimensional */
   if (decl->Declaration.File == TGSI_FILE_INPUT &&
       iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) {
      TXT("[]");
   }

   if (decl->Declaration.Dimension) {
      CHR('[');
      SID(decl->Dim.Index2D);
      CHR(']');
   }

   CHR('[');
   SID(decl->Range.First);
   if (decl->Range.First != decl->Range.Last) {
      TXT("..");
      SID(decl->Range.Last);
   }
   CHR(']');

   _dump_writemask(
      ctx,
      decl->Declaration.UsageMask );

   if (decl->Declaration.Local)
      TXT( ", LOCAL" );

   if (decl->Declaration.Semantic) {
      TXT( ", " );
      ENM( decl->Semantic.Name, tgsi_semantic_names );
      if (decl->Semantic.Index != 0 ||
          decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {
         CHR( '[' );
         UID( decl->Semantic.Index );
         CHR( ']' );
      }
   }

   if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
      TXT(", ");
      ENM(decl->Resource.Resource, tgsi_texture_names);
      if (decl->Resource.Writable)
         TXT(", WR");
      if (decl->Resource.Raw)
         TXT(", RAW");
   }

   if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
      TXT(", ");
      ENM(decl->SamplerView.Resource, tgsi_texture_names);
      TXT(", ");
      if ((decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeY) &&
          (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeZ) &&
          (decl->SamplerView.ReturnTypeX == decl->SamplerView.ReturnTypeW)) {
         ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names);
      } else {
         ENM(decl->SamplerView.ReturnTypeX, tgsi_type_names);
         TXT(", ");
         ENM(decl->SamplerView.ReturnTypeY, tgsi_type_names);
         TXT(", ");
         ENM(decl->SamplerView.ReturnTypeZ, tgsi_type_names);
         TXT(", ");
         ENM(decl->SamplerView.ReturnTypeW, tgsi_type_names);
      }
   }

   if (decl->Declaration.Interpolate) {
      if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
          decl->Declaration.File == TGSI_FILE_INPUT)
      {
         TXT( ", " );
         ENM( decl->Interp.Interpolate, tgsi_interpolate_names );
      }

      if (decl->Interp.Centroid) {
         TXT( ", CENTROID" );
      }

      if (decl->Interp.CylindricalWrap) {
         TXT(", CYLWRAP_");
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) {
            CHR('X');
         }
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Y) {
            CHR('Y');
         }
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_Z) {
            CHR('Z');
         }
         if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_W) {
            CHR('W');
         }
      }
   }

   if (decl->Declaration.Invariant) {
      TXT( ", INVARIANT" );
   }


   if (decl->Declaration.File == TGSI_FILE_IMMEDIATE_ARRAY) {
      unsigned i;
      char range_indent[4];

      TXT(" {");

      if (decl->Range.Last < 10)
         range_indent[0] = '\0';
      else if (decl->Range.Last < 100) {
         range_indent[0] = ' ';
         range_indent[1] = '\0';
      } else if (decl->Range.Last < 1000) {
         range_indent[0] = ' ';
         range_indent[1] = ' ';
         range_indent[2] = '\0';
      } else {
         range_indent[0] = ' ';
         range_indent[1] = ' ';
         range_indent[2] = ' ';
         range_indent[3] = '\0';
      }

      dump_imm_data(iter, decl->ImmediateData.u,
                    4, TGSI_IMM_FLOAT32);
      for(i = 1; i <= decl->Range.Last; ++i) {
         /* indent by strlen of:
          *   "DCL IMMX[0..1] {" */
         CHR('\n');
         TXT( "                " );
         TXT( range_indent );
         dump_imm_data(iter, decl->ImmediateData.u + i,
                       4, TGSI_IMM_FLOAT32);
      }

      TXT(" }");
   }

   EOL();

   return TRUE;
}
예제 #25
0
파일: Writer.cpp 프로젝트: chrisoldwood/XML
void Writer::writeElement(ElementNodePtr element)
{
	tstring indentation;
	tstring terminator;

	if (!(m_flags & NO_FORMATTING))
	{
		for (uint i = 0; i != m_depth; ++i)
			indentation += m_indentStyle;

		terminator = DEFAULT_TERMINATOR;
	}

	if (element->hasChildren())
	{
		const bool inlineValue = ( (element->getChildCount() == 1)
								&& (element->getChild(0)->type() == TEXT_NODE) );

		if (!element->getAttributes().isEmpty())
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s"), element->name().c_str());

			writeAttributes(element->getAttributes());

			m_buffer += TXT(">");

			if (!inlineValue)
				m_buffer += terminator;
		}
		else
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s>"), element->name().c_str());

			if (!inlineValue)
				m_buffer += terminator;
		}

		++m_depth;
		writeContainer(*element);
		--m_depth;

		if (!inlineValue)
			m_buffer += indentation;

		m_buffer += Core::fmt(TXT("</%s>"), element->name().c_str());
		m_buffer += terminator;
	}
	else
	{
		if (!element->getAttributes().isEmpty())
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s"), element->name().c_str());

			writeAttributes(element->getAttributes());

			m_buffer += TXT("/>");
			m_buffer += terminator;
		}
		else
		{
			m_buffer += indentation;
			m_buffer += Core::fmt(TXT("<%s/>"), element->name().c_str());
			m_buffer += terminator;
		}
	}
}
예제 #26
0
typedef bool              (checkFileType_t)   (FILE *const);
typedef AudioIO*          (createInstance_t)  (void);

//AudioIO library mappings
static const struct
{
	const CHR                 name[16];
	const uint8_t             id;
	libraryVersion_t   *const libraryVersion;
	supportedFormats_t *const supportedFormats;
	checkFileType_t    *const checkFileType;
	createInstance_t   *const createInstance;
}
g_audioIO_mapping[] =
{
	{ TXT("libsndfile"),  AUDIO_LIB_LIBSNDFILE,  AudioIO_SndFile ::libraryVersion, AudioIO_SndFile ::supportedFormats, AudioIO_SndFile ::checkFileType, AudioIO_SndFile ::createInstance },
	{ TXT("libopusfile"), AUDIO_LIB_LIBOPUSFILE, AudioIO_OpusFile::libraryVersion, AudioIO_OpusFile::supportedFormats, AudioIO_OpusFile::checkFileType, AudioIO_OpusFile::createInstance },
	{ TXT("libmpg123"),   AUDIO_LIB_LIBMPG123,   AudioIO_Mpg123  ::libraryVersion, AudioIO_Mpg123  ::supportedFormats, AudioIO_Mpg123  ::checkFileType, AudioIO_Mpg123  ::createInstance },
	{ TXT(""),            AUDIO_LIB_NULL,        NULL,                             NULL,                               NULL,                            NULL                             }
};

//Get id from AudioIO library name
static uint8_t parseName(const CHR *const name)
{
	if (name && name[0])
	{
		for (size_t i = 0; g_audioIO_mapping[i].id; ++i)
		{
			if (STRCASECMP(name, g_audioIO_mapping[i].name) == 0)
			{
				return g_audioIO_mapping[i].id;
예제 #27
0
static boolean
iter_instruction(
   struct tgsi_iterate_context *iter,
   struct tgsi_full_instruction *inst )
{
   struct dump_ctx *ctx = (struct dump_ctx *) iter;
   uint instno = ctx->instno++;
   const struct tgsi_opcode_info *info = tgsi_get_opcode_info( inst->Instruction.Opcode );
   uint i;
   boolean first_reg = TRUE;

   INSTID( instno );
   TXT( ": " );

   ctx->indent -= info->pre_dedent;
   for(i = 0; (int)i < ctx->indent; ++i)
      TXT( "  " );
   ctx->indent += info->post_indent;

   if (inst->Instruction.Predicate) {
      CHR( '(' );

      if (inst->Predicate.Negate)
         CHR( '!' );

      TXT( "PRED[" );
      SID( inst->Predicate.Index );
      CHR( ']' );

      if (inst->Predicate.SwizzleX != TGSI_SWIZZLE_X ||
          inst->Predicate.SwizzleY != TGSI_SWIZZLE_Y ||
          inst->Predicate.SwizzleZ != TGSI_SWIZZLE_Z ||
          inst->Predicate.SwizzleW != TGSI_SWIZZLE_W) {
         CHR( '.' );
         ENM( inst->Predicate.SwizzleX, tgsi_swizzle_names );
         ENM( inst->Predicate.SwizzleY, tgsi_swizzle_names );
         ENM( inst->Predicate.SwizzleZ, tgsi_swizzle_names );
         ENM( inst->Predicate.SwizzleW, tgsi_swizzle_names );
      }

      TXT( ") " );
   }

   TXT( info->mnemonic );

   switch (inst->Instruction.Saturate) {
   case TGSI_SAT_NONE:
      break;
   case TGSI_SAT_ZERO_ONE:
      TXT( "_SAT" );
      break;
   case TGSI_SAT_MINUS_PLUS_ONE:
      TXT( "_SATNV" );
      break;
   default:
      assert( 0 );
   }

   for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
      const struct tgsi_full_dst_register *dst = &inst->Dst[i];

      if (!first_reg)
         CHR( ',' );
      CHR( ' ' );

      _dump_register_dst( ctx, dst );
      _dump_writemask( ctx, dst->Register.WriteMask );

      first_reg = FALSE;
   }

   for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
      const struct tgsi_full_src_register *src = &inst->Src[i];

      if (!first_reg)
         CHR( ',' );
      CHR( ' ' );

      if (src->Register.Negate)
         CHR( '-' );
      if (src->Register.Absolute)
         CHR( '|' );

      _dump_register_src(ctx, src);

      if (src->Register.SwizzleX != TGSI_SWIZZLE_X ||
          src->Register.SwizzleY != TGSI_SWIZZLE_Y ||
          src->Register.SwizzleZ != TGSI_SWIZZLE_Z ||
          src->Register.SwizzleW != TGSI_SWIZZLE_W) {
         CHR( '.' );
         ENM( src->Register.SwizzleX, tgsi_swizzle_names );
         ENM( src->Register.SwizzleY, tgsi_swizzle_names );
         ENM( src->Register.SwizzleZ, tgsi_swizzle_names );
         ENM( src->Register.SwizzleW, tgsi_swizzle_names );
      }

      if (src->Register.Absolute)
         CHR( '|' );

      first_reg = FALSE;
   }

   if (inst->Instruction.Texture) {
      if (!(inst->Instruction.Opcode >= TGSI_OPCODE_SAMPLE &&
            inst->Instruction.Opcode <= TGSI_OPCODE_GATHER4)) {
         TXT( ", " );
         ENM( inst->Texture.Texture, tgsi_texture_names );
      }
      for (i = 0; i < inst->Texture.NumOffsets; i++) {
         TXT( ", " );
         TXT(tgsi_file_name(inst->TexOffsets[i].File));
         CHR( '[' );
         SID( inst->TexOffsets[i].Index );
         CHR( ']' );
         CHR( '.' );
         ENM( inst->TexOffsets[i].SwizzleX, tgsi_swizzle_names);
         ENM( inst->TexOffsets[i].SwizzleY, tgsi_swizzle_names);
         ENM( inst->TexOffsets[i].SwizzleZ, tgsi_swizzle_names);
      }
   }

   switch (inst->Instruction.Opcode) {
   case TGSI_OPCODE_IF:
   case TGSI_OPCODE_UIF:
   case TGSI_OPCODE_ELSE:
   case TGSI_OPCODE_BGNLOOP:
   case TGSI_OPCODE_ENDLOOP:
   case TGSI_OPCODE_CAL:
   case TGSI_OPCODE_BGNSUB:
      TXT( " :" );
      UID( inst->Label.Label );
      break;
   }

   /* update indentation */
   if (inst->Instruction.Opcode == TGSI_OPCODE_IF ||
       inst->Instruction.Opcode == TGSI_OPCODE_UIF ||
       inst->Instruction.Opcode == TGSI_OPCODE_ELSE ||
       inst->Instruction.Opcode == TGSI_OPCODE_BGNLOOP) {
      ctx->indentation += indent_spaces;
   }

   EOL();

   return TRUE;
}
예제 #28
0
static void
dump_instruction_verbose(
   struct tgsi_full_instruction  *inst,
   unsigned                      ignored,
   unsigned                      deflt,
   struct tgsi_full_instruction  *fi )
{
   unsigned i;

   TXT( "\nOpcode     : OPCODE_" );
   TXT( tgsi_get_opcode_info( inst->Instruction.Opcode )->mnemonic );
   if( deflt || fi->Instruction.Saturate != inst->Instruction.Saturate ) {
      TXT( "\nSaturate   : " );
      ENM( inst->Instruction.Saturate, TGSI_SATS );
   }
   if( deflt || fi->Instruction.NumDstRegs != inst->Instruction.NumDstRegs ) {
      TXT( "\nNumDstRegs : " );
      UID( inst->Instruction.NumDstRegs );
   }
   if( deflt || fi->Instruction.NumSrcRegs != inst->Instruction.NumSrcRegs ) {
      TXT( "\nNumSrcRegs : " );
      UID( inst->Instruction.NumSrcRegs );
   }
   if( ignored ) {
      TXT( "\nPadding    : " );
      UIX( inst->Instruction.Padding );
   }

   if( deflt || tgsi_compare_instruction_ext_label( inst->InstructionExtLabel, fi->InstructionExtLabel ) ) {
      EOL();
      TXT( "\nType    : " );
      ENM( inst->InstructionExtLabel.Type, TGSI_INSTRUCTION_EXTS );
      if( deflt || fi->InstructionExtLabel.Label != inst->InstructionExtLabel.Label ) {
         TXT( "\nLabel   : " );
         UID( inst->InstructionExtLabel.Label );
      }
      if( ignored ) {
         TXT( "\nPadding : " );
         UIX( inst->InstructionExtLabel.Padding );
         if( deflt || fi->InstructionExtLabel.Extended != inst->InstructionExtLabel.Extended ) {
            TXT( "\nExtended: " );
            UID( inst->InstructionExtLabel.Extended );
         }
      }
   }

   if( deflt || tgsi_compare_instruction_ext_texture( inst->InstructionExtTexture, fi->InstructionExtTexture ) ) {
      EOL();
      TXT( "\nType    : " );
      ENM( inst->InstructionExtTexture.Type, TGSI_INSTRUCTION_EXTS );
      if( deflt || fi->InstructionExtTexture.Texture != inst->InstructionExtTexture.Texture ) {
         TXT( "\nTexture : " );
         ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES );
      }
      if( ignored ) {
         TXT( "\nPadding : " );
         UIX( inst->InstructionExtTexture.Padding );
         if( deflt || fi->InstructionExtTexture.Extended != inst->InstructionExtTexture.Extended ) {
            TXT( "\nExtended: " );
            UID( inst->InstructionExtTexture.Extended );
         }
      }
   }

   for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
      struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
      struct tgsi_full_dst_register *fd = &fi->FullDstRegisters[i];

      EOL();
      TXT( "\nFile     : " );
      ENM( dst->DstRegister.File, TGSI_FILES );
      if( deflt || fd->DstRegister.WriteMask != dst->DstRegister.WriteMask ) {
         TXT( "\nWriteMask: " );
         ENM( dst->DstRegister.WriteMask, TGSI_WRITEMASKS );
      }
      if( ignored ) {
         if( deflt || fd->DstRegister.Indirect != dst->DstRegister.Indirect ) {
            TXT( "\nIndirect : " );
            UID( dst->DstRegister.Indirect );
         }
         if( deflt || fd->DstRegister.Dimension != dst->DstRegister.Dimension ) {
            TXT( "\nDimension: " );
            UID( dst->DstRegister.Dimension );
         }
      }
      if( deflt || fd->DstRegister.Index != dst->DstRegister.Index ) {
         TXT( "\nIndex    : " );
         SID( dst->DstRegister.Index );
      }
      if( ignored ) {
         TXT( "\nPadding  : " );
         UIX( dst->DstRegister.Padding );
         if( deflt || fd->DstRegister.Extended != dst->DstRegister.Extended ) {
            TXT( "\nExtended : " );
            UID( dst->DstRegister.Extended );
         }
      }

      if( deflt || tgsi_compare_dst_register_ext_modulate( dst->DstRegisterExtModulate, fd->DstRegisterExtModulate ) ) {
         EOL();
         TXT( "\nType    : " );
         ENM( dst->DstRegisterExtModulate.Type, TGSI_DST_REGISTER_EXTS );
         if( deflt || fd->DstRegisterExtModulate.Modulate != dst->DstRegisterExtModulate.Modulate ) {
            TXT( "\nModulate: " );
            ENM( dst->DstRegisterExtModulate.Modulate, TGSI_MODULATES );
         }
         if( ignored ) {
            TXT( "\nPadding : " );
            UIX( dst->DstRegisterExtModulate.Padding );
            if( deflt || fd->DstRegisterExtModulate.Extended != dst->DstRegisterExtModulate.Extended ) {
               TXT( "\nExtended: " );
               UID( dst->DstRegisterExtModulate.Extended );
            }
         }
      }
   }

   for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
      struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
      struct tgsi_full_src_register *fs = &fi->FullSrcRegisters[i];

      EOL();
      TXT( "\nFile     : ");
      ENM( src->SrcRegister.File, TGSI_FILES );
      if( deflt || fs->SrcRegister.SwizzleX != src->SrcRegister.SwizzleX ) {
         TXT( "\nSwizzleX : " );
         ENM( src->SrcRegister.SwizzleX, TGSI_SWIZZLES );
      }
      if( deflt || fs->SrcRegister.SwizzleY != src->SrcRegister.SwizzleY ) {
         TXT( "\nSwizzleY : " );
         ENM( src->SrcRegister.SwizzleY, TGSI_SWIZZLES );
      }
      if( deflt || fs->SrcRegister.SwizzleZ != src->SrcRegister.SwizzleZ ) {
         TXT( "\nSwizzleZ : " );
         ENM( src->SrcRegister.SwizzleZ, TGSI_SWIZZLES );
      }
      if( deflt || fs->SrcRegister.SwizzleW != src->SrcRegister.SwizzleW ) {
         TXT( "\nSwizzleW : " );
         ENM( src->SrcRegister.SwizzleW, TGSI_SWIZZLES );
      }
      if( deflt || fs->SrcRegister.Negate != src->SrcRegister.Negate ) {
         TXT( "\nNegate   : " );
         UID( src->SrcRegister.Negate );
      }
      if( ignored ) {
         if( deflt || fs->SrcRegister.Indirect != src->SrcRegister.Indirect ) {
            TXT( "\nIndirect : " );
            UID( src->SrcRegister.Indirect );
         }
         if( deflt || fs->SrcRegister.Dimension != src->SrcRegister.Dimension ) {
            TXT( "\nDimension: " );
            UID( src->SrcRegister.Dimension );
         }
      }
      if( deflt || fs->SrcRegister.Index != src->SrcRegister.Index ) {
         TXT( "\nIndex    : " );
         SID( src->SrcRegister.Index );
      }
      if( ignored ) {
         if( deflt || fs->SrcRegister.Extended != src->SrcRegister.Extended ) {
            TXT( "\nExtended : " );
            UID( src->SrcRegister.Extended );
         }
      }

      if( deflt || tgsi_compare_src_register_ext_mod( src->SrcRegisterExtMod, fs->SrcRegisterExtMod ) ) {
         EOL();
         TXT( "\nType     : " );
         ENM( src->SrcRegisterExtMod.Type, TGSI_SRC_REGISTER_EXTS );
         if( deflt || fs->SrcRegisterExtMod.Complement != src->SrcRegisterExtMod.Complement ) {
            TXT( "\nComplement: " );
            UID( src->SrcRegisterExtMod.Complement );
         }
         if( deflt || fs->SrcRegisterExtMod.Bias != src->SrcRegisterExtMod.Bias ) {
            TXT( "\nBias     : " );
            UID( src->SrcRegisterExtMod.Bias );
         }
         if( deflt || fs->SrcRegisterExtMod.Scale2X != src->SrcRegisterExtMod.Scale2X ) {
            TXT( "\nScale2X   : " );
            UID( src->SrcRegisterExtMod.Scale2X );
         }
         if( deflt || fs->SrcRegisterExtMod.Absolute != src->SrcRegisterExtMod.Absolute ) {
            TXT( "\nAbsolute  : " );
            UID( src->SrcRegisterExtMod.Absolute );
         }
         if( deflt || fs->SrcRegisterExtMod.Negate != src->SrcRegisterExtMod.Negate ) {
            TXT( "\nNegate   : " );
            UID( src->SrcRegisterExtMod.Negate );
         }
         if( ignored ) {
            TXT( "\nPadding   : " );
            UIX( src->SrcRegisterExtMod.Padding );
            if( deflt || fs->SrcRegisterExtMod.Extended != src->SrcRegisterExtMod.Extended ) {
               TXT( "\nExtended  : " );
               UID( src->SrcRegisterExtMod.Extended );
            }
         }
      }
   }
}
예제 #29
0
inline typename TypedObject<T>::Iterator TypedObject<T>::selectWhere(Connection& connection, const tstring& predicate)
{
	tstring query = Core::fmt(TXT("SELECT * FROM %s WHERE %s"), T::WMI_CLASS_NAME, predicate.c_str());

	return connection.execQuery(query.c_str());
}
예제 #30
0
void CNetDDESvrApp::OnNetDDEClientConnect(CNetDDESvrSocket& oConnection, CNetDDEPacket& oReqPacket)
{
	ASSERT(oReqPacket.DataType() == CNetDDEPacket::NETDDE_CLIENT_CONNECT);

	bool bResult = false;

	uint16  nProtocol;
	CString strService;
	CString strComputer;
	CString strUser;
	CString strProcess;
	CString strVersion;

	// Decode request message.
	CMemStream oReqStream(oReqPacket.Buffer());

	oReqStream.Open();
	oReqStream.Seek(sizeof(CNetDDEPacket::Header));

	oReqStream >> nProtocol;
	oReqStream >> strService;
	oReqStream >> strComputer;
	oReqStream >> strUser;
	oReqStream >> strProcess;
	oReqStream >> strVersion;

	oReqStream.Close();

	if (App.m_bTraceNetConns)
	{
		App.Trace(TXT("NETDDE_CLIENT_CONNECT: %u %s %s %s"), nProtocol, strService, strComputer, strUser);
		App.Trace(TXT("NETDDE_CLIENT_VERSION: %s %s"), strProcess, strVersion);
	}

	// Save connection details.
	oConnection.m_strService  = strService;
	oConnection.m_strComputer = strComputer;
	oConnection.m_strUser     = strUser;

	if (nProtocol == NETDDE_PROTOCOL)
		bResult = true;

	// Create response message.
	CBuffer    oRspBuffer;
	CMemStream oRspStream(oRspBuffer);

	oRspStream.Create();

	oRspStream << bResult;
	oRspStream << CString(App.VERSION);

	oRspStream.Close();

	// Send response message.
	CNetDDEPacket oRspPacket(CNetDDEPacket::NETDDE_CLIENT_CONNECT, oReqPacket.PacketID(), oRspBuffer);

	oConnection.SendPacket(oRspPacket);

	// Update stats.
	++m_nPktsSent;
}