/* ** This is the default collating function named "BINARY" which is always ** available. ** ** If the padFlag argument is not NULL then space padding at the end ** of strings is ignored. This implements the RTRIM collation. */ static int binCollFunc( void *padFlag, int nKey1, const void *pKey1, int nKey2, const void *pKey2 ){ int rc, n; n = nKey1<nKey2 ? nKey1 : nKey2; rc = memcmp(pKey1, pKey2, n); if( rc==0 ){ if( padFlag && allSpaces(((char*)pKey1)+n, nKey1-n) && allSpaces(((char*)pKey2)+n, nKey2-n) ){ /* Leave rc unchanged at 0 */ }else{ rc = nKey1 - nKey2; } } return rc; }
void readName( char* name, int f_or_l, int length ) { if( f_or_l == 0 ) // Wish passing strings in C was easier. f_or_l stands for first or last as in name. 0 for first and 1 for last name. { printf( "Please enter your first name on the card.\n" ) ; } else { printf( "Please enter your last name on the card.\n" ) ; } printf( "Please note if your name may contain spaces, but cannot exceed %d characters including spaces.\n", length - 1 ) ; printf( "Please use only English characters, numbers or special characters cannot be accepted by the system.\n" ) ; getData( name, length ) ; while( !checkName( name ) || allSpaces( name ) ) // Keep checking till the user gets it right. { printf( "The system seems to get only spaces, numericals or special characters.\nPlease try again.\n" ) ; getData( name, length ) ; } }