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 pathread.h
63 lines (43 loc) · 1.82 KB
/
read.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef READ_H
#define READ_H
//print out the [user]$~ prefix
void print_prefix(const char* visible_directory);
//store the last part of the directory in a string
void getvwd(const char* current_path,char* visible_directory);
// return the index of the next nonspace in a string
//
unsigned int skip_space(const char* s, unsigned int index);
// return a dynamic char* of the next word in a string
char* next_word(const char* s, unsigned int* index);
//parse and execute inbuilt commands
short parse_builtin(const char* s, char* working_directory, char* visible_directory);
//TODO
//what does this func do
void parse(const char* s, char* working_directory, char* visible_directory);
//parse borrowed from brennen.io
char **lsh_split_line(char *line, int *position);
//count all words in s
unsigned int count_words(const char* s);
//free 2d array
void free_2d(char** s,const unsigned short argc);
void change_dir(const char *s,char *working_directory,char *visible_directory,unsigned int *index_of_next_word);
//fork, look for bin, exec, return 1 for success, 0 no file, -1 failed exec
short fork_exec(const char* s);
char** shorten_arg(char** argv, int arg_amount);
// resize an array with defined amount of bytes
//output is dynamic string, don't forget to free(s)
//@param s string to increment
//@param size amount of bytes to add
char* resize(char* s, unsigned int size);
//read standard input into a string
//output is dynamic string, don't forget to free(s)
//@param BUFFERSIZE size for buffer
//@return char* string containing standard in.
char* read_stdin(int buffer_size);
//DEBUG FUNCTIONS
//#############################################################################
void print2d(char** argv, const int argc);
//easy write to stdout
void fprint(const char* s);
void fdprint(const char* s);
#endif