On 2004-07-13 22:25, Miguel Cardenas <[EMAIL PROTECTED]> wrote:
> Efectively was that way... in Linux it used to work fine... then my
> next question should be... is there any other way to retrieve the
> hostname? and... as a normal user?
Yep. See the manpage of gethostname(). This should work fine:
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
5 #define HOST_NAME_MAX 255
6 static char buf[HOST_NAME_MAX + 1];
7
8 int
9 main(void)
10 {
11
12 if (gethostname(buf, HOST_NAME_MAX) == -1) {
13 fprintf(stderr,
14 "error: my hostname is not defined\n");
15 exit(EXIT_FAILURE);
16 }
17 printf("%s\n", buf);
18 return EXIT_SUCCESS;
19 }
Giorgos
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"