Пример #1
0
void main()
{
	int devices = setupESCAPI();

	if (devices == 0)
	{
		printf("ESCAPI initialization failure or no devices found.\n");
		return;
	}

	int i;
	for (i = 0; i < devices; i++)
	{
		char temp[256];
		getCaptureDeviceName(i, temp, 256);
		printf("Device %d: \"%s\"\n", i, temp);
	}

}
void LUA_INFO_CALLBACK(SLuaCallBack* p)
{ // the callback function of the new Lua command
	char infoString[200];
	infoString[0]=0;

	if (p->inputArgCount>0)
	{ // Ok, we have at least 1 input argument
		if (p->inputArgTypeAndSize[0*2+0]==sim_lua_arg_int)
		{ // Ok, we have (at least) one int as argument
			if ( (countCaptureDevices()>p->inputInt[0])&&(p->inputInt[0]>=0)&&(p->inputInt[0]<4) )
			{
				getCaptureDeviceName(p->inputInt[0],infoString,200);
			}
			else
				simSetLastError(LUA_INFO,"Wrong index."); // output an error
		}
		else
			simSetLastError(LUA_INFO,"Wrong argument type/size."); // output an error
	}
	else
		simSetLastError(LUA_INFO,"Not enough arguments."); // output an error

	// Now we prepare the return value:
	int l=int(strlen(infoString));
	if (l!=0)
	{
		p->outputArgCount=1; // 1 return value
		p->outputArgTypeAndSize=(simInt*)simCreateBuffer(p->outputArgCount*2*sizeof(simInt)); // x return values takes x*2 simInt for the type and size buffer
		p->outputArgTypeAndSize[2*0+0]=sim_lua_arg_string;	// The return value is a string
		p->outputArgTypeAndSize[2*0+1]=1;					// Not used (table size if the return value was a table)
		p->outputChar=(simChar*)simCreateBuffer(l+1); // 1 string return value
		for (int i=0;i<l;i++)
			p->outputChar[i]=infoString[i];
		p->outputChar[l]=0;
	}
	else
		p->outputArgCount=0; // no return values (nil)
}