Ok.. I'm working on an account system, and want to make sure that no two
accounts have the same email address. Don't want users having duplicate
accounts. The issue I'm having is that during account creation I'm scanning
all the existing user accounts to see if any have the same address. I'm
using fork() so that I don't have the entire mud come to a screeching halt
while it scans, but for some reason, although everything in the fork() seems
to be working fine, it doesn't set the d->connected correctly or process the
nanny function again at the end the way I'm wanting it to. Ideas? Thansk!
- Valnir
/* Code snippet */
void check_dup_email ( DESCRIPTOR_DATA *d, char *email )
{
DIR *user_dir;
struct dirent *users;
USER_DATA *usr;
char name[MIL];
char buf[MSL];
bool duplicate = FALSE;
int f;
if ( ( f = fork() ) == (-1) )
{
write_to_buffer( d, "\n\r\n\r", 0 );
write_to_buffer( d, "An error occured while trying to validate your
email address!\n\r", 0 );
write_to_buffer( d, "You will not be able to complete continue
creating your account\n\r"
"until this problem is solved. The staff has been
contacted.\n\r\n\r"
"Please check back soon!\n\r\n\r"
"^e[^fPress Return to Disconnect^e]^0\n\r", 0 );
d->connected = CON_USER_DISCONNECT;
bug( "fork() failed in check_dup_email.", 0 );
do_bug( NULL, "fork() failed in check_dup_email." );
return;
}
if ( !f )
{
write_to_buffer( d, "Please wait while we scan for duplicate
accounts.", 0 );
process_output( d, FALSE );
if ( ( user_dir = opendir(USER_DIR) ) != NULL )
{
while ( ( users = readdir(user_dir) ) != NULL )
{
write_to_buffer( d, ".", 0 );
if ( !str_cmp( users->d_name, "." )
|| !str_cmp( users->d_name, ".." ) )
continue;
if ( !strstr( users->d_name, ".usr" ) )
continue;
/* get name from file filename - still need to parse the
'.usr' off the filename */
if ( ( usr = load_account( NULL, name ) ) != NULL )
{
if ( !str_cmp( usr->email, email ) )
{
sprintf( buf, "Attempt to use duplicate email
address detected. "
"Same as '%s'.", usr->name );
log_string( buf );
duplicate = TRUE;
}
}
unload_account( NULL, usr);
process_output( d, FALSE );
if ( duplicate )
break;
}
}
else
bug( "Could not open USER_DIR!", 0 );
closedir( user_dir );
write_to_buffer( d, "\n\r\n\r", 0 );
if ( duplicate )
{
write_to_buffer( d, "Duplicate email found! We do not allow
multiple accounts\n\r"
"per player. If you have forgotten your account name, please
contact\n\r"
"the staff at http://www.legendofthenobles.com/?page=email
to request\n\r"
"your account name.\n\r\n\r"
"^e[^fPress Return to Disconnect^e]^0\n\r", 0 );
process_output( d, TRUE );
d->connected = CON_USER_DISCONNECT;
}
else
{
write_to_buffer( d, "No duplicate found.\n\r", 0 );
process_output( d, TRUE );
d->connected = CON_CONFIRM_EMAIL;
nanny( d, email );
}
exit(0);
}
return;
}
--
ROM mailing list
ROM@rom.org
Unsubscribe here ->>> http://www.rom.org/cgi-bin/mailman/listinfo/rom