imapext-2007

view src/osdep/os2/os_os2.c @ 0:ada5e610ab86

imap-2007e
author yuuji@gentei.org
date Mon, 14 Sep 2009 15:17:45 +0900
parents
children
line source
1 /* ========================================================================
2 * Copyright 1988-2006 University of Washington
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *
11 * ========================================================================
12 */
14 /*
15 * Program: Operating-system dependent routines -- OS/2 emx version
16 *
17 * Author: Mark Crispin
18 * Networks and Distributed Computing
19 * Computing & Communications
20 * University of Washington
21 * Administration Building, AG-44
22 * Seattle, WA 98195
23 * Internet: MRC@CAC.Washington.EDU
24 *
25 * Date: 14 March 1996
26 * Last Edited: 30 August 2006
27 */
29 #include <stdio.h>
30 #include <time.h>
31 #include <sys/time.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <sys/socket.h>
35 #include <netinet/in.h>
36 #include <arpa/inet.h>
37 #include <netdb.h>
38 #include <ctype.h>
39 #include <errno.h>
40 extern int errno; /* just in case */
41 #include "tcp_os2.h" /* must be before osdep includes tcp.h */
42 #include "mail.h"
43 #include "osdep.h"
44 #include "misc.h"
45 #include "fs_os2.c"
46 #include "ftl_os2.c"
47 #include "nl_os2.c"
48 #include "env_os2.c"
49 #include "tcp_os2.c"
51 /* Return my local host name
52 * Returns: my local host name
53 */
55 char *mylocalhost (void)
56 {
57 if (!myLocalHost) { /* known yet? */
58 char *s,tmp[MAILTMPLEN];
59 struct hostent *he;
60 /* could we get local id? */
61 gethostname (tmp,MAILTMPLEN-1);
62 if (he = gethostbyname (lcase (tmp))) {
63 if (he->h_name) s = he->h_name;
64 else sprintf (s = tmp,"[%i.%i.%i.%i]",he->h_addr[0],he->h_addr[1],
65 he->h_addr[2],he->h_addr[3]);
66 }
67 else s = "random-pc";
68 myLocalHost = cpystr (s); /* record for subsequent use */
69 }
70 return myLocalHost;
71 }
74 /* Look up host address
75 * Accepts: pointer to pointer to host name
76 * socket address block
77 * Returns: non-zero with host address in socket, official host name in host;
78 * else NIL
79 */
81 long lookuphost (char **host,struct sockaddr_in *sin)
82 {
83 long ret = -1;
84 char tmp[MAILTMPLEN];
85 struct hostent *hn = gethostbyname (lcase (strcpy (tmp,*host)));
86 if (!hn) return NIL; /* got a host name? */
87 *host = cpystr (hn->h_name); /* set official name */
88 /* copy host addresses */
89 memcpy (&sin->sin_addr,hn->h_addr,hn->h_length);
90 return T;
91 }
94 /*
95 * Emulator for BSD syslog() routine.
96 */
98 void syslog (int priority,const char *message,...)
99 {
100 }

UW-IMAP'd extensions by yuuji