| 1 | /* |
| 2 | * uxstore.c: Unix-specific implementation of the interface defined |
| 3 | * in storage.h. |
| 4 | */ |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | #include <stdlib.h> |
| 8 | #include <gtk/gtk.h> |
| 9 | #include <gdk/gdkx.h> |
| 10 | #include <X11/Xlib.h> |
| 11 | #include "putty.h" |
| 12 | #include "storage.h" |
| 13 | |
| 14 | /* |
| 15 | * For the moment, the only existing Unix utility is pterm and that |
| 16 | * has no GUI configuration at all, so our write routines need do |
| 17 | * nothing. Eventually I suppose these will read and write an rc |
| 18 | * file somewhere or other. |
| 19 | */ |
| 20 | |
| 21 | void *open_settings_w(char *sessionname) |
| 22 | { |
| 23 | return NULL; |
| 24 | } |
| 25 | |
| 26 | void write_setting_s(void *handle, char *key, char *value) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | void write_setting_i(void *handle, char *key, int value) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | void close_settings_w(void *handle) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | /* |
| 39 | * Reading settings, for the moment, is done by retrieving X |
| 40 | * resources from the X display. When we introduce disk files, I |
| 41 | * think what will happen is that the X resources will override |
| 42 | * PuTTY's inbuilt defaults, but that the disk files will then |
| 43 | * override those. This isn't optimal, but it's the best I can |
| 44 | * immediately work out. |
| 45 | */ |
| 46 | |
| 47 | static Display *display; |
| 48 | |
| 49 | void *open_settings_r(char *sessionname) |
| 50 | { |
| 51 | static int thing_to_return_an_arbitrary_non_null_pointer_to; |
| 52 | display = GDK_DISPLAY(); |
| 53 | if (!display) |
| 54 | return NULL; |
| 55 | else |
| 56 | return &thing_to_return_an_arbitrary_non_null_pointer_to; |
| 57 | } |
| 58 | |
| 59 | char *read_setting_s(void *handle, char *key, char *buffer, int buflen) |
| 60 | { |
| 61 | char *val = XGetDefault(display, app_name, key); |
| 62 | if (!val) |
| 63 | return NULL; |
| 64 | else { |
| 65 | strncpy(buffer, val, buflen); |
| 66 | buffer[buflen-1] = '\0'; |
| 67 | return buffer; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | int read_setting_i(void *handle, char *key, int defvalue) |
| 72 | { |
| 73 | char *val = XGetDefault(display, app_name, key); |
| 74 | if (!val) |
| 75 | return defvalue; |
| 76 | else |
| 77 | return atoi(val); |
| 78 | } |
| 79 | |
| 80 | void close_settings_r(void *handle) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | void del_settings(char *sessionname) |
| 85 | { |
| 86 | } |
| 87 | |
| 88 | void *enum_settings_start(void) |
| 89 | { |
| 90 | return NULL; |
| 91 | } |
| 92 | |
| 93 | char *enum_settings_next(void *handle, char *buffer, int buflen) |
| 94 | { |
| 95 | return NULL; |
| 96 | } |
| 97 | |
| 98 | void enum_settings_finish(void *handle) |
| 99 | { |
| 100 | } |
| 101 | |
| 102 | int verify_host_key(char *hostname, int port, char *keytype, char *key) |
| 103 | { |
| 104 | return 1; /* key does not exist in registry */ |
| 105 | } |
| 106 | |
| 107 | void store_host_key(char *hostname, int port, char *keytype, char *key) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | void read_random_seed(noise_consumer_t consumer) |
| 112 | { |
| 113 | } |
| 114 | |
| 115 | void write_random_seed(void *data, int len) |
| 116 | { |
| 117 | } |
| 118 | |
| 119 | void cleanup_all(void) |
| 120 | { |
| 121 | } |