Files
sibo-playground/code/inventory/upc.h
T

25 lines
578 B
C

/*
* upc.h - UPC-A barcode validation.
*
* Pure C, no SIBO/PLIB dependencies, so it can be unit-tested on any host
* compiler as well as built for the Workabout.
*/
#ifndef UPC_H
#define UPC_H
#define UPC_A_LEN 12
/*
* Returns 1 if s is a valid 12-digit UPC-A (all digits and a correct
* check digit), 0 otherwise. s must be NUL-terminated.
*/
int upcIsValid(const char *s);
/*
* Returns the UPC-A check digit (0-9) computed from the first 11 digits
* of s, or -1 if those 11 characters are not all digits.
*/
int upcCheckDigit(const char *s);
#endif /* UPC_H */