# Manual for Libdatovka

libdatovka

3

libdatovka

ISDS client library

    #include <libdatovka/isds.h>
    #include <stdio.h>

    isds_error err;
    struct isds_ctx *ctx;

    err = isds_init();
    ctx = isds_ctx_create();

    err = isds_login(ctx, NULL, "username", "password", NULL, NULL);
    if (err) {
        printf("isds_login() failed: %s: %s\n",
            isds_strerror(err), isds_long_message(ctx));
    } else {
        printf("Logged in.\n");
    }

    err = isds_ctx_free(&ctx);
    err = isds_cleanup();

### Description

This is a client library for accessing SOAP services of ISDS (Informační systém datových schránek / Data Box Information System) as defined in Czech ISDS Act (300/2008 Coll.) and implied documents. Current implementation details are described in Provozní řád that can be downloaded from Dokumenty ke stažení section of ISDS Information Portal.

The library provides a C language interface with synchronous non-reentrant blocking calls. Network communication progress reporting and operation logging and library debugging are implemented by calling back application-provided functions. Network operations can be cancelled from network reporting call-back.

### Library Initialization and Deinitialization

A libdatovka application must include the `libdatovka/isds.h` header file. The application must call `isds_init` function to initialize the library before calling any other library functions. After last libdatovka call, `isds_cleanup` function should be called to clean up some global resources and to deinitialize dependent libraries.

### Contexts

Most of the functions operate on an established connection to the ISDS server. This is called a context and it's represented by a pointer to an opaque isds_ctx structure. The structure maintains state about network connection, authorization or error from last call on the context.

The context is allocated by `isds_ctx_create` function and deallocated by `isds_ctx_free` function.

There are more context subtypes. A specific subtype is assigned to the context when a fresh new context is passed to one of the few stratifying functions (`isds_login`, `czp_convert_document`, `isds_request_new_testing_box`). Once the context is specialized, you can use it only with functions understanding the subtype. This is not enforced by the library now, but it does not matter much because all the other functions assume the `isds_login` was called on the context. In other words, do not share the context among the three stratifying functions.

For example create a context with `isds_ctx_create`, then call `isds_login`, then work with box, then call `isds_logout`. Here you can reuse the context and log in as another user by calling `isds_login` again or destroy the context with `isds_ctx_free` if you don't need it anymore.

Or create a context with `isds_ctx_create`, send a document to authorized conversion using `czp_convert_document`, then you can send more documents to the authorized conversion by calling `czp_convert_document` again on the same context and finally destroy the context with `isds_ctx_free`.

### Errors

Most of the functions return an error code of `isds_error` type. IE_SUCCESS value denotes a successful call. Other values represent some kind of failure.

You can use `isds_strerror` function to obtain a human readable string representation of the error code.

If a function with context argument failed, you can use `isds_long_message` function to obtain a detailed error message. Please note that returned value lasts only to the next call on the context.

### Character Encoding

All strings exchanged between the library and the application are encoded in UTF-8. Although there are a few exceptions:

- `isds_strerror` and `isds_long_message` functions return locale encoded string.

- `isds_version` returns locale encoded string.

- Log call-back function set by `isds_set_log_callback` function is called with raw byte stream.

- isds_pki_credentials structure string members have encoding specific to cryptographic library linked to cURL library.

### Global Settings

Some functions influence library behaviour globally. These are:

- `isds_init` and `isds_cleanup` used to initialize and deinitialize the library.

- `isds_set_logging` and `isds_set_log_callback` to set logging.

### Logging and Debugging

Logging is global for all libdatovka calls. Log level and facility can be set with `isds_set_logging` function.

The log is printed on standard error output by default. Application can redirect the messages to a call-back function by registering the call-back function with `isds_set_log_callback`.

### Network Input/Output

Some functions operating on a context create network sockets and do network input and output.

Network timeout can be set with `isds_set_timeout` function. Function calls aborted owing to the timeout will return IE_TIMED_OUT.

Network operation progress can be monitored by a call-back function. The call-back function can be registered using `isds_set_xferinfo_callback` function. Registered call-back function will be called periodically with arguments declaring amount of transferred data. The call-back return value determines whether to continue in the network operation or to cancel the operation. Functions failed owing to cancelling network operation will return IE_ABORTED. The now deprecated call-back function `isds_set_progress_callback` behaves similarly but uses floating-point values to pass amounts of transferred data. Is is discouraged to use `isds_set_progress_callback` in new code.

### Memory management

The library provides destructors for all libdatovka data structures. For example `isds_ctx_free` function accepts a pointer to a pointer to the isds_ctx structure, frees the double referenced structure (recursively), writes NULL to the pointed pointer (which invalidates the pointer effectively) and returns nothing.

Upon a function call, all output arguments are automatically reallocated to desired size. On a function failure, all output arguments are automatically deallocated and their pointers set to NULL. Exceptions are documented at respective functions.

