Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macgetargv.c @ 10072:ecebcd84df37 legacy-trunk
put the preferences file in a folder called "Python" inside the prefs folder, just like the IDE does -- jvr
| author | Just van Rossum <just@lettererror.com> |
|---|---|
| date | Tue, 02 Feb 1999 15:49:03 +0000 |
| parents | 1ae7e2ebc2f3 |
| children | b90d601d4d59 |
| rev | line source |
|---|---|
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4552
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 The Netherlands. |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 /* Construct argc and argv for main() by using Apple Events */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 /* From Jack's implementation for STDWIN */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #include <stdlib.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 #ifndef SystemSevenOrLater |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 #define SystemSevenOrLater 1 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 #endif |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 #include <Types.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 #include <Files.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 #include <Events.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 #include <Memory.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 #include <Processes.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 #include <Errors.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 #include <AppleEvents.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 #include <AEObjects.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 #include <Fonts.h> |
|
2399
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
43 #include <TextEdit.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
44 #include <Menus.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
45 #include <Dialogs.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
46 #include <Windows.h> |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
48 #include "Python.h" |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
49 #include "macglue.h" |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
50 |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 #ifdef GENERATINGCFM /* Defined to 0 or 1 in Universal headers */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 #define HAVE_UNIVERSAL_HEADERS |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 #endif |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 |
|
2794
823f3a8ecfe4
Initial port to CodeWarrior CFM68K support (mainly by disabling
Jack Jansen <jack.jansen@cwi.nl>
parents:
2411
diff
changeset
|
55 #ifdef SYMANTEC__CFM68K__ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 #pragma lib_export on |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 #endif |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 #ifndef HAVE_UNIVERSAL_HEADERS |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 #define NewAEEventHandlerProc(x) (x) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 #define AEEventHandlerUPP EventHandlerProcPtr |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 #endif |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 static int arg_count; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 static char *arg_vector[256]; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
66 FSSpec PyMac_ApplicationFSSpec; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
67 char PyMac_ApplicationPath[256]; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
68 static int applocation_inited; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 |
|
3215
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
70 /* Duplicate a string to the heap. We also export this since it isn't standard |
|
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
71 ** and others use it |
|
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
72 */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 |
|
3215
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
74 char * |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 strdup(char *src) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 char *dst = malloc(strlen(src) + 1); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 if (dst) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 strcpy(dst, src); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 return dst; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
83 /* Initialize FSSpec and full name of current application */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 |
|
3054
2cb1416010b3
Python will now attempt (again) to create at least a minimal
Jack Jansen <jack.jansen@cwi.nl>
parents:
2874
diff
changeset
|
85 OSErr |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
86 PyMac_init_process_location() |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 ProcessSerialNumber currentPSN; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 ProcessInfoRec info; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
90 OSErr err; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
92 if ( applocation_inited ) return 0; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 currentPSN.highLongOfPSN = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 currentPSN.lowLongOfPSN = kCurrentProcess; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 info.processInfoLength = sizeof(ProcessInfoRec); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 info.processName = NULL; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
97 info.processAppSpec = &PyMac_ApplicationFSSpec; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
98 if ( err=GetProcessInformation(¤tPSN, &info)) |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
99 return err; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
100 if ( err=PyMac_GetFullPath(&PyMac_ApplicationFSSpec, PyMac_ApplicationPath) ) |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
101 return err; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
102 applocation_inited = 1; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
103 return 0; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 /* Given an FSSpec, return the FSSpec of the parent folder */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 static OSErr |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 get_folder_parent (FSSpec * fss, FSSpec * parent) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 CInfoPBRec rec; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 short err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 * parent = * fss; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 rec.hFileInfo.ioNamePtr = parent->name; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 rec.hFileInfo.ioVRefNum = parent->vRefNum; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 rec.hFileInfo.ioDirID = parent->parID; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 rec.hFileInfo.ioFDirIndex = -1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 rec.hFileInfo.ioFVersNum = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 if (err = PBGetCatInfoSync (& rec)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 parent->parID = rec.dirInfo.ioDrParID; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 /* parent->name[0] = 0; */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 return 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 /* Given an FSSpec return a full, colon-separated pathname */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
129 OSErr |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
130 PyMac_GetFullPath (FSSpec *fss, char *buf) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 short err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 FSSpec fss_parent, fss_current; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 char tmpbuf[256]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 int plen; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 fss_current = *fss; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 plen = fss_current.name[0]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 memcpy(buf, &fss_current.name[1], plen); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 buf[plen] = 0; |
|
4552
efb2938ce676
Fixed FSSpec->pathname code to add colon if the fsspec points to a disk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4523
diff
changeset
|
141 /* Special case for disk names */ |
|
efb2938ce676
Fixed FSSpec->pathname code to add colon if the fsspec points to a disk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4523
diff
changeset
|
142 if ( fss_current.parID <= 1 ) { |
|
efb2938ce676
Fixed FSSpec->pathname code to add colon if the fsspec points to a disk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4523
diff
changeset
|
143 buf[plen++] = ':'; |
|
efb2938ce676
Fixed FSSpec->pathname code to add colon if the fsspec points to a disk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4523
diff
changeset
|
144 buf[plen] = 0; |
|
efb2938ce676
Fixed FSSpec->pathname code to add colon if the fsspec points to a disk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4523
diff
changeset
|
145 return 0; |
|
efb2938ce676
Fixed FSSpec->pathname code to add colon if the fsspec points to a disk.
Jack Jansen <jack.jansen@cwi.nl>
parents:
4523
diff
changeset
|
146 } |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 while (fss_current.parID > 1) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 /* Get parent folder name */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 if (err = get_folder_parent(&fss_current, &fss_parent)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 fss_current = fss_parent; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 /* Prepend path component just found to buf */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 plen = fss_current.name[0]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 if (strlen(buf) + plen + 1 > 256) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 /* Oops... Not enough space (shouldn't happen) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 *buf = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 return -1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 memcpy(tmpbuf, &fss_current.name[1], plen); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 tmpbuf[plen] = ':'; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 strcpy(&tmpbuf[plen+1], buf); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 strcpy(buf, tmpbuf); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 return 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 /* Check that there aren't any args remaining in the event */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 static OSErr |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 get_missing_params(AppleEvent *theAppleEvent) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 DescType theType; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 Size actualSize; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 OSErr err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 err = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 &theType, nil, 0, &actualSize); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 if (err == errAEDescNotFound) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 return noErr; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 else |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 return errAEEventNotHandled; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 static int got_one; /* Flag that we can stop getting events */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
185 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 /* Handle the Print or Quit events (by failing) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 static pascal OSErr |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 handle_not(AppleEvent *theAppleEvent, AppleEvent *reply, long refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
190 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 #pragma unused (reply, refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 got_one = 1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 return errAEEventNotHandled; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 /* Handle the Open Application event (by ignoring it) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 static pascal OSErr |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 handle_open_app(AppleEvent *theAppleEvent, AppleEvent *reply, long refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 #pragma unused (reply, refCon) |
|
3249
1cf6e10522e0
Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3215
diff
changeset
|
202 #if 0 |
|
1cf6e10522e0
Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3215
diff
changeset
|
203 /* Test by Jack: would removing this facilitate debugging? */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 got_one = 1; |
|
3249
1cf6e10522e0
Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3215
diff
changeset
|
205 #endif |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 return get_missing_params(theAppleEvent); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 /* Handle the Open Document event, by adding an argument */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 static pascal OSErr |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 handle_open_doc(AppleEvent *theAppleEvent, AppleEvent *reply, long refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 #pragma unused (reply, refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 OSErr err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 AEDescList doclist; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 AEKeyword keywd; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 DescType rttype; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 long i, ndocs, size; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 FSSpec fss; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 char path[256]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 got_one = 1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 if (err = AEGetParamDesc(theAppleEvent, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 keyDirectObject, typeAEList, &doclist)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 if (err = get_missing_params(theAppleEvent)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
228 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 if (err = AECountItems(&doclist, &ndocs)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 for(i = 1; i <= ndocs; i++) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 err = AEGetNthPtr(&doclist, i, typeFSS, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 &keywd, &rttype, &fss, sizeof(fss), &size); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 if (err) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 break; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
236 PyMac_GetFullPath(&fss, path); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 arg_vector[arg_count++] = strdup(path); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 /* Install standard core event handlers */ |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
243 AEEventHandlerUPP open_doc_upp; |
|
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
244 AEEventHandlerUPP open_app_upp; |
|
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
245 AEEventHandlerUPP not_upp; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 static void |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 set_ae_handlers() |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 { |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
250 open_doc_upp = NewAEEventHandlerProc(handle_open_doc); |
|
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
251 open_app_upp = NewAEEventHandlerProc(handle_open_app); |
|
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
252 not_upp = NewAEEventHandlerProc(handle_not); |
|
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
253 |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
254 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
255 open_app_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
257 open_doc_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
259 not_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
261 not_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 /* Uninstall standard core event handlers */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 static void |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 reset_ae_handlers() |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
268 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 AERemoveEventHandler(kCoreEventClass, kAEOpenApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
270 open_app_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
272 open_doc_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
273 AERemoveEventHandler(kCoreEventClass, kAEPrintDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
274 not_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
275 AERemoveEventHandler(kCoreEventClass, kAEQuitApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
276 not_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
278 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 /* Wait for events until a core event has been handled */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
281 static void |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 event_loop() |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 EventRecord event; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 int n; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
286 int ok; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
288 got_one = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
289 for (n = 0; n < 100 && !got_one; n++) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 SystemTask(); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
291 ok = GetNextEvent(everyEvent, &event); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
292 if (ok && event.what == kHighLevelEvent) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
293 AEProcessAppleEvent(&event); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
295 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
296 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
297 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 /* Get the argv vector, return argc */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 int |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
301 PyMac_GetArgv(pargv, noevents) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 char ***pargv; |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
303 int noevents; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
305 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 arg_count = 0; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
307 (void)PyMac_init_process_location(); |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
308 arg_vector[arg_count++] = strdup(PyMac_ApplicationPath); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
310 if( !noevents ) { |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
311 set_ae_handlers(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
312 event_loop(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
313 reset_ae_handlers(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
314 } |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 arg_vector[arg_count] = NULL; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 *pargv = arg_vector; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 return arg_count; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 } |
