1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| #define _CRT_SECURE_NO_DEPRECATE
#include "ModuleInterface.h"
#include <vector>
#include <string>
typedef std::pair<std::string, std::string> DeviceInfo;
std::vector<DeviceInfo> g_availableDevices;
MODULE_API long GetModuleVersion();
long GetModuleVersion()
{
return MODULE_INTERFACE_VERSION;
}
MODULE_API long GetDeviceInterfaceVersion()
{
return DEVICE_INTERFACE_VERSION;
}
void AddAvailableDeviceName(const char* name, const char* descr)
{
std::vector<DeviceInfo>::const_iterator it;
for (it=g_availableDevices.begin(); it!=g_availableDevices.end(); ++it)
if (it->first.compare(name) == 0)
return; // already there
// add to the list
g_availableDevices.push_back(std::make_pair(name, descr));
}
MODULE_API unsigned GetNumberOfDevices()
{
return (unsigned) g_availableDevices.size();
}
MODULE_API bool GetDeviceName(unsigned deviceIndex, char* name, unsigned bufLen)
{
if (deviceIndex >= g_availableDevices.size())
return false;
if (g_availableDevices[deviceIndex].first.length() >= bufLen)
return false; // buffer too small, can't truncate the name
strcpy(name, g_availableDevices[deviceIndex].first.c_str());
return true;
}
MODULE_API bool GetDeviceDescription(unsigned deviceIndex, char* description, unsigned bufLen)
{
if (deviceIndex >= g_availableDevices.size())
return false;
strncpy(description, g_availableDevices[deviceIndex].second.c_str(), bufLen-1);
return true;
} |
Partager