This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconchita.c
50 lines (44 loc) · 1.44 KB
/
conchita.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
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include "read.h"
#include <limits.h>
#define BUFFERSIZE 16
//TODO
//Merge to writes only, no printf
int main(){
setvbuf(stdout, NULL, _IONBF, 0); //disable printf() buffer
char working_directory[PATH_MAX];
char visible_directory[FILENAME_MAX];
if(1){
char* home_dir = getenv("HOME");
unsigned int faux_index = 0; //segfault on static value. Really should've written this better.
if(home_dir!=NULL)
change_dir(home_dir, working_directory, visible_directory, &faux_index); //set to home dir, if dir is known
} //move to home dir automatically. disabled for debug
/*
char* home_dir = getenv("HOME");
unsigned int faux_index = 0; //segfault on static value. Really should've written this better.
if(home_dir!=NULL)
change_dir(home_dir, working_directory, visible_directory, &faux_index); //set to home dir, if dir is known
*/
// while loop stdin
//
// TODO
// current working directory
// enable directory changing
while(1){
print_prefix(visible_directory);
char* s = read_stdin(BUFFERSIZE);
parse(s,working_directory,visible_directory);
free(s);
} //main input loop
// Close stdin on exit
// close(STDIN_FILENO); //close input
close(1); //close stdout
//free(s);
return 0;
}