File src/hstr_favorites.c added (mode: 100644) (index 0000000..ee38533) |
|
1 |
|
/* |
|
2 |
|
============================================================================ |
|
3 |
|
Name : hstr_favorites.c |
|
4 |
|
Author : martin.dvorak@midforger.com |
|
5 |
|
Copyright : Apache 2.0 |
|
6 |
|
Description : Favorite commands. |
|
7 |
|
============================================================================ |
|
8 |
|
*/ |
|
9 |
|
|
|
10 |
|
#include "include/hstr_favorites.h" |
|
11 |
|
|
|
12 |
|
FavoriteItems *favorites; |
|
13 |
|
|
|
14 |
|
FavoriteItems *favorites_init() { |
|
15 |
|
favorites=malloc(sizeof(FavoriteItems)); |
|
16 |
|
return favorites; |
|
17 |
|
} |
|
18 |
|
|
|
19 |
|
FavoriteItems *favorites_load() { |
|
20 |
|
// TODO fake initialization |
|
21 |
|
favorites->count=3; |
|
22 |
|
favorites->items=malloc(sizeof(char *)*favorites->count); |
|
23 |
|
favorites->items[0]="a"; |
|
24 |
|
favorites->items[1]="b"; |
|
25 |
|
favorites->items[2]="c"; |
|
26 |
|
|
|
27 |
|
return favorites; |
|
28 |
|
} |
|
29 |
|
|
|
30 |
|
void favorites_add(char *newFavorite) { |
|
31 |
|
favorites->items=realloc(favorites->items, sizeof(char *)*favorites->count); |
|
32 |
|
favorites->items[favorites->count++]=newFavorite; |
|
33 |
|
} |
|
34 |
|
|
|
35 |
|
void favorites_save() { |
|
36 |
|
} |
|
37 |
|
|
|
38 |
|
void favorites_close() { |
|
39 |
|
if(favorites) { |
|
40 |
|
if(favorites->count) { |
|
41 |
|
int i; |
|
42 |
|
for(i=0; i<favorites->count; i++) { |
|
43 |
|
free(favorites->items[i]); |
|
44 |
|
} |
|
45 |
|
} |
|
46 |
|
} |
|
47 |
|
} |
File src/include/hstr_favorites.h added (mode: 100644) (index 0000000..b60c9d9) |
|
1 |
|
/* |
|
2 |
|
============================================================================ |
|
3 |
|
Name : hstr_favorites.h |
|
4 |
|
Author : martin.dvorak@midforger.com |
|
5 |
|
Copyright : Apache 2.0 |
|
6 |
|
Description : Favorite commands. |
|
7 |
|
============================================================================ |
|
8 |
|
*/ |
|
9 |
|
|
|
10 |
|
#ifndef _HSTR_FAVORITES_H_ |
|
11 |
|
#define _HSTR_FAVORITES_H_ |
|
12 |
|
|
|
13 |
|
#include <stdlib.h> |
|
14 |
|
|
|
15 |
|
#define HH_RC_FILE ".hhrc" |
|
16 |
|
|
|
17 |
|
typedef struct { |
|
18 |
|
char **items; |
|
19 |
|
unsigned count; |
|
20 |
|
} FavoriteItems; |
|
21 |
|
|
|
22 |
|
FavoriteItems *favorites_init(); |
|
23 |
|
FavoriteItems *favorites_load(); |
|
24 |
|
void favorites_add(); |
|
25 |
|
void favorites_save(); |
|
26 |
|
void favorites_close(); |
|
27 |
|
|
|
28 |
|
#endif |