annotate src/glyphs-shared.c @ 5658:289cf21be887

Don't augment ENVIRONMENT when that's not indicated, #'macroexpand. This reflects better understanding on my part of the &environment macro keyword, and I've expanded the Lisp manual and docstrings to reflect that. lisp/ChangeLog addition: 2012-05-06 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (block): Comment on why we can't use &environment here. * cl-macs.el (defmacro*): Document &environment in more detail. * cl-macs.el (macrolet): Use &environment, instead of referencing byte-compile-macro-environment directly. * cl-macs.el (symbol-macrolet): Ditto. * cl-macs.el (lexical-let): Ditto. * cl-macs.el (labels): Ditto. man/ChangeLog addition: 2012-05-06 Aidan Kehoe <kehoea@parhasard.net> * lispref/macros.texi (Expansion): Cross-reference to documentation of #'cl-prettyexpand, #'defmacro* when talking about #'macroexpand. tests/ChangeLog addition: 2012-05-06 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Use &environment appropriately in #'macrolet, instead of relying on #'macroexpand to guess what we mean.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 06 May 2012 15:29:59 +0100
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
1 /* Routines shared between window-system backends for glyph objects.
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4226
9b4442ac18c7 [xemacs-hg @ 2007-10-15 09:55:43 by didierv]
didierv
parents: 2367
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
4 Copyright (C) 1995 Tinker Systems
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
5 Copyright (C) 1995, 1996, 2001 Ben Wing
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems
4226
9b4442ac18c7 [xemacs-hg @ 2007-10-15 09:55:43 by didierv]
didierv
parents: 2367
diff changeset
7 Copyright (C) 1998, 1999, 2000 Andy Piper
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
8
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
9 This file is part of XEmacs.
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
10
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4834
diff changeset
11 XEmacs is free software: you can redistribute it and/or modify it
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
12 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4834
diff changeset
13 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4834
diff changeset
14 option) any later version.
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
15
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
16 XEmacs is distributed in the hope that it will be useful, but WITHOUT
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
19 for more details.
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
20
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
21 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4834
diff changeset
22 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
23
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
25
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
26 /* taken from glyphs-*.c
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
27 HINT HINT HINT Bill Perry: Please put code here and avoid massive
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
28 duplication in *-gtk.c!!! */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
29
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
30 #include <config.h>
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
31 #include "lisp.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
32
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 771
diff changeset
33 #include "buffer.h"
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
34 #include "elhash.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 771
diff changeset
35 #include "faces.h"
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
36 #include "frame.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 771
diff changeset
37 #include "glyphs.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 771
diff changeset
38 #include "imgproc.h"
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
39 #include "insdel.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 771
diff changeset
40 #include "lstream.h"
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
41 #include "opaque.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
42 #include "sysdep.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 771
diff changeset
43 #include "window.h"
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 771
diff changeset
44
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
45 #include "sysfile.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
46
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
47 Lisp_Object Q_resource_type, Q_resource_id;
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
48
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
49 void
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
50 shared_resource_validate (Lisp_Object instantiator)
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
51 {
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
52 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
53 &&
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
54 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
55 ||
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
56 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
57 sferror ("Must supply :file, :resource-id and :resource-type",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
58 instantiator);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
59 }
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
60
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
61
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
62 Lisp_Object
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
63 shared_resource_normalize (Lisp_Object inst, Lisp_Object console_type,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 800
diff changeset
64 Lisp_Object UNUSED (dest_mask), Lisp_Object tag)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
65 {
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
66 /* This function can call lisp */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
67 Lisp_Object file = Qnil;
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
68 struct gcpro gcpro1, gcpro2;
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
69 Lisp_Object alist = Qnil;
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
70
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
71 GCPRO2 (file, alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
72
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
73 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
74 console_type);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
75
4226
9b4442ac18c7 [xemacs-hg @ 2007-10-15 09:55:43 by didierv]
didierv
parents: 2367
diff changeset
76 if (NILP (file)) /* normalization impossible for the console type */
9b4442ac18c7 [xemacs-hg @ 2007-10-15 09:55:43 by didierv]
didierv
parents: 2367
diff changeset
77 RETURN_UNGCPRO (Qnil);
9b4442ac18c7 [xemacs-hg @ 2007-10-15 09:55:43 by didierv]
didierv
parents: 2367
diff changeset
78
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
79 if (CONSP (file)) /* failure locating filename */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
80 signal_double_image_error ("Opening pixmap file",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
81 "no such file or directory",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
82 Fcar (file));
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
83
4226
9b4442ac18c7 [xemacs-hg @ 2007-10-15 09:55:43 by didierv]
didierv
parents: 2367
diff changeset
84 if (EQ (file, Qt)) /* no conversion necessary */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
85 RETURN_UNGCPRO (inst);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
86
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
87 alist = tagged_vector_to_alist (inst);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
88
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
89 {
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
90 alist = remassq_no_quit (Q_file, alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
91 alist = Fcons (Fcons (Q_file, file), alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
92 }
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
93
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
94 {
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
95 Lisp_Object result = alist_to_tagged_vector (tag, alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
96 free_alist (alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
97 RETURN_UNGCPRO (result);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
98 }
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
99 }
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
100
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
101 /* Originally from xmu.c, but is now shared across X11, GTK, and MSW. */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
102 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
103 * Based on an optimized version provided by Jim Becker, August 5, 1988.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
104 */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
105
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
106
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
107 #ifndef BitmapSuccess
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
108 #define BitmapSuccess 0
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
109 #define BitmapOpenFailed 1
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
110 #define BitmapFileInvalid 2
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
111 #define BitmapNoMemory 3
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
112 #endif
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
113
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
114 #define MAX_SIZE 255
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
115
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
116 /* shared data for the image read/parse logic */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
117 static short hexTable[256]; /* conversion value */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
118 static int hex_initialized; /* easier to fill in at run time */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
119
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
120
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
121 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
122 * Table index for the hex values. Initialized once, first time.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
123 * Used for translation value or delimiter significance lookup.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
124 */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
125 static void initHexTable (void)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
126 {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
127 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
128 * We build the table at run time for several reasons:
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
129 *
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
130 * 1. portable to non-ASCII machines.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
131 * 2. still reentrant since we set the init flag after setting table.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
132 * 3. easier to extend.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
133 * 4. less prone to bugs.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
134 */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
135 hexTable['0'] = 0; hexTable['1'] = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
136 hexTable['2'] = 2; hexTable['3'] = 3;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
137 hexTable['4'] = 4; hexTable['5'] = 5;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
138 hexTable['6'] = 6; hexTable['7'] = 7;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
139 hexTable['8'] = 8; hexTable['9'] = 9;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
140 hexTable['A'] = 10; hexTable['B'] = 11;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
141 hexTable['C'] = 12; hexTable['D'] = 13;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
142 hexTable['E'] = 14; hexTable['F'] = 15;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
143 hexTable['a'] = 10; hexTable['b'] = 11;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
144 hexTable['c'] = 12; hexTable['d'] = 13;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
145 hexTable['e'] = 14; hexTable['f'] = 15;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
146
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
147 /* delimiters of significance are flagged w/ negative value */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
148 hexTable[' '] = -1; hexTable[','] = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
149 hexTable['}'] = -1; hexTable['\n'] = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
150 hexTable['\t'] = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
151
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
152 hex_initialized = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
153 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
154
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
155 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
156 * read next hex value in the input stream, return -1 if EOF
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
157 */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
158 static int NextInt (FILE *fstream)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
159 {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
160 int ch;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
161 int value = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
162 int gotone = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
163 int done = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
164
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
165 /* loop, accumulate hex value until find delimiter */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
166 /* skip any initial delimiters found in read stream */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
167
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
168 while (!done) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
169 ch = getc(fstream);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
170 if (ch == EOF) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
171 value = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
172 done++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
173 } else {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
174 /* trim high bits, check type and accumulate */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
175 ch &= 0xff;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
176 if (isascii(ch) && isxdigit(ch)) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
177 value = (value << 4) + hexTable[ch];
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
178 gotone++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
179 } else if ((hexTable[ch]) < 0 && gotone)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
180 done++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
181 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
182 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
183 return value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
184 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
185
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
186
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
187 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
188 * The data returned by the following routine is always in left-most byte
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
189 * first and left-most bit first. If it doesn't return BitmapSuccess then
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
190 * its arguments won't have been touched. This routine should look as much
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
191 * like the Xlib routine XReadBitmapfile as possible.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
192 */
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
193 static int
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
194 read_bitmap_data (FILE *fstream, int *width, int *height, Binbyte **datap,
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
195 int *x_hot, int *y_hot)
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
196 {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
197 Binbyte *data = NULL; /* working variable */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
198 Ascbyte line[MAX_SIZE]; /* input line from file */
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
199 int size; /* number of bytes of data */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
200 Ascbyte name_and_type[MAX_SIZE]; /* an input line */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
201 Ascbyte *type; /* for parsing */
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
202 int value; /* from an input line */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
203 int version10p; /* boolean, old format */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
204 int padding; /* to handle alignment */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
205 int bytes_per_line; /* per scanline of data */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
206 int ww = 0; /* width */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
207 int hh = 0; /* height */
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
208 int hx = -1; /* x hotspot */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
209 int hy = -1; /* y hotspot */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
210
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
211 #ifndef Xmalloc
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
212 #define Xmalloc(size) malloc(size)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
213 #endif
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
214
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
215 /* first time initialization */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
216 if (!hex_initialized) initHexTable();
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
217
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
218 /* error cleanup and return macro */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
219 #define RETURN(code) { if (data) free (data); return code; }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
220
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
221 while (fgets(line, MAX_SIZE, fstream)) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
222 if (strlen(line) == MAX_SIZE-1) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
223 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
224 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
225 if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
226 if (!(type = strrchr(name_and_type, '_')))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
227 type = name_and_type;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
228 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
229 type++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
230
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
231 if (!strcmp("width", type))
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
232 ww = value;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
233 if (!strcmp("height", type))
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
234 hh = value;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
235 if (!strcmp("hot", type)) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
236 if (type-- == name_and_type || type-- == name_and_type)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
237 continue;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
238 if (!strcmp("x_hot", type))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
239 hx = value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
240 if (!strcmp("y_hot", type))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
241 hy = value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
242 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
243 continue;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
244 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
245
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
246 if (sscanf(line, "static short %s = {", name_and_type) == 1)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
247 version10p = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
248 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
249 version10p = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
250 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
251 version10p = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
252 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
253 continue;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
254
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
255 if (!(type = strrchr(name_and_type, '_')))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
256 type = name_and_type;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
257 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
258 type++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
259
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
260 if (strcmp("bits[]", type))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
261 continue;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
262
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
263 if (!ww || !hh)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
264 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
265
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
266 if ((ww % 16) && ((ww % 16) < 9) && version10p)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
267 padding = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
268 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
269 padding = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
270
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
271 bytes_per_line = (ww+7)/8 + padding;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
272
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
273 size = bytes_per_line * hh;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
274 data = (Binbyte *) Xmalloc ((unsigned int) size);
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
275 if (!data)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
276 RETURN (BitmapNoMemory);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
277
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
278 if (version10p) {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
279 Binbyte *ptr;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
280 int bytes;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
281
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
282 for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
283 if ((value = NextInt(fstream)) < 0)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
284 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
285 *(ptr++) = value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
286 if (!padding || ((bytes+2) % bytes_per_line))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
287 *(ptr++) = value >> 8;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
288 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
289 } else {
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
290 Binbyte *ptr;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
291 int bytes;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
292
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
293 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
294 if ((value = NextInt(fstream)) < 0)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
295 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
296 *ptr=value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
297 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
298 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
299 break;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
300 } /* end while */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
301
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
302 if (data == NULL) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
303 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
304 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
305
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
306 *datap = data;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
307 data = NULL;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
308 *width = ww;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
309 *height = hh;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
310 if (x_hot) *x_hot = hx;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
311 if (y_hot) *y_hot = hy;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
312
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
313 RETURN (BitmapSuccess);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
314 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
315
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
316
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
317 int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
318 read_bitmap_data_from_file (Lisp_Object filename,
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
319 /* Remaining args are RETURNED */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
320 int *width,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
321 int *height,
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
322 Binbyte **datap,
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
323 int *x_hot, int *y_hot)
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
324 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
325 FILE *fstream;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
326 int status;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
327 Extbyte *fileext;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
328
4834
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4226
diff changeset
329 LISP_PATHNAME_CONVERT_OUT (filename, fileext);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
330 if ((fstream = fopen (fileext, "r")) == NULL)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
331 return BitmapOpenFailed;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
332 status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
333 retry_fclose (fstream);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
334 return status;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
335 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
336
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
337 void
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
338 syms_of_glyphs_shared (void)
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
339 {
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
340 DEFKEYWORD (Q_resource_id);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
341 DEFKEYWORD (Q_resource_type);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
342 }