\doxysection{src/sim/reader\+\_\+pcsc.c File Reference}
\label{reader__pcsc_8c}\index{src/sim/reader\_pcsc.c@{src/sim/reader\_pcsc.c}}


PC/\+SC Card reader backend for libosmosim.  


{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/sim/sim.\+h$>$}\newline
{\ttfamily \#include $<$wintypes.\+h$>$}\newline
{\ttfamily \#include $<$winscard.\+h$>$}\newline
{\ttfamily \#include \char`\"{}sim\+\_\+int.\+h\char`\"{}}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ pcsc\+\_\+reader\+\_\+state}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ PCSC\+\_\+\+ERROR}(rv,  text)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \textbf{ pcsc\+\_\+get\+\_\+atr} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$card)
\item 
static struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$ \textbf{ pcsc\+\_\+reader\+\_\+open} (int num, const char $\ast$id, void $\ast$ctx)
\item 
static struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$ \textbf{ pcsc\+\_\+card\+\_\+open} (struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$rh, enum \textbf{ osim\+\_\+proto} proto)
\item 
static int \textbf{ pcsc\+\_\+card\+\_\+reset} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$card, bool cold\+\_\+reset)
\item 
static int \textbf{ pcsc\+\_\+card\+\_\+close} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$card)
\item 
static int \textbf{ pcsc\+\_\+transceive} (struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$rh, struct \textbf{ msgb} $\ast$msg)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const struct \textbf{ osim\+\_\+reader\+\_\+ops} \textbf{ pcsc\+\_\+reader\+\_\+ops}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
PC/\+SC Card reader backend for libosmosim. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{reader__pcsc_8c_a28c349a77de0ea8767431bd6ae3a7da0}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!PCSC\_ERROR@{PCSC\_ERROR}}
\index{PCSC\_ERROR@{PCSC\_ERROR}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{PCSC\_ERROR}
{\footnotesize\ttfamily \#define PCSC\+\_\+\+ERROR(\begin{DoxyParamCaption}\item[{}]{rv,  }\item[{}]{text }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{if} (rv != SCARD\_S\_SUCCESS) \{ \(\backslash\)}
\DoxyCodeLine{        fprintf(stderr, text \textcolor{stringliteral}{"{}: \%s (0x\%lX)\(\backslash\)n"{}}, pcsc\_stringify\_error(rv), rv); \(\backslash\)}
\DoxyCodeLine{        goto end; \(\backslash\)}
\DoxyCodeLine{\}}

\end{DoxyCode}


\doxysubsection{Function Documentation}
\mbox{\label{reader__pcsc_8c_af6794b3e5853447d559b757927392ae0}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!pcsc\_card\_close@{pcsc\_card\_close}}
\index{pcsc\_card\_close@{pcsc\_card\_close}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{pcsc\_card\_close()}
{\footnotesize\ttfamily static int pcsc\+\_\+card\+\_\+close (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{card }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ pcsc\+\_\+reader\+\_\+state\+::h\+Card}, \textbf{ PCSC\+\_\+\+ERROR}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::priv}, and \textbf{ osim\+\_\+card\+\_\+hdl\+::reader}.

\mbox{\label{reader__pcsc_8c_a671198215b07478331d3095ee228783c}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!pcsc\_card\_open@{pcsc\_card\_open}}
\index{pcsc\_card\_open@{pcsc\_card\_open}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{pcsc\_card\_open()}
{\footnotesize\ttfamily static struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$ pcsc\+\_\+card\+\_\+open (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$}]{rh,  }\item[{enum \textbf{ osim\+\_\+proto}}]{proto }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osim\+\_\+card\+\_\+hdl\+::apps}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::card}, \textbf{ osim\+\_\+chan\+\_\+hdl\+::card}, \textbf{ osim\+\_\+card\+\_\+hdl\+::channels}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::dw\+Active\+Protocol}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::h\+Card}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::h\+Context}, \textbf{ INIT\+\_\+\+LLIST\+\_\+\+HEAD}, \textbf{ osim\+\_\+chan\+\_\+hdl\+::list}, \textbf{ llist\+\_\+add()}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::name}, \textbf{ OSIM\+\_\+\+PROTO\+\_\+\+T0}, \textbf{ PCSC\+\_\+\+ERROR}, \textbf{ pcsc\+\_\+get\+\_\+atr()}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::pio\+Send\+Pci}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::priv}, and \textbf{ osim\+\_\+card\+\_\+hdl\+::reader}.

