-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.h
42 lines (30 loc) · 1.49 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
// UCLA CS 111 Lab 1 command interface
#ifndef COMMAND_H
#define COMMAND_H
#include <stdbool.h>
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);
/* 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. */
void 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);
//All below are declared in read-command.c
/* Returns an array where each index holds the commands that the command with
that index depends on.
e.g. element 5 holds the id's of the commands command 5 must wait on */
int** set_dependencies(command_t* commands, int num_commands);
/* Returns true if no dependencies overlap.
Overlapping means writing to the same file, or reading from a file the other writes to*/
bool check_dependencies(command_t c1, command_t c2);
#endif