- Initial support for win32

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@654 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
fabled 2002-06-14 12:52:56 +00:00
parent 523b680f32
commit 7635468ed9
43 changed files with 337 additions and 54 deletions

8
Makefile.mak Normal file
View File

@ -0,0 +1,8 @@
SUBDIRS = src
all::
all depend install clean::
@for %i in ( $(SUBDIRS) ) do \
@cmd /c "cd %i && $(MAKE) /nologo /f Makefile.mak $@"

26
README.Win32 Normal file
View File

@ -0,0 +1,26 @@
README for Win32 port of OpenSC
Compiling
=========
Type "nmake -f makefile.mak" to compile.
You need also perl and flex installed for the compile process
to complete succesfully.
What works
==========
At the moment only libopensc and basic tools have been ported
to windows. They should at least compile.
What needs to be done
=====================
Other parts of OpenSC should ported as well (other tools & pkcs11
module). Also we should implement native Win32 APIs such as
CryptoAPI Provider, some login stuff and ActiveX plugin for
Explorer to do the signing.

View File

@ -2,5 +2,8 @@
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = Makefile.mak
# Order IS important
SUBDIRS = common include scconf scldap scrandom libopensc pkcs15init tests tools openssh scam pam sia signer pkcs11

8
src/Makefile.mak Normal file
View File

@ -0,0 +1,8 @@
SUBDIRS = include common scconf libopensc tools
all::
all depend install clean::
@for %i in ( $(SUBDIRS) ) do \
@cmd /c "cd %i && $(MAKE) /nologo /f Makefile.mak $@"

View File

@ -2,4 +2,4 @@
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = getopt.c getopt.h getopt1.c
EXTRA_DIST = Makefile.mak getopt.c getopt.h getopt1.c getpass.c

14
src/common/Makefile.mak Normal file
View File

@ -0,0 +1,14 @@
TOPDIR = ..\..
HEADERS = getopt.h
TARGET = common.lib
OBJECTS = getopt.obj getopt1.obj getpass.obj
all: $(TARGET) install-headers
$(TARGET): $(OBJECTS)
lib /nologo /machine:ix86 /out:$(TARGET) $(OBJECTS)
!INCLUDE $(TOPDIR)\win32\Make.rules.mak

5
src/include/Makefile.mak Normal file
View File

@ -0,0 +1,5 @@
all: config.h
config.h: winconfig.h
@copy /y winconfig.h config.h

26
src/include/winconfig.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef _OPENSC_WINCONFIG_H
#define _OPENSC_WINCONFIG_H
#ifndef strcasecmp
#define strcasecmp stricmp
#endif
#ifndef strncasecmp
#define strncasecmp strnicmp
#endif
#ifndef snprintf
#define snprintf _snprintf
#endif
#ifndef vsnprintf
#define vsnprintf _vsnprintf
#endif
#ifndef isatty
#define isatty _isatty
#endif
#define OPENSC_CONF_PATH "C:\\WINNT\\opensc.conf"
#endif

View File

@ -4,7 +4,7 @@ includedir = ${prefix}/include/opensc
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = opensc-config.in
EXTRA_DIST = Makefile.mak opensc-config.in
if HAVE_SSL
SSL_LIB = @LIBCRYPTO@

View File

@ -0,0 +1,26 @@
TOPDIR = ..\..
TARGET = opensc.dll
HEADERS = opensc.h pkcs15.h emv.h \
errors.h types.h \
cardctl.h asn1.h log.h
OBJECTS = sc.obj ctx.obj module.obj asn1.obj log.obj base64.obj \
errors.obj sec.obj card.obj iso7816.obj dir.obj \
pkcs15.obj pkcs15-cert.obj pkcs15-pin.obj \
pkcs15-prkey.obj pkcs15-pubkey.obj pkcs15-sec.obj \
pkcs15-wrap.obj pkcs15-algo.obj \
pkcs15-cache.obj reader-pcsc.obj \
card-setcos.obj card-miocos.obj card-flex.obj card-gpk.obj \
card-etoken.obj card-tcos.obj card-emv.obj card-default.obj
all: $(TARGET) install-headers
!INCLUDE $(TOPDIR)\win32\Make.rules.mak
$(TARGET): $(OBJECTS)
perl $(TOPDIR)\win32\makedef.pl $*.def $* $(OBJECTS)
link $(LINKFLAGS) /dll /def:$*.def /implib:$*.lib /out:$(TARGET) $(OBJECTS) ..\scconf\scconf.lib winscard.lib

