Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
transmit.c File Reference

Implements the OP_PCSC_TRANSMIT opcode (conditional build). More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 free_value (vh)
map_setm (NULL, 0)
map_setm (-1)
 if (!ce||vapdu.type !=VAL_ARRAY)
 if (n< 0) n=0
 if (i< n,(int) sizeof(sbuf))
 free_value (vapdu)
 if (ce->proto==SCARD_PROTOCOL_T0) pio = *SCARD_PCI_T1
 if (rv==SCARD_S_SUCCESS &&rlen >=2)
map_setm (sw1)
map_setm (sw2)
map_setm ((int) rv)
 if (datalen > 0)
 push_value (vm, m)

Variables

case OP_PCSC_TRANSMIT
Value vh = pop_value(vm)
int hid = (int)vh.i
pcsc_card_entryce = pcsc_get_card(hid)
Value m = make_map_empty()
int n = array_length(&vapdu)
unsigned char sbuf [4096]
SCARD_IO_REQUEST pio
 else
unsigned char rbuf [4096]
DWORD rlen = sizeof(rbuf)
LONG rv = SCardTransmit(ce->h, &pio, sbuf, (DWORD)n, NULL, rbuf, &rlen)
int sw1 = -1
int sw2 = -1
int datalen = 0
 break

Detailed Description

Implements the OP_PCSC_TRANSMIT opcode (conditional build).

Transmits an APDU to the connected smart card associated with a given handle. Returns a map with the response bytes and status words. When PCSC support is disabled at build time, consumes its arguments and returns a map with code = -2.

OP_PCSC_TRANSMIT: (handle_id:int, apdu:array<int>) -> map

  • Pops: apdu array, then handle_id.
  • Pushes: map { data: array<int>, sw1:int, sw2:int, code:int }.
    • On success (code == SCARD_S_SUCCESS), data contains response bytes (no status words) and sw1/sw2 are the trailing status bytes.
    • On error, data is [], sw1/sw2 remain -1, and code is the PCSC error.
  • Notes: Negotiates protocol from the connected handle (T0/T1) and uses SCardTransmit. APDU bytes are taken modulo 256 from array ints.

Definition in file transmit.c.

Function Documentation

◆ free_value() [1/2]

free_value ( vapdu )

◆ free_value() [2/2]

free_value ( vh )

◆ if() [1/6]

if ( !ce||vapdu.type ! = VAL_ARRAY)

Definition at line 46 of file transmit.c.

◆ if() [2/6]

else if ( ce-> proto = =SCARD_PROTOCOL_T0) = *SCARD_PCI_T1

◆ if() [3/6]

if ( datalen ,
0  )

Definition at line 92 of file transmit.c.

◆ if() [4/6]

if ( i < n,
(int) sizeof(sbuf)  )

Definition at line 54 of file transmit.c.

◆ if() [5/6]

if ( )
pure virtual

Definition at line 42 of file insert.c.

◆ if() [6/6]

if ( rv = = SCARD_S_SUCCESS && rlen >= 2)

Definition at line 82 of file transmit.c.

◆ m() [1/5]

map_set & m ( (int) rv)

◆ m() [2/5]

map_set & m ( - 1)

◆ m() [3/5]

map_set & m ( NULL ,
0  )

◆ m() [4/5]

map_set & m ( sw1 )

◆ m() [5/5]

map_set & m ( sw2 )

◆ push_value()

push_value ( vm ,
m  )

Variable Documentation

◆ break

break

Definition at line 120 of file transmit.c.

◆ ce

Definition at line 38 of file transmit.c.

◆ datalen

int datalen = 0

Definition at line 81 of file transmit.c.

◆ else

else
Initial value:
{
pio = *SCARD_PCI_T1
SCARD_IO_REQUEST pio
Definition transmit.c:67

Definition at line 72 of file transmit.c.

◆ hid

int hid = (int)vh.i

Definition at line 36 of file transmit.c.

◆ m

Definition at line 40 of file transmit.c.

◆ n

int n = array_length(&vapdu)

Definition at line 51 of file transmit.c.

◆ OP_PCSC_TRANSMIT

case OP_PCSC_TRANSMIT

Definition at line 31 of file transmit.c.

◆ pio

SCARD_IO_REQUEST pio

Definition at line 67 of file transmit.c.

◆ rbuf

unsigned char rbuf[4096]

Definition at line 76 of file transmit.c.

◆ rlen

DWORD rlen = sizeof(rbuf)

Definition at line 77 of file transmit.c.

◆ rv

LONG rv = SCardTransmit(ce->h, &pio, sbuf, (DWORD)n, NULL, rbuf, &rlen)

Definition at line 78 of file transmit.c.

◆ sbuf

unsigned char sbuf[4096]

Definition at line 53 of file transmit.c.

◆ sw1

int sw1 = -1

Definition at line 80 of file transmit.c.

◆ sw2

int sw2 = -1

Definition at line 80 of file transmit.c.

◆ vh

Value vh = pop_value(vm)

Definition at line 35 of file transmit.c.