| 1 |
RUBRIC |
| 2 |
------ |
| 3 |
This is just a little program I hacked up in a few minutes. It takes in |
| 4 |
an EAN code as a command line argument and prints to STDOUT whether it |
| 5 |
is valid or not. It does this by performing a checksum on the supplied |
| 6 |
EAN. |
| 7 |
|
| 8 |
It can also check: |
| 9 |
|
| 10 |
- UPC codes (12 digits), just preface them with a zero |
| 11 |
- Four digit codes (PLUs) which some supermarkets with older tills |
| 12 |
use on their till systems to ring up products like bread, fruit, veg... |
| 13 |
basically any loose product. Eancheck can validate them, no prefixing |
| 14 |
needed. |
| 15 |
|
| 16 |
If you want to use the eancheck functions in a program, I invite you to |
| 17 |
use eancheck.h in your programs. It provides two functions, one to check |
| 18 |
check digits and another to generate them for a given EAN. |
| 19 |
|
| 20 |
COMPATIBILITY |
| 21 |
------------- |
| 22 |
So far I have tested the main program on Windows and Linux, both times with |
| 23 |
the G++ compiler. I have only tested the header file on Linux, but I assume |
| 24 |
it works on Windows too. |
| 25 |
|
| 26 |
USING EANCHECK.H |
| 27 |
---------------- |
| 28 |
eancheck.h provides two functions you can use. |
| 29 |
|
| 30 |
* int ec_checkean(char inputean[]) |
| 31 |
This function takes an input EAN as a character array (string) and returns |
| 32 |
0 if the check digit is correct, 1 if it is incorrect and 3 if invalid |
| 33 |
characters were found in the string. |
| 34 |
* int ec_gencd(char inputean[]) |
| 35 |
This function takes an EAN without the check digit and returns either the |
| 36 |
check digit (from 0-9) or 10 if an invalid character was found. |
| 37 |
|
| 38 |
LICENSING INFORMATION |
| 39 |
--------------------- |
| 40 |
I don't care what you do with this code, it's a pissy little program. Do what |
| 41 |
thou wilt. |