Mercurial > cpython-lru_cache-weakref
annotate Include/cStringIO.h @ 24042:63fbbed10714 legacy-trunk
Simplify HTTPSConnection constructor.
See discussion in SF bug 458463.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Fri, 28 Jun 2002 23:38:14 +0000 |
| parents | f1af8ad11000 |
| children | ca20be24381f |
| rev | line source |
|---|---|
| 4598 | 1 #ifndef CSTRINGIO_INCLUDED |
| 2 #define CSTRINGIO_INCLUDED | |
|
22688
c0596f84a8fb
Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents:
18064
diff
changeset
|
3 #ifdef __cplusplus |
|
c0596f84a8fb
Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents:
18064
diff
changeset
|
4 extern "C" { |
|
c0596f84a8fb
Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents:
18064
diff
changeset
|
5 #endif |
| 4598 | 6 /* |
| 7 | |
| 8 This header provides access to cStringIO objects from C. | |
| 9 Functions are provided for calling cStringIO objects and | |
| 10 macros are provided for testing whether you have cStringIO | |
| 11 objects. | |
| 12 | |
| 13 Before calling any of the functions or macros, you must initialize | |
| 14 the routines with: | |
| 15 | |
|
9944
396a38ea9b84
There's a macro PycString_IMPORT which the documentation listed as
Guido van Rossum <guido@python.org>
parents:
9605
diff
changeset
|
16 PycString_IMPORT |
| 4598 | 17 |
| 18 This would typically be done in your init function. | |
| 19 | |
| 20 */ | |
| 21 | |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
22 /* Basic functions to manipulate cStringIO objects from C */ |
| 4598 | 23 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
24 static struct PycStringIO_CAPI { |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
25 |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
26 /* Read a string. If the last argument is -1, the remainder will be read. */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
27 int(*cread)(PyObject *, char **, int); |
| 4598 | 28 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
29 /* Read a line */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
30 int(*creadline)(PyObject *, char **); |
| 4598 | 31 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
32 /* Write a string */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
33 int(*cwrite)(PyObject *, char *, int); |
| 4598 | 34 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
35 /* Get the cStringIO object as a Python string */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
36 PyObject *(*cgetvalue)(PyObject *); |
| 4598 | 37 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
38 /* Create a new output object */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
39 PyObject *(*NewOutput)(int); |
| 4598 | 40 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
41 /* Create an input object from a Python string */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
9944
diff
changeset
|
42 PyObject *(*NewInput)(PyObject *); |
| 4598 | 43 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
44 /* The Python types for cStringIO input and output objects. |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
45 Note that you can do input on an output object. |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
46 */ |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
47 PyTypeObject *InputType, *OutputType; |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
48 |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
49 } * PycStringIO = NULL; |
| 4598 | 50 |
| 51 /* These can be used to test if you have one */ | |
| 4902 | 52 #define PycStringIO_InputCheck(O) \ |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
53 ((O)->ob_type==PycStringIO->InputType) |
| 4902 | 54 #define PycStringIO_OutputCheck(O) \ |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
55 ((O)->ob_type==PycStringIO->OutputType) |
| 4598 | 56 |
|
9605
6b59f9ab5db1
Undo the change here -- there's no point in declaring a static
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
57 static void * |
|
13660
a1ce07218781
Miscelaneous ANSIfications. I'm assuming here 'main' should take (int,
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
58 xxxPyCObject_Import(char *module_name, char *name) |
|
5991
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
59 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
60 PyObject *m, *c; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
61 void *r=NULL; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
62 |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
63 if((m=PyImport_ImportModule(module_name))) |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
64 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
65 if((c=PyObject_GetAttrString(m,name))) |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
66 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
67 r=PyCObject_AsVoidPtr(c); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
68 Py_DECREF(c); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
69 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
70 Py_DECREF(m); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
71 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
72 |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
73 return r; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
74 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
75 |
| 4598 | 76 #define PycString_IMPORT \ |
|
18064
ac5489a2548d
Cast the result of xxxPyCObject_Import to PycStringIO_CAPI*.
Martin v. Löwis <martin@v.loewis.de>
parents:
13660
diff
changeset
|
77 PycStringIO=(struct PycStringIO_CAPI*)xxxPyCObject_Import("cStringIO", "cStringIO_CAPI") |
| 4598 | 78 |
|
22688
c0596f84a8fb
Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents:
18064
diff
changeset
|
79 #ifdef __cplusplus |
|
c0596f84a8fb
Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents:
18064
diff
changeset
|
80 } |
|
c0596f84a8fb
Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents:
18064
diff
changeset
|
81 #endif |
| 4598 | 82 #endif /* CSTRINGIO_INCLUDED */ |
