github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/include/capi/cef_stream_capi.h (about)

     1  // Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
     2  //
     3  // Redistribution and use in source and binary forms, with or without
     4  // modification, are permitted provided that the following conditions are
     5  // met:
     6  //
     7  //    * Redistributions of source code must retain the above copyright
     8  // notice, this list of conditions and the following disclaimer.
     9  //    * Redistributions in binary form must reproduce the above
    10  // copyright notice, this list of conditions and the following disclaimer
    11  // in the documentation and/or other materials provided with the
    12  // distribution.
    13  //    * Neither the name of Google Inc. nor the name Chromium Embedded
    14  // Framework nor the names of its contributors may be used to endorse
    15  // or promote products derived from this software without specific prior
    16  // written permission.
    17  //
    18  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21  // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22  // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23  // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24  // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25  // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29  //
    30  // ---------------------------------------------------------------------------
    31  //
    32  // This file was generated by the CEF translator tool and should not edited
    33  // by hand. See the translator.README.txt file in the tools directory for
    34  // more information.
    35  //
    36  
    37  #ifndef CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_
    38  #define CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_
    39  #pragma once
    40  
    41  #ifdef __cplusplus
    42  extern "C" {
    43  #endif
    44  
    45  #include "include/capi/cef_base_capi.h"
    46  
    47  
    48  ///
    49  // Structure the client can implement to provide a custom stream reader. The
    50  // functions of this structure may be called on any thread.
    51  ///
    52  typedef struct _cef_read_handler_t {
    53    ///
    54    // Base structure.
    55    ///
    56    cef_base_t base;
    57  
    58    ///
    59    // Read raw binary data.
    60    ///
    61    size_t (CEF_CALLBACK *read)(struct _cef_read_handler_t* self, void* ptr,
    62        size_t size, size_t n);
    63  
    64    ///
    65    // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
    66    // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure.
    67    ///
    68    int (CEF_CALLBACK *seek)(struct _cef_read_handler_t* self, int64 offset,
    69        int whence);
    70  
    71    ///
    72    // Return the current offset position.
    73    ///
    74    int64 (CEF_CALLBACK *tell)(struct _cef_read_handler_t* self);
    75  
    76    ///
    77    // Return non-zero if at end of file.
    78    ///
    79    int (CEF_CALLBACK *eof)(struct _cef_read_handler_t* self);
    80  
    81    ///
    82    // Return true (1) if this handler performs work like accessing the file
    83    // system which may block. Used as a hint for determining the thread to access
    84    // the handler from.
    85    ///
    86    int (CEF_CALLBACK *may_block)(struct _cef_read_handler_t* self);
    87  } cef_read_handler_t;
    88  
    89  
    90  ///
    91  // Structure used to read data from a stream. The functions of this structure
    92  // may be called on any thread.
    93  ///
    94  typedef struct _cef_stream_reader_t {
    95    ///
    96    // Base structure.
    97    ///
    98    cef_base_t base;
    99  
   100    ///
   101    // Read raw binary data.
   102    ///
   103    size_t (CEF_CALLBACK *read)(struct _cef_stream_reader_t* self, void* ptr,
   104        size_t size, size_t n);
   105  
   106    ///
   107    // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
   108    // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure.
   109    ///
   110    int (CEF_CALLBACK *seek)(struct _cef_stream_reader_t* self, int64 offset,
   111        int whence);
   112  
   113    ///
   114    // Return the current offset position.
   115    ///
   116    int64 (CEF_CALLBACK *tell)(struct _cef_stream_reader_t* self);
   117  
   118    ///
   119    // Return non-zero if at end of file.
   120    ///
   121    int (CEF_CALLBACK *eof)(struct _cef_stream_reader_t* self);
   122  
   123    ///
   124    // Returns true (1) if this reader performs work like accessing the file
   125    // system which may block. Used as a hint for determining the thread to access
   126    // the reader from.
   127    ///
   128    int (CEF_CALLBACK *may_block)(struct _cef_stream_reader_t* self);
   129  } cef_stream_reader_t;
   130  
   131  
   132  ///
   133  // Create a new cef_stream_reader_t object from a file.
   134  ///
   135  CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
   136      const cef_string_t* fileName);
   137  
   138  ///
   139  // Create a new cef_stream_reader_t object from data.
   140  ///
   141  CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data,
   142      size_t size);
   143  
   144  ///
   145  // Create a new cef_stream_reader_t object from a custom handler.
   146  ///
   147  CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler(
   148      cef_read_handler_t* handler);
   149  
   150  
   151  ///
   152  // Structure the client can implement to provide a custom stream writer. The
   153  // functions of this structure may be called on any thread.
   154  ///
   155  typedef struct _cef_write_handler_t {
   156    ///
   157    // Base structure.
   158    ///
   159    cef_base_t base;
   160  
   161    ///
   162    // Write raw binary data.
   163    ///
   164    size_t (CEF_CALLBACK *write)(struct _cef_write_handler_t* self,
   165        const void* ptr, size_t size, size_t n);
   166  
   167    ///
   168    // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
   169    // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure.
   170    ///
   171    int (CEF_CALLBACK *seek)(struct _cef_write_handler_t* self, int64 offset,
   172        int whence);
   173  
   174    ///
   175    // Return the current offset position.
   176    ///
   177    int64 (CEF_CALLBACK *tell)(struct _cef_write_handler_t* self);
   178  
   179    ///
   180    // Flush the stream.
   181    ///
   182    int (CEF_CALLBACK *flush)(struct _cef_write_handler_t* self);
   183  
   184    ///
   185    // Return true (1) if this handler performs work like accessing the file
   186    // system which may block. Used as a hint for determining the thread to access
   187    // the handler from.
   188    ///
   189    int (CEF_CALLBACK *may_block)(struct _cef_write_handler_t* self);
   190  } cef_write_handler_t;
   191  
   192  
   193  ///
   194  // Structure used to write data to a stream. The functions of this structure may
   195  // be called on any thread.
   196  ///
   197  typedef struct _cef_stream_writer_t {
   198    ///
   199    // Base structure.
   200    ///
   201    cef_base_t base;
   202  
   203    ///
   204    // Write raw binary data.
   205    ///
   206    size_t (CEF_CALLBACK *write)(struct _cef_stream_writer_t* self,
   207        const void* ptr, size_t size, size_t n);
   208  
   209    ///
   210    // Seek to the specified offset position. |whence| may be any one of SEEK_CUR,
   211    // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure.
   212    ///
   213    int (CEF_CALLBACK *seek)(struct _cef_stream_writer_t* self, int64 offset,
   214        int whence);
   215  
   216    ///
   217    // Return the current offset position.
   218    ///
   219    int64 (CEF_CALLBACK *tell)(struct _cef_stream_writer_t* self);
   220  
   221    ///
   222    // Flush the stream.
   223    ///
   224    int (CEF_CALLBACK *flush)(struct _cef_stream_writer_t* self);
   225  
   226    ///
   227    // Returns true (1) if this writer performs work like accessing the file
   228    // system which may block. Used as a hint for determining the thread to access
   229    // the writer from.
   230    ///
   231    int (CEF_CALLBACK *may_block)(struct _cef_stream_writer_t* self);
   232  } cef_stream_writer_t;
   233  
   234  
   235  ///
   236  // Create a new cef_stream_writer_t object for a file.
   237  ///
   238  CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_file(
   239      const cef_string_t* fileName);
   240  
   241  ///
   242  // Create a new cef_stream_writer_t object for a custom handler.
   243  ///
   244  CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler(
   245      cef_write_handler_t* handler);
   246  
   247  
   248  #ifdef __cplusplus
   249  }
   250  #endif
   251  
   252  #endif  // CEF_INCLUDE_CAPI_CEF_STREAM_CAPI_H_