Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

poslib/domainfn.h

Go to the documentation of this file.

  
00001 /* 00002 Posadis - A DNS Server 00003 Domain functions 00004 Copyright (C) 2002 Meilof Veeningen <> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #ifndef __POSLIB_DOMAINFN_H 00022 #define __POSLIB_DOMAINFN_H 00023 00024 class domainname; 00025 00026 #include "sysstl.h" 00027 #include "dnsmessage.h" 00028 00047 #define DOM_LEN 255 00048 00055 #define DOMLABEL_LEN 63 00056 00064 class domainname { 00065 public: 00071 domainname(); 00072 00082 domainname(const char *text, domainname origin); 00083 00096 domainname(const char *text, const _domain origin = ""); 00097 00107 domainname(message_buff &buff, int ix); 00108 00119 domainname(bool is_binary, const _domain dom); 00120 00127 domainname(const domainname& nam); 00128 00137 bool operator==(const domainname& nam); 00138 00147 bool operator!=(const domainname& nam); 00148 00156 domainname& operator=(const domainname& nam); 00157 00166 domainname& operator=(const char *buff); 00167 00179 domainname& operator+=(const domainname& dom); 00188 domainname& operator+(const domainname& dom); 00189 00199 bool operator>=(const domainname& dom); 00200 00210 bool operator>(const domainname& dom); 00211 00217 ~domainname(); 00218 00226 _domain c_str(); 00227 00236 int len(); 00237 00246 stl_string tostring(); 00247 00256 #define tocstr() tostring().c_str() 00257 00266 int nlabels(); 00267 00277 stl_string label(int ix); 00278 00287 domainname from(int ix); 00288 00298 domainname to(int labels); 00299 00311 stl_string torelstring(domainname &root); 00312 00323 int ncommon(domainname &dom); 00324 00325 private: 00326 char *domain; 00327 }; 00328 00334 typedef char _sdomain[DOM_LEN]; 00335 00345 void *memdup(const void *src, int len); 00346 00356 int dom_comprlen(message_buff &buff, int ix); 00357 00367 _domain dom_uncompress(message_buff &buff, int ix); 00368 00374 struct dom_compr_info { 00375 public: 00376 dom_compr_info(_domain _dom, int _ix, int _nl, int _nul); 00377 _domain dom; 00378 int ix; 00379 int nl; 00380 int nul; 00381 }; 00382 00392 void dom_write(stl_string &ret, _domain dom, stl_slist(dom_compr_info)& compr); 00393 00394 /* traditional domain-name functions */ 00395 00404 _domain domfrom(_domain dom, int ix); 00405 00415 bool domisparent(_domain parent, _domain child); 00416 00426 int domlen(const _domain dom); 00427 00436 _domain domdup(const _domain dom); 00437 00446 bool domlcmp(const _domain dom1, const _domain dom2); 00447 00456 bool domcmp(const _domain dom1, const _domain dom2); 00457 00466 void domcat(_domain target, const _domain src); 00467 00477 void domcpy(_domain res, const _domain src); 00478 00489 void domfromlabel(_domain dom, const char *label, int len = -1); 00490 00499 stl_string dom_tostring(const _domain dom); 00500 00509 int dom_nlabels(const _domain dom); 00510 00520 stl_string dom_label(const _domain dom, int label); 00521 00531 const _domain dom_plabel(const _domain dom, int label); 00532 00543 int domncommon(const _domain dom1, const _domain dom2); 00544 00560 int domccmp(const _domain _dom1, const _domain _dom2); 00561 00573 void domto(_domain ret, const _domain src, int labels); 00574 00575 #endif /* __POSLIB_DOMAINFN_H */

  
Generated on Fri Dec 24 19:55:14 2004 for Poslib by doxygen 1.3.7