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

Implements the OP_PCSC_CONNECT 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 (vctx)
 free_value (vreader)
 if (!e||!rname)
 if (!hslot)
 free (rname)
 if (rv !=SCARD_S_SUCCESS)
 push_value (vm, make_int(hslot))

Variables

case OP_PCSC_CONNECT
Value vctx = pop_value(vm)
int ctx_id = (int)vctx.i
char * rname = value_to_string_alloc(&vreader)
pcsc_ctx_entrye = pcsc_get_ctx(ctx_id)
int hslot = pcsc_alloc_card_slot()
pcsc_card_entryce = pcsc_get_card(hslot)
DWORD dwActive = 0
LONG rv
ce proto = dwActive
 break

Detailed Description

Implements the OP_PCSC_CONNECT opcode (conditional build).

Connects to a smart card in the specified reader using an existing PC/SC context. On success, allocates/returns a card handle id from the internal registry. When PCSC support is disabled at build time, this opcode returns 0.

OP_PCSC_CONNECT: (ctx_id:int, reader_name:any) -> int

  • Pops: reader_name (converted to string), then ctx_id.
  • Pushes: card handle id (>0) on success; 0 on error/invalid inputs or when FUN_WITH_PCSC is disabled.
  • Notes: Uses SCARD_SHARE_SHARED and negotiates T0/T1 protocols.

Definition in file connect.c.

Function Documentation

◆ free()

free ( rname )

◆ free_value() [1/2]

free_value ( vctx )

◆ free_value() [2/2]

free_value ( vreader )

◆ if() [1/3]

if ( !e||! rname)

Definition at line 39 of file connect.c.

◆ if() [2/3]

if ( ! hslot)

Definition at line 46 of file connect.c.

◆ if() [3/3]

if ( rv ! = SCARD_S_SUCCESS)

Definition at line 57 of file connect.c.

◆ push_value()

push_value ( vm ,
make_int(hslot)  )

Variable Documentation

◆ break

break

Definition at line 71 of file connect.c.

◆ ce

Definition at line 51 of file connect.c.

◆ ctx_id

int ctx_id = (int)vctx.i

Definition at line 33 of file connect.c.

◆ dwActive

DWORD dwActive = 0

Definition at line 52 of file connect.c.

◆ e

Definition at line 38 of file connect.c.

◆ hslot

int hslot = pcsc_alloc_card_slot()

Definition at line 45 of file connect.c.

◆ OP_PCSC_CONNECT

case OP_PCSC_CONNECT

Definition at line 27 of file connect.c.

◆ proto

ce proto = dwActive

Definition at line 62 of file connect.c.

◆ rname

char* rname = value_to_string_alloc(&vreader)

Definition at line 35 of file connect.c.

◆ rv

LONG rv
Initial value:
= SCardConnect(e->ctx, rname, SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
&ce->h, &dwActive)
pcsc_card_entry * ce
Definition connect.c:51
char * rname
Definition connect.c:35
DWORD dwActive
Definition connect.c:52
pcsc_ctx_entry * e
Definition connect.c:38

Definition at line 53 of file connect.c.

◆ vctx

Value vctx = pop_value(vm)

Definition at line 31 of file connect.c.