aboutsummaryrefslogtreecommitdiff
path: root/runcap.h
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-07-19 11:29:27 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-07-19 11:29:27 +0300
commit651babfefa21536112cbcd799932b3595aeb2da4 (patch)
tree6922b7ea70642f4ce7a8cb97f01e62115e97d940 /runcap.h
parent3e59cfb01443a14962547ed75bbbaaefa25a7633 (diff)
downloadruncap-651babfefa21536112cbcd799932b3595aeb2da4.tar.gz
runcap-651babfefa21536112cbcd799932b3595aeb2da4.tar.bz2
Rename struct filecapture to stream_capture; portability fixes
Diffstat (limited to 'runcap.h')
-rw-r--r--runcap.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/runcap.h b/runcap.h
index c57f2e1..9537eee 100644
--- a/runcap.h
+++ b/runcap.h
@@ -17,22 +17,23 @@
17#ifndef _RUNCAP_H_ 17#ifndef _RUNCAP_H_
18# define _RUNCAP_H_ 1 18# define _RUNCAP_H_ 1
19 19
20struct filecapture 20struct stream_capture
21{ 21{
22 size_t fc_size; /* size of the buffer */ 22 int sc_fd; /* Input descriptor */
23 off_t fc_leng; /* total length of captured data */ 23 char *sc_base; /* buffer space */
24 size_t fc_nlines; /* number of captured lines */ 24 size_t sc_size; /* size of the buffer */
25 size_t fc_cur; /* current offset in buffer */ 25 size_t sc_level; /* number of characters currently in buffer */
26 char * fc_base; /* buffer space */ 26 size_t sc_cur; /* current offset in buffer */
27 size_t fc_level; /* number of characters currently in buffer */ 27 off_t sc_leng; /* total length of captured data */
28 void (*fc_linemon) (const char *, size_t, void *); 28 size_t sc_nlines; /* number of captured lines */
29 int sc_storfd; /* Storage file descriptor */
30
31 void (*sc_linemon) (const char *, size_t, void *);
29 /* Line monitor function */ 32 /* Line monitor function */
30 void *fc_monarg; /* Line monitor argument */ 33 void *sc_monarg; /* Line monitor argument */
31 int fc_tmpfd; /* Storage file descriptor */
32 int fc_fd; /* Input descriptor */
33}; 34};
34 35
35#define FC_BUFSIZE 4096 36#define STRCAP_BUFSIZE 4096
36 37
37enum { 38enum {
38 RUNCAP_STDIN, 39 RUNCAP_STDIN,
@@ -46,7 +47,7 @@ struct runcap
46 char *rc_program; /* [IN] (Path)name of the program to run */ 47 char *rc_program; /* [IN] (Path)name of the program to run */
47 char **rc_argv; /* [IN] Argument vector */ 48 char **rc_argv; /* [IN] Argument vector */
48 unsigned rc_timeout; /* [IN] Execution timeout */ 49 unsigned rc_timeout; /* [IN] Execution timeout */
49 struct filecapture rc_cap[RUNCAP_NBUF]; 50 struct stream_capture rc_cap[RUNCAP_NBUF];
50 /* rc_cap[RUNCAP_STDIN] - [IN], rest - [OUT] */ 51 /* rc_cap[RUNCAP_STDIN] - [IN], rest - [OUT] */
51 pid_t rc_pid; /* [OUT] - PID of the process */ 52 pid_t rc_pid; /* [OUT] - PID of the process */
52 int rc_status; /* [OUT] - Termination status */ 53 int rc_status; /* [OUT] - Termination status */
@@ -61,16 +62,16 @@ struct runcap
61#define RCF_STDERR_SIZE 0x0020 62#define RCF_STDERR_SIZE 0x0020
62#define RCF_STDERR_LINEMON 0x0040 63#define RCF_STDERR_LINEMON 0x0040
63 64
64int filecapture_init(struct filecapture *fc, size_t size); 65int stream_capture_init(struct stream_capture *fc, size_t size);
65void filecapture_free(struct filecapture *fc); 66void stream_capture_free(struct stream_capture *fc);
66 67
67int runcap(struct runcap *rc, int flags); 68int runcap(struct runcap *rc, int flags);
68void runcap_free(struct runcap *rc); 69void runcap_free(struct runcap *rc);
69 70
70static inline struct filecapture * 71static inline struct stream_capture *
71runcap_filecapture(struct runcap *rc, int stream) 72runcap_stream_capture(struct runcap *rc, int stream)
72{ 73{
73 struct filecapture *fp; 74 struct stream_capture *fp;
74 75
75 if (stream != RUNCAP_STDOUT && stream != RUNCAP_STDERR) { 76 if (stream != RUNCAP_STDOUT && stream != RUNCAP_STDERR) {
76 errno = EINVAL; 77 errno = EINVAL;
@@ -79,7 +80,7 @@ runcap_filecapture(struct runcap *rc, int stream)
79 80
80 fp = &rc->rc_cap[stream]; 81 fp = &rc->rc_cap[stream];
81 82
82 if (!fp->fc_base || fp->fc_size == 0) { 83 if (!fp->sc_base || fp->sc_size == 0) {
83 errno = EINVAL; 84 errno = EINVAL;
84 return NULL; 85 return NULL;
85 } 86 }

Return to:

Send suggestions and report system problems to the System administrator.