vpcd-config: added scripts for windows builds
This commit is contained in:
@@ -8,10 +8,17 @@
|
|||||||
#include<stdio.h> //printf
|
#include<stdio.h> //printf
|
||||||
#include<string.h> //memset
|
#include<string.h> //memset
|
||||||
#include<errno.h> //errno
|
#include<errno.h> //errno
|
||||||
|
#include<string.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include<winsock2.h>
|
||||||
|
#include<WS2tcpip.h>
|
||||||
|
#define close(s) closesocket(s)
|
||||||
|
#else
|
||||||
#include<sys/socket.h> //socket
|
#include<sys/socket.h> //socket
|
||||||
#include<netinet/in.h> //sockaddr_in
|
#include<netinet/in.h> //sockaddr_in
|
||||||
#include<arpa/inet.h> //getsockname
|
#include<arpa/inet.h> //getsockname
|
||||||
#include<unistd.h> //close
|
#include<unistd.h> //close
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ERROR_STRING "Unable to guess local IP address"
|
#define ERROR_STRING "Unable to guess local IP address"
|
||||||
|
|
||||||
@@ -23,7 +30,12 @@ const char *local_ip (void)
|
|||||||
socklen_t namelen = sizeof(name);
|
socklen_t namelen = sizeof(name);
|
||||||
struct sockaddr_in serv;
|
struct sockaddr_in serv;
|
||||||
static char buffer[20];
|
static char buffer[20];
|
||||||
int sock = socket ( AF_INET, SOCK_DGRAM, 0);
|
int sock = -1;
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSADATA wsaData;
|
||||||
|
WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
|
#endif
|
||||||
|
sock = socket ( AF_INET, SOCK_DGRAM, 0);
|
||||||
if(sock < 0) {
|
if(sock < 0) {
|
||||||
perror(ERROR_STRING);
|
perror(ERROR_STRING);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -42,6 +54,9 @@ const char *local_ip (void)
|
|||||||
ip = buffer;
|
ip = buffer;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
if (!ip)
|
if (!ip)
|
||||||
printf("%s: %s\n" , ERROR_STRING, strerror(errno));
|
printf("%s: %s\n" , ERROR_STRING, strerror(errno));
|
||||||
if (sock > 0)
|
if (sock > 0)
|
||||||
|
|||||||
@@ -19,17 +19,23 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
#include "vpcd.h"
|
#include "vpcd.h"
|
||||||
|
|
||||||
extern const char *local_ip (void);
|
extern const char *local_ip (void);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define VICC_MAX_SLOTS 1
|
||||||
|
#include <process.h>
|
||||||
|
#include <string.h>
|
||||||
|
#else
|
||||||
/* pcscd allows at most 16 readers. We will use 10.
|
/* pcscd allows at most 16 readers. We will use 10.
|
||||||
* See PCSCLITE_MAX_READERS_CONTEXTS in pcsclite.h */
|
* See PCSCLITE_MAX_READERS_CONTEXTS in pcsclite.h */
|
||||||
#include <pcsclite.h>
|
#include <pcsclite.h>
|
||||||
#define VICC_MAX_SLOTS \
|
#define VICC_MAX_SLOTS \
|
||||||
(PCSCLITE_MAX_READERS_CONTEXTS > 6 ? \
|
(PCSCLITE_MAX_READERS_CONTEXTS > 6 ? \
|
||||||
PCSCLITE_MAX_READERS_CONTEXTS-6 : 1)
|
PCSCLITE_MAX_READERS_CONTEXTS-6 : 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ERROR_STRING "Unable to guess local IP address"
|
#define ERROR_STRING "Unable to guess local IP address"
|
||||||
|
|
||||||
@@ -46,14 +52,33 @@ void print_qrcode(const char *uri)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define QR_SERVICE_URL "https://api.qrserver.com/v1/create-qr-code/?data="
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#define IE_PATH "\"C:\\Program Files\\Internet Explorer\\IExplore.exe\" "
|
||||||
void print_qrcode(const char *uri)
|
void print_qrcode(const char *uri)
|
||||||
{
|
{
|
||||||
printf("https://api.qrserver.com/v1/create-qr-code/?data=%s\n", uri);
|
char command[200];
|
||||||
|
memset(command, 0, sizeof command);
|
||||||
|
strcpy(command, IE_PATH);
|
||||||
|
strcat(command, QR_SERVICE_URL);
|
||||||
|
strcat(command, uri);
|
||||||
|
system(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void print_qrcode(const char *uri)
|
||||||
|
{
|
||||||
|
printf("%s%s\n", QR_SERVICE_URL, uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main ( int argc , char *argv[] )
|
int main ( int argc , char *argv[] )
|
||||||
{
|
{
|
||||||
char slot;
|
char slot;
|
||||||
@@ -65,16 +90,17 @@ int main ( int argc , char *argv[] )
|
|||||||
if (!ip)
|
if (!ip)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
for (slot = 1; slot < VICC_MAX_SLOTS; slot++) {
|
for (slot = 0; slot < VICC_MAX_SLOTS; slot++) {
|
||||||
port = VPCDPORT+slot-1;
|
port = VPCDPORT+slot;
|
||||||
printf("VPCD hostname: %s\n", ip);
|
printf("VPCD hostname: %s\n", ip);
|
||||||
printf("VPCD port: %d\n", port);
|
printf("VPCD port: %d\n", port);
|
||||||
printf("On your NFC phone with the Remote Smart Card Reader app scan this code:\n", port);
|
printf("On your NFC phone with the Remote Smart Card Reader app scan this code:\n");
|
||||||
sprintf(uri, "vpcd://%s:%d", ip, port);
|
sprintf(uri, "vpcd://%s:%d", ip, port);
|
||||||
print_qrcode(uri);
|
print_qrcode(uri);
|
||||||
puts("");
|
if (slot < VICC_MAX_SLOTS-1)
|
||||||
|
puts("");
|
||||||
}
|
}
|
||||||
|
|
||||||
fail = 0;
|
fail = 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
|||||||
20
virtualsmartcard/win32/vpcd-config/vpcd-config.sln
Normal file
20
virtualsmartcard/win32/vpcd-config/vpcd-config.sln
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vpcd-config", "vpcd-config.vcxproj", "{F5ECFFD7-BE92-4A5F-94B0-FF91F7680B0F}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{F5ECFFD7-BE92-4A5F-94B0-FF91F7680B0F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{F5ECFFD7-BE92-4A5F-94B0-FF91F7680B0F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{F5ECFFD7-BE92-4A5F-94B0-FF91F7680B0F}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{F5ECFFD7-BE92-4A5F-94B0-FF91F7680B0F}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
74
virtualsmartcard/win32/vpcd-config/vpcd-config.vcxproj
Normal file
74
virtualsmartcard/win32/vpcd-config/vpcd-config.vcxproj
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{F5ECFFD7-BE92-4A5F-94B0-FF91F7680B0F}</ProjectGuid>
|
||||||
|
<RootNamespace>vpcdconfig</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..\src\vpcd;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>Ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\src\vpcd-config\local-ip.c" />
|
||||||
|
<ClCompile Include="..\..\src\vpcd-config\vpcd-config.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\src\vpcd\vpcd.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user