From 4d3f46e26e8322c49f227c6b0ff30443da82a168 Mon Sep 17 00:00:00 2001 From: Martin Dvorak Date: Mon, 17 Mar 2014 00:04:51 +0100 Subject: [PATCH] Initial sync commit of favorites with fake loading. --- src/hstr_favorites.c | 47 ++++++++++++++++++++++++++++++++++++ src/include/hstr_favorites.h | 28 +++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/hstr_favorites.c create mode 100644 src/include/hstr_favorites.h diff --git a/src/hstr_favorites.c b/src/hstr_favorites.c new file mode 100644 index 0000000..ee38533 --- /dev/null +++ b/src/hstr_favorites.c @@ -0,0 +1,47 @@ +/* + ============================================================================ + Name : hstr_favorites.c + Author : martin.dvorak@midforger.com + Copyright : Apache 2.0 + Description : Favorite commands. + ============================================================================ +*/ + +#include "include/hstr_favorites.h" + +FavoriteItems *favorites; + +FavoriteItems *favorites_init() { + favorites=malloc(sizeof(FavoriteItems)); + return favorites; +} + +FavoriteItems *favorites_load() { + // TODO fake initialization + favorites->count=3; + favorites->items=malloc(sizeof(char *)*favorites->count); + favorites->items[0]="a"; + favorites->items[1]="b"; + favorites->items[2]="c"; + + return favorites; +} + +void favorites_add(char *newFavorite) { + favorites->items=realloc(favorites->items, sizeof(char *)*favorites->count); + favorites->items[favorites->count++]=newFavorite; +} + +void favorites_save() { +} + +void favorites_close() { + if(favorites) { + if(favorites->count) { + int i; + for(i=0; icount; i++) { + free(favorites->items[i]); + } + } + } +} diff --git a/src/include/hstr_favorites.h b/src/include/hstr_favorites.h new file mode 100644 index 0000000..b60c9d9 --- /dev/null +++ b/src/include/hstr_favorites.h @@ -0,0 +1,28 @@ +/* + ============================================================================ + Name : hstr_favorites.h + Author : martin.dvorak@midforger.com + Copyright : Apache 2.0 + Description : Favorite commands. + ============================================================================ +*/ + +#ifndef _HSTR_FAVORITES_H_ +#define _HSTR_FAVORITES_H_ + +#include + +#define HH_RC_FILE ".hhrc" + +typedef struct { + char **items; + unsigned count; +} FavoriteItems; + +FavoriteItems *favorites_init(); +FavoriteItems *favorites_load(); +void favorites_add(); +void favorites_save(); +void favorites_close(); + +#endif