forked from CS429-S2022/CI-Lab-Student
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.c
More file actions
54 lines (47 loc) · 1.58 KB
/
Copy pathinterface.c
File metadata and controls
54 lines (47 loc) · 1.58 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**************************************************************************
* C S 429 EEL interpreter
*
* interface.c - Initialization and finalization routines for the interpreter.
*
* Copyright (c) 2021. S. Chatterjee, X. Shen, T. Byrd. All rights reserved.
* May not be used, modified, or copied without permission.
**************************************************************************/
#include "ci.h"
#include "ansicolors.h"
char default_ci_prompt[] = ANSI_BOLD ANSI_COLOR_BLUE "UTCS429-S2021-ci>>> " ANSI_RESET;
const char ci_logo[] = ANSI_COLOR_MAGENTA "`·.¸¸.·´¯`·.¸><(((º>" ANSI_RESET;
const char author[] = ANSI_BOLD ANSI_COLOR_RED "REPLACE THIS WITH YOUR NAME AND UT EID" ANSI_RESET;
static void print_init_msg(void) {
time_t t;
fprintf(outfile, "Welcome to the EEL interpreter\n\n");
fprintf(outfile, "%s\n\n", ci_logo);
fprintf(outfile, "Author: %s\n", author);
assert(time(&t) != -1);
fprintf(outfile, "Run begun at %s\n\n", ctime(&t));
}
void init(void) {
if (! ci_prompt) ci_prompt = default_ci_prompt;
init_table();
if (outfile != stdout) {
ci_prompt = "";
return;
}
print_init_msg();
fprintf(outfile, "%s", ci_prompt);
return;
}
void finalize(void) {
if (infile != NULL) {
fclose(infile);
}
if (outfile != stdout) return;
time_t t;
assert(time(&t) != -1);
delete_table();
fprintf(outfile, "Run ended at %s\n", ctime(&t));
fprintf(outfile, ANSI_BOLD "Goodbye!\n\n" ANSI_RESET);
return;
}
void flush(void) {
if (outfile != stdout) fflush(outfile);
}