Skip to content

Commit

Permalink
add some basic history function prototype in history header file
Browse files Browse the repository at this point in the history
  • Loading branch information
parsa011 committed Aug 26, 2021
1 parent 41a78e3 commit 4e21b68
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ lash
dist/
tags
.vscode/
.VSCodeCounter
39 changes: 39 additions & 0 deletions history.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "history.h"

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "lib/string/strlib.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(strcat(user_home_path,HISTORY_FILE_NAME),"w+");
}

/*
* Add a line to history file , if post == -1 will and to bottome of file
*/
void add_to_history(const char *line,int pos) {
}

/*
* Get a special line of history file
*/
void get_history(int line) {
}

/*
* Close history file
*/
void close_history() {
fclose(history_file);
}
18 changes: 18 additions & 0 deletions history.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>
#include "basics.h"

#define HISTORY_FILE_NAME ".lashhistory"

extern FILE *history_file;
extern char *history_file_path;
extern uint64 history_pointer;

void clear_history();
void where_history();
char *current_history();
void history_set_pos();
void init_lash_history();
void add_to_history(const char *,int);
void get_histroy(int);
void remove_history(int);
void close_history();
7 changes: 5 additions & 2 deletions lash.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
#include "prompt.h"
#include "input.h"
#include "glob.h"
#include "history.h"
#include "lib/string/strlib.h"

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

// initialize basics and read from config file
init_glob();

init_lash_history();
set_prompt("\033[033m[%P]\033[0m-(%u)-{%t} \n > ");

// Run loop
lash_loop();

close_history();

return EXIT_SUCCESS;
}
Expand Down Expand Up @@ -50,7 +54,6 @@ void lash_loop(void) {

if (args != NULL)
lash_execute_shell(args,special_args,fileredirect,pipeargs);// Proceed
//status = lash_execute(args);
cleanup();
free(line);
free(args);
Expand Down

0 comments on commit 4e21b68

Please sign in to comment.