Mercurial > noffle
comparison src/util.c @ 244:4e69e9b722ae noffle
[svn] * src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF
article format draft draft-ietf-usefor-article-06.txt recommends that
Xref: references contain the FQDN of the server. We were using the
host name without the domain. So split the routine used for obtaining
the FQDN from protocol.c into util.c, and use it when adding Xrefs.
author | bears |
---|---|
date | Fri, 15 Mar 2002 10:50:33 +0000 |
parents | fbff73fe5b40 |
children | b660fadc1814 |
comparison
equal
deleted
inserted
replaced
243:6eb6c912a0e4 | 244:4e69e9b722ae |
---|---|
1 /* | 1 /* |
2 util.c | 2 util.c |
3 | 3 |
4 $Id: util.c 371 2002-02-26 17:13:31Z bears $ | 4 $Id: util.c 375 2002-03-15 10:50:33Z bears $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
19 #endif | 19 #endif |
20 #endif | 20 #endif |
21 | 21 |
22 #include <errno.h> | 22 #include <errno.h> |
23 #include <ctype.h> | 23 #include <ctype.h> |
24 #include <netdb.h> | |
24 #include <sys/types.h> | 25 #include <sys/types.h> |
25 #include <sys/stat.h> | 26 #include <sys/stat.h> |
27 #include <sys/utsname.h> | |
26 #include <fcntl.h> | 28 #include <fcntl.h> |
27 #include <stdlib.h> | 29 #include <stdlib.h> |
28 #include <unistd.h> | 30 #include <unistd.h> |
29 #include "configfile.h" | 31 #include "configfile.h" |
30 #include "log.h" | 32 #include "log.h" |
502 if ( sigaction( sig, &act, &oldAct ) < 0 ) | 504 if ( sigaction( sig, &act, &oldAct ) < 0 ) |
503 return SIG_ERR; | 505 return SIG_ERR; |
504 return oldAct.sa_handler; | 506 return oldAct.sa_handler; |
505 } | 507 } |
506 | 508 |
509 static Bool | |
510 getHostFQDN( Str result ) | |
511 { | |
512 struct hostent *myHostEnt; | |
513 struct utsname myName; | |
514 | |
515 if ( uname( &myName ) >= 0 | |
516 && ( myHostEnt = gethostbyname( myName.nodename ) ) ) | |
517 { | |
518 Utl_cpyStr( result, myHostEnt->h_name ); | |
519 return TRUE; | |
520 } | |
521 return FALSE; | |
522 } | |
523 | |
524 Bool | |
525 Utl_getFQDN( Str result ) | |
526 { | |
527 /* get hostname from Cfg-File */ | |
528 Utl_cpyStr( result, Cfg_hostnameMsgId() ); | |
529 if ( strlen( result ) != 0 ) | |
530 return TRUE; | |
531 return getHostFQDN( result ); | |
532 } | |
533 | |
507 #if defined(UTIL_TEST) | 534 #if defined(UTIL_TEST) |
508 | 535 |
509 /* Test code borrowed from wildmat.c. Yep, still uses gets(). */ | 536 /* Test code borrowed from wildmat.c. Yep, still uses gets(). */ |
510 extern char *gets(); | 537 extern char *gets(); |
511 | 538 |