/* tcluser.c -- handles: Tcl stubs for the user-record-oriented commands dprintf'ized, 1aug96 */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include "../lush.h" #include "eggdrop.h" #include "users.h" #include "proto.h" #include "cmdt.h" #include "tclegg.h" /* eggdrop always uses the same interpreter */ extern Tcl_Interp *interp; extern struct userrec *userlist; extern int default_flags; extern struct dcc_t dcc[]; extern int dcc_total; /***********************************************************************/ int tcl_countusers STDVAR { char s[40]; BADARGS(1,1,""); sprintf(s,"%d",count_users(userlist)); Tcl_AppendResult(irp,s,NULL); return TCL_OK; } int tcl_validuser STDVAR { BADARGS(2,2," handle"); if (is_user(argv[1])) Tcl_AppendResult(irp,"1",NULL); else Tcl_AppendResult(irp,"0",NULL); return TCL_OK; } int tcl_finduser STDVAR { char s[20]; BADARGS(2,2," nick!user@host"); get_handle_by_host(s,argv[1]); Tcl_AppendResult(irp,s,NULL); return TCL_OK; } int tcl_passwdOk STDVAR { BADARGS(3,3," handle passwd"); if (pass_match_by_handle(argv[2],argv[1])) Tcl_AppendResult(irp,"1",NULL); else Tcl_AppendResult(irp,"0",NULL); return TCL_OK; } int tcl_chattr STDVAR { int atr,oatr,f,i,pos=1,recheck=0; char s[20]; BADARGS(2,3," handle ?changes?"); if ((argv[1][0]=='*') || (!is_user(argv[1]))) { Tcl_AppendResult(irp,"*",NULL); return TCL_OK; } oatr=atr=get_attr_handle(argv[1]); if (argc==3) { /* make changes */ for (i=0; iflags & f)==f) Tcl_AppendElement(interp,u->handle); u=u->next; } return TCL_OK; } int tcl_save STDVAR { write_userfile(); return TCL_OK; } int tcl_reload STDVAR { reload(); return TCL_OK; } int tcl_gethosts STDVAR { struct userrec *u; struct eggqueue *q; BADARGS(2,2," handle"); u=get_user_by_handle(userlist,argv[1]); if (u==NULL) return TCL_OK; q=u->host; while (q!=NULL) { Tcl_AppendElement(irp,q->item); q=q->next; } return TCL_OK; } int tcl_chpass STDVAR { char par[10],pass[10]; BADARGS(3,3," handle password"); strncpy(par,argv[2],9); par[9]=0; nsplit(pass,par); change_pass_by_handle(argv[1],pass); return TCL_OK; } int tcl_chhandle STDVAR { char hand[10]; int x; BADARGS(3,3," oldhandle newhandle"); strncpy(hand,argv[2],9); hand[9]=0; if (is_user(hand)) x=0; else { x=change_handle(argv[1],hand); if (x) notes_change(-1,argv[1],hand); } sprintf(hand,"%d",x); Tcl_AppendResult(irp,hand,NULL); return TCL_OK; } int tcl_getting_users STDVAR { int i; BADARGS(1,1,""); for (i=0; istatus&STAT_GETTING)) { Tcl_AppendResult(irp,"1",NULL); return TCL_OK; } } Tcl_AppendResult(irp,"0",NULL); return TCL_OK; }