4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 #pragma ident "%Z%%M% %I% %E% SMI"
26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
32 extern int _error(int do_perror
, char *fmt
, ...);
37 * Icon loader for eeprom command.
39 * Based on libsuntool/icon/icon_load.c 10.10 88/02/08
40 * See <suntool/icon_load.h> for icon file format.
44 loadlogo(char *name
, int w
, int h
, char *logo
)
49 int icw
= 64, ich
= 64, bits
= 16;
52 if (!(f
= fopen(name
, "r")))
53 return (_error(PERROR
, "cannot open %s", name
));
59 if ((c
= fscanf(f
, "%*[^DFHVW*]")) == EOF
)
62 switch (c
= getc(f
)) {
64 if ((c
= fscanf(f
, "epth=%d", &nval
)) == 1 &&
69 if ((c
= fscanf(f
, "ormat_version=%d", &nval
)) == 1 &&
74 c
= fscanf(f
, "eight=%d", &ich
);
77 c
= fscanf(f
, "alid_bits_per_item=%d", &bits
);
80 c
= fscanf(f
, "idth=%d", &icw
);
83 c
= fscanf(f
, "%c", &slash
);
85 goto eoh
; /* end of header */
87 (void) ungetc(slash
, f
);
94 icw
!= w
|| ich
!= h
||
95 bits
!= 16 && bits
!= 32) {
98 return (_error(NO_PERROR
, "header format error in %s", name
));
101 for (count
= ((w
+ (bits
- 1)) / bits
) * h
; count
> 0; count
--) {
102 c
= fscanf(f
, " 0x%x,", &val
);
103 if (c
== 0 || c
== EOF
)
121 return (_error(NO_PERROR
, "data format error in %s", name
));