Output strings are allocated using standard `malloc` call. Application is responsible for their deallocation (in case of no failure and if not specified otherwise.) Use standard `free` call for strings, use libdatovka destructors for libdatovka structures.

### Available Functions, Types, and Constants

See `libdatovka/isds.h` header file.

### See Also

- isds.h.libdatovka

  3

- libcurl

  3

isds.h.libdatovka

3

isds.h.libdatovka

API definition for libdatovka

    #include <libdatovka/isds.h>

### Description

This header file declares interface for the libdatovka library.

### Constants

#### Service locators

Addresses of known ISDS servers.

##### Base URLs of production ISDS instance

###### `isds_locator`

    extern const char isds_locator[];

Without client certificate authentication.

###### `isds_cert_locator`

    extern const char isds_cert_locator[];

With client certificate authentication.

###### `isds_vodz_locator`

    extern const char isds_vodz_locator[];

High-volume data message locator without client certificate authentication.

###### `isds_vodz_cert_locator`

    extern const char isds_vodz_cert_locator[];

High-volume data message locator with client certificate authentication.

###### `isds_otp_locator`

    extern const char isds_otp_locator[];

With OTP authentication.

###### `isds_mep_locator`

    extern const char isds_mep_locator[];

With MEP authentication.

##### Base URLs of testing ISDS instance

###### `isds_testing_locator`

    extern const char isds_testing_locator[];

Without client certificate authentication.

###### `isds_cert_testing_locator`

    extern const char isds_cert_testing_locator[];

With client certificate authentication.

###### `isds_vodz_testing_locator`

    extern const char isds_vodz_testing_locator[];

High-volume data message locator without client certificate authentication.

###### `isds_vodz_cert_testing_locator`

    extern const char isds_vodz_cert_testing_locator[];

High-volume data message locator with client certificate authentication.

###### `isds_otp_testing_locator`

    extern const char isds_otp_testing_locator[];

With OTP authentication.

###### `isds_mep_testing_locator`

    extern const char isds_mep_testing_locator[];

With MEP authentication.

### Data types

#### struct isds_ctx

    struct isds_ctx;

Context for specific ISDS box.

#### `isds_error`

    typedef enum isds_error;

Error code. Known values:

IE_SUCCESS

- No error. Numeric value 0.

IE_ERROR

- Unspecified error.

IE_NOTSUP

- Operation is not supported.

IE_INVAL

- Invalid value.

IE_INVALID_CONTEXT

- The context is not valid.

IE_NOT_LOGGED_IN

- The context has not been logged in.

IE_CONNECTION_CLOSED

- Network connection has been closed.

IE_TIMED_OUT

- Time limit for network operation exceeded.

IE_NONEXIST

- Requested entity doesn't exist.

IE_NOMEM

- Not enough memory.

IE_NETWORK

- Network error.

IE_HTTP

- Error on HTTP level.

IE_SOAP

- Error on SOAP level.

IE_XML

- Error on XML level.

IE_ISDS

- Problem with ISDS server.

IE_ENUM

- Invalid enumeration value.

IE_DATE

- Invalid date value.

IE_TOO_BIG

- Value is too big.

IE_TOO_SMALL

- Value is too small.

IE_NOTUNIQ

- Value is not unique.

IE_NOTEQUAL

- Compared values are not equal.

IE_PARTIAL_SUCCESS

- Operation on a vector succeeded for some values but failed for others.

IE_ABORTED

- Operation was aborted by application request.

IE_SECURITY

- Security requirements were not satisfied.

#### `isds_log_level`

    typedef enum isds_log_level;

Log level. Know values:

`ILL_NONE`

- 0

`ILL_CRIT`

- 10

`ILL_ERR`

- 20

`ILL_WARNING`

- 30

`ILL_INFO`

- 40

`ILL_DEBUG`

- 50

`ILL_ALL`

- 100

#### `isds_log_facility`

    typedef enum isds_log_facility;

Log facility. Know values:

`ILF_NONE`

- 0x0

`ILF_HTTP`

- 0x1

`ILF_SOAP`

- 0x2

`ILF_ISDS`

- 0x4

`ILF_FILE`

- 0x8

`ILF_SEC`

- 0x10

`ILF_XML`

- 0x20

`ILF_ALL`

- 0xFF

#### `isds_option`

    typedef enum isds_option;

libdatovka option identifiers. Known values:

`IOPT_TLS_VERIFY_SERVER`

- Option type is `_Bool`. Whether to verify server identity. Default value is true.

`IOPT_TLS_CA_FILE`

- Option type is `char *`. Option value is a file name with certificate authority certificates. Default value depends on used cryptographic library.

`IOPT_TLS_CA_DIRECTORY`

- Option type is `char *`, Option value is a directory with certificate authority certificates. Default value depends on used cryptographic library.

`IOPT_TLS_CRL_FILE`

