1 /* $Id: maccfg.c,v 1.1.2.5 1999/03/28 02:06:10 ben Exp $ */
3 * maccfg.c -- Mac port configuration
21 static void get_string(struct strloc *l, char *d, size_t maxlen) {
25 GetIndString(s, l->id, l->idx);
27 /* maxlen includes a terminator */
30 for (i = 0; i < len; i++)
35 static void get_wordness(short id, short *dst) {
38 h = GetResource(PREF_wordness_type, id);
39 if (h == NULL || *h == NULL)
40 fatalbox ("Couldn't get wordness id %d (%d)", id, ResError());
41 memcpy(dst, *h, 256 * sizeof(short));
44 #pragma options align=mac68k
46 unsigned long basic_flags;
47 #define CLOSE_ON_EXIT 0x80000000
48 unsigned long ssh_flags;
49 #define NO_PTY 0x80000000
50 unsigned long telnet_flags;
51 #define RFC_ENVIRON 0x80000000
52 unsigned long kbd_flags;
53 #define BKSP_IS_DELETE 0x80000000
54 #define RXVT_HOMEEND 0x40000000
55 #define LINUX_FUNKEYS 0x20000000
56 #define APP_CURSOR 0x10000000
57 #define APP_KEYPAD 0x08000000
58 unsigned long term_flags;
59 #define DEC_OM 0x80000000
60 #define WRAP_MODE 0x40000000
61 #define LFHASCR 0x20000000
62 #define WIN_NAME_ALWAYS 0x10000000
63 unsigned long colour_flags;
64 #define BOLD_COLOUR 0x80000000
65 unsigned long selection_flags;
66 #define IMPLICIT_COPY 0x80000000
70 struct strloc termtype, termspeed;
71 struct strloc environmt;
72 struct strloc username;
73 long width, height, savelines;
78 unsigned short meta_modifiers;
80 #pragma options align=reset
83 * Load a configuration from the current chain of resource files.
85 void mac_loadconfig(Config *cfg) {
89 h = GetResource('pSET', PREF_settings);
90 if (h == NULL || *h == NULL)
91 fatalbox("Can't load settings");
93 if (GetHandleSize(h) != sizeof(struct pSET))
94 fatalbox("Settings resource is wrong size (%d vs %d)",
95 GetHandleSize(h), sizeof(struct pSET));
96 s = (struct pSET *)*h;
98 get_string(&s->host, cfg->host, sizeof(cfg->host));
100 cfg->protocol = s->protocol;
101 cfg->close_on_exit = (s->basic_flags & CLOSE_ON_EXIT) != 0;
103 cfg->nopty = (s->ssh_flags & NO_PTY) != 0;
105 get_string(&s->termtype, cfg->termtype, sizeof(cfg->termtype));
106 get_string(&s->termspeed, cfg->termspeed, sizeof(cfg->termspeed));
107 get_string(&s->environmt, cfg->environmt, sizeof(cfg->environmt));
108 get_string(&s->username, cfg->username, sizeof(cfg->username));
109 cfg->rfc_environ = (s->telnet_flags & RFC_ENVIRON) != 0;
111 cfg->bksp_is_delete = (s->kbd_flags & BKSP_IS_DELETE) != 0;
112 cfg->rxvt_homeend = (s->kbd_flags & RXVT_HOMEEND) != 0;
113 cfg->linux_funkeys = (s->kbd_flags & LINUX_FUNKEYS) != 0;
114 cfg->app_cursor = (s->kbd_flags & APP_CURSOR) != 0;
115 cfg->app_keypad = (s->kbd_flags & APP_KEYPAD) != 0;
116 cfg->meta_modifiers = s->meta_modifiers;
118 cfg->savelines = s->savelines;
119 cfg->dec_om = (s->term_flags & DEC_OM) != 0;
120 cfg->wrap_mode = (s->term_flags & WRAP_MODE) != 0;
121 cfg->lfhascr = (s->term_flags & LFHASCR) != 0;
122 cfg->win_name_always = (s->term_flags & WIN_NAME_ALWAYS) != 0;
123 cfg->width = s->width;
124 cfg->height = s->height;
125 get_string(&s->font, cfg->font, sizeof(cfg->font));
126 cfg->fontisbold = FALSE; /* XXX */
127 cfg->fontheight = s->font_height;
128 cfg->vtmode = VT_POORMAN; /* XXX */
130 cfg->try_palette = FALSE; /* XXX */
131 cfg->bold_colour = (s->colour_flags & BOLD_COLOUR) != 0;
132 cfg->colours = GetNewPalette(s->colours_id);
133 if (cfg->colours == NULL)
134 fatalbox("Failed to get default palette");
136 cfg->implicit_copy = (s->selection_flags & IMPLICIT_COPY) != 0;
137 get_wordness(s->wordness_id, cfg->wordness);
145 * c-file-style: "simon"