#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#include "extern.h"

exeadd()
     {
      char junle[9];            /* ｶｷｺﾐ ﾎﾞｰﾄﾞ */
      char title[31];           /* ﾀｲﾄﾙ ﾓｼﾞﾚﾂ */
      int  numd;               /* work ｼﾋｮｳ */
     
	  if ( ! mail && ! strcmp(hiscall,guestid) )
		 {  strcpy(ssent,": ゲストのかたはボードに書き込めません\n");
			rsout();
			return(0);
		  }

      numd = atoi(cmdnum);
      if ( numd != 0 )
         { *(pfna) = NULL;
           if ( numd > 999 )  { paraerr(); return(0); }
           if (*(rtbl + numd) == NULL )  { paraerr(); return(0); }
           if (*(rtbl + numd) == -1 )    { paraerr(); return(0); }
	   makfname("MSG",*(rtbl + numd),pfna);
         }

      /* read ｻﾚﾃｲﾅｲ ﾄｷﾉ ｶｷｺﾐ ｷﾝｼ */
      if (! strlen(pfna))
         {  sprintf(ssent,": 応えるファイルＮｏ．を F コマンドで選んで下さい\n");
            rsout();
            return(0);
         }

      /* ﾒｯｾｰｼﾞ ﾊｱｸ ｼｮﾘ */
      fpw = fopen(pfna,"r");
      if ( fpw == NULL ) return(0);
      if ( fgets(fbuff,255,fpw) == NULL ) return(0);

      fclose(fpw);      
      substr(fbuff,0,8,junle);
      substr(fbuff,11,30,title);
      
     strcpy(ssent,"\n");
     strncat(ssent,fbuff,54);*(ssent+55) = '\n'; *(ssent+56) = NULL;
     rsout();
     if ( ! exp_flg )
        { sprintf(ynsent,": この話題への書きこみですね? ");
          if ( mail ) { sprintf(ynsent,": このメールへの返事ですね? "); }
          if(y_or_n()) return(0);
        }

     if ( mail ) { substr(fbuff,48,8,tocall);
					 if ( ! strcmp(tocall,guestid) )
					 {strcpy(ssent,": ゲスト宛に返事をだすことはできません\n");
						rsout();
						return(0);
		  			 }

                 }

     filrcv(junle,title,"Re");
     return(0);
     }
