mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-05-11 09:48:24 +02:00
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@801 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
56 lines
1.4 KiB
Diff
56 lines
1.4 KiB
Diff
--- grub-0.95/stage2/graphics.c.xpmjunk 2005-01-04 17:01:35.492804523 -0500
|
|
+++ grub-0.95/stage2/graphics.c 2005-01-04 17:02:52.722495885 -0500
|
|
@@ -262,6 +262,35 @@
|
|
return;
|
|
}
|
|
|
|
+/* Open the file, and search for a valid XPM header. Return 1 if one is found,
|
|
+ * leaving the current position as the start of the next line. Else,
|
|
+ * return 0.
|
|
+ */
|
|
+int xpm_open(const char *s) {
|
|
+ char buf, prev, target[]="/* XPM */\n";
|
|
+ int pos=0;
|
|
+
|
|
+ if (!grub_open(s))
|
|
+ return 0;
|
|
+
|
|
+ prev='\n';
|
|
+ buf=0;
|
|
+ do {
|
|
+ if (grub_read(&buf, 1) != 1) {
|
|
+ grub_close();
|
|
+ return 0;
|
|
+ }
|
|
+ if ((pos == 0 && prev == '\n') || pos > 0) {
|
|
+ if (buf == target[pos])
|
|
+ pos++;
|
|
+ else
|
|
+ pos=0;
|
|
+ }
|
|
+ prev=buf;
|
|
+ } while (target[pos]);
|
|
+ return 1;
|
|
+}
|
|
+
|
|
/* Read in the splashscreen image and set the palette up appropriately.
|
|
* Format of splashscreen is an xpm (can be gzipped) with 16 colors and
|
|
* 640x480. */
|
|
@@ -271,15 +300,9 @@
|
|
unsigned char c, base, mask, *s1, *s2, *s4, *s8;
|
|
unsigned i, len, idx, colors, x, y, width, height;
|
|
|
|
- if (!grub_open(s))
|
|
+ if (!xpm_open(s))
|
|
return 0;
|
|
|
|
- /* read header */
|
|
- if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10)) {
|
|
- grub_close();
|
|
- return 0;
|
|
- }
|
|
-
|
|
/* parse info */
|
|
while (grub_read(&c, 1)) {
|
|
if (c == '"')
|