Mercurial > cpython-lru_cache-weakref
annotate Include/cStringIO.h @ 6719:faebc1940432 legacy-trunk
Understand -Xlinker option.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 02 Dec 1997 20:38:11 +0000 |
| parents | c62e34ea464b |
| children | 4cf0da071e2b |
| rev | line source |
|---|---|
| 4598 | 1 #ifndef CSTRINGIO_INCLUDED |
| 2 #define CSTRINGIO_INCLUDED | |
| 3 /* | |
| 4 | |
| 5 $Id$ | |
| 6 | |
| 7 cStringIO C API | |
| 8 | |
| 9 Copyright | |
| 10 | |
| 11 Copyright 1996 Digital Creations, L.C., 910 Princess Anne | |
| 12 Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All | |
| 13 rights reserved. Copyright in this software is owned by DCLC, | |
| 14 unless otherwise indicated. Permission to use, copy and | |
| 15 distribute this software is hereby granted, provided that the | |
| 16 above copyright notice appear in all copies and that both that | |
| 17 copyright notice and this permission notice appear. Note that | |
| 18 any product, process or technology described in this software | |
| 19 may be the subject of other Intellectual Property rights | |
| 20 reserved by Digital Creations, L.C. and are not licensed | |
| 21 hereunder. | |
| 22 | |
| 23 Trademarks | |
| 24 | |
| 25 Digital Creations & DCLC, are trademarks of Digital Creations, L.C.. | |
| 26 All other trademarks are owned by their respective companies. | |
| 27 | |
| 28 No Warranty | |
| 29 | |
| 30 The software is provided "as is" without warranty of any kind, | |
| 31 either express or implied, including, but not limited to, the | |
| 32 implied warranties of merchantability, fitness for a particular | |
| 33 purpose, or non-infringement. This software could include | |
| 34 technical inaccuracies or typographical errors. Changes are | |
| 35 periodically made to the software; these changes will be | |
| 36 incorporated in new editions of the software. DCLC may make | |
| 37 improvements and/or changes in this software at any time | |
| 38 without notice. | |
| 39 | |
| 40 Limitation Of Liability | |
| 41 | |
| 42 In no event will DCLC be liable for direct, indirect, special, | |
| 43 incidental, economic, cover, or consequential damages arising | |
| 44 out of the use of or inability to use this software even if | |
| 45 advised of the possibility of such damages. Some states do not | |
| 46 allow the exclusion or limitation of implied warranties or | |
| 47 limitation of liability for incidental or consequential | |
| 48 damages, so the above limitation or exclusion may not apply to | |
| 49 you. | |
| 50 | |
| 51 If you have questions regarding this software, | |
| 52 contact: | |
| 53 | |
| 54 info@digicool.com | |
| 55 Digital Creations L.C. | |
| 56 | |
| 57 (540) 371-6909 | |
| 58 | |
| 59 | |
| 60 This header provides access to cStringIO objects from C. | |
| 61 Functions are provided for calling cStringIO objects and | |
| 62 macros are provided for testing whether you have cStringIO | |
| 63 objects. | |
| 64 | |
| 65 Before calling any of the functions or macros, you must initialize | |
| 66 the routines with: | |
| 67 | |
| 68 PycStringIO_IMPORT | |
| 69 | |
| 70 This would typically be done in your init function. | |
| 71 | |
| 72 $Log$ | |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
73 Revision 2.6 1997/10/07 14:44:48 guido |
|
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
74 Use K&R function prototypes. |
|
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
75 |
|
5991
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
76 Revision 2.5 1997/08/13 03:14:08 guido |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
77 cPickle release 0.3 from Jim Fulton |
|
5284
02b2edf55baf
Got rid of the static decl of PyCObject_Import, which was a 1.4
Guido van Rossum <guido@python.org>
parents:
5279
diff
changeset
|
78 |
|
5991
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
79 Revision 1.3 1997/06/13 19:44:02 jim |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
80 - changed to avoid warning of multiple declarations in 1.5 and |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
81 our 1.4. |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
82 |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
83 Revision 1.2 1997/01/27 14:13:05 jim |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
84 Changed the way the C API was exported. |
| 4902 | 85 |
| 86 Revision 1.1 1997/01/02 15:18:36 chris | |
| 87 initial version | |
| 4598 | 88 |
| 89 | |
| 90 */ | |
| 91 | |
| 92 /* Basic fuctions to manipulate cStringIO objects from C */ | |
| 93 | |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
94 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
|
95 |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
96 /* Read a string. If the last argument is -1, the remainder will be read. */ |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
97 int(*cread) Py_FPROTO((PyObject *, char **, int)); |
| 4598 | 98 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
99 /* Read a line */ |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
100 int(*creadline) Py_FPROTO((PyObject *, char **)); |
| 4598 | 101 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
102 /* Write a string */ |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
103 int(*cwrite) Py_FPROTO((PyObject *, char *, int)); |
| 4598 | 104 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
105 /* Get the cStringIO object as a Python string */ |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
106 PyObject *(*cgetvalue) Py_FPROTO((PyObject *)); |
| 4598 | 107 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
108 /* Create a new output object */ |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
109 PyObject *(*NewOutput) Py_FPROTO((int)); |
| 4598 | 110 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
111 /* Create an input object from a Python string */ |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
112 PyObject *(*NewInput) Py_FPROTO((PyObject *)); |
| 4598 | 113 |
|
5279
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
114 /* 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
|
115 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
|
116 */ |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
117 PyTypeObject *InputType, *OutputType; |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
118 |
|
16372a4c4c14
Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents:
4902
diff
changeset
|
119 } * PycStringIO = NULL; |
| 4598 | 120 |
| 121 /* These can be used to test if you have one */ | |
| 4902 | 122 #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
|
123 ((O)->ob_type==PycStringIO->InputType) |
| 4902 | 124 #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
|
125 ((O)->ob_type==PycStringIO->OutputType) |
| 4598 | 126 |
|
5991
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
127 static void * |
|
6421
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
128 xxxPyCObject_Import(module_name, name) |
|
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
129 char *module_name; |
|
c62e34ea464b
Use K&R function prototypes.
Guido van Rossum <guido@python.org>
parents:
5991
diff
changeset
|
130 char *name; |
|
5991
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
131 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
132 PyObject *m, *c; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
133 void *r=NULL; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
134 |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
135 if((m=PyImport_ImportModule(module_name))) |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
136 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
137 if((c=PyObject_GetAttrString(m,name))) |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
138 { |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
139 r=PyCObject_AsVoidPtr(c); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
140 Py_DECREF(c); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
141 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
142 Py_DECREF(m); |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
143 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
144 |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
145 return r; |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
146 } |
|
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
147 |
| 4598 | 148 #define PycString_IMPORT \ |
|
5991
a5737dd96979
cPickle release 0.3 from Jim Fulton
Guido van Rossum <guido@python.org>
parents:
5284
diff
changeset
|
149 PycStringIO=xxxPyCObject_Import("cStringIO", "cStringIO_CAPI") |
| 4598 | 150 |
| 151 #endif /* CSTRINGIO_INCLUDED */ |
