#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#include "extern.h"

mlchk(chkflg)
       int chkflg;   /* chkflg = 1..¶Ø ¼Þ®³·®³ ¶¸Ã² º³¼Ý ½Ù  0..¼Å² */
                     /*          2..ÓÄ Æ ÓÄÞ½ */
       {  char tocall[9];
          int  mlflg = 0;
          long flptr;
       
          if ( chkflg )  fpw = fopen(MAIL_HDR,"r+");
               else      fpw = fopen(MAIL_HDR,"r");
               
          while(1)
             {  flptr = ftell(fpw);
                if ( fgets(fbuff,255,fpw) == NULL ) break;
                if ( ! isdigit(*(fbuff)) ) continue;
                substr(fbuff,5,8,tocall);
                if ( strcmp(tocall,hiscall) )  continue;
                substr(fbuff,4,1,tocall);
                if ( *(tocall) == ' ' ) mlflg = 1; /* mail Ê±¸ */
                
                if ( chkflg && islower(*(tocall)) )
                   { *(tocall) -= 0x20;   /* ¶Ø º³¼Ý -> ÎÝ º³¼Ý */
                     if ( chkflg == 2 ) strcpy(tocall," ");
                     flptr = flptr + 4;
                     fseek(fpw,flptr,0);
                     fputs(tocall,fpw);
                     flptr = flptr - 4;
                     fseek(fpw,flptr,0); 
                   }
              }
          fclose(fpw);
          return(mlflg);
       }


