Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/ctbmodule.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 91dd223829c6 |
| children | 82309c7325ef |
| 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> |
| 7433 | 35 #include <CTBUtilities.h> |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
36 #include <ToolUtils.h> |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
37 #include <OSUtils.h> |
| 2416 | 38 |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
39 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
40 #define _UnimplementedToolTrap 0xA89F |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
41 #define _CommToolboxTrap 0x8B |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
42 #define _UnimplementedOSTrap 0x9F |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
43 |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
44 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
|
45 "No Error", |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
46 "Rejected", /* 1 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
47 "Failed", /* 2 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
48 "Timeout", /* 3 */ |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
49 "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
|
50 "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
|
51 "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
|
52 "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
|
53 "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
|
54 "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
|
55 "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
|
56 "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
|
57 #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
|
58 }; |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
59 |
| 5071 | 60 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
|
61 |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
62 static PyObject * |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
63 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
|
64 { |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
65 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
|
66 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
|
67 return NULL; |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
68 } else { |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
69 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
|
70 } |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
71 } |
|
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
72 |
| 5071 | 73 static PyObject *ErrorObject; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
74 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
75 typedef struct { |
| 5071 | 76 PyObject_HEAD |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
77 ConnHandle hdl; /* The handle to the connection */ |
| 5071 | 78 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
|
79 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
|
80 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
|
81 } ctbcmobject; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
82 |
| 5071 | 83 staticforward PyTypeObject ctbcmtype; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
84 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 #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
|
86 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
87 static |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
88 TrapAvailable(short tNumber, TrapType tType) |
|
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 short unImplemented; |
|
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 if (tType == OSTrap) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
93 unImplemented = _UnimplementedOSTrap; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
94 else |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
95 unImplemented = _UnimplementedToolTrap; |
|
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 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
|
98 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
99 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
100 static |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
101 initialize_ctb() |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
102 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
103 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
104 static initialized = -1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
105 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
106 if ( initialized >= 0 ) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
107 return initialized; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
108 initialized = 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
109 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
110 if ( !TrapAvailable(_CommToolboxTrap, OSTrap) ) { |
| 5071 | 111 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
|
112 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
113 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
114 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
|
115 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
|
116 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
117 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
118 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
|
119 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
|
120 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
121 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
122 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
|
123 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
|
124 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
125 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
126 initialized = 1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
127 return 1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
128 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
129 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
130 static int |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
131 ctbcm_pycallback(arg) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
132 void *arg; |
|
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 ctbcmobject *self = (ctbcmobject *)arg; |
| 5071 | 135 PyObject *args, *rv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
136 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
137 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
|
138 return 0; |
| 5071 | 139 args = Py_BuildValue("(i)", self->err); |
| 140 rv = PyEval_CallObject(self->callback, args); | |
| 141 Py_DECREF(args); | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
142 if( rv == NULL ) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
143 return -1; |
| 5071 | 144 Py_DECREF(rv); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
145 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
146 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
147 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
148 /*DBG*/int ncallback; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
149 static pascal void |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
150 ctbcm_ctbcallback(hconn) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
151 ConnHandle hconn; |
|
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 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
154 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
155 /* 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
|
156 ncallback++; /*DBG*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
157 self = (ctbcmobject *)CMGetUserData(hconn); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
158 self->err = (int)((*hconn)->errCode); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
159 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
|
160 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
161 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
162 static ctbcmobject * |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
163 newctbcmobject(arg) |
| 5071 | 164 PyObject *arg; |
|
2026
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 ctbcmobject *self; |
| 5071 | 167 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
|
168 if (self == NULL) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
169 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
170 self->hdl = NULL; |
| 5071 | 171 Py_INCREF(Py_None); |
| 172 self->callback = Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
173 self->has_callback = 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
174 return self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
175 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
176 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
177 /* ctbcm methods */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
178 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
179 static void |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
180 ctbcm_dealloc(self) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
181 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
182 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
183 if ( self->hdl ) { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
184 (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
|
185 /*XXXX Is this safe? */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
186 CMDispose(self->hdl); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
187 self->hdl = NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
188 } |
| 5071 | 189 PyMem_DEL(self); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
190 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
191 |
| 5071 | 192 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
193 ctbcm_open(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
194 ctbcmobject *self; |
| 5071 | 195 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
196 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
197 long timeout; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
198 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
199 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
|
200 |
| 5071 | 201 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
|
202 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
|
203 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
|
204 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 205 Py_INCREF(Py_None); |
| 206 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
207 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
208 |
| 5071 | 209 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
210 ctbcm_listen(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
211 ctbcmobject *self; |
| 5071 | 212 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
213 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
214 long timeout; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
215 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
216 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
|
217 |
| 5071 | 218 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
|
219 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
|
220 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
|
221 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 222 Py_INCREF(Py_None); |
| 223 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
224 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
225 |
| 5071 | 226 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
227 ctbcm_accept(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
228 ctbcmobject *self; |
| 5071 | 229 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
230 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
231 int accept; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
232 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
233 |
| 5071 | 234 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
|
235 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
|
236 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
|
237 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 238 Py_INCREF(Py_None); |
| 239 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
240 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
241 |
| 5071 | 242 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
243 ctbcm_close(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
244 ctbcmobject *self; |
| 5071 | 245 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
246 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
247 int now; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
248 long timeout; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
249 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
250 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
|
251 |
| 5071 | 252 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
|
253 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
|
254 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
|
255 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 256 Py_INCREF(Py_None); |
| 257 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
258 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
259 |
| 5071 | 260 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
261 ctbcm_read(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
262 ctbcmobject *self; |
| 5071 | 263 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
264 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
265 long timeout, len; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
266 int chan; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
267 CMFlags flags; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
268 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
|
269 PyObject *rv, *rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
270 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
|
271 |
| 5071 | 272 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
|
273 return NULL; |
| 5071 | 274 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
|
275 return NULL; |
| 5071 | 276 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
|
277 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
|
278 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 279 _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
|
280 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
|
281 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
|
282 return rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
283 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
284 |
| 5071 | 285 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
286 ctbcm_write(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
287 ctbcmobject *self; |
| 5071 | 288 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
289 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
290 long timeout, len; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
291 int chan, ilen, flags; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
292 OSErr err; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
293 char *buf; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
294 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
|
295 |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5257
diff
changeset
|
296 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
|
297 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
298 len = ilen; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
299 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
|
300 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
|
301 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 302 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
|
303 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
304 |
| 5071 | 305 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
306 ctbcm_status(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
307 ctbcmobject *self; |
| 5071 | 308 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
309 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
310 CMBufferSizes sizes; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
311 CMStatFlags flags; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
312 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
|
313 PyObject *rv, *rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
314 |
| 5071 | 315 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
316 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
|
317 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
|
318 return PyCtb_Error(ErrorObject, (int)err); |
| 5071 | 319 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
|
320 if ( rv == NULL ) |
|
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 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
|
323 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
|
324 return rrv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
325 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
326 |
| 5071 | 327 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
328 ctbcm_getconfig(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
329 ctbcmobject *self; |
| 5071 | 330 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
331 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
332 char *rv; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
333 |
| 5071 | 334 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
335 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
336 if ((rv=(char *)CMGetConfig(self->hdl)) == NULL ) { |
| 5071 | 337 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
|
338 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
339 } |
| 5071 | 340 return PyString_FromString(rv); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
341 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
342 |
| 5071 | 343 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
344 ctbcm_setconfig(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
345 ctbcmobject *self; |
| 5071 | 346 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
347 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
348 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
|
349 short rv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
350 |
| 5071 | 351 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
|
352 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
|
353 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
|
354 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
|
355 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
356 |
| 5071 | 357 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
358 ctbcm_choose(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
359 ctbcmobject *self; |
| 5071 | 360 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
361 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
362 int rv; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
363 Point pt; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
364 |
| 5071 | 365 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
366 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
367 pt.v = 40; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
368 pt.h = 40; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
369 rv=CMChoose(&self->hdl, pt, (ConnectionChooseIdleUPP)0); |
| 5071 | 370 return PyInt_FromLong(rv); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
371 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
372 |
| 5071 | 373 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
374 ctbcm_idle(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
375 ctbcmobject *self; |
| 5071 | 376 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
377 { |
| 5071 | 378 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
379 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
380 CMIdle(self->hdl); |
| 5071 | 381 Py_INCREF(Py_None); |
| 382 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
383 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
384 |
| 5071 | 385 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
386 ctbcm_abort(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
387 ctbcmobject *self; |
| 5071 | 388 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
389 { |
| 5071 | 390 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
391 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
392 CMAbort(self->hdl); |
| 5071 | 393 Py_INCREF(Py_None); |
| 394 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
395 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
396 |
| 5071 | 397 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
398 ctbcm_reset(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
399 ctbcmobject *self; |
| 5071 | 400 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
401 { |
| 5071 | 402 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
403 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
404 CMReset(self->hdl); |
| 5071 | 405 Py_INCREF(Py_None); |
| 406 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
407 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
408 |
| 5071 | 409 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
410 ctbcm_break(self, args) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
411 ctbcmobject *self; |
| 5071 | 412 PyObject *args; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
413 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
414 long duration; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
415 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
|
416 |
| 5071 | 417 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
|
418 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
419 CMBreak(self->hdl, duration,self->has_callback, cb_upp); |
| 5071 | 420 Py_INCREF(Py_None); |
| 421 return Py_None; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
422 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
423 |
| 5071 | 424 static struct PyMethodDef ctbcm_methods[] = { |
| 425 {"Open", (PyCFunction)ctbcm_open}, | |
| 426 {"Close", (PyCFunction)ctbcm_close}, | |
| 427 {"Read", (PyCFunction)ctbcm_read}, | |
| 428 {"Write", (PyCFunction)ctbcm_write}, | |
| 429 {"Status", (PyCFunction)ctbcm_status}, | |
| 430 {"GetConfig", (PyCFunction)ctbcm_getconfig}, | |
| 431 {"SetConfig", (PyCFunction)ctbcm_setconfig}, | |
| 432 {"Choose", (PyCFunction)ctbcm_choose}, | |
| 433 {"Idle", (PyCFunction)ctbcm_idle}, | |
| 434 {"Listen", (PyCFunction)ctbcm_listen}, | |
| 435 {"Accept", (PyCFunction)ctbcm_accept}, | |
| 436 {"Abort", (PyCFunction)ctbcm_abort}, | |
| 437 {"Reset", (PyCFunction)ctbcm_reset}, | |
| 438 {"Break", (PyCFunction)ctbcm_break}, | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
439 {NULL, NULL} /* sentinel */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
440 }; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
441 |
| 5071 | 442 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
443 ctbcm_getattr(self, name) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
444 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
445 char *name; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
446 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
447 if ( strcmp(name, "callback") == 0 ) { |
| 5071 | 448 Py_INCREF(self->callback); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
449 return self->callback; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
450 } |
| 5071 | 451 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
|
452 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
453 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
454 static int |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
455 ctbcm_setattr(self, name, v) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
456 ctbcmobject *self; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
457 char *name; |
| 5071 | 458 PyObject *v; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
459 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
460 if ( strcmp(name, "callback") != 0 ) { |
| 5071 | 461 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
|
462 return -1; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
463 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
464 if ( v == NULL ) { |
| 5071 | 465 v = Py_None; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
466 } |
|
5257
81283795f16a
- Most errors are *not* OSErr style, so raise better exceptions (with
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
467 Py_INCREF(v); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
468 self->callback = v; |
| 5071 | 469 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
|
470 return 0; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
471 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
472 |
| 5071 | 473 statichere PyTypeObject ctbcmtype = { |
| 474 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
|
475 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
13609
diff
changeset
|
476 "ctb.CTBConnectionMgr", /*tp_name*/ |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
477 sizeof(ctbcmobject), /*tp_basicsize*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
478 0, /*tp_itemsize*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
479 /* methods */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
480 (destructor)ctbcm_dealloc, /*tp_dealloc*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
481 0, /*tp_print*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
482 (getattrfunc)ctbcm_getattr, /*tp_getattr*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
483 (setattrfunc)ctbcm_setattr, /*tp_setattr*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
484 0, /*tp_compare*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
485 0, /*tp_repr*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
486 0, /*tp_as_number*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
487 0, /*tp_as_sequence*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
488 0, /*tp_as_mapping*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
489 0, /*tp_hash*/ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
490 }; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
491 /* --------------------------------------------------------------------- */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
492 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
493 /* 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
|
494 |
| 5071 | 495 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
496 ctb_cmnew(self, args) |
| 5071 | 497 PyObject *self; /* Not used */ |
| 498 PyObject *args; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
499 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
500 int strlen; |
| 5071 | 501 PyObject *sizes_obj; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
502 char *c_str; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
503 unsigned char p_str[255]; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
504 CMBufferSizes sizes; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
505 short procid; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
506 ConnHandle hdl; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
507 ctbcmobject *rv; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
508 |
| 5071 | 509 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
|
510 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
511 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
|
512 p_str[0] = strlen; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
513 if (!initialize_ctb()) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
514 return NULL; |
| 5071 | 515 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
|
516 memset(sizes, '\0', sizeof sizes); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
517 } else { |
| 5071 | 518 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
|
519 &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
|
520 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
521 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
522 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
|
523 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
|
524 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
|
525 if ( hdl == NULL ) { |
| 5071 | 526 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
|
527 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
528 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
529 rv = newctbcmobject(args); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
530 if ( rv == NULL ) |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
531 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
|
532 rv->hdl = hdl; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
533 CMSetUserData(hdl, (long)rv); |
| 5071 | 534 return (PyObject *)rv; |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
535 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
536 |
| 5071 | 537 static PyObject * |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
538 ctb_available(self, args) |
| 5071 | 539 PyObject *self; |
| 540 PyObject *args; | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
541 { |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
542 int ok; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
543 |
| 5071 | 544 if (!PyArg_NoArgs(args)) |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
545 return NULL; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
546 ok = initialize_ctb(); |
| 5071 | 547 PyErr_Clear(); |
| 548 return PyInt_FromLong(ok); | |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
549 } |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
550 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
551 /* 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
|
552 |
| 5071 | 553 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
|
554 {"CMNew", ctb_cmnew}, |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
555 {"available", ctb_available}, |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
556 {NULL, NULL} /* sentinel */ |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
557 }; |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
558 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
559 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
560 /* 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
|
561 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
562 void |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
563 initctb() |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
564 { |
| 5071 | 565 PyObject *m, *d, *o; |
|
2026
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 /* Create the module and add the functions */ |
| 5071 | 568 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
|
569 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
570 /* Add some symbolic constants to the module */ |
| 5071 | 571 d = PyModule_GetDict(m); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
572 |
| 5071 | 573 #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
|
574 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
575 CMCONST("cmData", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
576 CMCONST("cmCntl", 2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
577 CMCONST("cmAttn", 3); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
578 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
579 CMCONST("cmFlagsEOM", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
580 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
581 CMCONST("chooseDisaster", -2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
582 CMCONST("chooseFailed", -1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
583 CMCONST("chooseAborted", 0); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
584 CMCONST("chooseOKMinor", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
585 CMCONST("chooseOKMajor", 2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
586 CMCONST("chooseCancel", 3); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
587 |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
588 CMCONST("cmStatusOpening", 1); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
589 CMCONST("cmStatusOpen", 2); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
590 CMCONST("cmStatusClosing", 4); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
591 CMCONST("cmStatusDataAvail", 8); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
592 CMCONST("cmStatusCntlAvail", 0x10); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
593 CMCONST("cmStatusAttnAvail", 0x20); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
594 CMCONST("cmStatusDRPend", 0x40); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
595 CMCONST("cmStatusDWPend", 0x80); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
596 CMCONST("cmStatusCWPend", 0x100); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
597 CMCONST("cmStatusCWPend", 0x200); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
598 CMCONST("cmStatusARPend", 0x400); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
599 CMCONST("cmStatusAWPend", 0x800); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
600 CMCONST("cmStatusBreakPending", 0x1000); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
601 CMCONST("cmStatusListenPend", 0x2000); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
602 CMCONST("cmStatusIncomingCallPresent", 0x4000); |
|
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
603 |
| 6442 | 604 ErrorObject = PyErr_NewException("ctb.error", NULL, NULL); |
| 5071 | 605 PyDict_SetItemString(d, "error", ErrorObject); |
|
6330
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
606 ctbcmtype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
607 Py_INCREF(&ctbcmtype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
608 PyDict_SetItemString(d, "CTBConnectionMgrType", (PyObject *)&ctbcmtype); |
|
2026
97d614b24c08
Interface to Mac Communications Toolbox (only Connection Manager for
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
609 } |
