#include <stdio.h>
#include <string.h>
#include <conio.h>

char hostname[80],username[80],editname[80],fullname[80],replyto[80],mboxname[80];
char recordname[80],folderdir[80],mqueuedir[80],maildir[80],tzone[80],alias[80],maxlet[80];

char cfgstr[80];

FILE* msgfile;
FILE* wrkfile;




chk_for_mail(char *s)
{
char nfilename[80];

    strcpy(nfilename,maildir);
    strcat(nfilename,"\\");
    strcat(nfilename,s);
    strcat(nfilename,".txt");

    if(msgfile = fopen(nfilename,"rt"))
    {
         clrscr();
         printf("Mats har post!\n");


         fclose(msgfile);
    }

}











extract(char *s, int p)
{
int i;
    strcpy(s,&cfgstr[p]);
    while(s[0] == ' ') strcpy(s,&s[1]);

    if(i = strrchr(s,'\n') - s)
    {
         s[i] = 0;
         s[i+1] = 0;
    }
}


init()
{
FILE* cfgfile;

    if(cfgfile = fopen("XMAILER.RC","rt"))
    {
         strcpy(hostname,"nocall.ampr.org");                /* Initial values */
         strcpy(username,"noname");
         strcpy(editname,"");
         strcpy(fullname,"noname");
         strcpy(replyto,"[email protected]");
         strcpy(recordname,"\spool\outmail.txt");
         strcpy(folderdir,"\folder");
         strcpy(mqueuedir,"\spool\mqueue");
         strcpy(maildir,"\spool\mail");
         strcpy(tzone,"GMT");
         strcpy(alias,"\alias");
         strcpy(maxlet,"100");


         while(fgets(cfgstr,80,cfgfile))
         {
              if(strstr(strlwr(cfgstr),"host"))
                   extract(hostname,4);
              if(strstr(strlwr(cfgstr),"user"))
                   extract(username,4);
              if(strstr(strlwr(cfgstr),"edit"))
                   extract(editname,4);
              if(strstr(strlwr(cfgstr),"fullname"))
                   extract(fullname,8);
              if(strstr(strlwr(cfgstr),"reply"))
                   extract(replyto,5);
              if(strstr(strlwr(cfgstr),"mbox"))
                   extract(mboxname,4);
              if(strstr(strlwr(cfgstr),"record"))
                   extract(recordname,6);
              if(strstr(strlwr(cfgstr),"folder"))
                   extract(folderdir,6);
              if(strstr(strlwr(cfgstr),"mqueue"))
                   extract(mqueuedir,6);
              if(strstr(strlwr(cfgstr),"mail"))
                   extract(maildir,4);
              if(strstr(strlwr(cfgstr),"tzone"))
                   extract(tzone,5);
              if(strstr(strlwr(cfgstr),"alias"))
                   extract(alias,5);
              if(strstr(strlwr(cfgstr),"maxlet"))
                   extract(maxlet,6);
         }
         chk_for_mail(username);
    }
    else
    {
         printf("Error: XMAILER.RC not found\n");
         exit(1);
    }
}



main()
{
char ch;

    init();

    do
    {
         printf("\"%s\"> ",username);
         ch = getchar();

         switch(ch){





         }
    } while(ch != 'q');
}