imapext-2007
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/osdep/unix/os_ptx.c Mon Sep 14 15:17:45 2009 +0900 1.3 @@ -0,0 +1,115 @@ 1.4 +/* ======================================================================== 1.5 + * Copyright 1988-2007 University of Washington 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * 1.14 + * ======================================================================== 1.15 + */ 1.16 + 1.17 +/* 1.18 + * Program: Operating-system dependent routines -- PTX version 1.19 + * 1.20 + * Author: Mark Crispin 1.21 + * Networks and Distributed Computing 1.22 + * Computing & Communications 1.23 + * University of Washington 1.24 + * Administration Building, AG-44 1.25 + * Seattle, WA 98195 1.26 + * Internet: MRC@CAC.Washington.EDU 1.27 + * 1.28 + * Date: 11 May 1989 1.29 + * Last Edited: 16 August 2007 1.30 + */ 1.31 + 1.32 +#include "tcp_unix.h" /* must be before osdep includes tcp.h */ 1.33 +#include "mail.h" 1.34 +#include "osdep.h" 1.35 +#include <ctype.h> 1.36 +#include <stdio.h> 1.37 +#include <sys/stat.h> 1.38 +#include <sys/time.h> 1.39 +#include <sys/tiuser.h> 1.40 +#include <sys/stropts.h> 1.41 +#include <sys/socket.h> 1.42 +#include <sys/poll.h> 1.43 +#include <netinet/in.h> 1.44 +#include <arpa/inet.h> 1.45 +#include <netdb.h> 1.46 +#include <errno.h> 1.47 +#include <pwd.h> 1.48 +#include <shadow.h> 1.49 +#include <sys/select.h> 1.50 +#include "misc.h" 1.51 + 1.52 +extern int sys_nerr; 1.53 +extern char *sys_errlist[]; 1.54 + 1.55 +#define DIR_SIZE(d) d->d_reclen 1.56 + 1.57 +#define toint(c) ((c)-'0') 1.58 +#define isodigit(c) (((unsigned)(c)>=060)&((unsigned)(c)<=067)) 1.59 + 1.60 + 1.61 +#include "fs_unix.c" 1.62 +#include "ftl_unix.c" 1.63 +#include "nl_unix.c" 1.64 +#define env_init ENV_INIT 1.65 +#include "env_unix.c" 1.66 +#undef env_init 1.67 +#define getpeername Getpeername 1.68 +#define fork vfork 1.69 +#include "tcp_unix.c" 1.70 +#include "gr_waitp.c" 1.71 +#include "flocksim.c" 1.72 +#include "scandir.c" 1.73 +#include "tz_sv4.c" 1.74 +#include "utime.c" 1.75 + 1.76 +/* Jacket around env_init() to work around PTX inetd braindamage */ 1.77 + 1.78 +static char may_need_server_init = T; 1.79 + 1.80 +long env_init (char *user,char *home) 1.81 +{ 1.82 + if (may_need_server_init) { /* maybe need to do server init cruft? */ 1.83 + may_need_server_init = NIL; /* not any more we don't */ 1.84 + if (!getuid ()) { /* if root, we're most likely a server */ 1.85 + t_sync (0); /* PTX inetd is stupid, stupid, stupid */ 1.86 + ioctl (0,I_PUSH,"tirdwr");/* it needs this cruft, else servers won't */ 1.87 + dup2 (0,1); /* work. How obnoxious!!! */ 1.88 + } 1.89 + } 1.90 + ENV_INIT (user,home); /* call the real routine */ 1.91 +} 1.92 + 1.93 +/* Emulator for BSD gethostid() call 1.94 + * Returns: unique identifier for this machine 1.95 + */ 1.96 + 1.97 +long gethostid (void) 1.98 +{ 1.99 + struct sockaddr_in sin; 1.100 + int inet = t_open (TLI_TCP, O_RDWR, 0); 1.101 + if (inet < 0) return 0; 1.102 + getmyinaddr (inet,&sin,sizeof (sin)); 1.103 + close (inet); 1.104 + return sin.sin_addr.s_addr; 1.105 +} 1.106 + 1.107 + 1.108 +/* Replaced version of getpeername() that jackets into getpeerinaddr() 1.109 + * Accepts: file descriptor 1.110 + * pointer to Internet socket addr 1.111 + * length 1.112 + * Returns: zero if success, data in socket addr 1.113 + */ 1.114 + 1.115 +int Getpeername (int s,struct sockaddr *name,int *namelen) 1.116 +{ 1.117 + return getpeerinaddr (s,(struct sockaddr_in *) name,*namelen); 1.118 +}