int process_prefix(int len, long offset) { switch (len) { case 16: check_mastercard_16(offset); check_visa_16(offset); check_discover_16(offset); check_jcb_16(offset); break; case 15: check_amex_15(offset); check_enroute_15(offset); check_jcb_15(offset); break; case 14: check_diners_club_cb_14(offset); break; /** It has been purported that these cards are no longer in use case 13: check_visa_13(offset); break; **/ } return (0); }
/* * === FUNCTION ============================================================== * Name: sanity_checks * * Description: Check to ensure that all methods are functioning as expected * and detect all the different card formats * * Version: 0.0.1 * Params: N/A * Returns: void * Usage: sanity_checks() * Outputs: Sanity check test results * ============================================================================= */ void sanity_checks(FILE *output) { long int offset = 0; char result; int i; /* Mastercard 16 digit */ fprintf(output, "%s", "Mastercard 16: "); for ( i = 0; i < MCARD_16; i++ ) { memcpy(cardbuf, mastercard_16[i], CARDSIZE); result = (check_mastercard_16(offset)) ? '.' : 'F'; fprintf(output, "%c", result); } fprintf(output, "%s", "\n"); /* Visa 16 digit */ fprintf(output, "%s", "Visa 16: "); memcpy(cardbuf, visa_16, CARDSIZE); result = (check_visa_16(offset)) ? '.' : 'F'; fprintf(output, "%c", result); fprintf(output, "%s", "\n"); /* Discover 16 digit */ fprintf(output, "%s", "Discover 16: "); memcpy(cardbuf, discover_16, CARDSIZE); result = (check_discover_16(offset)) ? '.' : 'F'; fprintf(output, "%c", result); fprintf(output, "%s", "\n"); /* JCB 16 digit */ fprintf(output, "%s", "JCB 16: "); for ( i = 0; i < JCB_16; i++ ) { memcpy(cardbuf, jcb_16[i], CARDSIZE); result = (check_jcb_16(offset)) ? '.' : 'F'; fprintf(output, "%c", result); } fprintf(output, "%s", "\n"); /* AMEX 15 digit */ fprintf(output, "%s", "AMEX 15: "); for ( i = 0; i < AMEX_15; i++ ) { memcpy(cardbuf, amex_15[i], CARDSIZE); result = (check_amex_15(offset)) ? '.' : 'F'; fprintf(output, "%c", result); } fprintf(output, "%s", "\n"); /* Enroute 15 digit */ fprintf(output, "%s", "Enroute 15: "); for ( i = 0; i < ENROUTE_15; i++ ) { memcpy(cardbuf, enroute_15[i], CARDSIZE); result = (check_enroute_15(offset)) ? '.' : 'F'; fprintf(output, "%c", result); } fprintf(output, "%s", "\n"); /* JCB 15 digit */ fprintf(output, "%s", "JCB 15: "); for ( i = 0; i < JCB_15; i++ ) { memcpy(cardbuf, jcb_15[i], CARDSIZE); result = (check_jcb_15(offset)) ? '.' : 'F'; fprintf(output, "%c", result); } fprintf(output, "%s", "\n"); /* Diners 14 digit */ fprintf(output, "%s", "Diners 14: "); for ( i = 0; i < DINERS_14; i++ ) { memcpy(cardbuf, diners_club_cb_14[i], CARDSIZE); result = (check_diners_club_cb_14(offset)) ? '.' : 'F'; fprintf(output, "%c", result); } fprintf(output, "%s", "\n"); }