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