1 /* buildcmd.[ch] -- build command lines from a stream of arguments
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * Written by James Youngman.
22 #ifndef INC_BUILDCMD_H
23 #define INC_BUILDCMD_H 1
27 /* Number of valid elements in `cmd_argv'. */
30 /* The list of args being built. */
31 char **cmd_argv
; /* NULL */
33 /* Number of elements allocated for `cmd_argv'. */
36 /* Storage for elements of `cmd_argv'. */
39 /* Number of chars being used in `cmd_argv'. */
42 /* Number of chars being used in `cmd_argv' for the initial args.. */
43 int cmd_initial_argv_chars
;
45 /* User context information. */
53 struct buildcmd_control
55 /* If true, exit if lines_per_exec or args_per_exec is exceeded. */
56 int exit_if_size_exceeded
; /* false */
58 /* The maximum number of characters that can be used per command line. */
61 /* The length of `replace_pat'. */
64 /* If nonzero, then instead of putting the args from stdin at
65 the end of the command argument list, they are each stuck into the
66 initial args, replacing each occurrence of the `replace_pat' in the
70 /* Number of initial arguments given on the command line. */
71 int initial_argc
; /* 0 */
74 int (*exec_callback
)(const struct buildcmd_control
*, struct buildcmd_state
*);
76 /* If nonzero, the maximum number of nonblank lines from stdin to use
78 long lines_per_exec
; /* 0 */
80 /* The maximum number of arguments to use per command line. */
81 long args_per_exec
; /* 1024 */
87 extern void bc_do_insert (const struct buildcmd_control
*ctl
,
88 struct buildcmd_state
*state
,
89 char *arg
, size_t arglen
,
90 const char *prefix
, size_t pfxlen
,
91 const char *linebuf
, size_t lblen
,
94 extern void bc_push_arg (const struct buildcmd_control
*ctl
,
95 struct buildcmd_state
*state
,
96 const char *arg
, size_t len
,
97 const char *prefix
, size_t pfxlen
,
100 extern void bc_init_state(const struct buildcmd_control
*ctl
,
101 struct buildcmd_state
*state
,
103 extern void bc_init_controlinfo(struct buildcmd_control
*ctl
);
104 extern long bc_get_arg_max(void);
105 extern void bc_clear_args(const struct buildcmd_control
*ctl
,
106 struct buildcmd_state
*state
);