- Option type is `char *`. Option value is a file name with certificat revocation list in PEM format. Default value depends on used cryptographic library.

`IOPT_NORMALIZE_MIME_TYPE`

- Optiona type is `_Bool`. Whether to normalize MIME type values. Default value is false.

#### `isds_tls_option`

    typedef enum isds_tls_option;

This type is deprecated.

TLS libdatovka option identifiers. Known values:

`ITLS_VERIFY_SERVER`

- Option type is `_Bool`. Whether to verify server identity.

`ITLS_CA_FILE`

- Option type is `char *`. Option value is a file name with certificate authority certificates.

`ITLS_CA_DIRECTORY`

- Option type is `char *`. Option value is a directory name with certificate authority certificates.

`ITLS_CRL_FILE`

- Option type is `char *`. Option value is a file name with certificate revocation list in PEM format.

#### `isds_pki_format`

    typedef enum isds_pki_format;

Cryptographic material encoding. Known values:

`PKI_FORMAT_PEM`

- PEM format.

`PKI_FORMAT_DER`

- DER format.

`PKI_FORMAT_ENG`

- The material is stored in a cryptographic engine.

#### struct isds_pki_credentials

    struct isds_pki_credentials;

This structure holds public key infrastructure cryptographic material to authenticate a client. Members are:

`char *`engine;

- String identifier of cryptographic engine to use (where key is stored). Use NULL for no engine.

`isds_pki_format` certificate_format;

- Certificate format.

`char *`certificate;

- A path to client certificate, or a certificate nickname in case of NSS as curl back-end, or key slot identifier inside cryptographic engine. Some cryptographic engines can pair certificate with key automatically (NULL value).

`isds_pki_format` key_format;

- Private key format.

`char *`key;

- A path to client private key, or key identifier in case an engine is used.

`char *`passphrase;

- Zero terminated string with password for decrypting private key, or engine PIN. Use NULL for no pass-phrase or to let the engine to ask for it.

#### `isds_otp_method`

    typedef enum isds_otp_method;

One-time password authentication method. Known values:

`OTP_HMAC`

- HMAC-based OTP method.

`OTP_TIME`

- Time-based OTP method.

#### `isds_otp_resolution`

    typedef enum isds_otp_resolution;

One-time password authentication resolution. Known values:

`OTP_RESOLUTION_SUCCESS`

- Authentication succeeded.

`OTP_RESOLUTION_UNKNOWN`

- Status is unknown.

`OTP_RESOLUTION_BAD_AUTHENTICATION`

- Bad log-in. You can retry to log in.

`OTP_RESOLUTION_ACCESS_BLOCKED`

- Access blocked for 60 minutes. (Because a brute force attack was detected.)

`OTP_RESOLUTION_PASSWORD_EXPIRED`

- Password has expired.

  It's not clear which password expired: OTP or regular password?

`OTP_RESOLUTION_TOO_FAST`

- OTP cannot be sent repeatedly at this rate. (Minimal delay depends on TOTP window setting.)

`OTP_RESOLUTION_UNAUTHORIZED`

- User name is not allowed to access requested URI.

`OTP_RESOLUTION_TOTP_SENT`

- OTP has been generated and sent by the ISDS to the user.

`OTP_RESOLUTION_TOTP_NOT_SENT`

- OTP could not been sent by the ISDS. Retry later.

#### struct isds_otp

    struct isds_otp;

This structure holds one-time password when authenticating a client and resolution of the authentication.

Input members are:

`isds_otp_method` method;

- Select OTP method to use.

`char *`otp_code;

- One-time password to use. Pass NULL, if you do not know it yet (e.g. in case of first phase of time-based OTP authentication to request new code from ISDS.)

Output members are:

`isds_otp_resolution` resolution;

- Fine-grade resolution of this OTP authentication attempt.

#### `isds_DbType`

    typedef enum isds_DbType;

Box type. It classifies box owner by his legal status. Known values:

`DBTYPE_OVM_MAIN`

- This is a special value for `isds_find_box_by_fulltext`. It's not accepted by any other services.

`DBTYPE_SYSTEM`

- This is a special value for sender of messages sent by the ISDS. You can find it only in incoming messages. It's not accepted by any other services.

`DBTYPE_OVM`

- Standard government (state or municipality or similar) office.

`DBTYPE_OVM_NOTAR`

- Notary (stopped being used, replaced with OVM_PFO).

`DBTYPE_OVM_EXEKUT`

- Executor (stopped being used, replaced with OVM_PFO).

`DBTYPE_OVM_REQ`

- Subsidiary office with OVM (governing) status assigned on request (section 6 and 7 of the act).

`DBTYPE_OVM_FO`

- Natural person with OVM status (without identification number).

`DBTYPE_OVM_PFO`

- Natural person in business with OVM status (e.g. notary or executor).

`DBTYPE_OVM_PO`

- Juridical person with OVM status (arisen from previously existing PO or PO_REQ).

