/* ======================================================================== * Copyright 1988-2006 University of Washington * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * * ======================================================================== */ /* * Program: VMS environment routines * * Author: Mark Crispin * Networks and Distributed Computing * Computing & Communications * University of Washington * Administration Building, AG-44 * Seattle, WA 98195 * Internet: MRC@CAC.Washington.EDU * * Date: 2 August 1994 * Last Edited: 30 August 2006 */ static char *myUserName = NIL; /* user name */ static char *myLocalHost = NIL; /* local host name */ static char *myHomeDir = NIL; /* home directory name */ static char *myNewsrc = NIL; /* newsrc file name */ #include "pmatch.c" /* include wildcard pattern matcher */ /* Environment manipulate parameters * Accepts: function code * function-dependent value * Returns: function-dependent return value */ void *env_parameters (long function,void *value) { void *ret = NIL; switch ((int) function) { case SET_USERNAME: myUserName = cpystr ((char *) value); case GET_USERNAME: ret = (void *) myUserName; break; case SET_HOMEDIR: myHomeDir = cpystr ((char *) value); case GET_HOMEDIR: ret = (void *) myHomeDir; break; case SET_LOCALHOST: myLocalHost = cpystr ((char *) value); case GET_LOCALHOST: ret = (void *) myLocalHost; break; case SET_NEWSRC: if (myNewsrc) fs_give ((void **) &myNewsrc); myNewsrc = cpystr ((char *) value); case GET_NEWSRC: if (!myNewsrc) { /* set news file name if not defined */ char tmp[MAILTMPLEN]; sprintf (tmp,"%s:.newsrc",myhomedir ()); myNewsrc = cpystr (tmp); } ret = (void *) myNewsrc; break; } return ret; } /* Write current time * Accepts: destination string * optional format of day-of-week prefix * format of date and time */ static void do_date (char *date,char *prefix,char *fmt) { time_t tn = time (0); struct tm *t = localtime (&tn); int zone = LOCALTIMEZONE + (t->tm_isdst ? 60 : 0); if (prefix) { /* want day of week? */ sprintf (date,prefix,days[t->tm_wday]); date += strlen (date); /* make next sprintf append */ } /* output the date */ sprintf (date,fmt,t->tm_mday,months[t->tm_mon],t->tm_year+1900, t->tm_hour,t->tm_min,t->tm_sec,zone/60,abs (zone) % 60); } /* Write current time in RFC 822 format * Accepts: destination string */ void rfc822_date (char *date) { do_date (date,"%s, ","%d %s %d %02d:%02d:%02d %+03d%02d"); } /* Write current time in internal format * Accepts: destination string */ void internal_date (char *date) { do_date (date,NIL,"%02d-%s-%d %02d:%02d:%02d %+03d%02d"); } /* Return my user name * Returns: my user name */ char *myusername () { struct stat sbuf; char tmp[MAILTMPLEN]; if (!myUserName) { /* get user name if don't have it yet */ myUserName = cpystr (cuserid (NIL)); myHomeDir = cpystr ("SYS$LOGIN"); } return myUserName; } /* Return my home directory name * Returns: my home directory name */ char *myhomedir () { if (!myHomeDir) myusername ();/* initialize if first time */ return myHomeDir; } /* Determine default prototype stream to user * Accepts: type (NIL for create, T for append) * Returns: default prototype stream */ MAILSTREAM *default_proto (long type) { return NIL; /* no default prototype */ } /* Emulator for BSD syslog() routine * Accepts: priority * message * parameters */ void syslog (int priority,const char *message,...) { } /* Emulator for BSD openlog() routine * Accepts: identity * options * facility */ void openlog (const char *ident,int logopt,int facility) { }