annotate src/glyphs-shared.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents b39c14581166
children a5954632b187
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.
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
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
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
7 Copyright (C) 1998, 1999, 2000 Andy Piper.
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
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
11 XEmacs is free software; you can redistribute it and/or modify it
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
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
13 Free Software Foundation; either version 2, or (at your option) any
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
14 later version.
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
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
22 along with XEmacs; see the file COPYING. If not, write to
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
23 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
24 Boston, MA 02111-1307, USA. */
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 /* Synched up with: Not in FSF. */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
27
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
28 /* taken from glyphs-*.c
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
29 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
30 duplication in *-gtk.c!!! */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
31
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
32 #include <config.h>
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
33 #include "lisp.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
34 #include "lstream.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
35
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
36 #include "window.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
37 #include "elhash.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
38 #include "buffer.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
39 #include "frame.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
40 #include "insdel.h"
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"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
43 #include "sysfile.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
44 #include "faces.h"
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
45 #include "imgproc.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,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
64 Lisp_Object dest_mask, Lisp_Object tag)
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
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
76 if (CONSP (file)) /* failure locating filename */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
77 signal_double_image_error ("Opening pixmap file",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
78 "no such file or directory",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
79 Fcar (file));
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
80
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
81 if (NILP (file)) /* no conversion necessary */
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
82 RETURN_UNGCPRO (inst);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
83
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
84 alist = tagged_vector_to_alist (inst);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
85
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 = remassq_no_quit (Q_file, alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
88 alist = Fcons (Fcons (Q_file, file), alist);
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
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
91 {
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
92 Lisp_Object result = alist_to_tagged_vector (tag, alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
93 free_alist (alist);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
94 RETURN_UNGCPRO (result);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
95 }
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
96 }
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
97
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
98 /* 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
99 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
100 * 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
101 */
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
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
104 #ifndef BitmapSuccess
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
105 #define BitmapSuccess 0
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
106 #define BitmapOpenFailed 1
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
107 #define BitmapFileInvalid 2
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
108 #define BitmapNoMemory 3
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
109 #endif
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
110
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
111 #define MAX_SIZE 255
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
112
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
113 /* shared data for the image read/parse logic */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
114 static short hexTable[256]; /* conversion value */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
115 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
116
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
117
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
118 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
119 * 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
120 * Used for translation value or delimiter significance lookup.
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 static void initHexTable (void)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
123 {
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 * 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
126 *
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
127 * 1. portable to non-ASCII machines.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
128 * 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
129 * 3. easier to extend.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
130 * 4. less prone to bugs.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
131 */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
132 hexTable['0'] = 0; hexTable['1'] = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
133 hexTable['2'] = 2; hexTable['3'] = 3;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
134 hexTable['4'] = 4; hexTable['5'] = 5;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
135 hexTable['6'] = 6; hexTable['7'] = 7;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
136 hexTable['8'] = 8; hexTable['9'] = 9;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
137 hexTable['A'] = 10; hexTable['B'] = 11;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
138 hexTable['C'] = 12; hexTable['D'] = 13;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
139 hexTable['E'] = 14; hexTable['F'] = 15;
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
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
144 /* delimiters of significance are flagged w/ negative value */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
145 hexTable[' '] = -1; hexTable[','] = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
146 hexTable['}'] = -1; hexTable['\n'] = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
147 hexTable['\t'] = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
148
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
149 hex_initialized = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
150 }
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 /*
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
153 * 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
154 */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
155 static int NextInt (FILE *fstream)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
156 {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
157 int ch;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
158 int value = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
159 int gotone = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
160 int done = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
161
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
162 /* loop, accumulate hex value until find delimiter */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
163 /* skip any initial delimiters found in read stream */
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 while (!done) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
166 ch = getc(fstream);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
167 if (ch == EOF) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
168 value = -1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
169 done++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
170 } else {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
171 /* trim high bits, check type and accumulate */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
172 ch &= 0xff;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
173 if (isascii(ch) && isxdigit(ch)) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
174 value = (value << 4) + hexTable[ch];
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
175 gotone++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
176 } else if ((hexTable[ch]) < 0 && gotone)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
177 done++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
178 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
179 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
180 return value;
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
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 * 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
186 * 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
187 * 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
188 * like the Xlib routine XReadBitmapfile as possible.
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
189 */
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
190 static int
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
191 read_bitmap_data (FILE *fstream, int *width, int *height, UChar_Binary **datap,
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
192 int *x_hot, int *y_hot)
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
193 {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
194 UChar_Binary *data = NULL; /* working variable */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
195 Char_ASCII line[MAX_SIZE]; /* input line from file */
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
196 int size; /* number of bytes of data */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
197 Char_ASCII name_and_type[MAX_SIZE]; /* an input line */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
198 Char_ASCII *type; /* for parsing */
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
199 int value; /* from an input line */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
200 int version10p; /* boolean, old format */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
201 int padding; /* to handle alignment */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
202 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
203 int ww = 0; /* width */
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
204 int hh = 0; /* height */
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
205 int hx = -1; /* x hotspot */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
206 int hy = -1; /* y hotspot */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
207
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
208 #ifndef Xmalloc
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
209 #define Xmalloc(size) malloc(size)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
210 #endif
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
211
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
212 /* first time initialization */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
213 if (!hex_initialized) initHexTable();
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 /* error cleanup and return macro */
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
216 #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
217
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
218 while (fgets(line, MAX_SIZE, fstream)) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
219 if (strlen(line) == MAX_SIZE-1) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
220 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
221 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
222 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
223 if (!(type = strrchr(name_and_type, '_')))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
224 type = name_and_type;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
225 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
226 type++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
227
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
228 if (!strcmp("width", type))
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
229 ww = value;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
230 if (!strcmp("height", type))
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
231 hh = value;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
232 if (!strcmp("hot", type)) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
233 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
234 continue;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
235 if (!strcmp("x_hot", type))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
236 hx = value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
237 if (!strcmp("y_hot", type))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
238 hy = value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
239 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
240 continue;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
241 }
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 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
244 version10p = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
245 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
246 version10p = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
247 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
248 version10p = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
249 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
250 continue;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
251
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
252 if (!(type = strrchr(name_and_type, '_')))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
253 type = name_and_type;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
254 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
255 type++;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
256
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
257 if (strcmp("bits[]", type))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
258 continue;
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 (!ww || !hh)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
261 RETURN (BitmapFileInvalid);
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 % 16) && ((ww % 16) < 9) && version10p)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
264 padding = 1;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
265 else
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
266 padding = 0;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
267
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
268 bytes_per_line = (ww+7)/8 + padding;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
269
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
270 size = bytes_per_line * hh;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
271 data = (UChar_Binary *) Xmalloc ((unsigned int) size);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
272 if (!data)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
273 RETURN (BitmapNoMemory);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
274
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
275 if (version10p) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
276 UChar_Binary *ptr;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
277 int bytes;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
278
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
279 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
280 if ((value = NextInt(fstream)) < 0)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
281 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
282 *(ptr++) = value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
283 if (!padding || ((bytes+2) % bytes_per_line))
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
284 *(ptr++) = value >> 8;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
285 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
286 } else {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
287 UChar_Binary *ptr;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
288 int bytes;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
289
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
290 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
291 if ((value = NextInt(fstream)) < 0)
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
292 RETURN (BitmapFileInvalid);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
293 *ptr=value;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
294 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
295 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
296 break;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
297 } /* end while */
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 if (data == NULL) {
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
300 RETURN (BitmapFileInvalid);
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
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
303 *datap = data;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
304 data = NULL;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
305 *width = ww;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
306 *height = hh;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
307 if (x_hot) *x_hot = hx;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
308 if (y_hot) *y_hot = hy;
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
309
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
310 RETURN (BitmapSuccess);
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
311 }
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
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
314 int
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
315 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
316 /* Remaining args are RETURNED */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
317 int *width,
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 611
diff changeset
318 int *height,
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
319 UChar_Binary **datap,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 608
diff changeset
320 int *x_hot, int *y_hot)
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
321 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
322 FILE *fstream;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
323 int status;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
324 Extbyte *fileext;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
325
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
326 LISP_STRING_TO_EXTERNAL (filename, fileext, Qnative);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
327 if ((fstream = fopen (fileext, "r")) == NULL)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
328 return BitmapOpenFailed;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
329 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
330 retry_fclose (fstream);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
331 return status;
608
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
332 }
4d7fdf497470 [xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
wmperry
parents: 563
diff changeset
333
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
334 void
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
335 syms_of_glyphs_shared (void)
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
336 {
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
337 DEFKEYWORD (Q_resource_id);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
338 DEFKEYWORD (Q_resource_type);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents:
diff changeset
339 }