#include<stdlib.h>
#include<io.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include"scrtools.h"
#include"mails.c"

void main() {
        char from[10];
        char to[10];
        char buffer[100];
        int x, ocount;
        switch(getusr(from)) {
                    case 0: disp("\r\n\7@0F@Invalid User Name...\r\n\r\n"); delay(500); textmode(3); exit(99);
                    case -1: textmode(3); disp("@03@\7 Error Exiting..."); exit(9);
                    case 1: break;
                    default: textmode(3); disp("\r\n\7@07@Error, exiting....\r\n"); exit(222);
                    }
        directvideo = 1;
        textmode(64);
        strupr(from);
        top:
            clrscr();
            sprintf(buffer,"%s%s%s@0F@:",MAILVER,MAILVER2,__DATE__);
            disp(buffer);
            dfile(INFOFILE);
            disp("\r\n@02@To                      : ");
            textcolor(LIGHTBLUE);
            if(sgets(8,to,0)) to[0] =0;
            x=0;
            while(to[x] != ' ' && to[x] != 0) x++;
            to[x] = 0;
            if (to[0] == 0 || to[0] == ' ') {
                disp("\r\n@07@Do you wish to abort this message @0D@[@05@N/y@0D@]? ");
                x = getch();
                if (x == 'Y' || x == 'y') {
                      disp("@09@Yes.");
                      textmode(3);
                      disp("@0C@\r\nMessage Aborted, Exiting...");
                      exit(0);
                      }
                else  {
                      disp("@09@No.");
                      goto top;
                      }
                }
           if(stricmp(to,"all") == 0) {
               disp("\r\n\7@09@Enter Password: ");
               textcolor(0);
               sgets(40,buffer,0);
               if(stricmp(buffer,ALLPASS) == 0)
                    disp("@0F@\r\nPassword Accepted, @0f@\1 Have a Nice Day \1\r\n");
               else {
                    disp("\7\r\n@0F@Invalid Password...");
                    goto top;
                    }
               } //All Check
           strupr(&to);
           if(stricmp(to,"all"))  switch(chkusr(to)) {
                    case 0: disp("\r\n\7@0F@Invalid User Name...\r\n\r\n"); delay(500); goto top;
                    case 1: break;
                    default: textmode(3); disp("\r\n\7@07@Error, exiting....\r\n"); exit(222);
                    }
            if(sendm(to,from,"","",0) == -1) {
                    disp("@08@ERROR!\r\n");
                    exit(1);
                    }
            disp("@07@\r\n\r\nSend Another Message (@03@Y/N@07@)? ");
            for(;;) {
                char cha = getch();
                cha = toupper(cha);
                if(cha == 'N') {
                     disp("@03@No.\r\nExiting...\r\n");
                     delay(500);
                     textmode(3);
                     disp("@0F@Thank you for using ");
                     disp(MAILVER);
                     delay(500);
                     exit(0);
                     }
                else if(cha == 'Y') {
                disp("@03@Yes!!!\r\n");
                goto top;
                }
           } //For
} //Program

