Index: apps/plugins/viewers.config
===================================================================
--- apps/plugins/viewers.config (revision 13775)
+++ apps/plugins/viewers.config (working copy)
@@ -1,3 +1,5 @@
+html,viewers/HTML_Parser,7
+htm,viewers/HTML_Parser,7
ch8,viewers/chip8,0
txt,viewers/viewer,1
nfo,viewers/viewer,1
Index: apps/plugins/SOURCES
===================================================================
--- apps/plugins/SOURCES (revision 13775)
+++ apps/plugins/SOURCES (working copy)
@@ -1,4 +1,5 @@
/* plugins common to all models */
+HTML_Parser.c
battery_bench.c
chessclock.c
credits.c
Index: apps/plugins/HTML_Parser.c
===================================================================
--- apps/plugins/HTML_Parser.c (revision 0)
+++ apps/plugins/HTML_Parser.c (revision 0)
@@ -0,0 +1,271 @@
+/*****************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: HTML_Parser $
+ *
+ * Copyright (C) 2007 Gerritt Gonzales
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * This program will parse html and htm files, suitable for reading
+ * in the text viewer.
+ * More formatting to come.
+ * Usage: Select a html or htm file, then select the txt file created
+ * for viewing.
+ ****************************************************************************/
+
+#include "plugin.h"
+
+/* This macros must always be included. Should be placed at the top by
+ convention, although the actual position doesn't matter */
+PLUGIN_HEADER
+
+/* here is a global api struct pointer. while not strictly necessary,
+ it's nice not to have to pass the api pointer in all function calls
+ in the plugin */
+static struct plugin_api* rb;
+#define plug_QUIT BUTTON_POWER
+#define EXT_UNKNOWN -1
+#define EXT_l 0
+#define EXT_m 1
+
+void cleanup(void *parameter){
+ (void)parameter;
+ rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
+}
+
+static int getExt(char *filename){
+ /* requires additional extention checking here */
+ switch (filename[rb->strlen(filename)-1]){
+ /*html*/
+ case 'l': return EXT_l;
+ /*htm*/
+ case 'm': return EXT_m;
+ /*anything else*/
+ default: return EXT_UNKNOWN;
+ }
+ return EXT_UNKNOWN; /*error*/
+}
+
+int tag(int IN, int OUT){
+ int inc=0;
+ int dec=0;
+ int size_of=1;
+ char buff[1];
+
+ dec=rb->read(IN, &buff[0], size_of);
+ inc=inc+dec;
+ if(dec==0){
+ return inc;
+ }
+
+ /* tag formatting here */
+ /* looking for
and
tags also get by default*/ + if((buff[0]=='b') || (buff[0]=='B')){ + //check for r + dec=rb->read(IN, &buff[0], size_of); + inc=inc+dec; + if(dec==0){ + return inc; + } + if((buff[0]=='r') || (buff[0]=='R')){ + rb->write(OUT, "\n", 1); + } + if((buff[0]=='>')){ + /* Some possible formatting for the Bold tag */ + /* to much effort to look for the end tag */ + /* + rb->write(OUT, "\n", 1); + rb->write(OUT, "*", 1); + rb->write(OUT, "\n", 1); + */ + } + }else{ + /* some formatting for the
paragragh tag */
+ if((buff[0]=='P') || (buff[0]=='p')){
+ rb->write(OUT, "\n", 1);
+ rb->write(OUT, "\n", 1);
+ /* rb->write(OUT, " ", 1); */
+ }
+ }
+ while (buff[0]!='>'){
+ dec=rb->read(IN, &buff[0], size_of);
+ inc=inc+dec;
+ if(dec==0){
+ return inc;
+ }
+ /* to deal with nested tags */
+ /* this can have adverse affects on poorly tagged pages */
+ /* a missed closing tag will leave the document missing characters */
+ if(buff[0]=='<'){
+ inc=inc+tag(IN, OUT);
+ }
+ }
+ return inc;
+}
+
+int html_parse(char *param, char *newparam){
+ int t;
+ int f=0;
+ int fd1=0;
+ int dec=0;
+ int inc=0;
+ int skipit=0;
+ int button;
+ int size_of=1;
+ int size_of_file=0;
+ char buffheader[26];
+ char buff[1];
+
+ f = rb->open(param, O_RDONLY);
+ if(f < 0){
+ rb->splash(HZ*2, "Can't open file %s", param);
+ }else{
+ size_of_file=rb->filesize(f);
+ button = rb->button_get(false);
+ switch(button){
+ case(plug_QUIT):
+ cleanup(NULL);
+ rb->close(f);
+ rb->lcd_clear_display();
+ return PLUGIN_OK;
+ break;
+ default:
+ if (rb->default_event_handler_ex(button, cleanup, NULL)
+ == SYS_USB_CONNECTED)
+ return PLUGIN_USB_CONNECTED;
+ break;
+ }
+ fd1 = rb->open(newparam, O_CREAT|O_WRONLY|O_TRUNC);
+ rb->lcd_puts(0,6," * FILE Name:");
+ rb->lcd_puts_scroll(0,7, newparam);
+ rb->lcd_update();
+ /* build header */
+ rb->snprintf(buffheader, 26, " \n\n");
+ for(t=0; t< 26; t++){
+ rb->write(fd1, &buffheader[t], 1);
+ }
+ while(inc