File: shellcommand.h

package info (click to toggle)
librudiments0 0.27-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,528 kB
  • ctags: 2,284
  • sloc: cpp: 14,657; sh: 7,547; ansic: 2,664; makefile: 945; xml: 15
file content (71 lines) | stat: -rw-r--r-- 2,051 bytes parent folder | download
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
// FIXME: implement this class

// Copyright (c) 2003 David Muse
// See the COPYING file for more information.

#ifndef RUDIMENTS_SHELLCOMMAND_H
#define RUDIMENTS_SHELLCOMMAND_H

#include <rudiments/private/shellcommandincludes.h>

// The shellcommand class provides methods for running commands, reading their
// output or writing input to them.

// wrap:
//	stdlib.h - system()
//	unistd.h - execve()/fexecve(),execv(),execle(),execl(),execvp(),execlp()
//	stdio.h - popen(), pclose()
//	not in many systems -
//		spawn.h - posix spawn interface
//				posix_spawn()
//				posix_spawnp()
//				posix_spawnattr_init()
//				posix_spawnattr_destroy()
//				posix_spawnattr_getsigdefault()
//				posix_spawnattr_setsigdefault()
//				posix_spawnattr_getsigmask()
//				posix_spawnattr_setsigmask()
//				posix_spawnattr_getflags()
//				posix_spawnattr_setflags()
//				posix_spawnattr_getpgroup()
//				posix_spawnattr_setpgroup()
//				posix_spawnattr_getschedpolicy()
//				posix_spawnattr_setschedpolicy()
//				posix_spawnattr_getschedparam()
//				posix_spawnattr_setschedparam()
//				posix_spawn_file_actions_init()
//				posix_spawn_file_actions_destroy()
//				posix_spawn_file_actions_addopen()
//				posix_spawn_file_actions_addclose()
//				posix_spawn_file_actions_adddup2()

class shellcommand {
	public:
		int	run(const char *command);
			// Runs "command".

		int	getStandardInput();
			// If run() succeeded, returns the file descriptor
			// of the standard input of the command or 0 otherwise.

		int	getStandardOutput();
			// If run() succeeded, returns the file descriptor
			// of the standard output of the command or 0 otherwise.

		int	getStandardError();
			// If run() succeeded, returns the file descriptor
			// of the standard error of the command or 0 otherwise.

		int	close();
			// Closes the previously run command.
			//
			// Returns 1 on success and 0 on failure.

	#include <rudiments/private/shellcommand.h>
};

#ifdef ENABLE_RUDIMENTS_INLINES
	#include <rudiments/private/shellcommandinlines.h>
#endif

#endif