Example #1
0
/*
 * ApplyDataHdr adds a data header to a data buffer
 *
 * Params:
 * channel is the channel to which the data belongs
 * commbuff is the buffer with the data to be sent
 * mux is the MUX object the data is to be transmitted through
 */
void ApplyDataHdr(int8 channel, COMMBUFF **commbuff, MUX *mux)
{
	CHANNEL *chanlPtr;
	DATA_PACKET_HDR packetdatahdr;
	int16 length;
	COMMBUFF *cb = *commbuff;

	DEBUG("ApplyDataHdr(%lu, %p, %p)\n", (int32) channel, commbuff,
	      mux);

	length = (int16) commbuff_length(cb);
	convert_word(length);

	chanlPtr = mux->channels[channel];

	packetdatahdr.type = PACKETTYPE_DATA_HDR;
	packetdatahdr.channel = channel;
	packetdatahdr.len = length;

	commbuff_add_header(cb, &packetdatahdr, sizeof(DATA_PACKET_HDR));
	*commbuff = cb;

	chanlPtr->qed_totl_amount += sizeof(DATA_PACKET_HDR);
	mux->total_queued_amount += sizeof(DATA_PACKET_HDR);
}
Example #2
0
File: hw4.c Project: pete0877/wpi
int main (void)
{
 	
	char  s[21],             /* a temp word variable */
	      table[200][21];    /* the table of words   */
	int ns[200];             /* array of occurences  */
        int n;                   /* count variable       */

   for(n=0;n<199;n++) ns[n]=1;   /*   set up the array   */
   n=0;
   do
   {
   	get_word(s);    /*  input a word from the inout */

      if (!strcmp(s,"* no more *"))
      {
	/*    If it is the end of the file : */
	print_table(sort(table,ns,n),n,ns);
      	return(0);
      }
      convert_word(s);   /* make the word loower case */
      if (!lookup(s,table,n,ns))
      {
	/*   word is not in the table yet   */
      	insert_word(s,table,n);
      	n++;
      }
   } while (1);
   /* wont quit until the end of file is reached  */
}