예제 #1
0
파일: mmsg.c 프로젝트: E-LLP/VICAR
FUNCTION  CODE  m_msg
(
 TEXT	message[],			/* In: message to be logged */
 TEXT	key[]				/* In: message key */
 )
    {
    CODE 	code;

/* the following avoids declaring a full PARBLK just to send a message	*/
#define ALDIM(bytes) 	1+((bytes-1)/sizeof (ALIGN)) 
#define HEAD_SIZ (sizeof(struct PARBLK) - P_BYTES + 8)  /* 8 for align safety*/
#define MBLKDIM (3*sizeof(struct VARIABLE) + 3*OUTMSGSIZ + HEAD_SIZ)
						/* block size in bytes	*/
    ALIGN	block[ALDIM(MBLKDIM)];		/* parameter block to send */
    struct	PARBLK  *parblk;		/* pointer to parameter block*/

    TEXT	*vector[1];			/* pointer to value */
    TEXT	msgbuf[OUTMSGSIZ+1];
    TEXT	msgkey[KEYSIZ+1];

    
    parblk = (struct PARBLK *) block;
    q_init (parblk, MBLKDIM - HEAD_SIZ, P_ABORT);	/* initialize block */
    s_bcopy((GENPTR)message, (GENPTR)msgbuf, OUTMSGSIZ); /* copy locally */
    if (s_length(message) > OUTMSGSIZ)			/* if too long-	*/
	msgbuf[OUTMSGSIZ] = EOS;			/* truncate	*/
    vector[0] = (TEXT *) msgbuf;
    code = q_string(parblk, "MESSAGE", 1, vector, P_ADD); /* add message */
    if (code == SUCCESS)
	{
	s_bcopy(key, msgkey, KEYSIZ);			/* copy key locally */
	if (s_length(key) > KEYSIZ)
	    msgkey[KEYSIZ] = EOS;			/* police length */
        vector[0] = (TEXT *) msgkey;			/* pointer to key   */
	code = q_string(parblk, "KEY", 1, vector, P_ADD); /* add key 	    */
	}
    if (code == SUCCESS)
	{
	code = q_sndp(parblk, M_HLOGMSG);		/* send message     */
	if (code == SUCCESS)
	    {
	    code = c_rcvp((GENPTR)parblk, sizeof(block)); /* rcv handsh blk */
	    (*parblk).hostcode = code;			/* save host code   */
	    if (code != SUCCESS)
		{
		t_write(
	"[TAE-MSGHANDS] Unable to confirm message reception by TM", T_STDCC);
		procexit(code);
		}
	    }
	}
    s_copy(msgkey, savekey);				/* save the key     */
    m_msgout(msgbuf, msgkey);				/* write to output  */
    return(code);
    }
예제 #2
0
파일: zexit.c 프로젝트: E-LLP/VICAR
FUNCTION  VOID  z_exit
(
    FUNINT		sfi,			/* in: value for $sfi	*/
    TEXT		*skey			/* in: value for $sky	*/

 )
    {
#define ALDIM(bytes) 	1+((bytes-1)/sizeof (ALIGN)) 
#define HEAD_SIZ (sizeof(struct PARBLK) - P_BYTES + 8)  /* 8 for align safety*/
#define ZBLKDIM		(3*sizeof(struct VARIABLE) + 2*STRINGSIZ + HEAD_SIZ)
    						/* block dimension	*/

    IMPORT TEXT		savekey[];		/* key for last message	*/
    TEXT		*keyptr[1];		/* pointer to key string */
    TAEINT		sfival[1];
    ALIGN		block[ALDIM(ZBLKDIM)];	/* parameter block to send */
    struct	PARBLK  *termblk;		/* pointer to parameter block*/
    CODE		code;

    keyptr[0] = skey;				/* assume key present	*/
    if (NULLSTR(skey))
	keyptr[0] = savekey;			/* else, give old key	*/
    sfival[0] = sfi;
    termblk = (struct PARBLK *)block;		/* cast pointer		*/
    q_init(termblk, ZBLKDIM - HEAD_SIZ, P_ABORT); /* initialize the block*/
    q_intg(termblk, "$SFI", 1, sfival, P_ADD);	/* put sfi in block	*/
    q_string(termblk, "$SKEY", 1, keyptr, P_ADD);  /* put skey in block */
    code = q_out(termblk);			/* send block to tm	*/
    procexit(code);
    return;
    }
