#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#include "extern.h"

exerecall() /* mail ﾌｯｷ */
       {  char tocall[9];
          int  mlcnt = 0;
          long flptr;
       
          if ( ! mail ) { paraerr(); return(0); }
          fpw = fopen(MAIL_HDR,"r+");
               
          while(1)
             {  flptr = ftell(fpw);
                if ( fgets(fbuff,255,fpw) == NULL ) break;
                if ( ! isdigit(fbuff[0]) ) continue;
                substr(fbuff,5,8,tocall);
                if ( strcmp(tocall,hiscall) )  continue;
                substr(fbuff,4,1,tocall);
                if ( *(tocall) != 'X' ) continue;
                
	        freopen(MAIL_HDR,"r+",fpw);
                mlcnt++;
                strcpy(tocall,"R");
                flptr = flptr + 4;
                fseek(fpw,flptr,0);
                fputs(tocall,fpw);
                flptr = flptr - 4;
                fseek(fpw,flptr,0); 
              }

          fclose(fpw);
          if ( mlcnt )
             { sprintf(ssent,"\n %d 通のメールを復活させました。\n\n",mlcnt); }
          else
             { strcpy(ssent,"\n復活できたメールはありません。\n\n"); }
          rsout();
          return(0);
       }
