Home | History | Annotate | Download | only in nacl_io
      1 /* Copyright 2013 The Chromium Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file. */
      4 
      5 #ifndef LIBRARIES_NACL_IO_IOCTL_H_
      6 #define LIBRARIES_NACL_IO_IOCTL_H_
      7 
      8 #include <sys/types.h>
      9 
     10 /*
     11  * ioctl to feed input to a tty node. Accepts a pointer to the following
     12  * struct (tioc_nacl_input_string), which contains a pointer to an array
     13  * of characters.
     14  */
     15 #define TIOCNACLINPUT  0xadcd02
     16 
     17 /*
     18  * ioctl to register an output handler with the tty node.  Will fail
     19  * with EALREADY if a handler is already registered.  Expects an
     20  * argument of type tioc_nacl_output.  The handler will be called during
     21  * calls to write() on the thread that calls write(), or, for echoed input
     22  * during the TIOCNACLINPUT ioctl() on the thread calling ioctl(). The
     23  * handler should return the number of bytes written/handled, or -errno
     24  * if an error occured.
     25  */
     26 #define TIOCNACLOUTPUT 0xadcd03
     27 
     28 struct tioc_nacl_input_string {
     29   size_t length;
     30   const char* buffer;
     31 };
     32 
     33 
     34 typedef ssize_t (*tioc_nacl_output_handler_t)(const char* buf,
     35                                               size_t count,
     36                                               void* user_data);
     37 
     38 struct tioc_nacl_output {
     39   tioc_nacl_output_handler_t handler;
     40   void* user_data;
     41 };
     42 
     43 
     44 #endif  /* LIBRARIES_NACL_IO_NACL_IO_H_ */
     45