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