login.c
umud/login.c · 2.1 KB
From the archive umud2.0.tar.gz
Download the archive « Back to the archive contents
/*
Copyright (C) 1991, Marcus J. Ranum. All rights reserved.
*/
#ifndef lint
static char RCSid[] = "$Header: /home/mjr/hacks/umud/RCS/login.c,v 1.1 92/02/09 22:59:33 mjr Exp $";
#endif
/* configure all options BEFORE including system stuff. */
#include "config.h"
#include "mud.h"
#include "vars.h"
#include "look.h"
/*
login is expected to do something intelligent with the line of
user information passed to it. the first word is assumed to be "connect"
or something like that. the second is the object-id, the third is
maybe a password.
*/
login(lp,whobuf)
char *lp;
char *whobuf;
{
char *opw;
int ac;
char *av[25];
char ab[MUDBUF];
char pbuf[MAXOID];
ac = run_tokenize(lp,av,25,ab,sizeof(ab));
if(ac == 1 && !strcmp(av[0],"QUIT"))
return(-1);
if(ac < 2 || ac > 3 || strlen(av[1]) > MAXOID - 2)
return(0);
(void)strcpy(whobuf,av[1]);
if((opw = ut_getatt(av[1],0,typ_str,var_pass,(char *)0)) == (char *)0)
return(0);
if(*opw == '\0')
return(1);
/* no password given */
if(ac != 3)
return(0);
/* password encryption is seeded with the object # as key */
rot_init(av[1]);
/* then the password plaintext is encrypted with it. */
rot_decode(opw,pbuf);
/* so it should match the plaintext password given us by the player */
if(strcmp(av[2],pbuf))
return(0);
return(1);
}
void
welcome(who)
char *who;
{
char *w;
char *linkmsg;
say(who,"Welcome to UnterMUD ",version," (",mud_getname(),")\n",(char *)0);
(void)say_file(who,"NEWS/welcome.txt");
w = ut_loc(who);
if(!strcmp(w,"nowhere") && (linkmsg = ut_getatt(who,0,typ_str,var_linkmsg,(char *)0)) != (char *)0) {
say(who,"You shouldn't be here. Go away.\n",(char *)0);
say(who,linkmsg,"\n",(char *)0);
} else {
run(who,who,"look",0,(char **)0,1);
if(!ut_flagged(who,var_isdark))
ut_roombcast(w,who,ut_name(who)," has arrived.\n",(char *)0);
}
}
/* WARNING!!! the calls to goodbye() actually may make more
Iob writes as a result of a player hangup WHILE RUNNING INSIDE io_sync()!
Do NOT do much in goodbye!() or madness may result.
*/
void
goodbye(w)
char *w;
{
if(!ut_flagged(w,var_isdark))
ut_roombcast(ut_loc(w),w,ut_name(w)," has disconnected.\n",(char *)0);
}