CNAME.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /*
  3. * License Information:
  4. *
  5. * Net_DNS: A resolver library for PHP
  6. * Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. /* Net_DNS_RR_CNAME definition {{{ */
  23. /**
  24. * A representation of a resource record of type <b>CNAME</b>
  25. *
  26. * @package Net_DNS
  27. */
  28. class Net_DNS_RR_CNAME extends Net_DNS_RR
  29. {
  30. /* class variable definitions {{{ */
  31. var $name;
  32. var $type;
  33. var $class;
  34. var $ttl;
  35. var $rdlength;
  36. var $rdata;
  37. var $cname;
  38. /* }}} */
  39. /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
  40. function Net_DNS_RR_CNAME(&$rro, $data, $offset = '')
  41. {
  42. $this->name = $rro->name;
  43. $this->type = $rro->type;
  44. $this->class = $rro->class;
  45. $this->ttl = $rro->ttl;
  46. $this->rdlength = $rro->rdlength;
  47. $this->rdata = $rro->rdata;
  48. if ($offset) {
  49. if ($this->rdlength > 0) {
  50. list($cname, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
  51. $this->cname = $cname;
  52. }
  53. } else {
  54. $this->cname = ereg_replace("[ \t]+(.+)[\. \t]*$", '\\1', $data);
  55. }
  56. }
  57. /* }}} */
  58. /* Net_DNS_RR_CNAME::rdatastr() {{{ */
  59. function rdatastr()
  60. {
  61. if (strlen($this->cname)) {
  62. return($this->cname . '.');
  63. }
  64. return('; no data');
  65. }
  66. /* }}} */
  67. /* Net_DNS_RR_CNAME::rr_rdata($packet, $offset) {{{ */
  68. function rr_rdata($packet, $offset)
  69. {
  70. if (strlen($this->cname)) {
  71. return($packet->dn_comp($this->cname, $offset));
  72. }
  73. return(NULL);
  74. }
  75. /* }}} */
  76. }
  77. /* }}} */
  78. /* VIM settings {{{
  79. * Local variables:
  80. * tab-width: 4
  81. * c-basic-offset: 4
  82. * soft-stop-width: 4
  83. * c indent on
  84. * End:
  85. * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
  86. * vim<600: sw=4 ts=4
  87. * }}} */
  88. ?>