예제 #1
0
파일: zvarargs.c 프로젝트: mingpen/OpenNT
int _CRTAPI1  Z_cscanf (const char* Arg1, DWORD64ARGS)
{

    int RetVal;

    SHORT sTimerHandle;
    ULONG ulElapsedTime;

    if (fInitDone == FALSE) {
        ApfInitDll();
    }
    TimerOpen(&sTimerHandle, MICROSECONDS);
    TimerInit(sTimerHandle);
    //
    // Call the api
    //
    RetVal = _cscanf(Arg1, ARGS64);
    //
    // Get the elapsed time
    //
    ulElapsedTime = TimerRead(sTimerHandle);
    ApfRecordInfo(I__cscanf, ulElapsedTime - ApfData[I_CALIBRATE].ulFirstTime);
    TimerClose(sTimerHandle);

    return(RetVal);
}
예제 #2
0
파일: console.c 프로젝트: abc6081/daq
int con_scanf(char *fmt, void *app)
{
#ifdef LINUX

  int i;

  echo();
  i = scanw(fmt,app);    
  refresh();
  noecho();
  return i;

#else

  int res;
      
  res = _cscanf(fmt, app) ;

  con_kbhit() ;                 /* Due to input reading problem */

  return res;

#endif
}
예제 #3
0
int GetTestDeviceFromList(struct BENCHMARK_TEST_PARAM* testParam)
{
    const int LINE_MAX_SIZE   = 1024;
    const int STRING_MAX_SIZE = 256;
    const int NUM_STRINGS = 3;
    const int ALLOC_SIZE = LINE_MAX_SIZE + (STRING_MAX_SIZE * NUM_STRINGS);

    int userInput;

    char* buffer;
    char* line;
    char* product;
    char* manufacturer;
    char* serial;

    struct usb_bus* bus;
    struct usb_device* dev;
    usb_dev_handle* udev;
    struct usb_device* validDevices[256];

    int deviceIndex=0;
	struct usb_interface_descriptor* firstInterface;

    int ret = -1;

    buffer = malloc(ALLOC_SIZE);
    if (!buffer)
    {
        CONERR0("failed allocating memory!\n");
        return ret;
    }

    line = buffer;
    product = buffer + LINE_MAX_SIZE;
    manufacturer = product + STRING_MAX_SIZE;
    serial = manufacturer + STRING_MAX_SIZE;

    for (bus = usb_get_busses(); bus; bus = bus->next)
    {
        for (dev = bus->devices; dev; dev = dev->next)
        {

            udev = usb_open(dev);
            if (udev)
            {
                memset(buffer, 0, ALLOC_SIZE);
                line = buffer;
                if (dev->descriptor.iManufacturer)
                {
                    if (usb_get_string_simple(udev, dev->descriptor.iManufacturer, manufacturer, STRING_MAX_SIZE - 1) > 0)
                    {
                        strcat(line,"(");
                        strcat(line,manufacturer);
                        strcat(line,") ");
                    }
                }

                if (dev->descriptor.iProduct)
                {
                    if (usb_get_string_simple(udev, dev->descriptor.iProduct, product, STRING_MAX_SIZE - 1) > 0)
                    {
                        strcat(line,product);
                        strcat(line," ");
                    }
                }

                if (dev->descriptor.iSerialNumber)
                {
                    if (usb_get_string_simple(udev, dev->descriptor.iSerialNumber, serial, STRING_MAX_SIZE - 1) > 0)
                    {
                        strcat(line,"[");
                        strcat(line,serial);
                        strcat(line,"] ");
                    }
                }

                if (!deviceIndex)
                    CONMSG0("\n");

                validDevices[deviceIndex++] = dev;

                CONMSG("%d. %04X:%04X %s\n",
                          deviceIndex, dev->descriptor.idVendor, dev->descriptor.idProduct, line);

                usb_close(udev);
            }
        }
    }
    
	if (!deviceIndex) 
	{
		CONERR0("No devices where found!\n");
		ret = -1;
		goto Done;
	}

    CONMSG("\nSelect device (1-%d) :",deviceIndex);
	ret = _cscanf("%i",&userInput);
    if (ret != 1 || userInput < 1)
	{
        CONMSG0("\n");
        CONMSG0("Aborting..\n");
		ret = -1;
		goto Done;
	}
    CONMSG0("\n");
    userInput--;
    if (userInput >= 0 && userInput < deviceIndex)
    {
        testParam->DeviceHandle = usb_open(validDevices[userInput]);
        if (testParam->DeviceHandle)
        {
			testParam->Device = validDevices[userInput];
            testParam->Vid = testParam->Device->descriptor.idVendor;
            testParam->Pid = testParam->Device->descriptor.idProduct;
			if (usb_find_interface(&validDevices[userInput]->config[0],testParam->Intf, testParam->Altf, &firstInterface) == NULL)
			{
				// the specified (or default) interface didn't exist, use the first one.
				if (firstInterface != NULL)
				{
					testParam->Intf = firstInterface->bInterfaceNumber;
				}
				else
				{
					CONERR("device %04X:%04X does not have any interfaces!\n",
						testParam->Vid, testParam->Pid);
					ret = -1;
					goto Done;
				}
			}
            ret = 0;
        }
	}

Done:
	if (buffer)
        free(buffer);

    return ret;
}