Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Apr 1996 12:18:01 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        ATuretta@stylo.it (Angelo Turetta)
Cc:        freebsd-questions@freebsd.org
Subject:   Re: How can I use gethostname() in snake_saver ??
Message-ID:  <199604191918.MAA08755@phaeton.artisoft.com>
In-Reply-To: <c=IT%a=_%p=stylo%l=STYLOSERVER960419183610BF006300@styloserver.stylo.it> from "Angelo Turetta" at Apr 19, 96 06:36:07 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> I'm learning unix programming, so I'm obviously missing some very basic
> information: please, be patient :-)
> 
> I've modified snake_saver.c to make it use the host name as its 'snake'
> message. The hack is really simple: in saver_load() I use gethostname(3)  to
> fill a static array that is later used by snake_saver() instead of the local
> array 'saves'.
> 
> When I try to install the screen saver using modload(8), I get:
> 
>   /usr/src/lkm/syscons/snake> modload -u -o /tmp/saver_mod -e saver_init -q
> /lkm/snake_saver_mod.o
>   /lkm/snake_saver_mod.o: Undefined symbol `_gethostname' referenced from
> text segment
>   modload: /usr/bin/ld: return code 1
> 
> Is it only some -lxxxx missing or am I pretending too much :-) ????
> 
> Thanks for any help.

gethostname() is a libc function.

The screen saver is a kernel module.

You need to include <sys/sysctl.h> and access the control variable
"kern.hostname".

The C library is not available in the kernel, where the save runs.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604191918.MAA08755>