Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macgetargv.c @ 12962:bac045b85263 legacy-trunk
Made argc/argv processing work again under carbon.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Tue, 20 Jun 2000 07:40:34 +0000 |
| parents | 379797f3eeb2 |
| children | db963a615bc9 |
| 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 #include <Types.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 #include <Files.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 #include <Events.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 #include <Memory.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 #include <Processes.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 #include <Errors.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 #include <AppleEvents.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 #include <AEObjects.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 #include <Fonts.h> |
|
2399
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
39 #include <TextEdit.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
40 #include <Menus.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
41 #include <Dialogs.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
42 #include <Windows.h> |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
44 #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
|
45 #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
|
46 |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 static int arg_count; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 static int applocation_inited; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 |
|
3215
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
53 /* 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
|
54 ** and others use it |
|
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
55 */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
3215
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
57 char * |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 strdup(char *src) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 char *dst = malloc(strlen(src) + 1); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 if (dst) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 strcpy(dst, src); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 return dst; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 |
|
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 /* Initialize FSSpec and full name of current application */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 |
|
3054
2cb1416010b3
Python will now attempt (again) to create at least a minimal
Jack Jansen <jack.jansen@cwi.nl>
parents:
2874
diff
changeset
|
68 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
|
69 PyMac_init_process_location() |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 ProcessSerialNumber currentPSN; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 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
|
73 OSErr err; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
75 if ( applocation_inited ) return 0; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 currentPSN.highLongOfPSN = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 currentPSN.lowLongOfPSN = kCurrentProcess; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 info.processInfoLength = sizeof(ProcessInfoRec); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 return 0; |
|
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 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 /* 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
|
90 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 static OSErr |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 get_folder_parent (FSSpec * fss, FSSpec * parent) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 CInfoPBRec rec; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 short err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 * parent = * fss; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 rec.hFileInfo.ioNamePtr = parent->name; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 rec.hFileInfo.ioVRefNum = parent->vRefNum; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 rec.hFileInfo.ioDirID = parent->parID; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 rec.hFileInfo.ioFDirIndex = -1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 rec.hFileInfo.ioFVersNum = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 if (err = PBGetCatInfoSync (& rec)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 parent->parID = rec.dirInfo.ioDrParID; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 /* parent->name[0] = 0; */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 return 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 /* Given an FSSpec return a full, colon-separated pathname */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
112 OSErr |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
113 PyMac_GetFullPath (FSSpec *fss, char *buf) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 short err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 FSSpec fss_parent, fss_current; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 char tmpbuf[256]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 int plen; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 fss_current = *fss; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 plen = fss_current.name[0]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 memcpy(buf, &fss_current.name[1], plen); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 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
|
124 /* 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 } |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 while (fss_current.parID > 1) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 /* Get parent folder name */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 if (err = get_folder_parent(&fss_current, &fss_parent)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 fss_current = fss_parent; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 /* Prepend path component just found to buf */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 plen = fss_current.name[0]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 if (strlen(buf) + plen + 1 > 256) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 /* Oops... Not enough space (shouldn't happen) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 *buf = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 return -1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 memcpy(tmpbuf, &fss_current.name[1], plen); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 tmpbuf[plen] = ':'; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 strcpy(&tmpbuf[plen+1], buf); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 strcpy(buf, tmpbuf); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 return 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 /* 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
|
151 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 static OSErr |
|
12832
b90d601d4d59
Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
153 get_missing_params(const AppleEvent *theAppleEvent) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 DescType theType; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 Size actualSize; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 OSErr err; |
|
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 err = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 &theType, nil, 0, &actualSize); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 if (err == errAEDescNotFound) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 return noErr; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 else |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 return errAEEventNotHandled; |
|
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 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
|
168 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 /* Handle the Print or Quit events (by failing) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 static pascal OSErr |
|
12832
b90d601d4d59
Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
172 handle_not(const AppleEvent *theAppleEvent, AppleEvent *reply, unsigned long refCon) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 #pragma unused (reply, refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 got_one = 1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 return errAEEventNotHandled; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 /* Handle the Open Application event (by ignoring it) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 static pascal OSErr |
|
12832
b90d601d4d59
Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
182 handle_open_app(const AppleEvent *theAppleEvent, AppleEvent *reply, unsigned long refCon) |
|
2393
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 #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
|
185 #if 0 |
|
1cf6e10522e0
Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3215
diff
changeset
|
186 /* Test by Jack: would removing this facilitate debugging? */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 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
|
188 #endif |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 return get_missing_params(theAppleEvent); |
|
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 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 /* Handle the Open Document event, by adding an argument */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 static pascal OSErr |
|
12832
b90d601d4d59
Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
195 handle_open_doc(const AppleEvent *theAppleEvent, AppleEvent *reply, unsigned long refCon) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 #pragma unused (reply, refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 OSErr err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 AEDescList doclist; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 AEKeyword keywd; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 DescType rttype; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 long i, ndocs, size; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 FSSpec fss; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 char path[256]; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 got_one = 1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 if (err = AEGetParamDesc(theAppleEvent, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 keyDirectObject, typeAEList, &doclist)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 if (err = get_missing_params(theAppleEvent)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 if (err = AECountItems(&doclist, &ndocs)) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 for(i = 1; i <= ndocs; i++) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 err = AEGetNthPtr(&doclist, i, typeFSS, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 &keywd, &rttype, &fss, sizeof(fss), &size); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 if (err) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 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
|
219 PyMac_GetFullPath(&fss, path); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 arg_vector[arg_count++] = strdup(path); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 /* 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
|
226 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
|
227 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
|
228 AEEventHandlerUPP not_upp; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 static void |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 set_ae_handlers() |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 { |
|
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
|
233 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
|
234 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
|
235 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
|
236 |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 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
|
238 open_app_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 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
|
240 open_doc_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 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
|
242 not_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 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
|
244 not_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 } |
|
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 /* Uninstall standard core event handlers */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 static void |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 reset_ae_handlers() |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 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
|
253 open_app_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
254 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
|
255 open_doc_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 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
|
257 not_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 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
|
259 not_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
261 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 /* 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
|
263 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 static void |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 event_loop() |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 EventRecord event; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
268 int n; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 int ok; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
270 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 got_one = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
272 for (n = 0; n < 100 && !got_one; n++) { |
|
12962
bac045b85263
Made argc/argv processing work again under carbon.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12859
diff
changeset
|
273 #ifndef TARGET_API_MAC_CARBON |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
274 SystemTask(); |
|
12962
bac045b85263
Made argc/argv processing work again under carbon.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12859
diff
changeset
|
275 #endif |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
276 ok = GetNextEvent(everyEvent, &event); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 if (ok && event.what == kHighLevelEvent) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
278 AEProcessAppleEvent(&event); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 } |
|
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 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 /* Get the argv vector, return argc */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 int |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
286 PyMac_GetArgv(pargv, noevents) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 char ***pargv; |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
288 int noevents; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
289 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
291 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
|
292 (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
|
293 arg_vector[arg_count++] = strdup(PyMac_ApplicationPath); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
295 if( !noevents ) { |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
296 set_ae_handlers(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
297 event_loop(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
298 reset_ae_handlers(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
299 } |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
301 arg_vector[arg_count] = NULL; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
303 *pargv = arg_vector; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 return arg_count; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
305 } |
