tsigrecord_python.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (C) 2011 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 __PYTHON_TSIGRECORD_H
  15. #define __PYTHON_TSIGRECORD_H 1
  16. #include <Python.h>
  17. #include <dns/tsigrecord.h>
  18. namespace isc {
  19. namespace dns {
  20. namespace python {
  21. extern PyTypeObject tsigrecord_type;
  22. /// This is A simple shortcut to create a python TSIGRecord object (in the
  23. /// form of a pointer to PyObject) with minimal exception safety.
  24. /// On success, it returns a valid pointer to PyObject with a reference
  25. /// counter of 1; if something goes wrong it throws an exception (it never
  26. /// returns a NULL pointer).
  27. /// This function is expected to be called with in a try block
  28. /// followed by necessary setup for python exception.
  29. PyObject* createTSIGRecordObject(const TSIGRecord& source);
  30. /// \brief Checks if the given python object is a TSIGRecord object
  31. ///
  32. /// \param obj The object to check the type of
  33. /// \return true if the object is of type TSIGRecord, false otherwise
  34. bool PyTSIGRecord_Check(PyObject* obj);
  35. /// \brief Returns a reference to the TSIGRecord object contained within the given
  36. /// Python object.
  37. ///
  38. /// \note The given object MUST be of type TSIGRecord; this can be checked with
  39. /// either the right call to ParseTuple("O!"), or with PyTSIGRecord_Check()
  40. ///
  41. /// \note This is not a copy; if the TSIGRecord is needed when the PyObject
  42. /// may be destroyed, the caller must copy it itself.
  43. ///
  44. /// \param rrtype_obj The rrtype object to convert
  45. const TSIGRecord& PyTSIGRecord_ToTSIGRecord(PyObject* tsigrecord_obj);
  46. } // namespace python
  47. } // namespace dns
  48. } // namespace isc
  49. #endif // __PYTHON_TSIGRECORD_H
  50. // Local Variables:
  51. // mode: c++
  52. // End: