imapext-2007

diff src/osdep/tops-20/env_t20.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/tops-20/env_t20.c	Mon Sep 14 15:17:45 2009 +0900
     1.3 @@ -0,0 +1,226 @@
     1.4 +/* ========================================================================
     1.5 + * Copyright 1988-2006 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:	Environment routines -- TOPS-20 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:	1 August 1988
    1.29 + * Last Edited:	30 August 2006
    1.30 + */
    1.31 +
    1.32 +
    1.33 +/* Dedication:
    1.34 + * This file is dedicated with affection to the TOPS-20 operating system, which
    1.35 + * set standards for user and programmer friendliness that have still not been
    1.36 + * equaled by more `modern' operating systems.
    1.37 + * Wasureru mon ka!!!!
    1.38 + */
    1.39 +
    1.40 +/* c-client environment parameters */
    1.41 +
    1.42 +static char *myUserName = NIL;	/* user name */
    1.43 +static char *myHomeDir = NIL;	/* home directory name */
    1.44 +static char *myLocalHost = NIL;	/* local host name */
    1.45 +static char *myNewsrc = NIL;	/* newsrc file name */
    1.46 +static short no822tztext = NIL;	/* disable RFC [2]822 timezone text */
    1.47 +
    1.48 +
    1.49 +#include "pmatch.c"		/* include wildcard pattern matcher */
    1.50 +
    1.51 +/* Environment manipulate parameters
    1.52 + * Accepts: function code
    1.53 + *	    function-dependent value
    1.54 + * Returns: function-dependent return value
    1.55 + */
    1.56 +
    1.57 +void *env_parameters (long function,void *value)
    1.58 +{
    1.59 +  void *ret = NIL;
    1.60 +  switch ((int) function) {
    1.61 +  case SET_USERNAME:
    1.62 +    if (myUserName) fs_give ((void **) &myUserName);
    1.63 +    myUserName = cpystr ((char *) value);
    1.64 +  case GET_USERNAME:
    1.65 +    ret = (void *) myUserName;
    1.66 +    break;
    1.67 +  case SET_HOMEDIR:
    1.68 +    if (myHomeDir) fs_give ((void **) &myHomeDir);
    1.69 +    myHomeDir = cpystr ((char *) value);
    1.70 +  case GET_HOMEDIR:
    1.71 +    ret = (void *) myHomeDir;
    1.72 +    break;
    1.73 +  case SET_LOCALHOST:
    1.74 +    if (myLocalHost) fs_give ((void **) &myLocalHost);
    1.75 +    myLocalHost = cpystr ((char *) value);
    1.76 +  case GET_LOCALHOST:
    1.77 +    ret = (void *) myLocalHost;
    1.78 +    break;
    1.79 +  case SET_NEWSRC:
    1.80 +    if (myNewsrc) fs_give ((void **) &myNewsrc);
    1.81 +    myNewsrc = cpystr ((char *) value);
    1.82 +  case GET_NEWSRC:
    1.83 +    ret = (void *) myNewsrc;
    1.84 +    break;
    1.85 +  case SET_DISABLE822TZTEXT:
    1.86 +    no822tztext = value ? T : NIL;
    1.87 +  case GET_DISABLE822TZTEXT:
    1.88 +    ret = (void *) (no822tztext ? VOIDT : NIL);
    1.89 +    break;
    1.90 +  }
    1.91 +  return ret;
    1.92 +}
    1.93 +
    1.94 +/* Write current time in RFC 822 format
    1.95 + * Accepts: destination string
    1.96 + */
    1.97 +
    1.98 +void rfc822_date (char *date)
    1.99 +{
   1.100 +  char *s;
   1.101 +  int argblk[4];
   1.102 +  argblk[1] = (int) (date-1);
   1.103 +  argblk[2] = -1;		/* time now */
   1.104 +  argblk[3] = OT_822;		/* want RFC [2]822 format */
   1.105 +  jsys (ODTIM,argblk);
   1.106 +				/* suppress time zone text if desired */
   1.107 +  if (no822tztext && (s = strstr (date," ("))) *s = NIL;
   1.108 +}
   1.109 +
   1.110 +
   1.111 +/* Write current time in internal format
   1.112 + * Accepts: destination string
   1.113 + */
   1.114 +
   1.115 +void internal_date (char *date)
   1.116 +{
   1.117 +  int argblk[5];
   1.118 +  argblk[1] = (int) (date-1);
   1.119 +  argblk[2] = -1;		/* time now */
   1.120 +  argblk[3] = OT_4YR;		/* output in 4-digit year format */
   1.121 +  jsys (ODTIM,argblk);
   1.122 +  argblk[2] = ' ';		/* delimit with space */
   1.123 +  jsys (BOUT,argblk);
   1.124 +  argblk[2] = -1;		/* time now */
   1.125 +  argblk[4] = 0;		/* no flags */
   1.126 +  jsys (ODCNV,argblk);		/* get time zone */
   1.127 +  argblk[2] = ((argblk[4] & 077000000) >> 18) * -100;
   1.128 +				/* add an hour if summer time */
   1.129 +  if (argblk[4] & IC_ADS) argblk[2] += 100;
   1.130 +  argblk[3] = 0340005000012;
   1.131 +  jsys (NOUT,argblk);
   1.132 +}
   1.133 +
   1.134 +/* Return my user name
   1.135 + * Accepts: pointer to optional flags
   1.136 + * Returns: my user name
   1.137 + */
   1.138 +
   1.139 +char *myusername_full (unsigned long *flags)
   1.140 +{
   1.141 +  if (!myUserName) {		/* get user name if don't have it yet */
   1.142 +    char tmp[MAILTMPLEN];
   1.143 +    int argblk[5],i;
   1.144 +    jsys (GJINF,argblk);	/* get job poop */
   1.145 +    if (!(i = argblk[1])) {	/* remember user number */
   1.146 +      if (flags) *flags = MU_NOTLOGGEDIN;
   1.147 +      return "SYSTEM";		/* not logged in */
   1.148 +    }
   1.149 +    argblk[1] = (int) (tmp-1);	/* destination */
   1.150 +    argblk[2] = i;		/* user number */
   1.151 +    jsys (DIRST,argblk);	/* get user name string */
   1.152 +    myUserName = cpystr (tmp);	/* copy user name */
   1.153 +    argblk[1] = 0;		/* no flags */
   1.154 +    argblk[2] = i;		/* user number */
   1.155 +    argblk[3] = 0;		/* no stepping */
   1.156 +    jsys (RCDIR,argblk);	/* get home directory */
   1.157 +    argblk[1] = (int) (tmp-1);	/* destination */
   1.158 +    argblk[2] = argblk[3];	/* home directory number */
   1.159 +    jsys (DIRST,argblk);	/* get home directory string */
   1.160 +    myHomeDir = cpystr (tmp);	/* copy home directory */
   1.161 +    if (!myNewsrc) {		/* set news file name if not defined */
   1.162 +      sprintf (tmp,"%sNEWSRC",myhomedir ());
   1.163 +      myNewsrc = cpystr (tmp);
   1.164 +    }
   1.165 +    if (flags) *flags = MU_LOGGEDIN;
   1.166 +  }
   1.167 +  return myUserName;
   1.168 +}
   1.169 +
   1.170 +/* Return my local host name
   1.171 + * Returns: my local host name
   1.172 + */
   1.173 +
   1.174 +char *mylocalhost ()
   1.175 +{
   1.176 +  if (!myLocalHost) {		/* initialize if first time */
   1.177 +    char tmp[MAILTMPLEN];
   1.178 +    int argblk[5];
   1.179 +    argblk[1] = _GTHNS;		/* convert number to string */
   1.180 +    argblk[2] = (int) (tmp-1);
   1.181 +    argblk[3] = -1;		/* want local host */
   1.182 +    if (!jsys (GTHST,argblk)) strcpy (tmp,"LOCAL");
   1.183 +    myLocalHost = cpystr (tmp);
   1.184 +  }
   1.185 +  return myLocalHost;
   1.186 +}
   1.187 +
   1.188 +
   1.189 +/* Return my home directory name
   1.190 + * Returns: my home directory name
   1.191 + */
   1.192 +
   1.193 +char *myhomedir ()
   1.194 +{
   1.195 +  if (!myHomeDir) myusername ();/* initialize if first time */
   1.196 +  return myHomeDir ? myHomeDir : "";
   1.197 +}
   1.198 +
   1.199 +
   1.200 +/* Determine default prototype stream to user
   1.201 + * Accepts: type (NIL for create, T for append)
   1.202 + * Returns: default prototype stream
   1.203 + */
   1.204 +
   1.205 +MAILSTREAM *default_proto (long type)
   1.206 +{
   1.207 +  return NIL;			/* no default prototype */
   1.208 +}
   1.209 +
   1.210 +/* Emulator for BSD syslog() routine
   1.211 + * Accepts: priority
   1.212 + *	    message
   1.213 + *	    parameters
   1.214 + */
   1.215 +
   1.216 +void syslog (int priority,const char *message,...)
   1.217 +{
   1.218 +}
   1.219 +
   1.220 +
   1.221 +/* Emulator for BSD openlog() routine
   1.222 + * Accepts: identity
   1.223 + *	    options
   1.224 + *	    facility
   1.225 + */
   1.226 +
   1.227 +void openlog (const char *ident,int logopt,int facility)
   1.228 +{
   1.229 +}

UW-IMAP'd extensions by yuuji