imapext-2007

view src/osdep/unix/os_ptx.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-2007 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 -- PTX 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: 11 May 1989
26 * Last Edited: 16 August 2007
27 */
29 #include "tcp_unix.h" /* must be before osdep includes tcp.h */
30 #include "mail.h"
31 #include "osdep.h"
32 #include <ctype.h>
33 #include <stdio.h>
34 #include <sys/stat.h>
35 #include <sys/time.h>
36 #include <sys/tiuser.h>
37 #include <sys/stropts.h>
38 #include <sys/socket.h>
39 #include <sys/poll.h>
40 #include <netinet/in.h>
41 #include <arpa/inet.h>
42 #include <netdb.h>
43 #include <errno.h>
44 #include <pwd.h>
45 #include <shadow.h>
46 #include <sys/select.h>
47 #include "misc.h"
49 extern int sys_nerr;
50 extern char *sys_errlist[];
52 #define DIR_SIZE(d) d->d_reclen
54 #define toint(c) ((c)-'0')
55 #define isodigit(c) (((unsigned)(c)>=060)&((unsigned)(c)<=067))
58 #include "fs_unix.c"
59 #include "ftl_unix.c"
60 #include "nl_unix.c"
61 #define env_init ENV_INIT
62 #include "env_unix.c"
63 #undef env_init
64 #define getpeername Getpeername
65 #define fork vfork
66 #include "tcp_unix.c"
67 #include "gr_waitp.c"
68 #include "flocksim.c"
69 #include "scandir.c"
70 #include "tz_sv4.c"
71 #include "utime.c"
73 /* Jacket around env_init() to work around PTX inetd braindamage */
75 static char may_need_server_init = T;
77 long env_init (char *user,char *home)
78 {
79 if (may_need_server_init) { /* maybe need to do server init cruft? */
80 may_need_server_init = NIL; /* not any more we don't */
81 if (!getuid ()) { /* if root, we're most likely a server */
82 t_sync (0); /* PTX inetd is stupid, stupid, stupid */
83 ioctl (0,I_PUSH,"tirdwr");/* it needs this cruft, else servers won't */
84 dup2 (0,1); /* work. How obnoxious!!! */
85 }
86 }
87 ENV_INIT (user,home); /* call the real routine */
88 }
90 /* Emulator for BSD gethostid() call
91 * Returns: unique identifier for this machine
92 */
94 long gethostid (void)
95 {
96 struct sockaddr_in sin;
97 int inet = t_open (TLI_TCP, O_RDWR, 0);
98 if (inet < 0) return 0;
99 getmyinaddr (inet,&sin,sizeof (sin));
100 close (inet);
101 return sin.sin_addr.s_addr;
102 }
105 /* Replaced version of getpeername() that jackets into getpeerinaddr()
106 * Accepts: file descriptor
107 * pointer to Internet socket addr
108 * length
109 * Returns: zero if success, data in socket addr
110 */
112 int Getpeername (int s,struct sockaddr *name,int *namelen)
113 {
114 return getpeerinaddr (s,(struct sockaddr_in *) name,*namelen);
115 }

UW-IMAP'd extensions by yuuji