[Previous]
[Contents]
[Next]

dev_insert_chars()

insert characters in the canonical input buffer of a device

Synopsis:

#include <sys/dev.h>
int dev_insert_chars( int fd, int n, char *buf );

Description:

The dev_insert_chars() function inserts the n characters pointed to by buf into the canonical input buffer of the opened device given in fd. If n is negative, the characters are written into the raw queue rather than the canonical queue.

The dev_insert_chars() function is useful for implementing command-line recall algorithms.

Returns:

0
Success
-1
An error occurred. errno is set to indicate the error.

Errors:

EBADF
The fd argument is invalid, or the file is not opened for reading.
EINVAL
One of the arguments is invalid.
ENOSYS
This function is not supported for this file descriptor.

Examples:

#include <sys/dev.h>
#include <string.h>

int main( void )
  {
    unsigned char *p;

    /* Insert the following characters into the standard 
       input, as if they had been typed on the keyboard
       (Note: the \r instead of \n) */

    p = "Hello World!!!\r";
    dev_insert_chars( 0, strlen( p ), p );
    return( EXIT_SUCCESS );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, input_line()


[Previous]
[Contents]
[Next]