name_python.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_NAME_H
  15. #define __PYTHON_NAME_H 1
  16. #include <Python.h>
  17. #include <util/python/pycppwrapper_util.h>
  18. namespace isc {
  19. namespace dns {
  20. class NameComparisonResult;
  21. class Name;
  22. namespace python {
  23. //
  24. // Declaration of the custom exceptions
  25. // Initialization and addition of these go in the module init at the
  26. // end
  27. //
  28. extern PyObject* po_EmptyLabel;
  29. extern PyObject* po_TooLongName;
  30. extern PyObject* po_TooLongLabel;
  31. extern PyObject* po_BadLabelType;
  32. extern PyObject* po_BadEscape;
  33. extern PyObject* po_IncompleteName;
  34. extern PyObject* po_InvalidBufferPosition;
  35. extern PyObject* po_DNSMessageFORMERR;
  36. //
  37. // Declaration of enums
  38. // Initialization and addition of these go in the module init at the
  39. // end
  40. //
  41. extern PyObject* po_NameRelation;
  42. // The s_* Class simply covers one instantiation of the object.
  43. class s_NameComparisonResult : public PyObject {
  44. public:
  45. s_NameComparisonResult() : cppobj(NULL) {}
  46. NameComparisonResult* cppobj;
  47. };
  48. class s_Name : public PyObject {
  49. public:
  50. s_Name() : cppobj(NULL), position(0) {}
  51. Name* cppobj;
  52. size_t position;
  53. };
  54. extern PyTypeObject name_comparison_result_type;
  55. extern PyTypeObject name_type;
  56. bool initModulePart_Name(PyObject* mod);
  57. /// This is A simple shortcut to create a python Name object (in the
  58. /// form of a pointer to PyObject) with minimal exception safety.
  59. /// On success, it returns a valid pointer to PyObject with a reference
  60. /// counter of 1; if something goes wrong it throws an exception (it never
  61. /// returns a NULL pointer).
  62. /// This function is expected to be called with in a try block
  63. /// followed by necessary setup for python exception.
  64. PyObject* createNameObject(const Name& source);
  65. } // namespace python
  66. } // namespace dns
  67. } // namespace isc
  68. #endif // __PYTHON_NAME_H
  69. // Local Variables:
  70. // mode: c++
  71. // End: