1 /* ========================================================================
2 * Copyright 1988-2006 University of Washington
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
11 * ========================================================================
15 * Program: Operating-system dependent routines -- OS/2 emx version
17 * Author: Mark Crispin
18 * Networks and Distributed Computing
19 * Computing & Communications
20 * University of Washington
21 * Administration Building, AG-44
23 * Internet: MRC@CAC.Washington.EDU
26 * Last Edited: 30 August 2006
32 #include <sys/types.h>
34 #include <sys/socket.h>
35 #include <netinet/in.h>
36 #include <arpa/inet.h>
41 extern int errno
; /* just in case */
43 #include "tcp_os2.h" /* must be before osdep includes tcp.h */
53 /* Return my local host name
54 * Returns: my local host name
57 char *mylocalhost (void)
59 if (!myLocalHost
) { /* known yet? */
60 char *s
,tmp
[MAILTMPLEN
];
62 /* could we get local id? */
63 gethostname (tmp
,MAILTMPLEN
-1);
64 if (he
= gethostbyname (lcase (tmp
))) {
65 if (he
->h_name
) s
= he
->h_name
;
66 else sprintf (s
= tmp
,"[%i.%i.%i.%i]",he
->h_addr
[0],he
->h_addr
[1],
67 he
->h_addr
[2],he
->h_addr
[3]);
70 myLocalHost
= cpystr (s
); /* record for subsequent use */
76 /* Look up host address
77 * Accepts: pointer to pointer to host name
78 * socket address block
79 * Returns: non-zero with host address in socket, official host name in host;
83 long lookuphost (char **host
,struct sockaddr_in
*sin
)
87 struct hostent
*hn
= gethostbyname (lcase (strcpy (tmp
,*host
)));
88 if (!hn
) return NIL
; /* got a host name? */
89 *host
= cpystr (hn
->h_name
); /* set official name */
90 /* copy host addresses */
91 memcpy (&sin
->sin_addr
,hn
->h_addr
,hn
->h_length
);
97 * Emulator for BSD syslog() routine.
100 void syslog (int priority
,const char *message
,...)