feat(inventory): add upc.h (Phase 1: scan + UPC validation)
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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 */
|
||||||
Reference in New Issue
Block a user