imapext-2007
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/osdep/vms/env_vms.c Mon Sep 14 15:17:45 2009 +0900 1.3 @@ -0,0 +1,174 @@ 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: VMS environment routines 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: 2 August 1994 1.29 + * Last Edited: 30 August 2006 1.30 + */ 1.31 + 1.32 + 1.33 +static char *myUserName = NIL; /* user name */ 1.34 +static char *myLocalHost = NIL; /* local host name */ 1.35 +static char *myHomeDir = NIL; /* home directory name */ 1.36 +static char *myNewsrc = NIL; /* newsrc file name */ 1.37 + 1.38 +#include "pmatch.c" /* include wildcard pattern matcher */ 1.39 + 1.40 +/* Environment manipulate parameters 1.41 + * Accepts: function code 1.42 + * function-dependent value 1.43 + * Returns: function-dependent return value 1.44 + */ 1.45 + 1.46 +void *env_parameters (long function,void *value) 1.47 +{ 1.48 + void *ret = NIL; 1.49 + switch ((int) function) { 1.50 + case SET_USERNAME: 1.51 + myUserName = cpystr ((char *) value); 1.52 + case GET_USERNAME: 1.53 + ret = (void *) myUserName; 1.54 + break; 1.55 + case SET_HOMEDIR: 1.56 + myHomeDir = cpystr ((char *) value); 1.57 + case GET_HOMEDIR: 1.58 + ret = (void *) myHomeDir; 1.59 + break; 1.60 + case SET_LOCALHOST: 1.61 + myLocalHost = cpystr ((char *) value); 1.62 + case GET_LOCALHOST: 1.63 + ret = (void *) myLocalHost; 1.64 + break; 1.65 + case SET_NEWSRC: 1.66 + if (myNewsrc) fs_give ((void **) &myNewsrc); 1.67 + myNewsrc = cpystr ((char *) value); 1.68 + case GET_NEWSRC: 1.69 + if (!myNewsrc) { /* set news file name if not defined */ 1.70 + char tmp[MAILTMPLEN]; 1.71 + sprintf (tmp,"%s:.newsrc",myhomedir ()); 1.72 + myNewsrc = cpystr (tmp); 1.73 + } 1.74 + ret = (void *) myNewsrc; 1.75 + break; 1.76 + } 1.77 + return ret; 1.78 +} 1.79 + 1.80 +/* Write current time 1.81 + * Accepts: destination string 1.82 + * optional format of day-of-week prefix 1.83 + * format of date and time 1.84 + */ 1.85 + 1.86 +static void do_date (char *date,char *prefix,char *fmt) 1.87 +{ 1.88 + time_t tn = time (0); 1.89 + struct tm *t = localtime (&tn); 1.90 + int zone = LOCALTIMEZONE + (t->tm_isdst ? 60 : 0); 1.91 + if (prefix) { /* want day of week? */ 1.92 + sprintf (date,prefix,days[t->tm_wday]); 1.93 + date += strlen (date); /* make next sprintf append */ 1.94 + } 1.95 + /* output the date */ 1.96 + sprintf (date,fmt,t->tm_mday,months[t->tm_mon],t->tm_year+1900, 1.97 + t->tm_hour,t->tm_min,t->tm_sec,zone/60,abs (zone) % 60); 1.98 +} 1.99 + 1.100 + 1.101 +/* Write current time in RFC 822 format 1.102 + * Accepts: destination string 1.103 + */ 1.104 + 1.105 +void rfc822_date (char *date) 1.106 +{ 1.107 + do_date (date,"%s, ","%d %s %d %02d:%02d:%02d %+03d%02d"); 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 + do_date (date,NIL,"%02d-%s-%d %02d:%02d:%02d %+03d%02d"); 1.118 +} 1.119 + 1.120 +/* Return my user name 1.121 + * Returns: my user name 1.122 + */ 1.123 + 1.124 +char *myusername () 1.125 +{ 1.126 + struct stat sbuf; 1.127 + char tmp[MAILTMPLEN]; 1.128 + 1.129 + if (!myUserName) { /* get user name if don't have it yet */ 1.130 + myUserName = cpystr (cuserid (NIL)); 1.131 + myHomeDir = cpystr ("SYS$LOGIN"); 1.132 + } 1.133 + return myUserName; 1.134 +} 1.135 + 1.136 + 1.137 +/* Return my home directory name 1.138 + * Returns: my home directory name 1.139 + */ 1.140 + 1.141 +char *myhomedir () 1.142 +{ 1.143 + if (!myHomeDir) myusername ();/* initialize if first time */ 1.144 + return myHomeDir; 1.145 +} 1.146 + 1.147 + 1.148 +/* Determine default prototype stream to user 1.149 + * Accepts: type (NIL for create, T for append) 1.150 + * Returns: default prototype stream 1.151 + */ 1.152 + 1.153 +MAILSTREAM *default_proto (long type) 1.154 +{ 1.155 + return NIL; /* no default prototype */ 1.156 +} 1.157 + 1.158 +/* Emulator for BSD syslog() routine 1.159 + * Accepts: priority 1.160 + * message 1.161 + * parameters 1.162 + */ 1.163 + 1.164 +void syslog (int priority,const char *message,...) 1.165 +{ 1.166 +} 1.167 + 1.168 + 1.169 +/* Emulator for BSD openlog() routine 1.170 + * Accepts: identity 1.171 + * options 1.172 + * facility 1.173 + */ 1.174 + 1.175 +void openlog (const char *ident,int logopt,int facility) 1.176 +{ 1.177 +}