| 1 |
/* |
| 2 |
* ISMN.h |
| 3 |
* PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC) |
| 4 |
* |
| 5 |
* Information recompiled by Kronuz on November 12, 2004 |
| 6 |
* http://www.ismn-international.org |
| 7 |
* |
| 8 |
* IDENTIFICATION |
| 9 |
* contrib/isn/ISMN.h |
| 10 |
* |
| 11 |
* M-3452-4680-5 <=> (0)-3452-4680-5 <=> 0345246805 <=> 9790345246805 <=> 979-0-3452-4680-5 |
| 12 |
* |
| 13 |
* (M counts as 3) |
| 14 |
* ISMN M 3 4 5 2 4 6 8 0 |
| 15 |
* Weight 3 1 3 1 3 1 3 1 3 |
| 16 |
* Product 9 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 65 |
| 17 |
* 65 / 10 = 6 remainder 5 |
| 18 |
* Check digit 10 - 5 = 5 |
| 19 |
* => M-3452-4680-5 |
| 20 |
* |
| 21 |
* ISMN 9 7 9 0 3 4 5 2 4 6 8 0 |
| 22 |
* Weight 1 3 1 3 1 3 1 3 1 3 1 3 |
| 23 |
* Product 9 + 21 + 9 + 0 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 95 |
| 24 |
* 95 / 10 = 9 remainder 5 |
| 25 |
* Check digit 10 - 5 = 5 |
| 26 |
* => 979-0-3452-4680-5 |
| 27 |
* |
| 28 |
* Since mod10(9*1 + 7*3 + 9*1 + 0*3) = mod10(M*3) = mod10(3*3) = 9; the check digit remains the same. |
| 29 |
* |
| 30 |
*/ |
| 31 |
|
| 32 |
/* where the digit set begins, and how many of them are in the table */ |
| 33 |
static const unsigned ISMN_index[10][2] = { |
| 34 |
{0, 5}, |
| 35 |
{5, 0}, |
| 36 |
{5, 0}, |
| 37 |
{5, 0}, |
| 38 |
{5, 0}, |
| 39 |
{5, 0}, |
| 40 |
{5, 0}, |
| 41 |
{5, 0}, |
| 42 |
{5, 0}, |
| 43 |
{5, 0}, |
| 44 |
}; |
| 45 |
static const char *ISMN_range[][2] = { |
| 46 |
{"0-000", "0-099"}, |
| 47 |
{"0-1000", "0-3999"}, |
| 48 |
{"0-40000", "0-69999"}, |
| 49 |
{"0-700000", "0-899999"}, |
| 50 |
{"0-9000000", "0-9999999"}, |
| 51 |
{NULL, NULL} |
| 52 |
}; |