summaryrefslogtreecommitdiffstats
path: root/apps/logfdisp.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-12-31 17:01:00 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-12-31 17:01:00 +0000
commit4c793febc8c4c828ab2bb7d7de3c37b05ac0cac2 (patch)
treed3804830e5ed45b93481c3111582bc42936f7772 /apps/logfdisp.c
parentd6def79dca7ed686196b860c9b160d1d0cbf93c5 (diff)
downloadrockbox-4c793febc8c4c828ab2bb7d7de3c37b05ac0cac2.tar.gz
rockbox-4c793febc8c4c828ab2bb7d7de3c37b05ac0cac2.tar.bz2
rockbox-4c793febc8c4c828ab2bb7d7de3c37b05ac0cac2.zip
Commit FS#9733 (multiline logf) by Yoshihisa Uchida
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19625 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/logfdisp.c')
-rw-r--r--apps/logfdisp.c58
1 files changed, 50 insertions, 8 deletions
diff --git a/apps/logfdisp.c b/apps/logfdisp.c
index bfe37bc3fb..d55b3ba773 100644
--- a/apps/logfdisp.c
+++ b/apps/logfdisp.c
@@ -62,8 +62,8 @@ bool logfdisplay(void)
#endif
:LCD_WIDTH)/w;
- if (columns > MAX_LOGF_ENTRY)
- columns = MAX_LOGF_ENTRY;
+ if (columns > MAX_LOGF_ENTRY+1)
+ columns = MAX_LOGF_ENTRY+1;
if(!lines)
return false;
@@ -83,7 +83,12 @@ bool logfdisplay(void)
}
memcpy(buffer, logfbuffer[index], columns);
- buffer[columns]=0;
+ if (logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_CONTINUE_LINE)
+ buffer[columns-1] = '>';
+ else if (logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_MULTI_LINE)
+ buffer[columns-1] = '\0';
+ buffer[columns] = '\0';
+
lcd_puts(0, i, buffer);
}
lcd_update();
@@ -113,24 +118,61 @@ bool logfdump(void)
fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC);
if(-1 != fd) {
- unsigned char buffer[MAX_LOGF_ENTRY +1];
+ unsigned char buffer[MAX_LOGF_ONE_LINE_SIZE +1];
+ unsigned char *ptr;
int index = logfindex-1;
int stop = logfindex;
+ int tindex;
+ bool dumpwrap = false;
+ bool multiline;
-
- while(index != stop) {
+ while(!dumpwrap || (index >= stop)) {
if(index < 0) {
if(logfwrap)
+ {
index = MAX_LOGF_LINES-1;
+ dumpwrap = true;
+ }
else
break; /* done */
}
+
+ multiline = false;
+ if (logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_MULTI_LINE)
+ {
+ multiline = true;
+ do {
+ index--;
+ if(index < 0) {
+ if(logfwrap)
+ {
+ index = MAX_LOGF_LINES-1;
+ dumpwrap = true;
+ }
+ else
+ goto end_loop;
+ }
+ } while(logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_CONTINUE_LINE);
+ index++;
+ if (index >= MAX_LOGF_LINES)
+ index = 0;
+ }
+
+ tindex = index-1;
+ ptr = buffer;
+ do {
+ tindex++;
+ memcpy(ptr, logfbuffer[tindex], MAX_LOGF_ENTRY);
+ ptr += MAX_LOGF_ENTRY;
+ if (tindex >= MAX_LOGF_LINES)
+ tindex = 0;
+ } while(logfbuffer[tindex][MAX_LOGF_ENTRY] == LOGF_TERMINATE_CONTINUE_LINE);
+ *ptr = '\0';
- memcpy(buffer, logfbuffer[index], MAX_LOGF_ENTRY);
- buffer[MAX_LOGF_ENTRY]=0;
fdprintf(fd, "%s\n", buffer);
index--;
}
+end_loop:
close(fd);
}
return false;