`DBTYPE_PO`

- Standard commercial organization (listed in trade registry).

`DBTYPE_PO_ZAK`

- Other organization founded by an act (stopped being used, replaced with PO).

`DBTYPE_PO_REQ`

- An organization with a box assigned on its request.

`DBTYPE_PFO`

- Person in business.

`DBTYPE_PFO_ADVOK`

- Lawyer.

`DBTYPE_PFO_DANPOR`

- Tax consultant.

`DBTYPE_PFO_INSSPR`

- Administrator of insolvency (stopped being used, replaced with OVM_PFO).

`DBTYPE_PFO_AUDITOR`

- Statutory auditor.

`DBTYPE_PFO_ZNALEC`

- Expert witness.

`DBTYPE_PFO_TLUMOCNIK`

- Sworn translator.

`DBTYPE_PFO_ARCH`

- Architect.

`DBTYPE_PFO_AIAT`

- Authorised engineer / technician.

`DBTYPE_PFO_AZI`

- Authorised geodetics engineer.

`DBTYPE_PFO_REQ`

- Person in business on its request.

`DBTYPE_FO`

- Standard person.

Some interfaces refer to gross box type. These are the shortest names of the identifiers. For example, `DBTYPE_OVM` is a gross type for `DB_OVM_NOTAR` or `DBTYPE_OVM`. But not for `DBTYPE_PO`.

#### `isds_DbState`

    typedef enum isds_DbState;

Box status from point of view of accessibility. Known values:

`DBSTATE_ACCESSIBLE`

- The box is accessible.

`DBSTATE_TEMP_INACCESSIBLE`

- The box is temporarily inaccessible (at the request of the user).

`DBSTATE_NOT_YET_ACCESSIBLE`

- The box has not yet been activated.

`DBSTATE_PERM_INACCESSIBLE`

- The box is permanently inaccessible.

`DBSTATE_REMOVED`

- The box has been removed.

`DBSTATE_TEMP_INACCESSIBLE_LAW`

- The box is temporarily inaccessible (because of the reasons enumerated in the law).

#### `isds_privileges`

    typedef enum isds_privileges;

Distinct user permissions from point of view of ISDS. Instances can be bitmaps of any of these distinct values. Distinct known values are:

`PRIVIL_READ_NON_PERSONAL`

- The user can download and read messages with dmPersonalDelivery equal to false.

`PRIVIL_READ_ALL`

- The user can download and read messages with dmPersonalDelivery equal to true.

`PRIVIL_CREATE_DM`

- The user can create and send messages, the user can download outgoing (sent) messages.

`PRIVIL_VIEW_INFO`

- The user can list messages and read data about a message post and delivery.

`PRIVIL_SEARCH_DB`

- The user can can search for boxes.

`PRIVIL_OWNER_ADM`

- The user can administer his box (to add and remove permitted users and to modify theirs permissions.)

`PRIVIL_READ_VAULT`

- The user can read messages stored in the long term storage.

  This permission is not used since 2012-05.

`PRIVIL_ERASE_VAULT`

- The user can delete messages from the long term storage.

#### `enum isds_message_status`

    typedef enum isds_message_status isds_message_status;

Message status. Known values are:

`MESSAGESTATE_SENT`

- The message has been put into ISDS.

`MESSAGESTATE_STAMPED`

- Message was stamped by a time stamp authority.

`MESSAGESTATE_INFECTED`

- The message included viruses. Infected documents have been removed from the message.

`MESSAGESTATE_DELIVERED`

- The message was delivered. (dmDeliveryTime is populated.)

`MESSAGESTATE_SUBSTITUTED`

- The message was delivered through fiction, dmAcceptanceTime is populated.

`MESSAGESTATE_RECEIVED`

- The message was accepted (by user's log-in or user's explicit request). dmAcceptanceTime is populated.

`MESSAGESTATE_READ`

- The message has been read by a user.

`MESSAGESTATE_UNDELIVERABLE`