\mbox{\label{reader__pcsc_8c_a07db52c6142f99541b86d89c90dd35e3}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!pcsc\_card\_reset@{pcsc\_card\_reset}}
\index{pcsc\_card\_reset@{pcsc\_card\_reset}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{pcsc\_card\_reset()}
{\footnotesize\ttfamily static int pcsc\+\_\+card\+\_\+reset (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{card,  }\item[{bool}]{cold\+\_\+reset }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ pcsc\+\_\+reader\+\_\+state\+::dw\+Active\+Protocol}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::h\+Card}, \textbf{ PCSC\+\_\+\+ERROR}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::priv}, and \textbf{ osim\+\_\+card\+\_\+hdl\+::reader}.

\mbox{\label{reader__pcsc_8c_a5353218e621842cbd13ac8a109670bfc}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!pcsc\_get\_atr@{pcsc\_get\_atr}}
\index{pcsc\_get\_atr@{pcsc\_get\_atr}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{pcsc\_get\_atr()}
{\footnotesize\ttfamily static int pcsc\+\_\+get\+\_\+atr (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{card }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osim\+\_\+card\+\_\+hdl\+::atr}, \textbf{ osim\+\_\+card\+\_\+hdl\+::atr\+\_\+len}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::card}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::h\+Card}, \textbf{ PCSC\+\_\+\+ERROR}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::priv}, and \textbf{ osim\+\_\+card\+\_\+hdl\+::reader}.



Referenced by \textbf{ pcsc\+\_\+card\+\_\+open()}.

\mbox{\label{reader__pcsc_8c_a56a805d0d7beb4fc67a6922833085999}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!pcsc\_reader\_open@{pcsc\_reader\_open}}
\index{pcsc\_reader\_open@{pcsc\_reader\_open}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{pcsc\_reader\_open()}
{\footnotesize\ttfamily static struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$ pcsc\+\_\+reader\+\_\+open (\begin{DoxyParamCaption}\item[{int}]{num,  }\item[{const char $\ast$}]{id,  }\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ pcsc\+\_\+reader\+\_\+state\+::dw\+Active\+Protocol}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::h\+Context}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::name}, \textbf{ PCSC\+\_\+\+ERROR}, and \textbf{ osim\+\_\+reader\+\_\+hdl\+::priv}.

\mbox{\label{reader__pcsc_8c_a2844818e210c7c5345c2228c035cf839}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!pcsc\_transceive@{pcsc\_transceive}}
\index{pcsc\_transceive@{pcsc\_transceive}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{pcsc\_transceive()}
{\footnotesize\ttfamily static int pcsc\+\_\+transceive (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$}]{rh,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ msgb\+::data}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::h\+Card}, \textbf{ msgb\+\_\+apdu\+\_\+le}, \textbf{ msgb\+\_\+length()}, \textbf{ msgb\+\_\+put()}, \textbf{ msgb\+\_\+tailroom()}, \textbf{ PCSC\+\_\+\+ERROR}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::pio\+Recv\+Pci}, \textbf{ pcsc\+\_\+reader\+\_\+state\+::pio\+Send\+Pci}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::priv}, and \textbf{ msgb\+::tail}.



\doxysubsection{Variable Documentation}
\mbox{\label{reader__pcsc_8c_ab7f69b3b69ba8374a6fde6f6758da104}} 
\index{reader\_pcsc.c@{reader\_pcsc.c}!pcsc\_reader\_ops@{pcsc\_reader\_ops}}
\index{pcsc\_reader\_ops@{pcsc\_reader\_ops}!reader\_pcsc.c@{reader\_pcsc.c}}
\doxysubsubsection{pcsc\_reader\_ops}
{\footnotesize\ttfamily const struct \textbf{ osim\+\_\+reader\+\_\+ops} pcsc\+\_\+reader\+\_\+ops}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{        .name = \textcolor{stringliteral}{"{}PC/SC"{}},}
\DoxyCodeLine{        .reader\_open = pcsc\_reader\_open,}
\DoxyCodeLine{        .card\_open = pcsc\_card\_open,}
\DoxyCodeLine{        .card\_reset = pcsc\_card\_reset,}
\DoxyCodeLine{        .card\_close = pcsc\_card\_close,}
\DoxyCodeLine{        .transceive = pcsc\_transceive,}
\DoxyCodeLine{\}}

\end{DoxyCode}


Referenced by \textbf{ osim\+\_\+reader\+\_\+open()}.

