ux-guesses.cc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. /* Print guesses of host and domain name as made by the setup SDK. */
  39. /* $RCSfile: ux-guesses.cc,v $ $Revision: 1.5 $ $Date: 2005/04/19 22:07:21 $ $State: Exp $ */
  40. /*
  41. * $Log: ux-guesses.cc,v $
  42. * Revision 1.5 2005/04/19 22:07:21 nkinder
  43. * Fixed licensing typo
  44. *
  45. * Revision 1.4 2005/04/15 22:40:11 nkinder
  46. * 155068 - Added license to source files
  47. *
  48. * Revision 1.3 2005/03/11 03:46:41 rmeggins
  49. * This one is mostly strcpy/strcat checking, checking for null strings before strlen, removing some dead code, other odds and ends.
  50. *
  51. * Revision 1.2 2005/02/28 23:37:49 nkinder
  52. * 149951 - Updated source code copyrights
  53. *
  54. * Revision 1.1.1.1 2005/01/21 00:40:49 cvsadm
  55. * Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)
  56. *
  57. * Revision 1.1.2.4 2004/07/14 01:39:20 dboreham
  58. * changes to make newer C++ compilers happy
  59. *
  60. * Revision 1.1.1.1 2004/06/03 22:32:45 telackey
  61. * Initial import Thu Jun 3 15:32:43 PDT 2004
  62. *
  63. * Revision 1.1.2.3 2003/09/22 19:38:52 ulfw
  64. * Update copyright years from 2001 to 2001-2003
  65. *
  66. * Revision 1.1.2.2 2001/11/02 23:33:04 richm
  67. * XXX use new copyright XXX
  68. *
  69. * Revision 1.1.2.1 2000/08/07 15:14:28 mwahl
  70. * rename functions
  71. *
  72. *
  73. */
  74. #include "dialog.h"
  75. extern "C" {
  76. #if defined(__sun) || defined(__hppa) || defined(__osf__) || defined(__linux__) || defined(linux)
  77. #include <netdb.h>
  78. #endif
  79. }
  80. class PrintGuessPreInstall:public DialogManager
  81. {
  82. public:
  83. PrintGuessPreInstall(int, char **);
  84. ~PrintGuessPreInstall();
  85. int init();
  86. int start();
  87. void setParent(void *) { }
  88. void *parent() const { return 0;}
  89. void resetLast() { }
  90. void add (Dialog *) { }
  91. void addLast(Dialog *) { }
  92. void clear() { }
  93. int cont() { return -1;}
  94. private:
  95. Bool _reconfig;
  96. Bool _configured;
  97. };
  98. PrintGuessPreInstall::PrintGuessPreInstall(int argc, char **argv) : _reconfig(False)
  99. {
  100. setInstallMode(Interactive);
  101. setInstallType(Typical);
  102. _configured = False;
  103. /* getOptions(argc, argv); */
  104. }
  105. PrintGuessPreInstall::~PrintGuessPreInstall()
  106. {
  107. }
  108. int PrintGuessPreInstall::init()
  109. {
  110. return 0;
  111. }
  112. int PrintGuessPreInstall::start()
  113. {
  114. const char *hno = InstUtil::guessHostname();
  115. printf("hostname: %s\n",hno ? hno : "<unknown>");
  116. if (hno) {
  117. #if defined(__sun) || defined(__hppa) || defined(__osf__) || defined(__linux__) || defined(linux)
  118. static char test_host[BIG_BUF] = {0};
  119. struct hostent *hp;
  120. PL_strncpyz(test_host,hno,sizeof(test_host));
  121. hp = gethostbyname(test_host);
  122. if (hp == NULL) {
  123. printf("addressable: no\n");
  124. } else {
  125. printf("addressable: yes\n");
  126. }
  127. #endif
  128. }
  129. const char *dno = InstUtil::guessDomain();
  130. printf("domain: %s\n",dno ? dno : "<unknown>");
  131. return 0;
  132. }
  133. int main(int argc,char **argv)
  134. {
  135. PrintGuessPreInstall program(argc,argv);
  136. int err = program.init();
  137. if (!err) {
  138. err = program.start();
  139. }
  140. return err;
  141. }