annotate Mac/Python/macgetargv.c @ 17322:bd110eadc19a legacy-trunk

One-liner critical fix from Jim Fulton: Eric's string-method crusade got the order backwards in a line (for .find()).
author Tim Peters <tim.peters@gmail.com>
date Thu, 05 Apr 2001 22:26:23 +0000
parents b31a046f88a7
children 042dca1d4526
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 12962
diff changeset
56 #ifndef HAVE_STRDUP
3215
3b2be811a66a Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents: 3054
diff changeset
57 char *
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 12962
diff changeset
58 strdup(const char *src)
2393
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 }
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 12962
diff changeset
65 #endif
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
66
4523
4d0681f7cf6b Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
67 /* Initialize FSSpec and full name of current application */
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
3054
2cb1416010b3 Python will now attempt (again) to create at least a minimal
Jack Jansen <jack.jansen@cwi.nl>
parents: 2874
diff changeset
69 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
70 PyMac_init_process_location()
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 ProcessSerialNumber currentPSN;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 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
74 OSErr err;
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
75
4523
4d0681f7cf6b Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
76 if ( applocation_inited ) return 0;
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 currentPSN.highLongOfPSN = 0;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 currentPSN.lowLongOfPSN = kCurrentProcess;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 info.processInfoLength = sizeof(ProcessInfoRec);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 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
81 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
82 if ( err=GetProcessInformation(&currentPSN, &info))
4d0681f7cf6b Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
83 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
84 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
85 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
86 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
87 return 0;
2393
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 /* 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
91
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 static OSErr
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 get_folder_parent (FSSpec * fss, FSSpec * parent)
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 CInfoPBRec rec;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 short err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
97
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 * parent = * fss;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 rec.hFileInfo.ioNamePtr = parent->name;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 rec.hFileInfo.ioVRefNum = parent->vRefNum;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 rec.hFileInfo.ioDirID = parent->parID;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 rec.hFileInfo.ioFDirIndex = -1;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 rec.hFileInfo.ioFVersNum = 0;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 if (err = PBGetCatInfoSync (& rec))
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 return err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 parent->parID = rec.dirInfo.ioDrParID;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 /* parent->name[0] = 0; */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 return 0;
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 /* Given an FSSpec return a full, colon-separated pathname */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
112
4523
4d0681f7cf6b Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
113 OSErr
4d0681f7cf6b Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
114 PyMac_GetFullPath (FSSpec *fss, char *buf)
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 short err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
117 FSSpec fss_parent, fss_current;
15787
b31a046f88a7 FSSpec names may be longer on carbon (1024 chars), cater for that in buffer sizes.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
118 char tmpbuf[1024];
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 int plen;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
120
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
121 fss_current = *fss;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 plen = fss_current.name[0];
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
123 memcpy(buf, &fss_current.name[1], plen);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 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
125 /* 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
126 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
127 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
128 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
129 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
130 }
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 while (fss_current.parID > 1) {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 /* Get parent folder name */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 if (err = get_folder_parent(&fss_current, &fss_parent))
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 return err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 fss_current = fss_parent;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 /* Prepend path component just found to buf */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
137 plen = fss_current.name[0];
15787
b31a046f88a7 FSSpec names may be longer on carbon (1024 chars), cater for that in buffer sizes.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
138 if (strlen(buf) + plen + 1 > 1024) {
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
139 /* Oops... Not enough space (shouldn't happen) */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
140 *buf = 0;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 return -1;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 }
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
143 memcpy(tmpbuf, &fss_current.name[1], plen);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
144 tmpbuf[plen] = ':';
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
145 strcpy(&tmpbuf[plen+1], buf);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 strcpy(buf, tmpbuf);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
147 }
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
148 return 0;
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
151 /* 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
152
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
153 static OSErr
12832
b90d601d4d59 Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
154 get_missing_params(const AppleEvent *theAppleEvent)
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
156 DescType theType;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
157 Size actualSize;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 OSErr err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 err = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard,
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 &theType, nil, 0, &actualSize);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 if (err == errAEDescNotFound)
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 return noErr;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 else
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 return errAEEventNotHandled;
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 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
169
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
170 /* Handle the Print or Quit events (by failing) */
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 static pascal OSErr
12832
b90d601d4d59 Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
173 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
174 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
175 #pragma unused (reply, refCon)
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 got_one = 1;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
177 return errAEEventNotHandled;
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
180 /* Handle the Open Application event (by ignoring it) */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
181
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
182 static pascal OSErr
12832
b90d601d4d59 Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
183 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
184 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
185 #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
186 #if 0
1cf6e10522e0 Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents: 3215
diff changeset
187 /* Test by Jack: would removing this facilitate debugging? */
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
188 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
189 #endif
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
190 return get_missing_params(theAppleEvent);
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
193 /* Handle the Open Document event, by adding an argument */
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 static pascal OSErr
12832
b90d601d4d59 Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
196 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
197 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
198 #pragma unused (reply, refCon)
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
199 OSErr err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
200 AEDescList doclist;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 AEKeyword keywd;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
202 DescType rttype;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
203 long i, ndocs, size;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
204 FSSpec fss;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
205 char path[256];
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
206
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 got_one = 1;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
208 if (err = AEGetParamDesc(theAppleEvent,
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
209 keyDirectObject, typeAEList, &doclist))
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
210 return err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
211 if (err = get_missing_params(theAppleEvent))
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
212 return err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
213 if (err = AECountItems(&doclist, &ndocs))
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
214 return err;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
215 for(i = 1; i <= ndocs; i++) {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
216 err = AEGetNthPtr(&doclist, i, typeFSS,
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
217 &keywd, &rttype, &fss, sizeof(fss), &size);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
218 if (err)
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
219 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
220 PyMac_GetFullPath(&fss, path);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
221 arg_vector[arg_count++] = strdup(path);
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 return err;
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
226 /* 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
227 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
228 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
229 AEEventHandlerUPP not_upp;
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
230
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
231 static void
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
232 set_ae_handlers()
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
233 {
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
234 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
235 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
236 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
237
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
238 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
239 open_app_upp, 0L, false);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
240 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
241 open_doc_upp, 0L, false);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
242 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
243 not_upp, 0L, false);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
244 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
245 not_upp, 0L, false);
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
248 /* Uninstall standard core event handlers */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
249
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
250 static void
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
251 reset_ae_handlers()
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
252 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
253 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
254 open_app_upp, false);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
255 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
256 open_doc_upp, false);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
257 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
258 not_upp, false);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
259 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
260 not_upp, false);
2393
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
263 /* 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
264
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
265 static void
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
266 event_loop()
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
267 {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
268 EventRecord event;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
269 int n;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
270 int ok;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
271
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
272 got_one = 0;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
273 for (n = 0; n < 100 && !got_one; n++) {
13608
a901c2c0166b Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13547
diff changeset
274 #if !TARGET_API_MAC_CARBON
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
275 SystemTask();
12962
bac045b85263 Made argc/argv processing work again under carbon.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12859
diff changeset
276 #endif
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
277 ok = GetNextEvent(everyEvent, &event);
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
278 if (ok && event.what == kHighLevelEvent) {
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
279 AEProcessAppleEvent(&event);
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
284 /* Get the argv vector, return argc */
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
285
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
286 int
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4020
diff changeset
287 PyMac_GetArgv(pargv, noevents)
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
288 char ***pargv;
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4020
diff changeset
289 int noevents;
2393
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
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
292 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
293 (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
294 arg_vector[arg_count++] = strdup(PyMac_ApplicationPath);
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
295
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4020
diff changeset
296 if( !noevents ) {
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4020
diff changeset
297 set_ae_handlers();
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4020
diff changeset
298 event_loop();
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4020
diff changeset
299 reset_ae_handlers();
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4020
diff changeset
300 }
2393
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
301
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
302 arg_vector[arg_count] = NULL;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
303
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
304 *pargv = arg_vector;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
305 return arg_count;
b156bf4be62f get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff changeset
306 }