Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/ctbmodule.c @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | ac235c9e6881 |
| children | 172c7febd755 |
| rev | line source |
|---|---|
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1 /*********************************************************** |
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
5071
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
| 2416 | 3 The Netherlands. |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 All Rights Reserved |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
6 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
14 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
22 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
24 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
25 /* Note: This file is partially converted to the new naming standard */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
26 /* ctbcm objects */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
27 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
28 |
| 5071 | 29 #include "Python.h" |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
30 |
| 2416 | 31 #include "macglue.h" |
| 32 | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 #include <CommResources.h> |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
34 #include <Connections.h> |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
35 #include <ToolUtils.h> |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
36 #include <OSUtils.h> |
| 2416 | 37 |
| 38 #ifndef HAVE_UNIVERSAL_HEADERS | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
39 #define ConnectionCompletionUPP ProcPtr |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
40 #define ConnectionChooseIdleUPP ProcPtr |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
41 #define NewConnectionCompletionProc(x) (x) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
42 #define NewConnectionChooseIdleProc(x) (x) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
43 #endif |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
44 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
45 #define _UnimplementedToolTrap 0xA89F |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
46 #define _CommToolboxTrap 0x8B |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
47 #define _UnimplementedOSTrap 0x9F |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
48 |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
49 static char *errornames[] = { |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
50 "No Error", |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
51 "Rejected", /* 1 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
52 "Failed", /* 2 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
53 "Timeout", /* 3 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
54 "Not Open", /* 4 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
55 "Not Closed", /* 5 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
56 "No Request Pending", /* 6 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
57 "Not Supported", /* 7 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
58 "No Tools", /* 8 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
59 "User Cancel", /* 9 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
60 "Error 10", /* 10 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
61 "Unknown Error", /* 11 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
62 #define MAX_POS_ERROR 11 |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
63 }; |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
64 |
| 5071 | 65 extern PyObject *PyErr_Mac(PyObject *,int); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
66 |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
67 static PyObject * |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
68 PyCtb_Error(PyObject *errobj, int errcode) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
69 { |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
70 if ( errcode > 0 && errcode <= MAX_POS_ERROR ) { |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
71 PyErr_SetString(errobj, errornames[errcode]); |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
72 return NULL; |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
73 } else { |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
74 return PyErr_Mac(errobj, errcode); |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
75 } |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
76 } |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
77 |
| 5071 | 78 static PyObject *ErrorObject; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
79 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
80 typedef struct { |
| 5071 | 81 PyObject_HEAD |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
82 ConnHandle hdl; /* The handle to the connection */ |
| 5071 | 83 PyObject *callback; /* Python callback routine */ |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
84 int has_callback; /* True if callback not None */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 int err; /* Error to pass to the callback */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
86 } ctbcmobject; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
87 |
| 5071 | 88 staticforward PyTypeObject ctbcmtype; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
89 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
90 #define is_ctbcmobject(v) ((v)->ob_type == &ctbcmtype) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
91 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
92 static |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
93 TrapAvailable(short tNumber, TrapType tType) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
94 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
95 short unImplemented; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
96 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
97 if (tType == OSTrap) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
98 unImplemented = _UnimplementedOSTrap; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
99 else |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
100 unImplemented = _UnimplementedToolTrap; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
101 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
102 return NGetTrapAddress(tNumber, tType) != NGetTrapAddress(unImplemented, tType); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
103 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
104 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
105 static |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
106 initialize_ctb() |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
107 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
108 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
109 static initialized = -1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
110 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
111 if ( initialized >= 0 ) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
112 return initialized; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
113 initialized = 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
114 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
115 if ( !TrapAvailable(_CommToolboxTrap, OSTrap) ) { |
| 5071 | 116 PyErr_SetString(ErrorObject, "CTB not available"); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
117 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
118 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
119 if ( (err=InitCTBUtilities()) ) { |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
120 PyCtb_Error(ErrorObject, (int)err); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
121 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
122 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
123 if ( (err=InitCRM()) ) { |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
124 PyCtb_Error(ErrorObject, (int)err); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
125 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
126 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
127 if ( (err=InitCM()) ) { |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
128 PyCtb_Error(ErrorObject, (int)err); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
129 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
130 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
131 initialized = 1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
132 return 1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
133 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
134 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
135 static int |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
136 ctbcm_pycallback(arg) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
137 void *arg; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
138 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
139 ctbcmobject *self = (ctbcmobject *)arg; |
| 5071 | 140 PyObject *args, *rv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
141 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
142 if ( !self->has_callback ) /* It could have been removed in the meantime */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
143 return 0; |
| 5071 | 144 args = Py_BuildValue("(i)", self->err); |
| 145 rv = PyEval_CallObject(self->callback, args); | |
| 146 Py_DECREF(args); | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
147 if( rv == NULL ) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
148 return -1; |
| 5071 | 149 Py_DECREF(rv); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
150 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
151 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
152 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
153 /*DBG*/int ncallback; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
154 static pascal void |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
155 ctbcm_ctbcallback(hconn) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
156 ConnHandle hconn; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
157 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
158 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
159 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
160 /* XXXX Do I have to do the A5 mumbo-jumbo? */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
161 ncallback++; /*DBG*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
162 self = (ctbcmobject *)CMGetUserData(hconn); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
163 self->err = (int)((*hconn)->errCode); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
164 Py_AddPendingCall(ctbcm_pycallback, (void *)self); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
165 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
166 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
167 static ctbcmobject * |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
168 newctbcmobject(arg) |
| 5071 | 169 PyObject *arg; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
170 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
171 ctbcmobject *self; |
| 5071 | 172 self = PyObject_NEW(ctbcmobject, &ctbcmtype); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
173 if (self == NULL) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
174 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
175 self->hdl = NULL; |
| 5071 | 176 Py_INCREF(Py_None); |
| 177 self->callback = Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
178 self->has_callback = 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
179 return self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
180 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
181 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
182 /* ctbcm methods */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
183 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
184 static void |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
185 ctbcm_dealloc(self) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
186 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
187 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
188 if ( self->hdl ) { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
189 (void)CMClose(self->hdl, 0, (ConnectionCompletionUPP)0, 0, 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
190 /*XXXX Is this safe? */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
191 CMDispose(self->hdl); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
192 self->hdl = NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
193 } |
| 5071 | 194 PyMem_DEL(self); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
195 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
196 |
| 5071 | 197 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
198 ctbcm_open(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
199 ctbcmobject *self; |
| 5071 | 200 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
201 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
202 long timeout; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
203 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
204 ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
205 |
| 5071 | 206 if (!PyArg_Parse(args, "l", &timeout)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
207 return NULL; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
208 if ( (err=CMOpen(self->hdl, self->has_callback, cb_upp, timeout)) != 0) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
209 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 210 Py_INCREF(Py_None); |
| 211 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
212 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
213 |
| 5071 | 214 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
215 ctbcm_listen(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
216 ctbcmobject *self; |
| 5071 | 217 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
218 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
219 long timeout; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
220 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
221 ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
222 |
| 5071 | 223 if (!PyArg_Parse(args, "l", &timeout)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
224 return NULL; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
225 if ( (err=CMListen(self->hdl,self->has_callback, cb_upp, timeout)) != 0) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
226 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 227 Py_INCREF(Py_None); |
| 228 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
229 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
230 |
| 5071 | 231 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
232 ctbcm_accept(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
233 ctbcmobject *self; |
| 5071 | 234 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
235 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
236 int accept; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
237 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
238 |
| 5071 | 239 if (!PyArg_Parse(args, "i", &accept)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
240 return NULL; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
241 if ( (err=CMAccept(self->hdl, accept)) != 0) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
242 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 243 Py_INCREF(Py_None); |
| 244 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
245 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
246 |
| 5071 | 247 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
248 ctbcm_close(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
249 ctbcmobject *self; |
| 5071 | 250 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
251 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
252 int now; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
253 long timeout; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
254 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
255 ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
256 |
| 5071 | 257 if (!PyArg_Parse(args, "(li)", &timeout, &now)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
258 return NULL; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
259 if ( (err=CMClose(self->hdl, self->has_callback, cb_upp, timeout, now)) != 0) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
260 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 261 Py_INCREF(Py_None); |
| 262 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
263 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
264 |
| 5071 | 265 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
266 ctbcm_read(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
267 ctbcmobject *self; |
| 5071 | 268 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
269 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
270 long timeout, len; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
271 int chan; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
272 CMFlags flags; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
273 OSErr err; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
274 PyObject *rv, *rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
275 ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
276 |
| 5071 | 277 if (!PyArg_Parse(args, "(lil)", &len, &chan, &timeout)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
278 return NULL; |
| 5071 | 279 if ((rv=PyString_FromStringAndSize(NULL, len)) == NULL) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
280 return NULL; |
| 5071 | 281 if ((err=CMRead(self->hdl, (Ptr)PyString_AsString(rv), &len, (CMChannel)chan, |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
282 self->has_callback, cb_upp, timeout, &flags)) != 0 && err != cmTimeOut) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
283 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 284 _PyString_Resize(&rv, len); |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
285 rrv = Py_BuildValue("(Oi)", rv, (int)flags); |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
286 Py_DECREF(rv); |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
287 return rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
288 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
289 |
| 5071 | 290 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
291 ctbcm_write(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
292 ctbcmobject *self; |
| 5071 | 293 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
294 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
295 long timeout, len; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
296 int chan, ilen, flags; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
297 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
298 char *buf; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
299 ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
300 |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5257
diff
changeset
|
301 if (!PyArg_Parse(args, "(s#ili)", &buf, &ilen, &chan, &timeout, &flags)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
302 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
303 len = ilen; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
304 if ((err=CMWrite(self->hdl, (Ptr)buf, &len, (CMChannel)chan, |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
305 self->has_callback, cb_upp, timeout, (CMFlags)flags)) != 0 && err != cmTimeOut) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
306 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 307 return PyInt_FromLong((int)len); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
308 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
309 |
| 5071 | 310 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
311 ctbcm_status(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
312 ctbcmobject *self; |
| 5071 | 313 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
314 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
315 CMBufferSizes sizes; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
316 CMStatFlags flags; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
317 OSErr err; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
318 PyObject *rv, *rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
319 |
| 5071 | 320 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
321 return NULL; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
322 if ((err=CMStatus(self->hdl, sizes, &flags)) != 0) |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
323 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 324 rv = Py_BuildValue("(llllll)", sizes[0], sizes[1], sizes[2], sizes[3], sizes[4], sizes[5]); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
325 if ( rv == NULL ) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
326 return NULL; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
327 rrv = Py_BuildValue("(Ol)", rv, (long)flags); |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
328 Py_DECREF(rv); |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
329 return rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
330 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
331 |
| 5071 | 332 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
333 ctbcm_getconfig(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
334 ctbcmobject *self; |
| 5071 | 335 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
336 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
337 char *rv; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
338 |
| 5071 | 339 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
340 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
341 if ((rv=(char *)CMGetConfig(self->hdl)) == NULL ) { |
| 5071 | 342 PyErr_SetString(ErrorObject, "CMGetConfig failed"); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
343 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
344 } |
| 5071 | 345 return PyString_FromString(rv); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
346 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
347 |
| 5071 | 348 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
349 ctbcm_setconfig(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
350 ctbcmobject *self; |
| 5071 | 351 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
352 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
353 char *cfg; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
354 short rv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
355 |
| 5071 | 356 if (!PyArg_Parse(args, "s", &cfg)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
357 return NULL; |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
358 rv=CMSetConfig(self->hdl, (Ptr)cfg); |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
359 return PyInt_FromLong((long)rv); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
360 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
361 |
| 5071 | 362 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
363 ctbcm_choose(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
364 ctbcmobject *self; |
| 5071 | 365 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
366 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
367 int rv; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
368 Point pt; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
369 |
| 5071 | 370 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
371 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
372 pt.v = 40; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
373 pt.h = 40; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
374 rv=CMChoose(&self->hdl, pt, (ConnectionChooseIdleUPP)0); |
| 5071 | 375 return PyInt_FromLong(rv); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
376 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
377 |
| 5071 | 378 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
379 ctbcm_idle(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
380 ctbcmobject *self; |
| 5071 | 381 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
382 { |
| 5071 | 383 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
384 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
385 CMIdle(self->hdl); |
| 5071 | 386 Py_INCREF(Py_None); |
| 387 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
388 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
389 |
| 5071 | 390 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
391 ctbcm_abort(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
392 ctbcmobject *self; |
| 5071 | 393 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
394 { |
| 5071 | 395 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
396 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
397 CMAbort(self->hdl); |
| 5071 | 398 Py_INCREF(Py_None); |
| 399 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
400 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
401 |
| 5071 | 402 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
403 ctbcm_reset(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
404 ctbcmobject *self; |
| 5071 | 405 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
406 { |
| 5071 | 407 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
408 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
409 CMReset(self->hdl); |
| 5071 | 410 Py_INCREF(Py_None); |
| 411 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
412 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
413 |
| 5071 | 414 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
415 ctbcm_break(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
416 ctbcmobject *self; |
| 5071 | 417 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
418 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
419 long duration; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
420 ConnectionCompletionUPP cb_upp = NewConnectionCompletionProc(ctbcm_ctbcallback); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
421 |
| 5071 | 422 if (!PyArg_Parse(args, "l", &duration)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
423 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
424 CMBreak(self->hdl, duration,self->has_callback, cb_upp); |
| 5071 | 425 Py_INCREF(Py_None); |
| 426 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
427 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
428 |
| 5071 | 429 static struct PyMethodDef ctbcm_methods[] = { |
| 430 {"Open", (PyCFunction)ctbcm_open}, | |
| 431 {"Close", (PyCFunction)ctbcm_close}, | |
| 432 {"Read", (PyCFunction)ctbcm_read}, | |
| 433 {"Write", (PyCFunction)ctbcm_write}, | |
| 434 {"Status", (PyCFunction)ctbcm_status}, | |
| 435 {"GetConfig", (PyCFunction)ctbcm_getconfig}, | |
| 436 {"SetConfig", (PyCFunction)ctbcm_setconfig}, | |
| 437 {"Choose", (PyCFunction)ctbcm_choose}, | |
| 438 {"Idle", (PyCFunction)ctbcm_idle}, | |
| 439 {"Listen", (PyCFunction)ctbcm_listen}, | |
| 440 {"Accept", (PyCFunction)ctbcm_accept}, | |
| 441 {"Abort", (PyCFunction)ctbcm_abort}, | |
| 442 {"Reset", (PyCFunction)ctbcm_reset}, | |
| 443 {"Break", (PyCFunction)ctbcm_break}, | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
444 {NULL, NULL} /* sentinel */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
445 }; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
446 |
| 5071 | 447 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
448 ctbcm_getattr(self, name) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
449 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
450 char *name; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
451 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
452 if ( strcmp(name, "callback") == 0 ) { |
| 5071 | 453 Py_INCREF(self->callback); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
454 return self->callback; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
455 } |
| 5071 | 456 return Py_FindMethod(ctbcm_methods, (PyObject *)self, name); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
457 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
458 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
459 static int |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
460 ctbcm_setattr(self, name, v) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
461 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
462 char *name; |
| 5071 | 463 PyObject *v; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
464 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
465 if ( strcmp(name, "callback") != 0 ) { |
| 5071 | 466 PyErr_SetString(PyExc_AttributeError, "ctbcm objects have callback attr only"); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
467 return -1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
468 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
469 if ( v == NULL ) { |
| 5071 | 470 v = Py_None; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
471 } |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
472 Py_INCREF(v); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
473 self->callback = v; |
| 5071 | 474 self->has_callback = (v != Py_None); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
475 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
476 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
477 |
| 5071 | 478 statichere PyTypeObject ctbcmtype = { |
| 479 PyObject_HEAD_INIT(&PyType_Type) | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
480 0, /*ob_size*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
481 "ctbcm", /*tp_name*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
482 sizeof(ctbcmobject), /*tp_basicsize*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
483 0, /*tp_itemsize*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
484 /* methods */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
485 (destructor)ctbcm_dealloc, /*tp_dealloc*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
486 0, /*tp_print*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
487 (getattrfunc)ctbcm_getattr, /*tp_getattr*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
488 (setattrfunc)ctbcm_setattr, /*tp_setattr*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
489 0, /*tp_compare*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
490 0, /*tp_repr*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
491 0, /*tp_as_number*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
492 0, /*tp_as_sequence*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
493 0, /*tp_as_mapping*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
494 0, /*tp_hash*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
495 }; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
496 /* --------------------------------------------------------------------- */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
497 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
498 /* Function of no arguments returning new ctbcm object */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
499 |
| 5071 | 500 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
501 ctb_cmnew(self, args) |
| 5071 | 502 PyObject *self; /* Not used */ |
| 503 PyObject *args; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
504 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
505 int strlen; |
| 5071 | 506 PyObject *sizes_obj; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
507 char *c_str; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
508 unsigned char p_str[255]; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
509 CMBufferSizes sizes; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
510 short procid; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
511 ConnHandle hdl; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
512 ctbcmobject *rv; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
513 |
| 5071 | 514 if (!PyArg_Parse(args, "(s#O)", &c_str, &strlen, &sizes_obj)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
515 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
516 strncpy((char *)p_str+1, c_str, strlen); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
517 p_str[0] = strlen; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
518 if (!initialize_ctb()) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
519 return NULL; |
| 5071 | 520 if ( sizes_obj == Py_None ) { |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
521 memset(sizes, '\0', sizeof sizes); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
522 } else { |
| 5071 | 523 if ( !PyArg_Parse(sizes_obj, "(llllll)", &sizes[0], &sizes[1], &sizes[2], |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
524 &sizes[3], &sizes[4], &sizes[5])) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
525 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
526 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
527 if ( (procid=CMGetProcID(p_str)) < 0 ) |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
528 return PyCtb_Error(ErrorObject, procid); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
529 hdl = CMNew(procid, cmNoMenus|cmQuiet, sizes, 0, 0); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
530 if ( hdl == NULL ) { |
| 5071 | 531 PyErr_SetString(ErrorObject, "CMNew failed"); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
532 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
533 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
534 rv = newctbcmobject(args); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
535 if ( rv == NULL ) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
536 return NULL; /* XXXX Should dispose of hdl */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
537 rv->hdl = hdl; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
538 CMSetUserData(hdl, (long)rv); |
| 5071 | 539 return (PyObject *)rv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
540 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
541 |
| 5071 | 542 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
543 ctb_available(self, args) |
| 5071 | 544 PyObject *self; |
| 545 PyObject *args; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
546 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
547 int ok; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
548 |
| 5071 | 549 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
550 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
551 ok = initialize_ctb(); |
| 5071 | 552 PyErr_Clear(); |
| 553 return PyInt_FromLong(ok); | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
554 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
555 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
556 /* List of functions defined in the module */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
557 |
| 5071 | 558 static struct PyMethodDef ctb_methods[] = { |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
559 {"CMNew", ctb_cmnew}, |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
560 {"available", ctb_available}, |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
561 {NULL, NULL} /* sentinel */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
562 }; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
563 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
564 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
565 /* Initialization function for the module (*must* be called initctb) */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
566 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
567 void |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
568 initctb() |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
569 { |
| 5071 | 570 PyObject *m, *d, *o; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
571 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
572 /* Create the module and add the functions */ |
| 5071 | 573 m = Py_InitModule("ctb", ctb_methods); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
574 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
575 /* Add some symbolic constants to the module */ |
| 5071 | 576 d = PyModule_GetDict(m); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
577 |
| 5071 | 578 #define CMCONST(name, value) o = PyInt_FromLong(value); PyDict_SetItemString(d, name, o) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
579 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
580 CMCONST("cmData", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
581 CMCONST("cmCntl", 2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
582 CMCONST("cmAttn", 3); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
583 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
584 CMCONST("cmFlagsEOM", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
585 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
586 CMCONST("chooseDisaster", -2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
587 CMCONST("chooseFailed", -1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
588 CMCONST("chooseAborted", 0); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
589 CMCONST("chooseOKMinor", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
590 CMCONST("chooseOKMajor", 2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
591 CMCONST("chooseCancel", 3); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
592 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
593 CMCONST("cmStatusOpening", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
594 CMCONST("cmStatusOpen", 2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
595 CMCONST("cmStatusClosing", 4); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
596 CMCONST("cmStatusDataAvail", 8); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
597 CMCONST("cmStatusCntlAvail", 0x10); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
598 CMCONST("cmStatusAttnAvail", 0x20); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
599 CMCONST("cmStatusDRPend", 0x40); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
600 CMCONST("cmStatusDWPend", 0x80); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
601 CMCONST("cmStatusCWPend", 0x100); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
602 CMCONST("cmStatusCWPend", 0x200); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
603 CMCONST("cmStatusARPend", 0x400); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
604 CMCONST("cmStatusAWPend", 0x800); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
605 CMCONST("cmStatusBreakPending", 0x1000); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
606 CMCONST("cmStatusListenPend", 0x2000); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
607 CMCONST("cmStatusIncomingCallPresent", 0x4000); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
608 |
| 5071 | 609 ErrorObject = PyString_FromString("ctb.error"); |
| 610 PyDict_SetItemString(d, "error", ErrorObject); | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
611 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
612 /* Check for errors */ |
| 5071 | 613 if (PyErr_Occurred()) |
| 614 Py_FatalError("can't initialize module ctb"); | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
615 } |
