NaCl libpcsc

Check-in [727411c09e]
Login
Overview
Comment:First incomplete conversion from the old PCSC build to the new one
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 727411c09ec37deff9b88e8ca954f74b715d09ee
User & Date: rkeene on 2016-04-13 21:58:41
Other Links: manifest | tags
Context
2016-04-13
22:13
Better targets check-in: 60c7795ca7 user: rkeene tags: trunk
21:58
First incomplete conversion from the old PCSC build to the new one check-in: 727411c09e user: rkeene tags: trunk
20:16
initial empty check-in check-in: a10d20a3d7 user: rkeene tags: trunk
Changes

Added Makefile version [1ca3a38e08].





































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# Setup cross-compiler toolchain
## Set path to include the tools
PATH := ${PATH}:${NACL_SDK_ROOT}/toolchain/linux_pnacl/bin
export PATH

## Set variables needed by projects
HOST_CC      := $(shell which "$${CC:-cc}")
BUILD_CC     := ${HOST_CC}
CC_FOR_BUILD := ${HOST_CC}
AR           := pnacl-ar
AS           := pnacl-as
LD           := pnacl-ld
CC           := pnacl-clang
CXX          := pnacl-clang++
RANLIB       := pnacl-ranlib
STRIP        := pnacl-strip
OBJCOPY      := pnacl-objcopy
export HOST_CC BUILD_CC CC_FOR_BUILD AR AS LD CC CXX RANLIB STRIP OBJCOPY

## Set some CFLAGS that the compiler fails to internally set
CFLAGS       := -I${NACL_SDK_ROOT}/include
CXXFLAGS     := $(CFLAGS)
CPPFLAGS     := $(CFLAGS)
export CFLAGS CXXFLAGS CPPFLAGS

all: libpcsc.a

libpcsc.a:

boost: build-boost
	rm -rf boost
	./build-boost

.PHONY: all

Added bin/download version [6ec0ffbfde].





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#! /usr/bin/env bash

url="$1"
file="$2"
hash="$3"

if [ -f "${file}" ]; then
	exit 0
fi

mkdir -p "$(dirname "${file}")"

hashMethod='sha256'

rm -f "${file}.new"
wget --header "X-Cache-URL: ${url}" -O "${file}.new" "http://hashcache.rkeene.org/${hashMethod}/${hash}" || \
	wget -O "${file}.new" "${url}" || \
	exit 1

chkHash="$(openssl "${hashMethod}" "${file}.new" | sed 's@.*= *@@')"

if [ "${chkHash}" != "${hash}" ]; then
	echo "error: Checksum mismatch: Got: ${chkHash}; Expected: ${hash}" >&2

	exit 1
fi

mv "${file}.new" "${file}"

exit 0

Added bin/extract version [6d090e378d].



























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#! /usr/bin/env bash

file="$1"
directory="$2"

if [ ! -f "${file}" ]; then
	echo "error: Unable to extract \"${file}\"" >&2

	exit 1
fi

rm -rf "${directory}"

