imapext-2007

annotate 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
rev   line source
yuuji@0 1 /* ========================================================================
yuuji@0 2 * Copyright 1988-2007 University of Washington
yuuji@0 3 *
yuuji@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
yuuji@0 5 * you may not use this file except in compliance with the License.
yuuji@0 6 * You may obtain a copy of the License at
yuuji@0 7 *
yuuji@0 8 * http://www.apache.org/licenses/LICENSE-2.0
yuuji@0 9 *
yuuji@0 10 *
yuuji@0 11 * ========================================================================
yuuji@0 12 */
yuuji@0 13
yuuji@0 14 /*
yuuji@0 15 * Program: Operating-system dependent routines -- PTX version
yuuji@0 16 *
yuuji@0 17 * Author: Mark Crispin
yuuji@0 18 * Networks and Distributed Computing
yuuji@0 19 * Computing & Communications
yuuji@0 20 * University of Washington
yuuji@0 21 * Administration Building, AG-44
yuuji@0 22 * Seattle, WA 98195
yuuji@0 23 * Internet: MRC@CAC.Washington.EDU
yuuji@0 24 *
yuuji@0 25 * Date: 11 May 1989
yuuji@0 26 * Last Edited: 16 August 2007
yuuji@0 27 */
yuuji@0 28
yuuji@0 29 #include "tcp_unix.h" /* must be before osdep includes tcp.h */
yuuji@0 30 #include "mail.h"
yuuji@0 31 #include "osdep.h"
yuuji@0 32 #include <ctype.h>
yuuji@0 33 #include <stdio.h>
yuuji@0 34 #include <sys/stat.h>
yuuji@0 35 #include <sys/time.h>
yuuji@0 36 #include <sys/tiuser.h>
yuuji@0 37 #include <sys/stropts.h>
yuuji@0 38 #include <sys/socket.h>
yuuji@0 39 #include <sys/poll.h>
yuuji@0 40 #include <netinet/in.h>
yuuji@0 41 #include <arpa/inet.h>
yuuji@0 42 #include <netdb.h>
yuuji@0 43 #include <errno.h>
yuuji@0 44 #include <pwd.h>
yuuji@0 45 #include <shadow.h>
yuuji@0 46 #include <sys/select.h>
yuuji@0 47 #include "misc.h"
yuuji@0 48
yuuji@0 49 extern int sys_nerr;
yuuji@0 50 extern char *sys_errlist[];
yuuji@0 51
yuuji@0 52 #define DIR_SIZE(d) d->d_reclen
yuuji@0 53
yuuji@0 54 #define toint(c) ((c)-'0')
yuuji@0 55 #define isodigit(c) (((unsigned)(c)>=060)&((unsigned)(c)<=067))
yuuji@0 56
yuuji@0 57
yuuji@0 58 #include "fs_unix.c"
yuuji@0 59 #include "ftl_unix.c"
yuuji@0 60 #include "nl_unix.c"
yuuji@0 61 #define env_init ENV_INIT
yuuji@0 62 #include "env_unix.c"
yuuji@0 63 #undef env_init
yuuji@0 64 #define getpeername Getpeername
yuuji@0 65 #define fork vfork
yuuji@0 66 #include "tcp_unix.c"
yuuji@0 67 #include "gr_waitp.c"
yuuji@0 68 #include "flocksim.c"
yuuji@0 69 #include "scandir.c"
yuuji@0 70 #include "tz_sv4.c"
yuuji@0 71 #include "utime.c"
yuuji@0 72
yuuji@0 73 /* Jacket around env_init() to work around PTX inetd braindamage */
yuuji@0 74
yuuji@0 75 static char may_need_server_init = T;
yuuji@0 76
yuuji@0 77 long env_init (char *user,char *home)
yuuji@0 78 {
yuuji@0 79 if (may_need_server_init) { /* maybe need to do server init cruft? */
yuuji@0 80 may_need_server_init = NIL; /* not any more we don't */
yuuji@0 81 if (!getuid ()) { /* if root, we're most likely a server */
yuuji@0 82 t_sync (0); /* PTX inetd is stupid, stupid, stupid */
yuuji@0 83 ioctl (0,I_PUSH,"tirdwr");/* it needs this cruft, else servers won't */
yuuji@0 84 dup2 (0,1); /* work. How obnoxious!!! */
yuuji@0 85 }
yuuji@0 86 }
yuuji@0 87 ENV_INIT (user,home); /* call the real routine */
yuuji@0 88 }
yuuji@0 89
yuuji@0 90 /* Emulator for BSD gethostid() call
yuuji@0 91 * Returns: unique identifier for this machine
yuuji@0 92 */
yuuji@0 93
yuuji@0 94 long gethostid (void)
yuuji@0 95 {
yuuji@0 96 struct sockaddr_in sin;
yuuji@0 97 int inet = t_open (TLI_TCP, O_RDWR, 0);
yuuji@0 98 if (inet < 0) return 0;
yuuji@0 99 getmyinaddr (inet,&sin,sizeof (sin));
yuuji@0 100 close (inet);
yuuji@0 101 return sin.sin_addr.s_addr;
yuuji@0 102 }
yuuji@0 103
yuuji@0 104
yuuji@0 105 /* Replaced version of getpeername() that jackets into getpeerinaddr()
yuuji@0 106 * Accepts: file descriptor
yuuji@0 107 * pointer to Internet socket addr
yuuji@0 108 * length
yuuji@0 109 * Returns: zero if success, data in socket addr
yuuji@0 110 */
yuuji@0 111
yuuji@0 112 int Getpeername (int s,struct sockaddr *name,int *namelen)
yuuji@0 113 {
yuuji@0 114 return getpeerinaddr (s,(struct sockaddr_in *) name,*namelen);
yuuji@0 115 }

UW-IMAP'd extensions by yuuji