1 /***********************************************************
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
7 Permission to use, copy, modify, and distribute this software and its
8 documentation for any purpose and without fee is hereby granted,
9 provided that the above copyright notice appear in all copies and that
10 both that copyright notice and this permission notice appear in
11 supporting documentation, and that the names of Stichting Mathematisch
12 Centrum or CWI not be used in advertising or publicity pertaining to
13 distribution of the software without specific, written prior permission.
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 ******************************************************************/
28 #include <StandardFile.h>
34 /* Scheduler parameters */
36 int check_interrupt
; /* if true check for command-dot */
37 int process_events
; /* if nonzero enable evt processing, this mask */
38 int besocial
; /* Be social, give up CPU now and again */
39 double check_interval
; /* how often to check */
40 double bg_yield
; /* yield at most so long when in background */
43 char *PyMac_getscript(void); /* Get the default encoding for our 8bit character set */
45 void PyMac_FixGUSIcd(void); /* Workaround for GUSI chdir() call */
46 extern void PyMac_SetGUSISpin(void); /* Install our private GUSI spin routine */
49 char *PyMac_StrError(int); /* strerror with mac errors */
50 unsigned char *Pstring(char *str
); /* Convert c-string to pascal-string in static buffer */
53 extern int PyMac_ConsoleIsDead
; /* True when exiting */
54 extern void PyMac_StopGUSISpin(void); /* Stop eventprocessing during exit() */
57 extern short PyMac_AppRefNum
; /* RefNum of application rsrcfork (from macmain.c) */
58 extern FSSpec PyMac_ApplicationFSSpec
; /* Application location (from macargv.c) */
59 extern char PyMac_ApplicationPath
[]; /* Application location (from macargv.c) */
60 extern OSErr
PyMac_init_application_location(void); /* Init the above */
61 extern OSErr
PyMac_GetFullPath(FSSpec
*, char *); /* convert fsspec->path (macargv.c) */
62 extern int PyMac_GetArgv(char ***, int); /* Get argc, argv (from macargv.c) */
63 extern int PyMac_AppearanceCompliant
; /* True if in appearance support mode */
65 extern PyObject
*PyMac_OSErrException
; /* Exception for OSErr */
66 PyObject
*PyMac_GetOSErrException(void); /* Initialize & return it */
68 void PyMac_GetSchedParams(PyMacSchedParams
*); /* Get schedulers params */
69 void PyMac_SetSchedParams(PyMacSchedParams
*); /* Set schedulers params */
70 PyObject
*PyErr_Mac(PyObject
*, int); /* Exception with a mac error */
71 PyObject
*PyMac_Error(OSErr
); /* Uses PyMac_GetOSErrException */
72 int PyMac_DoYield(int, int); /* Yield cpu. First arg is maxtime, second ok to call python */
73 int PyMac_HandleEvent(EventRecord
*); /* Handle one event, possibly in Python */
74 void PyMac_HandleEventIntern(EventRecord
*); /* Handle one event internal only */
75 int PyMac_SetEventHandler(PyObject
*); /* set python-coded event handler */
77 void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */
78 void PyMac_RestoreMenuBar(void); /* Restore menu bar for ease of exiting */
80 int PyMac_FindResourceModule(PyStringObject
*, char *, char *); /* Test for 'PYC ' resource in a file */
81 PyObject
* PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */
82 int PyMac_FindCodeResourceModule(PyStringObject
*, char *, char *); /* Test for 'PYD ' resource in a file */
83 PyObject
* PyMac_LoadCodeResourceModule(char *, char *); /* Load 'PYD ' resource from file */
84 struct filedescr
*PyMac_FindModuleExtension(char *, size_t *, char *); /* Look for module in single folder */
86 #if !TARGET_API_MAC_CARBON
87 int PyMac_GetDirectory(FSSpec
*dirfss
, char *prompt
); /* Ask user for a directory */
88 void PyMac_PromptGetFile(short numTypes
, ConstSFTypeListPtr typeList
,
89 StandardFileReply
*reply
, char *prompt
); /* Ask user for file, with prompt */
90 #endif /* TARGET_API_MAC_CARBON */
92 int PyMac_GetOSType(PyObject
*, OSType
*); /* argument parser for OSType */
93 PyObject
*PyMac_BuildOSType(OSType
); /* Convert OSType to PyObject */
95 PyObject
*PyMac_BuildNumVersion(NumVersion
); /* Convert NumVersion to PyObject */
97 int PyMac_GetStr255(PyObject
*, Str255
); /* argument parser for Str255 */
98 PyObject
*PyMac_BuildStr255(Str255
); /* Convert Str255 to PyObject */
99 PyObject
*PyMac_BuildOptStr255(Str255
); /* Convert Str255 to PyObject, NULL to None */
101 int PyMac_GetFSSpec(PyObject
*, FSSpec
*); /* argument parser for FSSpec */
102 PyObject
*PyMac_BuildFSSpec(FSSpec
*); /* Convert FSSpec to PyObject */
104 int PyMac_GetRect(PyObject
*, Rect
*); /* argument parser for Rect */
105 PyObject
*PyMac_BuildRect(Rect
*); /* Convert Rect to PyObject */
107 int PyMac_GetPoint(PyObject
*, Point
*); /* argument parser for Point */
108 PyObject
*PyMac_BuildPoint(Point
); /* Convert Point to PyObject */
110 int PyMac_GetEventRecord(PyObject
*, EventRecord
*); /* argument parser for EventRecord */
111 PyObject
*PyMac_BuildEventRecord(EventRecord
*); /* Convert EventRecord to PyObject */
113 int PyMac_GetFixed(PyObject
*, Fixed
*); /* argument parser for Fixed */
114 PyObject
*PyMac_BuildFixed(Fixed
); /* Convert Fixed to PyObject */
115 int PyMac_Getwide(PyObject
*, wide
*); /* argument parser for wide */
116 PyObject
*PyMac_Buildwide(wide
*); /* Convert wide to PyObject */
117 void PyMac_InitApplet(void); /* Initialize and run an Applet */
118 void PyMac_Initialize(void); /* Initialize function for embedding Python */
121 short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */
124 /* From macfiletype.c: */
126 long PyMac_getfiletype(char *); /* Get file type */
127 int PyMac_setfiletype(char *, long, long); /* Set file creator and type */
129 /* from macmain.c: */
130 void PyMac_Exit(int);
131 void PyMac_InitApplication(void);
132 #ifdef USE_MAC_APPLET_SUPPORT
133 void PyMac_InitApplet(void);
136 /* from macgetargv: */
137 OSErr
PyMac_init_process_location(void);
139 char * strdup(const char *str
);