• No results found

card_parse()

card_parse()

Accepts data from the card reader and parses it to the selected track data.

Prototype #include <acldev.h>

int card_parse(char *track, struct TRACK *parsed, char *order);

Parameters

Return Values

The individual tracks returned from read() are formatted as:

[C][S][track data]

where,

[C] is a single byte representing the length of the string containing the track data, including the count byte.

[S] is a one byte status of the read for the track.

[track data] is the complete track read of the track (if available). This field is omitted for tracks not available on the terminal; however, the count byte and status are provided for all three tracks.

Three of these fields are read from the card device regardless of how many physical tracks are read by the terminal. The tracks appear in order from track 1 to track 3, for example,

[C1][S1][track1][C2][S2][track2][C3][S3][track3] track Card reader data.

parsed Parsed output. order Track selection order.

Success: 1,2,3: Track number that was read (successful).

Failure: TK_NOT_FOUND (-1): None of the tracks specified in order contained a valid data status byte.

INVLD_ORDER (-2): The order contains a character that is not 1, 2, or 3. BAD_READ (-3): An attempt to parse a track field in the card read data fails.

INVLD_FORMAT (-4): Invalid format.

ACT_FRAMING_ERROR (-6): Track status byte from card read is 2, 3, or 4. Parsed track is still stored in structure TRACK, and errno contains the parsed track.

FUNCTION CALLS card_parse()

The supported tracks comply with standard specifications as follows:

Track 1 format IATA track 1 format consisting of a maximum of 79 alphanumeric characters. The track format is:

[ss][fc][PAN][fs][name][fs][other][es][lrc] where,

[ss] Start sentinel of “%” (0x25) [fc]: one-byte format code. [PAN] Primary account number; maximum 19 digits.

[fs] Field separator of “{” (0x7B) [name]: Name of the card holder; maximum 26 characters

[other] Can contain the following: 4-digit expiration datea 3-byte restriction or typea 5-byte offset of PVNa

16 bytes of discretionary data

a. Required by VISA and MasterCard Track 2 format.

[es] End sentinel of “?” (0x3F).

[lrc] 1-byte longitudinal redundancy check value Track 2 format ABA track 2 format consists of a maximum of 40 numeric

characters. The track format is: [ss][PAN][fs][other][es][lrc] where,

[ss] Start sentinel of “;” (0x3B).

[PAN] Primary account number; maximum 19 digits. [fs] Field separator of “=” (0x3D).

[other] Can contain the following: 4-digit expiration dateb 3-byte restriction or typeb 5-byte offset of PVNb

5 bytes of discretionary data

b. Required by VISA and MasterCard Track 3 format.

[es] End sentinel of “?” (0x3F).

[lrc] 1-byte longitudinal redundancy check value.

Track Format 3 ISO 4909 track 3 format consisting of a maximum of 107

alphanumeric characters. This standard was published in October, 1973; other formats are now in use. The track format is:

[ss][fc][PAN][fs][secure][other][es][lrc] where,

[ss] Start sentinel of “%” (0x25) [fc]; Two-byte format code. [PAN] Primary account number; maximum 19 digits.

FUNCTION CALLS card_parse()

card_parse() processes tracks based on the order parameter. On terminals that read multiple tracks on a single pass, the application can select which is the preferred track. For example, a terminal can read both track 1 and track 2 on a card swipe.

The information on track 1 provides information not available on track 2, and the track 1 information is preferred. If the data in track 1 is invalid or missing, then track 2 data is read and returned. By specifying the order for processing as “12”,

card_parse() always attempts to obtain track 1, but returns track 2 if track 1 fails.

[secure] Name of the card holder, 26 characters max Can contain the following:

3-byte country code

1-byte field separator of “=” (0x3D) 3-byte currency code

1-byte currency exponent

4-byte amount authorized per cycle 4-byte amount remaining this cycle 4-byte cycle begin

2-byte cycle length 1-byte re-entry count

6-byte PIN control parameters

or

1-byte field separator of “=” (0x3D) 1-byte interchange control

2-byte PAN service restriction 2-byte SAN-1 service restriction 2-byte SAN-2 service restriction 4-byte expiration date

1-byte field separator of “=” (0x3D) 1-byte card sequence number 9-byte card security number

or

1-byte field separator of “=” (0x3D) [other] Can contain the following:

Optional first secondary account number Optional second secondary account number 1-byte relay marker

6-byte cryptographic check

or

1-byte field separator of “=” (0x3D) Discretionary data

[es] End sentinel of “?” (0x3F).

FUNCTION CALLS card_parse()

If a non-existent track is specified in the order parameter, card_parse()

processes as though the track existed but was invalid.

card_parse() places the track information in a caller-supplied structure TRACK (defined in ACLDEV.H). This structure contains the following data elements and sizes:

struct TRACK {

char acct [23];/* account number */ char exp [5];/* expiration date */ char name [27];/* name for track 2 */ char type [4];/* required by VISA/ MC */ char PVN [6];/* required by VISA/ MC */ char disc [17];/* tracks 1 and 2 only */ char track [108];/* raw track data */

Not all fields are available on all tracks; the following table indicates the fields available after parsing. This function clears all fields in the structure prior to parsing. Any fields not used for a particular track are zero-filled.

The track field is an exact copy of the data portion of the track field of the card read. This can be used for inclusion in packets or additional parsing, if required. The actual parsing of the track field is accomplished by calling the ACL routine

track_parse().

For tracks 1 and 2, if discretionary data is not available, card_parse() returns success and the discretionary field is null.

Dependencies ACL MEMCLR(), track_parse()

Example The linked example code file demonstrates use ofcard_parse.

Track1 Track2 Track3

acct X XX exp X XX name X –– type X X– PVN X X– disc X X– track X XX NOTE

FUNCTION CALLS