View File

@ -153,7 +153,11 @@ static void sc_asn1_print_utf8string(const u8 * buf, size_t buflen)
static void sc_asn1_print_integer(const u8 * buf, size_t buflen)
{
#ifndef _WIN32
long long a = 0;
#else
__int64 a = 0;
#endif
int i;
if (buflen > sizeof(a)) {
@ -169,7 +173,11 @@ static void sc_asn1_print_integer(const u8 * buf, size_t buflen)
static void sc_asn1_print_bit_string(const u8 * buf, size_t buflen)
{
unsigned long long a = 0;
#ifndef _WIN32
long long a = 0;
#else
__int64 a = 0;
#endif
int i, r;
if (buflen > sizeof(a) + 1) {

View File

@ -58,7 +58,8 @@ static int autodetect_class(struct sc_card *card)
apdu.datalen = 0;
apdu.lc = 0;
apdu.le = 256;
apdu.resplen = sizeof(rbuf);
apdu.resp = rbuf;
apdu.resplen = sizeof(rbuf);
r = sc_transmit_apdu(card, &apdu);
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
if (apdu.sw1 == 0x6E)

View File

@ -386,7 +386,7 @@ static void parse_sec_attr(struct sc_file *file, const u8 *buf, size_t len)
/* acl defaults to 0xFF if unspecified */
for (i = 0; i < 9; i++)
if (idx[i] != -1)
add_acl_entry(file, idx[i], (i < len) ? buf[i] : 0xFF);
add_acl_entry(file, idx[i], (u8)((i < len) ? buf[i] : 0xFF));
}
static int etoken_select_file(struct sc_card *card,

View File

@ -195,18 +195,18 @@ static int parse_flex_sf_reply(struct sc_context *ctx, const u8 *buf, int buflen
}
p += 2;
if (file->type == SC_FILE_TYPE_DF) {
add_acl_entry(file, SC_AC_OP_LIST_FILES, p[0] >> 4, is_mf);
add_acl_entry(file, SC_AC_OP_DELETE, p[1] >> 4, is_mf);
add_acl_entry(file, SC_AC_OP_CREATE, p[1] & 0x0F, is_mf);
add_acl_entry(file, SC_AC_OP_LIST_FILES, (u8)(p[0] >> 4), is_mf);
add_acl_entry(file, SC_AC_OP_DELETE, (u8)(p[1] >> 4), is_mf);
add_acl_entry(file, SC_AC_OP_CREATE, (u8)(p[1] & 0x0F), is_mf);
} else { /* EF */
add_acl_entry(file, SC_AC_OP_READ, p[0] >> 4, 0);
add_acl_entry(file, SC_AC_OP_READ, (u8)(p[0] >> 4), 0);
switch (file->ef_structure) {
case SC_FILE_EF_TRANSPARENT:
add_acl_entry(file, SC_AC_OP_UPDATE, p[0] & 0x0F, 0);
add_acl_entry(file, SC_AC_OP_UPDATE, (u8)(p[0] & 0x0F), 0);
break;
case SC_FILE_EF_LINEAR_FIXED:
case SC_FILE_EF_LINEAR_VARIABLE:
add_acl_entry(file, SC_AC_OP_UPDATE, p[0] & 0x0F, 0);
add_acl_entry(file, SC_AC_OP_UPDATE, (u8)(p[0] & 0x0F), 0);
break;
case SC_FILE_EF_CYCLIC:
#if 0
@ -216,8 +216,8 @@ static int parse_flex_sf_reply(struct sc_context *ctx, const u8 *buf, int buflen
break;
}
}
add_acl_entry(file, SC_AC_OP_REHABILITATE, p[2] >> 4, is_mf);
add_acl_entry(file, SC_AC_OP_INVALIDATE, p[2] & 0x0F, is_mf);
add_acl_entry(file, SC_AC_OP_REHABILITATE, (u8)(p[2] >> 4), is_mf);
add_acl_entry(file, SC_AC_OP_INVALIDATE, (u8)(p[2] & 0x0F), is_mf);
p += 3;
if (*p++)
file->status = SC_FILE_STATUS_ACTIVATED;

View File

@ -319,9 +319,9 @@ static void parse_sec_attr(struct sc_file *file, const u8 *buf, size_t len)
if (ops[i] == -1)
continue;
if ((i & 1) == 0)
add_acl_entry(file, ops[i], buf[i / 2] >> 4);
add_acl_entry(file, ops[i], (u8)(buf[i / 2] >> 4));
else
add_acl_entry(file, ops[i], buf[i / 2] & 0x0F);
add_acl_entry(file, ops[i], (u8)(buf[i / 2] & 0x0F));
}
}

View File

@ -25,6 +25,7 @@
#include "cardctl.h"
#include <string.h>
#include <ctype.h>
#include <time.h>
static const char *tcos_atrs[] = {
"3B:BA:13:00:81:31:86:5D:00:64:05:0A:02:01:31:80:90:00:8B", /* SLE44 */

View File

@ -288,8 +288,10 @@ static struct sc_card * sc_card_new()
return NULL;
}
card->app_count = -1;
card->magic = SC_CARD_MAGIC;
card->magic = SC_CARD_MAGIC;
#ifdef HAVE_PTHREAD
pthread_mutex_init(&card->mutex, NULL);
#endif
return card;
}
@ -311,8 +313,10 @@ static void sc_card_free(struct sc_card *card)
free(card->ops);
if (card->algorithms != NULL)
free(card->algorithms);
#ifdef HAVE_PTHREAD
pthread_mutex_destroy(&card->mutex);
card->magic = 0;
#endif
card->magic = 0;
free(card);
}
@ -429,8 +433,10 @@ int sc_lock(struct sc_card *card)
assert(card != NULL);
SC_FUNC_CALLED(card->ctx, 2);
#ifdef HAVE_PTHREAD
pthread_mutex_lock(&card->mutex);
if (card->lock_count == 0) {
#endif
if (card->lock_count == 0) {
if (card->reader->ops->lock != NULL)
r = card->reader->ops->lock(card->reader, card->slot);
if (r == 0)
@ -438,8 +444,10 @@ int sc_lock(struct sc_card *card)
}
if (r == 0)
card->lock_count++;
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&card->mutex);
SC_FUNC_RETURN(card->ctx, 2, r);
#endif
SC_FUNC_RETURN(card->ctx, 2, r);
}
int sc_unlock(struct sc_card *card)
@ -448,16 +456,20 @@ int sc_unlock(struct sc_card *card)
assert(card != NULL);
SC_FUNC_CALLED(card->ctx, 2);
#ifdef HAVE_PTHREAD
pthread_mutex_lock(&card->mutex);
card->lock_count--;
#endif
card->lock_count--;
assert(card->lock_count >= 0);
if (card->lock_count == 0) {
if (card->reader->ops->unlock != NULL)
r = card->reader->ops->unlock(card->reader, card->slot);
card->cache_valid = 0;
memset(&card->cache, 0, sizeof(card->cache));
}
pthread_mutex_unlock(&card->mutex);
}
#ifdef HAVE_PTHREAD
pthread_mutex_unlock(&card->mutex);
#endif
SC_FUNC_RETURN(card->ctx, 2, r);
}

