annotate Modules/cdmodule.c @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents fd25030223b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* CD module -- interface to Mark Callow's and Roger Chickering's */
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* CD Audio Library (CD). */
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 #include <sys/types.h>
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #include <cdaudio.h>
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
6 #include "Python.h"
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
8 #define NCALLBACKS 8
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 typedef struct {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
11 PyObject_HEAD
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
12 CDPLAYER *ob_cdplayer;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 } cdplayerobject;
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
15 static PyObject *CdError; /* exception cd.error */
1063
aaa3bccb143a Defined exception cd.error which is used for errors other than
Sjoerd Mullender <sjoerd@acm.org>
parents: 926
diff changeset
16
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
17 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
18 CD_allowremoval(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
20 if (!PyArg_ParseTuple(args, ":allowremoval"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
21 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
23 CDallowremoval(self->ob_cdplayer);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
25 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
26 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
29 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
30 CD_preventremoval(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
32 if (!PyArg_ParseTuple(args, ":preventremoval"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
33 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
34
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
35 CDpreventremoval(self->ob_cdplayer);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
37 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
38 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
41 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
42 CD_bestreadsize(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
44 if (!PyArg_ParseTuple(args, ":bestreadsize"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
45 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
47 return PyInt_FromLong((long) CDbestreadsize(self->ob_cdplayer));
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
50 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
51 CD_close(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
53 if (!PyArg_ParseTuple(args, ":close"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
54 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
56 if (!CDclose(self->ob_cdplayer)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
57 PyErr_SetFromErrno(CdError); /* XXX - ??? */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
58 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
59 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
60 self->ob_cdplayer = NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
61
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
62 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
63 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
65
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
66 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
67 CD_eject(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
69 CDSTATUS status;
849
fe6a5f2640a2 Wanneer er geen disk in de speler zit falen sommige routines. De
Guido van Rossum <guido@python.org>
parents: 848
diff changeset
70
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
71 if (!PyArg_ParseTuple(args, ":eject"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
72 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
73
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
74 if (!CDeject(self->ob_cdplayer)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
75 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
76 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
77 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
78 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
79 PyErr_SetString(CdError, "eject failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
80 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
81 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
83 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
84 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
86
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
87 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
88 CD_getstatus(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
90 CDSTATUS status;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
91
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
92 if (!PyArg_ParseTuple(args, ":getstatus"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
93 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
94
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
95 if (!CDgetstatus(self->ob_cdplayer, &status)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
96 PyErr_SetFromErrno(CdError); /* XXX - ??? */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
97 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
98 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
99
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
100 return Py_BuildValue("(ii(iii)(iii)(iii)iiii)", status.state,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
101 status.track, status.min, status.sec, status.frame,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
102 status.abs_min, status.abs_sec, status.abs_frame,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
103 status.total_min, status.total_sec, status.total_frame,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
104 status.first, status.last, status.scsi_audio,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
105 status.cur_block);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
107
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
108 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
109 CD_gettrackinfo(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
111 int track;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
112 CDTRACKINFO info;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
113 CDSTATUS status;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
114
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
115 if (!PyArg_ParseTuple(args, "i:gettrackinfo", &track))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
116 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
118 if (!CDgettrackinfo(self->ob_cdplayer, track, &info)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
119 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
120 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
121 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
122 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
123 PyErr_SetString(CdError, "gettrackinfo failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
124 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
125 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
126
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
127 return Py_BuildValue("((iii)(iii))",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
128 info.start_min, info.start_sec, info.start_frame,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
129 info.total_min, info.total_sec, info.total_frame);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
130 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
131
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
132 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
133 CD_msftoblock(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
135 int min, sec, frame;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
136
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
137 if (!PyArg_ParseTuple(args, "iii:msftoblock", &min, &sec, &frame))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
138 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
139
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
140 return PyInt_FromLong((long) CDmsftoblock(self->ob_cdplayer,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
141 min, sec, frame));
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
143
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
144 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
145 CD_play(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
147 int start, play;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
148 CDSTATUS status;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
149
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
150 if (!PyArg_ParseTuple(args, "ii:play", &start, &play))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
151 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
152
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
153 if (!CDplay(self->ob_cdplayer, start, play)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
154 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
155 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
156 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
157 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
158 PyErr_SetString(CdError, "play failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
159 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
160 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
161
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
162 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
163 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
165
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
166 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
167 CD_playabs(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
169 int min, sec, frame, play;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
170 CDSTATUS status;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
171
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
172 if (!PyArg_ParseTuple(args, "iiii:playabs", &min, &sec, &frame, &play))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
173 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
174
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
175 if (!CDplayabs(self->ob_cdplayer, min, sec, frame, play)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
176 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
177 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
178 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
179 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
180 PyErr_SetString(CdError, "playabs failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
181 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
182 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
183
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
184 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
185 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
186 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
187
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
188 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
189 CD_playtrack(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
190 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
191 int start, play;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
192 CDSTATUS status;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
193
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
194 if (!PyArg_ParseTuple(args, "ii:playtrack", &start, &play))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
195 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
196
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
197 if (!CDplaytrack(self->ob_cdplayer, start, play)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
198 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
199 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
200 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
201 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
202 PyErr_SetString(CdError, "playtrack failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
203 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
204 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
205
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
206 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
207 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
208 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
209
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
210 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
211 CD_playtrackabs(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
212 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
213 int track, min, sec, frame, play;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
214 CDSTATUS status;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
215
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
216 if (!PyArg_ParseTuple(args, "iiiii:playtrackabs", &track, &min, &sec,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
217 &frame, &play))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
218 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
219
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
220 if (!CDplaytrackabs(self->ob_cdplayer, track, min, sec, frame, play)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
221 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
222 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
223 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
224 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
225 PyErr_SetString(CdError, "playtrackabs failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
226 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
227 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
228
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
229 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
230 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
231 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
232
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
233 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
234 CD_readda(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
235 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
236 int numframes, n;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
237 PyObject *result;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
238
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
239 if (!PyArg_ParseTuple(args, "i:readda", &numframes))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
240 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
241
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
242 result = PyString_FromStringAndSize(NULL, numframes * sizeof(CDFRAME));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
243 if (result == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
244 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
245
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
246 n = CDreadda(self->ob_cdplayer,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
247 (CDFRAME *) PyString_AsString(result), numframes);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
248 if (n == -1) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
249 Py_DECREF(result);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
250 PyErr_SetFromErrno(CdError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
251 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
252 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
253 if (n < numframes)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
254 _PyString_Resize(&result, n * sizeof(CDFRAME));
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
255
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
256 return result;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
257 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
258
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
259 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
260 CD_seek(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
261 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
262 int min, sec, frame;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
263 long PyTryBlock;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
264
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
265 if (!PyArg_ParseTuple(args, "iii:seek", &min, &sec, &frame))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
266 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
267
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
268 PyTryBlock = CDseek(self->ob_cdplayer, min, sec, frame);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
269 if (PyTryBlock == -1) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
270 PyErr_SetFromErrno(CdError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
271 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
272 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
273
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
274 return PyInt_FromLong(PyTryBlock);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
275 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
276
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
277 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
278 CD_seektrack(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
279 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
280 int track;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
281 long PyTryBlock;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
282
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
283 if (!PyArg_ParseTuple(args, "i:seektrack", &track))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
284 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
285
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
286 PyTryBlock = CDseektrack(self->ob_cdplayer, track);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
287 if (PyTryBlock == -1) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
288 PyErr_SetFromErrno(CdError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
289 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
290 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
291
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
292 return PyInt_FromLong(PyTryBlock);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
293 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
294
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
295 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
296 CD_seekblock(cdplayerobject *self, PyObject *args)
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
297 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
298 unsigned long PyTryBlock;
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
299
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
300 if (!PyArg_ParseTuple(args, "l:seekblock", &PyTryBlock))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
301 return NULL;
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
302
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
303 PyTryBlock = CDseekblock(self->ob_cdplayer, PyTryBlock);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
304 if (PyTryBlock == (unsigned long) -1) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
305 PyErr_SetFromErrno(CdError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
306 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
307 }
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
308
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
309 return PyInt_FromLong(PyTryBlock);
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
310 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
311
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
312 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
313 CD_stop(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
314 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
315 CDSTATUS status;
849
fe6a5f2640a2 Wanneer er geen disk in de speler zit falen sommige routines. De
Guido van Rossum <guido@python.org>
parents: 848
diff changeset
316
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
317 if (!PyArg_ParseTuple(args, ":stop"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
318 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
319
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
320 if (!CDstop(self->ob_cdplayer)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
321 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
322 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
323 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
324 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
325 PyErr_SetString(CdError, "stop failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
326 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
327 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
328
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
329 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
330 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
331 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
332
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
333 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
334 CD_togglepause(cdplayerobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
335 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
336 CDSTATUS status;
849
fe6a5f2640a2 Wanneer er geen disk in de speler zit falen sommige routines. De
Guido van Rossum <guido@python.org>
parents: 848
diff changeset
337
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
338 if (!PyArg_ParseTuple(args, ":togglepause"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
339 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
340
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
341 if (!CDtogglepause(self->ob_cdplayer)) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
342 if (CDgetstatus(self->ob_cdplayer, &status) &&
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
343 status.state == CD_NODISC)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
344 PyErr_SetString(CdError, "no disc in player");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
345 else
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
346 PyErr_SetString(CdError, "togglepause failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
347 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
348 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
349
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
350 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
351 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
352 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
353
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
354 static PyMethodDef cdplayer_methods[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
355 {"allowremoval", (PyCFunction)CD_allowremoval, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
356 {"bestreadsize", (PyCFunction)CD_bestreadsize, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
357 {"close", (PyCFunction)CD_close, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
358 {"eject", (PyCFunction)CD_eject, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
359 {"getstatus", (PyCFunction)CD_getstatus, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
360 {"gettrackinfo", (PyCFunction)CD_gettrackinfo, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
361 {"msftoblock", (PyCFunction)CD_msftoblock, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
362 {"play", (PyCFunction)CD_play, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
363 {"playabs", (PyCFunction)CD_playabs, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
364 {"playtrack", (PyCFunction)CD_playtrack, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
365 {"playtrackabs", (PyCFunction)CD_playtrackabs, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
366 {"preventremoval", (PyCFunction)CD_preventremoval, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
367 {"readda", (PyCFunction)CD_readda, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
368 {"seek", (PyCFunction)CD_seek, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
369 {"seekblock", (PyCFunction)CD_seekblock, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
370 {"seektrack", (PyCFunction)CD_seektrack, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
371 {"stop", (PyCFunction)CD_stop, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
372 {"togglepause", (PyCFunction)CD_togglepause, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
373 {NULL, NULL} /* sentinel */
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
374 };
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
375
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
376 static void
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
377 cdplayer_dealloc(cdplayerobject *self)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
378 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
379 if (self->ob_cdplayer != NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
380 CDclose(self->ob_cdplayer);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
381 PyObject_Del(self);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
382 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
383
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
384 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
385 cdplayer_getattr(cdplayerobject *self, char *name)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
386 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
387 if (self->ob_cdplayer == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
388 PyErr_SetString(PyExc_RuntimeError, "no player active");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
389 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
390 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
391 return Py_FindMethod(cdplayer_methods, (PyObject *)self, name);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
392 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
393
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
394 PyTypeObject CdPlayertype = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
395 PyObject_HEAD_INIT(&PyType_Type)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
396 0, /*ob_size*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
397 "cd.cdplayer", /*tp_name*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
398 sizeof(cdplayerobject), /*tp_size*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
399 0, /*tp_itemsize*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
400 /* methods */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
401 (destructor)cdplayer_dealloc, /*tp_dealloc*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
402 0, /*tp_print*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
403 (getattrfunc)cdplayer_getattr, /*tp_getattr*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
404 0, /*tp_setattr*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
405 0, /*tp_compare*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
406 0, /*tp_repr*/
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
407 };
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
408
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
409 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
410 newcdplayerobject(CDPLAYER *cdp)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
411 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
412 cdplayerobject *p;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
413
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
414 p = PyObject_New(cdplayerobject, &CdPlayertype);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
415 if (p == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
416 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
417 p->ob_cdplayer = cdp;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
418 return (PyObject *) p;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
419 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
420
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
421 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
422 CD_open(PyObject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
423 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
424 char *dev, *direction;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
425 CDPLAYER *cdp;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
426
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
427 /*
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
428 * Variable number of args.
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
429 * First defaults to "None", second defaults to "r".
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
430 */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
431 dev = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
432 direction = "r";
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
433 if (!PyArg_ParseTuple(args, "|zs:open", &dev, &direction))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
434 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
435
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
436 cdp = CDopen(dev, direction);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
437 if (cdp == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
438 PyErr_SetFromErrno(CdError);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
439 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
440 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
441
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
442 return newcdplayerobject(cdp);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
443 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
444
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
445 typedef struct {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
446 PyObject_HEAD
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
447 CDPARSER *ob_cdparser;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
448 struct {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
449 PyObject *ob_cdcallback;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
450 PyObject *ob_cdcallbackarg;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
451 } ob_cdcallbacks[NCALLBACKS];
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
452 } cdparserobject;
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
453
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
454 static void
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
455 CD_callback(void *arg, CDDATATYPES type, void *data)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
456 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
457 PyObject *result, *args, *v = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
458 char *p;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
459 int i;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
460 cdparserobject *self;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
461
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
462 self = (cdparserobject *) arg;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
463 args = PyTuple_New(3);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
464 if (args == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
465 return;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
466 Py_INCREF(self->ob_cdcallbacks[type].ob_cdcallbackarg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
467 PyTuple_SetItem(args, 0, self->ob_cdcallbacks[type].ob_cdcallbackarg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
468 PyTuple_SetItem(args, 1, PyInt_FromLong((long) type));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
469 switch (type) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
470 case cd_audio:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
471 v = PyString_FromStringAndSize(data, CDDA_DATASIZE);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
472 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
473 case cd_pnum:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
474 case cd_index:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
475 v = PyInt_FromLong(((CDPROGNUM *) data)->value);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
476 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
477 case cd_ptime:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
478 case cd_atime:
830
ea5072de7427 Return more structured data in some cases
Guido van Rossum <guido@python.org>
parents: 820
diff changeset
479 #define ptr ((struct cdtimecode *) data)
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
480 v = Py_BuildValue("(iii)",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
481 ptr->mhi * 10 + ptr->mlo,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
482 ptr->shi * 10 + ptr->slo,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
483 ptr->fhi * 10 + ptr->flo);
830
ea5072de7427 Return more structured data in some cases
Guido van Rossum <guido@python.org>
parents: 820
diff changeset
484 #undef ptr
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
485 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
486 case cd_catalog:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
487 v = PyString_FromStringAndSize(NULL, 13);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
488 p = PyString_AsString(v);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
489 for (i = 0; i < 13; i++)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
490 *p++ = ((char *) data)[i] + '0';
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
491 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
492 case cd_ident:
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
493 #define ptr ((struct cdident *) data)
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
494 v = PyString_FromStringAndSize(NULL, 12);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
495 p = PyString_AsString(v);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
496 CDsbtoa(p, ptr->country, 2);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
497 p += 2;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
498 CDsbtoa(p, ptr->owner, 3);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
499 p += 3;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
500 *p++ = ptr->year[0] + '0';
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
501 *p++ = ptr->year[1] + '0';
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
502 *p++ = ptr->serial[0] + '0';
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
503 *p++ = ptr->serial[1] + '0';
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
504 *p++ = ptr->serial[2] + '0';
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
505 *p++ = ptr->serial[3] + '0';
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
506 *p++ = ptr->serial[4] + '0';
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
507 #undef ptr
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
508 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
509 case cd_control:
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
510 v = PyInt_FromLong((long) *((unchar *) data));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
511 break;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
512 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
513 PyTuple_SetItem(args, 2, v);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
514 if (PyErr_Occurred()) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
515 Py_DECREF(args);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
516 return;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
517 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
518
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
519 result = PyEval_CallObject(self->ob_cdcallbacks[type].ob_cdcallback,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
520 args);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
521 Py_DECREF(args);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
522 Py_XDECREF(result);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
523 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
524
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
525 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
526 CD_deleteparser(cdparserobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
527 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
528 int i;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
529
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
530 if (!PyArg_ParseTuple(args, ":deleteparser"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
531 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
532
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
533 CDdeleteparser(self->ob_cdparser);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
534 self->ob_cdparser = NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
535
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
536 /* no sense in keeping the callbacks, so remove them */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
537 for (i = 0; i < NCALLBACKS; i++) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
538 Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
539 self->ob_cdcallbacks[i].ob_cdcallback = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
540 Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
541 self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
542 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
543
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
544 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
545 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
546 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
547
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
548 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
549 CD_parseframe(cdparserobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
550 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
551 char *cdfp;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
552 int length;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
553 CDFRAME *p;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
554
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
555 if (!PyArg_ParseTuple(args, "s#:parseframe", &cdfp, &length))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
556 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
557
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
558 if (length % sizeof(CDFRAME) != 0) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
559 PyErr_SetString(PyExc_TypeError, "bad length");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
560 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
561 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
562
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
563 p = (CDFRAME *) cdfp;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
564 while (length > 0) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
565 CDparseframe(self->ob_cdparser, p);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
566 length -= sizeof(CDFRAME);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
567 p++;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
568 if (PyErr_Occurred())
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
569 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
570 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
571
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
572 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
573 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
574 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
575
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
576 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
577 CD_removecallback(cdparserobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
578 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
579 int type;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
580
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
581 if (!PyArg_ParseTuple(args, "i:removecallback", &type))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
582 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
583
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
584 if (type < 0 || type >= NCALLBACKS) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
585 PyErr_SetString(PyExc_TypeError, "bad type");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
586 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
587 }
921
8078834996ec cdmodule.c: 2 minor changes by Sjoerd.
Guido van Rossum <guido@python.org>
parents: 849
diff changeset
588
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
589 CDremovecallback(self->ob_cdparser, (CDDATATYPES) type);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
590
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
591 Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallback);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
592 self->ob_cdcallbacks[type].ob_cdcallback = NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
593
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
594 Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
595 self->ob_cdcallbacks[type].ob_cdcallbackarg = NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
596
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
597 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
598 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
599 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
600
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
601 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
602 CD_resetparser(cdparserobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
603 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
604 if (!PyArg_ParseTuple(args, ":resetparser"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
605 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
606
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
607 CDresetparser(self->ob_cdparser);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
608
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
609 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
610 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
611 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
612
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
613 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
614 CD_addcallback(cdparserobject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
615 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
616 int type;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
617 PyObject *func, *funcarg;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
618
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
619 /* XXX - more work here */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
620 if (!PyArg_ParseTuple(args, "iOO:addcallback", &type, &func, &funcarg))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
621 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
622
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
623 if (type < 0 || type >= NCALLBACKS) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
624 PyErr_SetString(PyExc_TypeError, "argument out of range");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
625 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
626 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
627
1071
2291da05f178 Changed an ifdef from IRIX_405 to CDsetcallback.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1063
diff changeset
628 #ifdef CDsetcallback
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
629 CDaddcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
630 (void *) self);
921
8078834996ec cdmodule.c: 2 minor changes by Sjoerd.
Guido van Rossum <guido@python.org>
parents: 849
diff changeset
631 #else
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
632 CDsetcallback(self->ob_cdparser, (CDDATATYPES) type, CD_callback,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
633 (void *) self);
921
8078834996ec cdmodule.c: 2 minor changes by Sjoerd.
Guido van Rossum <guido@python.org>
parents: 849
diff changeset
634 #endif
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
635 Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallback);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
636 Py_INCREF(func);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
637 self->ob_cdcallbacks[type].ob_cdcallback = func;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
638 Py_XDECREF(self->ob_cdcallbacks[type].ob_cdcallbackarg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
639 Py_INCREF(funcarg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
640 self->ob_cdcallbacks[type].ob_cdcallbackarg = funcarg;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
641
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
642 /*
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
643 if (type == cd_audio) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
644 sigfpe_[_UNDERFL].repls = _ZERO;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
645 handle_sigfpes(_ON, _EN_UNDERFL, NULL,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
646 _ABORT_ON_ERROR, NULL);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
647 }
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
648 */
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
649
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
650 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
651 return Py_None;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
652 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
653
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
654 static PyMethodDef cdparser_methods[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
655 {"addcallback", (PyCFunction)CD_addcallback, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
656 {"deleteparser", (PyCFunction)CD_deleteparser, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
657 {"parseframe", (PyCFunction)CD_parseframe, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
658 {"removecallback", (PyCFunction)CD_removecallback, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
659 {"resetparser", (PyCFunction)CD_resetparser, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
660 /* backward compatibility */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
661 {"setcallback", (PyCFunction)CD_addcallback, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
662 {NULL, NULL} /* sentinel */
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
663 };
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
664
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
665 static void
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
666 cdparser_dealloc(cdparserobject *self)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
667 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
668 int i;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
669
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
670 for (i = 0; i < NCALLBACKS; i++) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
671 Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallback);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
672 self->ob_cdcallbacks[i].ob_cdcallback = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
673 Py_XDECREF(self->ob_cdcallbacks[i].ob_cdcallbackarg);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
674 self->ob_cdcallbacks[i].ob_cdcallbackarg = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
675 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
676 CDdeleteparser(self->ob_cdparser);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
677 PyObject_Del(self);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
678 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
679
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
680 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
681 cdparser_getattr(cdparserobject *self, char *name)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
682 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
683 if (self->ob_cdparser == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
684 PyErr_SetString(PyExc_RuntimeError, "no parser active");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
685 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
686 }
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
687
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
688 return Py_FindMethod(cdparser_methods, (PyObject *)self, name);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
689 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
690
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
691 PyTypeObject CdParsertype = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
692 PyObject_HEAD_INIT(&PyType_Type)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
693 0, /*ob_size*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
694 "cd.cdparser", /*tp_name*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
695 sizeof(cdparserobject), /*tp_size*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
696 0, /*tp_itemsize*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
697 /* methods */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
698 (destructor)cdparser_dealloc, /*tp_dealloc*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
699 0, /*tp_print*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
700 (getattrfunc)cdparser_getattr, /*tp_getattr*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
701 0, /*tp_setattr*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
702 0, /*tp_compare*/
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
703 0, /*tp_repr*/
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
704 };
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
705
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
706 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
707 newcdparserobject(CDPARSER *cdp)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
708 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
709 cdparserobject *p;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
710 int i;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
711
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
712 p = PyObject_New(cdparserobject, &CdParsertype);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
713 if (p == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
714 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
715 p->ob_cdparser = cdp;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
716 for (i = 0; i < NCALLBACKS; i++) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
717 p->ob_cdcallbacks[i].ob_cdcallback = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
718 p->ob_cdcallbacks[i].ob_cdcallbackarg = NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
719 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
720 return (PyObject *) p;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
721 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
722
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
723 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
724 CD_createparser(PyObject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
725 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
726 CDPARSER *cdp;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
727
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
728 if (!PyArg_ParseTuple(args, ":createparser"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
729 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
730 cdp = CDcreateparser();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
731 if (cdp == NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
732 PyErr_SetString(CdError, "createparser failed");
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
733 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
734 }
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
735
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
736 return newcdparserobject(cdp);
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
737 }
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
738
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
739 static PyObject *
13514
5304b88fe3cc ANSI-fication of the SGI modules (note that svmodule.c and sgimodule.c
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
740 CD_msftoframe(PyObject *self, PyObject *args)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
741 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
742 int min, sec, frame;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
743
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
744 if (!PyArg_ParseTuple(args, "iii:msftoframe", &min, &sec, &frame))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
745 return NULL;
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
746
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
747 return PyInt_FromLong((long) CDmsftoframe(min, sec, frame));
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
748 }
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
749
4892
1c089c5b66e9 Renamed but not well tested.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
750 static PyMethodDef CD_methods[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
751 {"open", (PyCFunction)CD_open, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
752 {"createparser", (PyCFunction)CD_createparser, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
753 {"msftoframe", (PyCFunction)CD_msftoframe, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
754 {NULL, NULL} /* Sentinel */
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
755 };
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
756
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
757 void
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13514
diff changeset
758 initcd(void)
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
759 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
760 PyObject *m, *d;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
761
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
762 if (PyErr_WarnPy3k("the cd module has been removed in "
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
763 "Python 3.0", 2) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
764 return;
1063
aaa3bccb143a Defined exception cd.error which is used for errors other than
Sjoerd Mullender <sjoerd@acm.org>
parents: 926
diff changeset
765
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
766 m = Py_InitModule("cd", CD_methods);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
767 if (m == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
768 return;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
769 d = PyModule_GetDict(m);
1063
aaa3bccb143a Defined exception cd.error which is used for errors other than
Sjoerd Mullender <sjoerd@acm.org>
parents: 926
diff changeset
770
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
771 CdError = PyErr_NewException("cd.error", NULL, NULL);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
772 PyDict_SetItemString(d, "error", CdError);
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
773
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
774 /* Identifiers for the different types of callbacks from the parser */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
775 PyDict_SetItemString(d, "audio", PyInt_FromLong((long) cd_audio));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
776 PyDict_SetItemString(d, "pnum", PyInt_FromLong((long) cd_pnum));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
777 PyDict_SetItemString(d, "index", PyInt_FromLong((long) cd_index));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
778 PyDict_SetItemString(d, "ptime", PyInt_FromLong((long) cd_ptime));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
779 PyDict_SetItemString(d, "atime", PyInt_FromLong((long) cd_atime));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
780 PyDict_SetItemString(d, "catalog", PyInt_FromLong((long) cd_catalog));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
781 PyDict_SetItemString(d, "ident", PyInt_FromLong((long) cd_ident));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
782 PyDict_SetItemString(d, "control", PyInt_FromLong((long) cd_control));
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
783
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
784 /* Block size information for digital audio data */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
785 PyDict_SetItemString(d, "DATASIZE",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
786 PyInt_FromLong((long) CDDA_DATASIZE));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
787 PyDict_SetItemString(d, "BLOCKSIZE",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
788 PyInt_FromLong((long) CDDA_BLOCKSIZE));
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
789
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
790 /* Possible states for the cd player */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
791 PyDict_SetItemString(d, "ERROR", PyInt_FromLong((long) CD_ERROR));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
792 PyDict_SetItemString(d, "NODISC", PyInt_FromLong((long) CD_NODISC));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
793 PyDict_SetItemString(d, "READY", PyInt_FromLong((long) CD_READY));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
794 PyDict_SetItemString(d, "PLAYING", PyInt_FromLong((long) CD_PLAYING));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
795 PyDict_SetItemString(d, "PAUSED", PyInt_FromLong((long) CD_PAUSED));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
796 PyDict_SetItemString(d, "STILL", PyInt_FromLong((long) CD_STILL));
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
797 #ifdef CD_CDROM /* only newer versions of the library */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 47527
diff changeset
798 PyDict_SetItemString(d, "CDROM", PyInt_FromLong((long) CD_CDROM));
2603
4084ecf276cf Use newgetargs instead of getargs.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2061
diff changeset
799 #endif
820
09c69a1ec7b0 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
800 }