-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.c
73 lines (61 loc) · 1.31 KB
/
history.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "history.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include "lib/string/strlib.h"
#include "lib/file/filelib.h"
#include "glob.h"
FILE *history_file;
char *history_file_path;
uint64 history_poiner;
/*
* Open history file from the user home path , and create if dosnt exitst
*/
void init_lash_history() {
history_file_path = concat(2,user_home_path,HISTORY_FILE_NAME);
history_file = fopen(concat(2,user_home_path,HISTORY_FILE_NAME),"a+");
}
/*
* Add a line to history file , if post == -1 will and to bottome of file
*/
void add_to_history(const char *line,int pos) {
// TODO : before add we have to check if last added command is not equals to new line
if (pos == -1)
pos = file_linecount(history_file);
fseek(history_file,10,SEEK_SET);
fprintf(history_file,"%s\n",line);
savechanges();
}
/*
* Get a special line of history file
*/
void get_history(int line) {
}
/*
* Remove special line of history
*/
void remove_history(int line) {
}
void history_set_pos() {
}
char *current_history() {
return "";
}
/*
* Close history file
*/
void close_history() {
fclose(history_file);
}
/*
* Add changes to history file
*/
void savechanges() {
fflush(history_file);
}
/*
* make history epmty
*/
void clear_history() {
}