mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-11-13 04:13:19 +00:00
Settings terminées
This commit is contained in:
parent
40fda08947
commit
e72f28c95c
@ -72,7 +72,7 @@ void fishLoop(Settings * settings){
|
||||
pipe_redirection *r = getRedirection();
|
||||
|
||||
do {
|
||||
printf("%s", settings->PS1);
|
||||
printPS(settings->PS1, settings);
|
||||
line = fishReadLine();
|
||||
|
||||
r->to_use = 0;
|
||||
|
@ -46,6 +46,45 @@ void freeSettings(Settings *settings){
|
||||
}
|
||||
}
|
||||
|
||||
void printPS(char* PS, Settings* s){
|
||||
int buf= FISH_BUFFER_SIZE;
|
||||
int i = 0;
|
||||
int slashed = 0;
|
||||
char* path = NULL;
|
||||
while (PS[i] != '\0'){
|
||||
if(slashed){
|
||||
switch (PS[i])
|
||||
{
|
||||
case 'u':
|
||||
printf("%s",s->passwd->pw_name);
|
||||
break;
|
||||
case 'p':
|
||||
path = (char*) malloc(sizeof(char)*buf);
|
||||
while(getcwd(path,buf) == NULL){
|
||||
buf+=FISH_BUFFER_SIZE;
|
||||
free(path);
|
||||
path = (char*) malloc(sizeof(char)*buf);
|
||||
}
|
||||
printf("%s",path);
|
||||
free(path);
|
||||
path = NULL;
|
||||
break;
|
||||
default:printf("%c",PS[i]);
|
||||
|
||||
}
|
||||
slashed = 0;
|
||||
}
|
||||
else if(PS[i] == '\\'){
|
||||
slashed = 1;
|
||||
}else{
|
||||
printf("%c",PS[i]);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
char* extractVariable(char* filename, char* var){
|
||||
FILE *file = fopen ( filename, "r" );
|
||||
int var_size = strlen(var);
|
||||
@ -81,3 +120,5 @@ char* extractVariable(char* filename, char* var){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
Settings * getSettings(); //TESTEDssssss
|
||||
void freeSettings(Settings *settings); //TESTED
|
||||
char* extractVariable(char* filename, char* var);//TESTED
|
||||
void printPS(char* PS, Settings* s);
|
||||
|
||||
#endif //FISH_FISH_SETTINGS_H
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user