FilesTools – OpenCT

# Files and Tools in OpenCT

OpenCT needs a config file. It is recommended to configure openct with "--sysconfdir=/etc" so the usual name is /etc/openct.conf.

OpenCT needs a directory -- /var/run/openct -- for it's files and sockets. During bootup OpenCT will create the file -- /var/run/openct/status -- for coordination of all tools. For each reader there will be a process called "ifdhandler" and a socket in this directory, the name for the first reader is usualy "0", for the second "1" and so on.

If the environment variable OPENCT_SOCKETDIR is set, that directory will be used instead of /var/run/openct. On Solaris the files are placed in UTDEVROOT/openct/ directory if the environment variable UTDEVROOT is set.

OpenCT needs an init.d script to be run at bootup and at shutdown. The script is usualy called /etc/init.d/openct and there are symlinks in the /etc/rc*.d/ directories pointing to it.

On linux systems with hotplugging, OpenCT also has these files:

- /etc/hotplug/usb/openct.usermap -- tells the hotplug system which devices OpenCT knows about.
- /etc/hotplug/usb/openct -- script called by hotplug for each device added or removed.

Recently some linux distribution changed the tool for hotplug event handling from "hotplug" shell scripts towards udev or hald. Hald is suggested by some developers, but there is not enough documentation so we don't know how to use it. Also hald seems to miss some features hotplug and udev have. Using udev is supported by OpenCT. You will need these files:

- /etc/udev/rules.d/95-openct.rules -- tells udev which devices OpenCT knows about and to run
- /etc/hotplug/usb/openct -- script run by udev for each device added or remove.

The hotplug script is a generic script that works in both situations without changes.

OpenCT is shipped with these tools:

- openct-tool -- lists all readers, their names, the atr, waits for a reader or card etc. great for debugging.
- openct-control -- usualy only called by the init.d script on boot and shutdown
- ifdhandler -- does all the work in the background, called by openct-control or the hotplug script.

OpenCT is shipped with two plugins/drivers/shared objects:

- libopenctapi.so -- a shared object in CT-API format, you can use this with every ct-api aware application.
- openct-ifd.so -- a shared object in Ifdhandler v2 format, to be used by pcsc-lite as reader.

## Shared library

If you want to write an application to use openct directly, you can do so using the shared library libopenct.so. OpenCT also has header files for you in $(prefix)/include/openct/ and it comes with a pkg-config file "libopenct.pc", see the pkg-config documentation how to use it in your Makefile or autoconf configure.in file. This should make linking with OpenCT easy, please send us some feedback.