summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2007-06-22 12:48:06 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2007-06-22 12:48:06 +0000
commit6ecb06f97a511a15a62c577aedd51361e6b7d481 (patch)
treec02c54d7bacd2578ec66643ee4412557dab89924
parentaa202027c2f4fa7c5cfe4f2c807f75e0b8dfe298 (diff)
downloadrockbox-6ecb06f97a511a15a62c577aedd51361e6b7d481.tar.gz
rockbox-6ecb06f97a511a15a62c577aedd51361e6b7d481.zip
FS#7003 - Allow forward references of menus in tagnavi.config.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13685 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/tagtree.c48
-rw-r--r--apps/tagtree.h2
2 files changed, 39 insertions, 11 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 405274c6bd..03673fc653 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -69,6 +69,7 @@ enum variables {
69static long *uniqbuf; 69static long *uniqbuf;
70 70
71#define MAX_TAGS 5 71#define MAX_TAGS 5
72#define MAX_MENU_ID_SIZE 32
72 73
73static struct tagcache_search tcs, tcs2; 74static struct tagcache_search tcs, tcs2;
74static bool sort_inverse; 75static bool sort_inverse;
@@ -122,9 +123,8 @@ struct menu_entry {
122 123
123struct root_menu { 124struct root_menu {
124 char title[64]; 125 char title[64];
125 char id[32]; 126 char id[MAX_MENU_ID_SIZE];
126 int itemcount; 127 int itemcount;
127 struct root_menu *parent;
128 struct menu_entry *items[TAGMENU_MAX_ITEMS]; 128 struct menu_entry *items[TAGMENU_MAX_ITEMS];
129}; 129};
130 130
@@ -517,6 +517,7 @@ static bool parse_search(struct menu_entry *entry, const char *str)
517 struct search_instruction *inst = entry->si; 517 struct search_instruction *inst = entry->si;
518 char buf[MAX_PATH]; 518 char buf[MAX_PATH];
519 int i; 519 int i;
520 struct root_menu *new_menu;
520 521
521 strp = str; 522 strp = str;
522 523
@@ -542,12 +543,25 @@ static bool parse_search(struct menu_entry *entry, const char *str)
542 if (!strcasecmp(menus[i]->id, buf)) 543 if (!strcasecmp(menus[i]->id, buf))
543 { 544 {
544 entry->link = i; 545 entry->link = i;
545 menus[i]->parent = menu;
546 return true; 546 return true;
547 } 547 }
548 } 548 }
549 549
550 return false; 550 if (menu_count >= TAGMENU_MAX_MENUS)
551 {
552 logf("max menucount reached");
553 return false;
554 }
555
556 /* Allocate a new menu unless link is found. */
557 menus[menu_count] = buffer_alloc(sizeof(struct root_menu));
558 new_menu = menus[menu_count];
559 memset(new_menu, 0, sizeof(struct root_menu));
560 strncpy(new_menu->id, buf, MAX_MENU_ID_SIZE-1);
561 entry->link = menu_count;
562 ++menu_count;
563
564 return true;
551 } 565 }
552 566
553 if (entry->type != menu_next) 567 if (entry->type != menu_next)
@@ -738,7 +752,6 @@ static int parse_line(int n, const char *buf, void *parameters)
738 if (read_menu) 752 if (read_menu)
739 { 753 {
740 /* End the menu */ 754 /* End the menu */
741 menu_count++;
742 read_menu = false; 755 read_menu = false;
743 } 756 }
744 return 0; 757 return 0;
@@ -779,21 +792,36 @@ static int parse_line(int n, const char *buf, void *parameters)
779 return 0; 792 return 0;
780 } 793 }
781 794
782 menus[menu_count] = buffer_alloc(sizeof(struct root_menu)); 795 if (get_token_str(data, sizeof data) < 0)
783 menu = menus[menu_count];
784 memset(menu, 0, sizeof(struct root_menu));
785 if (get_token_str(menu->id, sizeof(menu->id)) < 0)
786 { 796 {
787 logf("%%menu_start id empty"); 797 logf("%%menu_start id empty");
788 return 0; 798 return 0;
789 } 799 }
800
801 menu = NULL;
802 for (i = 0; i < menu_count; i++)
803 {
804 if (!strcasecmp(menus[i]->id, data))
805 {
806 menu = menus[i];
807 }
808 }
809
810 if (menu == NULL)
811 {
812 menus[menu_count] = buffer_alloc(sizeof(struct root_menu));
813 menu = menus[menu_count];
814 ++menu_count;
815 memset(menu, 0, sizeof(struct root_menu));
816 strncpy(menu->id, data, MAX_MENU_ID_SIZE-1);
817 }
818
790 if (get_token_str(menu->title, sizeof(menu->title)) < 0) 819 if (get_token_str(menu->title, sizeof(menu->title)) < 0)
791 { 820 {
792 logf("%%menu_start title empty"); 821 logf("%%menu_start title empty");
793 return 0; 822 return 0;
794 } 823 }
795 logf("menu: %s", menu->title); 824 logf("menu: %s", menu->title);
796 menu->itemcount = 0;
797 read_menu = true; 825 read_menu = true;
798 break; 826 break;
799 827
diff --git a/apps/tagtree.h b/apps/tagtree.h
index 980dc0d0b4..e915dcec05 100644
--- a/apps/tagtree.h
+++ b/apps/tagtree.h
@@ -25,7 +25,7 @@
25 25
26#define TAGNAVI_VERSION "#! rockbox/tagbrowser/2.0" 26#define TAGNAVI_VERSION "#! rockbox/tagbrowser/2.0"
27#define TAGMENU_MAX_ITEMS 64 27#define TAGMENU_MAX_ITEMS 64
28#define TAGMENU_MAX_MENUS 16 28#define TAGMENU_MAX_MENUS 32
29#define TAGMENU_MAX_FMTS 32 29#define TAGMENU_MAX_FMTS 32
30 30
31enum table { root = 1, navibrowse, allsubentries, playtrack }; 31enum table { root = 1, navibrowse, allsubentries, playtrack };