1 ?RCS: $Id: d_gethname.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
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 Licence; 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 explicitly 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 HAS_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: This 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 the command to feed to the
54 ?C: popen() routine to derive the host name. See also HAS_GETHOSTNAME
55 ?C: and HAS_UNAME. Note that the command uses a fully qualified path,
56 ?C: so that it is safe even if used by a process with super-user
60 ?C: This symbol, if defined, indicates that the C program may use the
61 ?C: contents of PHOSTNAME as a command to feed to the popen() routine
62 ?C: to derive the host name.
64 ?H:?%<:#$d_gethname HAS_GETHOSTNAME /**/
65 ?H:?%<:#$d_uname HAS_UNAME /**/
66 ?H:?%<:#$d_phostname HAS_PHOSTNAME /**/
67 ?H:?%<:#ifdef HAS_PHOSTNAME
68 ?H:?%<:#define PHOSTNAME "$aphostname" /* How to get the host name */
73 : see how we will look up host name
77 if set gethostname val -f d_gethname; eval $csym; $val; then
78 echo 'gethostname() found.' >&4
84 if set uname val -f d_uname; eval $csym; $val; then
87 uname() was found, but you're running xenix, and older versions of xenix
88 have a broken uname(). If you don't really know whether your xenix is old
89 enough to have a broken system call, use the default answer.
96 rp='Is your uname() broken?'
99 n*) d_uname="$define"; call=uname;;
102 echo 'uname() found.' >&4
110 case "$d_gethname" in
111 '') d_gethname="$undef";;
114 '') d_uname="$undef";;
116 @if PHOSTNAME || MYHOSTNAME
117 case "$d_uname$d_gethname" in
122 Every now and then someone has a $call() that lies about the hostname
123 but can't be fixed for political or economic reasons. If you wish, I can
124 @if MYHOSTNAME && PHOSTNAME
125 pretend $call() isn't there and maybe compile in the hostname or
126 compute it from the '$phostname' command at run-time.
128 pretend $call() isn't there and maybe compile in the hostname.
130 pretend $call() isn't there and maybe compute hostname at run-time
131 thanks to the '$phostname' command.
133 get the hostname from whomai.h (provided you have one).
135 simply ignore your host name and use someting like "noname" instead.
139 rp="Shall I ignore $call() from now on?"
142 y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
146 @if PHOSTNAME || aphostname
147 ?X: Compute the full path name for the command
150 *) case "$aphostname" in
156 file=`./loc $file $file $pth`
157 aphostname=`echo $file $*`
163 @if PHOSTNAME && MYHOSTNAME
164 case "$d_uname$d_gethname" in
172 There is no gethostname() or uname() on this system. You have two
173 possibilities at this point:
175 1) You can have your host name ($myhostname) compiled into $package, which
176 lets $package start up faster, but makes your binaries non-portable, or
177 2) you can have $package use a
179 popen("$aphostname","r")
181 which will start slower but be more portable.
184 Option 1 will give you the option of using whoami.h if you have one.
186 If you want option 2 but with a different command, you can edit config.sh at
187 the end of this shell script.
190 case "$d_phostname" in
194 case "$d_portable" in
199 rp="Do you want your host name compiled in?"
202 n*) d_phostname="$define" ;;
203 *) aphostname=''; d_phostname="$undef";;
206 case "$aphostname" in
214 No hostname function--you can either use the whoami.h file, which has this line:
216 `grep sysname $usrinc/whoami.h`
218 or you can have the name we came up with earlier ($myhostname) hardwired in.
220 rp="Use whoami.h to get hostname?"
223 n*) i_whoami="$undef";;
228 No hostname function and no whoami.h -- hardwiring "$myhostname".
233 echo 'No hostname function -- hardwiring "'$myhostname'".' >&4;;
238 case "$d_uname$d_gethname" in
248 No hostname function--we'll use the whoami.h file, which has this line:
250 `grep sysname $usrinc/whoami.h`
254 *) echo "There will be no way for $package to get your hostname." >&4;;
257 echo "There will be no way for $package to get your hostname." >&4;;
260 echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
265 case "$d_uname$d_gethname" in
274 No hostname function--you can either use the whoami.h file, which has this line:
276 `grep sysname $usrinc/whoami.h`
278 or you can have the name we came up with earlier ($myhostname) hardwired in.
280 rp="Use whoami.h to get hostname?"
283 n*) i_whoami="$undef";;
287 echo 'No whoami.h--hardwiring "'$myhostname'".' >&4;;
290 echo 'Hardwiring "'$myhostname'".' >&4;;
294 case "$d_phostname" in
295 '') d_phostname="$undef";;