- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / nacl_io.h
1 /* Copyright (c) 2012 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_NACL_IO_H_
6 #define LIBRARIES_NACL_IO_NACL_IO_H_
7
8 #include <ppapi/c/pp_instance.h>
9 #include <ppapi/c/ppb.h>
10
11 #include "sdk_util/macros.h"
12
13 EXTERN_C_BEGIN
14
15 /**
16  * Initialize nacl_io.
17  *
18  * NOTE: If you initialize nacl_io with this constructor, you cannot
19  * use any mounts that require PPAPI; e.g. persistent storage, etc.
20  */
21 void nacl_io_init();
22
23 /**
24  * Initialize nacl_io with PPAPI support.
25  *
26  * Usage:
27  *   PP_Instance instance;
28  *   PPB_GetInterface get_interface;
29  *   nacl_io_init(instance, get_interface);
30  *
31  * If you are using the PPAPI C interface:
32  *   |instance| is passed to your instance in the DidCreate function.
33  *   |get_interface| is passed to your module in the PPP_InitializeModule
34  *   function.
35  *
36  * If you are using the PPAPI C++ interface:
37  *   |instance| can be retrieved via the pp::Instance::pp_instance() method.
38  *   |get_interface| can be retrieved via
39  *       pp::Module::Get()->get_browser_interface()
40  */
41 void nacl_io_init_ppapi(PP_Instance instance,
42                         PPB_GetInterface get_interface);
43
44
45 /**
46  * Mount a new filesystem type.
47  *
48  * This function is declared in <sys/mount.h>, but we document it here
49  * because nacl_io is controlled primarily through mount(2)/umount(2).
50  *
51  * Some parameters are dependent on the filesystem type being mounted.
52  *
53  * The |data| parameter, if used, is always parsed as a string of comma
54  * separated key-value pairs:
55  *   e.g. "key1=param1,key2=param2"
56  *
57  *
58  * filesystem types:
59  *   "memfs": An in-memory filesystem.
60  *     source: Unused.
61  *     data: Unused.
62  *
63  *   "dev": A filesystem with various utility nodes. Some examples:
64  *          "null": equivalent to /dev/null.
65  *          "zero": equivalent to /dev/zero.
66  *          "urandom": equivalent to /dev/urandom.
67  *          "console[0-3]": logs to the JavaScript console with varying log
68  *              levels.
69  *          "tty": Posts a message to JavaScript, which will send a "message"
70  *              event from this module's embed element.
71  *     source: Unused.
72  *     data: Unused.
73  *
74  *   "html5fs": A filesystem that uses PPAPI FileSystem interface, which can be
75  *              read in JavaScript via the HTML5 FileSystem API. This mount
76  *              provides the use of persistent storage. Please read the
77  *              documentation in ppapi/c/ppb_file_system.h for more information.
78  *     source: Unused.
79  *     data: A string of parameters:
80  *       "type": Which type of filesystem to mount. Valid values are
81  *           "PERSISTENT" and "TEMPORARY". The default is "PERSISTENT".
82  *       "expected_size": The expected file-system size. Note that this does
83  *           not request quota -- you must do that from JavaScript.
84  *
85  *   "httpfs": A filesystem that reads from a URL via HTTP.
86  *     source: The root URL to read from. All paths read from this filesystem
87  *             will be appended to this root.
88  *             e.g. If source == "http://example.com/path", reading from
89  *             "foo/bar.txt" will attempt to read from the URL
90  *             "http://example.com/path/foo/bar.txt".
91  *     data: A string of parameters:
92  *       "allow_cross_origin_requests": If "true", then reads from this
93  *           filesystem will follow the CORS standard for cross-origin requests.
94  *           See http://www.w3.org/TR/access-control.
95  *       "allow_credentials": If "true", credentials are sent with cross-origin
96  *           requests. If false, no credentials are sent with the request and
97  *           cookies are ignored in the response.
98  *       All other key/value pairs are assumed to be headers to use with
99  *       HTTP requests.
100  *
101  *   "passthroughfs": A filesystem that passes all requests through to the
102  *                    underlying NaCl calls. The primary use of this filesystem
103  *                    is to allow reading NMF resources.
104  *     source: Unused.
105  *     data: Unused.
106  *
107  *
108  * @param[in] source Depends on the filesystem type. See above.
109  * @param[in] target The absolute path to mount the filesystem.
110  * @param[in] filesystemtype The name of the filesystem type to mount. See
111  *     above for examples.
112  * @param[in] mountflags Unused.
113  * @param[in] data Depends on the filesystem type. See above.
114  * @return 0 on success, -1 on failure (with errno set).
115  *
116  * int mount(const char* source, const char* target, const char* filesystemtype,
117  *         unsigned long mountflags, const void *data) NOTHROW;
118  */
119
120 EXTERN_C_END
121
122 #endif  /* LIBRARIES_NACL_IO_NACL_IO_H_ */