pysocket.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef PYSOCKET_H
  2. #define PYSOCKET_H
  3. //*****************************************************************************
  4. //
  5. // pysocket.h
  6. //
  7. // Contains a python socket module, and an Socket class that is a python
  8. // wrapper for NakedMud sockets. If you wish to give python access to more
  9. // features of an socket, it should NOT be done by editing pysocket.c! Use
  10. // PySocket_addGetSetter and PySocket_addMethod in a new module implementing
  11. // the feature you want to give Python access to.
  12. //
  13. //*****************************************************************************
  14. // used by pymudsys. Do not touch!
  15. PyTypeObject PySocket_Type;
  16. // initialize sockets for use. This must be called AFTER all other modules
  17. // have added in new get/setters and methods to pyroom
  18. PyMODINIT_FUNC init_PySocket(void);
  19. PyObject *newPySocket(SOCKET_DATA *sock);
  20. SOCKET_DATA *PySocket_AsSocket(PyObject *sock);
  21. int PySocket_AsUid(PyObject *sock);
  22. //
  23. // checks to see if the PyObject is a PySocket
  24. int PySocket_Check(PyObject *value);
  25. //
  26. // getters allow Python to access pieces of the Socket module. Setters allow
  27. // Python to change pieces of the socket module. Getters are called when Python
  28. // tries to get the value of some variable on the object, and setters are called
  29. // when Python tries to set the value of some variable on the object. Get and
  30. // Set do not both need to be supplied. Examples of how to add new getters and
  31. // setters is presented in pysocket.c
  32. void PySocket_addGetSetter(const char *name, void *g, void *s, const char *doc);
  33. //
  34. // Adds a new method function (i.e. void *f) to the Socket class. Name is the
  35. // name of the function, f is the PyCFunction implementing the new method,
  36. // flags is the type of method beings used (almost always METH_VARARGS), and
  37. // dog is an (optional) description of what the method does. For examples on
  38. // how to add new methods, see pysocket.c
  39. void PySocket_addMethod(const char *name, void *f, int flags, const char *doc);
  40. #endif // PYSOCKET_H