-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.h
executable file
·46 lines (35 loc) · 1.93 KB
/
command.h
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
// UCLA CS 111 Lab 1 command interface
// Copyright 2012-2014 Paul Eggert.
// This program 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.
// This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
typedef struct command *command_t;
typedef struct command_stream *command_stream_t;
/* Create a command stream from GETBYTE and ARG. A reader of
the command stream will invoke GETBYTE (ARG) to get the next byte.
GETBYTE will return the next input byte, or a negative number
(setting errno) on failure. */
command_stream_t make_command_stream (int (*getbyte) (void *), void *arg);
/* Prepare for profiling to the file FILENAME. If FILENAME is null or
cannot be written to, set errno and return -1. Otherwise, return a
nonnegative integer flag useful as an argument to
execute_command. */
int prepare_profiling (char const *filename);
/* Read a command from STREAM; return it, or NULL on EOF. If there is
an error, report the error and exit instead of returning. */
command_t read_command_stream (command_stream_t stream);
/* Print a command to stdout, for debugging. */
void print_command (command_t);
/* Execute a command. Use profiling according to the flag; do not profile
if the flag is negative. */
void execute_command (command_t, int);
/* Return the exit status of a command, which must have previously
been executed. Wait for the command, if it is not already finished. */
int command_status (command_t);