Skip to content

Commit 4e21b68

Browse files
committed
add some basic history function prototype in history header file
1 parent 41a78e3 commit 4e21b68

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ lash
44
dist/
55
tags
66
.vscode/
7+
.VSCodeCounter

history.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "history.h"
2+
3+
#include <string.h>
4+
#include <stdio.h>
5+
#include <stdlib.h>
6+
7+
#include "lib/string/strlib.h"
8+
#include "glob.h"
9+
10+
FILE *history_file;
11+
char *history_file_path;
12+
uint64 history_poiner;
13+
14+
/*
15+
* Open history file from the user home path , and create if dosnt exitst
16+
*/
17+
void init_lash_history() {
18+
history_file_path = concat(2,user_home_path,HISTORY_FILE_NAME);
19+
history_file = fopen(strcat(user_home_path,HISTORY_FILE_NAME),"w+");
20+
}
21+
22+
/*
23+
* Add a line to history file , if post == -1 will and to bottome of file
24+
*/
25+
void add_to_history(const char *line,int pos) {
26+
}
27+
28+
/*
29+
* Get a special line of history file
30+
*/
31+
void get_history(int line) {
32+
}
33+
34+
/*
35+
* Close history file
36+
*/
37+
void close_history() {
38+
fclose(history_file);
39+
}

history.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
#include "basics.h"
3+
4+
#define HISTORY_FILE_NAME ".lashhistory"
5+
6+
extern FILE *history_file;
7+
extern char *history_file_path;
8+
extern uint64 history_pointer;
9+
10+
void clear_history();
11+
void where_history();
12+
char *current_history();
13+
void history_set_pos();
14+
void init_lash_history();
15+
void add_to_history(const char *,int);
16+
void get_histroy(int);
17+
void remove_history(int);
18+
void close_history();

lash.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
#include "prompt.h"
1313
#include "input.h"
1414
#include "glob.h"
15+
#include "history.h"
1516
#include "lib/string/strlib.h"
1617

1718
int main(int argc, char **arcv) {
1819

20+
// initialize basics and read from config file
1921
init_glob();
20-
22+
init_lash_history();
2123
set_prompt("\033[033m[%P]\033[0m-(%u)-{%t} \n > ");
2224

2325
// Run loop
2426
lash_loop();
27+
28+
close_history();
2529

2630
return EXIT_SUCCESS;
2731
}
@@ -50,7 +54,6 @@ void lash_loop(void) {
5054

5155
if (args != NULL)
5256
lash_execute_shell(args,special_args,fileredirect,pipeargs);// Proceed
53-
//status = lash_execute(args);
5457
cleanup();
5558
free(line);
5659
free(args);

0 commit comments

Comments
 (0)