pydnspp_common.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <util/python/pycppwrapper_util.h>
  20. namespace isc {
  21. namespace dns {
  22. namespace python {
  23. // For our 'general' isc::Exceptions
  24. extern PyObject* po_IscException;
  25. extern PyObject* po_InvalidParameter;
  26. // For our own isc::dns::Exception
  27. extern PyObject* po_DNSMessageBADVERS;
  28. // This function reads 'bytes' from a sequence
  29. // This sequence can be anything that implements the Sequence interface,
  30. // but must consist of Numbers between 0 and 255 for every value.
  31. //
  32. // The data is stored in *data.
  33. // Data must be allocated and have at least len bytes available.
  34. //
  35. // The current implementation removes read items from the
  36. // head of the sequence, unless it fails (and returns -1), in which
  37. // case nothing is removed
  38. int readDataFromSequence(uint8_t *data, size_t len, PyObject* sequence);
  39. int addClassVariable(PyTypeObject& c, const char* name, PyObject* obj);
  40. } // namespace python
  41. } // namespace dns
  42. } // namespace isc
  43. #endif // __LIBDNS_PYTHON_COMMON_H
  44. // Local Variables:
  45. // mode: c++
  46. // End: