File tree Expand file tree Collapse file tree 1 file changed +0
-36
lines changed Expand file tree Collapse file tree 1 file changed +0
-36
lines changed Original file line number Diff line number Diff line change 1
- #include <fcntl.h>
2
1
#include <stdbool.h>
3
2
#include <stdio.h>
4
3
#include <stdlib.h>
5
4
#include <string.h>
6
5
7
- struct Connection_t {
8
- int file_descriptor ;
9
- };
10
- typedef struct Connection_t Connection ;
11
-
12
- Connection * open_connection (char * filename ) {
13
- int fd = open (filename ,
14
- O_RDWR | // Read/Write mode
15
- O_CREAT , // Create file if it does not exist
16
- S_IWUSR | // Create file with user write permission
17
- S_IRUSR // Create file with user read permission
18
- );
19
-
20
- if (fd == -1 ) {
21
- printf ("Unable to open file '%s'\n" , filename );
22
- exit (EXIT_FAILURE );
23
- }
24
-
25
- Connection * connection = malloc (sizeof (Connection ));
26
- connection -> file_descriptor = fd ;
27
-
28
- return connection ;
29
- }
30
-
31
- char * get_db_filename (int argc , char * argv []) {
32
- if (argc < 2 ) {
33
- printf ("Must supply a filename for the database.\n" );
34
- exit (EXIT_FAILURE );
35
- }
36
- return argv [1 ];
37
- }
38
-
39
6
struct InputBuffer_t {
40
7
char * buffer ;
41
8
size_t buffer_length ;
@@ -69,9 +36,6 @@ void read_input(InputBuffer* input_buffer) {
69
36
}
70
37
71
38
int main (int argc , char * argv []) {
72
- char * db_filename = get_db_filename (argc , argv );
73
- Connection * connection = open_connection (db_filename );
74
-
75
39
InputBuffer * input_buffer = new_input_buffer ();
76
40
while (true) {
77
41
print_prompt ();
You can’t perform that action at this time.
0 commit comments