void SBCFromTXT(CPhidgetSBCHandle sbc, uint16_t txtLen, const char *txtRecord)
{
	char *hversion = NULL, *txtver = NULL;
	
	uint8_t valLen = 0;
	const char *valPtr = NULL;
	
	//txt version
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "txtvers", &valLen))) return;
	if(!(txtver = malloc(valLen+1))) return;
	ZEROMEM(txtver, valLen+1);
	memcpy(txtver, valPtr, valLen);
	sbc->txtver = (short)strtol(txtver, NULL, 10);
	free(txtver);
	
	//Firmware version
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "fversion", &valLen))) return;
	if(valLen > 12) valLen = 12;
	memcpy(sbc->fversion, valPtr, valLen);
	sbc->fversion[valLen] = '\0';
	
	//Hardware version
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "hversion", &valLen))) return;
	if(!(hversion = malloc(valLen+1))) return;
	ZEROMEM(hversion, valLen+1);
	memcpy(hversion, valPtr, valLen);
	sbc->hversion = (short)strtol(hversion, NULL, 10);
	free(hversion);
	
	// things added in version 2 of the txt
	if(sbc->txtver >= 2)
	{
		//Hostname
		if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "hostname", &valLen))) return;
		if(valLen > 128) valLen = 128;
		memcpy(sbc->hostname, valPtr, valLen);
		sbc->hostname[valLen] = '\0';
	}
	
	// things added in version 3 of the txt
	if(sbc->txtver >= 3)
	{
		//Device Name
		if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "name", &valLen))) return;
		if(valLen > 128) valLen = 128;
		memcpy(sbc->deviceName, valPtr, valLen);
		sbc->deviceName[valLen] = '\0';
	}
	else
	{
		sprintf(sbc->deviceName, "PhidgetSBC");
	}
}
示例#2
0
/* Adds an element to a list - Duplicates are not allowed.
 * Return:	EPHIDGET_OK on success
 *			EPHIDGET_DUPLICATE if the element already exists in the list
 */
