1 /*        $NetBSD: spawn_command.h,v 1.2 2017/02/14 01:16:49 christos Exp $     */
2 
3 #ifndef _SPAWN_COMMAND_H_INCLUDED_
4 #define _SPAWN_COMMAND_H_INCLUDED_
5 
6 /*++
7 /* NAME
8 /*        spawn_command 3h
9 /* SUMMARY
10 /*        run external command
11 /* SYNOPSIS
12 /*        #include <spawn_command.h>
13 /* DESCRIPTION
14 /* .nf
15 
16  /*
17   * Utility library.
18   */
19 #include <check_arg.h>
20 
21 /* Legacy API: type-unchecked arguments, internal use. */
22 #define SPAWN_CMD_END                   0         /* terminator */
23 #define SPAWN_CMD_ARGV                  1         /* command is array */
24 #define SPAWN_CMD_COMMAND     2         /* command is string */
25 #define SPAWN_CMD_STDIN                 3         /* mail_copy() flags */
26 #define SPAWN_CMD_STDOUT      4         /* mail_copy() sender */
27 #define SPAWN_CMD_STDERR      5         /* mail_copy() recipient */
28 #define SPAWN_CMD_UID                   6         /* privileges */
29 #define SPAWN_CMD_GID                   7         /* privileges */
30 #define SPAWN_CMD_TIME_LIMIT  8         /* time limit */
31 #define SPAWN_CMD_ENV                   9         /* extra environment */
32 #define SPAWN_CMD_SHELL                 10        /* alternative shell */
33 #define SPAWN_CMD_EXPORT      11        /* exportable parameters */
34 
35 /* Safer API: type-checked arguments, external use. */
36 #define CA_SPAWN_CMD_END      SPAWN_CMD_END
37 #define CA_SPAWN_CMD_ARGV(v)  SPAWN_CMD_ARGV, CHECK_PPTR(CA_SPAWN_CMD, char, (v))
38 #define CA_SPAWN_CMD_COMMAND(v)         SPAWN_CMD_COMMAND, CHECK_CPTR(CA_SPAWN_CMD, char, (v))
39 #define CA_SPAWN_CMD_STDIN(v) SPAWN_CMD_STDIN, CHECK_VAL(CA_SPAWN_CMD, int, (v))
40 #define CA_SPAWN_CMD_STDOUT(v)          SPAWN_CMD_STDOUT, CHECK_VAL(CA_SPAWN_CMD, int, (v))
41 #define CA_SPAWN_CMD_STDERR(v)          SPAWN_CMD_STDERR, CHECK_VAL(CA_SPAWN_CMD, int, (v))
42 #define CA_SPAWN_CMD_UID(v)   SPAWN_CMD_UID, CHECK_VAL(CA_SPAWN_CMD, uid_t, (v))
43 #define CA_SPAWN_CMD_GID(v)   SPAWN_CMD_GID, CHECK_VAL(CA_SPAWN_CMD, gid_t, (v))
44 #define CA_SPAWN_CMD_TIME_LIMIT(v) SPAWN_CMD_TIME_LIMIT, CHECK_VAL(CA_SPAWN_CMD, int, (v))
45 #define CA_SPAWN_CMD_ENV(v)   SPAWN_CMD_ENV, CHECK_PPTR(CA_SPAWN_CMD, char, (v))
46 #define CA_SPAWN_CMD_SHELL(v) SPAWN_CMD_SHELL, CHECK_CPTR(CA_SPAWN_CMD, char, (v))
47 #define CA_SPAWN_CMD_EXPORT(v)          SPAWN_CMD_EXPORT, CHECK_PPTR(CA_SPAWN_CMD, char, (v))
48 
49 CHECK_VAL_HELPER_DCL(CA_SPAWN_CMD, uid_t);
50 CHECK_VAL_HELPER_DCL(CA_SPAWN_CMD, int);
51 CHECK_VAL_HELPER_DCL(CA_SPAWN_CMD, gid_t);
52 CHECK_PPTR_HELPER_DCL(CA_SPAWN_CMD, char);
53 CHECK_CPTR_HELPER_DCL(CA_SPAWN_CMD, char);
54 
55 extern WAIT_STATUS_T spawn_command(int,...);
56 
57 /* LICENSE
58 /* .ad
59 /* .fi
60 /*        The Secure Mailer license must be distributed with this software.
61 /* AUTHOR(S)
62 /*        Wietse Venema
63 /*        IBM T.J. Watson Research
64 /*        P.O. Box 704
65 /*        Yorktown Heights, NY 10598, USA
66 /*--*/
67 
68 #endif
69