/* The actual read function. */ void readin() { char* fname = ( char* )malloc( sizeof( char ) * 26 ) ; // The extra length for the null terminator. readName( fname, 0, 26 ) ; char* lname = ( char* )malloc( sizeof( char ) * 31 ) ; readName( lname, 1, 31 ) ; char* cardnum = ( char* )malloc( sizeof( char ) * 17 ) ; readNums( cardnum, 0, 17 ) ; char* month = ( char* )malloc( sizeof( char ) * 3 ) ; readNums( month, 1, 3 ) ; while( !checkMonth( month ) ) { printf( "The entered month is not valid. Please try again.\n" ) ; readNums( month, 1, 3 ) ; } char* year = ( char* )malloc( sizeof( char ) * 5 ) ; readNums( year, 2, 5 ) ; while( !checkYear( year ) ) { printf( "The entered year is not valid. Please try again.\n" ) ; readNums( year, 2, 5 ) ; } char* cvv = ( char* )malloc( sizeof( char ) * 4 ) ; readNums( cvv, 3, 4 ) ; if( strlen( cvv ) != 3 ) // String already checked for numbers. Check if all three are there. { printf( "Not enough digits for 3 digit CVV security code. Please try again. \n" ) ; readNums( cvv, 3, 4 ) ; } char* zip = ( char* )malloc( sizeof( char ) * 6 ) ; readNums( zip, 4, 6 ) ; if( strlen( zip ) != 5 ) { printf( "Not enough numbers for 5 digit zipcode. Please try again.\n" ) ; readNums( zip, 4, 6 ) ; } char* amount = ( char* )malloc( sizeof( char ) * 10 ) ; readAmount( amount, 10 ) ; char* email = ( char* )malloc( sizeof( char ) * 25 ) ; readEmail( email, 31 ) ; display( fname, lname, cardnum, month, year, cvv, zip, amount, email ) ; // Free up all the memory pointers used here. free( fname ) ; free( lname ) ; free( cardnum ) ; free( month ) ; free( year ) ; free( cvv ) ; free( zip ) ; free( amount ) ; free( email ) ; }
bool SugarEmailIO::readSugarEmail(QIODevice *device, SugarEmail &email) { if (device == nullptr || !device->isReadable()) { return false; } email = SugarEmail(); xml.setDevice(device); if (xml.readNextStartElement()) { if (xml.name() == "sugarEmail" && xml.attributes().value(QStringLiteral("version")) == "1.0") { readEmail(email); } else { xml.raiseError(i18n("It is not a sugarEmail version 1.0 data.")); } } return !xml.error(); }