src/Cedar/VLanWin32.c
// Get the instance list of virtual LAN card

Get the instance list of virtual LAN card
Get the instance list of virtual LAN card
INSTANCE_LIST *GetInstanceList()
{
	INSTANCE_LIST *n = ZeroMalloc(sizeof(INSTANCE_LIST));
	char **ss = EnumVLan(VLAN_ADAPTER_NAME);
	if (ss == NULL)
	{
		n->NumInstance = 0;
		n->InstanceName = Malloc(0);
		return n;
	}
	else
	{
		UINT i, num;
		i = num = 0;
		while (true)
		{
			if (ss[i++] == NULL)
			{
				break;
			}
			num++;
		}
		i = 0;
		n->NumInstance = num;
		n->InstanceName = (char **)ZeroMalloc(sizeof(char *) * n->NumInstance);
		for (i = 0;i < num;i++)
		{
			char *s = ss[i] + StrLen(VLAN_ADAPTER_NAME) + StrLen(" - ");
			if (StrLen(ss[i]) > StrLen(VLAN_ADAPTER_NAME) + StrLen(" - "))
			{
				n->InstanceName[i] = CopyStr(s);
			}
		}
		FreeEnumVLan(ss);
	}
	ss = EnumVLan(VLAN_ADAPTER_NAME_OLD);
	if (ss != NULL)
	{
		UINT i, num, j;
		i = num = 0;
		while (true)
		{
			if (ss[i++] == NULL)
			{
				break;
			}
			num++;
		}
		j = n->NumInstance;
		n->NumInstance += num;
		n->InstanceName = (char **)ReAlloc(n->InstanceName, sizeof(char) * n->NumInstance);
		for (i = 0;i < num;i++)
		{
			char *s = ss[i] + StrLen(VLAN_ADAPTER_NAME_OLD) + StrLen(" - ");
			if (StrLen(ss[i]) > StrLen(VLAN_ADAPTER_NAME_OLD) + StrLen(" - "))
			{
				n->InstanceName[j] = CopyStr(s);
			}
			j++;
		}
		FreeEnumVLan(ss);
	}
	return n;
}
INSTANCE_LIST * GetInstanceList ( ) { INSTANCE_LIST * n = ZeroMalloc ( sizeof ( INSTANCE_LIST ) ) ; char * * ss = EnumVLan ( VLAN_ADAPTER_NAME ) ; if ( ss == NULL ) { n -> NumInstance = 0 ; n -> InstanceName = Malloc ( 0 ) ; return n ; } else { UINT i , num ; i = num = 0 ; while ( true ) { if ( ss [ i ++ ] == NULL ) { break ; } num ++ ; } i = 0 ; n -> NumInstance = num ; n -> InstanceName = ( char * * ) ZeroMalloc ( sizeof ( char * ) * n -> NumInstance ) ; for ( i = 0 ; i < num ; i ++ ) { char * s = ss [ i ] + StrLen ( VLAN_ADAPTER_NAME ) + StrLen ( " " ) ; if ( StrLen ( ss [ i ] ) > StrLen ( VLAN_ADAPTER_NAME ) + StrLen ( " " ) ) { n -> InstanceName [ i ] = CopyStr ( s ) ; } } FreeEnumVLan ( ss ) ; } ss = EnumVLan ( VLAN_ADAPTER_NAME_OLD ) ; if ( ss != NULL ) { UINT i , num , j ; i = num = 0 ; while ( true ) { if ( ss [ i ++ ] == NULL ) { break ; } num ++ ; } j = n -> NumInstance ; n -> NumInstance += num ; n -> InstanceName = ( char * * ) ReAlloc ( n -> InstanceName , sizeof ( char ) * n -> NumInstance ) ; for ( i = 0 ; i < num ; i ++ ) { char * s = ss [ i ] + StrLen ( VLAN_ADAPTER_NAME_OLD ) + StrLen ( " " ) ; if ( StrLen ( ss [ i ] ) > StrLen ( VLAN_ADAPTER_NAME_OLD ) + StrLen ( " " ) ) { n -> InstanceName [ j ] = CopyStr ( s ) ; } j ++ ; } FreeEnumVLan ( ss ) ; } return n ; }
Get the instance list of virtual LAN card
Get the instance list of virtual LAN card
// Enumeration
 // Failure
