xref: /original-bsd/usr.bin/window/startup.c (revision fd0bff90)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  */
17 
18 #ifndef lint
19 static char sccsid[] = "@(#)startup.c	3.23 (Berkeley) 07/24/89";
20 #endif /* not lint */
21 
22 #include "defs.h"
23 #include "value.h"
24 #include "var.h"
25 #include "char.h"
26 #include "local.h"
27 
28 doconfig()
29 {
30 	char buf[100];
31 	char *home;
32 	static char runcom[] = RUNCOM;
33 
34 	if ((home = getenv("HOME")) == 0)
35 		home = ".";
36 	(void) sprintf(buf, "%.*s/%s",
37 		(sizeof buf - sizeof runcom) / sizeof (char) - 1,
38 		home, runcom);
39 	return dosource(buf);
40 }
41 
42 /*
43  * The default is two windows of equal size.
44  */
45 dodefault()
46 {
47 	struct ww *w;
48 	register r = wwnrow / 2 - 1;
49 
50 	if (openwin(1, r + 2, 0, wwnrow - r - 2, wwncol, default_nline,
51 		(char *) 0, 1, 1, default_shellfile, default_shell) == 0)
52 		return;
53 	if ((w = openwin(0, 1, 0, r, wwncol, default_nline,
54 		(char *) 0, 1, 1, default_shellfile, default_shell)) == 0)
55 		return;
56 	wwprintf(w, "Escape character is %s.\r\n", unctrl(escapec));
57 }
58 
59 setvars()
60 {
61 	/* try to use a random ordering to balance the tree */
62 	(void) var_setnum("nrow", wwnrow);
63 	(void) var_setnum("ncol", wwncol);
64 	(void) var_setnum("baud", wwbaud);
65 	(void) var_setnum("m_rev", WWM_REV);
66 	(void) var_setnum("m_blk", WWM_BLK);
67 	(void) var_setnum("m_ul", WWM_UL);
68 	(void) var_setnum("m_grp", WWM_GRP);
69 	(void) var_setnum("m_dim", WWM_DIM);
70 	(void) var_setnum("m_usr", WWM_USR);
71 	(void) var_setstr("term", wwterm);
72 	(void) var_setnum("modes", wwavailmodes);
73 }
74