From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 21 Jul 93 11:37:11 GMT From: sarge!sarge!svh@uunet.uu.net (Steven Hovater) Subject: Re: SunAda question Message-ID: List-Id: kanderso@mabillon.ICS.UCI.EDU (Kenneth Anderson) writes: >Hello. I am using the sunada-1.1 compiler and it came with a package >unix defined in its standard library. One of the subprograms defined >in the package unix is > function gethostname(name: address; namelen: integer) > return status_code; >As defined this function seems very useless. It will only tell you whether >or not the call to gethostname was successful. It will not tell you, >despite its name, what the hostname is. >Two questions: > 1. Anyone know why such a useless function would be included in > this package? > 2. What is a good portable way of finding out the name of the machine > your program is running on? >Thanks in advance, >Ken Anderson Hi Ken - not speaking officially here for Verdix, but for myself :) Note that the function has an argument that's an address - that's the key here. Some might argue that it's bad form to putz around modifying what are considered in many circles to be "in" only parameters, and I won't get into that any further, but a quick answer to your question is that the function (if successful) will return a nice status code in the return value, and the name parameter (I did it very dirty below) gets modified to contain the hostname. This is fairly portable, IMHO - since it's a pragma interface to the unix funct ion of the same name. -----cut here---- with unix; with text_io; procedure gethost is namelen : integer := 20; hostname : string (1..namelen); stat : unix.status_code; begin stat := unix.gethostname(hostname'address,namelen); text_io.put_line ("Hostname is " & hostname); end gethost; --- cut here--- While this may not be the cleanest code, it gets the point across. -- Steven V. Hovater (703)318-5839 Senior CASE Engineer Verdix Corporation EMAIL: svh@verdix.com -- Steven V. Hovater (703)318-5839 Senior CASE Engineer Verdix Corporation EMAIL: svh@verdix.com