about summary refs log tree commit diff
path: root/lib/pm_system.h
blob: 58e17f0581434dce48bc23defd5992f3bc3b5a01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef PM_SYSTEM_H_INCLUDED
#define PM_SYSTEM_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif
#if 0
} /* to fake out automatic code indenters */
#endif


void
pm_system2_vp(const char *    const progName,
              const char **   const argArray,
              void stdinFeeder(int, void *),
              void *          const feederParm,
              void stdoutAccepter(int, void *),
              void *          const accepterParm,
              int *           const termStatusP);

void
pm_system2_lp(const char *    const progName,
              void stdinFeeder(int, void *),
              void *          const feederParm,
              void stdoutAccepter(int, void *),
              void *          const accepterParm,
              int *           const termStatusP,
              ...);

void
pm_system2(void                  stdinFeeder(int, void *),
           void *          const feederParm,
           void                  stdoutAccepter(int, void *),
           void *          const accepterParm,
           const char *    const shellCommand,
           int *           const termStatusP);

void
pm_system_vp(const char *    const progName,
             const char **   const argArray,
             void stdinFeeder(int, void *),
             void *          const feederParm,
             void stdoutAccepter(int, void *),
             void *          const accepterParm);

void
pm_system_lp(const char *    const progName,
             void stdinFeeder(int, void *),
             void *          const feederParm,
             void stdoutAccepter(int, void *),
             void *          const accepterParm,
             ...);

void
pm_system(void                  stdinFeeder(int, void *),
          void *          const feederParm,
          void                  stdoutAccepter(int, void *),
          void *          const accepterParm,
          const char *    const shellCommand);

const char *
pm_termStatusDesc(int const termStatus);


/* The following are Standard Input feeders and Standard Output accepters
   for pm_system() etc.
*/
void
pm_feed_null(int    const pipeToFeedFd,
             void * const feederParm);

void
pm_accept_null(int    const pipetosuckFd,
               void * const accepterParm);

struct bufferDesc {
    /* This is just a parameter for the routines below */
    unsigned int    size;
       /* For a read operation, number amount of space available to store
          data read.  For a write operation, number of bytes of data available.
       */
    unsigned char * buffer;
    unsigned int *  bytesTransferredP;
        /* The function returns the number of bytes placed in the buffer or
           extracted from the buffer here.  NULL if you don't want that
           information.
        */
};


/* The struct name "bufferDesc", without the "pm" namespace, is an unfortunate
   historical accident.
*/
typedef struct bufferDesc pm_bufferDesc;

void
pm_feed_from_memory(int    const pipeToFeedFd,
                    void * const feederParm);

void
pm_accept_to_memory(int    const pipetosuckFd,
                    void * const accepterParm);

#ifdef __cplusplus
}
#endif

#endif