예제 #1
0
static int read_telegram(struct r3964_info *pInfo, struct pid *pid,
			 unsigned char __user * buf)
{
	struct r3964_client_info *pClient;
	struct r3964_block_header *block;

	if (!buf) {
		return -EINVAL;
	}

	pClient = findClient(pInfo, pid);
	if (pClient == NULL) {
		return -EINVAL;
	}

	block = pClient->next_block_to_read;
	if (!block) {
		return 0;
	} else {
		if (copy_to_user(buf, block->data, block->length))
			return -EFAULT;

		remove_client_block(pInfo, pClient);
		return block->length;
	}

	return -EINVAL;
}
예제 #2
0
static struct r3964_message *remove_msg(struct r3964_info *pInfo,
                       struct r3964_client_info *pClient)
{
   struct r3964_message *pMsg=NULL;
   unsigned long flags;

   if(pClient->first_msg)
   {
      save_flags(flags);
      cli();

      pMsg = pClient->first_msg;
      pClient->first_msg = pMsg->next;
      if(pClient->first_msg==NULL)
      {
         pClient->last_msg = NULL;
      }
      
      pClient->msg_count--;
      if(pMsg->block)
      {
        remove_client_block(pInfo, pClient);
        pClient->next_block_to_read = pMsg->block;
      }
      restore_flags(flags);
   }
   return pMsg;
}