mirror of
https://github.com/dvorka/hstr.git
synced 2025-01-22 23:07:52 +08:00
Initial sync commit of favorites with fake loading.
This commit is contained in:
parent
dd18ef4dc8
commit
4d3f46e26e
2 changed files with 75 additions and 0 deletions
47
src/hstr_favorites.c
Normal file
47
src/hstr_favorites.c
Normal file
|
@ -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; i<favorites->count; i++) {
|
||||
free(favorites->items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
src/include/hstr_favorites.h
Normal file
28
src/include/hstr_favorites.h
Normal file
|
@ -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 <stdlib.h>
|
||||
|
||||
#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
|
Loading…
Reference in a new issue