1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Daniel Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #ifdef ROCKBOX_HAS_LOGF
26 #include <timefuncs.h>
37 #ifdef HAVE_LCD_BITMAP
38 bool logfdisplay(void)
46 bool lcd
= false; /* fixed atm */
49 lcd_getstringsize("A", &w
, &h
);
51 #ifdef HAVE_REMOTE_LCD
58 #ifdef HAVE_REMOTE_LCD
65 if (columns
> MAX_LOGF_ENTRY
+1)
66 columns
= MAX_LOGF_ENTRY
+1;
75 for(i
= lines
-1; i
>=0; i
--) {
76 unsigned char buffer
[columns
+ 1];
80 index
= MAX_LOGF_LINES
-1;
85 memcpy(buffer
, logfbuffer
[index
], columns
);
86 if (logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_CONTINUE_LINE
)
87 buffer
[columns
-1] = '>';
88 else if (logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_MULTI_LINE
)
89 buffer
[columns
-1] = '\0';
90 buffer
[columns
] = '\0';
92 lcd_puts(0, i
, buffer
);
95 } while(!action_userabort(HZ
));
99 #else /* HAVE_LCD_BITMAP */
100 bool logfdisplay(void)
103 /* TODO: implement a browser for charcell bitmaps */
106 #endif /* HAVE_LCD_BITMAP */
108 /* Store the logf log to logf.txt in the .rockbox directory. The order of the
109 * entries will be "reversed" so that the most recently logged entry is on the
115 if(!logfindex
&& !logfwrap
)
116 /* nothing is logged just yet */
119 fd
= open(ROCKBOX_DIR
"/logf.txt", O_CREAT
|O_WRONLY
|O_TRUNC
);
121 unsigned char buffer
[MAX_LOGF_ONE_LINE_SIZE
+1];
123 int index
= logfindex
-1;
124 int stop
= logfindex
;
126 bool dumpwrap
= false;
129 while(!dumpwrap
|| (index
>= stop
)) {
133 index
= MAX_LOGF_LINES
-1;
141 if (logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_MULTI_LINE
)
149 index
= MAX_LOGF_LINES
-1;
155 } while(logfbuffer
[index
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_CONTINUE_LINE
);
157 if (index
>= MAX_LOGF_LINES
)
165 memcpy(ptr
, logfbuffer
[tindex
], MAX_LOGF_ENTRY
);
166 ptr
+= MAX_LOGF_ENTRY
;
167 if (tindex
>= MAX_LOGF_LINES
)
169 } while(logfbuffer
[tindex
][MAX_LOGF_ENTRY
] == LOGF_TERMINATE_CONTINUE_LINE
);
172 fdprintf(fd
, "%s\n", buffer
);
181 #endif /* ROCKBOX_HAS_LOGF */