/* See the file wizshell.c, wizshell.h or the files in docs/ for information */ #include "wizshell.h" void shout(str) char *str; { who_t *tw; FILE *fp; tw=read_utmp(0); if(tw) tw=tw->next; while(tw) { if(tw->num3) /* they are listening */ if(!(fp=fopen(tw->str1,"a"))) { fprintf(stderr,"Could not open device file: %s\n",tw->str1); } else { fprintf(fp,"%s",str); fclose(fp); } tw=tw->next; } } void chat(str) char *str; { char *tmp; if(str[0]=='\0') { fprintf(stderr,"Usage: chat <what>\n"); return; } if(!envir.mesg) fprintf(stdout,"[You have messages turned off - type 'mesg y']\n"); MK_STR(tmp,strlen(str)+strlen(envir.login)+4) sprintf(tmp,"%c%s: %s\n",toupper(envir.login[0]),envir.login+1,str); shout(tmp); FREE(tmp); } #define MESG_EFFECTS_TELL /* I haven't decided yet :) */ void tell(str) char *str; { char *what,*endword,c; who_t *tw; FILE *fp; #ifdef MESG_EFFECTS_TELL int notlistening=0; #endif if(str[0]=='\0') { fprintf(stderr,"Usage: tell <who> <what>\n"); return; } #ifdef MESG_EFFECTS_TELL if(!envir.mesg) fprintf(stdout,"[You have messages turned off - type 'mesg y']\n"); #endif endword=str; while(*endword!=' ' && *endword!='\t' && *endword!='\0') endword++; c=*endword; if(c=='\0') { fprintf(stderr,"Usage: tell <who> <what>\n"); return; } what=eat_white(endword); *endword='\0'; tw=read_utmp(0); if(tw) tw=tw->next; while(tw) { if(!strcmp(tw->str2,str)) { #ifdef MESG_EFFECTS_TELL if(!tw->num3) { notlistening=1; tw=tw->next; continue; /* see if they have another login that is listening */ } #endif if(!(fp=fopen(tw->str1,"a"))) { fprintf(stderr,"Could not open device file: %s\n",tw->str1); } else { fprintf(stderr,"You tell %c%s: %s\n", toupper(str[0]),str+1,what); fprintf(fp,"%c%s tells you: %s\n", toupper(*envir.login),envir.login+1,what); fclose(fp); } return; } tw=tw->next; } #ifdef MESG_EFFECTS_TELL if(notlistening) fprintf(stderr,"%c%s has messages turned off.\n",toupper(str[0]),str+1); else #endif fprintf(stderr,"%s is not logged in.\n",str); return; }