/* */
1 /*
2 * Copyright (c) 2005 Tama Communications Corporation
3 *
4 * This file is part of GNU GLOBAL.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _XARGS_H_
21 #define _XARGS_H_
22
23 #include <stdio.h>
24
25 #include "strbuf.h"
26
27 /**
28 * @name Types
29 */
30 /** @{ */
31 #define XARGS_FILE 1
32 #define XARGS_ARGV 2
33 #define XARGS_STRBUF 3
34 #define XARGS_FIND 4
35 /** @} */
36
37 /**
38 * @name Options
39 */
40 /** @{ */
41 #define XA_IGNORE_ERROR 1
42 #define XA_SKIP_NOTSOURCE 2
43 #define XA_PUT_GPATH 4
44 #define XA_TRIM_LINE 8
45 /** @} */
46
47 typedef struct {
48 /*
49 * common area
50 */
51 char *command;
52 FILE *pipe;
53 STRBUF *result;
54 int end_of_arg;
55 int unread;
56 int seqno; /**< sequencial number */
57 int type; /**< @NAME{XARGS_XXX} Types */
58 /**
59 * @name options
60 *
61 * These variables are set to directly by calling procedures. <br>
62 * This might have to be reviewed.
63 */
64 /** @{ */
65 int ignore_error;
66 int max_args; /**< 0: no limit, \>0: limit */
67 int put_gpath;
68 int trim_line;
69 int skip_assembly;
70 void (*verbose)(char *, int, int);
71 /** @} */
72
73 /**
74 * @name XARGS_FILE
75 */
76 /** @{ */
77 FILE *ip;
78 long fptr;
79 STRBUF *path;
80 /** @} */
81
82 /**
83 * @name XARGS_ARGV
84 */
85 /** @{ */
86 int argc;
87 char *const *argv;
88 /** @} */
89
90 /**
91 * @name XARGS_STRBUF
92 */
93 /** @{ */
94 char *curp;
95 char *endp;
96 /** @} */
97
98 /*
99 * XARGS_FIND
100 */
101 } XARGS;
102
103 XARGS *xargs_open_with_file(const char *, int, FILE *);
104 XARGS *xargs_open_with_argv(const char *, int, int, char *const *);
105 XARGS *xargs_open_with_strbuf(const char *, int, STRBUF *);
106 XARGS *xargs_open_with_find(const char *, int);
107 char *xargs_read(XARGS *);
108 void xargs_unread(XARGS *);
109 int xargs_close(XARGS *);
110
111 #endif /*! _XARGS_H_ */
/* */