View File

@ -60,10 +60,12 @@ static const struct _sc_driver_entry internal_card_drivers[] = {
};
static const struct _sc_driver_entry internal_reader_drivers[] = {
#ifdef HAVE_LIBPCSCLITE
#if defined(HAVE_LIBPCSCLITE) || defined(_WIN32)
{ "pcsc", (void *) sc_get_pcsc_driver, NULL },
#endif
{ "ctapi", (void *) sc_get_ctapi_driver, NULL },
#ifndef _WIN32
{ "ctapi", (void *) sc_get_ctapi_driver, NULL },
#endif
{ NULL, NULL, NULL }
};

View File

@ -18,14 +18,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "log.h"
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#ifndef _WIN32
#include <unistd.h>
#include <sys/time.h>
#else
#include <io.h>
#endif
#ifndef __GNUC__
void error(struct sc_context *ctx, const char *format, ...)
@ -90,11 +97,9 @@ void do_log2(struct sc_context *ctx, int type, const char *file,
FILE *outf = NULL;
char buf[1024], *p;
int left, r;
struct timeval tv;
const char *color_pfx = "", *color_sfx = "";
assert(ctx != NULL);
gettimeofday(&tv, NULL);
switch (type) {
case SC_LOG_TYPE_ERROR:
if (ctx->log_errors == 0)

View File

@ -32,8 +32,9 @@ extern "C" {
#define SC_LOG_TYPE_VERBOSE 1
#define SC_LOG_TYPE_DEBUG 2
#ifdef __GNUC__
#define error(ctx, format, args...) do_log(ctx, SC_LOG_TYPE_ERROR, __FILE__, __LINE__, __FUNCTION__ , format , ## args)
#if defined(__GNUC__)
#define error(ctx, format, args...) do_log(ctx, SC_LOG_TYPE_ERROR, __FILE__, __LINE__, __FUNCTION__, format , ## args)
#define debug(ctx, format, args...) do_log(ctx, SC_LOG_TYPE_DEBUG, __FILE__, __LINE__, __FUNCTION__, format , ## args)
#else

View File

@ -27,6 +27,8 @@
#include <dlfcn.h>
#endif
#ifndef _WIN32
int sc_module_open(struct sc_context *ctx, void **mod_handle, const char *filename)
{
const char *error;
@ -96,3 +98,8 @@ int sc_module_get_address(struct sc_context *ctx, void *mod_handle, void **sym_a
*sym_address = address;
return SC_SUCCESS;
}
#else
#endif

View File

@ -688,7 +688,7 @@ struct sc_card_error {
const char *errorstr;
};
extern const char *sc_version;
extern const char *sc_get_version(void);
extern const struct sc_reader_driver *sc_get_pcsc_driver(void);
extern const struct sc_reader_driver *sc_get_ctapi_driver(void);

View File

@ -21,7 +21,9 @@
#include "internal.h"
#include "pkcs15.h"
#include "log.h"
#ifndef _WIN32
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

View File

@ -26,7 +26,9 @@
#include <string.h>
#include <stdio.h>
#include <sys/stat.h>
#ifndef _WIN32
#include <unistd.h>
#endif
#include <assert.h>
static int parse_x509_cert(struct sc_context *ctx, const u8 *buf, size_t buflen, struct sc_pkcs15_cert *cert)

View File

@ -25,7 +25,9 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifndef _WIN32
#include <unistd.h>
#endif
static int pkcs1_strip_padding(u8 *data, size_t len)
{

View File

@ -23,7 +23,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <wintypes.h>
/* #include <wintypes.h> */
#include <winscard.h>
/* Default timeout value for SCardGetStatusChange
@ -36,6 +36,20 @@
#define SC_STATUS_TIMEOUT SC_CUSTOM_STATUS_TIMEOUT
#endif
#ifdef _WIN32
/* Some windows specific kludge */
#define SCARD_PROTOCOL_ANY (SCARD_PROTOCOL_T0)
#define SCARD_SCOPE_GLOBAL SCARD_SCOPE_USER
/* Error printing */
#define PCSC_ERROR(ctx, desc, rv) error(ctx, desc ": %lx\n", rv);
#else
#define PCSC_ERROR(ctx, desc, rv) error(ctx, desc ": %s\n", pcsc_stringify_error(rv));
#endif
#define GET_SLOT_PTR(s, i) (&(s)->slot[(i)])
#define GET_PRIV_DATA(r) ((struct pcsc_private_data *) (r)->drv_data)
#define GET_SLOT_DATA(r) ((struct pcsc_slot_data *) (r)->drv_data)
@ -112,9 +126,9 @@ static int pcsc_transmit(struct sc_reader *reader, struct sc_slot_info *slot,
card = pslot->pcsc_card;
sSendPci.dwProtocol = opensc_proto_to_pcsc(slot->active_protocol);
sSendPci.cbPciLength = 0;
sSendPci.cbPciLength = sizeof(sSendPci);
sRecvPci.dwProtocol = opensc_proto_to_pcsc(slot->active_protocol);
sRecvPci.cbPciLength = 0;
sRecvPci.cbPciLength = sizeof(sRecvPci);
if (prv->gpriv->apdu_fix && sendsize >= 6) {
/* Check if the APDU in question is of Case 4 */
@ -134,10 +148,13 @@ static int pcsc_transmit(struct sc_reader *reader, struct sc_slot_info *slot,
dwSendLength = sendsize;
dwRecvLength = *recvsize;
if (dwRecvLength > 255)
if (dwRecvLength > 255)
dwRecvLength = 255;
rv = SCardTransmit(card, &sSendPci, sendbuf, dwSendLength,
&sRecvPci, recvbuf, &dwRecvLength);
rv = SCardTransmit(card, &sSendPci, sendbuf, dwSendLength,
&sRecvPci, recvbuf, &dwRecvLength);
if (rv != SCARD_S_SUCCESS) {
switch (rv) {
case SCARD_W_REMOVED_CARD:
@ -151,8 +168,8 @@ static int pcsc_transmit(struct sc_reader *reader, struct sc_slot_info *slot,
return SC_ERROR_CARD_REMOVED;
#endif
return SC_ERROR_TRANSMIT_FAILED;
default:
error(reader->ctx, "SCardTransmit failed: %s\n", pcsc_stringify_error(rv));
default:
PCSC_ERROR(reader->ctx, "SCardTransmit failed", rv);
return SC_ERROR_TRANSMIT_FAILED;
}
}
@ -174,7 +191,7 @@ static int pcsc_detect_card_presence(struct sc_reader *reader, struct sc_slot_in
rgReaderStates[0].dwEventState = SCARD_STATE_UNAWARE;
ret = SCardGetStatusChange(priv->pcsc_ctx, SC_STATUS_TIMEOUT, rgReaderStates, 1);
if (ret != 0) {
error(reader->ctx, "SCardGetStatusChange failed: %s\n", pcsc_stringify_error(ret));
PCSC_ERROR(reader->ctx, "SCardGetStatusChange failed", ret);
SC_FUNC_RETURN(reader->ctx, 1, pcsc_ret_to_error(ret));
}
if (rgReaderStates[0].dwEventState & SCARD_STATE_PRESENT) {
@ -196,7 +213,7 @@ static int refresh_slot_attributes(struct sc_reader *reader, struct sc_slot_info
rgReaderStates[0].dwEventState = SCARD_STATE_UNAWARE;
ret = SCardGetStatusChange(priv->pcsc_ctx, SC_STATUS_TIMEOUT, rgReaderStates, 1);
if (ret != 0) {
error(reader->ctx, "SCardGetStatusChange failed: %s\n", pcsc_stringify_error(ret));
PCSC_ERROR(reader->ctx, "SCardGetStatusChange failed", ret);
return pcsc_ret_to_error(ret);
}
slot->flags = 0;
@ -230,11 +247,11 @@ static int pcsc_connect(struct sc_reader *reader, struct sc_slot_info *slot)
pslot = (struct pcsc_slot_data *) malloc(sizeof(struct pcsc_slot_data));
if (pslot == NULL)
return SC_ERROR_OUT_OF_MEMORY;
rv = SCardConnect(priv->pcsc_ctx, priv->reader_name,
rv = SCardConnect(priv->pcsc_ctx, priv->reader_name,
SCARD_SHARE_SHARED, SCARD_PROTOCOL_ANY,
&card_handle, &active_proto);
&card_handle, &active_proto);
if (rv != 0) {
error(reader->ctx, "SCardConnect failed: %s\n", pcsc_stringify_error(rv));
PCSC_ERROR(reader->ctx, "SCardConnect failed", rv);
free(pslot);
return pcsc_ret_to_error(rv);
}
@ -265,7 +282,7 @@ static int pcsc_lock(struct sc_reader *reader, struct sc_slot_info *slot)
assert(pslot != NULL);
rv = SCardBeginTransaction(pslot->pcsc_card);
if (rv != SCARD_S_SUCCESS) {
error(reader->ctx, "SCardBeginTransaction failed: %s\n", pcsc_stringify_error(rv));
PCSC_ERROR(reader->ctx, "SCardBeginTransaction failed", rv);
return pcsc_ret_to_error(rv);
}
return 0;
@ -279,7 +296,7 @@ static int pcsc_unlock(struct sc_reader *reader, struct sc_slot_info *slot)
assert(pslot != NULL);
rv = SCardEndTransaction(pslot->pcsc_card, SCARD_LEAVE_CARD);
if (rv != SCARD_S_SUCCESS) {
error(reader->ctx, "SCardEndTransaction failed: %s\n", pcsc_stringify_error(rv));
PCSC_ERROR(reader->ctx, "SCardEndTransaction failed", rv);
return pcsc_ret_to_error(rv);
}
return 0;
@ -313,7 +330,13 @@ static int pcsc_init(struct sc_context *ctx, void **reader_data)
struct pcsc_global_private_data *gpriv;
scconf_block **blocks = NULL, *conf_block = NULL;
rv = SCardEstablishContext(SCARD_SCOPE_GLOBAL, "localhost", NULL,
rv = SCardEstablishContext(SCARD_SCOPE_GLOBAL,
#ifndef _WIN32
"localhost",
#else
NULL,
#endif
NULL,
&pcsc_ctx);
if (rv != SCARD_S_SUCCESS)
return pcsc_ret_to_error(rv);

View File

@ -26,13 +26,18 @@
#include <string.h>
#include <assert.h>
#undef sc_version
#ifdef VERSION
const char *sc_version = VERSION;
#else
#warning FIXME: version info undefined
const char *sc_version = "(undef)";
#endif
const char *sc_get_version(void)
{
return sc_version;
}
int sc_hex_to_bin(const char *in, u8 *out, size_t *outlen)
{
int err = 0;

View File

@ -20,7 +20,9 @@
#include "internal.h"
#include "log.h"
#ifndef _WIN32
#include <unistd.h>
#endif
#include <stdio.h>
#include <assert.h>

View File

@ -4,6 +4,8 @@ includedir = ${prefix}/include/opensc
MAINTAINERCLEANFILES = Makefile.in lex-parse.c
EXTRA_DIST = Makefile.am
include_HEADERS = scconf.h
noinst_HEADERS = internal.h

17
src/scconf/Makefile.mak Normal file
View File

@ -0,0 +1,17 @@
TOPDIR = ..\..
TARGET = scconf.lib
HEADERS = scconf.h
OBJECTS = parse.obj scconf.obj write.obj lex-parse.obj
.SUFFIXES : .l
all: $(TARGET) install-headers
lex-parse.c: lex-parse.l
flex -olex-parse.c < lex-parse.l
$(TARGET): $(OBJECTS)
lib /nologo /machine:ix86 /out:$(TARGET) $(OBJECTS)
!INCLUDE $(TOPDIR)\win32\Make.rules.mak

View File

@ -25,7 +25,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef _WIN32
#include <strings.h>
#endif
#include "scconf.h"
#include "internal.h"

View File

@ -25,7 +25,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef _WIN32
#include <strings.h>
#else
#define strcasecmp stricmp
#endif
#include <ctype.h>
#include "scconf.h"

View File

@ -1,6 +1,6 @@
# Process this file with automake to create Makefile.in
MAINTAINERCLEANFILES = Makefile.in
MAINTAINERCLEANFILES = Makefile.in Makefile.mak
INCLUDES = @CFLAGS_OPENSC@
LDFLAGS = @LDFLAGS@ @LIBOPENSC@

View File

@ -6,7 +6,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <opensc/opensc.h>
#include <opensc/pkcs15.h>

View File

@ -16,7 +16,7 @@ int sc_test_init(int *argc, char *argv[])
{
int i, c;
printf("Using libopensc version %s.\n", sc_version);
printf("Using libopensc version %s.\n", sc_get_version());
i = sc_establish_context(&ctx, "tests");
if (i != SC_SUCCESS) {
printf("Failed to establish context: %s\n", sc_strerror(i));

View File

@ -2,6 +2,8 @@
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = Makefile.mak
INCLUDES = @CFLAGS_OPENSC@
LDFLAGS = @LDFLAGS@ @LIBOPENSC@

17
src/tools/Makefile.mak Normal file
View File

@ -0,0 +1,17 @@
TOPDIR = ..\..
TARGETS = opensc-explorer.exe opensc-tool.exe \
pkcs15-tool.exe pkcs15-crypt.exe #pkcs15-init.exe
all: util.obj $(TARGETS)
!INCLUDE $(TOPDIR)\win32\Make.rules.mak
.c.obj:
cl $(COPTS) /c $<
.c.exe:
cl $(COPTS) /c $<
link $(LINKFLAGS) /pdb:$*.pdb /out:$@ $*.obj util.obj ..\common\common.lib ..\libopensc\opensc.lib

View File

@ -1169,7 +1169,7 @@ int main(int argc, char * const argv[])
int cargc;
char *cargv[20];
printf("OpenSC Explorer version %s\n", sc_version);
printf("OpenSC Explorer version %s\n", sc_get_version());
while (1) {
c = getopt_long(argc, argv, "r:c:d", options, &long_optind);

View File

@ -23,7 +23,9 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
#include <unistd.h>
#endif
#include <string.h>
#include <errno.h>
#include <ctype.h>

View File

@ -23,7 +23,9 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
#include <unistd.h>
#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
@ -128,7 +130,7 @@ int write_output(const u8 *buf, int len)
int output_binary = 1;
if (opt_output != NULL) {
outf = fopen(opt_output, "w");
outf = fopen(opt_output, "wb");
if (outf == NULL) {
fprintf(stderr, "Unable to open '%s' for writing.\n", opt_output);
return -1;

View File

@ -9,11 +9,14 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <fcntl.h>
#include <errno.h>
#include <getopt.h>
#ifndef _WIN32
#include <unistd.h>
#include <strings.h>
#endif
#include <sys/stat.h>
#include <opensc/opensc.h>

11
win32/Make.rules.mak Normal file
View File

@ -0,0 +1,11 @@
COPTS = /Zi /ML /nologo /DHAVE_CONFIG_H /DVERSION=\"0.7.0\" /I$(TOPDIR)\src\include
LINKFLAGS = /DEBUG /NOLOGO /INCREMENTAL:NO /MACHINE:IX86
install-headers:
@for %i in ( $(HEADERS) ) do \
@xcopy /d /q /y %i ..\include > nul
.c.obj::
cl $(COPTS) /c $<

33
win32/makedef.pl Normal file
View File

@ -0,0 +1,33 @@
$def = $ARGV[0];
shift @ARGV;
$lib = $ARGV[0];
shift @ARGV;
$dumpbin = "dumpbin /symbols @ARGV";
open(DUMP, "$dumpbin |")
|| die "Can't run `$dumpbin': $!.\n";
open(DEF, "> $def")
|| die "Can't open `$def': $!.\n";
print DEF "LIBRARY $lib\n";
print DEF "EXPORTS\n";
while(<DUMP>)
{
if(!/\bUNDEF\b/ && /\bExternal\b/)
{
s/^.*\|\s+//;
split;
$_ = $_[0];
if(!/^\?\?_G/ && !/^\?\?_E/)
{
# Stupid windows linker needs to have
# preceding underscore for ANSI C programs
s/^_//;
print DEF " $_\n";
}
}
}