Update Red Hat Copyright Notices
[nbdkit.git] / plugins / sh / call.h
blob296f1fe22f27da5a8036e6d2ac234cbb07f03fb9
1 /* nbdkit
2 * Copyright Red Hat
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of Red Hat nor the names of its contributors may be
16 * used to endorse or promote products derived from this software without
17 * specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
33 #ifndef NBDKIT_CALL_H
34 #define NBDKIT_CALL_H
36 #include "nbdkit-string.h"
38 /* eval and sh plugin call this in .load() to initialize some things
39 * in the shared call code. This also creates the tmpdir[] directory.
41 extern void call_load (void);
42 extern char tmpdir[];
44 /* Similarly the plugins should call this in their .unload()
45 * functions. It deletes tmpdir amongst other things.
47 extern void call_unload (void);
49 /* Exit codes. */
50 typedef enum exit_code {
51 OK = 0,
52 ERROR = 1, /* all script error codes are mapped to this */
53 MISSING = 2, /* method missing */
54 RET_FALSE = 3, /* script exited with code 3 meaning false */
55 SHUTDOWN_OK = 4, /* call nbdkit_shutdown(), then return OK */
56 SHUTDOWN_ERR = 5, /* call nbdkit_shutdown(), then return ERROR */
57 DISC_FORCE = 6, /* call nbdkit_disconnect(true); return is irrelevant */
58 DISC_SOFT_OK = 7, /* call nbdkit_disconnect(false), return OK */
59 DISC_SOFT_ERR = 8, /* call nbdkit_disconnect(false), return ERROR */
60 /* Adjust methods.c:sh_dump_plugin when defining new codes */
61 /* 9-15 are reserved since 1.34; handle like ERROR for now */
62 } exit_code;
64 extern exit_code call (const char **argv)
65 __attribute__ ((__nonnull__ (1)));
66 extern exit_code call_read (string *rbuf, const char **argv)
67 __attribute__ ((__nonnull__ (1, 2)));
68 extern exit_code call_write (const char *wbuf, size_t wbuflen,
69 const char **argv)
70 __attribute__ ((__nonnull__ (1, 3)));
72 #endif /* NBDKIT_CALL_H */