1 |
/* |
/* |
2 |
* PUPA -- Preliminary Universal Programming Architecture for GRUB |
* PUPA -- Preliminary Universal Programming Architecture for GRUB |
3 |
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org> |
* Copyright (C) 2002,2003 Yoshinori K. Okuji <okuji@enbug.org> |
4 |
* |
* |
5 |
* PUPA is free software; you can redistribute it and/or modify |
* PUPA is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
136 |
if (fread (img, 1, size, fp) != size) |
if (fread (img, 1, size, fp) != size) |
137 |
pupa_util_error ("cannot read %s", path); |
pupa_util_error ("cannot read %s", path); |
138 |
|
|
139 |
|
fclose (fp); |
140 |
|
|
141 |
return img; |
return img; |
142 |
} |
} |
143 |
|
|
144 |
void |
void |
145 |
|
pupa_util_load_image (const char *path, char *buf) |
146 |
|
{ |
147 |
|
FILE *fp; |
148 |
|
size_t size; |
149 |
|
|
150 |
|
pupa_util_info ("reading %s", path); |
151 |
|
|
152 |
|
size = pupa_util_get_image_size (path); |
153 |
|
|
154 |
|
fp = fopen (path, "rb"); |
155 |
|
if (! fp) |
156 |
|
pupa_util_error ("cannot open %s", path); |
157 |
|
|
158 |
|
if (fread (buf, 1, size, fp) != size) |
159 |
|
pupa_util_error ("cannot read %s", path); |
160 |
|
|
161 |
|
fclose (fp); |
162 |
|
} |
163 |
|
|
164 |
|
void |
165 |
pupa_util_write_image (const char *img, size_t size, FILE *out) |
pupa_util_write_image (const char *img, size_t size, FILE *out) |
166 |
{ |
{ |
167 |
pupa_util_info ("writing 0x%x bytes", size); |
pupa_util_info ("writing 0x%x bytes", size); |