rcode_python.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_RCODE_H
  15. #define __PYTHON_RCODE_H 1
  16. #include <Python.h>
  17. namespace isc {
  18. namespace dns {
  19. class Rcode;
  20. namespace python {
  21. // The s_* Class simply covers one instantiation of the object.
  22. //
  23. // We added a helper variable static_code here
  24. // Since we can create Rcodes dynamically with Rcode(int), but also
  25. // use the static globals (Rcode::NOERROR() etc), we use this
  26. // variable to see if the code came from one of the latter, in which
  27. // case Rcode_destroy should not free it (the other option is to
  28. // allocate new Rcodes for every use of the static ones, but this
  29. // seems more efficient).
  30. //
  31. // Follow-up note: we don't have to use the proxy function in the python lib;
  32. // we can just define class specific constants directly (see TSIGError).
  33. // We should make this cleanup later.
  34. class s_Rcode : public PyObject {
  35. public:
  36. s_Rcode();
  37. const Rcode* cppobj;
  38. bool static_code;
  39. };
  40. extern PyTypeObject rcode_type;
  41. bool initModulePart_Rcode(PyObject* mod);
  42. } // namespace python
  43. } // namespace dns
  44. } // namespace isc
  45. #endif // __PYTHON_RCODE_H
  46. // Local Variables:
  47. // mode: c++
  48. // End: