pydnspp_common.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __LIBDNS_PYTHON_COMMON_H
  15. #define __LIBDNS_PYTHON_COMMON_H 1
  16. #include <Python.h>
  17. #include <stdexcept>
  18. #include <string>
  19. namespace isc {
  20. namespace dns {
  21. namespace python {
  22. // For our 'general' isc::Exceptions
  23. extern PyObject* po_IscException;
  24. extern PyObject* po_InvalidParameter;
  25. // For our own isc::dns::Exception
  26. extern PyObject* po_DNSMessageBADVERS;
  27. // This function reads 'bytes' from a sequence
  28. // This sequence can be anything that implements the Sequence interface,
  29. // but must consist of Numbers between 0 and 255 for every value.
  30. //
  31. // The data is stored in *data.
  32. // Data must be allocated and have at least len bytes available.
  33. //
  34. // The current implementation removes read items from the
  35. // head of the sequence, unless it fails (and returns -1), in which
  36. // case nothing is removed
  37. int readDataFromSequence(uint8_t *data, size_t len, PyObject* sequence);
  38. int addClassVariable(PyTypeObject& c, const char* name, PyObject* obj);
  39. // Short term workaround for unifying the return type of tp_hash
  40. #if PY_MINOR_VERSION < 2
  41. typedef long Py_hash_t;
  42. #endif
  43. } // namespace python
  44. } // namespace dns
  45. } // namespace isc
  46. #endif // __LIBDNS_PYTHON_COMMON_H
  47. // Local Variables:
  48. // mode: c++
  49. // End: