3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic License,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
11 ?RCS: $Log: d_gethname.U,v $
12 ?RCS: Revision 3.0.1.1 1994/10/29 16:13:00 ram
13 ?RCS: patch36: call ./xenix explicitely instead of relying on PATH
15 ?RCS: Revision 3.0 1993/08/18 12:06:11 ram
16 ?RCS: Baseline for dist 3.0 netwide release.
18 ?MAKE:d_gethname d_uname d_phostname aphostname: phostname cat \
19 myhostname package d_portable Loc echo n c +i_whoami +usrinc \
20 Myread Guess Oldconfig Csym
21 ?MAKE: -pick add $@ %<
23 ?S: This variable conditionally defines the HAS_GETHOSTNAME symbol, which
24 ?S: indicates to the C program that the gethostname() routine may be
25 ?S: used to derive the host name.
28 ?S: This variable conditionally defines the HAS_UNAME symbol, which
29 ?S: indicates to the C program that the uname() routine may be
30 ?S: used to derive the host name.
33 ?S: This variable conditionally defines the PHOSTNAME symbol, which
34 ?S: contains the shell command which, when fed to popen(), may be
35 ?S: used to derive the host name.
38 ?S: Thie variable contains the command which can be used to compute the
39 ?S: host name. The command is fully qualified by its absolute path, to make
40 ?S: it safe when used by a process with super-user privileges.
42 ?C:HAS_GETHOSTNAME (GETHOSTNAME):
43 ?C: This symbol, if defined, indicates that the C program may use the
44 ?C: gethostname() routine to derive the host name. See also HAS_UNAME
48 ?C: This symbol, if defined, indicates that the C program may use the
49 ?C: uname() routine to derive the host name. See also HAS_GETHOSTNAME
53 ?C: This symbol, if defined, indicates that the C program may use the
54 ?C: contents of PHOSTNAME as a command to feed to the popen() routine
55 ?C: to derive the host name. See also HAS_GETHOSTNAME and HAS_UNAME.
56 ?C: Note that the command uses a fully qualified path, so that it is safe
57 ?C: even if used by a process with super-user privileges.
59 ?H:#$d_gethname HAS_GETHOSTNAME /**/
60 ?H:#$d_uname HAS_UNAME /**/
61 ?H:#$d_phostname PHOSTNAME "$aphostname" /* How to get the host name */
65 : see how we will look up host name
68 : dummy stub to allow use of elif
70 elif set gethostname val -f d_gethname; eval $csym; $val; then
71 echo 'gethostname() found.' >&4
76 elif set uname val -f d_uname; eval $csym; $val; then
79 uname() was found, but you're running xenix, and older versions of xenix
80 have a broken uname(). If you don't really know whether your xenix is old
81 enough to have a broken system call, use the default answer.
88 rp='Is your uname() broken?'
91 n*) d_uname="$define"; call=uname;;
94 echo 'uname() found.' >&4
100 case "$d_gethname" in
101 '') d_gethname="$undef";;
104 '') d_uname="$undef";;
106 @if PHOSTNAME || MYHOSTNAME
107 case "$d_uname$d_gethname" in
112 Every now and then someone has a $call() that lies about the hostname
113 but can't be fixed for political or economic reasons. If you wish, I can
114 @if MYHOSTNAME && PHOSTNAME
115 pretend $call() isn't there and maybe compile in the hostname or
116 compute it from the '$phostname' command at run-time.
118 pretend $call() isn't there and maybe compile in the hostname.
120 pretend $call() isn't there and maybe compute hostname at run-time
121 thanks to the '$phostname' command.
123 get the hostname from whomai.h (provided you have one).
125 simply ignore your host name and use someting like "noname" instead.
129 rp="Shall I ignore $call() from now on?"
132 y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
136 @if PHOSTNAME || aphostname
137 ?X: Compute the full path name for the command
140 *) case "$aphostname" in
146 file=`./loc $file $file $pth`
147 aphostname=`echo $file $*`
153 @if PHOSTNAME && MYHOSTNAME
154 case "$d_uname$d_gethname" in
162 There is no gethostname() or uname() on this system. You have two
163 possibilities at this point:
165 1) You can have your host name ($myhostname) compiled into $package, which
166 lets $package start up faster, but makes your binaries non-portable, or
167 2) you can have $package use a
169 popen("$aphostname","r")
171 which will start slower but be more portable.
174 Option 1 will give you the option of using whoami.h if you have one.
176 If you want option 2 but with a different command, you can edit config.sh at
177 the end of this shell script.
180 case "$d_phostname" in
184 case "$d_portable" in
189 rp="Do you want your host name compiled in?"
192 n*) d_phostname="$define" ;;
193 *) aphostname=''; d_phostname="$undef";;
196 case "$aphostname" in
204 No hostname function--you can either use the whoami.h file, which has this line:
206 `grep sysname $usrinc/whoami.h`
208 or you can have the name we came up with earlier ($myhostname) hardwired in.
210 rp="Use whoami.h to get hostname?"
213 n*) i_whoami="$undef";;
218 No hostname function and no whoami.h -- hardwiring "$myhostname".
223 echo 'No hostname function -- hardwiring "'$myhostname'".' >&4;;
228 case "$d_uname$d_gethname" in
238 No hostname function--we'll use the whoami.h file, which has this line:
240 `grep sysname $usrinc/whoami.h`
244 *) echo "There will be no way for $package to get your hostname." >&4;;
247 echo "There will be no way for $package to get your hostname." >&4;;
250 echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
255 case "$d_uname$d_gethname" in
264 No hostname function--you can either use the whoami.h file, which has this line:
266 `grep sysname $usrinc/whoami.h`
268 or you can have the name we came up with earlier ($myhostname) hardwired in.
270 rp="Use whoami.h to get hostname?"
273 n*) i_whoami="$undef";;
277 echo 'No whoami.h--hardwiring "'$myhostname'".' >&4;;
280 echo 'Hardwiring "'$myhostname'".' >&4;;
284 case "$d_phostname" in
285 '') d_phostname="$undef";;