|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T i
Length: 7197 (0x1c1d)
Types: TextFile
Names: »initialize.uts«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
└─⟦this⟧ »EUUGD11/euug-87hel/sec1/elm/src/initialize.uts«
From hpccc!mcgregor@hplabs.ARPA Fri May 9 16:05:10 1986
Received: from hplabs.ARPA by hpldat ; Fri, 9 May 86 16:05:01 pdt
Message-Id: <8605092305.AA00689@hpldat>
Received: by hplabs.ARPA ; Fri, 9 May 86 16:01:29 pdt
From: Scott McGregor <hpccc!mcgregor@hplabs.ARPA>
To: taylor@hplabs
Date: Fri, 9 May 86 15:23:16 PDT
Subject: initialize.c
X-Mailer: msg [version 3.3a]
/** initialize.c **/
/***** Initialize - read in all the defaults etc etc
(C) Copyright 1985 Dave Taylor
*****/
#include "headers.h"
#ifdef BSD
# include <sgtty.h>
#else
# include <termio.h>
#endif
#include <pwd.h>
#ifdef BSD
# include <sys/time.h>
#else
# include <time.h>
#endif
#include <signal.h>
#include <ctype.h>
#include <errno.h>
#ifdef BSD
#undef tolower
#endif
extern int errno; /* system error number on failure */
char *error_name(), *error_description();
char *expand_logname(), *getenv(), *getlogin();
initialize(InitScreen_to)
int InitScreen_to;
{
struct passwd *pass, *getpwnam();
register int i;
int quit_signal(), term_signal(), ill_signal(),
fpe_signal(), bus_signal(), segv_signal(),
alarm_signal();
char buffer[SLEN], *cp;
userid = getuid();
groupid = getgid();
strcpy(home,((cp = getenv("HOME")) == NULL)? "" : cp);
strcpy(shell,((cp = getenv("SHELL")) == NULL)? "" : cp);
if (debug) { /* setup for dprintf statements! */
char filename[SLEN];
sprintf(filename, "%s/%s", home, DEBUG);
if ((debugfile = fopen(filename, "w")) == NULL) {
debug = 0; /* otherwise 'leave' will try to log! */
leave(fprintf(stderr,"Could not open file %s for debug output!\n",
filename));
}
if (InitScreen_to) {
InitScreen();
}
chown(filename, userid, groupid); /* file owned by user */
fprintf(debugfile, "Debug output of the MSG program. Version %s\n\n",
VERSION);
}
#ifndef UTS
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, quit_signal); /* Quit signal */
signal(SIGTERM, term_signal); /* Terminate signal */
signal(SIGILL, ill_signal); /* Illegal instruction */
signal(SIGFPE, fpe_signal); /* Floating point exception */
signal(SIGBUS, bus_signal); /* Bus error */
signal(SIGSEGV, segv_signal); /* Segmentation Violation */
#endif
signal(SIGALRM, alarm_signal); /* Process Timer Alarm */
if (isa3270()) {
isatube++;
dprint0(1, "** We're using a 3270 tube!! **\n");
}
#ifndef UTS
get_connections(); /* who do we talk to directly?? */
#endif
open_domain_file(); /* if we got it, we want it! */
get_term_chars();
gethostname(hostname, sizeof(hostname));
if ((cp = getlogin()) == NULL)
cuserid(username);
else
strcpy(username, cp);
/* now let's get the full username.. */
if ((pass = getpwnam(username)) == NULL) {
error("Couldn't read password entry??");
strcpy(full_username, username);
}
else {
for (i=0; pass->pw_gecos[i] != '\0' && pass->pw_gecos[i] != ',';
i++)
if (pass->pw_gecos[i] == '&') {
full_username[i] = '\0';
strcat(full_username, expand_logname());
i = strlen(full_username) - 2;
}
else
full_username[i] = pass->pw_gecos[i];
full_username[i] = '\0';
}
if ((cp = getenv("EDITOR")) == NULL)
strcpy(editor,default_editor);
else
strcpy(editor, cp);
if (! mail_only) {
mailbox[0] = '\0';
strcpy(prefixchars, "> "); /* default message prefix */
}
read_rc_file(); /* reading the .msgrc next... */
/** now try to expand the specified filename... **/
if (strlen(infile) > 0) {
(void) expand_filename(infile);
if ((errno = can_access(infile, READ_ACCESS))) {
dprint2(1,"Error: given file %s as mailbox - unreadable (%s)!\n",
infile, error_name(errno));
fprintf(stderr,"Can't open mailbox '%s' for reading!\n", infile);
exit(1);
}
}
/** check to see if the user has defined a LINES or COLUMNS
value different to that in the termcap entry (for
windowing systems, of course!) **/
if ((cp = getenv("LINES")) != NULL && isdigit(*cp)) {
sscanf(cp, "%d", &LINES);
LINES -= 1; /* kludge for HP Window system? ... */
}
if ((cp = getenv("COLUMNS")) != NULL && isdigit(*cp))
sscanf(cp, "%d", &COLUMNS);
/** fix the shell if needed **/
if (shell[0] != '/') {
sprintf(buffer, "/bin/%s", shell);
strcpy(shell, buffer);
}
if (! mail_only) {
mailbox_defined = (mailbox[0] != '\0');
/* get the cursor control keys... */
if ((cp = return_value_of("ku")) == NULL || strlen(cp) != 2)
cursor_control = FALSE;
else {
strcpy(up, cp);
if ((cp = return_value_of("kd")) == NULL || strlen(cp) != 2)
cursor_control = FALSE;
else {
strcpy(down, cp);
cursor_control = TRUE;
transmit_functions(ON);
}
}
strcpy(start_highlight, "->");
end_highlight[0] = '\0';
if (!arrow_cursor) { /* try to use inverse bar instead */
if ((cp = return_value_of("so")) != NULL) {
strcpy(start_highlight, cp);
if ((cp = return_value_of("se")) == NULL)
strcpy(start_highlight, "->");
else {
strcpy(end_highlight, cp);
has_highlighting = TRUE;
}
}
}
}
if (read_aliases)
read_alias_files();
if (! mail_only) {
if (mini_menu)
headers_per_page = LINES - 13;
else
headers_per_page = LINES - 8; /* 5 more headers! */
newmbox(1,FALSE, TRUE); /* read in the mailbox! */
}
init_findnode(); /* set up the path alias stuff */
dprint0(2,"\n-- end of initialization phase --\n");
dprint3(2,"\thostname = %s\n\tusername = %s\n\tfull_username = \"%s\"\n",
hostname, username, full_username);
dprint3(2,"\thome = %s\n\teditor = %s\n\tmailbox = %s\n",
home, editor, mailbox);
dprint3(2,"\tinfile = %s\n\tfolder-dir = %s\n\tprintout = \"%s\"\n",
infile, folders, printout);
dprint3(2,"\tsavefile = %s\n\tprefix = \"%s\"\n\tshell = %s\n",
savefile, prefixchars, shell);
dprint0(1,"-- beginning execution phase --\n\n");
}
get_term_chars()
{
/** This routine sucks out the special terminal characters
ERASE and KILL for use in the input routine. The meaning
of the characters are (dare I say it?) fairly obvious... **/
#ifdef BSD
struct sgttyb term_buffer;
# define TCGETA TIOCGETP
#else
struct termio term_buffer;
#endif
if (ioctl(STANDARD_INPUT, TCGETA, &term_buffer) == -1) {
dprint1(1,"Error: %s encountered on ioctl call (get_term_chars)\n",
error_name(errno));
/* set to defaults for terminal driver */
backspace = BACKSPACE;
kill_line = ctrl('U');
}
else {
#ifdef BSD
backspace = term_buffer.sg_erase;
kill_line = term_buffer.sg_kill;
#else
backspace = term_buffer.c_cc[VERASE];
kill_line = term_buffer.c_cc[VKILL];
#endif
}
}
char *expand_logname()
{
/** Return logname in a nice format (for expanding "&" in the
/etc/passwd file) **/
static char buffer[SLEN];
register int i;
if (strlen(username) == 0)
buffer[0] = '\0';
else {
buffer[0] = toupper(username[0]);
for (i=1; username[i] != '\0'; i++)
buffer[i] = tolower(username[i]);
buffer[i] = '\0';
}
return( (char *) buffer);
}