annotate src/mac.c @ 96024:be43dd7afc91

Merge from gnus--devo--0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1244
author Miles Bader <miles@gnu.org>
date Tue, 17 Jun 2008 02:32:59 +0000
parents 4390d64d3328
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1 /* Unix emulation routines for GNU Emacs on the Mac OS.
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94293
diff changeset
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94293
diff changeset
3 2008 Free Software Foundation, Inc.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5 This file is part of GNU Emacs.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
6
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94293
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94293
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94293
diff changeset
10 (at your option) any later version.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
11
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
15 GNU General Public License for more details.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
16
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94293
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
19
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
20 /* Contributed by Andrew Choi (akochoi@mac.com). */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
21
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
22 #include <config.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
23
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
24 #include <stdio.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
25 #include <errno.h>
60360
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
26
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
27 #include "lisp.h"
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
28 #include "process.h"
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
29 #ifdef MAC_OSX
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
30 #undef select
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
31 #endif
61925
e3bedede9b3f Don't include time.h. Include sysselect.h after systime.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61785
diff changeset
32 #include "systime.h"
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
33 #include "sysselect.h"
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
34 #include "blockinput.h"
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
35
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
36 #include "macterm.h"
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
37
61572
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
38 #include "charset.h"
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
39 #include "coding.h"
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
40 #if !TARGET_API_MAC_CARBON
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
41 #include <Files.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
42 #include <MacTypes.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
43 #include <TextUtils.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
44 #include <Folders.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
45 #include <Resources.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
46 #include <Aliases.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
47 #include <Timer.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
48 #include <OSA.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
49 #include <AppleScript.h>
60360
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
50 #include <Events.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
51 #include <Processes.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
52 #include <EPPC.h>
61553
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
53 #include <MacLocales.h>
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
54 #include <Endian.h>
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
55 #endif /* not TARGET_API_MAC_CARBON */
60360
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
56
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
57 #include <utime.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
58 #include <dirent.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
59 #include <sys/types.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
60 #include <sys/stat.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
61 #include <pwd.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
62 #include <grp.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
63 #include <sys/param.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
64 #include <fcntl.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
65 #if __MWERKS__
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
66 #include <unistd.h>
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
67 #endif
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
68
61553
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
69 /* The system script code. */
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
70 static int mac_system_script_code;
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
71
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
72 /* The system locale identifier string. */
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
73 static Lisp_Object Vmac_system_locale;
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
74
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
75 /* An instance of the AppleScript component. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
76 static ComponentInstance as_scripting_component;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
77 /* The single script context used for all script executions. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
78 static OSAID as_script_context;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
79
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
80 #ifndef MAC_OSX
74626
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
81 #if TARGET_API_MAC_CARBON
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
82 static int wakeup_from_rne_enabled_p = 0;
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
83 #define ENABLE_WAKEUP_FROM_RNE (wakeup_from_rne_enabled_p = 1)
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
84 #define DISABLE_WAKEUP_FROM_RNE (wakeup_from_rne_enabled_p = 0)
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
85 #else
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
86 #define ENABLE_WAKEUP_FROM_RNE 0
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
87 #define DISABLE_WAKEUP_FROM_RNE 0
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
88 #endif
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
89 #endif
74626
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
90
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
91 #ifndef MAC_OSX
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
92 static OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *));
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
93 static OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int));
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
94 #endif
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
95
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
96 /* When converting from Mac to Unix pathnames, /'s in folder names are
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
97 converted to :'s. This function, used in copying folder names,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
98 performs a strncat and converts all character a to b in the copy of
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
99 the string s2 appended to the end of s1. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
100
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
101 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
102 string_cat_and_replace (char *s1, const char *s2, int n, char a, char b)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
103 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
104 int l1 = strlen (s1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
105 int l2 = strlen (s2);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
106 char *p = s1 + l1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
107 int i;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
108
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
109 strncat (s1, s2, n);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
110 for (i = 0; i < l2; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
111 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
112 if (*p == a)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
113 *p = b;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
114 p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
115 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
116 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
117
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
118
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
119 /* Convert a Mac pathname to Posix form. A Mac full pathname is one
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
120 that does not begin with a ':' and contains at least one ':'. A Mac
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
121 full pathname causes a '/' to be prepended to the Posix pathname.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
122 The algorithm for the rest of the pathname is as follows:
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
123 For each segment between two ':',
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
124 if it is non-null, copy as is and then add a '/' at the end,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
125 otherwise, insert a "../" into the Posix pathname.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
126 Returns 1 if successful; 0 if fails. */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
127
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
128 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
129 mac_to_posix_pathname (const char *mfn, char *ufn, int ufnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
130 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
131 const char *p, *q, *pe;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
132
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
133 strcpy (ufn, "");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
134
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
135 if (*mfn == '\0')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
136 return 1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
137
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
138 p = strchr (mfn, ':');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
139 if (p != 0 && p != mfn) /* full pathname */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
140 strcat (ufn, "/");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
141
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
142 p = mfn;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
143 if (*p == ':')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
144 p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
145
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
146 pe = mfn + strlen (mfn);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
147 while (p < pe)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
148 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
149 q = strchr (p, ':');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
150 if (q)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
151 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
152 if (q == p)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
153 { /* two consecutive ':' */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
154 if (strlen (ufn) + 3 >= ufnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
155 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
156 strcat (ufn, "../");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
157 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
158 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
159 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
160 if (strlen (ufn) + (q - p) + 1 >= ufnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
161 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
162 string_cat_and_replace (ufn, p, q - p, '/', ':');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
163 strcat (ufn, "/");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
164 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
165 p = q + 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
166 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
167 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
168 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
169 if (strlen (ufn) + (pe - p) >= ufnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
170 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
171 string_cat_and_replace (ufn, p, pe - p, '/', ':');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
172 /* no separator for last one */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
173 p = pe;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
174 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
175 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
176
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
177 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
178 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
179
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
180
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
181 extern char *get_temp_dir_name ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
182
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
183
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
184 /* Convert a Posix pathname to Mac form. Approximately reverse of the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
185 above in algorithm. */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
186
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
187 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
188 posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
189 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
190 const char *p, *q, *pe;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
191 char expanded_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
192
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
193 strcpy (mfn, "");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
194
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
195 if (*ufn == '\0')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
196 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
197
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
198 p = ufn;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
199
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
200 /* Check for and handle volume names. Last comparison: strangely
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
201 somewhere "/.emacs" is passed. A temporary fix for now. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
202 if (*p == '/' && strchr (p+1, '/') == NULL && strcmp (p, "/.emacs") != 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
203 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
204 if (strlen (p) + 1 > mfnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
205 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
206 strcpy (mfn, p+1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
207 strcat (mfn, ":");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
208 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
209 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
210
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
211 /* expand to emacs dir found by init_emacs_passwd_dir */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
212 if (strncmp (p, "~emacs/", 7) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
213 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
214 struct passwd *pw = getpwnam ("emacs");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
215 p += 7;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
216 if (strlen (pw->pw_dir) + strlen (p) > MAXPATHLEN)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
217 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
218 strcpy (expanded_pathname, pw->pw_dir);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
219 strcat (expanded_pathname, p);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
220 p = expanded_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
221 /* now p points to the pathname with emacs dir prefix */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
222 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
223 else if (strncmp (p, "/tmp/", 5) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
224 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
225 char *t = get_temp_dir_name ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
226 p += 5;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
227 if (strlen (t) + strlen (p) > MAXPATHLEN)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
228 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
229 strcpy (expanded_pathname, t);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
230 strcat (expanded_pathname, p);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
231 p = expanded_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
232 /* now p points to the pathname with emacs dir prefix */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
233 }
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
234 else if (*p != '/') /* relative pathname */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
235 strcat (mfn, ":");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
236
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
237 if (*p == '/')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
238 p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
239
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
240 pe = p + strlen (p);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
241 while (p < pe)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
242 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
243 q = strchr (p, '/');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
244 if (q)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
245 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
246 if (q - p == 2 && *p == '.' && *(p+1) == '.')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
247 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
248 if (strlen (mfn) + 1 >= mfnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
249 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
250 strcat (mfn, ":");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
251 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
252 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
253 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
254 if (strlen (mfn) + (q - p) + 1 >= mfnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
255 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
256 string_cat_and_replace (mfn, p, q - p, ':', '/');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
257 strcat (mfn, ":");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
258 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
259 p = q + 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
260 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
261 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
262 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
263 if (strlen (mfn) + (pe - p) >= mfnbuflen)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
264 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
265 string_cat_and_replace (mfn, p, pe - p, ':', '/');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
266 p = pe;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
267 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
268 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
269
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
270 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
271 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
272
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
273
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
274 /***********************************************************************
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
275 Conversions on Apple event objects
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
276 ***********************************************************************/
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
277
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
278 static Lisp_Object Qundecoded_file_name;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
279
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
280 static struct {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
281 AEKeyword keyword;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
282 char *name;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
283 Lisp_Object symbol;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
284 } ae_attr_table [] =
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
285 {{keyTransactionIDAttr, "transaction-id"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
286 {keyReturnIDAttr, "return-id"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
287 {keyEventClassAttr, "event-class"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
288 {keyEventIDAttr, "event-id"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
289 {keyAddressAttr, "address"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
290 {keyOptionalKeywordAttr, "optional-keyword"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
291 {keyTimeoutAttr, "timeout"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
292 {keyInteractLevelAttr, "interact-level"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
293 {keyEventSourceAttr, "event-source"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
294 /* {keyMissedKeywordAttr, "missed-keyword"}, */
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
295 {keyOriginalAddressAttr, "original-address"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
296 {keyReplyRequestedAttr, "reply-requested"},
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
297 {KEY_EMACS_SUSPENSION_ID_ATTR, "emacs-suspension-id"}
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
298 };
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
299
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
300 static Lisp_Object
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
301 mac_aelist_to_lisp (desc_list)
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
302 const AEDescList *desc_list;
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
303 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
304 OSErr err;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
305 long count;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
306 Lisp_Object result, elem;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
307 DescType desc_type;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
308 Size size;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
309 AEKeyword keyword;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
310 AEDesc desc;
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
311 int attribute_p = 0;
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
312
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
313 err = AECountItems (desc_list, &count);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
314 if (err != noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
315 return Qnil;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
316 result = Qnil;
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
317
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
318 again:
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
319 while (count > 0)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
320 {
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
321 if (attribute_p)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
322 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
323 keyword = ae_attr_table[count - 1].keyword;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
324 err = AESizeOfAttribute (desc_list, keyword, &desc_type, &size);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
325 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
326 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
327 err = AESizeOfNthItem (desc_list, count, &desc_type, &size);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
328
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
329 if (err == noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
330 switch (desc_type)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
331 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
332 case typeAEList:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
333 case typeAERecord:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
334 case typeAppleEvent:
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
335 if (attribute_p)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
336 err = AEGetAttributeDesc (desc_list, keyword, typeWildCard,
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
337 &desc);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
338 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
339 err = AEGetNthDesc (desc_list, count, typeWildCard,
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
340 &keyword, &desc);
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
341 if (err != noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
342 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
343 elem = mac_aelist_to_lisp (&desc);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
344 AEDisposeDesc (&desc);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
345 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
346
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
347 default:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
348 if (desc_type == typeNull)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
349 elem = Qnil;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
350 else
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
351 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
352 elem = make_uninit_string (size);
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
353 if (attribute_p)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
354 err = AEGetAttributePtr (desc_list, keyword, typeWildCard,
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
355 &desc_type, SDATA (elem),
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
356 size, &size);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
357 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
358 err = AEGetNthPtr (desc_list, count, typeWildCard, &keyword,
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
359 &desc_type, SDATA (elem), size, &size);
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
360 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
361 if (err != noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
362 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
363 desc_type = EndianU32_NtoB (desc_type);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
364 elem = Fcons (make_unibyte_string ((char *) &desc_type, 4), elem);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
365 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
366 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
367
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
368 if (err == noErr || desc_list->descriptorType == typeAEList)
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
369 {
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
370 if (err != noErr)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
371 elem = Qnil; /* Don't skip elements in AEList. */
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
372 else if (desc_list->descriptorType != typeAEList)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
373 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
374 if (attribute_p)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
375 elem = Fcons (ae_attr_table[count-1].symbol, elem);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
376 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
377 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
378 keyword = EndianU32_NtoB (keyword);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
379 elem = Fcons (make_unibyte_string ((char *) &keyword, 4),
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
380 elem);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
381 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
382 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
383
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
384 result = Fcons (elem, result);
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
385 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
386
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
387 count--;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
388 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
389
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
390 if (desc_list->descriptorType == typeAppleEvent && !attribute_p)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
391 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
392 attribute_p = 1;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
393 count = sizeof (ae_attr_table) / sizeof (ae_attr_table[0]);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
394 goto again;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
395 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
396
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
397 desc_type = EndianU32_NtoB (desc_list->descriptorType);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
398 return Fcons (make_unibyte_string ((char *) &desc_type, 4), result);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
399 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
400
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
401 Lisp_Object
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
402 mac_aedesc_to_lisp (desc)
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
403 const AEDesc *desc;
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
404 {
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
405 OSErr err = noErr;
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
406 DescType desc_type = desc->descriptorType;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
407 Lisp_Object result;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
408
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
409 switch (desc_type)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
410 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
411 case typeNull:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
412 result = Qnil;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
413 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
414
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
415 case typeAEList:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
416 case typeAERecord:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
417 case typeAppleEvent:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
418 return mac_aelist_to_lisp (desc);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
419 #if 0
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
420 /* The following one is much simpler, but creates and disposes
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
421 of Apple event descriptors many times. */
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
422 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
423 long count;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
424 Lisp_Object elem;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
425 AEKeyword keyword;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
426 AEDesc desc1;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
427
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
428 err = AECountItems (desc, &count);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
429 if (err != noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
430 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
431 result = Qnil;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
432 while (count > 0)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
433 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
434 err = AEGetNthDesc (desc, count, typeWildCard, &keyword, &desc1);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
435 if (err != noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
436 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
437 elem = mac_aedesc_to_lisp (&desc1);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
438 AEDisposeDesc (&desc1);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
439 if (desc_type != typeAEList)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
440 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
441 keyword = EndianU32_NtoB (keyword);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
442 elem = Fcons (make_unibyte_string ((char *) &keyword, 4), elem);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
443 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
444 result = Fcons (elem, result);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
445 count--;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
446 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
447 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
448 #endif
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
449 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
450
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
451 default:
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
452 #if TARGET_API_MAC_CARBON
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
453 result = make_uninit_string (AEGetDescDataSize (desc));
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
454 err = AEGetDescData (desc, SDATA (result), SBYTES (result));
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
455 #else
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
456 result = make_uninit_string (GetHandleSize (desc->dataHandle));
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
457 memcpy (SDATA (result), *(desc->dataHandle), SBYTES (result));
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
458 #endif
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
459 break;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
460 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
461
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
462 if (err != noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
463 return Qnil;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
464
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
465 desc_type = EndianU32_NtoB (desc_type);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
466 return Fcons (make_unibyte_string ((char *) &desc_type, 4), result);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
467 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
468
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
469 OSErr
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
470 mac_ae_put_lisp (desc, keyword_or_index, obj)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
471 AEDescList *desc;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
472 UInt32 keyword_or_index;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
473 Lisp_Object obj;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
474 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
475 OSErr err;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
476
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
477 if (!(desc->descriptorType == typeAppleEvent
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
478 || desc->descriptorType == typeAERecord
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
479 || desc->descriptorType == typeAEList))
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
480 return errAEWrongDataType;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
481
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
482 if (CONSP (obj) && STRINGP (XCAR (obj)) && SBYTES (XCAR (obj)) == 4)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
483 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
484 DescType desc_type1 = EndianU32_BtoN (*((UInt32 *) SDATA (XCAR (obj))));
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
485 Lisp_Object data = XCDR (obj), rest;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
486 AEDesc desc1;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
487
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
488 switch (desc_type1)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
489 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
490 case typeNull:
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
491 case typeAppleEvent:
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
492 break;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
493
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
494 case typeAEList:
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
495 case typeAERecord:
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
496 err = AECreateList (NULL, 0, desc_type1 == typeAERecord, &desc1);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
497 if (err == noErr)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
498 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
499 for (rest = data; CONSP (rest); rest = XCDR (rest))
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
500 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
501 UInt32 keyword_or_index1 = 0;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
502 Lisp_Object elem = XCAR (rest);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
503
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
504 if (desc_type1 == typeAERecord)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
505 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
506 if (CONSP (elem) && STRINGP (XCAR (elem))
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
507 && SBYTES (XCAR (elem)) == 4)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
508 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
509 keyword_or_index1 =
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
510 EndianU32_BtoN (*((UInt32 *)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
511 SDATA (XCAR (elem))));
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
512 elem = XCDR (elem);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
513 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
514 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
515 continue;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
516 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
517
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
518 err = mac_ae_put_lisp (&desc1, keyword_or_index1, elem);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
519 if (err != noErr)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
520 break;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
521 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
522
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
523 if (err == noErr)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
524 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
525 if (desc->descriptorType == typeAEList)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
526 err = AEPutDesc (desc, keyword_or_index, &desc1);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
527 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
528 err = AEPutParamDesc (desc, keyword_or_index, &desc1);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
529 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
530
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
531 AEDisposeDesc (&desc1);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
532 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
533 return err;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
534
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
535 default:
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
536 if (!STRINGP (data))
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
537 break;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
538 if (desc->descriptorType == typeAEList)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
539 err = AEPutPtr (desc, keyword_or_index, desc_type1,
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
540 SDATA (data), SBYTES (data));
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
541 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
542 err = AEPutParamPtr (desc, keyword_or_index, desc_type1,
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
543 SDATA (data), SBYTES (data));
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
544 return err;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
545 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
546 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
547
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
548 if (desc->descriptorType == typeAEList)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
549 err = AEPutPtr (desc, keyword_or_index, typeNull, NULL, 0);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
550 else
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
551 err = AEPutParamPtr (desc, keyword_or_index, typeNull, NULL, 0);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
552
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
553 return err;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
554 }
70987
f85bcca39940 Tiny layout change.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70871
diff changeset
555
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
556 static pascal OSErr
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
557 mac_coerce_file_name_ptr (type_code, data_ptr, data_size,
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
558 to_type, handler_refcon, result)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
559 DescType type_code;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
560 const void *data_ptr;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
561 Size data_size;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
562 DescType to_type;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
563 long handler_refcon;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
564 AEDesc *result;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
565 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
566 OSErr err;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
567
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
568 if (type_code == typeNull)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
569 err = errAECoercionFail;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
570 else if (type_code == to_type || to_type == typeWildCard)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
571 err = AECreateDesc (TYPE_FILE_NAME, data_ptr, data_size, result);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
572 else if (type_code == TYPE_FILE_NAME)
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
573 /* Coercion from undecoded file name. */
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
574 {
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
575 #ifdef MAC_OSX
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
576 CFStringRef str;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
577 CFURLRef url = NULL;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
578 CFDataRef data = NULL;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
579
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
580 str = CFStringCreateWithBytes (NULL, data_ptr, data_size,
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
581 kCFStringEncodingUTF8, false);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
582 if (str)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
583 {
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
584 url = CFURLCreateWithFileSystemPath (NULL, str,
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
585 kCFURLPOSIXPathStyle, false);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
586 CFRelease (str);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
587 }
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
588 if (url)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
589 {
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
590 data = CFURLCreateData (NULL, url, kCFStringEncodingUTF8, true);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
591 CFRelease (url);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
592 }
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
593 if (data)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
594 {
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
595 err = AECoercePtr (typeFileURL, CFDataGetBytePtr (data),
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
596 CFDataGetLength (data), to_type, result);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
597 CFRelease (data);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
598 }
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
599 else
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
600 err = memFullErr;
70301
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
601
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
602 if (err != noErr)
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
603 {
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
604 /* Just to be paranoid ... */
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
605 FSRef fref;
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
606 char *buf;
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
607
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
608 buf = xmalloc (data_size + 1);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
609 memcpy (buf, data_ptr, data_size);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
610 buf[data_size] = '\0';
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
611 err = FSPathMakeRef (buf, &fref, NULL);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
612 xfree (buf);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
613 if (err == noErr)
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
614 err = AECoercePtr (typeFSRef, &fref, sizeof (FSRef),
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
615 to_type, result);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
616 }
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
617 #else
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
618 FSSpec fs;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
619 char *buf;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
620
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
621 buf = xmalloc (data_size + 1);
70069
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
622 memcpy (buf, data_ptr, data_size);
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
623 buf[data_size] = '\0';
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
624 err = posix_pathname_to_fsspec (buf, &fs);
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
625 xfree (buf);
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
626 if (err == noErr)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
627 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result);
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
628 #endif
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
629 }
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
630 else if (to_type == TYPE_FILE_NAME)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
631 /* Coercion to undecoded file name. */
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
632 {
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
633 #ifdef MAC_OSX
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
634 CFURLRef url = NULL;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
635 CFStringRef str = NULL;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
636 CFDataRef data = NULL;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
637
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
638 if (type_code == typeFileURL)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
639 url = CFURLCreateWithBytes (NULL, data_ptr, data_size,
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
640 kCFStringEncodingUTF8, NULL);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
641 else
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
642 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
643 AEDesc desc;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
644 Size size;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
645 char *buf;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
646
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
647 err = AECoercePtr (type_code, data_ptr, data_size,
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
648 typeFileURL, &desc);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
649 if (err == noErr)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
650 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
651 size = AEGetDescDataSize (&desc);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
652 buf = xmalloc (size);
70069
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
653 err = AEGetDescData (&desc, buf, size);
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
654 if (err == noErr)
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
655 url = CFURLCreateWithBytes (NULL, buf, size,
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
656 kCFStringEncodingUTF8, NULL);
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
657 xfree (buf);
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
658 AEDisposeDesc (&desc);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
659 }
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
660 }
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
661 if (url)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
662 {
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
663 str = CFURLCopyFileSystemPath (url, kCFURLPOSIXPathStyle);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
664 CFRelease (url);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
665 }
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
666 if (str)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
667 {
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
668 data = CFStringCreateExternalRepresentation (NULL, str,
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
669 kCFStringEncodingUTF8,
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
670 '\0');
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
671 CFRelease (str);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
672 }
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
673 if (data)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
674 {
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
675 err = AECreateDesc (TYPE_FILE_NAME, CFDataGetBytePtr (data),
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
676 CFDataGetLength (data), result);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
677 CFRelease (data);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
678 }
70301
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
679
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
680 if (err != noErr)
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
681 {
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
682 /* Coercion from typeAlias to typeFileURL fails on Mac OS X
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
683 10.2. In such cases, try typeFSRef as a target type. */
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
684 char file_name[MAXPATHLEN];
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
685
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
686 if (type_code == typeFSRef && data_size == sizeof (FSRef))
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
687 err = FSRefMakePath (data_ptr, file_name, sizeof (file_name));
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
688 else
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
689 {
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
690 AEDesc desc;
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
691 FSRef fref;
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
692
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
693 err = AECoercePtr (type_code, data_ptr, data_size,
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
694 typeFSRef, &desc);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
695 if (err == noErr)
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
696 {
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
697 err = AEGetDescData (&desc, &fref, sizeof (FSRef));
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
698 AEDisposeDesc (&desc);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
699 }
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
700 if (err == noErr)
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
701 err = FSRefMakePath (&fref, file_name, sizeof (file_name));
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
702 }
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
703 if (err == noErr)
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
704 err = AECreateDesc (TYPE_FILE_NAME, file_name,
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
705 strlen (file_name), result);
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
706 }
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
707 #else
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
708 char file_name[MAXPATHLEN];
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
709
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
710 if (type_code == typeFSS && data_size == sizeof (FSSpec))
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
711 err = fsspec_to_posix_pathname (data_ptr, file_name,
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
712 sizeof (file_name) - 1);
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
713 else
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
714 {
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
715 AEDesc desc;
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
716 FSSpec fs;
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
717
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
718 err = AECoercePtr (type_code, data_ptr, data_size, typeFSS, &desc);
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
719 if (err == noErr)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
720 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
721 #if TARGET_API_MAC_CARBON
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
722 err = AEGetDescData (&desc, &fs, sizeof (FSSpec));
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
723 #else
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
724 fs = *(FSSpec *)(*(desc.dataHandle));
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
725 #endif
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
726 AEDisposeDesc (&desc);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
727 }
70301
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
728 if (err == noErr)
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
729 err = fsspec_to_posix_pathname (&fs, file_name,
9547c2b60f39 (mac_coerce_file_name_ptr): Try typeFSRef if coercion
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70069
diff changeset
730 sizeof (file_name) - 1);
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
731 }
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
732 if (err == noErr)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
733 err = AECreateDesc (TYPE_FILE_NAME, file_name,
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
734 strlen (file_name), result);
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
735 #endif
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
736 }
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
737 else
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
738 abort ();
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
739
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
740 if (err != noErr)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
741 return errAECoercionFail;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
742 return noErr;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
743 }
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
744
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
745 static pascal OSErr
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
746 mac_coerce_file_name_desc (from_desc, to_type, handler_refcon, result)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
747 const AEDesc *from_desc;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
748 DescType to_type;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
749 long handler_refcon;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
750 AEDesc *result;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
751 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
752 OSErr err = noErr;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
753 DescType from_type = from_desc->descriptorType;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
754
68037
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
755 if (from_type == typeNull)
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
756 err = errAECoercionFail;
e70c943e7ff3 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67786
diff changeset
757 else if (from_type == to_type || to_type == typeWildCard)
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
758 err = AEDuplicateDesc (from_desc, result);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
759 else
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
760 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
761 char *data_ptr;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
762 Size data_size;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
763
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
764 #if TARGET_API_MAC_CARBON
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
765 data_size = AEGetDescDataSize (from_desc);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
766 #else
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
767 data_size = GetHandleSize (from_desc->dataHandle);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
768 #endif
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
769 data_ptr = xmalloc (data_size);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
770 #if TARGET_API_MAC_CARBON
70069
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
771 err = AEGetDescData (from_desc, data_ptr, data_size);
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
772 #else
70069
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
773 memcpy (data_ptr, *(from_desc->dataHandle), data_size);
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
774 #endif
70069
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
775 if (err == noErr)
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
776 err = mac_coerce_file_name_ptr (from_type, data_ptr,
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
777 data_size, to_type,
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
778 handler_refcon, result);
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
779 xfree (data_ptr);
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
780 }
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
781
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
782 if (err != noErr)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
783 return errAECoercionFail;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
784 return noErr;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
785 }
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
787 OSErr
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
788 init_coercion_handler ()
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
789 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
790 OSErr err;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
791
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
792 static AECoercePtrUPP coerce_file_name_ptrUPP = NULL;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
793 static AECoerceDescUPP coerce_file_name_descUPP = NULL;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
794
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
795 if (coerce_file_name_ptrUPP == NULL)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
796 {
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
797 coerce_file_name_ptrUPP = NewAECoercePtrUPP (mac_coerce_file_name_ptr);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
798 coerce_file_name_descUPP = NewAECoerceDescUPP (mac_coerce_file_name_desc);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
799 }
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
800
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
801 err = AEInstallCoercionHandler (TYPE_FILE_NAME, typeWildCard,
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
802 (AECoercionHandlerUPP)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
803 coerce_file_name_ptrUPP, 0, false, false);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
804 if (err == noErr)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
805 err = AEInstallCoercionHandler (typeWildCard, TYPE_FILE_NAME,
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
806 (AECoercionHandlerUPP)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
807 coerce_file_name_ptrUPP, 0, false, false);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
808 if (err == noErr)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
809 err = AEInstallCoercionHandler (TYPE_FILE_NAME, typeWildCard,
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
810 coerce_file_name_descUPP, 0, true, false);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
811 if (err == noErr)
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
812 err = AEInstallCoercionHandler (typeWildCard, TYPE_FILE_NAME,
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
813 coerce_file_name_descUPP, 0, true, false);
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
814 return err;
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
815 }
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
816
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
817 #if TARGET_API_MAC_CARBON
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
818 OSErr
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
819 create_apple_event (class, id, result)
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
820 AEEventClass class;
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
821 AEEventID id;
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
822 AppleEvent *result;
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
823 {
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
824 OSErr err;
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
825 static const ProcessSerialNumber psn = {0, kCurrentProcess};
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
826 AEAddressDesc address_desc;
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
827
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
828 err = AECreateDesc (typeProcessSerialNumber, &psn,
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
829 sizeof (ProcessSerialNumber), &address_desc);
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
830 if (err == noErr)
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
831 {
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
832 err = AECreateAppleEvent (class, id,
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
833 &address_desc, /* NULL is not allowed
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
834 on Mac OS Classic. */
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
835 kAutoGenerateReturnID,
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
836 kAnyTransactionID, result);
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
837 AEDisposeDesc (&address_desc);
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
838 }
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
839
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
840 return err;
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
841 }
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
842
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
843 Lisp_Object
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
844 mac_event_parameters_to_lisp (event, num_params, names, types)
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
845 EventRef event;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
846 UInt32 num_params;
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
847 const EventParamName *names;
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
848 const EventParamType *types;
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
849 {
72542
bb89b5bbed54 (create_apple_event_from_event_ref, select)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71838
diff changeset
850 OSStatus err;
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
851 Lisp_Object result = Qnil;
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
852 UInt32 i;
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
853 ByteCount size;
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
854 #ifdef MAC_OSX
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
855 CFStringRef string;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
856 CFDataRef data;
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
857 #endif
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
858 char *buf = NULL;
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
859
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
860 for (i = 0; i < num_params; i++)
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
861 {
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
862 EventParamName name = names[i];
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
863 EventParamType type = types[i];
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
864
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
865 switch (type)
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
866 {
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
867 #ifdef MAC_OSX
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
868 case typeCFStringRef:
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
869 err = GetEventParameter (event, name, typeCFStringRef, NULL,
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
870 sizeof (CFStringRef), NULL, &string);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
871 if (err != noErr)
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
872 break;
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
873 data = CFStringCreateExternalRepresentation (NULL, string,
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
874 kCFStringEncodingUTF8,
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
875 '?');
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
876 if (data == NULL)
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
877 break;
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
878 name = EndianU32_NtoB (name);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
879 type = EndianU32_NtoB (typeUTF8Text);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
880 result =
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
881 Fcons (Fcons (make_unibyte_string ((char *) &name, 4),
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
882 Fcons (make_unibyte_string ((char *) &type, 4),
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
883 make_unibyte_string (CFDataGetBytePtr (data),
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
884 CFDataGetLength (data)))),
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
885 result);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
886 CFRelease (data);
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
887 break;
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
888 #endif
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
889
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
890 default:
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
891 err = GetEventParameter (event, name, type, NULL, 0, &size, NULL);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
892 if (err != noErr)
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
893 break;
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
894 buf = xrealloc (buf, size);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
895 err = GetEventParameter (event, name, type, NULL, size, NULL, buf);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
896 if (err == noErr)
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
897 {
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
898 name = EndianU32_NtoB (name);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
899 type = EndianU32_NtoB (type);
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
900 result =
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
901 Fcons (Fcons (make_unibyte_string ((char *) &name, 4),
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
902 Fcons (make_unibyte_string ((char *) &type, 4),
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
903 make_unibyte_string (buf, size))),
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
904 result);
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
905 }
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
906 break;
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
907 }
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
908 }
95481
4390d64d3328 Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
909 xfree (buf);
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
910
80513
e58dfb854c06 (create_apple_event) [TARGET_API_MAC_CARBON]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80450
diff changeset
911 return result;
70381
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
912 }
606c88bcaeee (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70301
diff changeset
913 #endif /* TARGET_API_MAC_CARBON */
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
914
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
915 /***********************************************************************
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
916 Conversion between Lisp and Core Foundation objects
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
917 ***********************************************************************/
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
918
58752
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
919 #if TARGET_API_MAC_CARBON
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
920 static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
921 static Lisp_Object Qarray, Qdictionary;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
922
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
923 struct cfdict_context
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
924 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
925 Lisp_Object *result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
926 int with_tag, hash_bound;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
927 };
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
928
61572
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
929 /* C string to CFString. */
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
930
58752
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
931 CFStringRef
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
932 cfstring_create_with_utf8_cstring (c_str)
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
933 const char *c_str;
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
934 {
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
935 CFStringRef str;
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
936
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
937 str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingUTF8);
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
938 if (str == NULL)
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
939 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
940 str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingMacRoman);
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
941
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
942 return str;
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
943 }
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
944
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
945
61572
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
946 /* Lisp string to CFString. */
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
947
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
948 CFStringRef
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
949 cfstring_create_with_string (s)
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
950 Lisp_Object s;
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
951 {
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
952 CFStringRef string = NULL;
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
953
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
954 if (STRING_MULTIBYTE (s))
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
955 {
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
956 char *p, *end = SDATA (s) + SBYTES (s);
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
957
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
958 for (p = SDATA (s); p < end; p++)
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
959 if (!isascii (*p))
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
960 {
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
961 s = ENCODE_UTF_8 (s);
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
962 break;
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
963 }
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
964 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
965 kCFStringEncodingUTF8, false);
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
966 }
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
967
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
968 if (string == NULL)
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
969 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
970 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
971 kCFStringEncodingMacRoman, false);
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
972
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
973 return string;
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
974 }
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
975
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
976
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
977 /* From CFData to a lisp string. Always returns a unibyte string. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
978
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
979 Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
980 cfdata_to_lisp (data)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
981 CFDataRef data;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
982 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
983 CFIndex len = CFDataGetLength (data);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
984 Lisp_Object result = make_uninit_string (len);
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
985
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
986 CFDataGetBytes (data, CFRangeMake (0, len), SDATA (result));
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
987
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
988 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
989 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
990
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
991
67088
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
992 /* From CFString to a lisp string. Returns a unibyte string
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
993 containing a UTF-8 byte sequence. */
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
994
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
995 Lisp_Object
67088
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
996 cfstring_to_lisp_nodecode (string)
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
997 CFStringRef string;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
998 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
999 Lisp_Object result = Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1000 const char *s = CFStringGetCStringPtr (string, kCFStringEncodingUTF8);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1001
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1002 if (s)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1003 result = make_unibyte_string (s, strlen (s));
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1004 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1005 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1006 CFDataRef data =
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1007 CFStringCreateExternalRepresentation (NULL, string,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1008 kCFStringEncodingUTF8, '?');
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1009
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1010 if (data)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1011 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1012 result = cfdata_to_lisp (data);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1013 CFRelease (data);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1014 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1015 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1016
67088
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1017 return result;
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1018 }
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1019
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1020
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1021 /* From CFString to a lisp string. Never returns a unibyte string
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1022 (even if it only contains ASCII characters).
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1023 This may cause GC during code conversion. */
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1024
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1025 Lisp_Object
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1026 cfstring_to_lisp (string)
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1027 CFStringRef string;
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1028 {
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1029 Lisp_Object result = cfstring_to_lisp_nodecode (string);
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1030
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1031 if (!NILP (result))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1032 {
67088
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1033 result = code_convert_string_norecord (result, Qutf_8, 0);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1034 /* This may be superfluous. Just to make sure that the result
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1035 is a multibyte string. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1036 result = string_to_multibyte (result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1037 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1038
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1039 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1040 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1041
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1042
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1043 /* CFNumber to a lisp integer or a lisp float. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1044
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1045 Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1046 cfnumber_to_lisp (number)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1047 CFNumberRef number;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1048 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1049 Lisp_Object result = Qnil;
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1050 #if BITS_PER_EMACS_INT > 32
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1051 SInt64 int_val;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1052 CFNumberType emacs_int_type = kCFNumberSInt64Type;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1053 #else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1054 SInt32 int_val;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1055 CFNumberType emacs_int_type = kCFNumberSInt32Type;
58752
4ad0594e1ac4 * macterm.h (cfstring_create_with_utf8_cstring): Added prototype.
Steven Tamm <steventamm@mac.com>
parents: 57425
diff changeset
1056 #endif
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1057 double float_val;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1058
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1059 if (CFNumberGetValue (number, emacs_int_type, &int_val)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1060 && !FIXNUM_OVERFLOW_P (int_val))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1061 result = make_number (int_val);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1062 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1063 if (CFNumberGetValue (number, kCFNumberDoubleType, &float_val))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1064 result = make_float (float_val);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1065 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1066 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1067
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1068
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1069 /* CFDate to a list of three integers as in a return value of
61338
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
1070 `current-time'. */
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1071
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1072 Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1073 cfdate_to_lisp (date)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1074 CFDateRef date;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1075 {
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
1076 CFTimeInterval sec;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
1077 int high, low, microsec;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
1078
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
1079 sec = CFDateGetAbsoluteTime (date) + kCFAbsoluteTimeIntervalSince1970;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1080 high = sec / 65536.0;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1081 low = sec - high * 65536.0;
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
1082 microsec = (sec - floor (sec)) * 1000000.0;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
1083
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
1084 return list3 (make_number (high), make_number (low), make_number (microsec));
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1085 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1086
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1087
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1088 /* CFBoolean to a lisp symbol, `t' or `nil'. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1089
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1090 Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1091 cfboolean_to_lisp (boolean)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1092 CFBooleanRef boolean;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1093 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1094 return CFBooleanGetValue (boolean) ? Qt : Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1095 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1096
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1097
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1098 /* Any Core Foundation object to a (lengthy) lisp string. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1099
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1100 Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1101 cfobject_desc_to_lisp (object)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1102 CFTypeRef object;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1103 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1104 Lisp_Object result = Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1105 CFStringRef desc = CFCopyDescription (object);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1106
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1107 if (desc)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1108 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1109 result = cfstring_to_lisp (desc);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1110 CFRelease (desc);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1111 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1112
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1113 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1114 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1115
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1116
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1117 /* Callback functions for cfproperty_list_to_lisp. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1118
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1119 static void
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1120 cfdictionary_add_to_list (key, value, context)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1121 const void *key;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1122 const void *value;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1123 void *context;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1124 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1125 struct cfdict_context *cxt = (struct cfdict_context *)context;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1126
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1127 *cxt->result =
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1128 Fcons (Fcons (cfstring_to_lisp (key),
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1129 cfproperty_list_to_lisp (value, cxt->with_tag,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1130 cxt->hash_bound)),
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1131 *cxt->result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1132 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1133
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1134 static void
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1135 cfdictionary_puthash (key, value, context)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1136 const void *key;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1137 const void *value;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1138 void *context;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1139 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1140 Lisp_Object lisp_key = cfstring_to_lisp (key);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1141 struct cfdict_context *cxt = (struct cfdict_context *)context;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1142 struct Lisp_Hash_Table *h = XHASH_TABLE (*(cxt->result));
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1143 unsigned hash_code;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1144
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1145 hash_lookup (h, lisp_key, &hash_code);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1146 hash_put (h, lisp_key,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1147 cfproperty_list_to_lisp (value, cxt->with_tag, cxt->hash_bound),
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1148 hash_code);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1149 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1150
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1151
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1152 /* Convert CFPropertyList PLIST to a lisp object. If WITH_TAG is
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1153 non-zero, a symbol that represents the type of the original Core
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1154 Foundation object is prepended. HASH_BOUND specifies which kinds
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1155 of the lisp objects, alists or hash tables, are used as the targets
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1156 of the conversion from CFDictionary. If HASH_BOUND is negative,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1157 always generate alists. If HASH_BOUND >= 0, generate an alist if
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1158 the number of keys in the dictionary is smaller than HASH_BOUND,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1159 and a hash table otherwise. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1160
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1161 Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1162 cfproperty_list_to_lisp (plist, with_tag, hash_bound)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1163 CFPropertyListRef plist;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1164 int with_tag, hash_bound;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1165 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1166 CFTypeID type_id = CFGetTypeID (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1167 Lisp_Object tag = Qnil, result = Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1168 struct gcpro gcpro1, gcpro2;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1169
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1170 GCPRO2 (tag, result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1171
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1172 if (type_id == CFStringGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1173 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1174 tag = Qstring;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1175 result = cfstring_to_lisp (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1176 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1177 else if (type_id == CFNumberGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1178 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1179 tag = Qnumber;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1180 result = cfnumber_to_lisp (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1181 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1182 else if (type_id == CFBooleanGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1183 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1184 tag = Qboolean;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1185 result = cfboolean_to_lisp (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1186 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1187 else if (type_id == CFDateGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1188 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1189 tag = Qdate;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1190 result = cfdate_to_lisp (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1191 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1192 else if (type_id == CFDataGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1193 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1194 tag = Qdata;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1195 result = cfdata_to_lisp (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1196 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1197 else if (type_id == CFArrayGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1198 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1199 CFIndex index, count = CFArrayGetCount (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1200
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1201 tag = Qarray;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1202 result = Fmake_vector (make_number (count), Qnil);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1203 for (index = 0; index < count; index++)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1204 XVECTOR (result)->contents[index] =
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1205 cfproperty_list_to_lisp (CFArrayGetValueAtIndex (plist, index),
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1206 with_tag, hash_bound);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1207 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1208 else if (type_id == CFDictionaryGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1209 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1210 struct cfdict_context context;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1211 CFIndex count = CFDictionaryGetCount (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1212
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1213 tag = Qdictionary;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1214 context.result = &result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1215 context.with_tag = with_tag;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1216 context.hash_bound = hash_bound;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1217 if (hash_bound < 0 || count < hash_bound)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1218 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1219 result = Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1220 CFDictionaryApplyFunction (plist, cfdictionary_add_to_list,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1221 &context);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1222 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1223 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1224 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1225 result = make_hash_table (Qequal,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1226 make_number (count),
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1227 make_float (DEFAULT_REHASH_SIZE),
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1228 make_float (DEFAULT_REHASH_THRESHOLD),
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1229 Qnil, Qnil, Qnil);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1230 CFDictionaryApplyFunction (plist, cfdictionary_puthash,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1231 &context);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1232 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1233 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1234 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1235 abort ();
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1236
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1237 UNGCPRO;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1238
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1239 if (with_tag)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1240 result = Fcons (tag, result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1241
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1242 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1243 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1244 #endif
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1245
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1246
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1247 /***********************************************************************
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1248 Emulation of the X Resource Manager
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1249 ***********************************************************************/
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1250
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1251 /* Parser functions for resource lines. Each function takes an
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1252 address of a variable whose value points to the head of a string.
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1253 The value will be advanced so that it points to the next character
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1254 of the parsed part when the function returns.
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1255
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1256 A resource name such as "Emacs*font" is parsed into a non-empty
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1257 list called `quarks'. Each element is either a Lisp string that
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1258 represents a concrete component, a Lisp symbol LOOSE_BINDING
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1259 (actually Qlambda) that represents any number (>=0) of intervening
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1260 components, or a Lisp symbol SINGLE_COMPONENT (actually Qquote)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1261 that represents as any single component. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1262
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1263 #define P (*p)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1264
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1265 #define LOOSE_BINDING Qlambda /* '*' ("L"oose) */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1266 #define SINGLE_COMPONENT Qquote /* '?' ("Q"uestion) */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1267
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1268 static void
60640
7dd25916c6bb Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60632
diff changeset
1269 skip_white_space (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1270 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1271 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1272 /* WhiteSpace = {<space> | <horizontal tab>} */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1273 while (*P == ' ' || *P == '\t')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1274 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1275 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1276
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1277 static int
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1278 parse_comment (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1279 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1280 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1281 /* Comment = "!" {<any character except null or newline>} */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1282 if (*P == '!')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1283 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1284 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1285 while (*P)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1286 if (*P++ == '\n')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1287 break;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1288 return 1;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1289 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1290 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1291 return 0;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1292 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1293
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1294 /* Don't interpret filename. Just skip until the newline. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1295 static int
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1296 parse_include_file (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1297 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1298 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1299 /* IncludeFile = "#" WhiteSpace "include" WhiteSpace FileName WhiteSpace */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1300 if (*P == '#')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1301 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1302 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1303 while (*P)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1304 if (*P++ == '\n')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1305 break;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1306 return 1;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1307 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1308 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1309 return 0;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1310 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1311
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1312 static char
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1313 parse_binding (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1314 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1315 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1316 /* Binding = "." | "*" */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1317 if (*P == '.' || *P == '*')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1318 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1319 char binding = *P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1320
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1321 while (*P == '.' || *P == '*')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1322 if (*P++ == '*')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1323 binding = '*';
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1324 return binding;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1325 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1326 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1327 return '\0';
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1328 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1329
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1330 static Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1331 parse_component (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1332 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1333 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1334 /* Component = "?" | ComponentName
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1335 ComponentName = NameChar {NameChar}
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1336 NameChar = "a"-"z" | "A"-"Z" | "0"-"9" | "_" | "-" */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1337 if (*P == '?')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1338 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1339 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1340 return SINGLE_COMPONENT;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1341 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1342 else if (isalnum (*P) || *P == '_' || *P == '-')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1343 {
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1344 const char *start = P++;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1345
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1346 while (isalnum (*P) || *P == '_' || *P == '-')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1347 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1348
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1349 return make_unibyte_string (start, P - start);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1350 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1351 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1352 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1353 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1354
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1355 static Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1356 parse_resource_name (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1357 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1358 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1359 Lisp_Object result = Qnil, component;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1360 char binding;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1361
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1362 /* ResourceName = [Binding] {Component Binding} ComponentName */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1363 if (parse_binding (p) == '*')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1364 result = Fcons (LOOSE_BINDING, result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1365
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1366 component = parse_component (p);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1367 if (NILP (component))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1368 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1369
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1370 result = Fcons (component, result);
61338
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
1371 while ((binding = parse_binding (p)) != '\0')
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1372 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1373 if (binding == '*')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1374 result = Fcons (LOOSE_BINDING, result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1375 component = parse_component (p);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1376 if (NILP (component))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1377 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1378 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1379 result = Fcons (component, result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1380 }
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1381
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1382 /* The final component should not be '?'. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1383 if (EQ (component, SINGLE_COMPONENT))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1384 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1385
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1386 return Fnreverse (result);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1387 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1388
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1389 static Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1390 parse_value (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1391 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1392 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1393 char *q, *buf;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1394 Lisp_Object seq = Qnil, result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1395 int buf_len, total_len = 0, len, continue_p;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1396
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1397 q = strchr (P, '\n');
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1398 buf_len = q ? q - P : strlen (P);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1399 buf = xmalloc (buf_len);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1400
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1401 while (1)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1402 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1403 q = buf;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1404 continue_p = 0;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1405 while (*P)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1406 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1407 if (*P == '\n')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1408 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1409 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1410 break;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1411 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1412 else if (*P == '\\')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1413 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1414 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1415 if (*P == '\0')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1416 break;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1417 else if (*P == '\n')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1418 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1419 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1420 continue_p = 1;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1421 break;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1422 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1423 else if (*P == 'n')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1424 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1425 *q++ = '\n';
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1426 P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1427 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1428 else if ('0' <= P[0] && P[0] <= '7'
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1429 && '0' <= P[1] && P[1] <= '7'
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1430 && '0' <= P[2] && P[2] <= '7')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1431 {
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
1432 *q++ = ((P[0] - '0') << 6) + ((P[1] - '0') << 3) + (P[2] - '0');
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1433 P += 3;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1434 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1435 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1436 *q++ = *P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1437 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1438 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1439 *q++ = *P++;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1440 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1441 len = q - buf;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1442 seq = Fcons (make_unibyte_string (buf, len), seq);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1443 total_len += len;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1444
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1445 if (continue_p)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1446 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1447 q = strchr (P, '\n');
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1448 len = q ? q - P : strlen (P);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1449 if (len > buf_len)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1450 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1451 xfree (buf);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1452 buf_len = len;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1453 buf = xmalloc (buf_len);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1454 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1455 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1456 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1457 break;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1458 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1459 xfree (buf);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1460
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1461 if (SBYTES (XCAR (seq)) == total_len)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1462 return make_string (SDATA (XCAR (seq)), total_len);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1463 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1464 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1465 buf = xmalloc (total_len);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1466 q = buf + total_len;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1467 for (; CONSP (seq); seq = XCDR (seq))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1468 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1469 len = SBYTES (XCAR (seq));
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1470 q -= len;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1471 memcpy (q, SDATA (XCAR (seq)), len);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1472 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1473 result = make_string (buf, total_len);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1474 xfree (buf);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1475 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1476 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1477 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1478
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1479 static Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1480 parse_resource_line (p)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1481 const char **p;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1482 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1483 Lisp_Object quarks, value;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1484
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1485 /* ResourceLine = Comment | IncludeFile | ResourceSpec | <empty line> */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1486 if (parse_comment (p) || parse_include_file (p))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1487 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1488
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1489 /* ResourceSpec = WhiteSpace ResourceName WhiteSpace ":" WhiteSpace Value */
60640
7dd25916c6bb Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60632
diff changeset
1490 skip_white_space (p);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1491 quarks = parse_resource_name (p);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1492 if (NILP (quarks))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1493 goto cleanup;
60640
7dd25916c6bb Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60632
diff changeset
1494 skip_white_space (p);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1495 if (*P != ':')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1496 goto cleanup;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1497 P++;
60640
7dd25916c6bb Fix typo (skip_while_space -> skip_white_space).
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60632
diff changeset
1498 skip_white_space (p);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1499 value = parse_value (p);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1500 return Fcons (quarks, value);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1501
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1502 cleanup:
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1503 /* Skip the remaining data as a dummy value. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1504 parse_value (p);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1505 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1506 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1507
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1508 #undef P
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1509
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1510 /* Equivalents of X Resource Manager functions.
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1511
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1512 An X Resource Database acts as a collection of resource names and
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1513 associated values. It is implemented as a trie on quarks. Namely,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1514 each edge is labeled by either a string, LOOSE_BINDING, or
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1515 SINGLE_COMPONENT. Each node has a node id, which is a unique
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1516 nonnegative integer, and the root node id is 0. A database is
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1517 implemented as a hash table that maps a pair (SRC-NODE-ID .
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1518 EDGE-LABEL) to DEST-NODE-ID. It also holds a maximum node id used
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1519 in the table as a value for HASHKEY_MAX_NID. A value associated to
66879
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1520 a node is recorded as a value for the node id.
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1521
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1522 A database also has a cache for past queries as a value for
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1523 HASHKEY_QUERY_CACHE. It is another hash table that maps
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1524 "NAME-STRING\0CLASS-STRING" to the result of the query. */
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1525
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1526 #define HASHKEY_MAX_NID (make_number (0))
66879
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1527 #define HASHKEY_QUERY_CACHE (make_number (-1))
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1528
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1529 static XrmDatabase
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1530 xrm_create_database ()
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1531 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1532 XrmDatabase database;
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1533
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1534 database = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1535 make_float (DEFAULT_REHASH_SIZE),
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1536 make_float (DEFAULT_REHASH_THRESHOLD),
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1537 Qnil, Qnil, Qnil);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1538 Fputhash (HASHKEY_MAX_NID, make_number (0), database);
66879
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1539 Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1540
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1541 return database;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1542 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1543
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1544 static void
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1545 xrm_q_put_resource (database, quarks, value)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1546 XrmDatabase database;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1547 Lisp_Object quarks, value;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1548 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1549 struct Lisp_Hash_Table *h = XHASH_TABLE (database);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1550 unsigned hash_code;
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1551 int max_nid, i;
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1552 Lisp_Object node_id, key;
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1553
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1554 max_nid = XINT (Fgethash (HASHKEY_MAX_NID, database, Qnil));
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1555
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1556 XSETINT (node_id, 0);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1557 for (; CONSP (quarks); quarks = XCDR (quarks))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1558 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1559 key = Fcons (node_id, XCAR (quarks));
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1560 i = hash_lookup (h, key, &hash_code);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1561 if (i < 0)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1562 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1563 max_nid++;
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
1564 XSETINT (node_id, max_nid);
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1565 hash_put (h, key, node_id, hash_code);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1566 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1567 else
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1568 node_id = HASH_VALUE (h, i);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1569 }
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1570 Fputhash (node_id, value, database);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1571
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1572 Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database);
66879
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1573 Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1574 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1575
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1576 /* Merge multiple resource entries specified by DATA into a resource
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1577 database DATABASE. DATA points to the head of a null-terminated
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1578 string consisting of multiple resource lines. It's like a
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1579 combination of XrmGetStringDatabase and XrmMergeDatabases. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1580
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1581 void
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1582 xrm_merge_string_database (database, data)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1583 XrmDatabase database;
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1584 const char *data;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1585 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1586 Lisp_Object quarks_value;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1587
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1588 while (*data)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1589 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1590 quarks_value = parse_resource_line (&data);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1591 if (!NILP (quarks_value))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1592 xrm_q_put_resource (database,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1593 XCAR (quarks_value), XCDR (quarks_value));
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1594 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1595 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1596
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1597 static Lisp_Object
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1598 xrm_q_get_resource_1 (database, node_id, quark_name, quark_class)
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1599 XrmDatabase database;
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1600 Lisp_Object node_id, quark_name, quark_class;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1601 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1602 struct Lisp_Hash_Table *h = XHASH_TABLE (database);
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1603 Lisp_Object key, labels[3], value;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1604 int i, k;
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1605
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1606 if (!CONSP (quark_name))
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1607 return Fgethash (node_id, database, Qnil);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1608
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1609 /* First, try tight bindings */
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1610 labels[0] = XCAR (quark_name);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1611 labels[1] = XCAR (quark_class);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1612 labels[2] = SINGLE_COMPONENT;
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1613
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1614 key = Fcons (node_id, Qnil);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1615 for (k = 0; k < sizeof (labels) / sizeof (*labels); k++)
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1616 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1617 XSETCDR (key, labels[k]);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1618 i = hash_lookup (h, key, NULL);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1619 if (i >= 0)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1620 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1621 value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i),
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1622 XCDR (quark_name), XCDR (quark_class));
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1623 if (!NILP (value))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1624 return value;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1625 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1626 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1627
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1628 /* Then, try loose bindings */
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1629 XSETCDR (key, LOOSE_BINDING);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1630 i = hash_lookup (h, key, NULL);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1631 if (i >= 0)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1632 {
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1633 value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i),
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1634 quark_name, quark_class);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1635 if (!NILP (value))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1636 return value;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1637 else
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1638 return xrm_q_get_resource_1 (database, node_id,
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1639 XCDR (quark_name), XCDR (quark_class));
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1640 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1641 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1642 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1643 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1644
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1645 static Lisp_Object
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1646 xrm_q_get_resource (database, quark_name, quark_class)
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1647 XrmDatabase database;
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1648 Lisp_Object quark_name, quark_class;
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1649 {
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1650 return xrm_q_get_resource_1 (database, make_number (0),
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1651 quark_name, quark_class);
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1652 }
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1653
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1654 /* Retrieve a resource value for the specified NAME and CLASS from the
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1655 resource database DATABASE. It corresponds to XrmGetResource. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1656
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1657 Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1658 xrm_get_resource (database, name, class)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1659 XrmDatabase database;
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1660 const char *name, *class;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1661 {
66879
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1662 Lisp_Object key, query_cache, quark_name, quark_class, tmp;
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1663 int i, nn, nc;
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1664 struct Lisp_Hash_Table *h;
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1665 unsigned hash_code;
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1666
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1667 nn = strlen (name);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1668 nc = strlen (class);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1669 key = make_uninit_string (nn + nc + 1);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1670 strcpy (SDATA (key), name);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1671 strncpy (SDATA (key) + nn + 1, class, nc);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1672
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1673 query_cache = Fgethash (HASHKEY_QUERY_CACHE, database, Qnil);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1674 if (NILP (query_cache))
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1675 {
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1676 query_cache = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1677 make_float (DEFAULT_REHASH_SIZE),
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1678 make_float (DEFAULT_REHASH_THRESHOLD),
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1679 Qnil, Qnil, Qnil);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1680 Fputhash (HASHKEY_QUERY_CACHE, query_cache, database);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1681 }
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1682 h = XHASH_TABLE (query_cache);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1683 i = hash_lookup (h, key, &hash_code);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1684 if (i >= 0)
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1685 return HASH_VALUE (h, i);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1686
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1687 quark_name = parse_resource_name (&name);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1688 if (*name != '\0')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1689 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1690 for (tmp = quark_name, nn = 0; CONSP (tmp); tmp = XCDR (tmp), nn++)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1691 if (!STRINGP (XCAR (tmp)))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1692 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1693
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1694 quark_class = parse_resource_name (&class);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1695 if (*class != '\0')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1696 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1697 for (tmp = quark_class, nc = 0; CONSP (tmp); tmp = XCDR (tmp), nc++)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1698 if (!STRINGP (XCAR (tmp)))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1699 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1700
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1701 if (nn != nc)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1702 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1703 else
66879
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1704 {
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1705 tmp = xrm_q_get_resource (database, quark_name, quark_class);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1706 hash_put (h, key, tmp, hash_code);
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1707 return tmp;
6a3a5a23008d (HASHKEY_QUERY_CACHE): New define.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66763
diff changeset
1708 }
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1709 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1710
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1711 #if TARGET_API_MAC_CARBON
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1712 static Lisp_Object
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1713 xrm_cfproperty_list_to_value (plist)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1714 CFPropertyListRef plist;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1715 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1716 CFTypeID type_id = CFGetTypeID (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1717
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1718 if (type_id == CFStringGetTypeID ())
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
1719 return cfstring_to_lisp (plist);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1720 else if (type_id == CFNumberGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1721 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1722 CFStringRef string;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1723 Lisp_Object result = Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1724
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1725 string = CFStringCreateWithFormat (NULL, NULL, CFSTR ("%@"), plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1726 if (string)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1727 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1728 result = cfstring_to_lisp (string);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1729 CFRelease (string);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1730 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1731 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1732 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1733 else if (type_id == CFBooleanGetTypeID ())
60660
40fe172d199c (HASHKEY_TERMINAL): Remove.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60640
diff changeset
1734 return build_string (CFBooleanGetValue (plist) ? "true" : "false");
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1735 else if (type_id == CFDataGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1736 return cfdata_to_lisp (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1737 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1738 return Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1739 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1740 #endif
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1741
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1742 /* Create a new resource database from the preferences for the
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1743 application APPLICATION. APPLICATION is either a string that
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1744 specifies an application ID, or NULL that represents the current
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1745 application. */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1746
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1747 XrmDatabase
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1748 xrm_get_preference_database (application)
73571
fbd883b271ad (create_apple_event_from_event_ref)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73384
diff changeset
1749 const char *application;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1750 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1751 #if TARGET_API_MAC_CARBON
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1752 CFStringRef app_id, *keys, user_doms[2], host_doms[2];
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1753 CFMutableSetRef key_set = NULL;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1754 CFArrayRef key_array;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1755 CFIndex index, count;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1756 char *res_name;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1757 XrmDatabase database;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1758 Lisp_Object quarks = Qnil, value = Qnil;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1759 CFPropertyListRef plist;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1760 int iu, ih;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1761 struct gcpro gcpro1, gcpro2, gcpro3;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1762
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1763 user_doms[0] = kCFPreferencesCurrentUser;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1764 user_doms[1] = kCFPreferencesAnyUser;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1765 host_doms[0] = kCFPreferencesCurrentHost;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1766 host_doms[1] = kCFPreferencesAnyHost;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1767
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1768 database = xrm_create_database ();
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1769
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1770 GCPRO3 (database, quarks, value);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1771
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1772 app_id = kCFPreferencesCurrentApplication;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1773 if (application)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1774 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1775 app_id = cfstring_create_with_utf8_cstring (application);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1776 if (app_id == NULL)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1777 goto out;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1778 }
77140
f9e6e90b6141 (xrm_get_preference_database, Fmac_get_preference)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1779 if (!CFPreferencesAppSynchronize (app_id))
f9e6e90b6141 (xrm_get_preference_database, Fmac_get_preference)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1780 goto out;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1781
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1782 key_set = CFSetCreateMutable (NULL, 0, &kCFCopyStringSetCallBacks);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1783 if (key_set == NULL)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1784 goto out;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1785 for (iu = 0; iu < sizeof (user_doms) / sizeof (*user_doms) ; iu++)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1786 for (ih = 0; ih < sizeof (host_doms) / sizeof (*host_doms); ih++)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1787 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1788 key_array = CFPreferencesCopyKeyList (app_id, user_doms[iu],
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1789 host_doms[ih]);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1790 if (key_array)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1791 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1792 count = CFArrayGetCount (key_array);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1793 for (index = 0; index < count; index++)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1794 CFSetAddValue (key_set,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1795 CFArrayGetValueAtIndex (key_array, index));
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1796 CFRelease (key_array);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1797 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1798 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1799
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1800 count = CFSetGetCount (key_set);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1801 keys = xmalloc (sizeof (CFStringRef) * count);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1802 CFSetGetValues (key_set, (const void **)keys);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1803 for (index = 0; index < count; index++)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1804 {
67088
5e6f93897afb (DECODE_UTF_8): Remove macro.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66879
diff changeset
1805 res_name = SDATA (cfstring_to_lisp_nodecode (keys[index]));
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1806 quarks = parse_resource_name (&res_name);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1807 if (!(NILP (quarks) || *res_name))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1808 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1809 plist = CFPreferencesCopyAppValue (keys[index], app_id);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1810 value = xrm_cfproperty_list_to_value (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1811 CFRelease (plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1812 if (!NILP (value))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1813 xrm_q_put_resource (database, quarks, value);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1814 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1815 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1816
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1817 xfree (keys);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1818 out:
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1819 if (key_set)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1820 CFRelease (key_set);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1821 CFRelease (app_id);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1822
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1823 UNGCPRO;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1824
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1825 return database;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1826 #else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1827 return xrm_create_database ();
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1828 #endif
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1829 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1830
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
1831
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1832 #ifndef MAC_OSX
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1833
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1834 /* The following functions with "sys_" prefix are stubs to Unix
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1835 functions that have already been implemented by CW or MPW. The
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1836 calls to them in Emacs source course are #define'd to call the sys_
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1837 versions by the header files s-mac.h. In these stubs pathnames are
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1838 converted between their Unix and Mac forms. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1839
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1840
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1841 /* Unix epoch is Jan 1, 1970 while Mac epoch is Jan 1, 1904: 66 years
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1842 + 17 leap days. These are for adjusting time values returned by
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1843 MacOS Toolbox functions. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1844
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1845 #define MAC_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1846
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1847 #ifdef __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1848 #if __MSL__ < 0x6000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1849 /* CW Pro 5 epoch is Jan 1, 1900 (aaarghhhhh!); remember, 1900 is not
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1850 a leap year! This is for adjusting time_t values returned by MSL
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1851 functions. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1852 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 70 + 17) * 24 * 60 * 60)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1853 #else /* __MSL__ >= 0x6000 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1854 /* CW changes Pro 6 to follow Unix! */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1855 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1856 #endif /* __MSL__ >= 0x6000 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1857 #elif __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1858 /* MPW library functions follow Unix (confused?). */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1859 #define CW_OR_MPW_UNIX_EPOCH_DIFF ((365L * 66 + 17) * 24 * 60 * 60)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1860 #else /* not __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1861 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1862 #endif /* not __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1863
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1864
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1865 /* Define our own stat function for both MrC and CW. The reason for
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1866 doing this: "stat" is both the name of a struct and function name:
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1867 can't use the same trick like that for sys_open, sys_close, etc. to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1868 redirect Emacs's calls to our own version that converts Unix style
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1869 filenames to Mac style filename because all sorts of compilation
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1870 errors will be generated if stat is #define'd to be sys_stat. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1871
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1872 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1873 stat_noalias (const char *path, struct stat *buf)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1874 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1875 char mac_pathname[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1876 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1877
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1878 if (posix_to_mac_pathname (path, mac_pathname, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1879 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1880
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1881 c2pstr (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1882 cipb.hFileInfo.ioNamePtr = mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1883 cipb.hFileInfo.ioVRefNum = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1884 cipb.hFileInfo.ioDirID = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1885 cipb.hFileInfo.ioFDirIndex = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1886 /* set to 0 to get information about specific dir or file */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1887
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1888 errno = PBGetCatInfo (&cipb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1889 if (errno == -43) /* -43: fnfErr defined in Errors.h */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1890 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1891 if (errno != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1892 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1893
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1894 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* bit 4 = 1 for directories */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1895 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1896 buf->st_mode = S_IFDIR | S_IREAD | S_IEXEC;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1897
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1898 if (!(cipb.hFileInfo.ioFlAttrib & 0x1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1899 buf->st_mode |= S_IWRITE; /* bit 1 = 1 for locked files/directories */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1900 buf->st_ino = cipb.dirInfo.ioDrDirID;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1901 buf->st_dev = cipb.dirInfo.ioVRefNum;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1902 buf->st_size = cipb.dirInfo.ioDrNmFls;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1903 /* size of dir = number of files and dirs */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1904 buf->st_atime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1905 = buf->st_mtime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1906 = cipb.dirInfo.ioDrMdDat - MAC_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1907 buf->st_ctime = cipb.dirInfo.ioDrCrDat - MAC_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1908 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1909 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1910 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1911 buf->st_mode = S_IFREG | S_IREAD;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1912 if (!(cipb.hFileInfo.ioFlAttrib & 0x1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1913 buf->st_mode |= S_IWRITE; /* bit 1 = 1 for locked files/directories */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1914 if (cipb.hFileInfo.ioFlFndrInfo.fdType == 'APPL')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1915 buf->st_mode |= S_IEXEC;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1916 buf->st_ino = cipb.hFileInfo.ioDirID;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1917 buf->st_dev = cipb.hFileInfo.ioVRefNum;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1918 buf->st_size = cipb.hFileInfo.ioFlLgLen;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1919 buf->st_atime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1920 = buf->st_mtime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1921 = cipb.hFileInfo.ioFlMdDat - MAC_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1922 buf->st_ctime = cipb.hFileInfo.ioFlCrDat - MAC_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1923 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1924
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1925 if (cipb.hFileInfo.ioFlFndrInfo.fdFlags & 0x8000)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1926 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1927 /* identify alias files as symlinks */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1928 buf->st_mode &= ~S_IFREG;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1929 buf->st_mode |= S_IFLNK;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1930 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1931
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1932 buf->st_nlink = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1933 buf->st_uid = getuid ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1934 buf->st_gid = getgid ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1935 buf->st_rdev = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1936
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1937 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1938 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1939
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1940
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1941 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1942 lstat (const char *path, struct stat *buf)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1943 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1944 int result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1945 char true_pathname[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1946
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1947 /* Try looking for the file without resolving aliases first. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1948 if ((result = stat_noalias (path, buf)) >= 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1949 return result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1950
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1951 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1952 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1953
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1954 return stat_noalias (true_pathname, buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1955 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1956
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1957
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1958 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1959 stat (const char *path, struct stat *sb)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1960 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1961 int result;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1962 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1963 int len;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1964
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1965 if ((result = stat_noalias (path, sb)) >= 0 &&
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1966 ! (sb->st_mode & S_IFLNK))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1967 return result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1968
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1969 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1970 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1971
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1972 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1973 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1974 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1975 fully_resolved_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1976 /* in fact our readlink terminates strings */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1977 return lstat (fully_resolved_name, sb);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1978 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1979 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1980 return lstat (true_pathname, sb);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1981 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1982
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1983
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1984 #if __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1985 /* CW defines fstat in stat.mac.c while MPW does not provide this
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1986 function. Without the information of how to get from a file
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1987 descriptor in MPW StdCLib to a Mac OS file spec, it should be hard
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1988 to implement this function. Fortunately, there is only one place
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1989 where this function is called in our configuration: in fileio.c,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1990 where only the st_dev and st_ino fields are used to determine
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1991 whether two fildes point to different i-nodes to prevent copying
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1992 a file onto itself equal. What we have here probably needs
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1993 improvement. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1994
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1995 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1996 fstat (int fildes, struct stat *buf)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1997 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1998 buf->st_dev = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1999 buf->st_ino = fildes;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2000 buf->st_mode = S_IFREG; /* added by T.I. for the copy-file */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2001 return 0; /* success */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2002 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2003 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2004
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2005
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2006 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2007 mkdir (const char *dirname, int mode)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2008 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2009 #pragma unused(mode)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2010
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2011 HFileParam hfpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2012 char true_pathname[MAXPATHLEN+1], mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2013
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2014 if (find_true_pathname (dirname, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2015 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2016
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2017 if (posix_to_mac_pathname (true_pathname, mac_pathname, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2018 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2019
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2020 c2pstr (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2021 hfpb.ioNamePtr = mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2022 hfpb.ioVRefNum = 0; /* ignored unless name is invalid */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2023 hfpb.ioDirID = 0; /* parent is the root */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2024
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2025 errno = PBDirCreate ((HParmBlkPtr) &hfpb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2026 /* just return the Mac OSErr code for now */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2027 return errno == noErr ? 0 : -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2028 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2029
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2030
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2031 #undef rmdir
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2032 sys_rmdir (const char *dirname)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2033 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2034 HFileParam hfpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2035 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2036
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2037 if (posix_to_mac_pathname (dirname, mac_pathname, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2038 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2039
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2040 c2pstr (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2041 hfpb.ioNamePtr = mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2042 hfpb.ioVRefNum = 0; /* ignored unless name is invalid */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2043 hfpb.ioDirID = 0; /* parent is the root */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2044
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2045 errno = PBHDelete ((HParmBlkPtr) &hfpb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2046 return errno == noErr ? 0 : -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2047 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2048
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2049
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2050 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2051 /* No implementation yet. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2052 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2053 execvp (const char *path, ...)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2054 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2055 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2056 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2057 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2058
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2059
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2060 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2061 utime (const char *path, const struct utimbuf *times)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2062 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2063 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2064 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2065 char mac_pathname[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2066 CInfoPBRec cipb;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2067
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2068 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2069 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2070
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2071 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2072 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2073 fully_resolved_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2074 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2075 strcpy (fully_resolved_name, true_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2076
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2077 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2078 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2079
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2080 c2pstr (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2081 cipb.hFileInfo.ioNamePtr = mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2082 cipb.hFileInfo.ioVRefNum = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2083 cipb.hFileInfo.ioDirID = 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2084 cipb.hFileInfo.ioFDirIndex = 0;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2085 /* set to 0 to get information about specific dir or file */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2086
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2087 errno = PBGetCatInfo (&cipb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2088 if (errno != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2089 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2090
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2091 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* bit 4 = 1 for directories */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2092 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2093 if (times)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2094 cipb.dirInfo.ioDrMdDat = times->modtime + MAC_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2095 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2096 GetDateTime (&cipb.dirInfo.ioDrMdDat);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2097 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2098 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2099 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2100 if (times)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2101 cipb.hFileInfo.ioFlMdDat = times->modtime + MAC_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2102 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2103 GetDateTime (&cipb.hFileInfo.ioFlMdDat);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2104 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2105
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2106 errno = PBSetCatInfo (&cipb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2107 return errno == noErr ? 0 : -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2108 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2109
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2110
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2111 #ifndef F_OK
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2112 #define F_OK 0
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2113 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2114 #ifndef X_OK
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2115 #define X_OK 1
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2116 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2117 #ifndef W_OK
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2118 #define W_OK 2
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2119 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2120
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2121 /* Like stat, but test for access mode in hfpb.ioFlAttrib */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2122 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2123 access (const char *path, int mode)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2124 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2125 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2126 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2127 char mac_pathname[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2128 CInfoPBRec cipb;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2129
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2130 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2131 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2132
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2133 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2134 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2135 fully_resolved_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2136 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2137 strcpy (fully_resolved_name, true_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2138
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2139 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2140 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2141
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2142 c2pstr (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2143 cipb.hFileInfo.ioNamePtr = mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2144 cipb.hFileInfo.ioVRefNum = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2145 cipb.hFileInfo.ioDirID = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2146 cipb.hFileInfo.ioFDirIndex = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2147 /* set to 0 to get information about specific dir or file */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2148
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2149 errno = PBGetCatInfo (&cipb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2150 if (errno != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2151 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2152
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2153 if (mode == F_OK) /* got this far, file exists */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2154 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2155
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2156 if (mode & X_OK)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2157 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* path refers to a directory */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2158 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2159 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2160 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2161 if (cipb.hFileInfo.ioFlFndrInfo.fdType == 'APPL')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2162 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2163 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2164 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2165 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2166
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2167 if (mode & W_OK)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2168 return (cipb.hFileInfo.ioFlAttrib & 0x1) ? -1 : 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2169 /* don't allow if lock bit is on */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2170
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2171 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2172 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2173
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2174
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2175 #define DEV_NULL_FD 0x10000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2176
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2177 #undef open
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2178 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2179 sys_open (const char *path, int oflag)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2180 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2181 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2182 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2183 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2184
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2185 if (strcmp (path, "/dev/null") == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2186 return DEV_NULL_FD; /* some bogus fd to be ignored in write */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2187
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2188 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2189 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2190
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2191 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2192 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2193 fully_resolved_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2194 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2195 strcpy (fully_resolved_name, true_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2196
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2197 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2198 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2199 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2200 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2201 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2202 int res = open (mac_pathname, oflag);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2203 /* if (oflag == O_WRONLY || oflag == O_RDWR) */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2204 if (oflag & O_CREAT)
75097
5e8caf6183ec (Fmac_set_file_creator): Use MAC_EMACS_CREATOR_CODE
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 74755
diff changeset
2205 fsetfileinfo (mac_pathname, MAC_EMACS_CREATOR_CODE, 'TEXT');
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2206 return res;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2207 #else /* not __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2208 return open (mac_pathname, oflag);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2209 #endif /* not __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2210 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2211 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2212
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2213
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2214 #undef creat
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2215 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2216 sys_creat (const char *path, mode_t mode)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2217 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2218 char true_pathname[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2219 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2220 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2221
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2222 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2223 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2224
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2225 if (!posix_to_mac_pathname (true_pathname, mac_pathname, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2226 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2227 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2228 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2229 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2230 int result = creat (mac_pathname);
75097
5e8caf6183ec (Fmac_set_file_creator): Use MAC_EMACS_CREATOR_CODE
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 74755
diff changeset
2231 fsetfileinfo (mac_pathname, MAC_EMACS_CREATOR_CODE, 'TEXT');
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2232 return result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2233 #else /* not __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2234 return creat (mac_pathname, mode);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2235 #endif /* not __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2236 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2237 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2238
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2239
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2240 #undef unlink
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2241 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2242 sys_unlink (const char *path)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2243 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2244 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2245 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2246 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2247
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2248 if (find_true_pathname (path, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2249 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2250
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2251 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2252 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2253 fully_resolved_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2254 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2255 strcpy (fully_resolved_name, true_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2256
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2257 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2258 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2259 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2260 return unlink (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2261 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2262
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2263
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2264 #undef read
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2265 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2266 sys_read (int fildes, char *buf, int count)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2267 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2268 if (fildes == 0) /* this should not be used for console input */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2269 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2270 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2271 #if __MSL__ >= 0x6000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2272 return _read (fildes, buf, count);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2273 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2274 return read (fildes, buf, count);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2275 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2276 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2277
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2278
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2279 #undef write
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2280 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2281 sys_write (int fildes, const char *buf, int count)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2282 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2283 if (fildes == DEV_NULL_FD)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2284 return count;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2285 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2286 #if __MSL__ >= 0x6000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2287 return _write (fildes, buf, count);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2288 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2289 return write (fildes, buf, count);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2290 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2291 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2292
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2293
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2294 #undef rename
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2295 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2296 sys_rename (const char * old_name, const char * new_name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2297 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2298 char true_old_pathname[MAXPATHLEN+1], true_new_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2299 char fully_resolved_old_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2300 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2301 char mac_old_name[MAXPATHLEN+1], mac_new_name[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2302
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2303 if (find_true_pathname (old_name, true_old_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2304 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2305
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2306 len = readlink (true_old_pathname, fully_resolved_old_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2307 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2308 fully_resolved_old_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2309 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2310 strcpy (fully_resolved_old_name, true_old_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2311
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2312 if (find_true_pathname (new_name, true_new_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2313 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2314
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2315 if (strcmp (fully_resolved_old_name, true_new_pathname) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2316 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2317
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2318 if (!posix_to_mac_pathname (fully_resolved_old_name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2319 mac_old_name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2320 MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2321 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2322
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2323 if (!posix_to_mac_pathname(true_new_pathname, mac_new_name, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2324 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2325
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2326 /* If a file with new_name already exists, rename deletes the old
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2327 file in Unix. CW version fails in these situation. So we add a
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2328 call to unlink here. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2329 (void) unlink (mac_new_name);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2330
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2331 return rename (mac_old_name, mac_new_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2332 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2333
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2334
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2335 #undef fopen
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2336 extern FILE *fopen (const char *name, const char *mode);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2337 FILE *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2338 sys_fopen (const char *name, const char *mode)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2339 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2340 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2341 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2342 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2343
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2344 if (find_true_pathname (name, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2345 return 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2346
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2347 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2348 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2349 fully_resolved_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2350 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2351 strcpy (fully_resolved_name, true_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2352
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2353 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2354 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2355 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2356 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2357 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2358 if (mode[0] == 'w' || mode[0] == 'a')
75097
5e8caf6183ec (Fmac_set_file_creator): Use MAC_EMACS_CREATOR_CODE
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 74755
diff changeset
2359 fsetfileinfo (mac_pathname, MAC_EMACS_CREATOR_CODE, 'TEXT');
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2360 #endif /* not __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2361 return fopen (mac_pathname, mode);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2362 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2363 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2364
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2365
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2366 extern Boolean mac_wait_next_event P_ ((EventRecord *, UInt32, Boolean));
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
2367
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2368 int
72983
ddc3ec9e715f [!MAC_OSX] (select): Fix argument name.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72953
diff changeset
2369 select (nfds, rfds, wfds, efds, timeout)
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2370 int nfds;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2371 SELECT_TYPE *rfds, *wfds, *efds;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2372 EMACS_TIME *timeout;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2373 {
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2374 OSStatus err = noErr;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2375
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2376 /* Can only handle wait for keyboard input. */
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2377 if (nfds > 1 || wfds || efds)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2378 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2379
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2380 /* Try detect_input_pending before ReceiveNextEvent in the same
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2381 BLOCK_INPUT block, in case that some input has already been read
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2382 asynchronously. */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2383 BLOCK_INPUT;
74626
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
2384 ENABLE_WAKEUP_FROM_RNE;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2385 if (!detect_input_pending ())
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2386 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2387 #if TARGET_API_MAC_CARBON
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2388 EventTimeout timeoutval =
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2389 (timeout
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2390 ? (EMACS_SECS (*timeout) * kEventDurationSecond
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2391 + EMACS_USECS (*timeout) * kEventDurationMicrosecond)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2392 : kEventDurationForever);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2393
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2394 if (timeoutval == 0.0)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2395 err = eventLoopTimedOutErr;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2396 else
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2397 err = ReceiveNextEvent (0, NULL, timeoutval,
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2398 kEventLeaveInQueue, NULL);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2399 #else /* not TARGET_API_MAC_CARBON */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2400 EventRecord e;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2401 UInt32 sleep_time = EMACS_SECS (*timeout) * 60 +
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2402 ((EMACS_USECS (*timeout) * 60) / 1000000);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2403
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2404 if (sleep_time == 0)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2405 err = -9875; /* eventLoopTimedOutErr */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2406 else
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2407 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2408 if (mac_wait_next_event (&e, sleep_time, false))
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2409 err = noErr;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2410 else
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2411 err = -9875; /* eventLoopTimedOutErr */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2412 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2413 #endif /* not TARGET_API_MAC_CARBON */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2414 }
74626
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
2415 DISABLE_WAKEUP_FROM_RNE;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2416 UNBLOCK_INPUT;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2417
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2418 if (err == noErr)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2419 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2420 /* Pretend that `select' is interrupted by a signal. */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2421 detect_input_pending ();
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2422 errno = EINTR;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2423 return -1;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2424 }
62283
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2425 else
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2426 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2427 if (rfds)
62283
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2428 FD_ZERO (rfds);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2429 return 0;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
2430 }
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2431 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2432
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2433
62283
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2434 /* Simulation of SIGALRM. The stub for function signal stores the
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2435 signal handler function in alarm_signal_func if a SIGALRM is
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2436 encountered. */
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2437
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2438 #include <signal.h>
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2439 #include "syssignal.h"
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2440
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2441 static TMTask mac_atimer_task;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2442
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2443 static QElemPtr mac_atimer_qlink = (QElemPtr) &mac_atimer_task;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2444
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2445 static int signal_mask = 0;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2446
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2447 #ifdef __MRC__
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2448 __sigfun alarm_signal_func = (__sigfun) 0;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2449 #elif __MWERKS__
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2450 __signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2451 #else /* not __MRC__ and not __MWERKS__ */
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2452 You lose!!!
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2453 #endif /* not __MRC__ and not __MWERKS__ */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2454
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2455 #undef signal
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2456 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2457 extern __sigfun signal (int signal, __sigfun signal_func);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2458 __sigfun
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2459 sys_signal (int signal_num, __sigfun signal_func)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2460 #elif __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2461 extern __signal_func_ptr signal (int signal, __signal_func_ptr signal_func);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2462 __signal_func_ptr
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2463 sys_signal (int signal_num, __signal_func_ptr signal_func)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2464 #else /* not __MRC__ and not __MWERKS__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2465 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2466 #endif /* not __MRC__ and not __MWERKS__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2467 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2468 if (signal_num != SIGALRM)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2469 return signal (signal_num, signal_func);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2470 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2471 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2472 #ifdef __MRC__
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2473 __sigfun old_signal_func;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2474 #elif __MWERKS__
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2475 __signal_func_ptr old_signal_func;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2476 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2477 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2478 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2479 old_signal_func = alarm_signal_func;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2480 alarm_signal_func = signal_func;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2481 return old_signal_func;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2482 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2483 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2484
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2485
62283
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2486 static pascal void
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2487 mac_atimer_handler (qlink)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2488 TMTaskPtr qlink;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2489 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2490 if (alarm_signal_func)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2491 (alarm_signal_func) (SIGALRM);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2492 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2493
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2494
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2495 static void
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2496 set_mac_atimer (count)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2497 long count;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2498 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2499 static TimerUPP mac_atimer_handlerUPP = NULL;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2500
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2501 if (mac_atimer_handlerUPP == NULL)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2502 mac_atimer_handlerUPP = NewTimerUPP (mac_atimer_handler);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2503 mac_atimer_task.tmCount = 0;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2504 mac_atimer_task.tmAddr = mac_atimer_handlerUPP;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2505 mac_atimer_qlink = (QElemPtr) &mac_atimer_task;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2506 InsTime (mac_atimer_qlink);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2507 if (count)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2508 PrimeTime (mac_atimer_qlink, count);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2509 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2510
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2511
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2512 int
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2513 remove_mac_atimer (remaining_count)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2514 long *remaining_count;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2515 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2516 if (mac_atimer_qlink)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2517 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2518 RmvTime (mac_atimer_qlink);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2519 if (remaining_count)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2520 *remaining_count = mac_atimer_task.tmCount;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2521 mac_atimer_qlink = NULL;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2522
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2523 return 0;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2524 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2525 else
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2526 return -1;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2527 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2528
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2529
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2530 int
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2531 sigblock (int mask)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2532 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2533 int old_mask = signal_mask;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2534
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2535 signal_mask |= mask;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2536
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2537 if ((old_mask ^ signal_mask) & sigmask (SIGALRM))
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2538 remove_mac_atimer (NULL);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2539
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2540 return old_mask;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2541 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2542
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2543
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2544 int
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2545 sigsetmask (int mask)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2546 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2547 int old_mask = signal_mask;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2548
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2549 signal_mask = mask;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2550
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2551 if ((old_mask ^ signal_mask) & sigmask (SIGALRM))
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2552 if (signal_mask & sigmask (SIGALRM))
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2553 remove_mac_atimer (NULL);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2554 else
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2555 set_mac_atimer (mac_atimer_task.tmCount);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2556
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2557 return old_mask;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2558 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2559
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2560
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2561 int
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2562 alarm (int seconds)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2563 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2564 long remaining_count;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2565
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2566 if (remove_mac_atimer (&remaining_count) == 0)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2567 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2568 set_mac_atimer (seconds * 1000);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2569
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2570 return remaining_count / 1000;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2571 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2572 else
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2573 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2574 mac_atimer_task.tmCount = seconds * 1000;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2575
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2576 return 0;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2577 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2578 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2579
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2580
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2581 int
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2582 setitimer (which, value, ovalue)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2583 int which;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2584 const struct itimerval *value;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2585 struct itimerval *ovalue;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2586 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2587 long remaining_count;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2588 long count = (EMACS_SECS (value->it_value) * 1000
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2589 + (EMACS_USECS (value->it_value) + 999) / 1000);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2590
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2591 if (remove_mac_atimer (&remaining_count) == 0)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2592 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2593 if (ovalue)
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2594 {
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2595 bzero (ovalue, sizeof (*ovalue));
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2596 EMACS_SET_SECS_USECS (ovalue->it_value, remaining_count / 1000,
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2597 (remaining_count % 1000) * 1000);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2598 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2599 set_mac_atimer (count);
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2600 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2601 else
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2602 mac_atimer_task.tmCount = count;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2603
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2604 return 0;
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2605 }
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2606
988827be383c [!MAC_OSX] Include keyboard.h and syssignal.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62054
diff changeset
2607
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2608 /* gettimeofday should return the amount of time (in a timeval
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2609 structure) since midnight today. The toolbox function Microseconds
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2610 returns the number of microseconds (in a UnsignedWide value) since
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2611 the machine was booted. Also making this complicated is WideAdd,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2612 WideSubtract, etc. take wide values. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2613
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2614 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2615 gettimeofday (tp)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2616 struct timeval *tp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2617 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2618 static inited = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2619 static wide wall_clock_at_epoch, clicks_at_epoch;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2620 UnsignedWide uw_microseconds;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2621 wide w_microseconds;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2622 time_t sys_time (time_t *);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2623
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2624 /* If this function is called for the first time, record the number
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2625 of seconds since midnight and the number of microseconds since
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2626 boot at the time of this first call. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2627 if (!inited)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2628 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2629 time_t systime;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2630 inited = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2631 systime = sys_time (NULL);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2632 /* Store microseconds since midnight in wall_clock_at_epoch. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2633 WideMultiply (systime, 1000000L, &wall_clock_at_epoch);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2634 Microseconds (&uw_microseconds);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2635 /* Store microseconds since boot in clicks_at_epoch. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2636 clicks_at_epoch.hi = uw_microseconds.hi;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2637 clicks_at_epoch.lo = uw_microseconds.lo;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2638 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2639
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2640 /* Get time since boot */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2641 Microseconds (&uw_microseconds);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2642
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2643 /* Convert to time since midnight*/
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2644 w_microseconds.hi = uw_microseconds.hi;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2645 w_microseconds.lo = uw_microseconds.lo;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2646 WideSubtract (&w_microseconds, &clicks_at_epoch);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2647 WideAdd (&w_microseconds, &wall_clock_at_epoch);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2648 tp->tv_sec = WideDivide (&w_microseconds, 1000000L, &tp->tv_usec);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2649
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2650 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2651 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2652
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2653
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2654 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2655 unsigned int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2656 sleep (unsigned int seconds)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2657 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2658 unsigned long time_up;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2659 EventRecord e;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2660
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2661 time_up = TickCount () + seconds * 60;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2662 while (TickCount () < time_up)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2663 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2664 /* Accept no event; just wait. by T.I. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2665 WaitNextEvent (0, &e, 30, NULL);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2666 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2667
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2668 return (0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2669 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2670 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2671
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2672
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2673 /* The time functions adjust time values according to the difference
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2674 between the Unix and CW epoches. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2675
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2676 #undef gmtime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2677 extern struct tm *gmtime (const time_t *);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2678 struct tm *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2679 sys_gmtime (const time_t *timer)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2680 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2681 time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2682
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2683 return gmtime (&unix_time);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2684 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2685
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2686
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2687 #undef localtime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2688 extern struct tm *localtime (const time_t *);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2689 struct tm *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2690 sys_localtime (const time_t *timer)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2691 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2692 #if __MSL__ >= 0x6000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2693 time_t unix_time = *timer;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2694 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2695 time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2696 #endif
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2697
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2698 return localtime (&unix_time);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2699 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2700
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2701
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2702 #undef ctime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2703 extern char *ctime (const time_t *);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2704 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2705 sys_ctime (const time_t *timer)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2706 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2707 #if __MSL__ >= 0x6000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2708 time_t unix_time = *timer;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2709 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2710 time_t unix_time = *timer + CW_OR_MPW_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2711 #endif
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2712
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2713 return ctime (&unix_time);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2714 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2715
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2716
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2717 #undef time
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2718 extern time_t time (time_t *);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2719 time_t
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2720 sys_time (time_t *timer)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2721 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2722 #if __MSL__ >= 0x6000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2723 time_t mac_time = time (NULL);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2724 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2725 time_t mac_time = time (NULL) - CW_OR_MPW_UNIX_EPOCH_DIFF;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2726 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2727
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2728 if (timer)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2729 *timer = mac_time;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2730
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2731 return mac_time;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2732 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2733
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2734
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2735 /* no subprocesses, empty wait */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2736
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2737 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2738 wait (int pid)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2739 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2740 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2741 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2742
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2743
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2744 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2745 croak (char *badfunc)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2746 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2747 printf ("%s not yet implemented\r\n", badfunc);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2748 exit (1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2749 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2750
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2751
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2752 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2753 mktemp (char *template)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2754 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2755 int len, k;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2756 static seqnum = 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2757
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2758 len = strlen (template);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2759 k = len - 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2760 while (k >= 0 && template[k] == 'X')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2761 k--;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2762
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2763 k++; /* make k index of first 'X' */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2764
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2765 if (k < len)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2766 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2767 /* Zero filled, number of digits equal to the number of X's. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2768 sprintf (&template[k], "%0*d", len-k, seqnum++);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2769
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2770 return template;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2771 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2772 else
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2773 return 0;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2774 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2775
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2776
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2777 /* Emulate getpwuid, getpwnam and others. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2778
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2779 #define PASSWD_FIELD_SIZE 256
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2780
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2781 static char my_passwd_name[PASSWD_FIELD_SIZE];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2782 static char my_passwd_dir[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2783
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2784 static struct passwd my_passwd =
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2785 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2786 my_passwd_name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2787 my_passwd_dir,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2788 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2789
53122
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2790 static struct group my_group =
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2791 {
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2792 /* There are no groups on the mac, so we just return "root" as the
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2793 group name. */
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2794 "root",
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2795 };
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2796
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2797
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2798 /* Initialized by main () in macterm.c to pathname of emacs directory. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2799
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2800 char emacs_passwd_dir[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2801
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2802 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2803 getwd (char *);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2804
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2805 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2806 init_emacs_passwd_dir ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2807 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2808 int found = false;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2809
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2810 if (getwd (emacs_passwd_dir) && getwd (my_passwd_dir))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2811 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2812 /* Need pathname of first ancestor that begins with "emacs"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2813 since Mac emacs application is somewhere in the emacs-*
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2814 tree. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2815 int len = strlen (emacs_passwd_dir);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2816 int j = len - 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2817 /* j points to the "/" following the directory name being
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2818 compared. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2819 int i = j - 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2820 while (i >= 0 && !found)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2821 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2822 while (i >= 0 && emacs_passwd_dir[i] != '/')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2823 i--;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2824 if (emacs_passwd_dir[i] == '/' && i+5 < len)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2825 found = (strncmp (&(emacs_passwd_dir[i+1]), "emacs", 5) == 0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2826 if (found)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2827 emacs_passwd_dir[j+1] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2828 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2829 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2830 j = i;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2831 i = j - 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2832 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2833 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2834 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2835
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2836 if (!found)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2837 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2838 /* Setting to "/" probably won't work but set it to something
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2839 anyway. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2840 strcpy (emacs_passwd_dir, "/");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2841 strcpy (my_passwd_dir, "/");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2842 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2843 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2844
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2845
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2846 static struct passwd emacs_passwd =
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2847 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2848 "emacs",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2849 emacs_passwd_dir,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2850 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2851
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2852 static int my_passwd_inited = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2853
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2854
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2855 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2856 init_my_passwd ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2857 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2858 char **owner_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2859
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2860 /* Note: my_passwd_dir initialized in int_emacs_passwd_dir to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2861 directory where Emacs was started. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2862
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2863 owner_name = (char **) GetResource ('STR ',-16096);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2864 if (owner_name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2865 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2866 HLock (owner_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2867 BlockMove ((unsigned char *) *owner_name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2868 (unsigned char *) my_passwd_name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2869 *owner_name[0]+1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2870 HUnlock (owner_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2871 p2cstr ((unsigned char *) my_passwd_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2872 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2873 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2874 my_passwd_name[0] = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2875 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2876
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2877
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2878 struct passwd *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2879 getpwuid (uid_t uid)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2880 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2881 if (!my_passwd_inited)
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2882 {
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2883 init_my_passwd ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2884 my_passwd_inited = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2885 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2886
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2887 return &my_passwd;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2888 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2889
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2890
53122
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2891 struct group *
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2892 getgrgid (gid_t gid)
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2893 {
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2894 return &my_group;
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2895 }
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2896
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
2897
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2898 struct passwd *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2899 getpwnam (const char *name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2900 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2901 if (strcmp (name, "emacs") == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2902 return &emacs_passwd;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2903
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2904 if (!my_passwd_inited)
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2905 {
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2906 init_my_passwd ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2907 my_passwd_inited = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2908 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2909
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2910 return &my_passwd;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2911 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2912
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2913
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2914 /* The functions fork, kill, sigsetmask, sigblock, request_sigio,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2915 setpgrp, setpriority, and unrequest_sigio are defined to be empty
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2916 as in msdos.c. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2917
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2918
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2919 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2920 fork ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2921 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2922 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2923 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2924
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2925
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2926 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2927 kill (int x, int y)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2928 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2929 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2930 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2931
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2932
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2933 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2934 sys_subshell ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2935 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2936 error ("Can't spawn subshell");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2937 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2938
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2939
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2940 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2941 request_sigio (void)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2942 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2943 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2944
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2945
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2946 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2947 unrequest_sigio (void)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2948 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2949 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2950
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2951
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2952 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2953 setpgrp ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2954 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2955 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2956 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2957
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2958
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2959 /* No pipes yet. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2960
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2961 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2962 pipe (int _fildes[2])
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2963 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2964 errno = EACCES;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2965 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2966 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2967
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2968
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2969 /* Hard and symbolic links. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2970
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2971 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2972 symlink (const char *name1, const char *name2)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2973 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2974 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2975 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2976 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2977
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2978
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2979 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2980 link (const char *name1, const char *name2)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2981 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2982 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2983 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2984 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2985
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2986 #endif /* ! MAC_OSX */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2987
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2988 /* Determine the path name of the file specified by VREFNUM, DIRID,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2989 and NAME and place that in the buffer PATH of length
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2990 MAXPATHLEN. */
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
2991 static int
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2992 path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2993 long dir_id, ConstStr255Param name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2994 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2995 Str255 dir_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2996 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2997 OSErr err;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2998
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2999 if (strlen (name) > man_path_len)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3000 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3001
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3002 memcpy (dir_name, name, name[0]+1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3003 memcpy (path, name, name[0]+1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3004 p2cstr (path);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3005
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3006 cipb.dirInfo.ioDrParID = dir_id;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3007 cipb.dirInfo.ioNamePtr = dir_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3008
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3009 do
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3010 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3011 cipb.dirInfo.ioVRefNum = vol_ref_num;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3012 cipb.dirInfo.ioFDirIndex = -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3013 cipb.dirInfo.ioDrDirID = cipb.dirInfo.ioDrParID;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3014 /* go up to parent each time */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3015
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3016 err = PBGetCatInfo (&cipb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3017 if (err != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3018 return 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3019
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3020 p2cstr (dir_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3021 if (strlen (dir_name) + strlen (path) + 1 >= man_path_len)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3022 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3023
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3024 strcat (dir_name, ":");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3025 strcat (dir_name, path);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3026 /* attach to front since we're going up directory tree */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3027 strcpy (path, dir_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3028 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3029 while (cipb.dirInfo.ioDrDirID != fsRtDirID);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3030 /* stop when we see the volume's root directory */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3031
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3032 return 1; /* success */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3033 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3034
60360
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3035
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
3036 #ifndef MAC_OSX
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
3037
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
3038 static OSErr
60360
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3039 posix_pathname_to_fsspec (ufn, fs)
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3040 const char *ufn;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3041 FSSpec *fs;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3042 {
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3043 Str255 mac_pathname;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3044
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3045 if (posix_to_mac_pathname (ufn, mac_pathname, sizeof (mac_pathname)) == 0)
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3046 return fnfErr;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3047 else
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3048 {
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3049 c2pstr (mac_pathname);
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3050 return FSMakeFSSpec (0, 0, mac_pathname, fs);
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3051 }
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3052 }
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3053
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
3054 static OSErr
60360
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3055 fsspec_to_posix_pathname (fs, ufn, ufnbuflen)
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3056 const FSSpec *fs;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3057 char *ufn;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3058 int ufnbuflen;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3059 {
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3060 char mac_pathname[MAXPATHLEN];
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3061
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3062 if (path_from_vol_dir_name (mac_pathname, sizeof (mac_pathname) - 1,
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3063 fs->vRefNum, fs->parID, fs->name)
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3064 && mac_to_posix_pathname (mac_pathname, ufn, ufnbuflen))
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3065 return noErr;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3066 else
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3067 return fnfErr;
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3068 }
86edfe26d552 [!MAC_OSX && HAVE_CARBON]: Include Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 59897
diff changeset
3069
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3070 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3071 readlink (const char *path, char *buf, int bufsiz)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3072 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3073 char mac_sym_link_name[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3074 OSErr err;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3075 FSSpec fsspec;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3076 Boolean target_is_folder, was_aliased;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3077 Str255 directory_name, mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3078 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3079
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3080 if (posix_to_mac_pathname (path, mac_sym_link_name, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3081 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3082
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3083 c2pstr (mac_sym_link_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3084 err = FSMakeFSSpec (0, 0, mac_sym_link_name, &fsspec);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3085 if (err != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3086 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3087 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3088 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3089 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3090
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3091 err = ResolveAliasFile (&fsspec, true, &target_is_folder, &was_aliased);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3092 if (err != noErr || !was_aliased)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3093 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3094 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3095 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3096 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3097
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3098 if (path_from_vol_dir_name (mac_pathname, 255, fsspec.vRefNum, fsspec.parID,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3099 fsspec.name) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3100 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3101 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3102 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3103 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3104
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3105 if (mac_to_posix_pathname (mac_pathname, buf, bufsiz) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3106 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3107 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3108 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3109 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3110
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3111 return strlen (buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3112 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3113
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3114
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3115 /* Convert a path to one with aliases fully expanded. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3116
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3117 static int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3118 find_true_pathname (const char *path, char *buf, int bufsiz)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3119 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3120 char *q, temp[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3121 const char *p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3122 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3123
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3124 if (bufsiz <= 0 || path == 0 || path[0] == '\0')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3125 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3126
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3127 buf[0] = '\0';
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3128
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3129 p = path;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3130 if (*p == '/')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3131 q = strchr (p + 1, '/');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3132 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3133 q = strchr (p, '/');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3134 len = 0; /* loop may not be entered, e.g., for "/" */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3135
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3136 while (q)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3137 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3138 strcpy (temp, buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3139 strncat (temp, p, q - p);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3140 len = readlink (temp, buf, bufsiz);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3141 if (len <= -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3142 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3143 if (strlen (temp) + 1 > bufsiz)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3144 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3145 strcpy (buf, temp);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3146 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3147 strcat (buf, "/");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3148 len++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3149 p = q + 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3150 q = strchr(p, '/');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3151 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3152
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3153 if (len + strlen (p) + 1 >= bufsiz)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3154 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3155
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3156 strcat (buf, p);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3157 return len + strlen (p);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3158 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3159
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3160
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3161 mode_t
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3162 umask (mode_t numask)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3163 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3164 static mode_t mask = 022;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3165 mode_t oldmask = mask;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3166 mask = numask;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3167 return oldmask;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3168 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3169
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3170
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3171 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3172 chmod (const char *path, mode_t mode)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3173 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3174 /* say it always succeed for now */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3175 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3176 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3177
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3178
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3179 int
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3180 fchmod (int fd, mode_t mode)
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3181 {
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3182 /* say it always succeed for now */
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3183 return 0;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3184 }
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3185
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3186
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3187 int
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3188 fchown (int fd, uid_t owner, gid_t group)
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3189 {
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3190 /* say it always succeed for now */
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3191 return 0;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3192 }
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3193
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3194
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
3195 int
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3196 dup (int oldd)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3197 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3198 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3199 return fcntl (oldd, F_DUPFD, 0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3200 #elif __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3201 /* current implementation of fcntl in fcntl.mac.c simply returns old
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3202 descriptor */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3203 return fcntl (oldd, F_DUPFD);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3204 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3205 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3206 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3207 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3208
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3209
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3210 /* This is from the original sysdep.c. Emulate BSD dup2. First close
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3211 newd if it already exists. Then, attempt to dup oldd. If not
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3212 successful, call dup2 recursively until we are, then close the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3213 unsuccessful ones. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3214
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3215 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3216 dup2 (int oldd, int newd)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3217 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3218 int fd, ret;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3219
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3220 close (newd);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3221
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3222 fd = dup (oldd);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3223 if (fd == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3224 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3225 if (fd == newd)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3226 return newd;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3227 ret = dup2 (oldd, newd);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3228 close (fd);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3229 return ret;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3230 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3231
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3232
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3233 /* let it fail for now */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3234
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3235 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3236 sbrk (int incr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3237 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3238 return (char *) -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3239 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3240
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3241
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3242 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3243 fsync (int fd)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3244 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3245 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3246 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3247
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3248
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3249 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3250 ioctl (int d, int request, void *argp)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3251 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3252 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3253 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3254
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3255
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3256 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3257 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3258 isatty (int fildes)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3259 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3260 if (fildes >=0 && fildes <= 2)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3261 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3262 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3263 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3264 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3265
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3266
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3267 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3268 getgid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3269 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3270 return 100;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3271 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3272
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3273
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3274 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3275 getegid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3276 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3277 return 100;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3278 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3279
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3280
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3281 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3282 getuid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3283 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3284 return 200;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3285 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3286
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3287
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3288 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3289 geteuid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3290 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3291 return 200;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3292 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3293 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3294
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3295
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3296 #ifdef __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3297 #if __MSL__ < 0x6000
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3298 #undef getpid
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3299 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3300 getpid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3301 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3302 return 9999;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3303 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3304 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3305 #endif /* __MWERKS__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3306
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3307 #endif /* ! MAC_OSX */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3308
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3309
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3310 /* Return the path to the directory in which Emacs can create
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3311 temporary files. The MacOS "temporary items" directory cannot be
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3312 used because it removes the file written by a process when it
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3313 exits. In that sense it's more like "/dev/null" than "/tmp" (but
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3314 again not exactly). And of course Emacs needs to read back the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3315 files written by its subprocesses. So here we write the files to a
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3316 directory "Emacs" in the Preferences Folder. This directory is
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3317 created if it does not exist. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3318
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3319 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3320 get_temp_dir_name ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3321 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3322 static char *temp_dir_name = NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3323 short vol_ref_num;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3324 long dir_id;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3325 OSErr err;
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
3326 Str255 full_path;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3327 char unix_dir_name[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3328 DIR *dir;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3329
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3330 /* Cache directory name with pointer temp_dir_name.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3331 Look for it only the first time. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3332 if (!temp_dir_name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3333 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3334 err = FindFolder (kOnSystemDisk, kPreferencesFolderType, kCreateFolder,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3335 &vol_ref_num, &dir_id);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3336 if (err != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3337 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3338
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3339 if (!path_from_vol_dir_name (full_path, 255, vol_ref_num, dir_id, "\p"))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3340 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3341
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3342 if (strlen (full_path) + 6 <= MAXPATHLEN)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3343 strcat (full_path, "Emacs:");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3344 else
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3345 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3346
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3347 if (!mac_to_posix_pathname (full_path, unix_dir_name, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3348 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3349
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3350 dir = opendir (unix_dir_name); /* check whether temp directory exists */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3351 if (dir)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3352 closedir (dir);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3353 else if (mkdir (unix_dir_name, 0700) != 0) /* create it if not */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3354 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3355
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3356 temp_dir_name = (char *) malloc (strlen (unix_dir_name) + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3357 strcpy (temp_dir_name, unix_dir_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3358 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3359
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3360 return temp_dir_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3361 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3362
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3363 #ifndef MAC_OSX
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3364
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3365 /* Allocate and construct an array of pointers to strings from a list
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3366 of strings stored in a 'STR#' resource. The returned pointer array
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3367 is stored in the style of argv and environ: if the 'STR#' resource
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3368 contains numString strings, a pointer array with numString+1
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3369 elements is returned in which the last entry contains a null
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3370 pointer. The pointer to the pointer array is passed by pointer in
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3371 parameter t. The resource ID of the 'STR#' resource is passed in
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3372 parameter StringListID.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3373 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3374
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3375 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3376 get_string_list (char ***t, short string_list_id)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3377 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3378 Handle h;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3379 Ptr p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3380 int i, num_strings;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3381
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3382 h = GetResource ('STR#', string_list_id);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3383 if (h)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3384 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3385 HLock (h);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3386 p = *h;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3387 num_strings = * (short *) p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3388 p += sizeof(short);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3389 *t = (char **) malloc (sizeof (char *) * (num_strings + 1));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3390 for (i = 0; i < num_strings; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3391 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3392 short length = *p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3393 (*t)[i] = (char *) malloc (length + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3394 strncpy ((*t)[i], p, length);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3395 (*t)[i][length] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3396 p += length;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3397 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3398 (*t)[num_strings] = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3399 HUnlock (h);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3400 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3401 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3402 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3403 /* Return no string in case GetResource fails. Bug fixed by
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3404 Ikegami Tsutomu. Caused MPW build to crash without sym -on
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3405 option (no sym -on implies -opt local). */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3406 *t = (char **) malloc (sizeof (char *));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3407 (*t)[0] = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3408 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3409 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3410
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3411
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3412 static char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3413 get_path_to_system_folder ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3414 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3415 short vol_ref_num;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3416 long dir_id;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3417 OSErr err;
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
3418 Str255 full_path;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3419 static char system_folder_unix_name[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3420 DIR *dir;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3421
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3422 err = FindFolder (kOnSystemDisk, kSystemFolderType, kDontCreateFolder,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3423 &vol_ref_num, &dir_id);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3424 if (err != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3425 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3426
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3427 if (!path_from_vol_dir_name (full_path, 255, vol_ref_num, dir_id, "\p"))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3428 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3429
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3430 if (!mac_to_posix_pathname (full_path, system_folder_unix_name,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3431 MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3432 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3433
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3434 return system_folder_unix_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3435 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3436
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3437
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3438 char **environ;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3439
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3440 #define ENVIRON_STRING_LIST_ID 128
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3441
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3442 /* Get environment variable definitions from STR# resource. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3443
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3444 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3445 init_environ ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3446 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3447 int i;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3448
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3449 get_string_list (&environ, ENVIRON_STRING_LIST_ID);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3450
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3451 i = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3452 while (environ[i])
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3453 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3454
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3455 /* Make HOME directory the one Emacs starts up in if not specified
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3456 by resource. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3457 if (getenv ("HOME") == NULL)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3458 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3459 environ = (char **) realloc (environ, sizeof (char *) * (i + 2));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3460 if (environ)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3461 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3462 environ[i] = (char *) malloc (strlen (my_passwd_dir) + 6);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3463 if (environ[i])
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3464 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3465 strcpy (environ[i], "HOME=");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3466 strcat (environ[i], my_passwd_dir);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3467 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3468 environ[i+1] = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3469 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3470 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3471 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3472
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3473 /* Make HOME directory the one Emacs starts up in if not specified
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3474 by resource. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3475 if (getenv ("MAIL") == NULL)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3476 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3477 environ = (char **) realloc (environ, sizeof (char *) * (i + 2));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3478 if (environ)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3479 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3480 char * path_to_system_folder = get_path_to_system_folder ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3481 environ[i] = (char *) malloc (strlen (path_to_system_folder) + 22);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3482 if (environ[i])
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3483 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3484 strcpy (environ[i], "MAIL=");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3485 strcat (environ[i], path_to_system_folder);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3486 strcat (environ[i], "Eudora Folder/In");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3487 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3488 environ[i+1] = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3489 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3490 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3491 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3492
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3493
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3494 /* Return the value of the environment variable NAME. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3495
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3496 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3497 getenv (const char *name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3498 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3499 int length = strlen(name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3500 char **e;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3501
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3502 for (e = environ; *e != 0; e++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3503 if (strncmp(*e, name, length) == 0 && (*e)[length] == '=')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3504 return &(*e)[length + 1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3505
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3506 if (strcmp (name, "TMPDIR") == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3507 return get_temp_dir_name ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3508
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3509 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3510 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3511
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3512
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3513 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3514 /* see Interfaces&Libraries:Interfaces:CIncludes:signal.h */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3515 char *sys_siglist[] =
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3516 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3517 "Zero is not a signal!!!",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3518 "Abort", /* 1 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3519 "Interactive user interrupt", /* 2 */ "?",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3520 "Floating point exception", /* 4 */ "?", "?", "?",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3521 "Illegal instruction", /* 8 */ "?", "?", "?", "?", "?", "?", "?",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3522 "Segment violation", /* 16 */ "?", "?", "?", "?", "?", "?", "?",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3523 "?", "?", "?", "?", "?", "?", "?", "?",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3524 "Terminal" /* 32 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3525 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3526 #elif __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3527 char *sys_siglist[] =
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3528 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3529 "Zero is not a signal!!!",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3530 "Abort",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3531 "Floating point exception",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3532 "Illegal instruction",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3533 "Interactive user interrupt",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3534 "Segment violation",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3535 "Terminal"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3536 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3537 #else /* not __MRC__ and not __MWERKS__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3538 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3539 #endif /* not __MRC__ and not __MWERKS__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3540
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3541
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3542 #include <utsname.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3543
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3544 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3545 uname (struct utsname *name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3546 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3547 char **system_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3548 system_name = GetString (-16413); /* IM - Resource Manager Reference */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3549 if (system_name)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3550 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3551 BlockMove (*system_name, name->nodename, (*system_name)[0]+1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3552 p2cstr (name->nodename);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3553 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3554 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3555 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3556 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3557 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3558
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3559
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3560 /* Event class of HLE sent to subprocess. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3561 const OSType kEmacsSubprocessSend = 'ESND';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3562
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3563 /* Event class of HLE sent back from subprocess. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3564 const OSType kEmacsSubprocessReply = 'ERPY';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3565
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3566
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3567 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3568 mystrchr (char *s, char c)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3569 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3570 while (*s && *s != c)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3571 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3572 if (*s == '\\')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3573 s++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3574 s++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3575 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3576
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3577 if (*s)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3578 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3579 *s = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3580 return s;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3581 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3582 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3583 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3584 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3585
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3586
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3587 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3588 mystrtok (char *s)
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3589 {
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3590 while (*s)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3591 s++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3592
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3593 return s + 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3594 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3595
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3596
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3597 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3598 mystrcpy (char *to, char *from)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3599 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3600 while (*from)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3601 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3602 if (*from == '\\')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3603 from++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3604 *to++ = *from++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3605 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3606 *to = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3607 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3608
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3609
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3610 /* Start a Mac subprocess. Arguments for it is passed in argv (null
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3611 terminated). The process should run with the default directory
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3612 "workdir", read input from "infn", and write output and error to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3613 "outfn" and "errfn", resp. The Process Manager call
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3614 LaunchApplication is used to start the subprocess. We use high
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3615 level events as the mechanism to pass arguments to the subprocess
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3616 and to make Emacs wait for the subprocess to terminate and pass
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3617 back a result code. The bulk of the code here packs the arguments
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3618 into one message to be passed together with the high level event.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3619 Emacs also sometimes starts a subprocess using a shell to perform
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3620 wildcard filename expansion. Since we don't really have a shell on
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3621 the Mac, this case is detected and the starting of the shell is
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3622 by-passed. We really need to add code here to do filename
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
3623 expansion to support such functionality.
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
3624
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
3625 We can't use this strategy in Carbon because the High Level Event
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
3626 APIs are not available. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3627
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3628 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3629 run_mac_command (argv, workdir, infn, outfn, errfn)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3630 unsigned char **argv;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3631 const char *workdir;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3632 const char *infn, *outfn, *errfn;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3633 {
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
3634 #if TARGET_API_MAC_CARBON
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3635 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3636 #else /* not TARGET_API_MAC_CARBON */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3637 char macappname[MAXPATHLEN+1], macworkdir[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3638 char macinfn[MAXPATHLEN+1], macoutfn[MAXPATHLEN+1], macerrfn[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3639 int paramlen, argc, newargc, j, retries;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3640 char **newargv, *param, *p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3641 OSErr iErr;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3642 FSSpec spec;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3643 LaunchParamBlockRec lpbr;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3644 EventRecord send_event, reply_event;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3645 RgnHandle cursor_region_handle;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3646 TargetID targ;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3647 unsigned long ref_con, len;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3648
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3649 if (posix_to_mac_pathname (workdir, macworkdir, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3650 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3651 if (posix_to_mac_pathname (infn, macinfn, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3652 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3653 if (posix_to_mac_pathname (outfn, macoutfn, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3654 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3655 if (posix_to_mac_pathname (errfn, macerrfn, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3656 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3657
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3658 paramlen = strlen (macworkdir) + strlen (macinfn) + strlen (macoutfn)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3659 + strlen (macerrfn) + 4; /* count nulls at end of strings */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3660
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3661 argc = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3662 while (argv[argc])
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3663 argc++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3664
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3665 if (argc == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3666 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3667
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3668 /* If a subprocess is invoked with a shell, we receive 3 arguments
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3669 of the form: "<path to emacs bins>/sh" "-c" "<path to emacs
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3670 bins>/<command> <command args>" */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3671 j = strlen (argv[0]);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3672 if (j >= 3 && strcmp (argv[0]+j-3, "/sh") == 0
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3673 && argc == 3 && strcmp (argv[1], "-c") == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3674 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3675 char *command, *t, tempmacpathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3676
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3677 /* The arguments for the command in argv[2] are separated by
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3678 spaces. Count them and put the count in newargc. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3679 command = (char *) alloca (strlen (argv[2])+2);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3680 strcpy (command, argv[2]);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3681 if (command[strlen (command) - 1] != ' ')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3682 strcat (command, " ");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3683
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3684 t = command;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3685 newargc = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3686 t = mystrchr (t, ' ');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3687 while (t)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3688 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3689 newargc++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3690 t = mystrchr (t+1, ' ');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3691 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3692
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3693 newargv = (char **) alloca (sizeof (char *) * newargc);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3694
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3695 t = command;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3696 for (j = 0; j < newargc; j++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3697 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3698 newargv[j] = (char *) alloca (strlen (t) + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3699 mystrcpy (newargv[j], t);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3700
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3701 t = mystrtok (t);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3702 paramlen += strlen (newargv[j]) + 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3703 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3704
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3705 if (strncmp (newargv[0], "~emacs/", 7) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3706 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3707 if (posix_to_mac_pathname (newargv[0], tempmacpathname, MAXPATHLEN+1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3708 == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3709 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3710 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3711 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3712 { /* sometimes Emacs call "sh" without a path for the command */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3713 #if 0
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3714 char *t = (char *) alloca (strlen (newargv[0]) + 7 + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3715 strcpy (t, "~emacs/");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3716 strcat (t, newargv[0]);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3717 #endif /* 0 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3718 Lisp_Object path;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
3719 openp (Vexec_path, build_string (newargv[0]), Vexec_suffixes, &path,
45004
303384b6edc4 (run_mac_command): Update call to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44890
diff changeset
3720 make_number (X_OK));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3721
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3722 if (NILP (path))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3723 return -1;
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45851
diff changeset
3724 if (posix_to_mac_pathname (SDATA (path), tempmacpathname,
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3725 MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3726 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3727 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3728 strcpy (macappname, tempmacpathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3729 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3730 else
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3731 {
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3732 if (posix_to_mac_pathname (argv[0], macappname, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3733 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3734
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3735 newargv = (char **) alloca (sizeof (char *) * argc);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3736 newargc = argc;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3737 for (j = 1; j < argc; j++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3738 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3739 if (strncmp (argv[j], "~emacs/", 7) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3740 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3741 char *t = strchr (argv[j], ' ');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3742 if (t)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3743 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3744 char tempcmdname[MAXPATHLEN+1], tempmaccmdname[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3745 strncpy (tempcmdname, argv[j], t-argv[j]);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3746 tempcmdname[t-argv[j]] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3747 if (posix_to_mac_pathname (tempcmdname, tempmaccmdname,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3748 MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3749 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3750 newargv[j] = (char *) alloca (strlen (tempmaccmdname)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3751 + strlen (t) + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3752 strcpy (newargv[j], tempmaccmdname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3753 strcat (newargv[j], t);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3754 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3755 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3756 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3757 char tempmaccmdname[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3758 if (posix_to_mac_pathname (argv[j], tempmaccmdname,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3759 MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3760 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3761 newargv[j] = (char *) alloca (strlen (tempmaccmdname)+1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3762 strcpy (newargv[j], tempmaccmdname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3763 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3764 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3765 else
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3766 newargv[j] = argv[j];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3767 paramlen += strlen (newargv[j]) + 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3768 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3769 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3770
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3771 /* After expanding all the arguments, we now know the length of the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3772 parameter block to be sent to the subprocess as a message
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3773 attached to the HLE. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3774 param = (char *) malloc (paramlen + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3775 if (!param)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3776 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3777
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3778 p = param;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3779 *p++ = newargc;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3780 /* first byte of message contains number of arguments for command */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3781 strcpy (p, macworkdir);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3782 p += strlen (macworkdir);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3783 *p++ = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3784 /* null terminate strings sent so it's possible to use strcpy over there */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3785 strcpy (p, macinfn);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3786 p += strlen (macinfn);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3787 *p++ = '\0';
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3788 strcpy (p, macoutfn);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3789 p += strlen (macoutfn);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3790 *p++ = '\0';
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3791 strcpy (p, macerrfn);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3792 p += strlen (macerrfn);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3793 *p++ = '\0';
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3794 for (j = 1; j < newargc; j++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3795 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3796 strcpy (p, newargv[j]);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3797 p += strlen (newargv[j]);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3798 *p++ = '\0';
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3799 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3800
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3801 c2pstr (macappname);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3802
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3803 iErr = FSMakeFSSpec (0, 0, macappname, &spec);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3804
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3805 if (iErr != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3806 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3807 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3808 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3809 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3810
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3811 lpbr.launchBlockID = extendedBlock;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3812 lpbr.launchEPBLength = extendedBlockLen;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3813 lpbr.launchControlFlags = launchContinue + launchNoFileFlags;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3814 lpbr.launchAppSpec = &spec;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3815 lpbr.launchAppParameters = NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3816
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3817 iErr = LaunchApplication (&lpbr); /* call the subprocess */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3818 if (iErr != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3819 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3820 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3821 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3822 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3823
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3824 send_event.what = kHighLevelEvent;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3825 send_event.message = kEmacsSubprocessSend;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3826 /* Event ID stored in "where" unused */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3827
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3828 retries = 3;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3829 /* OS may think current subprocess has terminated if previous one
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3830 terminated recently. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3831 do
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3832 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3833 iErr = PostHighLevelEvent (&send_event, &lpbr.launchProcessSN, 0, param,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3834 paramlen + 1, receiverIDisPSN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3835 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3836 while (iErr == sessClosedErr && retries-- > 0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3837
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3838 if (iErr != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3839 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3840 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3841 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3842 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3843
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3844 cursor_region_handle = NewRgn ();
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3845
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3846 /* Wait for the subprocess to finish, when it will send us a ERPY
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3847 high level event. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3848 while (1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3849 if (WaitNextEvent (highLevelEventMask, &reply_event, 180,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3850 cursor_region_handle)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3851 && reply_event.message == kEmacsSubprocessReply)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3852 break;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3853
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3854 /* The return code is sent through the refCon */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3855 iErr = AcceptHighLevelEvent (&targ, &ref_con, NULL, &len);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3856 if (iErr != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3857 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3858 DisposeHandle ((Handle) cursor_region_handle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3859 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3860 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3861 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3862
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3863 DisposeHandle ((Handle) cursor_region_handle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3864 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3865
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3866 return ref_con;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3867 #endif /* not TARGET_API_MAC_CARBON */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3868 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3869
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3870
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3871 DIR *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3872 opendir (const char *dirname)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3873 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3874 char true_pathname[MAXPATHLEN+1], fully_resolved_name[MAXPATHLEN+1];
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3875 char mac_pathname[MAXPATHLEN+1], vol_name[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3876 DIR *dirp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3877 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3878 HVolumeParam vpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3879 int len, vol_name_len;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3880
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3881 if (find_true_pathname (dirname, true_pathname, MAXPATHLEN+1) == -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3882 return 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3883
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3884 len = readlink (true_pathname, fully_resolved_name, MAXPATHLEN);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3885 if (len > -1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3886 fully_resolved_name[len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3887 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3888 strcpy (fully_resolved_name, true_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3889
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3890 dirp = (DIR *) malloc (sizeof(DIR));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3891 if (!dirp)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3892 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3893
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3894 /* Handle special case when dirname is "/": sets up for readir to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3895 get all mount volumes. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3896 if (strcmp (fully_resolved_name, "/") == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3897 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3898 dirp->getting_volumes = 1; /* special all mounted volumes DIR struct */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3899 dirp->current_index = 1; /* index for first volume */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3900 return dirp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3901 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3902
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3903 /* Handle typical cases: not accessing all mounted volumes. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3904 if (!posix_to_mac_pathname (fully_resolved_name, mac_pathname, MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3905 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3906
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3907 /* Emacs calls opendir without the trailing '/', Mac needs trailing ':' */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3908 len = strlen (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3909 if (mac_pathname[len - 1] != ':' && len < MAXPATHLEN)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3910 strcat (mac_pathname, ":");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3911
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3912 /* Extract volume name */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3913 vol_name_len = strchr (mac_pathname, ':') - mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3914 strncpy (vol_name, mac_pathname, vol_name_len);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3915 vol_name[vol_name_len] = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3916 strcat (vol_name, ":");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3917
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3918 c2pstr (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3919 cipb.hFileInfo.ioNamePtr = mac_pathname;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3920 /* using full pathname so vRefNum and DirID ignored */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3921 cipb.hFileInfo.ioVRefNum = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3922 cipb.hFileInfo.ioDirID = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3923 cipb.hFileInfo.ioFDirIndex = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3924 /* set to 0 to get information about specific dir or file */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3925
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3926 errno = PBGetCatInfo (&cipb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3927 if (errno != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3928 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3929 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3930 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3931 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3932
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3933 if (!(cipb.hFileInfo.ioFlAttrib & 0x10)) /* bit 4 = 1 for directories */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3934 return 0; /* not a directory */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3935
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3936 dirp->dir_id = cipb.dirInfo.ioDrDirID; /* used later in readdir */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3937 dirp->getting_volumes = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3938 dirp->current_index = 1; /* index for first file/directory */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3939
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3940 c2pstr (vol_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3941 vpb.ioNamePtr = vol_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3942 /* using full pathname so vRefNum and DirID ignored */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3943 vpb.ioVRefNum = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3944 vpb.ioVolIndex = -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3945 errno = PBHGetVInfo ((union HParamBlockRec *) &vpb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3946 if (errno != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3947 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3948 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3949 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3950 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3951
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3952 dirp->vol_ref_num = vpb.ioVRefNum;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3953
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3954 return dirp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3955 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3956
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3957 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3958 closedir (DIR *dp)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3959 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3960 free (dp);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3961
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3962 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3963 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3964
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3965
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3966 struct dirent *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3967 readdir (DIR *dp)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3968 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3969 HParamBlockRec hpblock;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3970 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3971 static struct dirent s_dirent;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3972 static Str255 s_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3973 int done;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3974 char *p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3975
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3976 /* Handle the root directory containing the mounted volumes. Call
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3977 PBHGetVInfo specifying an index to obtain the info for a volume.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3978 PBHGetVInfo returns an error when it receives an index beyond the
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3979 last volume, at which time we should return a nil dirent struct
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3980 pointer. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3981 if (dp->getting_volumes)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3982 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3983 hpblock.volumeParam.ioNamePtr = s_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3984 hpblock.volumeParam.ioVRefNum = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3985 hpblock.volumeParam.ioVolIndex = dp->current_index;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3986
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3987 errno = PBHGetVInfo (&hpblock, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3988 if (errno != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3989 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3990 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3991 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3992 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
3993
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3994 p2cstr (s_name);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3995 strcat (s_name, "/"); /* need "/" for stat to work correctly */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3996
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3997 dp->current_index++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3998
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3999 s_dirent.d_ino = hpblock.volumeParam.ioVRefNum;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4000 s_dirent.d_name = s_name;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4001
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4002 return &s_dirent;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4003 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4004 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4005 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4006 cipb.hFileInfo.ioVRefNum = dp->vol_ref_num;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4007 cipb.hFileInfo.ioNamePtr = s_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4008 /* location to receive filename returned */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4009
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4010 /* return only visible files */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4011 done = false;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4012 while (!done)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4013 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4014 cipb.hFileInfo.ioDirID = dp->dir_id;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4015 /* directory ID found by opendir */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4016 cipb.hFileInfo.ioFDirIndex = dp->current_index;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4017
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4018 errno = PBGetCatInfo (&cipb, false);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4019 if (errno != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4020 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4021 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4022 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4023 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4024
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4025 /* insist on a visible entry */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4026 if (cipb.hFileInfo.ioFlAttrib & 0x10) /* directory? */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4027 done = !(cipb.dirInfo.ioDrUsrWds.frFlags & fInvisible);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4028 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4029 done = !(cipb.hFileInfo.ioFlFndrInfo.fdFlags & fInvisible);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4030
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4031 dp->current_index++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4032 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4033
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4034 p2cstr (s_name);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4035
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4036 p = s_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4037 while (*p)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4038 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4039 if (*p == '/')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4040 *p = ':';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4041 p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4042 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4043
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4044 s_dirent.d_ino = cipb.dirInfo.ioDrDirID;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4045 /* value unimportant: non-zero for valid file */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4046 s_dirent.d_name = s_name;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4047
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4048 return &s_dirent;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4049 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4050 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4051
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4052
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4053 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4054 getwd (char *path)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4055 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4056 char mac_pathname[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4057 Str255 directory_name;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4058 OSErr errno;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4059 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4060
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4061 if (path_from_vol_dir_name (mac_pathname, 255, 0, 0, "\p") == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4062 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4063
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4064 if (mac_to_posix_pathname (mac_pathname, path, MAXPATHLEN+1) == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4065 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4066 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4067 return path;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4068 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4069
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4070 #endif /* ! MAC_OSX */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4071
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4072
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4073 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4074 initialize_applescript ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4075 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4076 AEDesc null_desc;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4077 OSAError osaerror;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4078
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4079 /* if open fails, as_scripting_component is set to NULL. Its
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4080 subsequent use in OSA calls will fail with badComponentInstance
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4081 error. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4082 as_scripting_component = OpenDefaultComponent (kOSAComponentType,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4083 kAppleScriptSubtype);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4084
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4085 null_desc.descriptorType = typeNull;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4086 null_desc.dataHandle = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4087 osaerror = OSAMakeContext (as_scripting_component, &null_desc,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4088 kOSANullScript, &as_script_context);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4089 if (osaerror)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4090 as_script_context = kOSANullScript;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4091 /* use default context if create fails */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4092 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4093
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4094
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4095 void
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4096 terminate_applescript()
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4097 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4098 OSADispose (as_scripting_component, as_script_context);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4099 CloseComponent (as_scripting_component);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4100 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4101
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4102 /* Convert a lisp string to the 4 byte character code. */
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4103
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4104 OSType
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4105 mac_get_code_from_arg(Lisp_Object arg, OSType defCode)
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4106 {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4107 OSType result;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4108 if (NILP(arg))
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4109 {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4110 result = defCode;
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4111 }
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4112 else
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4113 {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4114 /* check type string */
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4115 CHECK_STRING(arg);
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4116 if (SBYTES (arg) != 4)
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4117 {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4118 error ("Wrong argument: need string of length 4 for code");
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4119 }
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4120 result = EndianU32_BtoN (*((UInt32 *) SDATA (arg)));
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4121 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4122 return result;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4123 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4124
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4125 /* Convert the 4 byte character code into a 4 byte string. */
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4126
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4127 Lisp_Object
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4128 mac_get_object_from_code(OSType defCode)
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4129 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4130 UInt32 code = EndianU32_NtoB (defCode);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4131
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4132 return make_unibyte_string ((char *)&code, 4);
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4133 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4134
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4135
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4136 DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1, 1, 0,
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4137 doc: /* Get the creator code of FILENAME as a four character string. */)
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4138 (filename)
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4139 Lisp_Object filename;
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4140 {
72542
bb89b5bbed54 (create_apple_event_from_event_ref, select)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71838
diff changeset
4141 OSStatus status;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4142 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4143 FSRef fref;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4144 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4145 FSSpec fss;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4146 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4147 Lisp_Object result = Qnil;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4148 CHECK_STRING (filename);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4149
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4150 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4151 return Qnil;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4152 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4153 filename = Fexpand_file_name (filename, Qnil);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4154
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4155 BLOCK_INPUT;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4156 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4157 status = FSPathMakeRef(SDATA(ENCODE_FILE(filename)), &fref, NULL);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4158 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4159 status = posix_pathname_to_fsspec (SDATA (ENCODE_FILE (filename)), &fss);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4160 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4161
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4162 if (status == noErr)
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4163 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4164 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4165 FSCatalogInfo catalogInfo;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4166
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4167 status = FSGetCatalogInfo(&fref, kFSCatInfoFinderInfo,
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4168 &catalogInfo, NULL, NULL, NULL);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4169 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4170 FInfo finder_info;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4171
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4172 status = FSpGetFInfo (&fss, &finder_info);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4173 #endif
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4174 if (status == noErr)
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4175 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4176 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4177 result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator);
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4178 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4179 result = mac_get_object_from_code (finder_info.fdCreator);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4180 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4181 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4182 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4183 UNBLOCK_INPUT;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4184 if (status != noErr) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4185 error ("Error while getting file information.");
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4186 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4187 return result;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4188 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4189
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4190 DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0,
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4191 doc: /* Get the type code of FILENAME as a four character string. */)
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4192 (filename)
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4193 Lisp_Object filename;
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4194 {
72542
bb89b5bbed54 (create_apple_event_from_event_ref, select)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71838
diff changeset
4195 OSStatus status;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4196 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4197 FSRef fref;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4198 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4199 FSSpec fss;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4200 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4201 Lisp_Object result = Qnil;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4202 CHECK_STRING (filename);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4203
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4204 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4205 return Qnil;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4206 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4207 filename = Fexpand_file_name (filename, Qnil);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4208
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4209 BLOCK_INPUT;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4210 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4211 status = FSPathMakeRef(SDATA(ENCODE_FILE(filename)), &fref, NULL);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4212 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4213 status = posix_pathname_to_fsspec (SDATA (ENCODE_FILE (filename)), &fss);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4214 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4215
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4216 if (status == noErr)
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4217 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4218 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4219 FSCatalogInfo catalogInfo;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4220
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4221 status = FSGetCatalogInfo(&fref, kFSCatInfoFinderInfo,
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4222 &catalogInfo, NULL, NULL, NULL);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4223 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4224 FInfo finder_info;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4225
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4226 status = FSpGetFInfo (&fss, &finder_info);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4227 #endif
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4228 if (status == noErr)
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4229 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4230 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4231 result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType);
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4232 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4233 result = mac_get_object_from_code (finder_info.fdType);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4234 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4235 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4236 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4237 UNBLOCK_INPUT;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4238 if (status != noErr) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4239 error ("Error while getting file information.");
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4240 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4241 return result;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4242 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4243
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4244 DEFUN ("mac-set-file-creator", Fmac_set_file_creator, Smac_set_file_creator, 1, 2, 0,
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4245 doc: /* Set creator code of file FILENAME to CODE.
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4246 If non-nil, CODE must be a 4-character string. Otherwise, 'EMAx' is
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4247 assumed. Return non-nil if successful. */)
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4248 (filename, code)
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4249 Lisp_Object filename, code;
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4250 {
72542
bb89b5bbed54 (create_apple_event_from_event_ref, select)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71838
diff changeset
4251 OSStatus status;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4252 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4253 FSRef fref;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4254 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4255 FSSpec fss;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4256 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4257 OSType cCode;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4258 CHECK_STRING (filename);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4259
75097
5e8caf6183ec (Fmac_set_file_creator): Use MAC_EMACS_CREATOR_CODE
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 74755
diff changeset
4260 cCode = mac_get_code_from_arg(code, MAC_EMACS_CREATOR_CODE);
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4261
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4262 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4263 return Qnil;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4264 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4265 filename = Fexpand_file_name (filename, Qnil);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4266
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4267 BLOCK_INPUT;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4268 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4269 status = FSPathMakeRef(SDATA(ENCODE_FILE(filename)), &fref, NULL);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4270 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4271 status = posix_pathname_to_fsspec (SDATA (ENCODE_FILE (filename)), &fss);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4272 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4273
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4274 if (status == noErr)
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4275 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4276 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4277 FSCatalogInfo catalogInfo;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4278 FSRef parentDir;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4279 status = FSGetCatalogInfo(&fref, kFSCatInfoFinderInfo,
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4280 &catalogInfo, NULL, NULL, &parentDir);
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4281 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4282 FInfo finder_info;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4283
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4284 status = FSpGetFInfo (&fss, &finder_info);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4285 #endif
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4286 if (status == noErr)
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4287 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4288 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4289 ((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4290 status = FSSetCatalogInfo(&fref, kFSCatInfoFinderInfo, &catalogInfo);
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4291 /* TODO: on Mac OS 10.2, we need to touch the parent dir, FNNotify? */
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4292 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4293 finder_info.fdCreator = cCode;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4294 status = FSpSetFInfo (&fss, &finder_info);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4295 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4296 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4297 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4298 UNBLOCK_INPUT;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4299 if (status != noErr) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4300 error ("Error while setting creator information.");
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4301 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4302 return Qt;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4303 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4304
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4305 DEFUN ("mac-set-file-type", Fmac_set_file_type, Smac_set_file_type, 2, 2, 0,
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4306 doc: /* Set file code of file FILENAME to CODE.
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4307 CODE must be a 4-character string. Return non-nil if successful. */)
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4308 (filename, code)
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4309 Lisp_Object filename, code;
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4310 {
72542
bb89b5bbed54 (create_apple_event_from_event_ref, select)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71838
diff changeset
4311 OSStatus status;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4312 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4313 FSRef fref;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4314 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4315 FSSpec fss;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4316 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4317 OSType cCode;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4318 CHECK_STRING (filename);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4319
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4320 cCode = mac_get_code_from_arg(code, 0); /* Default to empty code*/
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4321
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4322 if (NILP(Ffile_exists_p(filename)) || !NILP(Ffile_directory_p(filename))) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4323 return Qnil;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4324 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4325 filename = Fexpand_file_name (filename, Qnil);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4326
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4327 BLOCK_INPUT;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4328 #ifdef MAC_OSX
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4329 status = FSPathMakeRef(SDATA(ENCODE_FILE(filename)), &fref, NULL);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4330 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4331 status = posix_pathname_to_fsspec (SDATA (ENCODE_FILE (filename)), &fss);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4332 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4333
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4334 if (status == noErr)
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4335 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4336 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4337 FSCatalogInfo catalogInfo;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4338 FSRef parentDir;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4339 status = FSGetCatalogInfo(&fref, kFSCatInfoFinderInfo,
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4340 &catalogInfo, NULL, NULL, &parentDir);
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4341 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4342 FInfo finder_info;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4343
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4344 status = FSpGetFInfo (&fss, &finder_info);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4345 #endif
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4346 if (status == noErr)
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4347 {
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4348 #ifdef MAC_OSX
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4349 ((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode;
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4350 status = FSSetCatalogInfo(&fref, kFSCatInfoFinderInfo, &catalogInfo);
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4351 /* TODO: on Mac OS 10.2, we need to touch the parent dir, FNNotify? */
64247
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4352 #else
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4353 finder_info.fdType = cCode;
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4354 status = FSpSetFInfo (&fss, &finder_info);
e55c855616f5 [!TARGET_API_MAC_CARBON] Include charset.h, coding.h, and Endian.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64214
diff changeset
4355 #endif
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4356 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4357 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4358 UNBLOCK_INPUT;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4359 if (status != noErr) {
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4360 error ("Error while setting creator information.");
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4361 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4362 return Qt;
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4363 }
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
4364
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4365
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4366 /* Compile and execute the AppleScript SCRIPT and return the error
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4367 status as function value. A zero is returned if compilation and
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4368 execution is successful, in which case *RESULT is set to a Lisp
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4369 string containing the resulting script value. Otherwise, the Mac
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4370 error code is returned and *RESULT is set to an error Lisp string.
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4371 For documentation on the MacOS scripting architecture, see Inside
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4372 Macintosh - Interapplication Communications: Scripting
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4373 Components. */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4374
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4375 static long
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4376 do_applescript (script, result)
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4377 Lisp_Object script, *result;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4378 {
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4379 AEDesc script_desc, result_desc, error_desc, *desc = NULL;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4380 OSErr error;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4381 OSAError osaerror;
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4382
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4383 *result = Qnil;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4384
45851
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
4385 if (!as_scripting_component)
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
4386 initialize_applescript();
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
4387
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4388 error = AECreateDesc (typeChar, SDATA (script), SBYTES (script),
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4389 &script_desc);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4390 if (error)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4391 return error;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4392
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4393 osaerror = OSADoScript (as_scripting_component, &script_desc, kOSANullScript,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4394 typeChar, kOSAModeNull, &result_desc);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4395
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4396 if (osaerror == noErr)
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4397 /* success: retrieve resulting script value */
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4398 desc = &result_desc;
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4399 else if (osaerror == errOSAScriptError)
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4400 /* error executing AppleScript: retrieve error message */
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4401 if (!OSAScriptError (as_scripting_component, kOSAErrorMessage, typeChar,
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4402 &error_desc))
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4403 desc = &error_desc;
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4404
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4405 if (desc)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4406 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4407 #if TARGET_API_MAC_CARBON
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4408 *result = make_uninit_string (AEGetDescDataSize (desc));
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4409 AEGetDescData (desc, SDATA (*result), SBYTES (*result));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4410 #else /* not TARGET_API_MAC_CARBON */
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4411 *result = make_uninit_string (GetHandleSize (desc->dataHandle));
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4412 memcpy (SDATA (*result), *(desc->dataHandle), SBYTES (*result));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4413 #endif /* not TARGET_API_MAC_CARBON */
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4414 AEDisposeDesc (desc);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4415 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4416
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4417 AEDisposeDesc (&script_desc);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4418
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4419 return osaerror;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4420 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4421
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4422
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4423 DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0,
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4424 doc: /* Compile and execute AppleScript SCRIPT and return the result.
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4425 If compilation and execution are successful, the resulting script
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4426 value is returned as a string. Otherwise the function aborts and
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4427 displays the error message returned by the AppleScript scripting
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4428 component. */)
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4429 (script)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4430 Lisp_Object script;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4431 {
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4432 Lisp_Object result;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4433 long status;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4434
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4435 CHECK_STRING (script);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
4436
57425
0867872551d9 macterm.c (x_raise_frame): Add BLOCK_INPUT around SelectWindow
Steven Tamm <steventamm@mac.com>
parents: 57397
diff changeset
4437 BLOCK_INPUT;
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4438 status = do_applescript (script, &result);
57425
0867872551d9 macterm.c (x_raise_frame): Add BLOCK_INPUT around SelectWindow
Steven Tamm <steventamm@mac.com>
parents: 57397
diff changeset
4439 UNBLOCK_INPUT;
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4440 if (status == 0)
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4441 return result;
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4442 else if (!STRINGP (result))
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4443 error ("AppleScript error %d", status);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4444 else
67665
98b67f3d9491 (create_apple_event_from_event_ref): Remove arg `types'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67456
diff changeset
4445 error ("%s", SDATA (result));
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4446 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4447
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4448
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4449 DEFUN ("mac-file-name-to-posix", Fmac_file_name_to_posix,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4450 Smac_file_name_to_posix, 1, 1, 0,
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4451 doc: /* Convert Macintosh FILENAME to Posix form. */)
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4452 (filename)
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4453 Lisp_Object filename;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4454 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4455 char posix_filename[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4456
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4457 CHECK_STRING (filename);
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4458
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4459 if (mac_to_posix_pathname (SDATA (filename), posix_filename, MAXPATHLEN))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4460 return build_string (posix_filename);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4461 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4462 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4463 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4464
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4465
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4466 DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4467 Sposix_file_name_to_mac, 1, 1, 0,
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4468 doc: /* Convert Posix FILENAME to Mac form. */)
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4469 (filename)
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4470 Lisp_Object filename;
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4471 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4472 char mac_filename[MAXPATHLEN+1];
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4473
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4474 CHECK_STRING (filename);
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4475
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4476 if (posix_to_mac_pathname (SDATA (filename), mac_filename, MAXPATHLEN))
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4477 return build_string (mac_filename);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4478 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4479 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4480 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4481
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4482
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4483 DEFUN ("mac-coerce-ae-data", Fmac_coerce_ae_data, Smac_coerce_ae_data, 3, 3, 0,
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4484 doc: /* Coerce Apple event data SRC-DATA of type SRC-TYPE to DST-TYPE.
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4485 Each type should be a string of length 4 or the symbol
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4486 `undecoded-file-name'. */)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4487 (src_type, src_data, dst_type)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4488 Lisp_Object src_type, src_data, dst_type;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4489 {
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4490 OSErr err;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4491 Lisp_Object result = Qnil;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4492 DescType src_desc_type, dst_desc_type;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4493 AEDesc dst_desc;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4494
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4495 CHECK_STRING (src_data);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4496 if (EQ (src_type, Qundecoded_file_name))
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
4497 src_desc_type = TYPE_FILE_NAME;
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4498 else
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4499 src_desc_type = mac_get_code_from_arg (src_type, 0);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4500
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4501 if (EQ (dst_type, Qundecoded_file_name))
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
4502 dst_desc_type = TYPE_FILE_NAME;
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4503 else
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4504 dst_desc_type = mac_get_code_from_arg (dst_type, 0);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4505
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4506 BLOCK_INPUT;
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
4507 err = AECoercePtr (src_desc_type, SDATA (src_data), SBYTES (src_data),
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4508 dst_desc_type, &dst_desc);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4509 if (err == noErr)
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4510 {
67786
55dd97aa46da (posix_pathname_to_fsspec, fsspec_to_posix_pathname): Add
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67731
diff changeset
4511 result = Fcdr (mac_aedesc_to_lisp (&dst_desc));
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4512 AEDisposeDesc (&dst_desc);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4513 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4514 UNBLOCK_INPUT;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4515
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4516 return result;
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4517 }
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4518
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
4519
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4520 #if TARGET_API_MAC_CARBON
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4521 static Lisp_Object Qxml, Qmime_charset;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4522 static Lisp_Object QNFD, QNFKD, QNFC, QNFKC, QHFS_plus_D, QHFS_plus_C;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4523
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4524 DEFUN ("mac-get-preference", Fmac_get_preference, Smac_get_preference, 1, 4, 0,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4525 doc: /* Return the application preference value for KEY.
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4526 KEY is either a string specifying a preference key, or a list of key
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4527 strings. If it is a list, the (i+1)-th element is used as a key for
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4528 the CFDictionary value obtained by the i-th element. Return nil if
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4529 lookup is failed at some stage.
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4530
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4531 Optional arg APPLICATION is an application ID string. If omitted or
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4532 nil, that stands for the current application.
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4533
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4534 Optional arg FORMAT specifies the data format of the return value. If
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4535 omitted or nil, each Core Foundation object is converted into a
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4536 corresponding Lisp object as follows:
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4537
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4538 Core Foundation Lisp Tag
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4539 ------------------------------------------------------------
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4540 CFString Multibyte string string
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4541 CFNumber Integer or float number
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4542 CFBoolean Symbol (t or nil) boolean
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4543 CFDate List of three integers date
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4544 (cf. `current-time')
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4545 CFData Unibyte string data
61338
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
4546 CFArray Vector array
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4547 CFDictionary Alist or hash table dictionary
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4548 (depending on HASH-BOUND)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4549
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4550 If it is t, a symbol that represents the type of the original Core
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4551 Foundation object is prepended. If it is `xml', the value is returned
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4552 as an XML representation.
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4553
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4554 Optional arg HASH-BOUND specifies which kinds of the list objects,
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4555 alists or hash tables, are used as the targets of the conversion from
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4556 CFDictionary. If HASH-BOUND is a negative integer or nil, always
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4557 generate alists. If HASH-BOUND >= 0, generate an alist if the number
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4558 of keys in the dictionary is smaller than HASH-BOUND, and a hash table
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4559 otherwise. */)
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4560 (key, application, format, hash_bound)
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4561 Lisp_Object key, application, format, hash_bound;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4562 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4563 CFStringRef app_id, key_str;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4564 CFPropertyListRef app_plist = NULL, plist;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4565 Lisp_Object result = Qnil, tmp;
73384
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4566 struct gcpro gcpro1, gcpro2;
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4567
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4568 if (STRINGP (key))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4569 key = Fcons (key, Qnil);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4570 else
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4571 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4572 CHECK_CONS (key);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4573 for (tmp = key; CONSP (tmp); tmp = XCDR (tmp))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4574 CHECK_STRING_CAR (tmp);
71838
a322faa9b90c (Fmac_get_preference): Use CHECK_LIST_END.
Kim F. Storm <storm@cua.dk>
parents: 71501
diff changeset
4575 CHECK_LIST_END (tmp, key);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4576 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4577 if (!NILP (application))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4578 CHECK_STRING (application);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4579 CHECK_SYMBOL (format);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4580 if (!NILP (hash_bound))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4581 CHECK_NUMBER (hash_bound);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4582
73384
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4583 GCPRO2 (key, format);
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4584
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4585 BLOCK_INPUT;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4586
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4587 app_id = kCFPreferencesCurrentApplication;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4588 if (!NILP (application))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4589 {
61572
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
4590 app_id = cfstring_create_with_string (application);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4591 if (app_id == NULL)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4592 goto out;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4593 }
77140
f9e6e90b6141 (xrm_get_preference_database, Fmac_get_preference)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
4594 if (!CFPreferencesAppSynchronize (app_id))
f9e6e90b6141 (xrm_get_preference_database, Fmac_get_preference)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
4595 goto out;
f9e6e90b6141 (xrm_get_preference_database, Fmac_get_preference)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
4596
61572
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
4597 key_str = cfstring_create_with_string (XCAR (key));
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4598 if (key_str == NULL)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4599 goto out;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4600 app_plist = CFPreferencesCopyAppValue (key_str, app_id);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4601 CFRelease (key_str);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4602 if (app_plist == NULL)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4603 goto out;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4604
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4605 plist = app_plist;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4606 for (key = XCDR (key); CONSP (key); key = XCDR (key))
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4607 {
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4608 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4609 break;
61572
4fdfaa49202b Include charset.h and coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61553
diff changeset
4610 key_str = cfstring_create_with_string (XCAR (key));
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4611 if (key_str == NULL)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4612 goto out;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4613 plist = CFDictionaryGetValue (plist, key_str);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4614 CFRelease (key_str);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4615 if (plist == NULL)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4616 goto out;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4617 }
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4618
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4619 if (NILP (key))
69960
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4620 {
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4621 if (EQ (format, Qxml))
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4622 {
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4623 CFDataRef data = CFPropertyListCreateXMLData (NULL, plist);
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4624 if (data == NULL)
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4625 goto out;
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4626 result = cfdata_to_lisp (data);
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4627 CFRelease (data);
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4628 }
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4629 else
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4630 result =
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4631 cfproperty_list_to_lisp (plist, EQ (format, Qt),
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4632 NILP (hash_bound) ? -1 : XINT (hash_bound));
b4cb58f90f13 (init_process): Remove undef.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69430
diff changeset
4633 }
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4634
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4635 out:
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4636 if (app_plist)
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4637 CFRelease (app_plist);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4638 CFRelease (app_id);
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4639
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4640 UNBLOCK_INPUT;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4641
73384
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4642 UNGCPRO;
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4643
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4644 return result;
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4645 }
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4646
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4647
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4648 static CFStringEncoding
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4649 get_cfstring_encoding_from_lisp (obj)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4650 Lisp_Object obj;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4651 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4652 CFStringRef iana_name;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4653 CFStringEncoding encoding = kCFStringEncodingInvalidId;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4654
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4655 if (NILP (obj))
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4656 return kCFStringEncodingUnicode;
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4657
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4658 if (INTEGERP (obj))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4659 return XINT (obj);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4660
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4661 if (SYMBOLP (obj) && !NILP (Fcoding_system_p (obj)))
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4662 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4663 Lisp_Object coding_spec, plist;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4664
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4665 coding_spec = Fget (obj, Qcoding_system);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4666 plist = XVECTOR (coding_spec)->contents[3];
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4667 obj = Fplist_get (XVECTOR (coding_spec)->contents[3], Qmime_charset);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4668 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4669
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4670 if (SYMBOLP (obj))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4671 obj = SYMBOL_NAME (obj);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4672
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4673 if (STRINGP (obj))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4674 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4675 iana_name = cfstring_create_with_string (obj);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4676 if (iana_name)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4677 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4678 encoding = CFStringConvertIANACharSetNameToEncoding (iana_name);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4679 CFRelease (iana_name);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4680 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4681 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4682
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4683 return encoding;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4684 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4685
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4686 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4687 static CFStringRef
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4688 cfstring_create_normalized (str, symbol)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4689 CFStringRef str;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4690 Lisp_Object symbol;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4691 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4692 int form = -1;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4693 TextEncodingVariant variant;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4694 float initial_mag = 0.0;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4695 CFStringRef result = NULL;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4696
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4697 if (EQ (symbol, QNFD))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4698 form = kCFStringNormalizationFormD;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4699 else if (EQ (symbol, QNFKD))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4700 form = kCFStringNormalizationFormKD;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4701 else if (EQ (symbol, QNFC))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4702 form = kCFStringNormalizationFormC;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4703 else if (EQ (symbol, QNFKC))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4704 form = kCFStringNormalizationFormKC;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4705 else if (EQ (symbol, QHFS_plus_D))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4706 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4707 variant = kUnicodeHFSPlusDecompVariant;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4708 initial_mag = 1.5;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4709 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4710 else if (EQ (symbol, QHFS_plus_C))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4711 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4712 variant = kUnicodeHFSPlusCompVariant;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4713 initial_mag = 1.0;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4714 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4715
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4716 if (form >= 0)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4717 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4718 CFMutableStringRef mut_str = CFStringCreateMutableCopy (NULL, 0, str);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4719
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4720 if (mut_str)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4721 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4722 CFStringNormalize (mut_str, form);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4723 result = mut_str;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4724 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4725 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4726 else if (initial_mag > 0.0)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4727 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4728 UnicodeToTextInfo uni = NULL;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4729 UnicodeMapping map;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4730 CFIndex length;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4731 UniChar *in_text, *buffer = NULL, *out_buf = NULL;
72542
bb89b5bbed54 (create_apple_event_from_event_ref, select)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71838
diff changeset
4732 OSStatus err = noErr;
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4733 ByteCount out_read, out_size, out_len;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4734
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4735 map.unicodeEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault,
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4736 kUnicodeNoSubset,
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4737 kTextEncodingDefaultFormat);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4738 map.otherEncoding = CreateTextEncoding (kTextEncodingUnicodeDefault,
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4739 variant,
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4740 kTextEncodingDefaultFormat);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4741 map.mappingVersion = kUnicodeUseLatestMapping;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4742
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4743 length = CFStringGetLength (str);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4744 out_size = (int)((float)length * initial_mag) * sizeof (UniChar);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4745 if (out_size < 32)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4746 out_size = 32;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4747
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4748 in_text = (UniChar *)CFStringGetCharactersPtr (str);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4749 if (in_text == NULL)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4750 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4751 buffer = xmalloc (sizeof (UniChar) * length);
70069
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4752 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4753 in_text = buffer;
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4754 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4755
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4756 if (in_text)
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
4757 err = CreateUnicodeToTextInfo (&map, &uni);
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4758 while (err == noErr)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4759 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4760 out_buf = xmalloc (out_size);
70069
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4761 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar),
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4762 in_text,
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4763 kUnicodeDefaultDirectionMask,
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4764 0, NULL, NULL, NULL,
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4765 out_size, &out_read, &out_len,
e82c1fc1df38 (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69960
diff changeset
4766 out_buf);
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4767 if (err == noErr && out_read < length * sizeof (UniChar))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4768 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4769 xfree (out_buf);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4770 out_size += length;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4771 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4772 else
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4773 break;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4774 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4775 if (err == noErr)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4776 result = CFStringCreateWithCharacters (NULL, out_buf,
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4777 out_len / sizeof (UniChar));
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4778 if (uni)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4779 DisposeUnicodeToTextInfo (&uni);
95481
4390d64d3328 Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
4780 xfree (out_buf);
4390d64d3328 Make "xfree (NULL)" a no-op; remove useless if-before-xfree.
Jim Meyering <jim@meyering.net>
parents: 94963
diff changeset
4781 xfree (buffer);
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4782 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4783 else
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4784 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4785 result = str;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4786 CFRetain (result);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4787 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4788
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4789 return result;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4790 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4791 #endif
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4792
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4793 DEFUN ("mac-code-convert-string", Fmac_code_convert_string, Smac_code_convert_string, 3, 4, 0,
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4794 doc: /* Convert STRING from SOURCE encoding to TARGET encoding.
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4795 The conversion is performed using the converter provided by the system.
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4796 Each encoding is specified by either a coding system symbol, a mime
74755
e97a993d4ab6 (Fmac_code_convert_string): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 74626
diff changeset
4797 charset string, or an integer as a CFStringEncoding value. An encoding
e97a993d4ab6 (Fmac_code_convert_string): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 74626
diff changeset
4798 of nil means UTF-16 in native byte order, no byte order mark.
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4799 On Mac OS X 10.2 and later, you can do Unicode Normalization by
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4800 specifying the optional argument NORMALIZATION-FORM with a symbol NFD,
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4801 NFKD, NFC, NFKC, HFS+D, or HFS+C.
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4802 On successful conversion, return the result string, else return nil. */)
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
4803 (string, source, target, normalization_form)
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4804 Lisp_Object string, source, target, normalization_form;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4805 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4806 Lisp_Object result = Qnil;
73384
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4807 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4808 CFStringEncoding src_encoding, tgt_encoding;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4809 CFStringRef str = NULL;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4810
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4811 CHECK_STRING (string);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4812 if (!INTEGERP (source) && !STRINGP (source))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4813 CHECK_SYMBOL (source);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4814 if (!INTEGERP (target) && !STRINGP (target))
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4815 CHECK_SYMBOL (target);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4816 CHECK_SYMBOL (normalization_form);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4817
73384
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4818 GCPRO4 (string, source, target, normalization_form);
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4819
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4820 BLOCK_INPUT;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4821
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4822 src_encoding = get_cfstring_encoding_from_lisp (source);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4823 tgt_encoding = get_cfstring_encoding_from_lisp (target);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4824
64553
58cbcf3e6ed1 (Fmac_code_convert_string): Add comment about Fstring_as_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64358
diff changeset
4825 /* We really want string_to_unibyte, but since it doesn't exist yet, we
58cbcf3e6ed1 (Fmac_code_convert_string): Add comment about Fstring_as_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64358
diff changeset
4826 use string_as_unibyte which works as well, except for the fact that
58cbcf3e6ed1 (Fmac_code_convert_string): Add comment about Fstring_as_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64358
diff changeset
4827 it's too permissive (it doesn't check that the multibyte string only
58cbcf3e6ed1 (Fmac_code_convert_string): Add comment about Fstring_as_unibyte.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64358
diff changeset
4828 contain single-byte chars). */
64358
a673f66d6156 [TARGET_API_MAC_CARBON] (Fmac_code_convert_string): Use
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64247
diff changeset
4829 string = Fstring_as_unibyte (string);
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4830 if (src_encoding != kCFStringEncodingInvalidId
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4831 && tgt_encoding != kCFStringEncodingInvalidId)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4832 str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string),
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4833 src_encoding, !NILP (source));
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4834 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4835 if (str)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4836 {
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4837 CFStringRef saved_str = str;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4838
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4839 str = cfstring_create_normalized (saved_str, normalization_form);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4840 CFRelease (saved_str);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4841 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4842 #endif
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4843 if (str)
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4844 {
66108
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4845 CFIndex str_len, buf_len;
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4846
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4847 str_len = CFStringGetLength (str);
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4848 if (CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4849 !NILP (target), NULL, 0, &buf_len) == str_len)
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4850 {
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4851 result = make_uninit_string (buf_len);
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4852 CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4853 !NILP (target), SDATA (result), buf_len, NULL);
f4ddfc71077d [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp): Allow nil
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64770
diff changeset
4854 }
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4855 CFRelease (str);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4856 }
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4857
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4858 UNBLOCK_INPUT;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4859
73384
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4860 UNGCPRO;
c5a4a949a307 (Fmac_get_preference, Fmac_code_convert_string): Add GCPROs.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72983
diff changeset
4861
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4862 return result;
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
4863 }
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4864
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4865 DEFUN ("mac-process-hi-command", Fmac_process_hi_command, Smac_process_hi_command, 1, 1, 0,
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4866 doc: /* Send a HI command whose ID is COMMAND-ID to the command chain.
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4867 COMMAND-ID must be a 4-character string. Some common command IDs are
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4868 defined in the Carbon Event Manager. */)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4869 (command_id)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4870 Lisp_Object command_id;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4871 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4872 OSStatus err;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4873 HICommand command;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4874
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4875 bzero (&command, sizeof (HICommand));
72771
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
4876 command.commandID = mac_get_code_from_arg (command_id, 0);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4877
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4878 BLOCK_INPUT;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4879 err = ProcessHICommand (&command);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4880 UNBLOCK_INPUT;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4881
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4882 if (err != noErr)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4883 error ("HI command (command ID: '%s') not handled.", SDATA (command_id));
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4884
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4885 return Qnil;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4886 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4887
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4888 #endif /* TARGET_API_MAC_CARBON */
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
4889
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4890
66763
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4891 static Lisp_Object
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4892 mac_get_system_locale ()
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4893 {
72542
bb89b5bbed54 (create_apple_event_from_event_ref, select)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71838
diff changeset
4894 OSStatus err;
66763
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4895 LangCode lang;
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4896 RegionCode region;
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4897 LocaleRef locale;
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4898 Str255 str;
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4899
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4900 lang = GetScriptVariable (smSystemScript, smScriptLang);
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4901 region = GetScriptManagerVariable (smRegionCode);
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4902 err = LocaleRefFromLangOrRegionCode (lang, region, &locale);
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4903 if (err == noErr)
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4904 err = LocaleRefGetPartString (locale, kLocaleAllPartsMask,
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4905 sizeof (str), str);
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4906 if (err == noErr)
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4907 return build_string (str);
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4908 else
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4909 return Qnil;
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4910 }
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4911
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
4912
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
4913 #ifdef MAC_OSX
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
4914
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
4915 extern int inhibit_window_system;
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
4916 extern int noninteractive;
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
4917
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4918 /* Unlike in X11, window events in Carbon do not come from sockets.
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4919 So we cannot simply use `select' to monitor two kinds of inputs:
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4920 window events and process outputs. We emulate such functionality
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4921 by regarding fd 0 as the window event channel and simultaneously
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4922 monitoring both kinds of input channels. It is implemented by
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4923 dividing into some cases:
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4924 1. The window event channel is not involved.
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4925 -> Use `select'.
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4926 2. Sockets are not involved.
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4927 -> Use ReceiveNextEvent.
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4928 3. [If SELECT_USE_CFSOCKET is set]
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4929 Only the window event channel and socket read/write channels are
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4930 involved, and timeout is not too short (greater than
77308
2ec04a50669a Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 77140
diff changeset
4931 SELECT_TIMEOUT_THRESHOLD_RUNLOOP seconds).
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4932 -> Create CFSocket for each socket and add it into the current
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4933 event RunLoop so that the current event loop gets quit when
80450
726ad0983c8b [MAC_OSX] (select_and_poll_event, sys_select):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80387
diff changeset
4934 the socket becomes ready. Then mac_run_loop_run_once can
726ad0983c8b [MAC_OSX] (select_and_poll_event, sys_select):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80387
diff changeset
4935 wait for both kinds of inputs.
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4936 4. Otherwise.
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4937 -> Periodically poll the window input channel while repeatedly
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4938 executing `select' with a short timeout
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4939 (SELECT_POLLING_PERIOD_USEC microseconds). */
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4940
72953
4df4a8300599 (SELECT_USE_CFSOCKET) [MAC_OSX]: Set default to 1.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72771
diff changeset
4941 #ifndef SELECT_USE_CFSOCKET
4df4a8300599 (SELECT_USE_CFSOCKET) [MAC_OSX]: Set default to 1.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72771
diff changeset
4942 #define SELECT_USE_CFSOCKET 1
4df4a8300599 (SELECT_USE_CFSOCKET) [MAC_OSX]: Set default to 1.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72771
diff changeset
4943 #endif
4df4a8300599 (SELECT_USE_CFSOCKET) [MAC_OSX]: Set default to 1.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72771
diff changeset
4944
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4945 #define SELECT_POLLING_PERIOD_USEC 100000
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4946 #if SELECT_USE_CFSOCKET
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4947 #define SELECT_TIMEOUT_THRESHOLD_RUNLOOP 0.2
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4948
79509
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
4949 /* Dictionary of file descriptors vs CFSocketRef's allocated in
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
4950 sys_select. */
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
4951 static CFMutableDictionaryRef cfsockets_for_select;
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
4952
79821
ae78ea064d75 (mac_emacs_pid) [MAC_OSX]: New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
4953 /* Process ID of Emacs. */
ae78ea064d75 (mac_emacs_pid) [MAC_OSX]: New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
4954 static pid_t mac_emacs_pid;
ae78ea064d75 (mac_emacs_pid) [MAC_OSX]: New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
4955
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4956 static void
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4957 socket_callback (s, type, address, data, info)
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4958 CFSocketRef s;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4959 CFSocketCallBackType type;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4960 CFDataRef address;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4961 const void *data;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4962 void *info;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4963 {
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4964 }
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4965 #endif /* SELECT_USE_CFSOCKET */
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4966
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4967 static int
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4968 select_and_poll_event (nfds, rfds, wfds, efds, timeout)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4969 int nfds;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4970 SELECT_TYPE *rfds, *wfds, *efds;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4971 EMACS_TIME *timeout;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4972 {
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4973 int timedout_p = 0;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4974 int r = 0;
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4975 EMACS_TIME select_timeout;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4976 EventTimeout timeoutval =
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4977 (timeout
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4978 ? (EMACS_SECS (*timeout) * kEventDurationSecond
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4979 + EMACS_USECS (*timeout) * kEventDurationMicrosecond)
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4980 : kEventDurationForever);
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4981 SELECT_TYPE orfds, owfds, oefds;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4982
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4983 if (timeout == NULL)
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4984 {
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4985 if (rfds) orfds = *rfds;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4986 if (wfds) owfds = *wfds;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4987 if (efds) oefds = *efds;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4988 }
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4989
80450
726ad0983c8b [MAC_OSX] (select_and_poll_event, sys_select):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80387
diff changeset
4990 /* Try detect_input_pending before mac_run_loop_run_once in the same
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4991 BLOCK_INPUT block, in case that some input has already been read
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4992 asynchronously. */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4993 BLOCK_INPUT;
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4994 while (1)
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
4995 {
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4996 if (detect_input_pending ())
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
4997 break;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4998
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
4999 EMACS_SET_SECS_USECS (select_timeout, 0, 0);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5000 r = select (nfds, rfds, wfds, efds, &select_timeout);
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5001 if (r != 0)
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5002 break;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5003
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5004 if (timeoutval == 0.0)
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5005 timedout_p = 1;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5006 else
80450
726ad0983c8b [MAC_OSX] (select_and_poll_event, sys_select):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80387
diff changeset
5007 timedout_p = mac_run_loop_run_once (timeoutval);
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5008
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5009 if (timeout == NULL && timedout_p)
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5010 {
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5011 if (rfds) *rfds = orfds;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5012 if (wfds) *wfds = owfds;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5013 if (efds) *efds = oefds;
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5014 }
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5015 else
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5016 break;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5017 }
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5018 UNBLOCK_INPUT;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5019
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5020 if (r != 0)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5021 return r;
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5022 else if (!timedout_p)
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5023 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5024 /* Pretend that `select' is interrupted by a signal. */
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5025 detect_input_pending ();
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5026 errno = EINTR;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5027 return -1;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5028 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5029 else
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5030 return 0;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5031 }
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5032
79509
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5033 /* Clean up the CFSocket associated with the file descriptor FD in
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5034 case the same descriptor is used in other threads later. If no
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5035 CFSocket is associated with FD, then return 0 without closing FD.
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5036 Otherwise, return 1 with closing FD. */
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5037
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5038 int
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5039 mac_try_close_socket (fd)
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5040 int fd;
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5041 {
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5042 #if SELECT_USE_CFSOCKET
79821
ae78ea064d75 (mac_emacs_pid) [MAC_OSX]: New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
5043 if (getpid () == mac_emacs_pid && cfsockets_for_select)
79509
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5044 {
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5045 void *key = (void *) fd;
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5046 CFSocketRef socket =
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5047 (CFSocketRef) CFDictionaryGetValue (cfsockets_for_select, key);
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5048
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5049 if (socket)
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5050 {
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5051 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5052 CFOptionFlags flags = CFSocketGetSocketFlags (socket);
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5053
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5054 if (!(flags & kCFSocketCloseOnInvalidate))
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5055 CFSocketSetSocketFlags (socket, flags | kCFSocketCloseOnInvalidate);
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5056 #endif
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5057 BLOCK_INPUT;
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5058 CFSocketInvalidate (socket);
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5059 CFDictionaryRemoveValue (cfsockets_for_select, key);
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5060 UNBLOCK_INPUT;
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5061
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5062 return 1;
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5063 }
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5064 }
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5065 #endif
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5066
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5067 return 0;
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5068 }
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5069
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
5070 int
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5071 sys_select (nfds, rfds, wfds, efds, timeout)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5072 int nfds;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5073 SELECT_TYPE *rfds, *wfds, *efds;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5074 EMACS_TIME *timeout;
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
5075 {
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5076 int timedout_p = 0;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5077 int r;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5078 EMACS_TIME select_timeout;
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5079 SELECT_TYPE orfds, owfds, oefds;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5080
56477
59a86f6ee1fb Fixes for Ctrl-G support on carbon, replacing old timeout based polling
Steven Tamm <steventamm@mac.com>
parents: 53122
diff changeset
5081 if (inhibit_window_system || noninteractive
72771
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5082 || nfds < 1 || rfds == NULL || !FD_ISSET (0, rfds))
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5083 return select (nfds, rfds, wfds, efds, timeout);
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5084
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5085 FD_CLR (0, rfds);
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5086 orfds = *rfds;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5087
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5088 if (wfds)
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5089 owfds = *wfds;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5090 else
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5091 FD_ZERO (&owfds);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5092
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5093 if (efds)
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5094 oefds = *efds;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5095 else
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
5096 {
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5097 EventTimeout timeoutval =
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5098 (timeout
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5099 ? (EMACS_SECS (*timeout) * kEventDurationSecond
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5100 + EMACS_USECS (*timeout) * kEventDurationMicrosecond)
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5101 : kEventDurationForever);
56479
45d805d79d29 mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents: 56478
diff changeset
5102
72771
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5103 FD_SET (0, rfds); /* sentinel */
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5104 do
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5105 {
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5106 nfds--;
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5107 }
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5108 while (!(FD_ISSET (nfds, rfds) || (wfds && FD_ISSET (nfds, wfds))));
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5109 nfds++;
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5110 FD_CLR (0, rfds);
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5111
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5112 if (nfds == 1)
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5113 return select_and_poll_event (nfds, rfds, wfds, efds, timeout);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5114
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5115 /* Avoid initial overhead of RunLoop setup for the case that
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5116 some input is already available. */
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5117 EMACS_SET_SECS_USECS (select_timeout, 0, 0);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5118 r = select_and_poll_event (nfds, rfds, wfds, efds, &select_timeout);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5119 if (r != 0 || timeoutval == 0.0)
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5120 return r;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5121
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5122 *rfds = orfds;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5123 if (wfds)
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5124 *wfds = owfds;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5125
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5126 #if SELECT_USE_CFSOCKET
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5127 if (timeoutval > 0 && timeoutval <= SELECT_TIMEOUT_THRESHOLD_RUNLOOP)
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5128 goto poll_periodically;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5129
80450
726ad0983c8b [MAC_OSX] (select_and_poll_event, sys_select):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80387
diff changeset
5130 /* Try detect_input_pending before mac_run_loop_run_once in the
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5131 same BLOCK_INPUT block, in case that some input has already
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5132 been read asynchronously. */
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5133 BLOCK_INPUT;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5134 if (!detect_input_pending ())
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5135 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5136 int minfd, fd;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5137 CFRunLoopRef runloop =
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5138 (CFRunLoopRef) GetCFRunLoopFromEventLoop (GetCurrentEventLoop ());
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5139 static CFMutableDictionaryRef sources;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5140
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5141 if (sources == NULL)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5142 sources =
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5143 CFDictionaryCreateMutable (NULL, 0, NULL,
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5144 &kCFTypeDictionaryValueCallBacks);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5145
79509
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5146 if (cfsockets_for_select == NULL)
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5147 cfsockets_for_select =
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5148 CFDictionaryCreateMutable (NULL, 0, NULL,
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5149 &kCFTypeDictionaryValueCallBacks);
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5150
72771
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5151 for (minfd = 1; ; minfd++) /* nfds-1 works as a sentinel. */
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5152 if (FD_ISSET (minfd, rfds) || (wfds && FD_ISSET (minfd, wfds)))
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5153 break;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5154
72771
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5155 for (fd = minfd; fd < nfds; fd++)
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5156 if (FD_ISSET (fd, rfds) || (wfds && FD_ISSET (fd, wfds)))
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5157 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5158 void *key = (void *) fd;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5159 CFRunLoopSourceRef source =
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5160 (CFRunLoopSourceRef) CFDictionaryGetValue (sources, key);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5161
79509
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5162 if (source == NULL || !CFRunLoopSourceIsValid (source))
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5163 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5164 CFSocketRef socket =
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5165 CFSocketCreateWithNative (NULL, fd,
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5166 (kCFSocketReadCallBack
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5167 | kCFSocketConnectCallBack),
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5168 socket_callback, NULL);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5169
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5170 if (socket == NULL)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5171 continue;
79509
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5172 CFDictionarySetValue (cfsockets_for_select, key, socket);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5173 source = CFSocketCreateRunLoopSource (NULL, socket, 0);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5174 CFRelease (socket);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5175 if (source == NULL)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5176 continue;
79509
e4c75e9b905b (cfsockets_for_select) [MAC_OSX && SELECT_USE_CFSOCKET]:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 78384
diff changeset
5177 CFDictionarySetValue (sources, key, source);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5178 CFRelease (source);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5179 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5180 CFRunLoopAddSource (runloop, source, kCFRunLoopDefaultMode);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5181 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5182
80450
726ad0983c8b [MAC_OSX] (select_and_poll_event, sys_select):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80387
diff changeset
5183 timedout_p = mac_run_loop_run_once (timeoutval);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5184
72771
0bddfbc5a0a5 [MAC_OSX] (sys_select): Check argument `nfds' more
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72704
diff changeset
5185 for (fd = minfd; fd < nfds; fd++)
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5186 if (FD_ISSET (fd, rfds) || (wfds && FD_ISSET (fd, wfds)))
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5187 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5188 void *key = (void *) fd;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5189 CFRunLoopSourceRef source =
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5190 (CFRunLoopSourceRef) CFDictionaryGetValue (sources, key);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5191
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5192 CFRunLoopRemoveSource (runloop, source, kCFRunLoopDefaultMode);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5193 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5194 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5195 UNBLOCK_INPUT;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5196
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5197 if (!timedout_p)
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5198 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5199 EMACS_SET_SECS_USECS (select_timeout, 0, 0);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5200 return select_and_poll_event (nfds, rfds, wfds, efds,
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5201 &select_timeout);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5202 }
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5203 else
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5204 {
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5205 FD_ZERO (rfds);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5206 if (wfds)
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5207 FD_ZERO (wfds);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5208 return 0;
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5209 }
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5210 #endif /* SELECT_USE_CFSOCKET */
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
5211 }
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5212
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5213 poll_periodically:
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5214 {
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5215 EMACS_TIME end_time, now, remaining_time;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5216
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5217 if (timeout)
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5218 {
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5219 remaining_time = *timeout;
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5220 EMACS_GET_TIME (now);
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5221 EMACS_ADD_TIME (end_time, now, remaining_time);
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5222 }
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5223
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5224 do
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5225 {
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5226 EMACS_SET_SECS_USECS (select_timeout, 0, SELECT_POLLING_PERIOD_USEC);
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5227 if (timeout && EMACS_TIME_LT (remaining_time, select_timeout))
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5228 select_timeout = remaining_time;
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5229 r = select_and_poll_event (nfds, rfds, wfds, efds, &select_timeout);
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5230 if (r != 0)
56479
45d805d79d29 mac.c (sys_select): Block input around call to
Steven Tamm <steventamm@mac.com>
parents: 56478
diff changeset
5231 return r;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5232
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5233 *rfds = orfds;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5234 if (wfds)
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5235 *wfds = owfds;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5236 if (efds)
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5237 *efds = oefds;
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5238
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5239 if (timeout)
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5240 {
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5241 EMACS_GET_TIME (now);
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5242 EMACS_SUB_TIME (remaining_time, end_time, now);
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5243 }
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5244 }
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5245 while (!timeout || EMACS_TIME_LT (now, end_time));
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5246
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5247 EMACS_SET_SECS_USECS (select_timeout, 0, 0);
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5248 return select_and_poll_event (nfds, rfds, wfds, efds, &select_timeout);
59146
9bde7721ad0f * dispextern.h: Change HAVE_CARBON to MAC_OS.
Steven Tamm <steventamm@mac.com>
parents: 58752
diff changeset
5249 }
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
5250 }
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
5251
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5252 /* Set up environment variables so that Emacs can correctly find its
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5253 support files when packaged as an application bundle. Directories
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5254 placed in /usr/local/share/emacs/<emacs-version>/, /usr/local/bin,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5255 and /usr/local/libexec/emacs/<emacs-version>/<system-configuration>
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5256 by `make install' by default can instead be placed in
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5257 .../Emacs.app/Contents/Resources/ and
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5258 .../Emacs.app/Contents/MacOS/. Each of these environment variables
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5259 is changed only if it is not already set. Presumably if the user
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5260 sets an environment variable, he will want to use files in his path
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5261 instead of ones in the application bundle. */
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5262 void
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5263 init_mac_osx_environment ()
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5264 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5265 CFBundleRef bundle;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5266 CFURLRef bundleURL;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5267 CFStringRef cf_app_bundle_pathname;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5268 int app_bundle_pathname_len;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5269 char *app_bundle_pathname;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5270 char *p, *q;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5271 struct stat st;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5272
79821
ae78ea064d75 (mac_emacs_pid) [MAC_OSX]: New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
5273 mac_emacs_pid = getpid ();
ae78ea064d75 (mac_emacs_pid) [MAC_OSX]: New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79759
diff changeset
5274
66763
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
5275 /* Initialize locale related variables. */
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
5276 mac_system_script_code =
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
5277 (ScriptCode) GetScriptManagerVariable (smSysScript);
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
5278 Vmac_system_locale = mac_get_system_locale ();
f6840b4933ef [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 66108
diff changeset
5279
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5280 /* Fetch the pathname of the application bundle as a C string into
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5281 app_bundle_pathname. */
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5282
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5283 bundle = CFBundleGetMainBundle ();
64604
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
5284 if (!bundle || CFBundleGetIdentifier (bundle) == NULL)
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
5285 {
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
5286 /* We could not find the bundle identifier. For now, prevent
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
5287 the fatal error by bringing it up in the terminal. */
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
5288 inhibit_window_system = 1;
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
5289 return;
b9746f88defa Don't include stdlib.h or string.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64553
diff changeset
5290 }
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5291
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5292 bundleURL = CFBundleCopyBundleURL (bundle);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5293 if (!bundleURL)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5294 return;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5295
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5296 cf_app_bundle_pathname = CFURLCopyFileSystemPath (bundleURL,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5297 kCFURLPOSIXPathStyle);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5298 app_bundle_pathname_len = CFStringGetLength (cf_app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5299 app_bundle_pathname = (char *) alloca (app_bundle_pathname_len + 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5300
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5301 if (!CFStringGetCString (cf_app_bundle_pathname,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5302 app_bundle_pathname,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5303 app_bundle_pathname_len + 1,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5304 kCFStringEncodingISOLatin1))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5305 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5306 CFRelease (cf_app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5307 return;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5308 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5309
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5310 CFRelease (cf_app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5311
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5312 /* P should have sufficient room for the pathname of the bundle plus
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5313 the subpath in it leading to the respective directories. Q
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5314 should have three times that much room because EMACSLOADPATH can
78384
ccca2e6b8cd9 Adjust load-path comment
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 78383
diff changeset
5315 have the value "<path to site-lisp dir>:<path to lisp dir>:<path
ccca2e6b8cd9 Adjust load-path comment
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 78383
diff changeset
5316 to leim dir>". */
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5317 p = (char *) alloca (app_bundle_pathname_len + 50);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5318 q = (char *) alloca (3 * app_bundle_pathname_len + 150);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5319 if (!getenv ("EMACSLOADPATH"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5320 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5321 q[0] = '\0';
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5322
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5323 strcpy (p, app_bundle_pathname);
78383
f97cdcfcf9ee Adjust load-path
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 78260
diff changeset
5324 strcat (p, "/Contents/Resources/site-lisp");
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5325 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5326 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5327
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5328 strcpy (p, app_bundle_pathname);
78383
f97cdcfcf9ee Adjust load-path
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 78260
diff changeset
5329 strcat (p, "/Contents/Resources/lisp");
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5330 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5331 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5332 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5333 strcat (q, ":");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5334 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5335 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5336
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5337 strcpy (p, app_bundle_pathname);
78383
f97cdcfcf9ee Adjust load-path
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents: 78260
diff changeset
5338 strcat (p, "/Contents/Resources/leim");
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5339 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5340 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5341 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5342 strcat (q, ":");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5343 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5344 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5345
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5346 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5347 setenv ("EMACSLOADPATH", q, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5348 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5349
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5350 if (!getenv ("EMACSPATH"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5351 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5352 q[0] = '\0';
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5353
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5354 strcpy (p, app_bundle_pathname);
50490
52dcc63018da mac.c (init_mac_osx_environment): Switch libexec and bin so that self-
Steven Tamm <steventamm@mac.com>
parents: 49600
diff changeset
5355 strcat (p, "/Contents/MacOS/libexec");
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5356 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5357 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5358
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5359 strcpy (p, app_bundle_pathname);
50490
52dcc63018da mac.c (init_mac_osx_environment): Switch libexec and bin so that self-
Steven Tamm <steventamm@mac.com>
parents: 49600
diff changeset
5360 strcat (p, "/Contents/MacOS/bin");
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5361 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5362 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5363 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5364 strcat (q, ":");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5365 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5366 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5367
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5368 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5369 setenv ("EMACSPATH", q, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5370 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5371
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5372 if (!getenv ("EMACSDATA"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5373 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5374 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5375 strcat (p, "/Contents/Resources/etc");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5376 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5377 setenv ("EMACSDATA", p, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5378 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5379
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5380 if (!getenv ("EMACSDOC"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5381 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5382 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5383 strcat (p, "/Contents/Resources/etc");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5384 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5385 setenv ("EMACSDOC", p, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5386 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5387
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5388 if (!getenv ("INFOPATH"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5389 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5390 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5391 strcat (p, "/Contents/Resources/info");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5392 if (stat (p, &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5393 setenv ("INFOPATH", p, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5394 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
5395 }
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
5396 #endif /* MAC_OSX */
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5397
74626
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5398 #if TARGET_API_MAC_CARBON
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5399 void
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5400 mac_wakeup_from_rne ()
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5401 {
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5402 #ifndef MAC_OSX
74626
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5403 if (wakeup_from_rne_enabled_p)
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5404 /* Post a harmless event so as to wake up from
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5405 ReceiveNextEvent. */
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5406 mac_post_mouse_moved_event ();
80387
3fdc60eb4014 (xrm_get_preference_database): Remove BLOCK_INPUT.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 79821
diff changeset
5407 #endif
74626
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5408 }
04ef1ad19c59 (wakeup_from_rne_enabled_p) [TARGET_API_MAC_CARBON]: New
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73571
diff changeset
5409 #endif
61553
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5410
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5411 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5412 syms_of_mac ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5413 {
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
5414 Qundecoded_file_name = intern ("undecoded-file-name");
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
5415 staticpro (&Qundecoded_file_name);
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
5416
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5417 #if TARGET_API_MAC_CARBON
61338
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
5418 Qstring = intern ("string"); staticpro (&Qstring);
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
5419 Qnumber = intern ("number"); staticpro (&Qnumber);
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
5420 Qboolean = intern ("boolean"); staticpro (&Qboolean);
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
5421 Qdate = intern ("date"); staticpro (&Qdate);
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
5422 Qdata = intern ("data"); staticpro (&Qdata);
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
5423 Qarray = intern ("array"); staticpro (&Qarray);
b44917251d3a (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60660
diff changeset
5424 Qdictionary = intern ("dictionary"); staticpro (&Qdictionary);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5425
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5426 Qxml = intern ("xml");
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5427 staticpro (&Qxml);
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5428
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5429 Qmime_charset = intern ("mime-charset");
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5430 staticpro (&Qmime_charset);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5431
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5432 QNFD = intern ("NFD"); staticpro (&QNFD);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5433 QNFKD = intern ("NFKD"); staticpro (&QNFKD);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5434 QNFC = intern ("NFC"); staticpro (&QNFC);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5435 QNFKC = intern ("NFKC"); staticpro (&QNFKC);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5436 QHFS_plus_D = intern ("HFS+D"); staticpro (&QHFS_plus_D);
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5437 QHFS_plus_C = intern ("HFS+C"); staticpro (&QHFS_plus_C);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5438 #endif
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5439
70871
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5440 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5441 int i;
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5442
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5443 for (i = 0; i < sizeof (ae_attr_table) / sizeof (ae_attr_table[0]); i++)
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5444 {
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5445 ae_attr_table[i].symbol = intern (ae_attr_table[i].name);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5446 staticpro (&ae_attr_table[i].symbol);
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5447 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5448 }
815f914dcf9b (ae_attr_table): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70492
diff changeset
5449
67456
2efa50cbb7cd (Qundecoded_file_name): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67088
diff changeset
5450 defsubr (&Smac_coerce_ae_data);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5451 #if TARGET_API_MAC_CARBON
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5452 defsubr (&Smac_get_preference);
61785
6e608d2306b0 [!TARGET_API_MAC_CARBON]: Don't include charset.h or coding.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61572
diff changeset
5453 defsubr (&Smac_code_convert_string);
72704
49fb9398679c [!MAC_OSX] Don't include keyboard.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72542
diff changeset
5454 defsubr (&Smac_process_hi_command);
60632
fa8be36e244d Include macterm.h instead of directly including Carbon.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 60360
diff changeset
5455 #endif
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5456
64214
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
5457 defsubr (&Smac_set_file_creator);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
5458 defsubr (&Smac_set_file_type);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
5459 defsubr (&Smac_get_file_creator);
0441edbff1bf Adding in functions for setting and retrieving file type info
Steven Tamm <steventamm@mac.com>
parents: 64084
diff changeset
5460 defsubr (&Smac_get_file_type);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5461 defsubr (&Sdo_applescript);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5462 defsubr (&Smac_file_name_to_posix);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5463 defsubr (&Sposix_file_name_to_mac);
61553
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5464
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5465 DEFVAR_INT ("mac-system-script-code", &mac_system_script_code,
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5466 doc: /* The system script code. */);
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5467 mac_system_script_code = (ScriptCode) GetScriptManagerVariable (smSysScript);
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5468
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5469 DEFVAR_LISP ("mac-system-locale", &Vmac_system_locale,
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5470 doc: /* The system locale identifier string.
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5471 This is not a POSIX locale ID, but an ICU locale ID. So encoding
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5472 information is not included. */);
72c95a1c84c6 [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't include
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61338
diff changeset
5473 Vmac_system_locale = mac_get_system_locale ();
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
5474 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50490
diff changeset
5475
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50490
diff changeset
5476 /* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50490
diff changeset
5477 (do not change this comment) */