blob: 6f29a20712e4755b7a7bc044ab00701e220e135c [file] [log] [blame]
Guido van Rossumb3404661995-01-22 18:36:13 +00001/***********************************************************
Jack Jansen42218ce1997-01-31 16:15:11 +00002Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
Guido van Rossumb3404661995-01-22 18:36:13 +00003The Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
Jack Jansen0194ad52001-05-12 22:46:35 +000025#ifdef WITHOUT_FRAMEWORKS
Jack Jansen5f653091995-01-18 13:53:49 +000026#include <Types.h>
Guido van Rossumb3404661995-01-22 18:36:13 +000027#include <Files.h>
Guido van Rossumcf27c2d1995-01-25 23:06:44 +000028#include <Events.h>
Jack Jansen32486f51995-08-14 12:36:37 +000029#include <StandardFile.h>
Jack Jansen0194ad52001-05-12 22:46:35 +000030#else
31#include <Carbon/Carbon.h>
32#endif
Jack Jansen5f653091995-01-18 13:53:49 +000033
Jack Jansen94bebc02001-08-08 13:17:31 +000034#include "pymactoolbox.h"
35
Jack Jansenc7fda7e1999-09-30 11:14:49 +000036#ifdef __cplusplus
37 extern "C" {
38#endif
39
Jack Jansen4a79a4b1997-06-03 15:27:31 +000040/* Scheduler parameters */
41typedef struct {
42 int check_interrupt; /* if true check for command-dot */
43 int process_events; /* if nonzero enable evt processing, this mask */
44 int besocial; /* Be social, give up CPU now and again */
45 double check_interval; /* how often to check */
46 double bg_yield; /* yield at most so long when in background */
47} PyMacSchedParams;
48
Jack Jansen2d1306b2000-04-07 09:10:49 +000049#ifdef USE_GUSI1
Jack Jansend88296d2000-07-11 19:51:05 +000050void PyMac_FixGUSIcd(void); /* Workaround for GUSI chdir() call */
Jack Jansen2d1306b2000-04-07 09:10:49 +000051extern void PyMac_SetGUSISpin(void); /* Install our private GUSI spin routine */
Jack Jansen378815c1996-03-06 16:21:34 +000052#endif
53
Jack Jansenf22e67d1998-07-13 13:39:34 +000054unsigned char *Pstring(char *str); /* Convert c-string to pascal-string in static buffer */
Guido van Rossumf71a9a91995-02-18 14:59:48 +000055
Jack Jansenf6865f71996-09-04 15:24:59 +000056#ifdef USE_GUSI
57extern int PyMac_ConsoleIsDead; /* True when exiting */
Jack Jansen570e4b71997-05-23 15:33:20 +000058extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */
Jack Jansenf6865f71996-09-04 15:24:59 +000059#endif
Jack Jansenee23d6e1995-01-27 14:43:25 +000060
Jack Jansen3d228871996-09-06 22:18:40 +000061extern short PyMac_AppRefNum; /* RefNum of application rsrcfork (from macmain.c) */
Jack Jansen570e4b71997-05-23 15:33:20 +000062extern FSSpec PyMac_ApplicationFSSpec; /* Application location (from macargv.c) */
63extern char PyMac_ApplicationPath[]; /* Application location (from macargv.c) */
Jack Jansend88296d2000-07-11 19:51:05 +000064extern OSErr PyMac_init_application_location(void); /* Init the above */
65extern OSErr PyMac_GetFullPath(FSSpec *, char *); /* convert fsspec->path (macargv.c) */
66extern int PyMac_GetArgv(char ***, int); /* Get argc, argv (from macargv.c) */
Jack Jansen8f5725a1999-12-07 23:08:10 +000067extern int PyMac_AppearanceCompliant; /* True if in appearance support mode */
Jack Jansen3d228871996-09-06 22:18:40 +000068
Guido van Rossumcf27c2d1995-01-25 23:06:44 +000069extern PyObject *PyMac_OSErrException; /* Exception for OSErr */
70PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */
Guido van Rossumb3404661995-01-22 18:36:13 +000071
Jack Jansen0194ad52001-05-12 22:46:35 +000072#if !TARGET_API_MAC_OSX
Jack Jansend88296d2000-07-11 19:51:05 +000073void PyMac_GetSchedParams(PyMacSchedParams *); /* Get schedulers params */
74void PyMac_SetSchedParams(PyMacSchedParams *); /* Set schedulers params */
Jack Jansend88296d2000-07-11 19:51:05 +000075int PyMac_DoYield(int, int); /* Yield cpu. First arg is maxtime, second ok to call python */
Jack Jansen0194ad52001-05-12 22:46:35 +000076#endif
Jack Jansend88296d2000-07-11 19:51:05 +000077int PyMac_HandleEvent(EventRecord *); /* Handle one event, possibly in Python */
78void PyMac_HandleEventIntern(EventRecord *); /* Handle one event internal only */
79int PyMac_SetEventHandler(PyObject *); /* set python-coded event handler */
Guido van Rossumb3404661995-01-22 18:36:13 +000080
Jack Jansen0194ad52001-05-12 22:46:35 +000081#if !TARGET_API_MAC_OSX
Jack Jansen3469e991996-09-06 00:30:45 +000082void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */
Jack Jansen0130f0f1997-06-12 10:51:39 +000083void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */
Jack Jansenb4b27be2001-04-25 22:07:42 +000084void PyMac_RaiseConsoleWindow(); /* Bring console window to front, if it exists */
Jack Jansen0194ad52001-05-12 22:46:35 +000085#endif
Jack Janseneda78631997-06-12 15:29:46 +000086int PyMac_FindResourceModule(PyStringObject *, char *, char *); /* Test for 'PYC ' resource in a file */
Jack Jansen74162f31995-02-15 22:58:33 +000087PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */
Jack Jansenf22e67d1998-07-13 13:39:34 +000088int PyMac_FindCodeResourceModule(PyStringObject *, char *, char *); /* Test for 'PYD ' resource in a file */
89PyObject * PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */
Jack Jansenfe38d292000-07-03 23:53:40 +000090struct filedescr *PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */
Jack Jansen74162f31995-02-15 22:58:33 +000091
Jack Jansen6e68a7e2001-05-12 21:31:34 +000092#if TARGET_API_MAC_OS8
Jack Jansen32486f51995-08-14 12:36:37 +000093int PyMac_GetDirectory(FSSpec *dirfss, char *prompt); /* Ask user for a directory */
94void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList,
95 StandardFileReply *reply, char *prompt); /* Ask user for file, with prompt */
Jack Jansen6e68a7e2001-05-12 21:31:34 +000096#endif /* TARGET_API_MAC_OS8 */
Jack Jansen3ec804a1995-02-20 15:56:10 +000097
Guido van Rossumf71a9a91995-02-18 14:59:48 +000098void PyMac_InitApplet(void); /* Initialize and run an Applet */
Jack Jansen52ac0371997-01-15 15:49:08 +000099void PyMac_Initialize(void); /* Initialize function for embedding Python */
Jack Jansenc84cb951998-04-15 14:12:45 +0000100
Jack Jansenee081042000-04-21 23:53:37 +0000101#ifdef USE_GUSI2
102short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */
103#endif
104
Jack Jansen4e566ab2001-07-08 22:07:23 +0000105/* from macfsmodule.c: */
106int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */
107PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */
108
109int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */
110PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */
111
112
Jack Jansenc84cb951998-04-15 14:12:45 +0000113/* From macfiletype.c: */
114
Jack Jansen9ae898b2000-07-11 21:16:03 +0000115long PyMac_getfiletype(char *); /* Get file type */
116int PyMac_setfiletype(char *, long, long); /* Set file creator and type */
117
118/* from macmain.c: */
119void PyMac_Exit(int);
120void PyMac_InitApplication(void);
Jack Jansen8413b472000-10-19 22:02:16 +0000121void PyMac_OutputSeen(void);
Jack Jansen8a387142001-02-11 01:08:04 +0000122void PyMac_OutputNotSeen(void);
123int PyMac_GetDelayConsoleFlag(void);
Jack Jansen9ae898b2000-07-11 21:16:03 +0000124#ifdef USE_MAC_APPLET_SUPPORT
125void PyMac_InitApplet(void);
126#endif
127
128/* from macgetargv: */
129OSErr PyMac_init_process_location(void);
130#ifndef HAVE_STRDUP
131char * strdup(const char *str);
132#endif
133
Jack Jansenc7fda7e1999-09-30 11:14:49 +0000134#ifdef __cplusplus
135 }
136#endif