imapext-2007

view src/osdep/vms/env_vms.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: VMS environment routines
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: 2 August 1994
26 * Last Edited: 30 August 2006
27 */
30 static char *myUserName = NIL; /* user name */
31 static char *myLocalHost = NIL; /* local host name */
32 static char *myHomeDir = NIL; /* home directory name */
33 static char *myNewsrc = NIL; /* newsrc file name */
35 #include "pmatch.c" /* include wildcard pattern matcher */
37 /* Environment manipulate parameters
38 * Accepts: function code
39 * function-dependent value
40 * Returns: function-dependent return value
41 */
43 void *env_parameters (long function,void *value)
44 {
45 void *ret = NIL;
46 switch ((int) function) {
47 case SET_USERNAME:
48 myUserName = cpystr ((char *) value);
49 case GET_USERNAME:
50 ret = (void *) myUserName;
51 break;
52 case SET_HOMEDIR:
53 myHomeDir = cpystr ((char *) value);
54 case GET_HOMEDIR:
55 ret = (void *) myHomeDir;
56 break;
57 case SET_LOCALHOST:
58 myLocalHost = cpystr ((char *) value);
59 case GET_LOCALHOST:
60 ret = (void *) myLocalHost;
61 break;
62 case SET_NEWSRC:
63 if (myNewsrc) fs_give ((void **) &myNewsrc);
64 myNewsrc = cpystr ((char *) value);
65 case GET_NEWSRC:
66 if (!myNewsrc) { /* set news file name if not defined */
67 char tmp[MAILTMPLEN];
68 sprintf (tmp,"%s:.newsrc",myhomedir ());
69 myNewsrc = cpystr (tmp);
70 }
71 ret = (void *) myNewsrc;
72 break;
73 }
74 return ret;
75 }
77 /* Write current time
78 * Accepts: destination string
79 * optional format of day-of-week prefix
80 * format of date and time
81 */
83 static void do_date (char *date,char *prefix,char *fmt)
84 {
85 time_t tn = time (0);
86 struct tm *t = localtime (&tn);
87 int zone = LOCALTIMEZONE + (t->tm_isdst ? 60 : 0);
88 if (prefix) { /* want day of week? */
89 sprintf (date,prefix,days[t->tm_wday]);
90 date += strlen (date); /* make next sprintf append */
91 }
92 /* output the date */
93 sprintf (date,fmt,t->tm_mday,months[t->tm_mon],t->tm_year+1900,
94 t->tm_hour,t->tm_min,t->tm_sec,zone/60,abs (zone) % 60);
95 }
98 /* Write current time in RFC 822 format
99 * Accepts: destination string
100 */
102 void rfc822_date (char *date)
103 {
104 do_date (date,"%s, ","%d %s %d %02d:%02d:%02d %+03d%02d");
105 }
108 /* Write current time in internal format
109 * Accepts: destination string
110 */
112 void internal_date (char *date)
113 {
114 do_date (date,NIL,"%02d-%s-%d %02d:%02d:%02d %+03d%02d");
115 }
117 /* Return my user name
118 * Returns: my user name
119 */
121 char *myusername ()
122 {
123 struct stat sbuf;
124 char tmp[MAILTMPLEN];
126 if (!myUserName) { /* get user name if don't have it yet */
127 myUserName = cpystr (cuserid (NIL));
128 myHomeDir = cpystr ("SYS$LOGIN");
129 }
130 return myUserName;
131 }
134 /* Return my home directory name
135 * Returns: my home directory name
136 */
138 char *myhomedir ()
139 {
140 if (!myHomeDir) myusername ();/* initialize if first time */
141 return myHomeDir;
142 }
145 /* Determine default prototype stream to user
146 * Accepts: type (NIL for create, T for append)
147 * Returns: default prototype stream
148 */
150 MAILSTREAM *default_proto (long type)
151 {
152 return NIL; /* no default prototype */
153 }
155 /* Emulator for BSD syslog() routine
156 * Accepts: priority
157 * message
158 * parameters
159 */
161 void syslog (int priority,const char *message,...)
162 {
163 }
166 /* Emulator for BSD openlog() routine
167 * Accepts: identity
168 * options
169 * facility
170 */
172 void openlog (const char *ident,int logopt,int facility)
173 {
174 }

UW-IMAP'd extensions by yuuji