- The message could not been delivered. (E.g.The recipient's box has been made inaccessible meantime.)

`MESSAGESTATE_REMOVED`

- The message's content was deleted.

`MESSAGESTATE_IN_VAULT`

- The message is stored in the long term storage.

The values can be combined into a bit mask for some functions. A special `MESSAGESTATE_ANY` macro denotes any of the states.

#### `isds_hash_algorithm`

    typedef enum isds_hash_algorithm;

Hash algorithm types. Known values are:

`HASH_ALGORITHM_MD5`

- MD5.

`HASH_ALGORITHM_SHA_1`

- SHA-1.

`HASH_ALGORITHM_SHA_224`

- SHA-224.

`HASH_ALGORITHM_SHA_256`

- SHA-256.

`HASH_ALGORITHM_SHA_384`

- SHA-384.

`HASH_ALGORITHM_SHA_512`

- SHA-256.

#### `isds_buffer_strategy`

    typedef enum isds_buffer_strategy;

Buffer storage strategy. This type defines how a function should embed application provided buffer into raw element of output structure. Known values are:

`BUFFER_DONT_STORE`

- Don't fill raw member.

`BUFFER_COPY`

- Copy buffer content into newly allocated raw member.

`BUFFER_MOVE`

- Copy pointer. Leave deallocation to structure destructor (`isds_*_free`()).

#### struct isds_hash

    struct isds_hash;

This is a hash value storage. Members are:

`isds_hash_algorithm` algorithm;

- Hash algorithm.

`size_t` length;

- Hash value length in bytes.

`void *`value;

- Hash value as a byte stream.

#### struct isds_PersonName

    struct isds_PersonName;

Name of a person. Members are:

`char *`pnFirstName;

- First name.

`char *`pnMiddleName;

- Middle name.

`char *`pnLastName;

- Current last name.

`char *`pnLastNameAtBirth;

- Last name at birth.

#### struct isds_BirthInfo

    struct isds_BirthInfo;

Date and place of a birth. Members are:

`struct tm *`biDate;

- Date of birth in local time at the birth place. Only tm_year, tm_mon and tm_mday members of the `struct tm` carry sane value. Others are undefined.

`char *`biCity;

- City where a person was born.

`char *`biCounty;

- Region where a person was born. This is the kind of region that is called Bezirk in German and okres in Czech.

`char *`biState;

- State wher a person was born.

#### struct isds_Address

    struct isds_Address;

Postal address. Members are:

`char *`adCity;

- City.

`char *`adStreet;

- Street.

`char *`adNumberInStreet;

- Identification of an entrance on the street. Číslo orientační in Czech.

`char *`adNumberInMunicipality;

- Identification of a building in the municipality. Číslo popisné in Czech.

`char *`adZipCode;

- Postal code for mail routing.

`char *`adState;

- State.

#### struct isds_DbOwnerInfo

    struct isds_DbOwnerInfo;

Data about a box and his owner. NULL pointer values mean undefined values. Members are:

`char *`dbID;

- Box identifier. Specification limits the length to 7 characters.

`isds_DbType *`dbType;

- Box type.

`char *`ic;

- Identifier of the owner.

`isds_PersonName *`personName;

- Name of a person owning the box.

`char *`firmName;

- Name of a firm owning the box.

`isds_BirthInfo *`birthInfo;

- Birth details of the person.

`isds_Address *`address;

- Postal address of the owner.

`char *`nationality;

- Nationality of the owner.

`char *`email;

- E-mail addres of the owner.

`char *`telNumber;

- Telephone number of the owner.

`char *`identifier;

- External box identifier for data provider (OVM, PO, maybe PFO box types.) Specification limits the length to 20 characters.

`char *`registryCode;

- PFO external registry code. Specification limits the length to 5 characters.

`long int *`dbState;

- Box state. 1 means the box is active.

  The type is long int because specification declares it as `xsd:integer`.

  TODO: enum?

`_Bool *`dbEffectiveOVM;

- The Box has OVM role (section 5a of the act).

`_Bool *`dbOpenAddressing;

- This

  non-OVM box is free to receive messages from anybody.

#### `isds_UserType`

    typedef enum isds_UserType;

User type. Known values are:

`USERTYPE_PRIMARY`

- Owner of the box.

`USERTYPE_ENTRUSTED`

- User with limited access to the box.

`USERTYPE_ADMINISTRATOR`

- User who can manage `USERTYPE_ENTRUSTED` users.

`USERTYPE_OFFICIAL`

- ???

`USERTYPE_OFFICIAL_CERT`

- ???

`USERTYPE_LIQUIDATOR`

- Company liquidator.

`USERTYPE_RECEIVER`

- Company receiver.

`USERTYPE_GUARDIAN`

- Legal guardian.

#### struct isds_DbUserInfo

    struct isds_DbUserInfo;

Data about a user. NULL pointer values mean undefined values. Members are:

`char *`userID;

- User identifier. Specification limits the length from 6 to 12 characters.

`isds_UserType *`userType;

- User type.

`long int *`userPrivils;

- Set of user permissions.

`isds_PersonName *`personName;

- Name of the user.

`isds_Address *`address;

- Postal address of the user.

`struct tm *`biDate;

- Date of birth in local time. Only tm_year, tm_mon and tm_mday members of the `struct tm` carry sane value. Others are undefined.

`char *`ic;

- Identifier a supervising firm. Specification limits the length to 8 characters.

`char *`firmName;

- Name of a supervising firm. Specification limits the length to 100 characters.

`char *`caStreet;

- Contact address. Street and number.

`char *`caCity;

- Czech city of the contact address.

`char *`caZipCode;

- Postal code of the contact address.

`char *`caState;

- Abbreviated country of contact address. This value is optional and implicit meaning is `CZ`.

#### `isds_event_type`

    typedef enum isds_event_type;

Message event type. Known values are:

`EVENT_UNKNOWN`

- Event unknown to this library.

`EVENT_ACCEPTED_BY_RECIPIENT`

- Message has been delivered and accepted by recipient action.

`EVENT_ACCEPTED_BY_FICTION`

- Message has been delivered, acceptance period timed out, the message is considered accepted.

`EVENT_ACCEPTED_BY_FICTION_NO_USER`

- Message has been delivered, acceptance period timed out because there was no user who could accept the message.

`EVENT_UNDELIVERABLE`

- Recipient box was made inaccessible, thus the message is undeliverable.

`EVENT_COMMERCIAL_ACCEPTED`

- Recipient confirmed acceptance of this commercial message.

`EVENT_ENTERED_SYSTEM`

- The message entered the ISDSsystem, i.e. it has been just sent by a sender.

`EVENT_DELIVERED`

- The message has been delivered into recipient's box.

`EVENT_PRIMARY_LOGIN`

- Primary user logged into recipient's box.

`EVENT_ENTRUSTED_LOGIN`

- Entrusted user with capability to read logged into recipient's box.

`EVENT_SYSCERT_LOGIN`

- An application authenticated by system certificate logged into recipient's box.

#### struct isds_event

    struct isds_event;

An event that happened in a message life. All members are optional. Members are:

`struct isds_timeval *`time;

- When the event occurred.

`isds_event_type *`type;

- Type of the event.

`char *`description;

- Human-readable event description generated by the ISDS system. (Very probably in Czech language).

#### `enum isds_IdLevel_value`

    enum isds_IdLevel_value;

Specifies which information the sender of a data message wants to publish about his person.

`PUBLISH_USERTYPE`

- Publish information about the sender type. This information is always revealed to the recipient.

`PUBLISH_PERSONNAME`

- Publish sender's personal name.

`PUBLISH_BIDATE`

- Publish sender's birth date.

`PUBLISH_BICITY`

- Publish sender's birth city. This information is available only when sender is SENDERTYPE_ENTRUSTED of a FO or PFO box.

`PUBLISH_BICOUNTY`

- Publish sender's birth county. This information is available only when sender is SENDERTYPE_ENTRUSTED of a FO or PFO box.

`PUBLISH_ADCODE`

- Publish sender's RUIAN address code.

`PUBLISH_FULLADDRESS`

- Publish sender's full address.

`PUBLISH_ROBIDENT`

- Publish information whether sender is identified within the ROB.

#### struct isds_envelope

    struct isds_envelope;

Message envelope. These are the metadata about a message. It does contain the message documents.

Be ware that the string length constraints are forced only on output members transmitted to the ISDS. The other direction (downloading from the ISDS) can break these rules. It should not happen, but nobody knows how much incompatible new version of the ISDS protocol will be. This is the gold Internet rule: be strict on what you send, be tolerant on what you receive.

Following members apply to incoming messages only:

`char *`dmID;

- Message identifier. Maximal length is 20 characters.

`char *`dbIDSender;

- Box identifier of the sender. Special value `aaaaaaa` means the message was sent by the ISDS system. Not by another user. Maximal length is 7 characters.

`char *`dmSender;

- Sender's name. Maximal length is 100 characters.

`char *`dmSenderAddress;

- Postal address of the sender. Maximal length is 100 characters.

`long int *`dmSenderType;

- Gross box type of the sender. You can use `isds_DbType` to enumerate some known box types. This is a generic integer because the protocol keeps the value unconstrained and the library must support any syntactically correct value.

`char *`dmRecipient;

- Recipient's name. Maximal length is 100 characters.

`char *`dmRecipientAddress;

- Postal address of the recipient. Maximal length is 100 characters.

`_Bool *`dmAmbiguousRecipient;

- The recipient has OVM role.

Following members are assigned by the ISDS in different phases of message life cycle:

`unsigned long int *`dmOrdinal;

- Ordinal number in list of incoming/outgoing messages.

`enum isds_message_status *`dmMessageStatus;

- Message state.

`long int *`dmAttachmentSize;

- Size of message documents in kilobytes. The value is rounded.

`struct isds_timeval *`dmDeliveryTime;

- The time of delivering the message into recipient's box. It will be `NULL`, if the message has not been delivered yet.

`struct isds_timeval *`dmAcceptanceTime;

- The time of accepting the message by the recipient. It will be `NULL`, if message has not been accepted yet.

`struct isds_hash *`hash;

- The message digest. This is a hash of a substring representing `isds:dmDM` XML subtree. You can use `isds_compute_message_hash` function to compute a hash of the message and then compare it against this structure member using `isds_hash_cmp` function.

`void *`timestamp;

- This is a binary image of a qualified time stamp of the hash value. The time stamp is provided by the ISDS system. Messages that have not yet been stamped will have this value `NULL`.

`size_t` timestamp_length;

- Length of the timestamp value in bytes.

`struct isds_list *`events;

- Events the message passed trough. It's a list of `isds_event` structures.

Following members apply to both outgoing and incoming messages:

`char *`dmSenderOrgUnit;

- Sender's organisation unit as a string. This is optional.

`long int *`dmSenderOrgUnitNum;

- Sender's organisation unit as a number. This is optional.

`char *`dbIDRecipient;

- Recipient's box identifier. This is mandatory. Maximal length is 7 characters.

`char *`dmRecipientOrgUnit;

- Recipient's organisation unit as a string. This is optional.

`long int *`dmRecipientOrgUnitNum;

- Recipient's organisation unit of as a number. This is optional.

`char *`dmToHands;

- A person in recipient's organisation. This is optional.

`char *`dmAnnotation;

- A subject (title) of the message. Maximal length is 255 characters.

`char *`dmRecipientRefNumber;

- Czech: číslo jednací příjemce. This is optional. Maximal length is 50 characters.

`char *`dmSenderRefNumber;

- Czech: číslo jednací odesílatele. This is optional. Maximal length is 50 chars.

`char *`dmRecipientIdent;

- Czech: spisová značka příjemce. This is optional. Maximal length is 50 characters.

`char *`dmSenderIdent;

- Czech: spisová značka odesílatele This is optional. Maximal length is 50 chars.

Following five members constitute a reference to an item from the Czech Act Collection. The human-readable reference looks like Point (Paragraph) § Section Law/Year Coll. The members apply to both incoming and outgoing messages:

`long int *`dmLegalTitleLaw;

- A number of an act mandating the authority.

`long int *`dmLegalTitleYear;

- A year of issuing the act mandating the authority.

`char *`dmLegalTitleSect;

- A section of the act mandating the authority. Czech: paragraf.

`char *`dmLegalTitlePar;

- A paragraph of the act mandating the authority. Czech: odstavec.

`char *`dmLegalTitlePoint;

- A point of the act mandating the authority. Czech: písmeno.

Other incoming/outgoing message members:

`_Bool *`dmPersonalDelivery;

- If true, only person with higher privileges can read this message.

`_Bool *`dmAllowSubstDelivery;

- Allow delivery through fiction. I.e. Even if the recipient did not read this message, the message is considered as delivered after (currently) 10 days. This is called delivery through fiction. Only OVM dbType sender can set it.

`char *`dmType;

- Message type (commercial subtypes or government message).

  Input values (when sending the message):

  `"I"`

- A commercial message offering paying the response (initiatory message). It's necessary to define dmSenderRefNumber member.

`"K"`

- A commercial message paid by the sender.

`"O"`

- A commercial response paid by the sender of a initiatory message. It's necessary to copy a value from the dmSenderRefNumber of the initiatory message to the dmRecipientRefNumber of this message.

`"V"`

- A non-commercial government message. This is the default meaning if the value is undefined while sending a message.

Output values (when retrieving the message):

`"A"`

- This is a subsidized initiatory commercial message which can pay a response.

`"B"`

- This is a subsidized initiatory commercial message which has already paid the response.

`"C"`

- This is a subsidized initiatory commercial message where the response offer has expired.

`"D"`

- This is an externally subsidized commercial message.

`"E"`

- This is a commercial message prepaid by a stamp.

`"G"`

- This is a commercial message paid by a sponsor.

`"I"`

- See the input values.

`"K"`

- See the input values.

`"O"`

- See the input values.

`"V"`

- See the input values.

`"X"`

- This is an initiatory commercial message where the response offer has expired.

`"Y"`

- This is an initiatory commercial message which has already paid the response.

`"Z"`

- This is limitedly subsidized commercial message.

Length of the value is exactly 1 UTF-8 character if defined. That means it's still zero-terminated character string.

`_Bool *`dmVODZ;

- Set to true when downloading lists of sent or received messages and a particular message is a high-volume data message.

`long int *`attsNum;

- Set to number of attachments when downloading lists of sent or received messages and a particular message is a high-volume data message.

Following members apply to outgoing messages only:

`_Bool *`dmOVM;

- OVM sending mode. Non-OVM dbType boxes that have dbEffectiveOVM equal to true MUST select between true (OVM mode) and false (non-OVM mode). Otherwise the value is optional and the default value is true.

`_Bool *`dmPublishOwnID;

- To allow to reveal sender's login name. The name will be available to the recipient through `isds_get_message_sender` function. The sender's box type and identifier will be always available. This feature exists because more users can have access to one box and the recipient could not tell who was the sender. This value is optional. Default value is false.

`int *`idLevel;

- Specifies which personal information about the sender should be revealed to the recipient. All specified information can be acquired by the recipient by using the `isds_GetMessageAuthor2` function. The sender's box type and identifier will always be available. The value of dmPublishOwnID MUST be set to true in order to specify which additional information the sender wants to disclose. The actual value of the idLevel is the sum of actual `enum isds_IdLevel_value` values.

#### `isds_FileMetaType`

    typedef enum isds_FileMetaType;

Document type from point of view of hierarchy of documents in a message. Known values are:

`FILEMETATYPE_MAIN`

- Main document. There should be exactly one document of this type in a message.

`FILEMETATYPE_ENCLOSURE`

- An appendix. If a message has more documents, generic-purpose documents other than the main one should have this type.

`FILEMETATYPE_SIGNATURE`

- Digital signature. This document is a signature of another document in the message.

`FILEMETATYPE_META`

- XML document for electronic document information system, elektronická spisová služba (ESS) in Czech, purpose.

#### struct isds_document

    struct isds_document;

A message document. Members are:

`_Bool` is_xml;

- True if the document is an ISDS XML document. False if the document is an ISDS binary document.

`xmlNodePtr` xml_node_list;

- XML node-set presenting the XML document content. This is a pointer to first XML node of the XML representation of the message as stored in xml member of `isds_message` structure. Use children and next members to walk through the document. See `libxml2` library documentation for more details. The xml_node_list will be `NULL` if the document is empty. It's valid only if the is_xml is true.

`void *`data;

- A binary document content. The encoding and format depends on dmMimeType member value. This is valid only if the is_xml is false.

`size_t` data_length;

- Length of the data buffer in bytes. It's valid only if the is_xml is false.

`char *`dmMimeType;

- MIME type of document. This member is mandatory.

`isds_FileMetaType` dmFileMetaType;

- Document type to create document hierarchy inside a message.

`char *`dmFileGuid;

- Message-local document identifier. It can be used as a key to refer to this document by dmUpFileGuid member from a different document. This is optional.

`char *`dmUpFileGuid;

- A reference to upper document identifier stored in dmFileGuid member of different document. You can use `isds_find_document_by_id` function to locate the upper document. This value is optional.

`char *`dmFileDescr;

- Document name (title). E.g. a file name. This value is mandatory.

`char *`dmFormat;

- A reference to XML format definition that explains how to interpret the XML document. E.g. a URL to an XML schema. This value is optional.

#### struct isds_box_state_period

    struct isds_box_state_period;

A box state valid in the time range. Members are:

`struct isds_timeval *`from;

- Time range beginning.

`struct isds_timeval *`to;

- Time range end.

`long int` dbState;

- Box state. `1` means the box is accessible. Other values mean the box is inaccessible. You can use `isds_DbState` enum to identify some states.

#### struct isds_dmMessageAuthor

    struct isds_dmMessageAuthor;

Response for GetMessageAuthor2. Members are:

`isds_sender_type *`userType;

- Message sender type.

`struct isds_PersonName2 *`personName;

- Contains pnGivenNames and pnLastName.

`struct tm *`biDate;

- Date of birth in local time at birth place, only tm_year, tm_mon and tm_mday carry sane value.

`char *`biCity;

- City of birth.

`char *`biCounty;

- County of birth (German: Bezirk, Czech: okres).

`char *`adCode;

- RUIAN address code.

`char *`fullAddress;

- Full address.

`_Bool *`robIdent;

- Flag whether the person is identifiers within the ROB.

#### `enum isds_message_type`

    typedef enum isds_message_type isds_message_type;

Specifies the direction of the message - whether the message is received or sent:

`MESSAGE_TYPE_RECEIVED`

- Specifies a received message.

`MESSAGE_TYPE_SENT`

- Specifies a sent message.

#### `enum isds_data_format`

    typedef enum isds_data_format isds_data_format;

Specifies data format:

`FORMAT_XML`

- Data in XML format.

`FORMAT_CSV`

- Data in CSV format.

#### `enum isds_asyncReqType`

    typedef enum isds_asyncReqType isds_asyncReqType;

Specifies synchronous request type:

`ASYNC_REQ_TYPE_LIST_ERASED`

- Response for the GetListOfErasedMessages request.

#### struct isds_erased_message

    struct isds_erased_message;

Describes entries in the lists of erased messages. Members are:

`char *`dmID;

- Message ID.

`char *`dbIDSender;

- Box ID of sender.

`char *`dmSender;

- Sender name.

`char *`dbIDRecipient;

- Box ID of recipient.

`char *`dmRecipient;

- Recipient name.

`char *`dmAnnotation;

- Subject (title) of the message.

`enum isds_message_status *`dmMessageStatus;

- Message state.

`struct isds_timeval *`dmDeliveryTime;

- Time of delivery into a box.

`struct isds_timeval *`dmAcceptanceTime;

- Time of acceptance of the message by a user.

`char *`dmType;

- Message type.

### Functions

-                   const char *isds_strerror
                    const isds_error error

-               struct isds_ctx *isds_ctx_create

### See Also

- libcurl

  3

- libdatovka

  3

- time.h

  0p