mkdir -p "${directory}" || exit 1
(
	cd "${directory}" || exit 1

	case "${file}" in
		*.tar.bz2|*.bz2)
			bzip2 -dc | tar -xf - || exit 1
			;;
		*.tar.gz|*.tgz)
			gzip -dc | tar -xf - || exit 1
			;;
		*.tar.xz|*.txz)
			xz -dc | tar -xf - || exit 1
			;;
		*.zip)
			cat > x.zip || exit 1
			unzip -q x.zip || exit 1
			rm -f x.zip
			;;
		*)
			echo "error: Don't know what to do with \"${file}\"" >&2

			exit 1
			;;
	esac

	if [ -d "$(echo *)" ]; then
		mv */* . >/dev/null 2>/dev/null
	fi
) < "${file}" || exit 1

exit 0

Added build-boost version [451acab69b].

























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /usr/bin/env bash

# 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d

ourScript="$(which "$0")"
if ! head -3 "${ourScript}" 2>/dev/null | grep 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d >/dev/null; then
	echo "error: Unable to find ourselves" >&2

	exit 1
fi

cd "$(dirname "${ourScript}")" || exit 1

PATH="${PATH}:$(pwd)/bin"
export PATH

if [ -z "${NACL_SDK_ROOT}" ]; then
	echo "error: Please set NACL_SDK_ROOT to the path of the current NaCl SDK target" >&2

	exit 1
fi

if [ ! -d "${NACL_SDK_ROOT}/toolchain" ]; then
	echo "error: Invalid NACL_SDK_ROOT, not found: ${NACL_SDK_ROOT}/toolchain" >&2

	exit 1
fi

# Build "boost"
function buildBoost() {
	local version url pkg sha256 configure_extra
	local archive workdir

	pkg='boost'
	version='1.57.0'
	url="http://downloads.sourceforge.net/project/boost/boost/${version}/boost_`echo ${version} | sed 's_\._\__g'`.tar.bz2"
	sha256='910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967'

	archive="archive/${pkg}-${version}.tar.bz2"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"

	download "${url}" "${archive}" "${sha256}" || return 1
	extract "${archive}" "${workdir}" || return 1

	(
		cd "${workdir}" || exit 1

		./bootstrap.sh --prefix="${instdir}" --with-python=false --show-libraries

		./bootstrap.sh --prefix="${instdir}" --with-python=false --without-libraries='atomic,chrono,container,context,coroutine,date_time,exception,filesystem,graph,graph_parallel,iostreams,locale,log,math,mpi,program_options,python,random,regex,serialization,signals,system,test,thread,timer,wave' || exit 1

		echo "using gcc : pnacl : ${CXX} ;" >> project-config.jam

		./b2 --debug-configuration toolset=gcc-pnacl target-os=linux link=static runtime-link=static || exit 1

		./bjam install | grep -v '^common.copy '

		exit 0
	) || return 1

	rm -rf "${workdir}"

	return 0
}

rm -rf boost.new
instdir="$(pwd)/boost.new/boost"
mkdir -p "${instdir}"

buildBoost || exit 1

rm -rf 'boost'
mv "$(pwd)/boost.new/boost" "$(pwd)"
rm -rf boost.new

exit 0

Added build/assemble-source-from-google.sh version [0f3dced8de].





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
57
58
59
60
61
62
#! /usr/bin/env bash

# 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d

ourScript="$(which "$0")"
if ! head -3 "${ourScript}" 2>/dev/null | grep 2b98dedbf1b314ee8bfa3ac824efabee2c9b402d >/dev/null; then
	echo "error: Unable to find ourselves" >&2

	exit 1
fi

cd "$(dirname "${ourScript}")" || exit 1
cd .. || exit 1

PATH="${PATH}:$(pwd)/bin"
export PATH

# Build the libpcsc we need
function assemblePCSC() {
	local version url pkg sha256
	local archive workdir

	pkg='google-chrome-smart-card-apps'
	version='20160317'
	sha256='a144a81be9fe72eb7698a7dc0c1aba6425220551cca432ba7e58984422a7cf46'

	archive="archive/${pkg}-${version}-nobinaries.zip"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"

	extract "${archive}" "${workdir}" || return 1

	(
		cd "${workdir}" || exit 1

		# Copy out PC/SC headers for later use
		mkdir -p "${instdir}/include/PCSC" || exit 1
		cp third_party/pcsc-lite/src-*/src/PCSC/*.h "${instdir}/include/PCSC" || exit 1

		# Copy out JavaScript files for later use
		mkdir "${instdir}/js" || exit 1
#		cp common-utils/*.js "${instdir}/js" || exit 1
#		cp third_party/pcsc-lite/client-side/*.js "${instdir}/js" || exit 1

		# Assemble all the files into a single tree
		for file in logging.h scard_structs_serialization.h dom_requests_manager.h thread_safe_string_pool.h \
		    pp_var_utils.cc pp_var_utils.h scard_structs_serialization.cc dom_requests_manager.cc logging.cc; do
			find . -type f -name "${file}" -exec cp '{}' "${instdir}" ';'
		done
	) || return 1

	rm -rf "${workdir}"

	return 0
}

instdir="$(pwd)/pcsc/src"
rm -rf "${instdir}"
mkdir -p "${instdir}"

assemblePCSC || exit 1

exit 0

Added pcsc/Makefile version [db5548a6ca].













































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
CFLAGS   += -Wall -std=gnu++11 -g3 -ggdb3
CXXFLAGS += -Wall -std=gnu++11 -g3 -ggdb3
CPPFLAGS += -I../src/src/PCSC

OBJS = pcsc_nacl.o pcsc_nacl_global.o scard_structs_serialization.o pp_var_utils.o logging.o dom_requests_manager.o pcsc_nacl_init.o

all: libpcsc.a

libpcsc.a: $(OBJS)
	rm -f libpcsc.a
	$(AR) rc libpcsc.a $(OBJS)
	-$(RANLIB) libpcsc.a

pcsc_nacl_init.o: pcsc_nacl_init.cc pcsc_nacl_global.h dom_requests_manager.h pcsc_nacl.h

pcsc_nacl.o: pcsc_nacl.cc pcsc_nacl.h logging.h pp_var_utils.h scard_structs_serialization.h
pcsc_nacl.h: dom_requests_manager.h thread_safe_string_pool.h

pcsc_nacl_global.o: pcsc_nacl_global.cc pcsc_nacl_global.h logging.h
pcsc_nacl_global.h: pcsc_nacl.h

pp_var_utils.o: pp_var_utils.cc pp_var_utils.h logging.h
pp_var_utils.h: logging.h

scard_structs_serialization.o: scard_structs_serialization.cc scard_structs_serialization.h pp_var_utils.h
scard_structs_serialization.h: pp_var_utils.h

dom_requests_manager.o: dom_requests_manager.cc dom_requests_manager.h logging.h pp_var_utils.h

logging.o: logging.cc logging.h

clean:
	rm -f $(OBJS)
	rm -f libpcsc.a

distclean: clean

.PHONY: all clean distclean

Added pcsc/pcsc-nacl.h version [5374437abd].























>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
#ifndef PCSC_NACL_H
#define PCSC_NACL_H 1
#ifdef __cplusplus
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>

void pcscNaClInit(pp::Instance *instance, pp::Core *core, const char *smartcardManagerAppId, const char *clientId);
bool pcscNaClHandleMessage(const pp::Var &message);

#endif
#endif

Added pcsc/pcsc_nacl_init.cc version [683a161fcd].























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>

#include <unistd.h>

#include "pcsc_nacl_global.h"
#include "dom_requests_manager.h"
#include "pcsc_nacl.h"

static DomRequestsManager *pcscNaClDRM = NULL;

void pcscNaClInit(pp::Instance *instance, pp::Core *core, const char *smartcardManagerAppId, const char *clientId) {
	DomRequestsManager::PpDelegateImpl *drmDelegateImpl;
	PcscNacl *pcsc_nacl;

	if (smartcardManagerAppId == NULL) {
		smartcardManagerAppId = "khpfeaanjngmcnplbdlpegiifgpfgdco";
	}

	if (clientId == NULL) {
		clientId = "UNKNOWN";
	}

	if (pcscNaClDRM == NULL) {
		drmDelegateImpl = new DomRequestsManager::PpDelegateImpl(instance, core);
	
		pcscNaClDRM = new DomRequestsManager("pcsc-nacl", drmDelegateImpl);
	}

	pcsc_nacl = new PcscNacl(pcscNaClDRM, smartcardManagerAppId, clientId);

	if (!pcsc_nacl->Initialize()) {
		return;
	}

	SetPcscNaclGlobalInstance(pcsc_nacl);

	return;
}

bool pcscNaClHandleMessage(const pp::Var &message) {
	return(pcscNaClDRM->HandleMessage(message));
}