/* k 0165	25/05/91	*/
/* k 0175 	09/06/91	*/
/* k 0191	02/07/91	*/
/* k 0206	06/09/91	*/
/* k 0218	16/09/91	*//* printf if no VT */
/* k 0224       23/09/91        *//* ebss */
/* k 0226	24/09/91	*//* literals */
/* k 0232	11/10/91	*/
/* k 0258	10/11/91	*//* 1 to -1 */
/* k 0304	23/02/92	*//*	path     */
#include <ebss.h>               /* @0224 */
#include <fcntl.h>		/* @0218 */
#if (OVL_TYPE!=1)
#include <stdio.h>		/* @0218 */
#endif
#include <pconio.h>
extern char wbuf[];                             /* @0230 */
extern char *msg1;	/* @0206 */             /* @0230 */
extern char *mname;	/* @0206 *//* @0208 */  /* @0230 */
extern char *p_msg;    /* @0230 */
smsgop(mno,pno,a)		/* @0191 */
short mno;			/* @0191 */
short pno;			/* @0191 */
short *a[];			/* @0191 */
{
char *s0,*s1;
short i;
short mfd;		/* @0206 */
#if ((OVL_TYPE==1)&&(RESIDENT!=1))      /* @0304 */
 Res_strcpy(portpath+1+portpath[0],mname);	/* @0304 */
#else                                           /* @0304 */
 strcpy(portpath+1+portpath[0],mname);	/* @0304 */
#endif                                  /* @0304 */
#if ((OVL_TYPE==1)&&(RESIDENT!=1))
 if ((mfd=Res_open(portpath+1,O_BINARY|0))==-1)/* @0206  @0218 @0230 @0304 */
  {			/* @0206 */
   pcprintf(msg1);	/* @0206 *//* @0230 *//* @0233 */
   return;		/* @0206 */
  }			/* @0206 */
 if (Res_lseek(mfd,(long)(2*(mno-1)),0)!=-1)	/* @0175 *//* @0258 */
   if (Res_read(mfd,&offs,2)>0)		/* @0175 */
    if (offs!=0)
     if (Res_lseek(mfd,(long)offs,0)!=-1)	/* @0175 */
       {
	 Res_read(mfd,wbuf+160,70);		/* @0175 @0206 @0230 */
#else
 if ((mfd=open(portpath+1,O_BINARY|0))==-1)/* @0206  @0218 @0230 *//* @0304 */
  {			/* @0206 */
   printf(msg1);	/* @0206 *//* @0230 */
   return;		/* @0206 */
  }			/* @0206 */
 if (lseek(mfd,(long)(2*(mno-1)),0)!=1)	/* @0175 */
   if (read(mfd,&offs,2)>0)		/* @0175 */
    if (offs!=0)
     if (lseek(mfd,(long)offs,0)!=-1)	/* @0175 */
       {
	 read(mfd,wbuf+160,70);		/* @0175 *//* @0206 */
#endif
	 i=0;
	 while (wbuf[i+160]!=0x0a)	/* @0175 @0206 *//* @0230 */
	   i++;
/*	 setcursor(NOCURSOR);*/		/* @0258 *//* @0308 */
	 if (vt_flag & VT_ACT)		/* @0218 */
	 {				/* @0218 */
	 setcursor(NOCURSOR);		/* @0258 */
	 wbuf[i+160]=0x00;		/* @0175 *//* @0206 *//* @0230 */
#if (OS_TYPE==0)			/* @0191 */
	 pcprintf(p_msg,mno);			/* @0226 *//* @0230 */
#elif (OS_TYPE==3)			/* @0191 */
         pcprintf("PORT-M MSG %u: ",mno);	/* @0191 */
#else					/* @0191 */
         pcprintf("PORT-X MSG %u: ",mno);	/* @0191 */
#endif					/* @0191 */
/*	 if (pno==0)   */
	   pcprintf(wbuf+160);		/* @0206 */
/*	 else
	  {
	   s0=wbuf+160;		/* @0206 */
	   for (i=0;i<70;i++)
	     if (wbuf[i+160]=='%')		/* @0206 *//* @0230 */
	       break;
	   if (i<70)
	     s1=s0+i;
	   for (i=0;i<pno;i++)
	    {
	    }
	  }          */
	 }		/* @0218 */
	 else		/* @0218 */
	 {		/* @0218 */
	 wbuf[i+161]=0x00;		/* @0175 *//* @0206 *//* @0230 */
#if (OS_TYPE==0)			/* @0191 *//* @0218 */
#if ((OVL_TYPE==1)&&(RESIDENT!=1))
	 Res_printf(p_msg,mno);          /* @0218 *//* @0226 *//* @0230 */
#else
	 printf(p_msg,mno);          /* @0218 *//* @0226 *//* @230 */
#endif
#elif (OS_TYPE==3)			/* @0191 *//* @0218 */
	 printf("PORT-M MSG %u: ",mno);	/* @0191 *//* @0218 */
#else					/* @0191 *//* @0218 */
	 printf("PORT-X MSG %u: ",mno);	/* @0191 *//* @0218 */
#endif					/* @0191 *//* @0218 */
#if ((OVL_TYPE==1)&&(RESIDENT!=1))
	 Res_printf(wbuf+160);	/* @0206 *//* @0218 *//* @0230 */
#else
	 printf(wbuf+160);		/* @0206 *//* @0218 *//* @0230 */
#endif
	 }					   /* @0218 */
	}
#if ((OVL_TYPE==1)&&(RESIDENT!=1))
	Res_close(mfd);		/* @0206 */
#else
	close(mfd);		/* @0206 */
#endif
}
