Exemple #1
0
static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
{
	struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
	int retval = -EINVAL;
	
	if (!serial)
		return -ENODEV;

	down (&port->sem);

	dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);

	if (!port->open_count) {
		dbg("%s - port not opened", __FUNCTION__);
		goto exit;
	}

	/* pass on to the driver specific version of this function if it is available */
	if (serial->type->write)
		retval = serial->type->write(port, from_user, buf, count);
	else
		retval = generic_write(port, from_user, buf, count);

exit:
	
	up (&port->sem);
	
	return retval;
}
Exemple #2
0
void parent_write(Server *serv, int fd)
{
    if (glob_child_dat.children[glob_child_dat.fd_to_child[fd]] == -2)
	delete_child(serv, glob_child_dat.fd_to_child[fd]);
    else
	generic_write(fd, serv, -1);
}
Exemple #3
0
int pvfwrite(pfile * fp, char * buffer, int buffer_size,int current_offset)
{
 if(fp)
 {
     int write_size = 0 ;
     write_size = generic_write(fp,buffer,current_offset,buffer_size,&credentials);
     return write_size ;
 }
}
Exemple #4
0
std::ostream & t_trie::latex_write (std::ostream & out) const {
    return generic_write(out,
                         TRIE_LATEX_PREFIX,
                         TRIE_LATEX_SUFFIX,
                         TRIE_LATEX_SEP,
                         CANDIDATE_LATEX_PREFIX,
                         CANDIDATE_LATEX_SUFFIX,
                         CANDIDATE_LATEX_SEP);
}
Exemple #5
0
std::ostream & t_trie::pretty_write (std::ostream & out) const {
    return generic_write(out,
                         TRIE_PRETTY_PREFIX,
                         TRIE_PRETTY_SUFFIX,
                         TRIE_PRETTY_SEP,
                         CANDIDATE_PRETTY_PREFIX,
                         CANDIDATE_PRETTY_SUFFIX,
                         CANDIDATE_PRETTY_SEP);
}
Exemple #6
0
std::ostream & t_trie::write (std::ostream & out) const {
    return generic_write(out,
                         TRIE_NORMAL_PREFIX,
                         TRIE_NORMAL_SUFFIX,
                         TRIE_NORMAL_SEP,
                         CANDIDATE_NORMAL_PREFIX,
                         CANDIDATE_NORMAL_SUFFIX,
                         CANDIDATE_NORMAL_SEP);
}
Exemple #7
0
static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
{
	struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
	struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
	
	if (!serial) {
		return -ENODEV;
	}
	
	dbg(__FUNCTION__ " - port %d, %d byte(s)", port->number, count);

	if (!port->active) {
		dbg (__FUNCTION__ " - port not opened");
		return -EINVAL;
	}
	
	/* pass on to the driver specific version of this function if it is available */
	if (serial->type->write) {
		return (serial->type->write(port, from_user, buf, count));
	} else {
		return (generic_write(port, from_user, buf, count));
	}
}
Exemple #8
0
static void stderr_console_write(struct console *console, const char *string,
				 unsigned len)
{
	generic_write(2 /* stderr */, string, len, NULL);
}
Exemple #9
0
static int slinear192_write(struct ast_filestream *fs, struct ast_frame *f){return generic_write(fs, f, AST_FORMAT_SLINEAR192);}
Exemple #10
0
static void
write_select(struct socket *socket)
{
	struct write_buffer *wb = socket->write_buffer;
	int wr;

	assertm(wb != NULL, "write socket has no buffer");
	if_assert_failed {
		socket->ops->done(socket, connection_state(S_INTERNAL));
		return;
	}

	/* We are making some progress, therefore reset the timeout; ie.  when
	 * uploading large files the time needed for all the data to be sent can
	 * easily exceed the timeout. */
	socket->ops->set_timeout(socket, connection_state(0));

#if 0
	printf("ws: %d\n",wb->length-wb->pos);
	for (wr = wb->pos; wr < wb->length; wr++) printf("%c", wb->data[wr]);
	printf("-\n");
#endif

#ifdef CONFIG_SSL
	if (socket->ssl) {
		wr = ssl_write(socket, wb->data + wb->pos, wb->length - wb->pos);
	} else
#endif
	{
		assert(wb->length - wb->pos > 0);
		wr = generic_write(socket, wb->data + wb->pos, wb->length - wb->pos);
	}

	switch (wr) {
	case SOCKET_CANT_WRITE:
		socket->ops->retry(socket, connection_state(S_CANT_WRITE));
		break;

	case SOCKET_SYSCALL_ERROR:
		socket->ops->retry(socket, connection_state_for_errno(errno));
		break;

	case SOCKET_INTERNAL_ERROR:
		/* The global errno variable is used for passing
		 * internal connection_state error value. */
		socket->ops->done(socket, connection_state(errno));
		break;

	default:
		if (wr < 0) break;

		/*printf("wr: %d\n", wr);*/
		wb->pos += wr;

		if (wb->pos == wb->length) {
			socket_write_T done = wb->done;

			if (!socket->duplex) {
				clear_handlers(socket->fd);

			} else {
				select_handler_T read_handler;
				select_handler_T error_handler;

				read_handler  = get_handler(socket->fd, SELECT_HANDLER_READ);
				error_handler = read_handler
					      ? (select_handler_T) exception
					      : NULL;

				set_handlers(socket->fd, read_handler, NULL,
					     error_handler, socket);
			}

			mem_free_set(&socket->write_buffer, NULL);
			done(socket);
		}
	}
}
Exemple #11
0
int tnt4882_command(gpib_board_t *board, uint8_t *buffer, size_t length, size_t *bytes_written)
{
	return generic_write( board, buffer, length, 0, 1, bytes_written);
}
Exemple #12
0
int tnt4882_accel_write(gpib_board_t *board, uint8_t *buffer, size_t length, int send_eoi, size_t *bytes_written)
{
	return generic_write( board, buffer, length, send_eoi, 0, bytes_written);
}