-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_utils.c
61 lines (50 loc) · 1.17 KB
/
list_utils.c
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
/**
* authors: Dillon O'Leary
* Ezra Boley
*/
#include "list_utils.h"
void append_build_spec(BuildSpecList *bsl, BuildSpec *bs) {
if (bsl->len == 0) {
bsl->frstBS = bs;
bsl->lstBS = bs;
} else {
bsl->lstBS->nxtBuildSpec = bs;
bsl->lstBS = bs;
}
bsl->len++;
}
BuildSpec *get_last_build_spec(BuildSpecList *bsl) {
return bsl->lstBS;
}
void append_cmd_to_buildspec(BuildSpec *bs, Command *cmd) {
if (bs->cmds->len == 0) {
bs->cmds->frstCmd = cmd;
bs->cmds->lstCmd = cmd;
} else {
bs->cmds->lstCmd->nxtCmd = cmd;
bs->cmds->lstCmd = cmd;
}
bs->cmds->len++;
}
Command *get_last_cmd(BuildSpec *bs) {
return bs->cmds->lstCmd;
}
void append_cmd_to_cmdlist(CommandList *cmdlist, Command *cmd) {
if (cmdlist->len == 0) {
cmdlist->frstCmd = cmd;
cmdlist->lstCmd = cmd;
} else {
cmdlist->lstCmd->nxtCmd = cmd;
cmdlist->lstCmd = cmd;
}
cmdlist->len++;
}
Command *next_cmd (Command *cmd) {
return cmd->nxtCmd;
}
BuildSpec *next_BS (BuildSpec *bs) {
return bs->nxtBuildSpec;
}
void init_cmd_list(CommandList *cmdList) {
cmdList->len = 0;
}