예제 #3
0
/************************************************************************
 * void q_num(WORD var)
 * convert an integer to a character string and add to output buffer
 * (bit of a work-around to get around a compiler problem)
 ***********************************************************************/
void q_num(WORD var)
{
	BYTE temp[10];
	BYTE show=1;
	BYTE count=temp;
	
	/* find the width of the number */
	while ((count /= 10) >= 1) show++;
	/* do the conversion to a string */
	lPrtString(temp,var);
	/* add string to output buffer */
	q_string(temp,show);
}
예제 #4
0
파일: next.c 프로젝트: DavidFeng/ci
void dump_source() {
  ++line;
  if (!src) return;

  printf(GREEN("%d: %.*s"), line, (int)(p - lp), lp);

  lp = p;
  int lc = 1;

  while (le < e) {
    ++le;
    printf(COLOR_BLUE ">% 7d " COLOR_YELLOW "% 4d: " COLOR_RED "%8.4s",
        (int)(le - be), lc++, &op_codes[*le * 5]);
    if (*le <= LGB) {
      printf(" % 4d", *++le);
      if (*(le - 1) == LGB) {

        int *id = sym;
        int print_id = 0;
        while (id[Tk]) {
          if (id[Class] == Glo && id[Val] == *le) {
            print_id = 1;
            break;
          }
          id = id + Idsz;
        }
        if (print_id) {
          int idc = (int)id_end((const char *)id[Name]) - id[Name];
          memcpy(buf, (const char *)id[Name], idc);
          buf[idc] = '\0';
        } else {
          q_string(buf, bd + *le);
        }
        printf(COLOR_YELLOW "\t;  %s", buf);
      }
      printf("\n" COLOR_RESET);
    } else {
      printf("\n" COLOR_RESET);
    }
  }
}
예제 #5
0
/************************************************************************
 * void tftp()
 * Simple application layer server to return data
 * The only functionality provided is reading, and only one 'file'.
 * this function doesn't need to know anything about buffer
 * positions, it simply uses functions provided by the IP layer.
 ***********************************************************************/
void tftp()
{
	WORD opcode;
	/* read the operation code */
	copy_rx_word(&opcode);
	/* read request */
	if (opcode == TFTP_READ) {
		/* check the requested filename is 'stats' */
		if (rx_byte() == 's' && rx_byte() == 't' && rx_byte() == 'a' &&
			rx_byte() == 't' && rx_byte() == 's' && rx_byte() == 0x00)
		{
			tx_word(TFTP_DATA);	/* op code */
			tx_word(0x0001);	/* block number */
			q_string("   IP Statistics   \n\n",21);
			q_string("Received:\t",10);
			q_num(ipstat.rxpackets);		
			q_string("\nTransmitted:\t",14);
			q_num(ipstat.txpackets);
			q_string("\nDropped:\t",10);
			q_num(ipstat.dropped);
			q_string("\n\n",2);
		}
		/* requested a different file, not found */
		else {
			tx_word(TFTP_ERR);
			tx_word(0x0001);
			q_string("File Not Found.",15);
			tx_byte(0x00);
		}
		udp_send(txpos-IPSIZE-UDPHSIZE,1);
	}
	/* write request, send error code and message */
	else if (opcode == TFTP_WRITE) {
		tx_word(TFTP_ERR);
		tx_word(0x0002);
		q_string("Access Violation.",17);
		tx_byte(0x00);
		udp_send(txpos-IPSIZE-UDPHSIZE,1);
	}
}