imapext-2007

view 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 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: Environment routines -- TOPS-20 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: 1 August 1988
26 * Last Edited: 30 August 2006
27 */
30 /* Dedication:
31 * This file is dedicated with affection to the TOPS-20 operating system, which
32 * set standards for user and programmer friendliness that have still not been
33 * equaled by more `modern' operating systems.
34 * Wasureru mon ka!!!!
35 */
37 /* c-client environment parameters */
39 static char *myUserName = NIL; /* user name */
40 static char *myHomeDir = NIL; /* home directory name */
41 static char *myLocalHost = NIL; /* local host name */
42 static char *myNewsrc = NIL; /* newsrc file name */
43 static short no822tztext = NIL; /* disable RFC [2]822 timezone text */
46 #include "pmatch.c" /* include wildcard pattern matcher */
48 /* Environment manipulate parameters
49 * Accepts: function code
50 * function-dependent value
51 * Returns: function-dependent return value
52 */
54 void *env_parameters (long function,void *value)
55 {
56 void *ret = NIL;
57 switch ((int) function) {
58 case SET_USERNAME:
59 if (myUserName) fs_give ((void **) &myUserName);
60 myUserName = cpystr ((char *) value);
61 case GET_USERNAME:
62 ret = (void *) myUserName;
63 break;
64 case SET_HOMEDIR:
65 if (myHomeDir) fs_give ((void **) &myHomeDir);
66 myHomeDir = cpystr ((char *) value);
67 case GET_HOMEDIR:
68 ret = (void *) myHomeDir;
69 break;
70 case SET_LOCALHOST:
71 if (myLocalHost) fs_give ((void **) &myLocalHost);
72 myLocalHost = cpystr ((char *) value);
73 case GET_LOCALHOST:
74 ret = (void *) myLocalHost;
75 break;
76 case SET_NEWSRC:
77 if (myNewsrc) fs_give ((void **) &myNewsrc);
78 myNewsrc = cpystr ((char *) value);
79 case GET_NEWSRC:
80 ret = (void *) myNewsrc;
81 break;
82 case SET_DISABLE822TZTEXT:
83 no822tztext = value ? T : NIL;
84 case GET_DISABLE822TZTEXT:
85 ret = (void *) (no822tztext ? VOIDT : NIL);
86 break;
87 }
88 return ret;
89 }
91 /* Write current time in RFC 822 format
92 * Accepts: destination string
93 */
95 void rfc822_date (char *date)
96 {
97 char *s;
98 int argblk[4];
99 argblk[1] = (int) (date-1);
100 argblk[2] = -1; /* time now */
101 argblk[3] = OT_822; /* want RFC [2]822 format */
102 jsys (ODTIM,argblk);
103 /* suppress time zone text if desired */
104 if (no822tztext && (s = strstr (date," ("))) *s = NIL;
105 }
108 /* Write current time in internal format
109 * Accepts: destination string
110 */
112 void internal_date (char *date)
113 {
114 int argblk[5];
115 argblk[1] = (int) (date-1);
116 argblk[2] = -1; /* time now */
117 argblk[3] = OT_4YR; /* output in 4-digit year format */
118 jsys (ODTIM,argblk);
119 argblk[2] = ' '; /* delimit with space */
120 jsys (BOUT,argblk);
121 argblk[2] = -1; /* time now */
122 argblk[4] = 0; /* no flags */
123 jsys (ODCNV,argblk); /* get time zone */
124 argblk[2] = ((argblk[4] & 077000000) >> 18) * -100;
125 /* add an hour if summer time */
126 if (argblk[4] & IC_ADS) argblk[2] += 100;
127 argblk[3] = 0340005000012;
128 jsys (NOUT,argblk);
129 }
131 /* Return my user name
132 * Accepts: pointer to optional flags
133 * Returns: my user name
134 */
136 char *myusername_full (unsigned long *flags)
137 {
138 if (!myUserName) { /* get user name if don't have it yet */
139 char tmp[MAILTMPLEN];
140 int argblk[5],i;
141 jsys (GJINF,argblk); /* get job poop */
142 if (!(i = argblk[1])) { /* remember user number */
143 if (flags) *flags = MU_NOTLOGGEDIN;
144 return "SYSTEM"; /* not logged in */
145 }
146 argblk[1] = (int) (tmp-1); /* destination */
147 argblk[2] = i; /* user number */
148 jsys (DIRST,argblk); /* get user name string */
149 myUserName = cpystr (tmp); /* copy user name */
150 argblk[1] = 0; /* no flags */
151 argblk[2] = i; /* user number */
152 argblk[3] = 0; /* no stepping */
153 jsys (RCDIR,argblk); /* get home directory */
154 argblk[1] = (int) (tmp-1); /* destination */
155 argblk[2] = argblk[3]; /* home directory number */
156 jsys (DIRST,argblk); /* get home directory string */
157 myHomeDir = cpystr (tmp); /* copy home directory */
158 if (!myNewsrc) { /* set news file name if not defined */
159 sprintf (tmp,"%sNEWSRC",myhomedir ());
160 myNewsrc = cpystr (tmp);
161 }
162 if (flags) *flags = MU_LOGGEDIN;
163 }
164 return myUserName;
165 }
167 /* Return my local host name
168 * Returns: my local host name
169 */
171 char *mylocalhost ()
172 {
173 if (!myLocalHost) { /* initialize if first time */
174 char tmp[MAILTMPLEN];
175 int argblk[5];
176 argblk[1] = _GTHNS; /* convert number to string */
177 argblk[2] = (int) (tmp-1);
178 argblk[3] = -1; /* want local host */
179 if (!jsys (GTHST,argblk)) strcpy (tmp,"LOCAL");
180 myLocalHost = cpystr (tmp);
181 }
182 return myLocalHost;
183 }
186 /* Return my home directory name
187 * Returns: my home directory name
188 */
190 char *myhomedir ()
191 {
192 if (!myHomeDir) myusername ();/* initialize if first time */
193 return myHomeDir ? myHomeDir : "";
194 }
197 /* Determine default prototype stream to user
198 * Accepts: type (NIL for create, T for append)
199 * Returns: default prototype stream
200 */
202 MAILSTREAM *default_proto (long type)
203 {
204 return NIL; /* no default prototype */
205 }
207 /* Emulator for BSD syslog() routine
208 * Accepts: priority
209 * message
210 * parameters
211 */
213 void syslog (int priority,const char *message,...)
214 {
215 }
218 /* Emulator for BSD openlog() routine
219 * Accepts: identity
220 * options
221 * facility
222 */
224 void openlog (const char *ident,int logopt,int facility)
225 {
226 }

UW-IMAP'd extensions by yuuji