2 * uxstore.c: Unix-specific implementation of the interface defined
17 * For the moment, the only existing Unix utility is pterm and that
18 * has no GUI configuration at all, so our write routines need do
19 * nothing. Eventually I suppose these will read and write an rc
20 * file somewhere or other.
23 void *open_settings_w(char *sessionname
)
28 void write_setting_s(void *handle
, char *key
, char *value
)
32 void write_setting_i(void *handle
, char *key
, int value
)
36 void close_settings_w(void *handle
)
41 * Reading settings, for the moment, is done by retrieving X
42 * resources from the X display. When we introduce disk files, I
43 * think what will happen is that the X resources will override
44 * PuTTY's inbuilt defaults, but that the disk files will then
45 * override those. This isn't optimal, but it's the best I can
46 * immediately work out.
49 static Display
*display
;
56 static tree234
*xrmtree
= NULL
;
58 int xrmcmp(void *av
, void *bv
)
60 struct xrm_string
*a
= (struct xrm_string
*)av
;
61 struct xrm_string
*b
= (struct xrm_string
*)bv
;
62 return strcmp(a
->key
, b
->key
);
65 void provide_xrm_string(char *string
)
68 struct xrm_string
*xrms
, *ret
;
70 p
= q
= strchr(string
, ':');
72 fprintf(stderr
, "pterm: expected a colon in resource string"
77 while (p
> string
&& p
[-1] != '.' && p
[-1] != '*')
79 xrms
= smalloc(sizeof(struct xrm_string
));
80 xrms
->key
= smalloc(q
-p
);
81 memcpy(xrms
->key
, p
, q
-p
);
82 xrms
->key
[q
-p
-1] = '\0';
83 while (*q
&& isspace(*q
))
85 xrms
->value
= dupstr(q
);
88 xrmtree
= newtree234(xrmcmp
);
90 ret
= add234(xrmtree
, xrms
);
92 /* Override an existing string. */
94 add234(xrmtree
, xrms
);
98 char *get_setting(char *key
)
100 struct xrm_string tmp
, *ret
;
103 ret
= find234(xrmtree
, &tmp
, NULL
);
107 return XGetDefault(display
, app_name
, key
);
110 void *open_settings_r(char *sessionname
)
112 static int thing_to_return_an_arbitrary_non_null_pointer_to
;
113 display
= GDK_DISPLAY();
117 return &thing_to_return_an_arbitrary_non_null_pointer_to
;
120 char *read_setting_s(void *handle
, char *key
, char *buffer
, int buflen
)
122 char *val
= get_setting(key
);
126 strncpy(buffer
, val
, buflen
);
127 buffer
[buflen
-1] = '\0';
132 int read_setting_i(void *handle
, char *key
, int defvalue
)
134 char *val
= get_setting(key
);
141 void close_settings_r(void *handle
)
145 void del_settings(char *sessionname
)
149 void *enum_settings_start(void)
154 char *enum_settings_next(void *handle
, char *buffer
, int buflen
)
159 void enum_settings_finish(void *handle
)
163 int verify_host_key(char *hostname
, int port
, char *keytype
, char *key
)
165 return 1; /* key does not exist in registry */
168 void store_host_key(char *hostname
, int port
, char *keytype
, char *key
)
172 void read_random_seed(noise_consumer_t consumer
)
176 void write_random_seed(void *data
, int len
)
180 void cleanup_all(void)