summaryrefslogtreecommitdiffabout
path: root/runcap.h
authorSergey Poznyakoff <gray@gnu.org.ua>2017-07-17 12:19:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-07-17 15:25:30 (GMT)
commitdb60fd0122ec26a7ff354c395590abf919274181 (patch) (side-by-side diff)
treee33dc8805e3fcf3d5182fd1521af50b1a1fbe42b /runcap.h
downloadruncap-db60fd0122ec26a7ff354c395590abf919274181.tar.gz
runcap-db60fd0122ec26a7ff354c395590abf919274181.tar.bz2
Initial commit
Diffstat (limited to 'runcap.h') (more/less context) (ignore whitespace changes)
-rw-r--r--runcap.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/runcap.h b/runcap.h
new file mode 100644
index 0000000..b677f05
--- a/dev/null
+++ b/runcap.h
@@ -0,0 +1,69 @@
+/* runcap - run program and capture its output
+ Copyright (C) 2017 Sergey Poznyakoff
+
+ Runcap is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ Runcap is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Runcap. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _RUNCAP_H_
+# define _RUNCAP_H_ 1
+
+struct filecapture
+{
+ size_t fc_size;
+ size_t fc_leng;
+ size_t fc_nlines;
+ size_t fc_linestart;
+ char * fc_base;
+ size_t fc_level;
+ void (*fc_linemon) (const char *, size_t, void *);
+ void *fc_monarg;
+ int fc_tmpfd;
+ int fc_fd;
+};
+
+#define FC_BUFSIZE 4096
+
+enum {
+ RUNCAP_STDIN,
+ RUNCAP_STDOUT,
+ RUNCAP_STDERR,
+ RUNCAP_NBUF
+};
+
+struct runcap
+{
+ char *rc_program; /* [IN] (Path)name of the program to run */
+ char **rc_argv; /* [IN] Argument vector */
+ unsigned rc_timeout; /* [IN] Execution timeout */
+ struct filecapture rc_cap[RUNCAP_NBUF];
+ /* rc_cap[RUNCAP_STDIN] - [IN], rest - [OUT] */
+ pid_t rc_pid; /* [OUT] - PID of the process */
+ int rc_status; /* [OUT] - Termination status */
+ int rc_errno; /* [OUT] - Value of errno, if terminated on error */
+};
+
+#define RCF_PROGRAM 0x0001 /* rc_program is set */
+#define RCF_TIMEOUT 0x0002 /* rc_timeout is set */
+#define RCF_STDIN 0x0004 /* rc_cap[RUNCAP_STDIN] is set */
+#define RCF_STDOUT_SIZE 0x0008
+#define RCF_STDOUT_LINEMON 0x0010
+#define RCF_STDERR_SIZE 0x0020
+#define RCF_STDERR_LINEMON 0x0040
+
+int filecapture_init(struct filecapture *fc, size_t size);
+void filecapture_free(struct filecapture *fc);
+
+int runcap(struct runcap *rc, int flags);
+void runcap_free(struct runcap *rc);
+
+#endif

Return to:

Send suggestions and report system problems to the System administrator.