-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.h
More file actions
32 lines (24 loc) · 1.06 KB
/
command.h
File metadata and controls
32 lines (24 loc) · 1.06 KB
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
// UCLA CS 111 Lab 1 command interface
#ifndef COMMAND_H
#define COMMAND_H
#include <stdbool.h>
#include "stack.h"
typedef struct command* command_t;
typedef struct stack* cmd_stk_t;
typedef cmd_stk_t 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);
/* 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 "time travel" if the flag is set. */
int execute_command (command_t);
/* 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);
#endif