File src/hashset.c changed (mode: 100644) (index 8f80fec..20ba53c) |
... |
... |
int hashset_put(HashSet * hs, const char *key, void *value) { |
59 |
59 |
return 0; |
return 0; |
60 |
60 |
} |
} |
61 |
61 |
|
|
62 |
|
newNode->key = strdup( key ); |
|
|
62 |
|
newNode->key = malloc(strlen(key)+1); |
|
63 |
|
strcpy(newNode->key, key); |
63 |
64 |
newNode->value = value; |
newNode->value = value; |
64 |
65 |
newNode->next = hs->lists[ listNum ]; |
newNode->next = hs->lists[ listNum ]; |
65 |
66 |
hs->lists[ listNum ] = newNode; |
hs->lists[ listNum ] = newNode; |
File src/hstr.c changed (mode: 100644) (index 7d685a8..5c8194f) |
... |
... |
static bool terminalHasColors=FALSE; |
63 |
63 |
static char screenLine[1000]; |
static char screenLine[1000]; |
64 |
64 |
|
|
65 |
65 |
int print_prompt(WINDOW *win) { |
int print_prompt(WINDOW *win) { |
66 |
|
char hostname[128]; |
|
|
66 |
|
char *hostname = get_hostname(); |
67 |
67 |
char *user = getenv(ENV_VAR_USER); |
char *user = getenv(ENV_VAR_USER); |
68 |
68 |
int xoffset = 1; |
int xoffset = 1; |
69 |
69 |
|
|
70 |
|
gethostname(hostname, sizeof hostname); |
|
71 |
70 |
mvwprintw(win, xoffset, Y_OFFSET_PROMPT, "%s@%s$ ", user, hostname); |
mvwprintw(win, xoffset, Y_OFFSET_PROMPT, "%s@%s$ ", user, hostname); |
72 |
71 |
refresh(); |
refresh(); |
73 |
72 |
|
|
File src/hstr_utils.c changed (mode: 100644) (index 093fc1a..4aa45ee) |
10 |
10 |
#include "include/hstr_utils.h" |
#include "include/hstr_utils.h" |
11 |
11 |
|
|
12 |
12 |
#define DEFAULT_COMMAND "pwd" |
#define DEFAULT_COMMAND "pwd" |
|
13 |
|
#define HOSTNAME_BUFFER 100 |
|
14 |
|
#define PROC_HOSTNAME "/proc/sys/kernel/hostname" |
13 |
15 |
|
|
14 |
16 |
void tiocsti() { |
void tiocsti() { |
15 |
17 |
char buf[] = DEFAULT_COMMAND; |
char buf[] = DEFAULT_COMMAND; |
|
... |
... |
void reverse_char_pointer_array(char **array, unsigned length) { |
43 |
45 |
} |
} |
44 |
46 |
} |
} |
45 |
47 |
|
|
46 |
|
|
|
|
48 |
|
char *get_hostname() |
|
49 |
|
{ |
|
50 |
|
char *b=malloc(HOSTNAME_BUFFER); |
|
51 |
|
if(access( PROC_HOSTNAME, F_OK ) != -1) { |
|
52 |
|
FILE *f = fopen(PROC_HOSTNAME, "r"); |
|
53 |
|
b=fgets(b, HOSTNAME_BUFFER, f); |
|
54 |
|
fclose(f); |
|
55 |
|
if(b) { |
|
56 |
|
b[strlen(b)-1]=0; |
|
57 |
|
return b; |
|
58 |
|
} |
|
59 |
|
} |
|
60 |
|
strcpy(b,"localhost"); |
|
61 |
|
return b; |
|
62 |
|
} |
47 |
63 |
|
|
File src/include/hstr_utils.h changed (mode: 100644) (index d7c86dd..2539087) |
15 |
15 |
#include <string.h> |
#include <string.h> |
16 |
16 |
#include <stdio.h> |
#include <stdio.h> |
17 |
17 |
#include <stdbool.h> |
#include <stdbool.h> |
|
18 |
|
#include <unistd.h> |
18 |
19 |
|
|
19 |
20 |
#define MIN(a,b) (((a)<(b))?(a):(b)) |
#define MIN(a,b) (((a)<(b))?(a):(b)) |
20 |
21 |
#define MAX(a,b) (((a)>(b))?(a):(b)) |
#define MAX(a,b) (((a)>(b))?(a):(b)) |
|
22 |
23 |
void tiocsti(); |
void tiocsti(); |
23 |
24 |
void fill_terminal_input(char* cmd, bool padding); |
void fill_terminal_input(char* cmd, bool padding); |
24 |
25 |
void reverse_char_pointer_array(char **array, unsigned length); |
void reverse_char_pointer_array(char **array, unsigned length); |
|
26 |
|
char *get_hostname(); |
25 |
27 |
|
|
26 |
28 |
#endif |
#endif |