Commit 09a831e6c1e23e307b404b00adc71bf903dd8ba9
1 parent
b5d9f6bd
Exists in
master
and in
1 other branch
Working on the simple command line interpreter for trace window.
Showing
4 changed files
with
117 additions
and
70 deletions
Show diff stats
src/include/v3270.h
| ... | ... | @@ -287,7 +287,7 @@ |
| 287 | 287 | LIB3270_EXPORT int v3270_print_selected(GtkWidget *widget, GError **error); |
| 288 | 288 | LIB3270_EXPORT int v3270_print_copy(GtkWidget *widget, GError **error); |
| 289 | 289 | |
| 290 | - LIB3270_EXPORT void v3270_exec_command(GtkWidget *widget, const gchar *cmdline); | |
| 290 | + LIB3270_EXPORT int v3270_exec_command(GtkWidget *widget, const gchar *cmdline); | |
| 291 | 291 | |
| 292 | 292 | LIB3270_EXPORT GtkWidget * v3270_dialog_new(const gchar *title, GtkWindow *parent, const gchar *apply); |
| 293 | 293 | ... | ... |
src/trace/exec.c
| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | |
| 35 | 35 | #include <libintl.h> |
| 36 | 36 | #include <glib/gi18n.h> |
| 37 | + #include <stdlib.h> | |
| 37 | 38 | |
| 38 | 39 | #include <lib3270.h> |
| 39 | 40 | #include <lib3270/log.h> |
| ... | ... | @@ -58,53 +59,92 @@ |
| 58 | 59 | return rc; |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | - static void set_property(H3270 *hSession, gchar *ptr) | |
| 62 | + static int set_property(H3270 *hSession, const gchar *name, const gchar * value) | |
| 62 | 63 | { |
| 63 | 64 | size_t ix; |
| 64 | 65 | |
| 65 | - const gchar * name = get_word(&ptr); | |
| 66 | - | |
| 67 | - debug("property_name: \"%s\"",name); | |
| 66 | + debug("%s=%s",name,value); | |
| 68 | 67 | |
| 69 | 68 | // Check toggles |
| 70 | 69 | for(ix = 0; ix < (size_t) LIB3270_TOGGLE_COUNT; ix++) |
| 71 | 70 | { |
| 72 | - debug("%s %s %d",name,lib3270_get_toggle_name((LIB3270_TOGGLE) ix),g_ascii_strcasecmp(name,lib3270_get_toggle_name((LIB3270_TOGGLE) ix))); | |
| 73 | 71 | if(g_ascii_strcasecmp(name,lib3270_get_toggle_name((LIB3270_TOGGLE) ix)) == 0) |
| 74 | - { | |
| 75 | - lib3270_set_toggle(hSession,(LIB3270_TOGGLE) ix, 1); | |
| 76 | - return; | |
| 77 | - } | |
| 72 | + return lib3270_set_toggle(hSession,(LIB3270_TOGGLE) ix, atoi(value)); | |
| 73 | + | |
| 78 | 74 | } |
| 79 | 75 | |
| 80 | 76 | // Check boolean properties |
| 81 | - const LIB3270_INT_PROPERTY * iProp = lib3270_get_boolean_properties_list(); | |
| 77 | + const LIB3270_INT_PROPERTY * bProp = lib3270_get_boolean_properties_list(); | |
| 78 | + for(ix = 0; bProp[ix].name; ix++) | |
| 79 | + { | |
| 80 | + if(g_ascii_strcasecmp(name,bProp[ix].name) == 0 && bProp[ix].set) | |
| 81 | + return bProp[ix].set(hSession,atoi(value)); | |
| 82 | + | |
| 83 | + } | |
| 84 | + | |
| 85 | + // Check integer properties | |
| 86 | + const LIB3270_INT_PROPERTY * iProp = lib3270_get_int_properties_list(); | |
| 82 | 87 | for(ix = 0; iProp[ix].name; ix++) |
| 83 | 88 | { |
| 84 | - debug("%s %s %d",name,iProp[ix].name,g_ascii_strcasecmp(name,iProp[ix].name)); | |
| 85 | 89 | if(g_ascii_strcasecmp(name,iProp[ix].name) == 0 && iProp[ix].set) |
| 86 | - { | |
| 87 | - iProp[ix].set(hSession,1); | |
| 88 | - return; | |
| 89 | - } | |
| 90 | + return iProp[ix].set(hSession,atoi(value)); | |
| 91 | + | |
| 90 | 92 | } |
| 91 | 93 | |
| 94 | + // Check string properties | |
| 95 | + const LIB3270_STRING_PROPERTY * sProp = lib3270_get_string_properties_list(); | |
| 96 | + for(ix = 0; sProp[ix].name; ix++) | |
| 97 | + { | |
| 98 | + if(g_ascii_strcasecmp(name,sProp[ix].name) == 0 && sProp[ix].set) | |
| 99 | + return sProp[ix].set(hSession,value); | |
| 92 | 100 | |
| 101 | + } | |
| 102 | + | |
| 103 | + return errno = ENOENT; | |
| 93 | 104 | |
| 94 | 105 | } |
| 95 | 106 | |
| 96 | - void v3270_exec_command(GtkWidget *widget, const gchar *text) | |
| 107 | + int v3270_exec_command(GtkWidget *widget, const gchar *text) | |
| 97 | 108 | { |
| 109 | + H3270 *hSession = v3270_get_session(widget); | |
| 98 | 110 | g_autofree gchar * cmdline = g_strdup(text); |
| 99 | 111 | |
| 100 | 112 | g_strstrip(cmdline); |
| 101 | 113 | |
| 102 | 114 | debug("cmdline: \"%s\"",cmdline); |
| 103 | 115 | |
| 104 | - if(g_str_has_prefix(cmdline,"set ")) | |
| 116 | + if(g_str_has_prefix(cmdline,"connect")) | |
| 117 | + { | |
| 118 | + return lib3270_reconnect(hSession,0); | |
| 119 | + } | |
| 120 | + | |
| 121 | + if(g_str_has_prefix(cmdline,"disconnect")) | |
| 122 | + { | |
| 123 | + return lib3270_disconnect(hSession); | |
| 124 | + } | |
| 125 | + | |
| 126 | + if(g_str_has_prefix(cmdline,"set")) | |
| 127 | + { | |
| 128 | + gchar *txtptr = cmdline+3; | |
| 129 | + const gchar * name = get_word(&txtptr); | |
| 130 | + g_strstrip(txtptr); | |
| 131 | + return set_property(hSession,name,(*txtptr ? txtptr : "1")); | |
| 132 | + } | |
| 133 | + | |
| 134 | + if(g_str_has_prefix(cmdline,"reset")) | |
| 135 | + { | |
| 136 | + gchar *txtptr = cmdline+3; | |
| 137 | + const gchar * name = get_word(&txtptr); | |
| 138 | + g_strstrip(txtptr); | |
| 139 | + return set_property(hSession,name,(*txtptr ? txtptr : "0")); | |
| 140 | + } | |
| 141 | + | |
| 142 | + gchar * sep = strchr(cmdline,'='); | |
| 143 | + if(sep) | |
| 105 | 144 | { |
| 106 | - set_property(v3270_get_session(widget), cmdline+3); | |
| 107 | - return; | |
| 145 | + *(sep++) = 0; | |
| 146 | + set_property(hSession,g_strstrip(cmdline),g_strstrip(sep)); | |
| 108 | 147 | } |
| 109 | 148 | |
| 149 | + return errno = ENOENT; | |
| 110 | 150 | } | ... | ... |
src/trace/trace.c
| ... | ... | @@ -166,7 +166,11 @@ static void destroy(GtkWidget *widget) |
| 166 | 166 | |
| 167 | 167 | static void activate(G_GNUC_UNUSED GtkButton *button, v3270_trace *window) |
| 168 | 168 | { |
| 169 | - v3270_exec_command(GTK_WIDGET(window),gtk_entry_get_text(GTK_ENTRY(window->entry))); | |
| 169 | + GtkWidget * terminal = GTK_WIDGET(lib3270_get_user_data(window->hSession)); | |
| 170 | + | |
| 171 | + int rc = v3270_exec_command(terminal,gtk_entry_get_text(GTK_ENTRY(window->entry))); | |
| 172 | + | |
| 173 | + v3270_trace_printf(GTK_WIDGET(window),"exec(\"%s\") exits with rc=%d (%s)\n",gtk_entry_get_text(GTK_ENTRY(window->entry)),rc,strerror(rc)); | |
| 170 | 174 | gtk_entry_set_text(GTK_ENTRY(window->entry),""); |
| 171 | 175 | } |
| 172 | 176 | ... | ... |
v3270.cbp
| ... | ... | @@ -74,123 +74,126 @@ |
| 74 | 74 | <Unit filename="src/dialogs/tools.c"> |
| 75 | 75 | <Option compilerVar="CC" /> |
| 76 | 76 | </Unit> |
| 77 | - <Unit filename="src/include/config.h" /> | |
| 78 | - <Unit filename="src/include/config.h.in" /> | |
| 79 | - <Unit filename="src/include/hostselect.h" /> | |
| 80 | - <Unit filename="src/include/internals.h" /> | |
| 81 | - <Unit filename="src/include/v3270.h" /> | |
| 82 | - <Unit filename="src/include/v3270/colorscheme.h" /> | |
| 83 | - <Unit filename="src/include/v3270/filetransfer.h" /> | |
| 84 | - <Unit filename="src/include/v3270/ftprogress.h" /> | |
| 85 | - <Unit filename="src/include/v3270/print.h" /> | |
| 86 | - <Unit filename="src/include/v3270/trace.h" /> | |
| 87 | - <Unit filename="src/testprogram/testprogram.c"> | |
| 77 | + <Unit filename="src/filetransfer/activity.c"> | |
| 88 | 78 | <Option compilerVar="CC" /> |
| 89 | 79 | </Unit> |
| 90 | - <Unit filename="src/trace/trace.c"> | |
| 80 | + <Unit filename="src/filetransfer/activitylist.c"> | |
| 91 | 81 | <Option compilerVar="CC" /> |
| 92 | 82 | </Unit> |
| 93 | - <Unit filename="src/v3270/accessible.c"> | |
| 83 | + <Unit filename="src/filetransfer/dialog.c"> | |
| 94 | 84 | <Option compilerVar="CC" /> |
| 95 | 85 | </Unit> |
| 96 | - <Unit filename="src/v3270/blink.c"> | |
| 86 | + <Unit filename="src/filetransfer/filelist.c"> | |
| 97 | 87 | <Option compilerVar="CC" /> |
| 98 | 88 | </Unit> |
| 99 | - <Unit filename="src/v3270/callbacks.c"> | |
| 89 | + <Unit filename="src/filetransfer/get.c"> | |
| 100 | 90 | <Option compilerVar="CC" /> |
| 101 | 91 | </Unit> |
| 102 | - <Unit filename="src/v3270/charset.c"> | |
| 92 | + <Unit filename="src/filetransfer/load.c"> | |
| 103 | 93 | <Option compilerVar="CC" /> |
| 104 | 94 | </Unit> |
| 105 | - <Unit filename="src/v3270/colors.c"> | |
| 95 | + <Unit filename="src/filetransfer/marshal.h" /> | |
| 96 | + <Unit filename="src/filetransfer/misc.c"> | |
| 106 | 97 | <Option compilerVar="CC" /> |
| 107 | 98 | </Unit> |
| 108 | - <Unit filename="src/v3270/draw.c"> | |
| 99 | + <Unit filename="src/filetransfer/private.h" /> | |
| 100 | + <Unit filename="src/filetransfer/save.c"> | |
| 109 | 101 | <Option compilerVar="CC" /> |
| 110 | 102 | </Unit> |
| 111 | - <Unit filename="src/v3270/font.c"> | |
| 103 | + <Unit filename="src/filetransfer/select.c"> | |
| 112 | 104 | <Option compilerVar="CC" /> |
| 113 | 105 | </Unit> |
| 114 | - <Unit filename="src/v3270/iocallback.c"> | |
| 106 | + <Unit filename="src/filetransfer/set.c"> | |
| 115 | 107 | <Option compilerVar="CC" /> |
| 116 | 108 | </Unit> |
| 117 | - <Unit filename="src/v3270/keyboard.c"> | |
| 109 | + <Unit filename="src/filetransfer/settings.c"> | |
| 118 | 110 | <Option compilerVar="CC" /> |
| 119 | 111 | </Unit> |
| 120 | - <Unit filename="src/v3270/linux/iosource.c"> | |
| 112 | + <Unit filename="src/filetransfer/tables.c"> | |
| 121 | 113 | <Option compilerVar="CC" /> |
| 122 | 114 | </Unit> |
| 123 | - <Unit filename="src/v3270/macros.c"> | |
| 115 | + <Unit filename="src/filetransfer/transfer.c"> | |
| 124 | 116 | <Option compilerVar="CC" /> |
| 125 | 117 | </Unit> |
| 126 | - <Unit filename="src/v3270/mouse.c"> | |
| 118 | + <Unit filename="src/filetransfer/v3270ft.c"> | |
| 127 | 119 | <Option compilerVar="CC" /> |
| 128 | 120 | </Unit> |
| 129 | - <Unit filename="src/v3270/oia.c"> | |
| 130 | - <Option compilerVar="CC" /> | |
| 131 | - </Unit> | |
| 132 | - <Unit filename="src/v3270/private.h" /> | |
| 133 | - <Unit filename="src/v3270/properties.c"> | |
| 121 | + <Unit filename="src/filetransfer/v3270ftprogress.c"> | |
| 134 | 122 | <Option compilerVar="CC" /> |
| 135 | 123 | </Unit> |
| 136 | - <Unit filename="src/v3270/security.c"> | |
| 124 | + <Unit filename="src/include/config.h" /> | |
| 125 | + <Unit filename="src/include/config.h.in" /> | |
| 126 | + <Unit filename="src/include/hostselect.h" /> | |
| 127 | + <Unit filename="src/include/internals.h" /> | |
| 128 | + <Unit filename="src/include/v3270.h" /> | |
| 129 | + <Unit filename="src/include/v3270/accessible.h" /> | |
| 130 | + <Unit filename="src/include/v3270/colorscheme.h" /> | |
| 131 | + <Unit filename="src/include/v3270/filetransfer.h" /> | |
| 132 | + <Unit filename="src/include/v3270/ftprogress.h" /> | |
| 133 | + <Unit filename="src/include/v3270/print.h" /> | |
| 134 | + <Unit filename="src/include/v3270/trace.h" /> | |
| 135 | + <Unit filename="src/terminal/accessible.c"> | |
| 137 | 136 | <Option compilerVar="CC" /> |
| 138 | 137 | </Unit> |
| 139 | - <Unit filename="src/v3270/selection.c"> | |
| 138 | + <Unit filename="src/terminal/blink.c"> | |
| 140 | 139 | <Option compilerVar="CC" /> |
| 141 | 140 | </Unit> |
| 142 | - <Unit filename="src/v3270/widget.c"> | |
| 141 | + <Unit filename="src/terminal/callbacks.c"> | |
| 143 | 142 | <Option compilerVar="CC" /> |
| 144 | 143 | </Unit> |
| 145 | - <Unit filename="src/v3270/windows/iosource.c"> | |
| 144 | + <Unit filename="src/terminal/charset.c"> | |
| 146 | 145 | <Option compilerVar="CC" /> |
| 147 | 146 | </Unit> |
| 148 | - <Unit filename="src/v3270ft/activity.c"> | |
| 147 | + <Unit filename="src/terminal/colors.c"> | |
| 149 | 148 | <Option compilerVar="CC" /> |
| 150 | 149 | </Unit> |
| 151 | - <Unit filename="src/v3270ft/activitylist.c"> | |
| 150 | + <Unit filename="src/terminal/draw.c"> | |
| 152 | 151 | <Option compilerVar="CC" /> |
| 153 | 152 | </Unit> |
| 154 | - <Unit filename="src/v3270ft/dialog.c"> | |
| 153 | + <Unit filename="src/terminal/font.c"> | |
| 155 | 154 | <Option compilerVar="CC" /> |
| 156 | 155 | </Unit> |
| 157 | - <Unit filename="src/v3270ft/filelist.c"> | |
| 156 | + <Unit filename="src/terminal/iocallback.c"> | |
| 158 | 157 | <Option compilerVar="CC" /> |
| 159 | 158 | </Unit> |
| 160 | - <Unit filename="src/v3270ft/get.c"> | |
| 159 | + <Unit filename="src/terminal/keyboard.c"> | |
| 161 | 160 | <Option compilerVar="CC" /> |
| 162 | 161 | </Unit> |
| 163 | - <Unit filename="src/v3270ft/load.c"> | |
| 162 | + <Unit filename="src/terminal/linux/iosource.c"> | |
| 164 | 163 | <Option compilerVar="CC" /> |
| 165 | 164 | </Unit> |
| 166 | - <Unit filename="src/v3270ft/misc.c"> | |
| 165 | + <Unit filename="src/terminal/marshal.h" /> | |
| 166 | + <Unit filename="src/terminal/oia.c"> | |
| 167 | 167 | <Option compilerVar="CC" /> |
| 168 | 168 | </Unit> |
| 169 | - <Unit filename="src/v3270ft/private.h" /> | |
| 170 | - <Unit filename="src/v3270ft/save.c"> | |
| 169 | + <Unit filename="src/terminal/private.h" /> | |
| 170 | + <Unit filename="src/terminal/properties.c"> | |
| 171 | 171 | <Option compilerVar="CC" /> |
| 172 | 172 | </Unit> |
| 173 | - <Unit filename="src/v3270ft/select.c"> | |
| 173 | + <Unit filename="src/terminal/security.c"> | |
| 174 | 174 | <Option compilerVar="CC" /> |
| 175 | 175 | </Unit> |
| 176 | - <Unit filename="src/v3270ft/set.c"> | |
| 176 | + <Unit filename="src/terminal/selection.c"> | |
| 177 | 177 | <Option compilerVar="CC" /> |
| 178 | 178 | </Unit> |
| 179 | - <Unit filename="src/v3270ft/settings.c"> | |
| 179 | + <Unit filename="src/terminal/widget.c"> | |
| 180 | 180 | <Option compilerVar="CC" /> |
| 181 | 181 | </Unit> |
| 182 | - <Unit filename="src/v3270ft/tables.c"> | |
| 182 | + <Unit filename="src/terminal/windows/iosource.c"> | |
| 183 | 183 | <Option compilerVar="CC" /> |
| 184 | 184 | </Unit> |
| 185 | - <Unit filename="src/v3270ft/transfer.c"> | |
| 185 | + <Unit filename="src/terminal/windows/resources.rc" /> | |
| 186 | + <Unit filename="src/testprogram/testprogram.c"> | |
| 186 | 187 | <Option compilerVar="CC" /> |
| 187 | 188 | </Unit> |
| 188 | - <Unit filename="src/v3270ft/v3270ft.c"> | |
| 189 | + <Unit filename="src/trace/exec.c"> | |
| 189 | 190 | <Option compilerVar="CC" /> |
| 190 | 191 | </Unit> |
| 191 | - <Unit filename="src/v3270ft/v3270ftprogress.c"> | |
| 192 | + <Unit filename="src/trace/trace.c"> | |
| 192 | 193 | <Option compilerVar="CC" /> |
| 193 | 194 | </Unit> |
| 195 | + <Unit filename="src/v3270/private.h" /> | |
| 196 | + <Unit filename="src/v3270ft/private.h" /> | |
| 194 | 197 | <Extensions> |
| 195 | 198 | <code_completion /> |
| 196 | 199 | <envvars /> | ... | ... |