annotate src/mac.c @ 56230:fe184d71d3cb

(Unconditional Replace): Use replace-string instead of query-replace in example. (Regexp Replace): Add explanations for `\,', `\#' and `\?' sequences. (Query Replace): Correct explanation of `^' which does not use the mark stack.
author David Kastrup <dak@gnu.org>
date Thu, 24 Jun 2004 14:05:59 +0000
parents 5544010b4c66
children 59a86f6ee1fb
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.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
4 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
5
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
9 any later version.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
10
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
11 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
12 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
13 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
14 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
15
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
20
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
21 /* 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
22
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
23 #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
24
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
25 #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
26 #include <errno.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
27 #include <utime.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
28 #include <dirent.h>
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
29 #include <sys/types.h>
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
30 #include <sys/stat.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
31 #include <string.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
32 #include <pwd.h>
53122
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
33 #include <grp.h>
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
34 #include <sys/param.h>
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
35 #include <stdlib.h>
48787
0360bdd5a70b Fixed OSX sys_read to not call select if IO is non-blocking
Steven Tamm <steventamm@mac.com>
parents: 48740
diff changeset
36 #include <fcntl.h>
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
37 #if __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
38 #include <unistd.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
39 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
40
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
41 #ifdef MAC_OSX
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
42 #undef mktime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
43 #undef DEBUG
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
44 #undef free
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
45 #undef malloc
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
46 #undef realloc
45848
39cdf9669519 In src/:
Andrew Choi <akochoi@shaw.ca>
parents: 45141
diff changeset
47 #undef init_process
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
48 #include <Carbon/Carbon.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
49 #undef free
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
50 #define free unexec_free
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
51 #undef malloc
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
52 #define malloc unexec_malloc
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
53 #undef realloc
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
54 #define realloc unexec_realloc
45848
39cdf9669519 In src/:
Andrew Choi <akochoi@shaw.ca>
parents: 45141
diff changeset
55 #undef init_process
39cdf9669519 In src/:
Andrew Choi <akochoi@shaw.ca>
parents: 45141
diff changeset
56 #define init_process emacs_init_process
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
57 #else /* not MAC_OSX */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
58 #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
59 #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
60 #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
61 #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
62 #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
63 #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
64 #include <FixMath.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
65 #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
66 #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
67 #include <AppleScript.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
68 #include <Scrap.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
69 #endif /* not MAC_OSX */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
70
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
71 #include "lisp.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
72 #include "process.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
73 #include "sysselect.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
74 #include "systime.h"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
75
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
76 Lisp_Object QCLIPBOARD;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
77
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
78 /* 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
79 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
80 /* 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
81 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
82
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
83
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
84 /* 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
85 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
86 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
87 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
88
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
89 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
90 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
91 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
92 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
93 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
94 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
95 int i;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
96
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
97 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
98 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
99 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
100 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
101 *p = b;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
102 p++;
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 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
105
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
106
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
107 /* 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
108 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
109 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
110 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
111 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
112 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
113 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
114 Returns 1 if successful; 0 if fails. */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
115
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
116 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
117 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
118 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
119 const char *p, *q, *pe;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
120
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
121 strcpy (ufn, "");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
122
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
123 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
124 return 1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
125
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
126 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
127 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
128 strcat (ufn, "/");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
129
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
130 p = mfn;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
131 if (*p == ':')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
132 p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
133
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
134 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
135 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
136 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
137 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
138 if (q)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
139 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
140 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
141 { /* two consecutive ':' */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
142 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
143 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
144 strcat (ufn, "../");
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 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
147 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
148 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
149 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
150 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
151 strcat (ufn, "/");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
152 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
153 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
154 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
155 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
156 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
157 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
158 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
159 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
160 /* 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
161 p = pe;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
162 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
163 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
164
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
165 return 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
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 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
170
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
171
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
172 /* 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
173 above in algorithm. */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
174
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
175 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
176 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
177 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
178 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
179 char expanded_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
180
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
181 strcpy (mfn, "");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
182
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
183 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
184 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
185
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
186 p = ufn;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
187
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
188 /* 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
189 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
190 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
191 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
192 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
193 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
194 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
195 strcat (mfn, ":");
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
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
199 /* 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
200 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
201 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
202 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
203 p += 7;
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 (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
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 (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
207 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
208 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
209 /* 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
210 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
211 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
212 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
213 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
214 p += 5;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
215 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
216 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
217 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
218 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
219 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
220 /* 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
221 }
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
222 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
223 strcat (mfn, ":");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
224
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
225 if (*p == '/')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
226 p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
227
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
228 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
229 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
230 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
231 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
232 if (q)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
233 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
234 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
235 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
236 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
237 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
238 strcat (mfn, ":");
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 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
241 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
242 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
243 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
244 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
245 strcat (mfn, ":");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
246 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
247 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
248 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
249 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
250 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
251 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
252 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
253 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
254 p = pe;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
255 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
256 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
257
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
258 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
259 }
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 #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
262
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
263 /* 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
264 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
265 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
266 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
267 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
268
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
269
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
270 /* 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
271 + 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
272 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
273
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
274 #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
275
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
276 #ifdef __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
277 #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
278 /* 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
279 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
280 functions. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
281 #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
282 #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
283 /* 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
284 #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
285 #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
286 #elif __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
287 /* 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
288 #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
289 #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
290 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
291 #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
292
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
293
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
294 /* 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
295 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
296 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
297 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
298 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
299 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
300
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
301 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
302 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
303 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
304 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
305 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
306
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
307 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
308 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
309
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
310 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
311 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
312 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
313 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
314 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
315 /* 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
316
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
317 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
318 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
319 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
320 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
321 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
322
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
323 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
324 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
325 buf->st_mode = S_IFDIR | S_IREAD | S_IEXEC;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
326
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
327 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
328 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
329 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
330 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
331 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
332 /* 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
333 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
334 = 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
335 = 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
336 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
337 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
338 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
339 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 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
349 = 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
350 = 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
351 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
352 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
353
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
354 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
355 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
356 /* 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
357 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
358 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
359 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
360
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
361 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
362 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
363 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
364 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
365
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
366 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
367 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
368
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
369
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
370 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
371 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
372 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
373 int result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
374 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
375
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
376 /* 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
377 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
378 return result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
379
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
380 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
381 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
382
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
383 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
384 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
385
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
386
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
387 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
388 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
389 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
390 int result;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
391 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
392 int len;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
393
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
394 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
395 ! (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
396 return result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
397
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
398 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
399 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
400
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
401 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
402 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
403 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
404 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
405 /* 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
406 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
407 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
408 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
409 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
410 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
411
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
412
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
413 #if __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
414 /* 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
415 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
416 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
417 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
418 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
419 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
420 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
421 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
422 improvement. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
423
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
424 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
425 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
426 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
427 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
428 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
429 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
430 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
431 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
432 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
433
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
434
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
435 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
436 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
437 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
438 #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
439
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
440 HFileParam hfpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
441 char true_pathname[MAXPATHLEN+1], mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
442
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
443 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
444 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
445
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
446 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
447 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
448
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
449 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
450 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
451 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
452 hfpb.ioDirID = 0; /* parent is the root */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
453
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
454 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
455 /* 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
456 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
457 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
458
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
459
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
460 #undef rmdir
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
461 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
462 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
463 HFileParam hfpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
464 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
465
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
466 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
467 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
468
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
469 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
470 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
471 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
472 hfpb.ioDirID = 0; /* parent is the root */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
473
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
474 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
475 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
476 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
477
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
478
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
479 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
480 /* 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
481 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
482 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
483 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
484 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
485 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
486 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
487
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
488
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
489 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
490 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
491 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
492 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
493 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
494 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
495 CInfoPBRec cipb;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
496
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
497 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
498 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
499
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
500 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
501 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
502 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
503 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
504 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
505
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
506 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
507 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
508
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
509 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
510 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
511 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
512 cipb.hFileInfo.ioDirID = 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
513 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
514 /* 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
515
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
516 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
517 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
518 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
519
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
520 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
521 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
522 if (times)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
523 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
524 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
525 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
526 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
527 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
528 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
529 if (times)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
530 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
531 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
532 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
533 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
534
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
535 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
536 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
537 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
538
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
539
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
540 #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
541 #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
542 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
543 #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
544 #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
545 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
546 #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
547 #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
548 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
549
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
550 /* 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
551 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
552 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
553 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
554 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
555 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
556 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
557 CInfoPBRec cipb;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
558
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
559 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
560 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
561
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
562 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
563 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
564 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
565 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
566 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
567
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
568 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
569 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
570
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
571 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
572 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
573 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
574 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
575 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
576 /* 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
577
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
578 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
579 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
580 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
581
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
582 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
583 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
584
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
585 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
586 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
587 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
588 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
589 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
590 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
591 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
592 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
593 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
594 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
595
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
596 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
597 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
598 /* 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
599
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
600 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
601 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
602
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
603
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
604 #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
605
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
606 #undef open
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
607 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
608 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
609 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
610 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
611 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
612 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
613
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
614 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
615 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
616
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
617 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
618 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
619
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
620 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
621 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
622 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
623 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
624 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
625
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
626 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
627 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
628 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
629 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
630 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
631 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
632 /* 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
633 if (oflag & O_CREAT)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
634 fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
635 return res;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
636 #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
637 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
638 #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
639 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
640 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
641
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
642
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
643 #undef creat
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
644 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
645 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
646 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
647 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
648 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
649 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
650
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
651 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
652 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
653
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
654 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
655 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
656 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
657 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
658 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
659 int result = creat (mac_pathname);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
660 fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
661 return result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
662 #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
663 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
664 #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
665 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
666 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
667
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
668
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
669 #undef unlink
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
670 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
671 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
672 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
673 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
674 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
675 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
676
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
677 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
678 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
679
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
680 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
681 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
682 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
683 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
684 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
685
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
686 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
687 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
688 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
689 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
690 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
691
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
692
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
693 #undef read
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
694 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
695 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
696 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
697 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
698 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
699 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
700 #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
701 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
702 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
703 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
704 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
705 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
706
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
707
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
708 #undef write
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
709 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
710 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
711 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
712 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
713 return count;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
714 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
715 #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
716 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
717 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
718 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
719 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
720 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
721
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
722
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
723 #undef rename
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
724 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
725 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
726 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
727 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
728 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
729 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
730 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
731
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
732 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
733 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
734
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
735 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
736 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
737 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
738 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
739 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
740
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
741 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
742 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
743
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
744 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
745 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
746
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
747 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
748 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
749 MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
750 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
751
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
752 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
753 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
754
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
755 /* 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
756 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
757 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
758 (void) unlink (mac_new_name);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
759
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
760 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
761 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
762
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
763
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
764 #undef fopen
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
765 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
766 FILE *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
767 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
768 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
769 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
770 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
771 char mac_pathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
772
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
773 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
774 return 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
775
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
776 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
777 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
778 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
779 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
780 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
781
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
782 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
783 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
784 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
785 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
786 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
787 if (mode[0] == 'w' || mode[0] == 'a')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
788 fsetfileinfo (mac_pathname, 'EMAx', 'TEXT');
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
789 #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
790 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
791 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
792 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
793
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
794
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
795 #include <Events.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
796
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
797 long target_ticks = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
798
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
799 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
800 __sigfun alarm_signal_func = (__sigfun) 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
801 #elif __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
802 __signal_func_ptr alarm_signal_func = (__signal_func_ptr) 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
803 #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
804 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
805 #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
806
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
807
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
808 /* These functions simulate SIG_ALRM. The stub for function signal
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
809 stores the signal handler function in alarm_signal_func if a
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
810 SIG_ALRM is encountered. check_alarm is called in XTread_socket,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
811 which emacs calls periodically. A pending alarm is represented by
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
812 a non-zero target_ticks value. check_alarm calls the handler
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
813 function pointed to by alarm_signal_func if one has been set up and
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
814 an alarm is pending. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
815
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
816 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
817 check_alarm ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
818 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
819 if (target_ticks && TickCount () > target_ticks)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
820 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
821 target_ticks = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
822 if (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
823 (*alarm_signal_func)(SIGALRM);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
824 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
825 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
826
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
827
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
828 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
829 select (n, rfds, wfds, efds, timeout)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
830 int n;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
831 SELECT_TYPE *rfds;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
832 SELECT_TYPE *wfds;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
833 SELECT_TYPE *efds;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
834 struct timeval *timeout;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
835 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
836 #ifdef 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
837 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
838 #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
839 EMACS_TIME end_time, now;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
840 EventRecord e;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
841
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
842 /* Can only handle wait for keyboard input. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
843 if (n > 1 || wfds || efds)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
844 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
845
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
846 EMACS_GET_TIME (end_time);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
847 EMACS_ADD_TIME (end_time, end_time, *timeout);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
848
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
849 do
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
850 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
851 /* Also return true if an event other than a keyDown has
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
852 occurred. This causes kbd_buffer_get_event in keyboard.c to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
853 call read_avail_input which in turn calls XTread_socket to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
854 poll for these events. Otherwise these never get processed
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
855 except but a very slow poll timer. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
856 if (FD_ISSET (0, rfds) && EventAvail (everyEvent, &e))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
857 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
858
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
859 /* Also check movement of the mouse. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
860 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
861 Point mouse_pos;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
862 static Point old_mouse_pos = {-1, -1};
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
863
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
864 GetMouse (&mouse_pos);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
865 if (!EqualPt (mouse_pos, old_mouse_pos))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
866 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
867 old_mouse_pos = mouse_pos;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
868 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
869 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
870 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
871
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
872 WaitNextEvent (0, &e, 1UL, NULL); /* Accept no event; wait 1
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
873 tic. by T.I. */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
874
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
875 EMACS_GET_TIME (now);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
876 EMACS_SUB_TIME (now, end_time, now);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
877 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
878 while (!EMACS_TIME_NEG_P (now));
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
879
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
880 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
881 #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
882 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
883
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
884
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
885 /* Called in sys_select to wait for an alarm signal to arrive. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
886
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
887 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
888 pause ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
889 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
890 EventRecord e;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
891 unsigned long tick;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
892
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
893 if (!target_ticks) /* no alarm pending */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
894 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
895
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
896 if ((tick = TickCount ()) < target_ticks)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
897 WaitNextEvent (0, &e, target_ticks - tick, NULL); /* Accept no event;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
898 just wait. by T.I. */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
899
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
900 target_ticks = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
901 if (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
902 (*alarm_signal_func)(SIGALRM);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
903
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
904 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
905 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
906
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
907
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
908 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
909 alarm (int seconds)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
910 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
911 long remaining = target_ticks ? (TickCount () - target_ticks) / 60 : 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
912
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
913 target_ticks = seconds ? TickCount () + 60 * seconds : 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
914
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
915 return (remaining < 0) ? 0 : (unsigned int) remaining;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
916 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
917
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
918
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
919 #undef signal
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
920 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
921 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
922 __sigfun
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
923 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
924 #elif __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
925 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
926 __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
927 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
928 #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
929 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
930 #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
931 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
932 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
933 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
934 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
935 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
936 #ifdef __MRC__
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
937 __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
938 #elif __MWERKS__
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
939 __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
940 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
941 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
942 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
943 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
944 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
945 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
946 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
947 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
948
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
949
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
950 /* 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
951 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
952 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
953 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
954 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
955
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
956 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
957 gettimeofday (tp)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
958 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
959 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
960 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
961 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
962 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
963 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
964 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
965
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
966 /* 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
967 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
968 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
969 if (!inited)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
970 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
971 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
972 inited = 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
973 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
974 /* 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
975 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
976 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
977 /* 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
978 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
979 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
980 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
981
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
982 /* 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
983 Microseconds (&uw_microseconds);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
984
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
985 /* 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
986 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
987 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
988 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
989 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
990 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
991
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
992 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
993 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
994
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
995
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
996 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
997 unsigned int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
998 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
999 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1000 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
1001 EventRecord e;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1002
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1003 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
1004 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
1005 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1006 /* 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
1007 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
1008 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1009
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1010 return (0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1011 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1012 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1013
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1014
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1015 /* 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
1016 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
1017
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1018 #undef gmtime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1019 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
1020 struct tm *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1021 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
1022 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1023 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
1024
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1025 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
1026 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1027
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1028
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1029 #undef localtime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1030 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
1031 struct tm *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1032 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
1033 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1034 #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
1035 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
1036 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1037 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
1038 #endif
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1039
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1040 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
1041 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1042
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1043
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1044 #undef ctime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1045 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
1046 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1047 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
1048 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1049 #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
1050 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
1051 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1052 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
1053 #endif
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1054
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1055 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
1056 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1057
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1058
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1059 #undef time
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1060 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
1061 time_t
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1062 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
1063 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1064 #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
1065 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
1066 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1067 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
1068 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1069
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1070 if (timer)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1071 *timer = mac_time;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1072
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1073 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
1074 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1075
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1076
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1077 /* MPW strftime broken for "%p" format */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1078 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1079 #undef strftime
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1080 #include <time.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1081 size_t
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1082 sys_strftime (char * s, size_t maxsize, const char * format,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1083 const struct tm * timeptr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1084 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1085 if (strcmp (format, "%p") == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1086 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1087 if (maxsize < 3)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1088 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1089 if (timeptr->tm_hour < 12)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1090 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1091 strcpy (s, "AM");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1092 return 2;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1093 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1094 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1095 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1096 strcpy (s, "PM");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1097 return 2;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1098 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1099 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1100 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1101 return strftime (s, maxsize, format, timeptr);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1102 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1103 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1104
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1105
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1106 /* 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
1107
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1108 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1109 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
1110 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1111 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1112 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1113
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1114
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1115 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1116 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
1117 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1118 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
1119 exit (1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1120 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1121
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1122
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1123 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1124 index (const char * str, int chr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1125 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1126 return strchr (str, chr);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1127 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1128
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1129
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1130 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1131 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
1132 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1133 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
1134 static seqnum = 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1135
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1136 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
1137 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
1138 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
1139 k--;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1140
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1141 k++; /* make k index of first 'X' */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1142
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1143 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
1144 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1145 /* 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
1146 sprintf (&template[k], "%0*d", len-k, seqnum++);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1147
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1148 return template;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1149 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1150 else
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1151 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
1152 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1153
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1154
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1155 /* 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
1156
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1157 #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
1158
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1159 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
1160 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
1161
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1162 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
1163 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1164 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
1165 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
1166 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1167
53122
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1168 static struct group my_group =
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1169 {
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1170 /* 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
1171 group name. */
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1172 "root",
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1173 };
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1174
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1175
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1176 /* 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
1177
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1178 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
1179
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1180 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1181 getwd (char *);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1182
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1183 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1184 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
1185 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1186 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
1187
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1188 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
1189 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1190 /* 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
1191 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
1192 tree. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1193 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
1194 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
1195 /* 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
1196 compared. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1197 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
1198 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
1199 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1200 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
1201 i--;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1202 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
1203 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
1204 if (found)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1205 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
1206 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1207 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1208 j = i;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1209 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
1210 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1211 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1212 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1213
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1214 if (!found)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1215 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1216 /* 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
1217 anyway. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1218 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
1219 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
1220 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1221 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1222
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1223
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1224 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
1225 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1226 "emacs",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1227 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
1228 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1229
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1230 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
1231
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1232
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1233 static void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1234 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
1235 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1236 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
1237
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1238 /* 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
1239 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
1240
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1241 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
1242 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
1243 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1244 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
1245 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
1246 (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
1247 *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
1248 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
1249 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
1250 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1251 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1252 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
1253 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1254
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1255
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1256 struct passwd *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1257 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
1258 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1259 if (!my_passwd_inited)
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1260 {
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1261 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
1262 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
1263 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1264
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1265 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
1266 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1267
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1268
53122
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1269 struct group *
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1270 getgrgid (gid_t gid)
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1271 {
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1272 return &my_group;
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1273 }
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1274
5544010b4c66 (struct my_group): Added.
Lars Hansen <larsh@soem.dk>
parents: 52401
diff changeset
1275
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1276 struct passwd *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1277 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
1278 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1279 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
1280 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
1281
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1282 if (!my_passwd_inited)
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1283 {
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1284 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
1285 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
1286 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1287
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1288 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
1289 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1290
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1291
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1292 /* 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
1293 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
1294 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
1295
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1296
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1297 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1298 fork ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1299 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1300 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1301 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1302
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1303
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1304 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1305 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
1306 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1307 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1308 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1309
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1310
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1311 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1312 sys_subshell ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1313 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1314 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
1315 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1316
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1317
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1318 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1319 sigsetmask (int x)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1320 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1321 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1322 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1323
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1324
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1325 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1326 sigblock (int mask)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1327 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1328 return 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1329 }
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1330
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1331
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1332 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1333 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
1334 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1335 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1336
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1337
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1338 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1339 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
1340 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1341 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1342
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1343
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1344 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1345 setpgrp ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1346 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1347 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1348 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1349
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1350
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1351 /* 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
1352
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1353 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1354 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
1355 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1356 errno = EACCES;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1357 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1358 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1359
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1360
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1361 /* 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
1362
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1363 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1364 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
1365 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1366 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1367 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1368 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1369
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1370
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1371 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1372 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
1373 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1374 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1375 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1376 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1377
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1378 #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
1379
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1380 /* 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
1381 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
1382 MAXPATHLEN. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1383 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1384 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
1385 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
1386 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1387 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
1388 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1389 OSErr err;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1390
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1391 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
1392 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1393
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1394 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
1395 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
1396 p2cstr (path);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1397
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1398 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
1399 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
1400
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1401 do
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1402 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1403 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
1404 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
1405 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
1406 /* 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
1407
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1408 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
1409 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
1410 return 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1411
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1412 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
1413 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
1414 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1415
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1416 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
1417 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
1418 /* 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
1419 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
1420 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1421 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
1422 /* stop when we see the volume's root directory */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1423
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1424 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
1425 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1426
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1427 #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
1428
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1429 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1430 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
1431 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1432 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
1433 OSErr err;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1434 FSSpec fsspec;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1435 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
1436 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
1437 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1438
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1439 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
1440 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1441
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1442 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
1443 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
1444 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
1445 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1446 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1447 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1448 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1449
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1450 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
1451 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
1452 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1453 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1454 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1455 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1456
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1457 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
1458 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
1459 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1460 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1461 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1462 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1463
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1464 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
1465 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1466 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1467 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1468 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1469
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1470 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
1471 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1472
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1473
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1474 /* 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
1475
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1476 static int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1477 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
1478 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1479 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
1480 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
1481 int len;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1482
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1483 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
1484 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1485
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1486 buf[0] = '\0';
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1487
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1488 p = path;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1489 if (*p == '/')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1490 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
1491 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1492 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
1493 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
1494
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1495 while (q)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1496 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1497 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
1498 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
1499 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
1500 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
1501 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1502 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
1503 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1504 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
1505 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1506 strcat (buf, "/");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1507 len++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1508 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
1509 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
1510 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1511
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1512 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
1513 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1514
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1515 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
1516 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
1517 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1518
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1519
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1520 mode_t
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1521 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
1522 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1523 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
1524 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
1525 mask = numask;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1526 return oldmask;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1527 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1528
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1529
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1530 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1531 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
1532 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1533 /* 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
1534 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1535 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1536
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1537
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1538 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1539 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
1540 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1541 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1542 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
1543 #elif __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1544 /* 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
1545 descriptor */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1546 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
1547 #else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1548 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1549 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1550 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1551
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1552
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1553 /* 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
1554 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
1555 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
1556 unsuccessful ones. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1557
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1558 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1559 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
1560 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1561 int fd, ret;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1562
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1563 close (newd);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1564
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1565 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
1566 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
1567 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1568 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
1569 return newd;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1570 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
1571 close (fd);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1572 return ret;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1573 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1574
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1575
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1576 /* 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
1577
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1578 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1579 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
1580 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1581 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
1582 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1583
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1584
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1585 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1586 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
1587 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1588 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1589 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1590
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1591
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1592 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1593 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
1594 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1595 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1596 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1597
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1598
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1599 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1600 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1601 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
1602 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1603 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
1604 return 1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1605 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1606 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1607 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1608
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1609
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1610 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1611 getgid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1612 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1613 return 100;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1614 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1615
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1616
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1617 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1618 getegid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1619 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1620 return 100;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1621 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1622
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1623
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1624 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1625 getuid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1626 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1627 return 200;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1628 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1629
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1630
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1631 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1632 geteuid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1633 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1634 return 200;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1635 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1636 #endif /* __MRC__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1637
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1638
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1639 #ifdef __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1640 #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
1641 #undef getpid
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1642 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1643 getpid ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1644 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1645 return 9999;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1646 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1647 #endif
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1648 #endif /* __MWERKS__ */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1649
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1650 #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
1651
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1652
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1653 /* 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
1654 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
1655 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
1656 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
1657 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
1658 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
1659 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
1660 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
1661
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1662 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1663 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
1664 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1665 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
1666 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
1667 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
1668 OSErr err;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1669 Str255 dir_name, full_path;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1670 CInfoPBRec cpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1671 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
1672 DIR *dir;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1673
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1674 /* 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
1675 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
1676 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
1677 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1678 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
1679 &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
1680 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
1681 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1682
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1683 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
1684 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1685
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1686 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
1687 strcat (full_path, "Emacs:");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1688 else
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1689 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1690
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1691 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
1692 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1693
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1694 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
1695 if (dir)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1696 closedir (dir);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1697 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
1698 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1699
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1700 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
1701 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
1702 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1703
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1704 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
1705 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1706
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1707 #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
1708
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1709 /* 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
1710 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
1711 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
1712 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
1713 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
1714 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
1715 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
1716 parameter StringListID.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1717 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1718
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1719 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1720 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
1721 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1722 Handle h;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1723 Ptr p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1724 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
1725
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1726 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
1727 if (h)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1728 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1729 HLock (h);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1730 p = *h;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1731 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
1732 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
1733 *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
1734 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
1735 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1736 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
1737 (*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
1738 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
1739 (*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
1740 p += length;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1741 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1742 (*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
1743 HUnlock (h);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1744 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1745 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1746 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1747 /* 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
1748 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
1749 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
1750 *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
1751 (*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
1752 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1753 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1754
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1755
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1756 static char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1757 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
1758 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1759 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
1760 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
1761 OSErr err;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1762 Str255 dir_name, full_path;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1763 CInfoPBRec cpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1764 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
1765 DIR *dir;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1766
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1767 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
1768 &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
1769 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
1770 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1771
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1772 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
1773 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1774
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1775 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
1776 MAXPATHLEN+1))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1777 return NULL;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1778
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1779 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
1780 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1781
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1782
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1783 char **environ;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1784
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1785 #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
1786
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1787 /* 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
1788
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1789 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1790 init_environ ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1791 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1792 int i;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1793
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1794 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
1795
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1796 i = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1797 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
1798 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1799
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1800 /* 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
1801 by resource. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1802 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
1803 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1804 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
1805 if (environ)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1806 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1807 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
1808 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
1809 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1810 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
1811 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
1812 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1813 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
1814 i++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1815 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1816 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1817
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1818 /* 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
1819 by resource. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1820 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
1821 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1822 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
1823 if (environ)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1824 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1825 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
1826 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
1827 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
1828 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1829 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
1830 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
1831 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
1832 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1833 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
1834 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1835 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1836 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1837
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1838
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1839 /* 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
1840
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1841 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1842 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
1843 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1844 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
1845 char **e;
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 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
1848 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
1849 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
1850
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1851 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
1852 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
1853
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1854 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1855 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1856
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1857
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1858 #ifdef __MRC__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1859 /* 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
1860 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
1861 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1862 "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
1863 "Abort", /* 1 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1864 "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
1865 "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
1866 "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
1867 "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
1868 "?", "?", "?", "?", "?", "?", "?", "?",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1869 "Terminal" /* 32 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1870 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1871 #elif __MWERKS__
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1872 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
1873 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1874 "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
1875 "Abort",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1876 "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
1877 "Illegal instruction",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1878 "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
1879 "Segment violation",
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1880 "Terminal"
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1881 };
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1882 #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
1883 You lose!!!
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1884 #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
1885
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1886
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1887 #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
1888
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1889 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1890 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
1891 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1892 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
1893 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
1894 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
1895 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1896 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
1897 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
1898 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1899 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1900 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1901 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1902 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1903
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1904
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1905 #include <Processes.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1906 #include <EPPC.h>
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1907
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1908 /* 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
1909 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
1910
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1911 /* 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
1912 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
1913
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1914
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1915 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1916 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
1917 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1918 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
1919 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1920 if (*s == '\\')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1921 s++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1922 s++;
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 (*s)
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 *s = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1928 return s;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1929 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1930 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1931 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1932 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1933
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1934
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1935 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1936 mystrtok (char *s)
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1937 {
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1938 while (*s)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1939 s++;
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 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
1942 }
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
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1945 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1946 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
1947 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1948 while (*from)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1949 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1950 if (*from == '\\')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1951 from++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1952 *to++ = *from++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1953 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1954 *to = '\0';
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 /* 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
1959 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
1960 "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
1961 "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
1962 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
1963 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
1964 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
1965 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
1966 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
1967 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
1968 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
1969 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
1970 by-passed. We really need to add code here to do filename
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1971 expansion to support such functionality. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1972
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1973 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1974 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
1975 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
1976 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
1977 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
1978 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1979 #ifdef 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
1980 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1981 #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
1982 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
1983 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
1984 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
1985 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
1986 OSErr iErr;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1987 FSSpec spec;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1988 LaunchParamBlockRec lpbr;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1989 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
1990 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
1991 TargetID targ;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1992 unsigned long ref_con, len;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
1993
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1994 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
1995 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1996 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
1997 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
1998 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
1999 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2000 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
2001 return -1;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2002
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2003 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
2004 + 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
2005
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2006 argc = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2007 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
2008 argc++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2009
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2010 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
2011 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2012
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2013 /* 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
2014 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
2015 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
2016 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
2017 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
2018 && 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
2019 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2020 char *command, *t, tempmacpathname[MAXPATHLEN+1];
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2021
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2022 /* 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
2023 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
2024 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
2025 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
2026 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
2027 strcat (command, " ");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2028
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2029 t = command;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2030 newargc = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2031 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
2032 while (t)
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 newargc++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2035 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
2036 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2037
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2038 newargv = (char **) alloca (sizeof (char *) * newargc);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2039
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2040 t = command;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2041 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
2042 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2043 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
2044 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
2045
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2046 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
2047 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
2048 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2049
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2050 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
2051 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2052 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
2053 == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2054 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2055 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2056 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2057 { /* 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
2058 #if 0
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2059 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
2060 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
2061 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
2062 #endif /* 0 */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2063 Lisp_Object path;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2064 openp (Vexec_path, build_string (newargv[0]), EXEC_SUFFIXES, &path,
45004
303384b6edc4 (run_mac_command): Update call to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44890
diff changeset
2065 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
2066
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2067 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
2068 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
2069 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
2070 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
2071 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2072 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2073 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
2074 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2075 else
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2076 {
44890
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 (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
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 newargv = (char **) alloca (sizeof (char *) * argc);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2081 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
2082 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
2083 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2084 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
2085 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2086 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
2087 if (t)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2088 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2089 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
2090 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
2091 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
2092 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
2093 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
2094 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2095 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
2096 + 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
2097 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
2098 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
2099 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2100 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2101 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2102 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
2103 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
2104 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
2105 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2106 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
2107 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
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 else
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2111 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
2112 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
2113 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2114 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2115
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2116 /* 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
2117 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
2118 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
2119 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
2120 if (!param)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2121 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2122
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2123 p = param;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2124 *p++ = newargc;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2125 /* 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
2126 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
2127 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
2128 *p++ = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2129 /* 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
2130 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
2131 p += strlen (macinfn);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2132 *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
2133 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
2134 p += strlen (macoutfn);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2135 *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
2136 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
2137 p += strlen (macerrfn);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2138 *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
2139 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
2140 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2141 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
2142 p += strlen (newargv[j]);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2143 *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
2144 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2145
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2146 c2pstr (macappname);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2147
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2148 iErr = FSMakeFSSpec (0, 0, macappname, &spec);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2149
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2150 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
2151 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2152 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2153 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2154 }
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 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
2157 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
2158 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
2159 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
2160 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
2161
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2162 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
2163 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
2164 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2165 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2166 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2167 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2168
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2169 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
2170 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
2171 /* 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
2172
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2173 retries = 3;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2174 /* 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
2175 terminated recently. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2176 do
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2177 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2178 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
2179 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
2180 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2181 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
2182
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2183 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
2184 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2185 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2186 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2187 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2188
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2189 cursor_region_handle = NewRgn ();
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 /* 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
2192 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
2193 while (1)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2194 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
2195 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
2196 && 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
2197 break;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2198
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2199 /* 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
2200 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
2201 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
2202 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2203 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
2204 free (param);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2205 return -1;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2206 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2207
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2208 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
2209 free (param);
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 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
2212 #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
2213 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2214
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2215
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2216 DIR *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2217 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
2218 {
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2219 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
2220 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
2221 DIR *dirp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2222 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2223 HVolumeParam vpb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2224 int len, vol_name_len;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2225
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2226 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
2227 return 0;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2228
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2229 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
2230 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
2231 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
2232 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2233 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
2234
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2235 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
2236 if (!dirp)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2237 return 0;
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 /* 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
2240 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
2241 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
2242 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2243 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
2244 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
2245 return dirp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2246 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2247
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2248 /* 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
2249 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
2250 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2251
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2252 /* 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
2253 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
2254 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
2255 strcat (mac_pathname, ":");
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2256
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2257 /* 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
2258 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
2259 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
2260 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
2261 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
2262
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2263 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
2264 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
2265 /* 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
2266 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
2267 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
2268 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
2269 /* 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
2270
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2271 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
2272 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
2273 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2274 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2275 return 0;
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 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
2279 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
2280
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2281 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
2282 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
2283 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
2284
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2285 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
2286 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
2287 /* 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
2288 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
2289 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
2290 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
2291 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
2292 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2293 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2294 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2295 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2296
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2297 dirp->vol_ref_num = vpb.ioVRefNum;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2298
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2299 return dirp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2300 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2301
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2302 int
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2303 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
2304 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2305 free (dp);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2306
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2307 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2308 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2309
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2310
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2311 struct dirent *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2312 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
2313 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2314 HParamBlockRec hpblock;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2315 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2316 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
2317 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
2318 int done;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2319 char *p;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2320
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2321 /* 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
2322 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
2323 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
2324 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
2325 pointer. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2326 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
2327 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2328 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
2329 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
2330 hpblock.volumeParam.ioVolIndex = dp->current_index;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2331
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2332 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
2333 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
2334 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2335 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2336 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2337 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2338
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2339 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
2340 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
2341
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2342 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
2343
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2344 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
2345 s_dirent.d_name = s_name;
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 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
2348 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2349 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2350 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2351 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
2352 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
2353 /* 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
2354
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2355 /* 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
2356 done = false;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2357 while (!done)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2358 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2359 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
2360 /* 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
2361 cipb.hFileInfo.ioFDirIndex = dp->current_index;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2362
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2363 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
2364 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
2365 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2366 errno = ENOENT;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2367 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2368 }
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2369
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2370 /* 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
2371 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
2372 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
2373 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2374 done = !(cipb.hFileInfo.ioFlFndrInfo.fdFlags & fInvisible);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2375
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2376 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
2377 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2378
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2379 p2cstr (s_name);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2380
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2381 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
2382 while (*p)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2383 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2384 if (*p == '/')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2385 *p = ':';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2386 p++;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2387 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2388
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2389 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
2390 /* 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
2391 s_dirent.d_name = s_name;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2392
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2393 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
2394 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2395 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2396
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2397
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2398 char *
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2399 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
2400 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2401 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
2402 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
2403 OSErr errno;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2404 CInfoPBRec cipb;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2405
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2406 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
2407 return NULL;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2408
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2409 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
2410 return 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2411 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2412 return path;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2413 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2414
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2415 #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
2416
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2417
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2418 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2419 initialize_applescript ()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2420 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2421 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
2422 OSAError osaerror;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2423
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2424 /* 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
2425 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
2426 error. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2427 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
2428 kAppleScriptSubtype);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2429
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2430 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
2431 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
2432 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
2433 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
2434 if (osaerror)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2435 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
2436 /* 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
2437 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2438
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2439
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2440 void terminate_applescript()
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2441 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2442 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
2443 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
2444 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2445
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2446
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2447 /* 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
2448 status as function value. A zero is returned if compilation and
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2449 execution is successful, in which case RESULT returns a pointer to
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2450 a string containing the resulting script value. Otherwise, the Mac
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2451 error code is returned and RESULT returns a pointer to an error
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2452 string. In both cases the caller should deallocate the storage
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2453 used by the string pointed to by RESULT if it is non-NULL. For
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2454 documentation on the MacOS scripting architecture, see Inside
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2455 Macintosh - Interapplication Communications: Scripting Components. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2456
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2457 static long
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2458 do_applescript (char *script, char **result)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2459 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2460 AEDesc script_desc, result_desc, error_desc;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2461 OSErr error;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2462 OSAError osaerror;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2463 long length;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2464
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2465 *result = 0;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2466
45851
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
2467 if (!as_scripting_component)
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
2468 initialize_applescript();
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
2469
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2470 error = AECreateDesc (typeChar, script, strlen(script), &script_desc);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2471 if (error)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2472 return error;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2473
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2474 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
2475 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
2476
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2477 if (osaerror == errOSAScriptError)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2478 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2479 /* error executing AppleScript: retrieve error message */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2480 if (!OSAScriptError (as_scripting_component, kOSAErrorMessage, typeChar,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2481 &error_desc))
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 #if 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
2484 length = AEGetDescDataSize (&error_desc);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2485 *result = (char *) xmalloc (length + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2486 if (*result)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2487 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2488 AEGetDescData (&error_desc, *result, length);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2489 *(*result + length) = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2490 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2491 #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
2492 HLock (error_desc.dataHandle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2493 length = GetHandleSize(error_desc.dataHandle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2494 *result = (char *) xmalloc (length + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2495 if (*result)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2496 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2497 memcpy (*result, *(error_desc.dataHandle), length);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2498 *(*result + length) = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2499 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2500 HUnlock (error_desc.dataHandle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2501 #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
2502 AEDisposeDesc (&error_desc);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2503 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2504 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2505 else if (osaerror == noErr) /* success: retrieve resulting script value */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2506 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2507 #if 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
2508 length = AEGetDescDataSize (&result_desc);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2509 *result = (char *) xmalloc (length + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2510 if (*result)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2511 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2512 AEGetDescData (&result_desc, *result, length);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2513 *(*result + length) = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2514 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2515 #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
2516 HLock (result_desc.dataHandle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2517 length = GetHandleSize(result_desc.dataHandle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2518 *result = (char *) xmalloc (length + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2519 if (*result)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2520 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2521 memcpy (*result, *(result_desc.dataHandle), length);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2522 *(*result + length) = '\0';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2523 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2524 HUnlock (result_desc.dataHandle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2525 #endif /* not TARGET_API_MAC_CARBON */
45851
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
2526 AEDisposeDesc (&result_desc);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2527 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2528
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2529 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
2530
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2531 return osaerror;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2532 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2533
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2534
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2535 DEFUN ("do-applescript", Fdo_applescript, Sdo_applescript, 1, 1, 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2536 doc: /* Compile and execute AppleScript SCRIPT and retrieve and return the result.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2537 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
2538 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
2539 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
2540 component. */)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2541 (script)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2542 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
2543 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2544 char *result, *temp;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2545 Lisp_Object lisp_result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2546 long status;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2547
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2548 CHECK_STRING (script);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2549
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45851
diff changeset
2550 status = do_applescript (SDATA (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
2551 if (status)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2552 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2553 if (!result)
45851
7b1f766314f6 2002-06-17 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 45848
diff changeset
2554 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
2555 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2556 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2557 /* Unfortunately only OSADoScript in do_applescript knows how
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2558 how large the resulting script value or error message is
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2559 going to be and therefore as caller memory must be
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2560 deallocated here. It is necessary to free the error
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2561 message before calling error to avoid a memory leak. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2562 temp = (char *) alloca (strlen (result) + 1);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2563 strcpy (temp, result);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2564 xfree (result);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2565 error (temp);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2566 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2567 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2568 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2569 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2570 lisp_result = build_string (result);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2571 xfree (result);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2572 return lisp_result;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2573 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2574 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2575
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2576
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2577 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
2578 Smac_file_name_to_posix, 1, 1, 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2579 doc: /* Convert Macintosh filename to Posix form. */)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2580 (mac_filename)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2581 Lisp_Object mac_filename;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2582 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2583 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
2584
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2585 CHECK_STRING (mac_filename);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2586
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45851
diff changeset
2587 if (mac_to_posix_pathname (SDATA (mac_filename), posix_filename,
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2588 MAXPATHLEN))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2589 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
2590 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2591 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2592 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2593
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2594
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2595 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
2596 Sposix_file_name_to_mac, 1, 1, 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2597 doc: /* Convert Posix filename to Mac form. */)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2598 (posix_filename)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2599 Lisp_Object posix_filename;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2600 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2601 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
2602
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2603 CHECK_STRING (posix_filename);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2604
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45851
diff changeset
2605 if (posix_to_mac_pathname (SDATA (posix_filename), mac_filename,
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2606 MAXPATHLEN))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2607 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
2608 else
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2609 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2610 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2611
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2612
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2613 /* set interprogram-paste-function to mac-paste-function in mac-win.el
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2614 to enable Emacs to obtain the contents of the Mac clipboard. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2615 DEFUN ("mac-paste-function", Fmac_paste_function, Smac_paste_function, 0, 0, 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2616 doc: /* Return the contents of the Mac clipboard as a string. */)
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 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2619 #if 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
2620 ScrapRef scrap;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2621 ScrapFlavorFlags sff;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2622 Size s;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2623 int i;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2624 char *data;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2625
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2626 if (GetCurrentScrap (&scrap) != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2627 return Qnil;
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 if (GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff) != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2630 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2631
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2632 if (GetScrapFlavorSize (scrap, kScrapFlavorTypeText, &s) != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2633 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2634
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2635 if ((data = (char*) alloca (s)) == NULL)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2636 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2637
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2638 if (GetScrapFlavorData (scrap, kScrapFlavorTypeText, &s, data) != noErr
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2639 || s == 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2640 return Qnil;
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2641
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2642 /* Emacs expects clipboard contents have Unix-style eol's */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2643 for (i = 0; i < s; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2644 if (data[i] == '\r')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2645 data[i] = '\n';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2646
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2647 return make_string (data, s);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2648 #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
2649 Lisp_Object value;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2650 Handle my_handle;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2651 long scrap_offset, rc, i;
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 my_handle = NewHandle (0); /* allocate 0-length data area */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2654
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2655 rc = GetScrap (my_handle, 'TEXT', &scrap_offset);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2656 if (rc < 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2657 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2658
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2659 HLock (my_handle);
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 /* Emacs expects clipboard contents have Unix-style eol's */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2662 for (i = 0; i < rc; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2663 if ((*my_handle)[i] == '\r')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2664 (*my_handle)[i] = '\n';
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2665
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2666 value = make_string (*my_handle, rc);
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 HUnlock (my_handle);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2669
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2670 DisposeHandle (my_handle);
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 return value;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2673 #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
2674 }
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
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2677 /* set interprogram-cut-function to mac-cut-function in mac-win.el
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2678 to enable Emacs to write the top of the kill-ring to the Mac clipboard. */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2679 DEFUN ("mac-cut-function", Fmac_cut_function, Smac_cut_function, 1, 2, 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2680 doc: /* Put the value of the string parameter to the Mac clipboard. */)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2681 (value, push)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2682 Lisp_Object value, push;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2683 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2684 char *buf;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2685 int len, i;
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 /* fixme: ignore the push flag for now */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2688
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2689 CHECK_STRING (value);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2690
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45851
diff changeset
2691 len = SCHARS (value);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2692 buf = (char *) alloca (len+1);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45851
diff changeset
2693 bcopy (SDATA (value), buf, len);
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2694 buf[len] = '\0';
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2695
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2696 /* convert to Mac-style eol's before sending to clipboard */
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2697 for (i = 0; i < len; i++)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2698 if (buf[i] == '\n')
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2699 buf[i] = '\r';
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 #if 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
2702 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2703 ScrapRef scrap;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2704 ClearCurrentScrap ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2705 if (GetCurrentScrap (&scrap) != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2706 error ("cannot get current scrap");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2707
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2708 if (PutScrapFlavor (scrap, kScrapFlavorTypeText, kScrapFlavorMaskNone, len,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2709 buf) != noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2710 error ("cannot put to scrap");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2711 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2712 #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
2713 ZeroScrap ();
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2714 PutScrap (len, 'TEXT', buf);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2715 #endif /* not TARGET_API_MAC_CARBON */
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2716
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2717 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2718 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2719
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2720
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2721 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2722 0, 1, 0,
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2723 doc: /* Whether there is an owner for the given X Selection.
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2724 The arg should be the name of the selection in question, typically one of
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2725 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
45141
0efae879dd3e (mac-cut-function): Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 45004
diff changeset
2726 \(Those are literal upper-case symbol names, since that's what X expects.)
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2727 For convenience, the symbol nil is the same as `PRIMARY',
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2728 and t is the same as `SECONDARY'. */)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2729 (selection)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2730 Lisp_Object selection;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2731 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2732 CHECK_SYMBOL (selection);
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 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2735 if the clipboard currently has valid text format contents. */
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 if (EQ (selection, QCLIPBOARD))
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2738 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2739 Lisp_Object val = Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2740
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2741 #if 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
2742 ScrapRef scrap;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2743 ScrapFlavorFlags sff;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2744
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2745 if (GetCurrentScrap (&scrap) == noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2746 if (GetScrapFlavorFlags (scrap, kScrapFlavorTypeText, &sff) == noErr)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2747 val = Qt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2748 #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
2749 Handle my_handle;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2750 long rc, scrap_offset;
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 my_handle = NewHandle (0);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2753
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2754 rc = GetScrap (my_handle, 'TEXT', &scrap_offset);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2755 if (rc >= 0)
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2756 val = Qt;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2757
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2758 DisposeHandle (my_handle);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2759 #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
2760
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2761 return val;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2762 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2763 return Qnil;
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2764 }
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2765
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2766 #ifdef MAC_OSX
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2767 #undef select
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2768
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2769 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
2770 extern int noninteractive;
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2771
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2772 /* When Emacs is started from the Finder, SELECT always immediately
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2773 returns as if input is present when file descriptor 0 is polled for
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2774 input. Strangely, when Emacs is run as a GUI application from the
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2775 command line, it blocks in the same situation. This `wrapper' of
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2776 the system call SELECT corrects this discrepancy. */
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2777 int
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2778 sys_select (n, rfds, wfds, efds, timeout)
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2779 int n;
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2780 SELECT_TYPE *rfds;
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2781 SELECT_TYPE *wfds;
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2782 SELECT_TYPE *efds;
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2783 struct timeval *timeout;
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2784 {
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2785 if (!inhibit_window_system && rfds && FD_ISSET (0, rfds))
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2786 return 1;
48793
da833584a044 Modifying sys_read to not check the event queue if timeout=0 and to never
Steven Tamm <steventamm@mac.com>
parents: 48787
diff changeset
2787 else if (inhibit_window_system || noninteractive ||
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2788 (timeout && (EMACS_SECS(*timeout)==0) &&
48793
da833584a044 Modifying sys_read to not check the event queue if timeout=0 and to never
Steven Tamm <steventamm@mac.com>
parents: 48787
diff changeset
2789 (EMACS_USECS(*timeout)==0)))
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2790 return select(n, rfds, wfds, efds, timeout);
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2791 else
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2792 {
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2793 EMACS_TIME end_time, now;
48818
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2794
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2795 EMACS_GET_TIME (end_time);
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2796 if (timeout)
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2797 EMACS_ADD_TIME (end_time, end_time, *timeout);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2798
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2799 do
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2800 {
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2801 int r;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2802 EMACS_TIME one_second;
48818
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2803 SELECT_TYPE orfds;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2804
48818
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2805 FD_ZERO (&orfds);
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2806 if (rfds)
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2807 {
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2808 orfds = *rfds;
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2809 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2810
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2811 EMACS_SET_SECS (one_second, 1);
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2812 EMACS_SET_USECS (one_second, 0);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2813
48793
da833584a044 Modifying sys_read to not check the event queue if timeout=0 and to never
Steven Tamm <steventamm@mac.com>
parents: 48787
diff changeset
2814 if (timeout && EMACS_TIME_LT(*timeout, one_second))
da833584a044 Modifying sys_read to not check the event queue if timeout=0 and to never
Steven Tamm <steventamm@mac.com>
parents: 48787
diff changeset
2815 one_second = *timeout;
da833584a044 Modifying sys_read to not check the event queue if timeout=0 and to never
Steven Tamm <steventamm@mac.com>
parents: 48787
diff changeset
2816
48818
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2817 if ((r = select (n, &orfds, wfds, efds, &one_second)) > 0)
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2818 {
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2819 *rfds = orfds;
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2820 return r;
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2821 }
5030a4c296d2 * macterm.c (mac_check_for_quit_char): Correctly set the
Steven Tamm <steventamm@mac.com>
parents: 48793
diff changeset
2822
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2823 mac_check_for_quit_char();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2824
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2825 EMACS_GET_TIME (now);
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2826 EMACS_SUB_TIME (now, end_time, now);
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2827 }
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2828 while (!timeout || !EMACS_TIME_NEG_P (now));
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2829
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2830 return 0;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2831 }
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2832 }
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2833
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2834 #undef read
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2835 int sys_read (fds, buf, nbyte)
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2836 int fds;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2837 char *buf;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2838 unsigned int nbyte;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2839 {
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2840 SELECT_TYPE rfds;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2841 EMACS_TIME one_second;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2842 int r;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2843
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2844 /* Use select to block on IO while still checking for quit_char */
48787
0360bdd5a70b Fixed OSX sys_read to not call select if IO is non-blocking
Steven Tamm <steventamm@mac.com>
parents: 48740
diff changeset
2845 if (!inhibit_window_system && !noninteractive &&
0360bdd5a70b Fixed OSX sys_read to not call select if IO is non-blocking
Steven Tamm <steventamm@mac.com>
parents: 48740
diff changeset
2846 ! (fcntl(fds, F_GETFL, 0) & O_NONBLOCK))
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2847 {
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2848 FD_ZERO (&rfds);
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2849 FD_SET (fds, &rfds);
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2850 if (sys_select (fds+1, &rfds, 0, 0, NULL) < 0)
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2851 return -1;
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2852 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48818
diff changeset
2853
48740
b45c19284d24 sys_select: Call mac_check_for_quit_char every second while blocking
Steven Tamm <steventamm@mac.com>
parents: 47942
diff changeset
2854 return read (fds, buf, nbyte);
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2855 }
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2856
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2857
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2858 /* 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
2859 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
2860 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
2861 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
2862 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
2863 .../Emacs.app/Contents/Resources/ and
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2864 .../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
2865 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
2866 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
2867 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
2868 void
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2869 init_mac_osx_environment ()
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2870 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2871 CFBundleRef bundle;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2872 CFURLRef bundleURL;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2873 CFStringRef cf_app_bundle_pathname;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2874 int app_bundle_pathname_len;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2875 char *app_bundle_pathname;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2876 char *p, *q;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2877 struct stat st;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2878
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2879 /* 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
2880 app_bundle_pathname. */
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2881
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2882 bundle = CFBundleGetMainBundle ();
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2883 if (!bundle)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2884 return;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2885
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2886 bundleURL = CFBundleCopyBundleURL (bundle);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2887 if (!bundleURL)
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2888 return;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2889
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2890 cf_app_bundle_pathname = CFURLCopyFileSystemPath (bundleURL,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2891 kCFURLPOSIXPathStyle);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2892 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
2893 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
2894
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2895 if (!CFStringGetCString (cf_app_bundle_pathname,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2896 app_bundle_pathname,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2897 app_bundle_pathname_len + 1,
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2898 kCFStringEncodingISOLatin1))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2899 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2900 CFRelease (cf_app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2901 return;
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2902 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2903
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2904 CFRelease (cf_app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2905
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2906 /* 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
2907 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
2908 should have three times that much room because EMACSLOADPATH can
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2909 have the value "<path to lisp dir>:<path to leim dir>:<path to
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2910 site-lisp dir>". */
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2911 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
2912 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
2913 if (!getenv ("EMACSLOADPATH"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2914 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2915 q[0] = '\0';
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2917 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2918 strcat (p, "/Contents/Resources/lisp");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2919 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
2920 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2921
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2922 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2923 strcat (p, "/Contents/Resources/leim");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2924 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
2925 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2926 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2927 strcat (q, ":");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2928 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2929 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2930
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2931 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2932 strcat (p, "/Contents/Resources/site-lisp");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2933 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
2934 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2935 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2936 strcat (q, ":");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2937 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2938 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2939
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2940 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2941 setenv ("EMACSLOADPATH", q, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2942 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2943
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2944 if (!getenv ("EMACSPATH"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2945 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2946 q[0] = '\0';
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2947
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2948 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
2949 strcat (p, "/Contents/MacOS/libexec");
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2950 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
2951 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2952
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2953 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
2954 strcat (p, "/Contents/MacOS/bin");
46916
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2955 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
2956 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2957 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2958 strcat (q, ":");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2959 strcat (q, p);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2960 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2961
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2962 if (q[0] != '\0')
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2963 setenv ("EMACSPATH", q, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2964 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2965
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2966 if (!getenv ("EMACSDATA"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2967 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2968 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2969 strcat (p, "/Contents/Resources/etc");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2970 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
2971 setenv ("EMACSDATA", p, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2972 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2973
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2974 if (!getenv ("EMACSDOC"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2975 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2976 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2977 strcat (p, "/Contents/Resources/etc");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2978 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
2979 setenv ("EMACSDOC", p, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2980 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2981
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2982 if (!getenv ("INFOPATH"))
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2983 {
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2984 strcpy (p, app_bundle_pathname);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2985 strcat (p, "/Contents/Resources/info");
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2986 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
2987 setenv ("INFOPATH", p, 1);
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2988 }
aff9c7fcedb0 2002-08-15 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46856
diff changeset
2989 }
46856
eba75fedd593 2002-08-10 Andrew Choi <akochoi@shaw.ca>
Andrew Choi <akochoi@shaw.ca>
parents: 46788
diff changeset
2990 #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
2991
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2992 void
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2993 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
2994 {
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2995 QCLIPBOARD = intern ("CLIPBOARD");
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2996 staticpro (&QCLIPBOARD);
47942
080b4586492b Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 46916
diff changeset
2997
44890
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2998 defsubr (&Smac_paste_function);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
2999 defsubr (&Smac_cut_function);
01b93e5e53a7 Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
diff changeset
3000 defsubr (&Sx_selection_exists_p);
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 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
3003 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
3004 defsubr (&Sposix_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
3005 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50490
diff changeset
3006
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50490
diff changeset
3007 /* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50490
diff changeset
3008 (do not change this comment) */