#include <string.h>

#include "extern.h"

hiscon()
    {   
		rsans(2);
		strcpy(ssent,"AT\n"); rsoutm();
		rsans(2);
       fp1 = fopen(CALL_MAST,"r");
       if ( fp1 == NULL ) { return(0); }
       while(1)
          { if ( fgets(fbuff,255,fp1) == NULL ) { fclose(fp1); return(1); }
            if ( strncmp(fbuff,hiscall,8) == NULL ) { break; }
          }
	   substr(fbuff,18,strlen(fbuff) - 18,ssent);
	   rsoutm();
	   
	   while(! chkcd() )
			{   if ( rswait() ) return(1);
				if (! strncmp(rsent,"NO",2) )   return(2);
				if (! strncmp(rsent,"BUSY",4) ) return(1);
			}

	   while(1)
			{   if ( rsin() )  return(1);
			/*	
				if (! strncmp(rsent,"CONNECT",7) )
						{ rsans(5); strcpy(ssent,"\n"); rsout();  continue; }
			*/
				if (! strncmp(rsent,"Please Return ==>",17) )
						{ strcpy(ssent,"\n"); rsout();  continue; }
				if (! strncmp(rsent,"Your ID ==>",11) )
						{ strcpy(ssent,sysop); strcat(ssent,"\n"); rsout();
						  continue; }
				if (! strncmp(rsent,"PASSWORD ==>",12) )
						{ substr(fbuff,9,8,ssent); strcat(ssent,"\n");
						  rsout(); continue; }
				if (! strncmp(rsent,"MAIN ->",7) )
						{ strcpy(ssent,"FORWARD\n"); rsout();  break; }
			}
		return(0);
	}

