Commit e1bc7225a607d6981798ec49af70be86f9f73e92
1 parent
6336c575
Exists in
master
and in
5 other branches
Atualizando classlib
Showing
3 changed files
with
30 additions
and
26 deletions
Show diff stats
src/classlib/exception.cc
| ... | ... | @@ -29,6 +29,7 @@ |
| 29 | 29 | |
| 30 | 30 | #include <stdarg.h> |
| 31 | 31 | #include <stdio.h> |
| 32 | + #include <string.h> | |
| 32 | 33 | |
| 33 | 34 | #include <pw3270/class.h> |
| 34 | 35 | |
| ... | ... | @@ -37,14 +38,9 @@ |
| 37 | 38 | namespace PW3270_NAMESPACE |
| 38 | 39 | { |
| 39 | 40 | |
| 40 | - exception::exception(int code, const char *fmt, ...) | |
| 41 | + exception::exception(int syscode) | |
| 41 | 42 | { |
| 42 | - va_list arg_ptr; | |
| 43 | - va_start(arg_ptr, fmt); | |
| 44 | - vsnprintf(this->msg,4095,fmt,arg_ptr); | |
| 45 | - va_end(arg_ptr); | |
| 46 | - | |
| 47 | - this->code = code; | |
| 43 | + snprintf(this->msg,4095,"%s",strerror(syscode)); | |
| 48 | 44 | } |
| 49 | 45 | |
| 50 | 46 | exception::exception(const char *fmt, ...) |
| ... | ... | @@ -53,8 +49,6 @@ |
| 53 | 49 | va_start(arg_ptr, fmt); |
| 54 | 50 | vsnprintf(this->msg,4095,fmt,arg_ptr); |
| 55 | 51 | va_end(arg_ptr); |
| 56 | - | |
| 57 | - this->code = -1; | |
| 58 | 52 | } |
| 59 | 53 | |
| 60 | 54 | const char * exception::what() const throw() | ... | ... |
src/classlib/local.cc
src/include/pw3270/class.h
| ... | ... | @@ -50,6 +50,7 @@ |
| 50 | 50 | #include <stdarg.h> |
| 51 | 51 | #include <lib3270.h> |
| 52 | 52 | #include <gtk/gtk.h> |
| 53 | + #include <errno.h> | |
| 53 | 54 | |
| 54 | 55 | #define PW3270_NAMESPACE h3270 |
| 55 | 56 | |
| ... | ... | @@ -60,13 +61,12 @@ |
| 60 | 61 | class exception : public std::exception |
| 61 | 62 | { |
| 62 | 63 | public: |
| 63 | - exception(int code, const char *fmt, ...); | |
| 64 | + exception(int syserror = errno); | |
| 64 | 65 | exception(const char *fmt, ...); |
| 65 | 66 | |
| 66 | 67 | virtual const char * what() const throw(); |
| 67 | 68 | |
| 68 | 69 | private: |
| 69 | - int code; | |
| 70 | 70 | char msg[4096]; |
| 71 | 71 | |
| 72 | 72 | }; |
| ... | ... | @@ -81,23 +81,29 @@ |
| 81 | 81 | { |
| 82 | 82 | public: |
| 83 | 83 | |
| 84 | - session(); | |
| 85 | 84 | virtual ~session(); |
| 86 | 85 | |
| 87 | 86 | // Factory methods and settings |
| 88 | - static session * create(const char *name = 0); | |
| 89 | 87 | static session * start(const char *name = 0); |
| 88 | + static session * create(const char *name = 0); | |
| 90 | 89 | static session * get_default(void); |
| 91 | 90 | static void set_plugin(session * (*factory)(const char *name)); |
| 92 | 91 | |
| 92 | +#ifdef WIN32 | |
| 93 | + void set_charset(const char *remote = 0, const char *local = "CP1252"); | |
| 94 | +#else | |
| 95 | + void set_charset(const char *remote = 0, const char *local = "UTF-8"); | |
| 96 | +#endif // WIN32 | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 93 | 100 | // Log management |
| 94 | 101 | void log(const char *fmt, ...); |
| 95 | 102 | void logva(const char *fmt, va_list args); |
| 96 | 103 | |
| 97 | - // 3270 methods | |
| 104 | + // Information | |
| 98 | 105 | virtual string get_version(void); |
| 99 | 106 | virtual string get_revision(void); |
| 100 | - | |
| 101 | 107 | virtual const char * get_charset(void); |
| 102 | 108 | |
| 103 | 109 | virtual bool is_connected(void) = 0; |
| ... | ... | @@ -105,63 +111,65 @@ |
| 105 | 111 | |
| 106 | 112 | virtual LIB3270_CSTATE get_cstate(void) = 0; |
| 107 | 113 | |
| 114 | + // Connection & Network | |
| 108 | 115 | virtual int connect(const char *uri, bool wait = true) = 0; |
| 109 | 116 | virtual int disconnect(void) = 0; |
| 110 | - | |
| 111 | 117 | virtual int wait_for_ready(int seconds) = 0; |
| 112 | 118 | virtual int wait(int seconds) = 0; |
| 113 | 119 | virtual int iterate(bool wait = true) = 0; |
| 114 | 120 | |
| 121 | + // Get/Set/Test without charset translation | |
| 115 | 122 | virtual string * get_text(int baddr, size_t len) = 0; |
| 116 | 123 | virtual string * get_text_at(int row, int col, size_t sz) = 0; |
| 117 | 124 | virtual int set_text_at(int row, int col, const char *str) = 0; |
| 118 | 125 | virtual int cmp_text_at(int row, int col, const char *text) = 0; |
| 119 | 126 | virtual int wait_for_text_at(int row, int col, const char *key, int timeout); |
| 127 | + virtual int emulate_input(const char *str) = 0; | |
| 120 | 128 | |
| 129 | + // Get/Set/Test with charset translation | |
| 121 | 130 | string * get_string(int baddr, size_t len); |
| 122 | 131 | string * get_string_at(int row, int col, size_t sz); |
| 123 | 132 | int set_string_at(int row, int col, const char *str); |
| 124 | 133 | int cmp_string_at(int row, int col, const char *text); |
| 125 | 134 | int wait_for_string_at(int row, int col, const char *key, int timeout); |
| 135 | + int input_string(const char *str); | |
| 126 | 136 | |
| 137 | + // Cursor management | |
| 127 | 138 | virtual int set_cursor_position(int row, int col) = 0; |
| 128 | 139 | virtual int set_cursor_addr(int addr) = 0; |
| 129 | 140 | virtual int get_cursor_addr(void) = 0; |
| 130 | 141 | |
| 142 | + // Toggle management | |
| 131 | 143 | virtual int set_toggle(LIB3270_TOGGLE ix, bool value) = 0; |
| 132 | 144 | |
| 145 | + // Keyboard actions | |
| 133 | 146 | virtual int enter(void) = 0; |
| 134 | 147 | virtual int pfkey(int key) = 0; |
| 135 | 148 | virtual int pakey(int key) = 0; |
| 149 | + virtual int quit(void) = 0; | |
| 136 | 150 | |
| 137 | - virtual int emulate_input(const char *str) = 0; | |
| 138 | - int input_string(const char *str); | |
| 139 | - | |
| 151 | + // Field management | |
| 140 | 152 | virtual int get_field_start(int baddr = -1) = 0; |
| 141 | 153 | virtual int get_field_len(int baddr = -1) = 0; |
| 142 | 154 | virtual int get_next_unprotected(int baddr = -1) = 0; |
| 143 | 155 | |
| 156 | + // Clipboard management | |
| 144 | 157 | virtual int set_copy(const char *text); |
| 145 | 158 | virtual string * get_copy(void); |
| 146 | 159 | |
| 147 | 160 | virtual string * get_clipboard(void); |
| 148 | 161 | virtual int set_clipboard(const char *text); |
| 149 | 162 | |
| 150 | - virtual int quit(void) = 0; | |
| 151 | - | |
| 152 | 163 | // Dialogs |
| 153 | 164 | virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); |
| 154 | 165 | virtual string * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename); |
| 155 | 166 | |
| 167 | + // Charset translation | |
| 156 | 168 | string * get_3270_text(string *str); |
| 157 | 169 | string * get_local_text(string *str); |
| 158 | 170 | |
| 159 | 171 | protected: |
| 160 | -#ifdef WIN32 | |
| 161 | - void set_charset(const char *remote = 0, const char *local = "CP1252"); | |
| 162 | -#else | |
| 163 | - void set_charset(const char *remote = 0, const char *local = "UTF-8"); | |
| 164 | -#endif // WIN32 | |
| 172 | + session(); | |
| 165 | 173 | |
| 166 | 174 | private: |
| 167 | 175 | ... | ... |