int CList_addToList(CListHandle *list, void *element, 
	int (*compare_fptr)(void *element1, void *element2))
{
	int result = 0;
	CListHandle trav = 0, newentry = 0;

	TESTPTRS(list, element)

	/* The very first thing we do is make sure none of these already exist in the list */
	result = CList_findInList(*list, element, compare_fptr, NULL);
	switch (result) {
		case EPHIDGET_OK:
			return EPHIDGET_DUPLICATE;
		case EPHIDGET_NOTFOUND:
			break;
		default:
			return result;
	}

	newentry = (CListHandle)malloc(sizeof(CList));
	if (!newentry) return EPHIDGET_NOMEMORY;
	ZEROMEM(newentry, sizeof(CList));

	newentry->next = 0;
	newentry->element = element;

	if (!*list)
		*list = newentry;
	else
	{
		for (trav = *list; trav->next; trav = trav->next);
		trav->next = newentry;
	}
	return EPHIDGET_OK;
}
示例#3
0
void DNSServiceQueryRecord_ws_CallBack
    (
    DNSServiceRef                       DNSServiceRef,
    DNSServiceFlags                     flags,
    uint32_t                            interfaceIndex,
    DNSServiceErrorType                 errorCode,
    const char                          *fullname,
    uint16_t                            rrtype,
    uint16_t                            rrclass,
    uint16_t                            rdlen,
    const void                          *rdata,
    uint32_t                            ttl,
    void                                *context
    )
{
	if (errorCode != kDNSServiceErr_NoError)
		LOG(PHIDGET_LOG_ERROR, "DNSServiceQueryRecord_ws_CallBack returned error: %d\n", errorCode);
	else
	{
		uint8_t valLen = 0;
		const char *valPtr = NULL;
		CPhidgetRemoteHandle networkInfo = (CPhidgetRemoteHandle)context;
		LOG(PHIDGET_LOG_INFO, "DNSServiceQueryRecord_ws_CallBack: %s",fullname);

		//server_id
		if(!(valPtr = TXTRecordGetValuePtrPtr(rdlen, rdata, "server_id", &valLen))) return;
		if(!(networkInfo->zeroconf_server_id = malloc(valLen+1))) return;
		ZEROMEM(networkInfo->zeroconf_server_id, valLen+1);
		memcpy(networkInfo->zeroconf_server_id, valPtr, valLen);
	}
}
示例#4
0
int CCONV CPhidgetDictionary_set_OnKeyChange_Handler(CPhidgetDictionaryHandle dict, CPhidgetDictionaryListenerHandle *dictlistener, const char *pattern, 
	int(CCONV *fptr)(CPhidgetDictionaryHandle dict, void *userPtr, const char *key, const char *val, CPhidgetDictionary_keyChangeReason reason),
	void *userPtr)
{
	CPhidgetDictionaryListenerHandle dict_listener;
	char errdesc[1024];
	int result;

	TESTPTRS(dict, pattern)
	TESTPTR(dictlistener)

	CThread_mutex_lock(&dict->lock);
	if(!CPhidget_statusFlagIsSet(dict->status, PHIDGET_SERVER_CONNECTED_FLAG))
	{
		CThread_mutex_unlock(&dict->lock);
		return EPHIDGET_NETWORK_NOTCONNECTED;
	}
		
	if(!(dict_listener = malloc(sizeof(CPhidgetDictionaryListener))))
	{
		CThread_mutex_unlock(&dict->lock);
		return EPHIDGET_NOMEMORY;
	}
	ZEROMEM(dict_listener, sizeof(CPhidgetDictionaryListener));
	
	dict_listener->dict = dict;
	dict_listener->fptr = fptr;
	dict_listener->userPtr = userPtr;
	
	CThread_mutex_lock(&dict->networkInfo->server->pdc_lock);
	if (!(dict_listener->listen_id = pdc_listen(dict->networkInfo->server->pdcs, pattern, dict_event_handler, dict_listener, errdesc, sizeof (errdesc))))
	{
		LOG(PHIDGET_LOG_DEBUG,"pdc_listen: %s", errdesc);
		free(dict_listener);
		CThread_mutex_unlock(&dict->networkInfo->server->pdc_lock);
		CThread_mutex_unlock(&dict->lock);
		return EPHIDGET_UNEXPECTED;
	}
	CThread_mutex_unlock(&dict->networkInfo->server->pdc_lock);
	
	CThread_mutex_lock(&dict->listenersLock);
	if((result = CList_addToList((CListHandle *)&dict->listeners, dict_listener, CPhidgetDictionaryListener_areEqual)))
	{
		CThread_mutex_unlock(&dict->listenersLock);
		CThread_mutex_lock(&dict->networkInfo->server->pdc_lock);
		pdc_ignore(dict->networkInfo->server->pdcs, dict_listener->listen_id, NULL, 0);
		CThread_mutex_unlock(&dict->networkInfo->server->pdc_lock);
		free(dict_listener);
		CThread_mutex_unlock(&dict->lock);
		return result;
	}
	CThread_mutex_unlock(&dict->listenersLock);
	CThread_mutex_unlock(&dict->lock);

	*dictlistener = dict_listener;
	
	return EPHIDGET_OK;
}
示例#5
0
文件: win8game.cpp 项目: Teile/monkey
BBWin8Game::BBWin8Game():
_nextUpdate( 0 ),
_updatePeriod( 0 ),
_d3dDevice( 0 ),
_d3dContext( 0 ),
_swapChain( 0 ),
_renderTargetView( 0 ),
_depthStencilView( 0 )
#if WINDOWS_8
,_wicFactory( 0 )
#endif
{
	_win8Game=this;
	
	ZEROMEM( _windowBounds );
	ZEROMEM( _renderTargetSize );
	
	CreateD3dDevice();
}
示例#6
0
void DDGetSurfaceDescription ( LPDIRECTDRAWSURFACE2 pSurface, DDSURFACEDESC *pSurfaceDesc )
{
	Assert ( pSurface != NULL );
	Assert ( pSurfaceDesc != NULL );

	ZEROMEM ( *pSurfaceDesc );
	pSurfaceDesc->dwSize = sizeof ( DDSURFACEDESC );

	ATTEMPT ( IDirectDrawSurface2_GetSurfaceDesc ( pSurface, pSurfaceDesc ) );
}
PlayreadySession::PlayreadySession()
    : m_key()
    , m_eKeyState(KEY_INIT)
    , m_fCommit(FALSE)
{
    DRM_RESULT dr = DRM_SUCCESS;
    DRM_ID oSessionID;
    DRM_DWORD cchEncodedSessionID = SIZEOF(m_rgchSessionID);

    ChkMem(m_pbOpaqueBuffer = (DRM_BYTE *)Oem_MemAlloc(MINIMUM_APPCONTEXT_OPAQUE_BUFFER_SIZE));
    m_cbOpaqueBuffer = MINIMUM_APPCONTEXT_OPAQUE_BUFFER_SIZE;

    ChkMem(m_poAppContext = (DRM_APP_CONTEXT *)Oem_MemAlloc(SIZEOF(DRM_APP_CONTEXT)));

    // Initialize DRM app context.
    ChkDR(Drm_Initialize(m_poAppContext,
                         NULL,
                         m_pbOpaqueBuffer,
                         m_cbOpaqueBuffer,
                         &g_dstrCDMDrmStoreName));

    if (DRM_REVOCATION_IsRevocationSupported()) {
        ChkMem(m_pbRevocationBuffer = (DRM_BYTE *)Oem_MemAlloc(REVOCATION_BUFFER_SIZE));

        ChkDR(Drm_Revocation_SetBuffer(m_poAppContext,
                                       m_pbRevocationBuffer,
                                       REVOCATION_BUFFER_SIZE));
    }

    // Generate a random media session ID.
    ChkDR(Oem_Random_GetBytes(NULL, (DRM_BYTE *)&oSessionID, SIZEOF(oSessionID)));

    ZEROMEM(m_rgchSessionID, SIZEOF(m_rgchSessionID));
    // Store the generated media session ID in base64 encoded form.
    ChkDR(DRM_B64_EncodeA((DRM_BYTE *)&oSessionID,
                          SIZEOF(oSessionID),
                          m_rgchSessionID,
                          &cchEncodedSessionID,
                          0));

    GST_DEBUG("Playready initialized");

 ErrorExit:
    if (DRM_FAILED(dr)) {
        m_eKeyState = KEY_ERROR;
        GST_ERROR("Playready initialization failed");
    }
}
示例#8
0
int CCONV CPhidgetDictionary_create(CPhidgetDictionaryHandle *dict)
{
	CPhidgetDictionaryHandle dicttemp = 0;
	
	TESTPTR(dict)

	if(!(dicttemp = (CPhidgetDictionaryHandle)malloc(sizeof(CPhidgetDictionary))))
		return EPHIDGET_NOMEMORY;
	ZEROMEM(dicttemp, sizeof(CPhidgetDictionary));

	CThread_mutex_init(&dicttemp->lock);
	CThread_mutex_init(&dicttemp->listenersLock);
	CThread_mutex_init(&dicttemp->openCloseLock);

	*dict = dicttemp;
	return EPHIDGET_OK;
}	
示例#9
0
// Lock, unlock calls
void DDLockSurface ( LPDIRECTDRAWSURFACE2 pSurface, LPRECT pDestRect, LPDDSURFACEDESC pSurfaceDesc, UINT32 uiFlags, HANDLE hEvent )
{
	HRESULT ReturnCode;

	Assert( pSurface != NULL );
	Assert( pSurfaceDesc != NULL );

	ZEROMEM ( *pSurfaceDesc );
	pSurfaceDesc->dwSize = sizeof(DDSURFACEDESC);

	do
	{
		ReturnCode = IDirectDrawSurface2_Lock( pSurface, pDestRect, pSurfaceDesc, uiFlags, hEvent);

	} while( ReturnCode == DDERR_WASSTILLDRAWING );

	ATTEMPT( ReturnCode );

}
示例#10
0
// string replacer, useful to hacking path strings etc
//
// eg:-   printf("%s\n", String_Replace("I like computers","like", "f*****g hate", TRUE));
//
// would produce "I f*****g hate computers"
//
char *String_Replace(char *psString, char *psFind, char *psReplace, BOOL bCaseInSensitive)
{
	static char sString[MAX_PATH];	
	int iFoundOffset;
	char *psFound;

	if (bCaseInSensitive)
		{
		char sFind[MAX_PATH];

		strcpy(sString,psString);
		strcpy(sFind,  psFind);

		strlwr(sString);
		strlwr(sFind);

		psFound = strstr(sString,sFind);
		iFoundOffset = psFound - sString;
		}
	else
		{
		psFound = strstr(psString,psFind);
		iFoundOffset = psFound - psString;
		}

	if (psFound)
		{
		ZEROMEM(sString);
		strncpy(sString,psString,iFoundOffset);
		strcat (sString,psReplace);
		strcat (sString,&psString[iFoundOffset+strlen(psFind)]);
		}
	else
		{
		strcpy(sString,psString);
		}

	return sString;

}// char *String_Replace(char *psString, char *psFind, char *psReplace, BOOL bCaseSensitive)
示例#11
0
void DDCreateRasterSurface ( LPDIRECTDRAW2 pDirectDraw, INT32 iWidth, INT32 iHeight,
									  BOOLEAN fVideoMemory,
									  LPDIRECTDRAWSURFACE *ppRasterSurface1,
									  LPDIRECTDRAWSURFACE2 *ppRasterSurface2 )
{
	DDSURFACEDESC	DDSurfaceDesc;

	// validate used portions of the structure
	Assert ( pDirectDraw != NULL );
	Assert ( iWidth != 0 );
	Assert ( iHeight != 0 );
	Assert ( ppRasterSurface1 != NULL );
	Assert ( ppRasterSurface2 != NULL );

	// create the raster surface
	ZEROMEM ( DDSurfaceDesc );
	DDSurfaceDesc.dwSize		= sizeof ( DDSurfaceDesc );
	DDSurfaceDesc.dwFlags	= DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
	DDSurfaceDesc.dwWidth	= iWidth;
	DDSurfaceDesc.dwHeight	= iHeight;
	DDSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_OFFSCREENPLAIN;
	DDCreateSurfaceInMemory ( pDirectDraw, &DDSurfaceDesc, fVideoMemory, ppRasterSurface1, ppRasterSurface2 );
}
示例#12
0
// this'll return a string of up to the first 4095 chars of a system error message...
//
LPCSTR SystemErrorString(DWORD dwError)
{
	static char sString[4096];

	LPVOID lpMsgBuf=0;

	FormatMessage( 
		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,
		dwError,
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
		(LPTSTR) &lpMsgBuf,
		0,
		NULL 
	);		

	ZEROMEM(sString);
	strncpy(sString,(LPCSTR) lpMsgBuf,sizeof(sString)-1);

	LocalFree( lpMsgBuf ); 

	return sString;
}
示例#13
0
int CCONV CPhidgetManager_create(CPhidgetManagerHandle *phidm)
{
	CPhidgetManagerHandle phidmtemp = 0;
	
	TESTPTR(phidm)
	if(!(phidmtemp = (CPhidgetManagerHandle)malloc(sizeof(CPhidgetManager))))
		return EPHIDGET_NOMEMORY;
	ZEROMEM(phidmtemp, sizeof(CPhidgetManager));
	
	phidmtemp->state = PHIDGETMANAGER_INACTIVE;
	
	if(!managerLockInitialized)
	{
		CThread_mutex_init(&managerLock);
		managerLockInitialized = PTRUE;
	}

	CThread_mutex_init(&phidmtemp->lock);
	CThread_mutex_init(&phidmtemp->openCloseLock);
	
	*phidm = phidmtemp;
	return EPHIDGET_OK;
}
示例#14
0
int CCONV CPhidget_create(CPhidgetHandle *phid)
{
	CPhidgetHandle temp_phid;

	TESTPTR(phid)
	
	if(!(temp_phid = malloc(sizeof(CPhidget))))
		return EPHIDGET_NOMEMORY;
	ZEROMEM(temp_phid, sizeof(CPhidget));

	CThread_mutex_init(&temp_phid->lock);
	CThread_mutex_init(&temp_phid->openCloseLock);
	CThread_mutex_init(&temp_phid->writelock);
	CThread_mutex_init(&temp_phid->outputLock);
	CThread_create_event(&temp_phid->writeAvailableEvent);
	CThread_create_event(&temp_phid->writtenEvent);

	CPhidget_clearStatusFlag(&temp_phid->status, PHIDGET_ATTACHED_FLAG, &temp_phid->lock);

	*phid = temp_phid;
	 
	 return EPHIDGET_OK;
}
示例#15
0
void DDCreateZBufferSurface ( LPDIRECTDRAW2 pDirectDraw, INT32 iWidth, INT32 iHeight,
									  BOOLEAN fVideoMemory,
									  LPDIRECTDRAWSURFACE *ppZBufferSurface1,
									  LPDIRECTDRAWSURFACE2 *ppZBufferSurface2 )
{
	DDSURFACEDESC	DDSurfaceDesc;

	// validate used portions of the structure
	Assert ( pDirectDraw != NULL );
	Assert ( iWidth != 0 );
	Assert ( iHeight != 0 );
	Assert ( ppZBufferSurface1 != NULL );
	Assert ( ppZBufferSurface2 != NULL );

	// create the z buffer
	ZEROMEM ( DDSurfaceDesc );
	DDSurfaceDesc.dwSize		= sizeof ( DDSurfaceDesc );
	DDSurfaceDesc.dwFlags	= DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_ZBUFFERBITDEPTH;
	DDSurfaceDesc.dwWidth	= iWidth;
	DDSurfaceDesc.dwHeight	= iHeight;
	DDSurfaceDesc.dwZBufferBitDepth	= 16;
	DDSurfaceDesc.ddsCaps.dwCaps		= DDSCAPS_ZBUFFER;
	DDCreateSurfaceInMemory ( pDirectDraw, &DDSurfaceDesc, fVideoMemory, ppZBufferSurface1, ppZBufferSurface2 );
}
示例#16
0
void				BinkSetupVideo(void)
{
	DDSURFACEDESC SurfaceDescription;
	HRESULT ReturnCode;
	UINT16 usRed, usGreen, usBlue;
	HVSURFACE hVSurface;

	GetVideoSurface( &hVSurface, FRAME_BUFFER );

	lpBinkVideoPlayback2 = GetVideoSurfaceDDSurface( hVSurface );

  ZEROMEM(SurfaceDescription);
  SurfaceDescription.dwSize = sizeof (DDSURFACEDESC);

  ReturnCode = IDirectDrawSurface2_GetSurfaceDesc ( lpBinkVideoPlayback2, &SurfaceDescription );
  if (ReturnCode != DD_OK)
  {
    DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
    return;
  }
 /* 
	usRed   = (UINT16) SurfaceDescription.ddpfPixelFormat.dwRBitMask;
	usGreen = (UINT16) SurfaceDescription.ddpfPixelFormat.dwGBitMask;
	usBlue  = (UINT16) SurfaceDescription.ddpfPixelFormat.dwBBitMask;

//	SurfaceDescription.ddpfPixelFormat

	if((usRed==0xf800) && (usGreen==0x07e0) && (usBlue==0x001f))
		guiBinkPixelFormat = BINKSURFACE565;
	else
		guiBinkPixelFormat = BINKSURFACE555;
*/
	//
	// Get bit count for the RGB
	//
	usRed = GetNumberOfBits( SurfaceDescription.ddpfPixelFormat.dwRBitMask );
	usGreen = GetNumberOfBits( SurfaceDescription.ddpfPixelFormat.dwGBitMask );
	usBlue = GetNumberOfBits( SurfaceDescription.ddpfPixelFormat.dwBBitMask );

	// 555
	if( usRed == 5 && usGreen == 5 && usBlue == 5 )
	{
		guiBinkPixelFormat = BINKSURFACE555;
	}
	//565
	else if( usRed == 5 && usGreen == 6 && usBlue == 5 )
	{
		guiBinkPixelFormat = BINKSURFACE565;
	}
	//655
	else if( usRed == 6 && usGreen == 5 && usBlue == 5 )
	{
		guiBinkPixelFormat = BINKSURFACE655;
	}

	//dont know the format, wont get video
	else
	{
		guiBinkPixelFormat = 0;
	}
}
void PhidFromTXT(CPhidgetHandle phid, uint16_t txtLen, const char *txtRecord)
{
	int i = 0;
	short txtver;
	
	uint8_t valLen = 0;
	const char *valPtr = NULL;
	
	//txt version
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "txtvers", &valLen))) return;
	txtver = (short)strtol(valPtr, NULL, 10);
	
	//Serial Number
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "serial", &valLen))) return;
	phid->serialNumber = strtol(valPtr, NULL, 10);
	phid->specificDevice = PTRUE;
	
	//version
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "version", &valLen))) return;
	phid->deviceVersion = strtol(valPtr, NULL, 10);
	
	//label
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "label", &valLen))) return;
	if(valLen > 10) valLen = 10;
	memcpy(phid->label, valPtr, valLen);
	phid->label[valLen] = '\0';
	
	//server_id
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "server_id", &valLen))) return;
	free(phid->networkInfo->zeroconf_server_id);
	if(!(phid->networkInfo->zeroconf_server_id = malloc(valLen+1))) return;
	ZEROMEM(phid->networkInfo->zeroconf_server_id, valLen+1);
	memcpy(phid->networkInfo->zeroconf_server_id, valPtr, valLen);
	
	// things added in version 2 of the txt
	if(txtver >= 2)
	{
		//Device ID
		if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "id", &valLen))) return;
		phid->deviceIDSpec = strtol(valPtr, NULL, 10);
		
		for(i = 1;i<PHIDGET_DEVICE_COUNT;i++)
			if(phid->deviceIDSpec == Phid_Device_Def[i].pdd_sdid) break;
		phid->deviceDef = &Phid_Device_Def[i];
		phid->attr = Phid_Device_Def[i].pdd_attr;
		
		//Device Class
		if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "class", &valLen))) return;
		phid->deviceID = strtol(valPtr, NULL, 10);
		phid->deviceType = Phid_DeviceName[phid->deviceID];
	}
	//Old version uses string searching, but some devices have the same name with different IDs
	else
	{
		char *name = NULL;
		char *type = NULL;
		
		//name
		if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "name", &valLen))) return;
		if(!(name = malloc(valLen+1))) return;
		ZEROMEM(name, valLen+1);
		memcpy(name, valPtr, valLen);
		for(i = 0;i<PHIDGET_DEVICE_COUNT;i++)
		{
			if(!strcmp(name, Phid_Device_Def[i].pdd_name))
			{
				phid->deviceIDSpec = Phid_Device_Def[i].pdd_sdid;
				phid->deviceDef = &Phid_Device_Def[i];
				phid->attr = Phid_Device_Def[i].pdd_attr;
				break;
			}
		}
		free(name);
		
		//type
		if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "type", &valLen))) return;
		if(!(type = malloc(valLen+1))) return;
		ZEROMEM(type, valLen+1);
		memcpy(type, valPtr, valLen);
		phid->deviceID = phidget_type_to_id(type);
		phid->deviceType = Phid_DeviceName[phid->deviceID];
		free(type);
	}
	
	phid->networkInfo->mdns = PTRUE;
	
}
示例#18
0
int CCONV CPhidgetManager_getAttachedDevices(CPhidgetManagerHandle phidm, CPhidgetHandle *phidArray[], int *count)
{
	CPhidgetList *trav = 0;
	int i = 0;

	TESTPTRS(phidArray, count)
	TESTPTR(phidm)

	*count = 0;
	if(CPhidget_statusFlagIsSet(phidm->status, PHIDGET_REMOTE_FLAG))
	{		
		for (trav=phidm->AttachedPhidgets; trav; trav = trav->next)
		{
			if (CPhidget_statusFlagIsSet(trav->phid->status, PHIDGET_ATTACHED_FLAG))
				(*count)++;
		}
		
		if(*count==0)
		{
			*phidArray = NULL;
		}
		else
		{
			*phidArray = (CPhidgetHandle *)malloc(sizeof(**phidArray) * *count);
			if (!*phidArray)
				return EPHIDGET_NOMEMORY;
			ZEROMEM(*phidArray, sizeof(**phidArray) * *count);

			for (trav=phidm->AttachedPhidgets, i=0; trav; trav = trav->next)
			{
				if (CPhidget_statusFlagIsSet(trav->phid->status, PHIDGET_ATTACHED_FLAG))
				{
					(*phidArray)[i] = trav->phid;
					i++;
				}
			}
		}
	}
	else
	{
		CThread_mutex_lock(&attachedDevicesLock);
		for (trav=AttachedDevices; trav; trav = trav->next)
		{
			if (CPhidget_statusFlagIsSet(trav->phid->status, PHIDGET_ATTACHED_FLAG))
				(*count)++;
		}
		if(*count==0)
		{
			*phidArray = NULL;
		}
		else
		{
			*phidArray = (CPhidgetHandle *)malloc(sizeof(**phidArray) * *count);
			if (!*phidArray)
			{
				CThread_mutex_unlock(&attachedDevicesLock);
				return EPHIDGET_NOMEMORY;
			}
			ZEROMEM(*phidArray, sizeof(**phidArray) * *count);

			for (trav=AttachedDevices, i=0; trav; trav = trav->next)
			{
				if (CPhidget_statusFlagIsSet(trav->phid->status, PHIDGET_ATTACHED_FLAG))
				{
					(*phidArray)[i] = trav->phid;
					i++;
				}
			}
		}

		CThread_mutex_unlock(&attachedDevicesLock);
	}
	return EPHIDGET_OK; 
}
示例#19
0
bool ParseSequenceLockFile(LPCSTR psFilename)
{
	#define UL_BAD   0
	#define UL_UPPER 1
	#define UL_LOWER 2
	int iUpperOrLower = UL_BAD;

	FILE *fHandle = fopen(psFilename,"rt");

	if (fHandle)
	{
		// file is text file, 
		// first line is "upper" or "lower" (ignore case), then sequence lock names till empty line or EOF		

		static char sLineBuffer[2048];	

		int iMembers = 0;

		MultiSequenceLock_t MultiSequenceLock;
		MultiSequenceLock.clear();

		while (1)
		{
			ZEROMEM(sLineBuffer);
			if (!fgets(sLineBuffer,sizeof(sLineBuffer),fHandle))
			{
				if (ferror(fHandle))
				{
					ErrorBox(va("Error while reading \"%s\"!",psFilename));
					iUpperOrLower = UL_BAD;
				}
				break;	// whether error or EOF
			}

			// zap any comments...
			//
			char *p = strstr(sLineBuffer,"//");
			if (p)
				*p=0;

			strcpy(sLineBuffer,String_ToUpper(String_LoseWhitespace(sLineBuffer)));

			if (strlen(sLineBuffer))
			{
				// analyse this line...
				//
				if (!iMembers)
				{
					if (strnicmp(sLineBuffer,"upper",5)==0)
					{
						iUpperOrLower = UL_UPPER;
					}
					else
					if (strnicmp(sLineBuffer,"lower",5)==0)
					{
						iUpperOrLower = UL_LOWER;
					}
					else
					{
						ErrorBox("First line of file must be \"upper\" or \"lower\"!");
						iUpperOrLower = UL_BAD;
						break;
					}
				}
				else
				{
					// is this string a valid sequence for upper/lower?...
					//
					int iCount = (iUpperOrLower == UL_UPPER)?Animation_GetNumUpperSequences():Animation_GetNumLowerSequences();

					int iScanIndex;
					for (iScanIndex=0; iScanIndex<iCount; iScanIndex++)
					{
						Sequence_t* pSeq = (iUpperOrLower == UL_UPPER)?Animation_GetUpperSequence(iScanIndex):Animation_GetLowerSequence(iScanIndex);

						if (strcmp(pSeq->sName.c_str(),sLineBuffer)==0)
						{
							// found this line, it's valid, so keep it...
							//
							MultiSequenceLock.push_back(iScanIndex);
							break;
						}
					}
					if (iScanIndex==iCount)
					{
						ErrorBox(va("Couldn't find specified sequence \"%s\" for model \"%s\"",sLineBuffer,(iUpperOrLower == UL_UPPER)?"UPPER":"LOWER"));
						iUpperOrLower = UL_BAD;
						break;
					}
				}
				iMembers++;
			}
		}

		if (iUpperOrLower != UL_BAD // avoid giving an error because of an existing error
			&& iMembers == 1)	// ie seq file only contains "upper" or "lower"
		{
			ErrorBox("No enum entries found in file");
			iUpperOrLower = UL_BAD;
		}

		switch (iUpperOrLower)
		{
			case UL_BAD:	

				// do nothing
				//
				break;

			case UL_UPPER:	
				
				MultiSequenceLock_Upper.clear(); 
				MultiSequenceLock_Upper = MultiSequenceLock;									
				iAnimLockNumber_Upper = -1;	
				break;

			case UL_LOWER:	
				
				MultiSequenceLock_Lower.clear();
				MultiSequenceLock_Lower = MultiSequenceLock;
				iAnimLockNumber_Lower = -1;
				break;

			default:		// I must have forgotten some new type
				assert(0);					
				break;	
		}			

		fclose(fHandle);
	}
	else
	{
		ErrorBox(va("Error opening file \"%s\"",psFilename));
	}	

	return (iUpperOrLower != UL_BAD);
}
//
// Expected synchronisation from caller. This method is not thread-safe!
//
RefPtr<Uint8Array> PlayreadySession::playreadyGenerateKeyRequest(Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
{
    RefPtr<Uint8Array> result;
    DRM_RESULT dr = DRM_SUCCESS;
    DRM_BYTE *pbChallenge = NULL;
    DRM_DWORD cbChallenge = 0;
    DRM_CHAR *pchSilentURL = NULL;
    DRM_DWORD cchSilentURL = 0;
    DRM_ANSI_STRING dastrCustomData = EMPTY_DRM_STRING;

    GST_DEBUG("generating key request");
    GST_MEMDUMP("init data", initData->data(), initData->byteLength());

    // The current state MUST be KEY_INIT otherwise error out.
    ChkBOOL(m_eKeyState == KEY_INIT, DRM_E_INVALIDARG);

    ChkDR(Drm_Content_SetProperty(m_poAppContext,
                                  DRM_CSP_AUTODETECT_HEADER,
                                  initData->data(),
                                  initData->byteLength()));
    GST_DEBUG("init data set on DRM context");

    if (DRM_SUCCEEDED(Drm_Reader_Bind(m_poAppContext, g_rgpdstrRights, NO_OF(g_rgpdstrRights), _PolicyCallback, NULL, &m_oDecryptContext))) {
        GST_DEBUG("Play rights already acquired!");
        m_eKeyState = KEY_READY;
        systemCode = dr;
        errorCode = 0;
        return nullptr;
    }
    GST_DEBUG("DRM reader bound");

    // Try to figure out the size of the license acquisition
    // challenge to be returned.
    dr = Drm_LicenseAcq_GenerateChallenge(m_poAppContext,
                                          g_rgpdstrRights,
                                          NO_OF(g_rgpdstrRights),
                                          NULL,
                                          dastrCustomData.pszString, //m_pchCustomData,
                                          dastrCustomData.cchString, //m_cchCustomData,
                                          NULL,
                                          &cchSilentURL,
                                          NULL,
                                          NULL,
                                          pbChallenge,
                                          &cbChallenge);
 
    if (dr == DRM_E_BUFFERTOOSMALL) {
        if (cchSilentURL > 0) {
            ChkMem(pchSilentURL = (DRM_CHAR *)Oem_MemAlloc(cchSilentURL + 1));
            ZEROMEM(pchSilentURL, cchSilentURL + 1);
        }

        // Allocate buffer that is sufficient to store the license acquisition
        // challenge.
        if (cbChallenge > 0)
            ChkMem(pbChallenge = (DRM_BYTE *)Oem_MemAlloc(cbChallenge));

        dr = DRM_SUCCESS;
    } else {
         ChkDR(dr);
         GST_DEBUG("challenge generated");
    }

    // Supply a buffer to receive the license acquisition challenge.
    ChkDR(Drm_LicenseAcq_GenerateChallenge(m_poAppContext,
                                           g_rgpdstrRights,
                                           NO_OF(g_rgpdstrRights),
                                           NULL,
                                           NULL,
                                           0,
                                           pchSilentURL,
                                           &cchSilentURL,
                                           NULL,
                                           NULL,
                                           pbChallenge,
                                           &cbChallenge));

    GST_MEMDUMP("generated license request :", pbChallenge, cbChallenge);

    result = Uint8Array::create(pbChallenge, cbChallenge);
    destinationURL = static_cast<const char *>(pchSilentURL);
    GST_DEBUG("destination URL : %s", destinationURL.utf8().data());

    m_eKeyState = KEY_PENDING;
    systemCode = dr;
    errorCode = 0;
    SAFE_OEM_FREE(pbChallenge);
    SAFE_OEM_FREE(pchSilentURL);

    return result;

ErrorExit:
    if (DRM_FAILED(dr)) {
        GST_DEBUG("DRM key generation failed");
        errorCode = MediaKeyError::MEDIA_KEYERR_CLIENT;
    }
    return result;
}
示例#21
0
文件: anims.cpp 项目: Eitani/OpenJK
static bool LoadAnimationCFG(LPCSTR psFullPath, ModelContainer_t *pContainer, FILE *handle)//, HDC hDC)	// hDC for text metrics
{
//	int  iLongestTextMetric = 0;
//	SIZE Size;
	bool bOk = false;	

//	FILE *handle = fopen(psFullPath,"rt");

	if (handle)
	{
		static char sLineBuffer[2048];

		int iFirstFrameAfterBoth = -1;	// stuff I need to do for ID's non-folded frame numbers
		int iFirstFrameAfterTorso= -1;

		while (1)
		{
			ZEROMEM(sLineBuffer);
			if (!fgets(sLineBuffer,sizeof(sLineBuffer),handle))
			{
				if (ferror(handle))
				{
					ErrorBox(va("Error while reading \"%s\"!",psFullPath));
//					ClearAnimationCFG();
				}
				break;	// whether error or EOF
			}

			char sComment[2048] = {0};	// keep comments now because of the way ID cfg files work

			// zap any comments...
			//
			char *p = strstr(sLineBuffer,"//");
			if (p)
			{
				strcpy(sComment,p+2);
				*p=0;
			}

			// update, to read ID cfg files, we need to skip over some stuff that Raven ones don't have...
			//
			// our cfg files don't have "sex" (how depressingly apt...)
			//
			if (strnicmp(sLineBuffer,"sex",3)==0)
				continue;
			//
			// or this other crap either...
			//
			if (strnicmp(sLineBuffer,"footsteps",9)==0)
				continue;
			if (strnicmp(sLineBuffer,"headoffset",10)==0)
				continue;
			if (strnicmp(sLineBuffer,"soundpath",9)==0)
				continue;

			Sequence_t seq;
			memset(&seq,0,sizeof(seq));

			char sLine[2048];
			int iElementsDone = sscanf( sLineBuffer, "%s %d %d %d %d", &sLine, &seq.iStartFrame, &seq.iFrameCount, &seq.iLoopFrame, &seq.iFPS );
			if (iElementsDone == EOF)
				continue;	// probably skipping over a comment line

			bool bElementsScannedOk = false;

			if (iElementsDone == 5)
			{
				// then it must be a Raven line...
				//
				bElementsScannedOk = true;
//				mdview.bAnimIsMultiPlayerFormat = false;
			}
			else
			{
				// try scanning it as an ID line...
				//
				iElementsDone = sscanf( sLineBuffer, "%d %d %d %d", &seq.iStartFrame, &seq.iFrameCount, &seq.iLoopFrame, &seq.iFPS );
				if (iElementsDone == 4)
				{
//					mdview.bAnimIsMultiPlayerFormat = true;
					// scanned an ID line in ok, now convert it to Raven format...
					//
					iElementsDone = sscanf( sComment, "%s", &sLine );	// grab anim name from original saved comment
					if (iElementsDone == 1)
					{
						// ... and convert their loop format to ours...
						//
						if (seq.iLoopFrame == 0)
						{
							seq.iLoopFrame = -1;
						}
						else
						{
							seq.iLoopFrame = seq.iFrameCount - seq.iLoopFrame;
						}


						// now do the folding number stuff since ID don't do it in their files...
						//
						if ( !strnicmp(sLine,"TORSO_",6) && iFirstFrameAfterBoth == -1)
						{
							iFirstFrameAfterBoth = seq.iStartFrame;
						}
						if ( !strnicmp(sLine,"LEGS_",5))
						{
							if (iFirstFrameAfterTorso == -1)
							{
								iFirstFrameAfterTorso = seq.iStartFrame;
							}

							// now correct the leg framenumber...
							//
							if (iFirstFrameAfterBoth != -1)	// if it did, then there'd be no torso frames, so no adj nec.
							{
								seq.iStartFrame -= (iFirstFrameAfterTorso - iFirstFrameAfterBoth);
							}
						}

						bElementsScannedOk = true;
					}
				}
			}

			if (bElementsScannedOk)
			{	
				strcpy(seq.sName,sLine);//seq.sName = sLine;

				pContainer->SequenceList.push_back(seq);

				//
				// this line seems to be ok...
				//
//				OutputDebugString(va("%s  %d %d %d %d\n",seq.sName.c_str(), seq.iStartFrame, seq.iFrameCount, seq.iLoopFrame, seq.iFrameSpeed ));


				// "both" or "torso" get added to 'upper' menu...
				//
/*				if ( (!strnicmp(seq.sName.c_str(),"BOTH_",5)) || (!strnicmp(seq.sName.c_str(),"TORSO_",6)) )
				{
					Sequences_UpperAnims.push_back(seq);
					if (iAnimLockLongestString < strlen(seq.sName.c_str()))
						iAnimLockLongestString = strlen(seq.sName.c_str());

					if (GetTextExtentPoint(	hDC,						// HDC hdc,           // handle to device context
											seq.sName.c_str(),			// LPCTSTR lpString,  // pointer to text string
											strlen(seq.sName.c_str()),	// int cbString,      // number of characters in string
											&Size						// LPSIZE lpSize      // pointer to structure for string size
											)
						)
					{
						if (iLongestTextMetric < Size.cx)
							iLongestTextMetric = Size.cx;
					}

//					Menu_UpperAnims_AddItem(seq.sName.c_str());					
				}

				// "both" or "legs" get added to 'lower' menu...
				//
				if ( (!strnicmp(seq.sName.c_str(),"BOTH_",5)) || (!strnicmp(seq.sName.c_str(),"LEGS_",5)) )
				{
					Sequences_LowerAnims.push_back(seq);
					if (iAnimLockLongestString < strlen(seq.sName.c_str()))
						iAnimLockLongestString = strlen(seq.sName.c_str());

					if (GetTextExtentPoint(	hDC,						// HDC hdc,           // handle to device context
											seq.sName.c_str(),			// LPCTSTR lpString,  // pointer to text string
											strlen(seq.sName.c_str()),	// int cbString,      // number of characters in string
											&Size						// LPSIZE lpSize      // pointer to structure for string size
											)
						)
					{
						if (iLongestTextMetric < Size.cx)
							iLongestTextMetric = Size.cx;
					}
 
//					Menu_LowerAnims_AddItem(seq.sName.c_str());
				}
*/
			}
			else
			{
				// so do we report this as an error or what?
				//
				ErrorBox(sLineBuffer);
			}
		}

		fclose(handle);
/*
		// now add to menus... (this code is awful, it was simple at first then mutated with feature-add)
		//
		char sLine[2048];
		vector< Sequence_t >::iterator it;
		for (it=Sequences_UpperAnims.begin(); it!=Sequences_UpperAnims.end(); it++)
		{
			sprintf(sLine,(*it).sName.c_str());

			while (1)
			{
				GetTextExtentPoint(	hDC,			// HDC hdc,           // handle to device context
									sLine,			// LPCTSTR lpString,  // pointer to text string
									strlen(sLine),	// int cbString,      // number of characters in string
									&Size			// LPSIZE lpSize      // pointer to structure for string size
									);
				if (Size.cx >= iLongestTextMetric)
					break;

				strcat(sLine," ");
			}

			Menu_UpperAnims_AddItem(va("%s (%d...%d)%s",sLine,(*it).iStartFrame,((*it).iStartFrame+(*it).iFrameCount)-1,((*it).iLoopFrame==-1)?"":va("  Loop %d",(*it).iStartFrame+(*it).iLoopFrame)));
		}

		for (it=Sequences_LowerAnims.begin(); it!=Sequences_LowerAnims.end(); it++)
		{
			sprintf(sLine,(*it).sName.c_str());

			while (1)
			{
				GetTextExtentPoint(	hDC,			// HDC hdc,           // handle to device context
									sLine,			// LPCTSTR lpString,  // pointer to text string
									strlen(sLine),	// int cbString,      // number of characters in string
									&Size			// LPSIZE lpSize      // pointer to structure for string size
									);
				if (Size.cx >= iLongestTextMetric)
					break;

				strcat(sLine," ");
			}

			Menu_LowerAnims_AddItem(va("%s (%d...%d)%s",sLine,(*it).iStartFrame,((*it).iStartFrame+(*it).iFrameCount)-1,((*it).iLoopFrame==-1)?"":va("  Loop %d",(*it).iStartFrame+(*it).iLoopFrame)));
		}
  */

		/*
		// a bit of sanity checking, to cope with something Bob tried to do...   :-)
		//
		Sequence_t* pSeq = NULL;
		gl_model* pModel;		
		
		if ((pModel = pModel_Lower)!=0)
		{
			pSeq = Animation_GetLowerSequence(Animation_GetNumLowerSequences()-1);
			ReportFrameMismatches(pSeq,pModel);
		}

		if ((pModel = pModel_Upper)!=0)
		{
			pSeq = Animation_GetUpperSequence(Animation_GetNumUpperSequences()-1);
			ReportFrameMismatches(pSeq,pModel);
		}
		*/
	}

	//return bOk;
	return !!(pContainer->SequenceList.size());
}
示例#22
0
Player_SID::Player_SID(ScummEngine *scumm, Audio::Mixer *mixer) {
	/*
	 * clear memory
	 */

	resID_song = 0;
	statusBits1A = 0;
	statusBits1B = 0;
	busyChannelBits = 0;
	SIDReg23 = 0;
	SIDReg23Stuff = 0;
	SIDReg24 = 0;
	bgSoundResID = 0;
	freeChannelCount = 0;
	usedChannelBits = 0;
	var481A = 0;
	songChannelBits = 0;
	//var5163 = 0;
	SIDReg24_HiNibble = 0;
	chansWithLowerPrioCount = 0;
	minChanPrio = 0;
	minChanPrioIndex = 0;

	_music = NULL;
	songFileOrChanBufData = NULL;
	actSongFileData = NULL;

	initializing = false;
	_soundInQueue = false;
	isVoiceChannel = false;
	isMusicPlaying = false;
	swapVarLoaded = false;
	bgSoundActive = false;
	filterUsed = false;
	pulseWidthSwapped = false;
	swapPrepared = false;
	filterSwapped = false;
	keepSwapVars = false;
	actFilterHasLowerPrio = false;

	ZEROMEM(chanFileData);
	ZEROMEM(chanDataOffset);
	ZEROMEM(songPosPtr);
	ZEROMEM(freqReg);
	ZEROMEM(vec6);
	ZEROMEM(songFileOrChanBufOffset);
	ZEROMEM(freqDelta);
	ZEROMEM(freqDeltaCounter);
	ZEROMEM(swapSongPosPtr);
	ZEROMEM(swapVec5);
	ZEROMEM(swapVec8);
	ZEROMEM(swapVec10);
	ZEROMEM(swapFreqReg);
	ZEROMEM(swapVec11);
	ZEROMEM(vec20);
	ZEROMEM(swapVec20);
	ZEROMEM(resStatus);
	ZEROMEM(attackReg);
	ZEROMEM(sustainReg);
	ZEROMEM(phaseBit);
	ZEROMEM(releasePhase);
	ZEROMEM(_soundQueue);
	ZEROMEM(channelMap);
	ZEROMEM(songPosUpdateCounter);
	ZEROMEM(chanPrio);
	ZEROMEM(waveCtrlReg);
	ZEROMEM(swapAttack);
	ZEROMEM(swapSustain);
	ZEROMEM(swapSongPrio);
	ZEROMEM(swapVec479C);
	ZEROMEM(swapVec19);
	ZEROMEM(swapSongPosUpdateCounter);
	ZEROMEM(swapWaveCtrlReg);
	ZEROMEM(stepTbl);

	/*
	 * initialize data
	 */

	const uint8 chanBuffer_const[3][45] = {
		{
			0x00,0x00,0x00,0x00,0x7f,0x01,0x19,0x00,
			0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,
			0x00,0x00,0xf0,0x40,0x10,0x04,0x00,0x00,
			0x00,0x04,0x27,0x03,0xff,0xff,0x01,0x00,
			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
			0x00,0x00,0x00,0x00,0x00
		},
		{
			0x00,0x00,0x00,0x00,0x7f,0x01,0x19,0x00,
			0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,
			0x00,0x00,0xf0,0x20,0x10,0x04,0x00,0x00,
			0x00,0x04,0x27,0x03,0xff,0xff,0x02,0x00,
			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
			0x00,0x00,0x00,0x00,0x00
		},
		{
			0x00,0x00,0x00,0x00,0x7f,0x01,0x19,0x00,
			0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,
			0x00,0x00,0xf0,0x20,0x10,0x04,0x00,0x00,
			0x00,0x04,0x27,0x03,0xff,0xff,0x02,0x00,
			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
			0x00,0x00,0x00,0x00,0x00
		}
	};
	memcpy(chanBuffer, chanBuffer_const, sizeof(chanBuffer_const));

	for (int i = 0; i < 7; ++i) {
		_soundQueue[i] = -1;
	};

	_music_timer = 0;

	_mixer = mixer;
	_sampleRate = _mixer->getOutputRate();
	_vm = scumm;

	// sound speed is slightly different on NTSC and PAL machines
	// as the SID clock depends on the frame rate.
	// ScummVM does not distinguish between NTSC and PAL targets
	// so we use the NTSC timing here as the music was composed for
	// NTSC systems (music on PAL systems is slower).
	_videoSystem = NTSC;
	_cpuCyclesLeft = 0;

	initSID();
	resetSID();

	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
}
示例#23
0
void PhidFromTXT(CPhidgetHandle phid, uint16_t txtLen, const char *txtRecord)
{
	int i = 0;
	char *type = NULL;
	char *serial = NULL;
	char *version = NULL;
	char *name = NULL;

	uint8_t valLen = 0;
	const char *valPtr = NULL;

	//Serial Number
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "serial", &valLen))) return;
	if(!(serial = malloc(valLen+1))) return;
	ZEROMEM(serial, valLen+1);
	memcpy(serial, valPtr, valLen);
	phid->serialNumber = strtol(serial, NULL, 10);
	phid->specificDevice = PTRUE;
	free(serial);

	//name
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "name", &valLen))) return;
	if(!(name = malloc(valLen+1))) return;
	ZEROMEM(name, valLen+1);
	memcpy(name, valPtr, valLen);
	for(i = 0;i<PHIDGET_DEVICE_COUNT;i++)
	{
		if(!strcmp(name, Phid_DeviceSpecificName[i]))
		{
			phid->deviceIDSpec = i;
			phid->attr = Phid_Device_Def[i].pdd_attr;
			break;
		}
	}
	free(name);

	//type
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "type", &valLen))) return;
	if(!(type = malloc(valLen+1))) return;
	ZEROMEM(type, valLen+1);
	memcpy(type, valPtr, valLen);
	phid->deviceID = phidget_type_to_id(type);
	phid->deviceType = Phid_DeviceName[phid->deviceID];
	free(type);

	//version
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "version", &valLen))) return;
	if(!(version = malloc(valLen+1))) return;
	ZEROMEM(version, valLen+1);
	memcpy(version, valPtr, valLen);
	phid->deviceVersion = strtol(version, NULL, 10);
	free(version);

	//label
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "label", &valLen))) return;
	if(valLen > 10) valLen = 10;
	memcpy(phid->label, valPtr, valLen);
	phid->label[valLen] = '\0';

	//server_id
	if(!(valPtr = TXTRecordGetValuePtr(txtLen, txtRecord, "server_id", &valLen))) return;
	if(!(phid->networkInfo->zeroconf_server_id = malloc(valLen+1))) return;
	ZEROMEM(phid->networkInfo->zeroconf_server_id, valLen+1);
	memcpy(phid->networkInfo->zeroconf_server_id, valPtr, valLen);

	phid->networkInfo->mdns = PTRUE;

}