Commit bccb3c515b5eecb8d9c084d5d8ead5841a5fd021
Exists in
master
and in
1 other branch
Merge branch 'develop'
Showing
46 changed files
with
892 additions
and
434 deletions
Show diff stats
Makefile.in
| ... | ... | @@ -133,9 +133,16 @@ install-windows-lib: |
| 133 | 133 | doc: |
| 134 | 134 | @$(DOXYGEN) ./doxygen/doxyfile |
| 135 | 135 | |
| 136 | +#---[ Install Targets ]------------------------------------------------------------------ | |
| 137 | + | |
| 138 | +Debug: | |
| 139 | + | |
| 140 | + @$(MAKE) -C client $@ | |
| 141 | + @$(MAKE) -C server $@ | |
| 142 | + | |
| 136 | 143 | #---[ Clean Targets ]-------------------------------------------------------------------- |
| 137 | 144 | |
| 138 | -clean: \ | |
| 145 | +clean: | |
| 139 | 146 | |
| 140 | 147 | @$(MAKE) -C client $@ |
| 141 | 148 | @$(MAKE) -C server $@ | ... | ... |
README.md
| ... | ... | @@ -74,3 +74,24 @@ Compiling for Windows (With MSYS2) |
| 74 | 74 | |
| 75 | 75 | * make install |
| 76 | 76 | |
| 77 | +Compiling for Windows (With MSVC) | |
| 78 | +--------------------------------- | |
| 79 | + | |
| 80 | +1. Install pw3270 with remote control and sdk modules | |
| 81 | + | |
| 82 | +2. Install git for windows | |
| 83 | + | |
| 84 | +3. Download and install Visual Studio Build Tools (https://visualstudio.microsoft.com/pt-br/downloads/) | |
| 85 | + | |
| 86 | +4. Get sources from git | |
| 87 | + | |
| 88 | + ```shell | |
| 89 | + git clone https://github.com/PerryWerneck/libipc3270.git ./ipc3270 | |
| 90 | + ``` | |
| 91 | + | |
| 92 | +5. Build and install | |
| 93 | + | |
| 94 | + ```shell | |
| 95 | + cd ipc3270 | |
| 96 | + install.bat | |
| 97 | + ``` | ... | ... |
client/ipcclient.cbp
| ... | ... | @@ -79,6 +79,7 @@ |
| 79 | 79 | <Unit filename="src/session/local/get.cc" /> |
| 80 | 80 | <Unit filename="src/session/local/init.cc" /> |
| 81 | 81 | <Unit filename="src/session/local/private.h" /> |
| 82 | + <Unit filename="src/session/local/properties.cc" /> | |
| 82 | 83 | <Unit filename="src/session/local/set.cc" /> |
| 83 | 84 | <Unit filename="src/session/local/wait.cc" /> |
| 84 | 85 | <Unit filename="src/session/remote/actions.cc" /> |
| ... | ... | @@ -97,9 +98,6 @@ |
| 97 | 98 | <Unit filename="src/session/tools.cc" /> |
| 98 | 99 | <Unit filename="src/testprogram/testprogram.cc" /> |
| 99 | 100 | <Extensions> |
| 100 | - <code_completion /> | |
| 101 | - <envvars /> | |
| 102 | - <debugger /> | |
| 103 | 101 | <lib_finder disable_auto="1" /> |
| 104 | 102 | </Extensions> |
| 105 | 103 | </Project> | ... | ... |
client/src/core/abstract.cc
| ... | ... | @@ -79,6 +79,8 @@ |
| 79 | 79 | /// @brief Setup charsets |
| 80 | 80 | void Abstract::Session::setCharSet(const char *remote, const char *local) { |
| 81 | 81 | |
| 82 | + debug("Charsets: remote=",remote," local=",local); | |
| 83 | + | |
| 82 | 84 | if(!local) { |
| 83 | 85 | |
| 84 | 86 | // TODO: Detect the current value (maybee something like g_charset) |
| ... | ... | @@ -117,8 +119,8 @@ |
| 117 | 119 | converter = lib3270_iconv_new(remote,local); |
| 118 | 120 | |
| 119 | 121 | debug("lib3270_iconv_new(",remote,",",local,"=",(void *) converter); |
| 120 | -#endif | |
| 121 | 122 | |
| 123 | +#endif | |
| 122 | 124 | |
| 123 | 125 | } |
| 124 | 126 | |
| ... | ... | @@ -168,11 +170,17 @@ |
| 168 | 170 | #else |
| 169 | 171 | if(converter) { |
| 170 | 172 | |
| 171 | - lib3270_auto_cleanup<char> converted = lib3270_iconv_from_host(converter,str.c_str(),str.size()); | |
| 173 | + char * converted = lib3270_iconv_from_host(converter,str.c_str(),str.size()); | |
| 172 | 174 | if(converted) { |
| 173 | - return std::string(converted); | |
| 175 | + std::string rc(converted); | |
| 176 | + lib3270_free(converted); | |
| 177 | + return rc; | |
| 174 | 178 | } |
| 175 | 179 | |
| 180 | + } else { | |
| 181 | + | |
| 182 | + throw std::runtime_error("Unable to convert charsets"); | |
| 183 | + | |
| 176 | 184 | } |
| 177 | 185 | |
| 178 | 186 | return str; |
| ... | ... | @@ -185,22 +193,32 @@ |
| 185 | 193 | |
| 186 | 194 | #ifdef HAVE_ICONV |
| 187 | 195 | |
| 196 | + debug("Using ICONV"); | |
| 188 | 197 | return convertCharset(const_cast<Abstract::Session *>(this)->converter.host,text,length); |
| 189 | 198 | |
| 190 | 199 | #else |
| 191 | 200 | |
| 192 | 201 | if(converter) { |
| 193 | 202 | |
| 194 | - lib3270_auto_cleanup<char> converted = lib3270_iconv_to_host(converter,text,length); | |
| 203 | + debug("Converting \"",text,"\" with lib3270 converter ",((void *) converter)); | |
| 204 | + | |
| 205 | + char * converted = lib3270_iconv_to_host(converter,text,length); | |
| 206 | + | |
| 195 | 207 | if(converted) { |
| 196 | - return std::string(converted); | |
| 208 | + std::string rc(converted); | |
| 209 | + debug("Converted=\"",rc,"\""); | |
| 210 | + lib3270_free(converted); | |
| 211 | + return rc; | |
| 197 | 212 | } |
| 198 | 213 | |
| 199 | 214 | } |
| 200 | 215 | |
| 201 | 216 | #endif // HAVE_ICONV |
| 202 | 217 | |
| 203 | - return std::string(text,length); | |
| 218 | + if(length > 0) | |
| 219 | + return std::string(text,length); | |
| 220 | + | |
| 221 | + return std::string(text); | |
| 204 | 222 | |
| 205 | 223 | } |
| 206 | 224 | ... | ... |
client/src/core/linux/request.cc
| ... | ... | @@ -77,7 +77,7 @@ |
| 77 | 77 | if(!response.msg) { |
| 78 | 78 | string message = error.message; |
| 79 | 79 | dbus_error_free(&error); |
| 80 | - throw std::runtime_error(message.c_str()); | |
| 80 | + throw std::runtime_error(message); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | dbus_message_iter_init(response.msg, &response.iter); |
| ... | ... | @@ -128,7 +128,8 @@ |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | IPC::Request & IPC::Request::push(const bool arg) { |
| 131 | - return push(DBUS_TYPE_BOOLEAN,&arg); | |
| 131 | + dbus_bool_t bl = (arg ? 1 : 0); | |
| 132 | + return push(DBUS_TYPE_BOOLEAN,&bl); | |
| 132 | 133 | } |
| 133 | 134 | |
| 134 | 135 | IPC::Request & IPC::Request::push(const uint8_t arg) { | ... | ... |
client/src/core/windows/pop.cc
| ... | ... | @@ -44,11 +44,31 @@ |
| 44 | 44 | |
| 45 | 45 | namespace TN3270 { |
| 46 | 46 | |
| 47 | + class InvalidFormatException : public std::exception { | |
| 48 | + private: | |
| 49 | + string message; | |
| 50 | + | |
| 51 | + public: | |
| 52 | + InvalidFormatException(const IPC::Request::Type received, const IPC::Request::Type expected) { | |
| 53 | + | |
| 54 | + message = "Invalid format on IPC package, expecting \'"; | |
| 55 | + message += (char) expected; | |
| 56 | + message += "\' but received \'"; | |
| 57 | + message += (char) received; | |
| 58 | + message += "\'"; | |
| 59 | + | |
| 60 | + } | |
| 61 | + | |
| 62 | + const char * what() const noexcept override { | |
| 63 | + return message.c_str(); | |
| 64 | + } | |
| 65 | + }; | |
| 66 | + | |
| 47 | 67 | IPC::Request & IPC::Request::pop(std::string &value) { |
| 48 | 68 | DataBlock * block = getNextBlock(); |
| 49 | 69 | |
| 50 | 70 | if(block->type != IPC::Request::String) |
| 51 | - throw std::runtime_error("Invalid format"); | |
| 71 | + throw InvalidFormatException(block->type, IPC::Request::String); | |
| 52 | 72 | |
| 53 | 73 | const char *ptr = (const char *) (block+1); |
| 54 | 74 | |
| ... | ... | @@ -80,7 +100,7 @@ |
| 80 | 100 | break; |
| 81 | 101 | |
| 82 | 102 | default: |
| 83 | - throw std::runtime_error("Invalid format"); | |
| 103 | + throw InvalidFormatException(block->type, IPC::Request::Int16); | |
| 84 | 104 | } |
| 85 | 105 | |
| 86 | 106 | return *this; |
| ... | ... | @@ -107,7 +127,7 @@ |
| 107 | 127 | break; |
| 108 | 128 | |
| 109 | 129 | default: |
| 110 | - throw std::runtime_error("Invalid format"); | |
| 130 | + throw InvalidFormatException(block->type, IPC::Request::Uint16); | |
| 111 | 131 | } |
| 112 | 132 | |
| 113 | 133 | return *this; |
| ... | ... | @@ -139,7 +159,7 @@ |
| 139 | 159 | break; |
| 140 | 160 | |
| 141 | 161 | default: |
| 142 | - throw std::runtime_error("Invalid format"); | |
| 162 | + throw InvalidFormatException(block->type, IPC::Request::Boolean); | |
| 143 | 163 | } |
| 144 | 164 | |
| 145 | 165 | return *this; | ... | ... |
client/src/core/windows/request.cc
| ... | ... | @@ -37,6 +37,7 @@ |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | 39 | #include <ipc-client-internals.h> |
| 40 | + #include <lib3270/trace.h> | |
| 40 | 41 | |
| 41 | 42 | using std::string; |
| 42 | 43 | |
| ... | ... | @@ -46,6 +47,51 @@ |
| 46 | 47 | |
| 47 | 48 | #define PIPE_BUFFER_LENGTH 8192 |
| 48 | 49 | |
| 50 | +#ifdef DEBUG | |
| 51 | + | |
| 52 | + // From lib3270_trace_data | |
| 53 | + static void trace_data(const char *msg, const unsigned char *data, size_t datalen) | |
| 54 | +{ | |
| 55 | + // 00000000001111111111222222222233333333334444444444555555555566666666667777777777 | |
| 56 | + // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 | |
| 57 | + // xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx . . . . . . . . . . . . . . . . | |
| 58 | + | |
| 59 | + size_t ix; | |
| 60 | + char buffer[80]; | |
| 61 | + char hexvalue[3]; | |
| 62 | + | |
| 63 | + memset(buffer,0,sizeof(buffer)); | |
| 64 | + | |
| 65 | + std::cout << msg << "(" << datalen << " bytes)" << std::endl; | |
| 66 | + | |
| 67 | + for(ix = 0; ix < datalen; ix++) | |
| 68 | + { | |
| 69 | + size_t col = (ix%15); | |
| 70 | + | |
| 71 | + if(col == 0) | |
| 72 | + { | |
| 73 | + if(ix) { | |
| 74 | + std::cout << "\t" << buffer << std::endl; | |
| 75 | + } | |
| 76 | + | |
| 77 | + memset(buffer,' ',79); | |
| 78 | + buffer[79] = 0; | |
| 79 | + } | |
| 80 | + | |
| 81 | + snprintf(hexvalue,3,"%02x",data[ix]); | |
| 82 | + memcpy(buffer+(col*3),hexvalue,2); | |
| 83 | + | |
| 84 | + if(data[ix] > ' ') | |
| 85 | + buffer[48 + (col*2)] = data[ix]; | |
| 86 | + | |
| 87 | + } | |
| 88 | + | |
| 89 | + std::cout << "\t" << buffer << std::endl; | |
| 90 | + | |
| 91 | +} | |
| 92 | + | |
| 93 | +#endif // DEBUG | |
| 94 | + | |
| 49 | 95 | IPC::Request::Request(HANDLE hPipe, const char *name, uint16_t type) { |
| 50 | 96 | |
| 51 | 97 | this->hPipe = hPipe; |
| ... | ... | @@ -114,7 +160,7 @@ |
| 114 | 160 | IPC::Request & IPC::Request::call() { |
| 115 | 161 | |
| 116 | 162 | #ifdef DEBUG |
| 117 | - // lib3270_trace_data(NULL,"Request block",(const char *) this->out.block, this->out.used); | |
| 163 | + // trace_data("Request block",(const unsigned char *) this->out.block, this->out.used); | |
| 118 | 164 | #endif // DEBUG |
| 119 | 165 | |
| 120 | 166 | debug("Sending request with ", *this->outvalues, " elements"); |
| ... | ... | @@ -137,8 +183,19 @@ |
| 137 | 183 | |
| 138 | 184 | debug("Received response \"", in.block, "\" with ", in.used, " bytes"); |
| 139 | 185 | |
| 186 | + // | |
| 187 | + // Heaer format: | |
| 188 | + // | |
| 189 | + // STRING Response name | |
| 190 | + // uint16_t Return code | |
| 191 | + // uint16_t Arguments | |
| 192 | + // | |
| 193 | + // Data block: | |
| 194 | + // | |
| 195 | + // | |
| 196 | + | |
| 140 | 197 | #ifdef DEBUG |
| 141 | - // lib3270_trace_data(NULL,"Response block",(const char *) this->in.block, this->in.used); | |
| 198 | + trace_data("Response block",(const unsigned char *) this->in.block, this->in.used); | |
| 142 | 199 | #endif // DEBUG |
| 143 | 200 | |
| 144 | 201 | // Extract response name | ... | ... |
client/src/core/windows/tools.cc
| ... | ... | @@ -90,7 +90,7 @@ |
| 90 | 90 | |
| 91 | 91 | for(ix = 0; installLocation.empty() && ix < (sizeof(keys)/sizeof(keys[0])); ix++) { |
| 92 | 92 | |
| 93 | - debug(ix,"=",keys[ix]); | |
| 93 | +// debug(ix,"=",keys[ix]); | |
| 94 | 94 | |
| 95 | 95 | rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,keys[ix],0,KEY_QUERY_VALUE,&hKey); |
| 96 | 96 | if(rc == ERROR_SUCCESS) { |
| ... | ... | @@ -103,11 +103,8 @@ |
| 103 | 103 | |
| 104 | 104 | rc = RegQueryValueExA(hKey,"InstallLocation",NULL,&datatype,(LPBYTE) datadir,&datalen); |
| 105 | 105 | if(rc == ERROR_SUCCESS) { |
| 106 | - | |
| 107 | - debug("Found: ",datadir); | |
| 108 | - | |
| 106 | +// debug("Found: ",datadir); | |
| 109 | 107 | installLocation.assign(datadir); |
| 110 | - | |
| 111 | 108 | } |
| 112 | 109 | |
| 113 | 110 | RegCloseKey(hKey); | ... | ... |
client/src/host/properties.cc
| ... | ... | @@ -58,7 +58,7 @@ std::vector<TN3270::Attribute> TN3270::Host::getAttributes() const { |
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -void TN3270::Host::setTimeout(time_t timeout) noexcept { | |
| 61 | +void TN3270::Host::setTimeout(time_t timeout) { | |
| 62 | 62 | this->timeout = timeout; |
| 63 | 63 | this->session->setTimeout(timeout); |
| 64 | 64 | } | ... | ... |
client/src/include/lib3270/ipc.h
| ... | ... | @@ -38,6 +38,7 @@ |
| 38 | 38 | #include <lib3270.h> |
| 39 | 39 | #include <lib3270/keyboard.h> |
| 40 | 40 | #include <lib3270/actions.h> |
| 41 | + #include <lib3270/ssl.h> | |
| 41 | 42 | |
| 42 | 43 | #if defined(_WIN32) || defined(_MSC_VER) |
| 43 | 44 | |
| ... | ... | @@ -113,29 +114,28 @@ |
| 113 | 114 | * |
| 114 | 115 | */ |
| 115 | 116 | template<typename T> |
| 116 | - class lib3270_auto_cleanup { | |
| 117 | + class lib3270_ptr { | |
| 117 | 118 | private: |
| 118 | - T *data; | |
| 119 | + T *ptr; | |
| 119 | 120 | |
| 120 | 121 | public: |
| 121 | - lib3270_auto_cleanup(T *data) { | |
| 122 | - this->data = data; | |
| 122 | + lib3270_ptr(T *d) : ptr(d) { | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - ~lib3270_auto_cleanup() { | |
| 126 | - lib3270_free((void *) this->data); | |
| 125 | + ~lib3270_ptr() { | |
| 126 | + lib3270_free((void *) this->ptr); | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | operator bool() const noexcept { |
| 130 | - return this->data != NULL; | |
| 130 | + return this->ptr != NULL; | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | T * operator->() { |
| 134 | - return this->data; | |
| 134 | + return this->ptr; | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | operator T *() const noexcept { |
| 138 | - return this->data; | |
| 138 | + return this->ptr; | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | }; |
| ... | ... | @@ -212,7 +212,7 @@ |
| 212 | 212 | /// @brief connection state. |
| 213 | 213 | enum ConnectionState : uint8_t { |
| 214 | 214 | DISCONNECTED = LIB3270_NOT_CONNECTED, ///< @brief disconnected |
| 215 | - RESOLVING = LIB3270_RESOLVING, ///< @brief resolving hostname | |
| 215 | + RESOLVING = LIB3270_CONNECTING, ///< @brief Connecting to host | |
| 216 | 216 | PENDING = LIB3270_PENDING, ///< @brief connection pending |
| 217 | 217 | CONNECTED_INITIAL = LIB3270_CONNECTED_INITIAL, ///< @brief connected, no mode yet |
| 218 | 218 | CONNECTED_ANSI = LIB3270_CONNECTED_ANSI, ///< @brief connected in NVT ANSI mode |
| ... | ... | @@ -229,6 +229,7 @@ |
| 229 | 229 | SSL_SECURE = LIB3270_SSL_SECURE, ///< @brief Connection secure with CA check |
| 230 | 230 | SSL_NEGOTIATED = LIB3270_SSL_NEGOTIATED, ///< @brief Connection secure, no CA, self-signed or expired CRL |
| 231 | 231 | SSL_NEGOTIATING = LIB3270_SSL_NEGOTIATING, ///< @brief Negotiating SSL |
| 232 | + SSL_VERIFYING = LIB3270_SSL_VERIFYING, ///< @brief Verifying SSL (Getting CRL) | |
| 232 | 233 | SSL_UNDEFINED = LIB3270_SSL_UNDEFINED ///< @brief Undefined |
| 233 | 234 | }; |
| 234 | 235 | |
| ... | ... | @@ -450,6 +451,15 @@ |
| 450 | 451 | |
| 451 | 452 | public: |
| 452 | 453 | |
| 454 | + struct Cursor { | |
| 455 | + unsigned short row; | |
| 456 | + unsigned short col; | |
| 457 | + | |
| 458 | + Cursor(unsigned short r, unsigned short c) : row(r), col(c) { | |
| 459 | + } | |
| 460 | + | |
| 461 | + }; | |
| 462 | + | |
| 453 | 463 | /// @brief Get an instance of the TN3270 session based on the supplied ID. |
| 454 | 464 | static Session * getInstance(const char *id = nullptr, const char *charset = nullptr); |
| 455 | 465 | virtual ~Session(); |
| ... | ... | @@ -585,6 +595,9 @@ |
| 585 | 595 | /// @brief Get cursor address |
| 586 | 596 | virtual unsigned short getCursorAddress() = 0; |
| 587 | 597 | |
| 598 | + /// @brief Get cursor position. | |
| 599 | + virtual struct Cursor getCursorPosition() = 0; | |
| 600 | + | |
| 588 | 601 | /// @brief Set local charset. |
| 589 | 602 | virtual void setCharSet(const char *charset = NULL) = 0; |
| 590 | 603 | |
| ... | ... | @@ -647,6 +660,11 @@ |
| 647 | 660 | int compare(int baddr, const char* s, int len = -1) const; |
| 648 | 661 | int compare(unsigned short row, unsigned short col, const char* s, int len = -1) const; |
| 649 | 662 | |
| 663 | + virtual void setProperty(const char *name, const int value) = 0; | |
| 664 | + virtual void setProperty(const char *name, const unsigned int value) = 0; | |
| 665 | + virtual void setProperty(const char *name, const bool value) = 0; | |
| 666 | + virtual void setProperty(const char *name, const char *value) = 0; | |
| 667 | + | |
| 650 | 668 | }; |
| 651 | 669 | |
| 652 | 670 | /// @brief TN3270 Host |
| ... | ... | @@ -782,6 +800,10 @@ |
| 782 | 800 | return session->getCursorAddress(); |
| 783 | 801 | } |
| 784 | 802 | |
| 803 | + inline Session::Cursor getCursorPosition() { | |
| 804 | + return session->getCursorPosition(); | |
| 805 | + } | |
| 806 | + | |
| 785 | 807 | inline void setHostURL(const char *url) { |
| 786 | 808 | session->setHostURL(url); |
| 787 | 809 | } |
| ... | ... | @@ -799,6 +821,23 @@ |
| 799 | 821 | return getAttribute(name); |
| 800 | 822 | } |
| 801 | 823 | |
| 824 | + // Set properties. | |
| 825 | + inline void setProperty(const char *name, const int value) { | |
| 826 | + session->setProperty(name,value); | |
| 827 | + } | |
| 828 | + | |
| 829 | + inline void setProperty(const char *name, const unsigned int value) { | |
| 830 | + session->setProperty(name,value); | |
| 831 | + } | |
| 832 | + | |
| 833 | + inline void setProperty(const char *name, const bool value) { | |
| 834 | + session->setProperty(name,value); | |
| 835 | + } | |
| 836 | + | |
| 837 | + inline void setProperty(const char *name, const char *value) { | |
| 838 | + session->setProperty(name,value); | |
| 839 | + } | |
| 840 | + | |
| 802 | 841 | /// @brief Get lib3270 version. |
| 803 | 842 | inline std::string getVersion() const { |
| 804 | 843 | return session->getVersion(); |
| ... | ... | @@ -839,7 +878,7 @@ |
| 839 | 878 | } |
| 840 | 879 | |
| 841 | 880 | // Set properties |
| 842 | - void setTimeout(time_t timeout = DEFAULT_TIMEOUT) noexcept; | |
| 881 | + void setTimeout(time_t timeout = DEFAULT_TIMEOUT); | |
| 843 | 882 | |
| 844 | 883 | inline void setUnlockDelay(unsigned short delay = 350) { |
| 845 | 884 | session->setUnlockDelay(delay); |
| ... | ... | @@ -937,6 +976,19 @@ |
| 937 | 976 | int compare(int baddr, const char* s, int len = -1) const; |
| 938 | 977 | int compare(unsigned short row, unsigned short col, const char* s, int len = -1) const; |
| 939 | 978 | |
| 979 | + /* | |
| 980 | + Host & setProperty(const char *name, const std::string &value) { | |
| 981 | + session->setProperty(name,value.c_str()); | |
| 982 | + return *this; | |
| 983 | + } | |
| 984 | + | |
| 985 | + template <typename T> | |
| 986 | + Host & setProperty(const char *name, const T value) { | |
| 987 | + session->setProperty(name,value); | |
| 988 | + return *this; | |
| 989 | + } | |
| 990 | + */ | |
| 991 | + | |
| 940 | 992 | // Set contents. |
| 941 | 993 | |
| 942 | 994 | /// @brief Input string. | ... | ... |
client/src/include/lib3270/ipc/request.h
| ... | ... | @@ -58,12 +58,8 @@ |
| 58 | 58 | |
| 59 | 59 | /// @brief PW3270 IPC Request/Response. |
| 60 | 60 | class TN3270_PUBLIC Request { |
| 61 | - private: | |
| 62 | - | |
| 61 | + public: | |
| 63 | 62 | #ifdef _WIN32 |
| 64 | - /// @brief Pipe Handle. | |
| 65 | - HANDLE hPipe; | |
| 66 | - | |
| 67 | 63 | /// @brief IPC Data type. |
| 68 | 64 | enum Type : uint8_t { |
| 69 | 65 | String = 's', |
| ... | ... | @@ -77,6 +73,13 @@ |
| 77 | 73 | Int64 = 'x', |
| 78 | 74 | Uint64 = 't' |
| 79 | 75 | }; |
| 76 | +#endif // _WIN32 | |
| 77 | + | |
| 78 | + private: | |
| 79 | + | |
| 80 | +#ifdef _WIN32 | |
| 81 | + /// @brief Pipe Handle. | |
| 82 | + HANDLE hPipe; | |
| 80 | 83 | |
| 81 | 84 | struct { |
| 82 | 85 | DWORD length; ///< @brief Length of input buffer. | ... | ... |
client/src/session/local/actions.cc
| ... | ... | @@ -74,7 +74,7 @@ |
| 74 | 74 | |
| 75 | 75 | void Local::Session::action(const char *action_name) { |
| 76 | 76 | std::lock_guard<std::recursive_mutex> lock(sync); |
| 77 | - chkResponse(lib3270_action_activate_by_name(action_name,hSession)); | |
| 77 | + chkResponse(lib3270_activate_by_name(hSession,action_name)); | |
| 78 | 78 | if(this->timeout) |
| 79 | 79 | chkResponse(lib3270_wait_for_ready(hSession,this->timeout)); |
| 80 | 80 | } | ... | ... |
client/src/session/local/attribute.cc
| ... | ... | @@ -527,6 +527,16 @@ |
| 527 | 527 | return rc; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | + struct Session::Cursor Local::Session::getCursorPosition() { | |
| 531 | + | |
| 532 | + std::lock_guard<std::recursive_mutex> lock(sync); | |
| 533 | + | |
| 534 | + unsigned short row = 0, col = 0; | |
| 535 | + | |
| 536 | + return Session::Cursor(row,col); | |
| 537 | + | |
| 538 | + }; | |
| 539 | + | |
| 530 | 540 | std::string Local::Session::getVersion() const { |
| 531 | 541 | |
| 532 | 542 | std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | ... | ... |
client/src/session/local/get.cc
| ... | ... | @@ -46,7 +46,7 @@ |
| 46 | 46 | |
| 47 | 47 | std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); |
| 48 | 48 | |
| 49 | - lib3270_auto_cleanup<char> text = lib3270_get_string_at_address(hSession, 0, -1, '\n'); | |
| 49 | + lib3270_ptr<char> text = lib3270_get_string_at_address(hSession, 0, -1, '\n'); | |
| 50 | 50 | |
| 51 | 51 | if(!text) { |
| 52 | 52 | throw std::runtime_error( _("Can't get screen contents") ); |
| ... | ... | @@ -59,7 +59,7 @@ |
| 59 | 59 | |
| 60 | 60 | std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); |
| 61 | 61 | |
| 62 | - lib3270_auto_cleanup<char> text = lib3270_get_string_at_address(hSession, baddr, len, lf); | |
| 62 | + lib3270_ptr<char> text = lib3270_get_string_at_address(hSession, baddr, len, lf); | |
| 63 | 63 | |
| 64 | 64 | if(!text) { |
| 65 | 65 | throw std::runtime_error( _("Can't get screen contents") ); |
| ... | ... | @@ -72,7 +72,7 @@ |
| 72 | 72 | |
| 73 | 73 | std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); |
| 74 | 74 | |
| 75 | - lib3270_auto_cleanup<char> text = lib3270_get_string_at(hSession, row, col, len, lf); | |
| 75 | + lib3270_ptr<char> text = lib3270_get_string_at(hSession, row, col, len, lf); | |
| 76 | 76 | |
| 77 | 77 | if(!text) { |
| 78 | 78 | throw std::runtime_error( _("Can't get screen contents") ); | ... | ... |
client/src/session/local/private.h
| ... | ... | @@ -161,7 +161,11 @@ |
| 161 | 161 | unsigned short setCursor(int addr) override; |
| 162 | 162 | unsigned short setCursor(unsigned short row, unsigned short col) override; |
| 163 | 163 | unsigned short getCursorAddress() override; |
| 164 | - | |
| 164 | + Session::Cursor getCursorPosition() override; | |
| 165 | + void setProperty(const char *name, const int value) override; | |
| 166 | + void setProperty(const char *name, const unsigned int value) override; | |
| 167 | + void setProperty(const char *name, const bool value) override; | |
| 168 | + void setProperty(const char *name, const char *value) override; | |
| 165 | 169 | |
| 166 | 170 | }; |
| 167 | 171 | ... | ... |
| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Contatos: | |
| 24 | + * | |
| 25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 27 | + * | |
| 28 | + */ | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * @file | |
| 32 | + * | |
| 33 | + * @brief | |
| 34 | + * | |
| 35 | + * @author perry.werneck@gmail.com | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | + #include "private.h" | |
| 40 | + #include <lib3270/ipc.h> | |
| 41 | + #include <lib3270/properties.h> | |
| 42 | + | |
| 43 | +/*---[ Implement ]----------------------------------------------------------------------------------*/ | |
| 44 | + | |
| 45 | + namespace TN3270 { | |
| 46 | + | |
| 47 | + void Local::Session::setProperty(const char *name, const int value) { | |
| 48 | + | |
| 49 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 50 | + int rc = lib3270_set_int_property(hSession,name,value,0); | |
| 51 | + if(rc) | |
| 52 | + chkResponse(rc); | |
| 53 | + | |
| 54 | + } | |
| 55 | + | |
| 56 | + void Local::Session::setProperty(const char *name, const unsigned int value) { | |
| 57 | + | |
| 58 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 59 | + int rc = lib3270_set_uint_property(hSession,name,value,0); | |
| 60 | + if(rc) | |
| 61 | + chkResponse(rc); | |
| 62 | + | |
| 63 | + } | |
| 64 | + | |
| 65 | + void Local::Session::setProperty(const char *name, const bool value) { | |
| 66 | + | |
| 67 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 68 | + int rc = lib3270_set_boolean_property(hSession,name,(int) value, 0); | |
| 69 | + if(rc) | |
| 70 | + chkResponse(rc); | |
| 71 | + | |
| 72 | + } | |
| 73 | + | |
| 74 | + void Local::Session::setProperty(const char *name, const char *value) { | |
| 75 | + | |
| 76 | + std::lock_guard<std::recursive_mutex> lock(const_cast<Local::Session *>(this)->sync); | |
| 77 | + int rc = lib3270_set_string_property(hSession, name, value, 0); | |
| 78 | + if(rc) | |
| 79 | + chkResponse(rc); | |
| 80 | + | |
| 81 | + } | |
| 82 | + | |
| 83 | + } | |
| 84 | + | |
| 85 | + | ... | ... |
client/src/session/local/wait.cc
| ... | ... | @@ -39,7 +39,10 @@ |
| 39 | 39 | #include "private.h" |
| 40 | 40 | #include <lib3270/actions.h> |
| 41 | 41 | #include <signal.h> |
| 42 | - #include <unistd.h> | |
| 42 | + | |
| 43 | +#ifndef _WIN32 | |
| 44 | + #include <unistd.h> | |
| 45 | +#endif // _WIN32 | |
| 43 | 46 | |
| 44 | 47 | /*---[ Implement ]----------------------------------------------------------------------------------*/ |
| 45 | 48 | ... | ... |
client/src/session/remote/attribute.cc
| ... | ... | @@ -489,7 +489,18 @@ |
| 489 | 489 | |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | + Session::Cursor IPC::Session::getCursorPosition() { | |
| 492 | 493 | |
| 494 | + uint32_t row, col; | |
| 495 | + | |
| 496 | + Request(*this,"getCursorPosition") | |
| 497 | + .call() | |
| 498 | + .pop(row) | |
| 499 | + .pop(col); | |
| 500 | + | |
| 501 | + return Session::Cursor(row,col); | |
| 502 | + | |
| 503 | + } | |
| 493 | 504 | |
| 494 | 505 | } |
| 495 | 506 | ... | ... |
client/src/session/remote/private.h
| ... | ... | @@ -166,6 +166,11 @@ |
| 166 | 166 | unsigned short setCursor(int addr) override; |
| 167 | 167 | unsigned short setCursor(unsigned short row, unsigned short col) override; |
| 168 | 168 | unsigned short getCursorAddress() override; |
| 169 | + Session::Cursor getCursorPosition() override; | |
| 170 | + void setProperty(const char *name, const int value) override; | |
| 171 | + void setProperty(const char *name, const unsigned int value) override; | |
| 172 | + void setProperty(const char *name, const bool value) override; | |
| 173 | + void setProperty(const char *name, const char *value) override; | |
| 169 | 174 | |
| 170 | 175 | }; |
| 171 | 176 | ... | ... |
client/src/session/remote/properties.cc
| ... | ... | @@ -236,6 +236,22 @@ |
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | + void IPC::Session::setProperty(const char *name, const int value) { | |
| 240 | + setAttribute(name,value); | |
| 241 | + } | |
| 242 | + | |
| 243 | + void IPC::Session::setProperty(const char *name, const unsigned int value) { | |
| 244 | + setAttribute(name,value); | |
| 245 | + } | |
| 246 | + | |
| 247 | + void IPC::Session::setProperty(const char *name, const bool value) { | |
| 248 | + setAttribute(name,value); | |
| 249 | + } | |
| 250 | + | |
| 251 | + void IPC::Session::setProperty(const char *name, const char *value) { | |
| 252 | + setAttribute(name,value); | |
| 253 | + } | |
| 254 | + | |
| 239 | 255 | } |
| 240 | 256 | |
| 241 | 257 | ... | ... |
client/src/session/remote/wait.cc
| ... | ... | @@ -205,9 +205,9 @@ |
| 205 | 205 | |
| 206 | 206 | void IPC::Session::wait(unsigned short row, unsigned short col, const char *text, int seconds) { |
| 207 | 207 | |
| 208 | - string key = convertToHost(text,-1); | |
| 208 | + debug((const char *) __FUNCTION__, "(", row, ",", col, ",\"",text,"\")"); | |
| 209 | 209 | |
| 210 | - debug((const char *) __FUNCTION__, "(", (int) row, ",", (int) col, ", \"", text, "\", length=", key.size()); | |
| 210 | + string key = convertToHost(text,-1); | |
| 211 | 211 | |
| 212 | 212 | wait(seconds, [this, key, row, col]() { |
| 213 | 213 | ... | ... |
client/src/testprogram/testprogram.cc
| ... | ... | @@ -38,14 +38,15 @@ |
| 38 | 38 | |
| 39 | 39 | #include <ctime> |
| 40 | 40 | |
| 41 | - #include <getopt.h> | |
| 42 | - | |
| 43 | 41 | #if defined(_MSC_VER) |
| 44 | 42 | #pragma comment(lib,"ipc3270.lib") |
| 45 | 43 | #else |
| 46 | 44 | #pragma GCC diagnostic ignored "-Wunused-function" |
| 47 | 45 | #pragma GCC diagnostic ignored "-Wunused-parameter" |
| 48 | 46 | #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" |
| 47 | + | |
| 48 | + #include <getopt.h> | |
| 49 | + | |
| 49 | 50 | #endif // _MSC_VER |
| 50 | 51 | |
| 51 | 52 | #include <cstdlib> |
| ... | ... | @@ -98,12 +99,22 @@ |
| 98 | 99 | */ |
| 99 | 100 | |
| 100 | 101 | // Test Attributes |
| 101 | - static void testAttributes(const char *session, const char *url) { | |
| 102 | + static void testAttributes(const char *session, const char *name) { | |
| 102 | 103 | |
| 103 | 104 | TN3270::Host host{session}; |
| 104 | 105 | |
| 106 | + host.setTimeout(5); | |
| 107 | + host.setProperty("crl_download",false); | |
| 108 | + | |
| 109 | + //name="url"; | |
| 110 | + | |
| 111 | + cout << endl << endl; | |
| 105 | 112 | for(auto attribute : host.getAttributes()) { |
| 106 | 113 | |
| 114 | + if(name && *name && strcasecmp(name,"all") && strcasecmp(attribute.getName(),name)) { | |
| 115 | + continue; | |
| 116 | + } | |
| 117 | + | |
| 107 | 118 | cout << attribute.getName() << ":\t"; |
| 108 | 119 | |
| 109 | 120 | try { |
| ... | ... | @@ -112,13 +123,27 @@ |
| 112 | 123 | |
| 113 | 124 | } catch(const std::exception &e) { |
| 114 | 125 | |
| 115 | - cout << e.what(); | |
| 126 | + cout << "Exception(" << e.what() << ")"; | |
| 116 | 127 | } |
| 117 | 128 | |
| 118 | 129 | cout << endl; |
| 119 | 130 | |
| 120 | 131 | } |
| 121 | 132 | |
| 133 | + cout << "Cursor position: "; | |
| 134 | + | |
| 135 | + try { | |
| 136 | + | |
| 137 | + auto cursor = host.getCursorPosition(); | |
| 138 | + cout << cursor.row << "," << cursor.col; | |
| 139 | + | |
| 140 | + } catch(const std::exception &e) { | |
| 141 | + | |
| 142 | + cout << "Exception(" << e.what() << ")"; | |
| 143 | + } | |
| 144 | + | |
| 145 | + cout << endl << endl << endl; | |
| 146 | + | |
| 122 | 147 | } |
| 123 | 148 | |
| 124 | 149 | // Performance test. |
| ... | ... | @@ -233,41 +258,80 @@ |
| 233 | 258 | const char * session = ":A"; |
| 234 | 259 | const char * url = nullptr; |
| 235 | 260 | |
| 261 | +#if ! defined(_MSC_VER) | |
| 262 | + | |
| 236 | 263 | static struct option options[] = { |
| 237 | - { "session", required_argument, 0, 's' }, | |
| 238 | - { "url", required_argument, 0, 'U' }, | |
| 239 | - { "perftest", no_argument, 0, 'P' }, | |
| 240 | - { "info", no_argument, 0, 'I' }, | |
| 264 | + { "session", required_argument, 0, 's' }, | |
| 265 | + { "url", required_argument, 0, 'U' }, | |
| 266 | + { "perftest", no_argument, 0, 'P' }, | |
| 267 | + { "attribute", optional_argument, 0, 'A' }, | |
| 268 | + { "info", no_argument, 0, 'I' }, | |
| 241 | 269 | { 0, 0, 0, 0} |
| 242 | 270 | |
| 243 | 271 | }; |
| 244 | 272 | |
| 245 | - int long_index =0; | |
| 246 | - int opt; | |
| 247 | - while((opt = getopt_long(argc, argv, "s:", options, &long_index )) != -1) { | |
| 273 | + try { | |
| 274 | + | |
| 275 | + int long_index =0; | |
| 276 | + int opt; | |
| 277 | + while((opt = getopt_long(argc, argv, "s:A", options, &long_index )) != -1) { | |
| 278 | + | |
| 279 | + switch(opt) { | |
| 280 | + case 's': | |
| 281 | + session = optarg; | |
| 282 | + cout << "Session: " << session << endl; | |
| 283 | + break; | |
| 248 | 284 | |
| 249 | - switch(opt) { | |
| 250 | - case 's': | |
| 251 | - session = optarg; | |
| 252 | - cout << "Session: " << session << endl; | |
| 253 | - break; | |
| 285 | + case 'A': | |
| 254 | 286 | |
| 255 | - case 'U': | |
| 256 | - url = optarg; | |
| 257 | - cout << "URL: " << session << endl; | |
| 258 | - break; | |
| 287 | + try { | |
| 259 | 288 | |
| 260 | - case 'P': | |
| 261 | - testPerformance(session,url); | |
| 262 | - return 0; | |
| 289 | + testAttributes(session,optarg); | |
| 263 | 290 | |
| 264 | - case 'I': | |
| 265 | - testHost(session,url); | |
| 266 | - return 0; | |
| 291 | + } catch(const std::exception &e) { | |
| 292 | + | |
| 293 | + cerr << e.what() << endl; | |
| 294 | + return -1; | |
| 295 | + } | |
| 296 | + | |
| 297 | + break; | |
| 298 | + | |
| 299 | + case 'U': | |
| 300 | + url = optarg; | |
| 301 | + cout << "URL: " << session << endl; | |
| 302 | + break; | |
| 303 | + | |
| 304 | + case 'P': | |
| 305 | + testPerformance(session,url); | |
| 306 | + return 0; | |
| 307 | + | |
| 308 | + case 'I': | |
| 309 | + testHost(session,url); | |
| 310 | + return 0; | |
| 311 | + | |
| 312 | + } | |
| 267 | 313 | |
| 268 | 314 | } |
| 269 | 315 | |
| 316 | + } catch(const std::exception &e) { | |
| 317 | + | |
| 318 | + cerr << "Error:" << endl << "\t" << e.what() << endl << endl; | |
| 319 | + exit(-1); | |
| 320 | + | |
| 270 | 321 | } |
| 322 | +#else | |
| 323 | + | |
| 324 | + printf("\nRunning IPC Client tests\n"); | |
| 325 | + | |
| 326 | + TN3270::Host host{session}; | |
| 327 | + host.setTimeout(10); | |
| 328 | + host.connect(); | |
| 329 | + printf("\n\nWaiting...\n"); | |
| 330 | + host.wait(14,22,"SISTEMA"); | |
| 331 | + | |
| 332 | + host.disconnect(); | |
| 333 | + | |
| 334 | +#endif // !_MSC_VER | |
| 271 | 335 | |
| 272 | 336 | /* |
| 273 | 337 | ... | ... |
ipc3270.exp
No preview for this file type
server/pw3270-plugin-ipc.cbp
| ... | ... | @@ -68,9 +68,6 @@ |
| 68 | 68 | <Option compilerVar="CC" /> |
| 69 | 69 | </Unit> |
| 70 | 70 | <Unit filename="src/core/linux/gobject.h" /> |
| 71 | - <Unit filename="src/core/linux/response.c"> | |
| 72 | - <Option compilerVar="CC" /> | |
| 73 | - </Unit> | |
| 74 | 71 | <Unit filename="src/core/linux/start.c"> |
| 75 | 72 | <Option compilerVar="CC" /> |
| 76 | 73 | </Unit> |
| ... | ... | @@ -102,6 +99,9 @@ |
| 102 | 99 | <Unit filename="src/core/methods/wait.c"> |
| 103 | 100 | <Option compilerVar="CC" /> |
| 104 | 101 | </Unit> |
| 102 | + <Unit filename="src/core/response.c"> | |
| 103 | + <Option compilerVar="CC" /> | |
| 104 | + </Unit> | |
| 105 | 105 | <Unit filename="src/core/setproperties.c"> |
| 106 | 106 | <Option compilerVar="CC" /> |
| 107 | 107 | </Unit> |
| ... | ... | @@ -121,9 +121,6 @@ |
| 121 | 121 | <Unit filename="src/core/windows/resources.rc"> |
| 122 | 122 | <Option compilerVar="WINDRES" /> |
| 123 | 123 | </Unit> |
| 124 | - <Unit filename="src/core/windows/response.c"> | |
| 125 | - <Option compilerVar="CC" /> | |
| 126 | - </Unit> | |
| 127 | 124 | <Unit filename="src/core/windows/start.c"> |
| 128 | 125 | <Option compilerVar="CC" /> |
| 129 | 126 | </Unit> |
| ... | ... | @@ -161,9 +158,6 @@ |
| 161 | 158 | <Option compilerVar="CC" /> |
| 162 | 159 | </Unit> |
| 163 | 160 | <Extensions> |
| 164 | - <code_completion /> | |
| 165 | - <envvars /> | |
| 166 | - <debugger /> | |
| 167 | 161 | <lib_finder disable_auto="1" /> |
| 168 | 162 | </Extensions> |
| 169 | 163 | </Project> | ... | ... |
server/src/core/getproperties.c
| ... | ... | @@ -127,6 +127,7 @@ GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GEr |
| 127 | 127 | if(strprop[ix].get && !g_ascii_strcasecmp(strprop[ix].name, property_name)) { |
| 128 | 128 | |
| 129 | 129 | // Found it! |
| 130 | + errno = 0; | |
| 130 | 131 | const char * value = strprop[ix].get(hSession); |
| 131 | 132 | |
| 132 | 133 | if(value) { |
| ... | ... | @@ -134,9 +135,14 @@ GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GEr |
| 134 | 135 | return g_variant_new_string(value); |
| 135 | 136 | } |
| 136 | 137 | |
| 137 | - // Erro! | |
| 138 | - ipc3270_set_error(object,errno,error); | |
| 139 | - return NULL; | |
| 138 | + debug("%s=%s",property_name,"NULL"); | |
| 139 | + | |
| 140 | + if(errno) { | |
| 141 | + ipc3270_set_error(object,errno,error); | |
| 142 | + return NULL; | |
| 143 | + } | |
| 144 | + | |
| 145 | + return g_variant_new_string(""); | |
| 140 | 146 | |
| 141 | 147 | } |
| 142 | 148 | ... | ... |
server/src/core/linux/gobject.c
| ... | ... | @@ -120,7 +120,7 @@ void ipc3270_add_terminal_introspection(GString *introspection) { |
| 120 | 120 | " <arg type='s' name='name' direction='in' />" \ |
| 121 | 121 | " <arg type='b' name='result' direction='out' />" \ |
| 122 | 122 | " </method>" |
| 123 | - " <method name='setwaitmode'>" | |
| 123 | + " <method name='setWaitMode'>" | |
| 124 | 124 | " <arg type='b' name='mode' direction='in' />" \ |
| 125 | 125 | " <arg type='i' name='result' direction='out' />" \ |
| 126 | 126 | " </method>" |
| ... | ... | @@ -197,6 +197,10 @@ void ipc3270_add_terminal_introspection(GString *introspection) { |
| 197 | 197 | " <arg type='i' name='addr' direction='in' />" \ |
| 198 | 198 | " <arg type='i' name='old' direction='out' />" \ |
| 199 | 199 | " </method>" \ |
| 200 | + " <method name= 'getCursorPosition'>" \ | |
| 201 | + " <arg type='u' name='row' direction='out' />" \ | |
| 202 | + " <arg type='u' name='col' direction='out' />" \ | |
| 203 | + " </method>" \ | |
| 200 | 204 | " <method name= 'getFieldAttribute'>" \ |
| 201 | 205 | " <arg type='u' name='attribute' direction='out' />" \ |
| 202 | 206 | " </method>" \ | ... | ... |
server/src/core/linux/response.c
| ... | ... | @@ -1,149 +0,0 @@ |
| 1 | -/* | |
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | - * | |
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | - * | |
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | - * Free Software Foundation. | |
| 11 | - * | |
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | - * obter mais detalhes. | |
| 16 | - * | |
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | - * | |
| 21 | - * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | - * | |
| 23 | - * Referências: | |
| 24 | - * | |
| 25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
| 26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
| 27 | - * | |
| 28 | - * Contatos: | |
| 29 | - * | |
| 30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | -#include "gobject.h" | |
| 36 | -#include <lib3270.h> | |
| 37 | -#include <lib3270/actions.h> | |
| 38 | -#include <lib3270/properties.h> | |
| 39 | -#include <lib3270/toggle.h> | |
| 40 | -#include <v3270.h> | |
| 41 | - | |
| 42 | -#include <dbus/dbus-glib.h> | |
| 43 | -#include <dbus/dbus-glib-bindings.h> | |
| 44 | - | |
| 45 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 46 | - | |
| 47 | -struct _ipc3270Response { | |
| 48 | - GObject parent; | |
| 49 | - GVariant * value; | |
| 50 | -}; | |
| 51 | - | |
| 52 | -struct _ipc3270ResponseClass { | |
| 53 | - | |
| 54 | - GObjectClass parent; | |
| 55 | - int dummy; | |
| 56 | - | |
| 57 | -}; | |
| 58 | - | |
| 59 | - | |
| 60 | -G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) | |
| 61 | - | |
| 62 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 63 | - | |
| 64 | -static void ipc3270Response_finalize(GObject *object) { | |
| 65 | - | |
| 66 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 67 | - | |
| 68 | - debug("%s value=%p",__FUNCTION__,response->value); | |
| 69 | - | |
| 70 | - if(response->value) | |
| 71 | - g_variant_unref(response->value); | |
| 72 | - | |
| 73 | -} | |
| 74 | - | |
| 75 | - | |
| 76 | -static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { | |
| 77 | - | |
| 78 | - debug("%s",__FUNCTION__); | |
| 79 | - | |
| 80 | - GObjectClass *object_class; | |
| 81 | - object_class = G_OBJECT_CLASS (klass); | |
| 82 | - object_class->finalize = ipc3270Response_finalize; | |
| 83 | - | |
| 84 | -} | |
| 85 | - | |
| 86 | -static void ipc3270Response_init(ipc3270Response *object) { | |
| 87 | - | |
| 88 | - object->value = NULL; | |
| 89 | - | |
| 90 | -} | |
| 91 | - | |
| 92 | -GObject * ipc3270_response_new() { | |
| 93 | - return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); | |
| 94 | -} | |
| 95 | - | |
| 96 | -void ipc3270_response_append_int32(GObject *object, gint32 value) { | |
| 97 | - | |
| 98 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 99 | - | |
| 100 | - if(response->value) | |
| 101 | - g_variant_unref(response->value); | |
| 102 | - | |
| 103 | - response->value = g_variant_new_int32(value); | |
| 104 | -} | |
| 105 | - | |
| 106 | -void ipc3270_response_append_uint32(GObject *object, guint32 value) { | |
| 107 | - | |
| 108 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 109 | - | |
| 110 | - if(response->value) | |
| 111 | - g_variant_unref(response->value); | |
| 112 | - | |
| 113 | - response->value = g_variant_new_uint32(value); | |
| 114 | -} | |
| 115 | - | |
| 116 | -void ipc3270_response_append_string(GObject *object, const gchar *text) { | |
| 117 | - | |
| 118 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 119 | - | |
| 120 | - if(response->value) | |
| 121 | - g_variant_unref(response->value); | |
| 122 | - | |
| 123 | - response->value = g_variant_new_string(text); | |
| 124 | - | |
| 125 | -} | |
| 126 | - | |
| 127 | -void ipc3270_response_append_boolean(GObject *object, gboolean value) { | |
| 128 | - | |
| 129 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 130 | - | |
| 131 | - if(response->value) | |
| 132 | - g_variant_unref(response->value); | |
| 133 | - | |
| 134 | - response->value = g_variant_new_boolean(value); | |
| 135 | -} | |
| 136 | - | |
| 137 | -GVariant * ipc3270_response_steal_value(GObject *object) { | |
| 138 | - | |
| 139 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 140 | - | |
| 141 | - GVariant * value = response->value; | |
| 142 | - response->value = NULL; | |
| 143 | - | |
| 144 | - return value; | |
| 145 | -} | |
| 146 | - | |
| 147 | -gboolean ipc3270_response_has_values(GObject *object) { | |
| 148 | - return IPC3270_RESPONSE(object)->value != NULL; | |
| 149 | -} |
server/src/core/linux/start.c
| ... | ... | @@ -67,8 +67,16 @@ static void |
| 67 | 67 | // It is an error if parameters is not of the right format: it must be a tuple containing the out-parameters of the D-Bus method. |
| 68 | 68 | // Even if the method has a single out-parameter, it must be contained in a tuple. |
| 69 | 69 | |
| 70 | - GVariant *values[] = { ipc3270_response_steal_value(response) }; | |
| 71 | - g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(values,1)); | |
| 70 | + guint ix; | |
| 71 | + guint length = ipc3270_response_length(response); | |
| 72 | + | |
| 73 | + g_autofree GVariant ** values = g_new0(GVariant *, length); | |
| 74 | + | |
| 75 | + for(ix = 0; ix < length; ix++) { | |
| 76 | + values[ix] = ipc3270_response_steal_value(response); | |
| 77 | + } | |
| 78 | + | |
| 79 | + g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(values,length)); | |
| 72 | 80 | |
| 73 | 81 | } else { |
| 74 | 82 | ... | ... |
server/src/core/methods/action.c
| ... | ... | @@ -39,7 +39,13 @@ int ipc3270_method_action(GObject *session, GVariant *request, GObject *response |
| 39 | 39 | |
| 40 | 40 | GVariant *value = g_variant_get_child_value(request,0); |
| 41 | 41 | |
| 42 | - ipc3270_response_append_int32(response, lib3270_action_activate_by_name(g_variant_get_string(value,NULL), ipc3270_get_session(session))); | |
| 42 | + ipc3270_response_append_int32( | |
| 43 | + response, | |
| 44 | + lib3270_activate_by_name( | |
| 45 | + ipc3270_get_session(session), | |
| 46 | + g_variant_get_string(value,NULL) | |
| 47 | + ) | |
| 48 | + ); | |
| 43 | 49 | |
| 44 | 50 | g_variant_unref(value); |
| 45 | 51 | ... | ... |
server/src/core/methods/cursor.c
| ... | ... | @@ -66,3 +66,22 @@ int ipc3270_method_set_cursor(GObject *session, GVariant *request, GObject *resp |
| 66 | 66 | return 0; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | +int ipc3270_method_get_cursor_position(GObject *session, GVariant G_GNUC_UNUSED(*request), GObject *response, GError **error) { | |
| 70 | + | |
| 71 | + H3270 *hSession = ipc3270_get_session(session); | |
| 72 | + | |
| 73 | + if(*error) | |
| 74 | + return 0; | |
| 75 | + | |
| 76 | + unsigned short row, col; | |
| 77 | + | |
| 78 | + int rc = lib3270_get_cursor_position(hSession,&row,&col); | |
| 79 | + if(rc) | |
| 80 | + return rc; | |
| 81 | + | |
| 82 | + ipc3270_response_append_uint32(response, (guint32) row); | |
| 83 | + ipc3270_response_append_uint32(response, (guint32) col); | |
| 84 | + | |
| 85 | + return 0; | |
| 86 | +} | |
| 87 | + | ... | ... |
server/src/core/methods/methods.c
| ... | ... | @@ -71,6 +71,7 @@ int ipc3270_method_call(GObject *object, const gchar *method_name, GVariant *req |
| 71 | 71 | |
| 72 | 72 | { "setCursorAddress", ipc3270_method_set_cursor }, |
| 73 | 73 | { "setCursorPosition", ipc3270_method_set_cursor }, |
| 74 | + { "getCursorPosition", ipc3270_method_get_cursor_position }, | |
| 74 | 75 | |
| 75 | 76 | { "action", ipc3270_method_action }, |
| 76 | 77 | { "activatable", ipc3270_method_activatable }, | ... | ... |
server/src/core/methods/private.h
| ... | ... | @@ -57,6 +57,7 @@ |
| 57 | 57 | G_GNUC_INTERNAL int ipc3270_method_wait_for_keyboard_unlock(GObject *session, GVariant *request, GObject *response, GError **error); |
| 58 | 58 | |
| 59 | 59 | G_GNUC_INTERNAL int ipc3270_method_set_cursor(GObject *session, GVariant *request, GObject *response, GError **error); |
| 60 | + G_GNUC_INTERNAL int ipc3270_method_get_cursor_position(GObject *session, GVariant *request, GObject *response, GError **error); | |
| 60 | 61 | |
| 61 | 62 | G_GNUC_INTERNAL int ipc3270_method_action(GObject *session, GVariant *request, GObject *response, GError **error); |
| 62 | 63 | G_GNUC_INTERNAL int ipc3270_method_activatable(GObject *session, GVariant *request, GObject *response, GError **error); | ... | ... |
| ... | ... | @@ -0,0 +1,145 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | + * | |
| 6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | + * | |
| 8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | + * Free Software Foundation. | |
| 11 | + * | |
| 12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | + * obter mais detalhes. | |
| 16 | + * | |
| 17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | + * | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | + * | |
| 23 | + * Referências: | |
| 24 | + * | |
| 25 | + * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
| 26 | + * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
| 27 | + * | |
| 28 | + * Contatos: | |
| 29 | + * | |
| 30 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 31 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + | |
| 35 | +#include <internals.h> | |
| 36 | + | |
| 37 | +#include <glib.h> | |
| 38 | +#include <gio/gio.h> | |
| 39 | + | |
| 40 | +#include <ipc-glib.h> | |
| 41 | +#include <lib3270.h> | |
| 42 | + | |
| 43 | +#include <lib3270/actions.h> | |
| 44 | +#include <lib3270/properties.h> | |
| 45 | +#include <lib3270/toggle.h> | |
| 46 | +#include <v3270.h> | |
| 47 | + | |
| 48 | +#ifndef _WIN32 | |
| 49 | + #include <dbus/dbus-glib.h> | |
| 50 | + #include <dbus/dbus-glib-bindings.h> | |
| 51 | +#endif // _WIN32 | |
| 52 | + | |
| 53 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 54 | + | |
| 55 | +struct _ipc3270Response { | |
| 56 | + GObject parent; | |
| 57 | + GList * values; | |
| 58 | +}; | |
| 59 | + | |
| 60 | +struct _ipc3270ResponseClass { | |
| 61 | + | |
| 62 | + GObjectClass parent; | |
| 63 | + int dummy; | |
| 64 | + | |
| 65 | +}; | |
| 66 | + | |
| 67 | + | |
| 68 | +G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) | |
| 69 | + | |
| 70 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 71 | + | |
| 72 | +static void ipc3270Response_finalize(GObject *object) { | |
| 73 | + | |
| 74 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 75 | + | |
| 76 | + if(response->values) | |
| 77 | + g_list_free_full(response->values,(GDestroyNotify) g_variant_unref); | |
| 78 | + | |
| 79 | +} | |
| 80 | + | |
| 81 | + | |
| 82 | +static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { | |
| 83 | + | |
| 84 | + debug("%s",__FUNCTION__); | |
| 85 | + | |
| 86 | + GObjectClass *object_class; | |
| 87 | + object_class = G_OBJECT_CLASS (klass); | |
| 88 | + object_class->finalize = ipc3270Response_finalize; | |
| 89 | + | |
| 90 | +} | |
| 91 | + | |
| 92 | +static void ipc3270Response_init(ipc3270Response *object) { | |
| 93 | + | |
| 94 | + object->values = NULL; | |
| 95 | + | |
| 96 | +} | |
| 97 | + | |
| 98 | +GObject * ipc3270_response_new() { | |
| 99 | + return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); | |
| 100 | +} | |
| 101 | + | |
| 102 | +void ipc3270_response_append(GObject *object, GVariant *value) { | |
| 103 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 104 | + response->values = g_list_append(response->values,value); | |
| 105 | +} | |
| 106 | + | |
| 107 | +void ipc3270_response_append_int32(GObject *object, gint32 value) { | |
| 108 | + ipc3270_response_append(object,g_variant_new_int32(value)); | |
| 109 | +} | |
| 110 | + | |
| 111 | +void ipc3270_response_append_uint32(GObject *object, guint32 value) { | |
| 112 | + ipc3270_response_append(object,g_variant_new_uint32(value)); | |
| 113 | +} | |
| 114 | + | |
| 115 | +void ipc3270_response_append_string(GObject *object, const gchar *text) { | |
| 116 | + ipc3270_response_append(object,g_variant_new_string(text)); | |
| 117 | +} | |
| 118 | + | |
| 119 | +void ipc3270_response_append_boolean(GObject *object, gboolean value) { | |
| 120 | + ipc3270_response_append(object,g_variant_new_boolean(value)); | |
| 121 | +} | |
| 122 | + | |
| 123 | +GVariant * ipc3270_response_steal_value(GObject *object) { | |
| 124 | + | |
| 125 | + ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 126 | + | |
| 127 | + GList *first = g_list_first(response->values); | |
| 128 | + GVariant * value = first->data; | |
| 129 | + | |
| 130 | + response->values = g_list_remove(response->values,value); | |
| 131 | + | |
| 132 | + return value; | |
| 133 | +} | |
| 134 | + | |
| 135 | +const GList * ipc3270_get_values(GObject *object) { | |
| 136 | + return IPC3270_RESPONSE(object)->values; | |
| 137 | +} | |
| 138 | + | |
| 139 | +guint ipc3270_response_length(GObject *object) { | |
| 140 | + return g_list_length(IPC3270_RESPONSE(object)->values); | |
| 141 | +} | |
| 142 | + | |
| 143 | +gboolean ipc3270_response_has_values(GObject *object) { | |
| 144 | + return IPC3270_RESPONSE(object)->values != NULL; | |
| 145 | +} | ... | ... |
server/src/core/windows/inout.c
| ... | ... | @@ -59,7 +59,7 @@ unsigned char * ipc3270_pack_error(const GError *error, size_t * szPacket) { |
| 59 | 59 | txtptr += strlen((char *) txtptr) + 1; |
| 60 | 60 | |
| 61 | 61 | // Add RC |
| 62 | - *((guint16 *) txtptr) = (guint16) error->code; | |
| 62 | + *((guint16 *) txtptr) = (guint16) (error->code ? error->code : -1); | |
| 63 | 63 | txtptr += sizeof(guint16); |
| 64 | 64 | |
| 65 | 65 | // Add message |
| ... | ... | @@ -168,6 +168,40 @@ unsigned char * pack_value(unsigned char *txtptr, GVariant *value) { |
| 168 | 168 | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | +unsigned char * ipc3270_pack(const gchar *name, GObject *object, int id, size_t * szPacket) { | |
| 172 | + | |
| 173 | + const GList * node; | |
| 174 | + size_t vCount = 0; | |
| 175 | + | |
| 176 | + g_return_val_if_fail(IS_IPC3270_RESPONSE(object),NULL); | |
| 177 | + | |
| 178 | + // Set packet size. | |
| 179 | + *szPacket = | |
| 180 | + strlen(name) + 1 | |
| 181 | + + (sizeof(guint16) * 2); | |
| 182 | + | |
| 183 | + for(node = ipc3270_get_values(object); node; node = g_list_next(node)) { | |
| 184 | + vCount++; | |
| 185 | + *szPacket += g_variant_get_size(node->data)+1; | |
| 186 | + } | |
| 187 | + | |
| 188 | + unsigned char * outputBuffer = g_malloc0(*szPacket); | |
| 189 | + unsigned char * txtptr = setup_header(outputBuffer,name,id,vCount); | |
| 190 | + | |
| 191 | + for(node = ipc3270_get_values(object); node; node = g_list_next(node)) { | |
| 192 | + txtptr = pack_value(txtptr, node->data); | |
| 193 | + if(!txtptr) { | |
| 194 | + g_free(outputBuffer); | |
| 195 | + return NULL; | |
| 196 | + } | |
| 197 | + } | |
| 198 | + | |
| 199 | + debug("used=%u allocated=%u",(unsigned int) (txtptr-outputBuffer), (unsigned int) *szPacket); | |
| 200 | + return outputBuffer; | |
| 201 | + | |
| 202 | +} | |
| 203 | + | |
| 204 | +/* | |
| 171 | 205 | unsigned char * ipc3270_pack_value(const gchar *name, int id, GVariant *value, size_t * szPacket) { |
| 172 | 206 | |
| 173 | 207 | debug("%s(%s)",__FUNCTION__,name); |
| ... | ... | @@ -239,6 +273,7 @@ unsigned char * ipc3270_pack(const gchar * name, int id, GVariant *values, size_ |
| 239 | 273 | |
| 240 | 274 | return outputBuffer; |
| 241 | 275 | } |
| 276 | +*/ | |
| 242 | 277 | |
| 243 | 278 | GVariant * ipc3270_unpack(const unsigned char *packet, int *id) { |
| 244 | 279 | |
| ... | ... | @@ -387,3 +422,4 @@ GVariant * ipc3270_unpack(const unsigned char *packet, int *id) { |
| 387 | 422 | return g_variant_builder_end(&builder); |
| 388 | 423 | |
| 389 | 424 | } |
| 425 | + | ... | ... |
server/src/core/windows/pipesource.c
| ... | ... | @@ -109,7 +109,7 @@ static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) { |
| 109 | 109 | */ |
| 110 | 110 | |
| 111 | 111 | g_autoptr (GError) error = NULL; |
| 112 | - g_autoptr (GVariant) response = NULL; | |
| 112 | + g_autoptr(GObject) response = ipc3270_response_new(); | |
| 113 | 113 | g_autoptr (GVariant) parameters = ipc3270_unpack(source->buffer, &request_type); |
| 114 | 114 | |
| 115 | 115 | /* |
| ... | ... | @@ -123,30 +123,16 @@ static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) { |
| 123 | 123 | // Process query |
| 124 | 124 | switch(request_type) { |
| 125 | 125 | case 1: // getProperty |
| 126 | - response = ipc3270_get_property(source->object, request_name, &error); | |
| 126 | + ipc3270_response_append(response,ipc3270_get_property(source->object, request_name, &error)); | |
| 127 | 127 | break; |
| 128 | 128 | |
| 129 | 129 | case 2: // setProperty |
| 130 | 130 | ipc3270_set_property(source->object, request_name, parameters, &error); |
| 131 | - response = g_variant_new_int32(0); | |
| 131 | + ipc3270_response_append_int32(response,0); | |
| 132 | 132 | break; |
| 133 | 133 | |
| 134 | 134 | case 3: // method |
| 135 | - { | |
| 136 | - g_autoptr(GObject) rsp = ipc3270_response_new(); | |
| 137 | - | |
| 138 | - debug("Parameters: %p", parameters); | |
| 139 | - debug("rsp: %p", rsp); | |
| 140 | - debug("Error=%p",error); | |
| 141 | - | |
| 142 | - ipc3270_method_call(source->object, request_name, parameters, rsp, &error); | |
| 143 | - | |
| 144 | - debug("Error=%p",error); | |
| 145 | - | |
| 146 | - if(ipc3270_response_has_values(rsp)) | |
| 147 | - response = ipc3270_response_steal_value(rsp); | |
| 148 | - | |
| 149 | - } | |
| 135 | + ipc3270_method_call(source->object, request_name, parameters, response, &error); | |
| 150 | 136 | break; |
| 151 | 137 | |
| 152 | 138 | default: |
| ... | ... | @@ -177,7 +163,7 @@ static void process_input(IPC3270_PIPE_SOURCE *source, DWORD cbRead) { |
| 177 | 163 | |
| 178 | 164 | } else { |
| 179 | 165 | |
| 180 | - buffer = ipc3270_pack_value(request_name, 0, response, &szPacket); | |
| 166 | + buffer = ipc3270_pack(request_name,response,0,&szPacket); | |
| 181 | 167 | |
| 182 | 168 | } |
| 183 | 169 | ... | ... |
server/src/core/windows/response.c
| ... | ... | @@ -1,150 +0,0 @@ |
| 1 | -/* | |
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | - * | |
| 6 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | - * | |
| 8 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | - * Free Software Foundation. | |
| 11 | - * | |
| 12 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | - * obter mais detalhes. | |
| 16 | - * | |
| 17 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 19 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 | - * | |
| 21 | - * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | - * | |
| 23 | - * Referências: | |
| 24 | - * | |
| 25 | - * https://github.com/joprietoe/gdbus/blob/master/gdbus-example-server.c | |
| 26 | - * https://github.com/bratsche/glib/blob/master/gio/tests/gdbus-example-export.c | |
| 27 | - * | |
| 28 | - * Contatos: | |
| 29 | - * | |
| 30 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 31 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - | |
| 35 | -#include "gobject.h" | |
| 36 | -#include <lib3270.h> | |
| 37 | -#include <lib3270/actions.h> | |
| 38 | -#include <lib3270/properties.h> | |
| 39 | -#include <lib3270/toggle.h> | |
| 40 | -#include <lib3270/log.h> | |
| 41 | -#include <v3270.h> | |
| 42 | - | |
| 43 | -/*--[ Widget definition ]----------------------------------------------------------------------------*/ | |
| 44 | - | |
| 45 | -struct _ipc3270Response { | |
| 46 | - GObject parent; | |
| 47 | - GVariant * value; | |
| 48 | -}; | |
| 49 | - | |
| 50 | -struct _ipc3270ResponseClass { | |
| 51 | - | |
| 52 | - GObjectClass parent; | |
| 53 | - int dummy; | |
| 54 | - | |
| 55 | -}; | |
| 56 | - | |
| 57 | - | |
| 58 | -G_DEFINE_TYPE(ipc3270Response, ipc3270Response, G_TYPE_OBJECT) | |
| 59 | - | |
| 60 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 61 | - | |
| 62 | -static void ipc3270Response_finalize(GObject *object) { | |
| 63 | - | |
| 64 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 65 | - | |
| 66 | - debug("%s value=%p",__FUNCTION__,response->value); | |
| 67 | - | |
| 68 | - if(response->value) | |
| 69 | - g_variant_unref(response->value); | |
| 70 | - | |
| 71 | -} | |
| 72 | - | |
| 73 | - | |
| 74 | -static void ipc3270Response_class_init(ipc3270ResponseClass *klass) { | |
| 75 | - | |
| 76 | - debug("%s",__FUNCTION__); | |
| 77 | - | |
| 78 | - GObjectClass *object_class; | |
| 79 | - object_class = G_OBJECT_CLASS (klass); | |
| 80 | - object_class->finalize = ipc3270Response_finalize; | |
| 81 | - | |
| 82 | -} | |
| 83 | - | |
| 84 | -static void ipc3270Response_init(ipc3270Response *object) { | |
| 85 | - | |
| 86 | - object->value = NULL; | |
| 87 | - | |
| 88 | -} | |
| 89 | - | |
| 90 | -GObject * ipc3270_response_new() { | |
| 91 | - return g_object_new(GLIB_TYPE_IPC3270_RESPONSE, NULL); | |
| 92 | -} | |
| 93 | - | |
| 94 | -void ipc3270_response_append_int32(GObject *object, gint32 value) { | |
| 95 | - | |
| 96 | - debug("%s(%d)",__FUNCTION__,value); | |
| 97 | - | |
| 98 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 99 | - | |
| 100 | - if(response->value) | |
| 101 | - g_variant_unref(response->value); | |
| 102 | - | |
| 103 | - response->value = g_variant_new_int32(value); | |
| 104 | -} | |
| 105 | - | |
| 106 | -void ipc3270_response_append_uint32(GObject *object, guint32 value) { | |
| 107 | - | |
| 108 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 109 | - | |
| 110 | - if(response->value) | |
| 111 | - g_variant_unref(response->value); | |
| 112 | - | |
| 113 | - response->value = g_variant_new_uint32(value); | |
| 114 | -} | |
| 115 | - | |
| 116 | -void ipc3270_response_append_string(GObject *object, const gchar *text) { | |
| 117 | - | |
| 118 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 119 | - | |
| 120 | - if(response->value) | |
| 121 | - g_variant_unref(response->value); | |
| 122 | - | |
| 123 | - response->value = g_variant_new_string(text); | |
| 124 | - | |
| 125 | -} | |
| 126 | - | |
| 127 | -void ipc3270_response_append_boolean(GObject *object, gboolean value) { | |
| 128 | - | |
| 129 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 130 | - | |
| 131 | - if(response->value) | |
| 132 | - g_variant_unref(response->value); | |
| 133 | - | |
| 134 | - response->value = g_variant_new_boolean(value); | |
| 135 | -} | |
| 136 | - | |
| 137 | - | |
| 138 | -GVariant * ipc3270_response_steal_value(GObject *object) { | |
| 139 | - | |
| 140 | - ipc3270Response * response = IPC3270_RESPONSE(object); | |
| 141 | - | |
| 142 | - GVariant * value = response->value; | |
| 143 | - response->value = NULL; | |
| 144 | - | |
| 145 | - return value; | |
| 146 | -} | |
| 147 | - | |
| 148 | -gboolean ipc3270_response_has_values(GObject *object) { | |
| 149 | - return IPC3270_RESPONSE(object)->value != NULL; | |
| 150 | -} |
server/src/include/ipc-glib.h
| ... | ... | @@ -106,13 +106,18 @@ |
| 106 | 106 | typedef struct _ipc3270ResponseClass ipc3270ResponseClass; |
| 107 | 107 | |
| 108 | 108 | GObject * ipc3270_response_new(); |
| 109 | + GType ipc3270Response_get_type(void); | |
| 109 | 110 | |
| 111 | + void ipc3270_response_append(GObject *object, GVariant *value); | |
| 110 | 112 | void ipc3270_response_append_int32(GObject *object, gint32 value); |
| 111 | 113 | void ipc3270_response_append_uint32(GObject *object, guint32 value); |
| 112 | 114 | void ipc3270_response_append_string(GObject *object, const gchar *text); |
| 113 | 115 | void ipc3270_response_append_boolean(GObject *object, gboolean value); |
| 114 | 116 | |
| 115 | 117 | gboolean ipc3270_response_has_values(GObject *object); |
| 118 | + guint ipc3270_response_length(GObject *object); | |
| 119 | + const GList * ipc3270_get_values(GObject *object); | |
| 120 | + | |
| 116 | 121 | GVariant * ipc3270_response_steal_value(GObject *object); |
| 117 | 122 | |
| 118 | 123 | |
| ... | ... | @@ -149,9 +154,10 @@ |
| 149 | 154 | GVariant * ipc3270_get_property(GObject *object, const gchar *property_name, GError **error); |
| 150 | 155 | |
| 151 | 156 | #ifdef _WIN32 |
| 152 | - unsigned char * ipc3270_pack(const gchar *name, int id, GVariant *values, size_t * szPacket); | |
| 153 | - unsigned char * ipc3270_pack_value(const gchar *name, int id, GVariant *value, size_t * szPacket); | |
| 157 | +// unsigned char * ipc3270_pack(const gchar *name, int id, GVariant *values, size_t * szPacket); | |
| 158 | +// unsigned char * ipc3270_pack_value(const gchar *name, int id, GVariant *value, size_t * szPacket); | |
| 154 | 159 | unsigned char * ipc3270_pack_error(const GError *error, size_t * szPacket); |
| 160 | + unsigned char * ipc3270_pack(const gchar *name, GObject *object, int id, size_t * szPacket); | |
| 155 | 161 | GVariant * ipc3270_unpack(const unsigned char *packet, int *id); |
| 156 | 162 | #endif // _WIN32 |
| 157 | 163 | ... | ... |
server/src/testprogram/testprogram.c
| ... | ... | @@ -43,6 +43,7 @@ |
| 43 | 43 | #include <glib.h> |
| 44 | 44 | #include <glib/gstdio.h> |
| 45 | 45 | #include <lib3270/toggle.h> |
| 46 | + #include <lib3270/ssl.h> | |
| 46 | 47 | |
| 47 | 48 | /*---[ Globals ]------------------------------------------------------------------------------------*/ |
| 48 | 49 | |
| ... | ... | @@ -106,6 +107,9 @@ |
| 106 | 107 | GtkWidget * notebook = gtk_notebook_new(); |
| 107 | 108 | GModule * module = NULL; |
| 108 | 109 | |
| 110 | + // Hack to speed up the tests. | |
| 111 | + lib3270_ssl_set_crl_download(v3270_get_session(terminal),0); | |
| 112 | + | |
| 109 | 113 | gtk_widget_set_name(window,session_name); |
| 110 | 114 | v3270_set_session_name(terminal,session_name); |
| 111 | 115 | ... | ... |
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +#!/bin/bash | |
| 2 | +# | |
| 3 | +# https://stackoverflow.com/questions/48648952/set-get-property-using-dbus-send | |
| 4 | +# | |
| 5 | + | |
| 6 | +. ./dbus.conf | |
| 7 | + | |
| 8 | +dbus-send \ | |
| 9 | + --session \ | |
| 10 | + --dest=${DBUS_DEST} \ | |
| 11 | + --print-reply \ | |
| 12 | + "${DBUS_PATH}" \ | |
| 13 | + "${DBUS_INTERFACE}.getCursorPosition" | |
| 14 | + | ... | ... |
server/testscripts/getstring.sh
| ... | ... | @@ -3,10 +3,12 @@ |
| 3 | 3 | # https://stackoverflow.com/questions/48648952/set-get-property-using-dbus-send |
| 4 | 4 | # |
| 5 | 5 | |
| 6 | +. ./dbus.conf | |
| 7 | + | |
| 6 | 8 | dbus-send \ |
| 7 | 9 | --session \ |
| 8 | - --dest=br.com.bb.pw3270.a\ | |
| 10 | + --dest=${DBUS_DEST} \ | |
| 9 | 11 | --print-reply \ |
| 10 | - "/br/com/bb/tn3270/session" \ | |
| 11 | - "br.com.bb.tn3270.session.getString" | |
| 12 | + "${DBUS_PATH}" \ | |
| 13 | + "${DBUS_INTERFACE}.getString" | |
| 12 | 14 | ... | ... |
server/testscripts/geturl.sh
| ... | ... | @@ -12,13 +12,14 @@ |
| 12 | 12 | # string:br.com.bb.tn3270.session \ |
| 13 | 13 | # string:url |
| 14 | 14 | |
| 15 | +. ./dbus.conf | |
| 15 | 16 | |
| 16 | 17 | gdbus \ |
| 17 | 18 | call \ |
| 18 | 19 | --session \ |
| 19 | - --dest "br.com.bb.pw3270.a" \ | |
| 20 | - --object-path "/br/com/bb/tn3270/session" \ | |
| 20 | + --dest ${DBUS_DEST} \ | |
| 21 | + --object-path "${DBUS_PATH}" \ | |
| 21 | 22 | --method org.freedesktop.DBus.Properties.Get \ |
| 22 | - "br.com.bb.tn3270.session" \ | |
| 23 | + "${DBUS_INTERFACE}" \ | |
| 23 | 24 | "url" |
| 24 | 25 | ... | ... |
server/testscripts/introspect.sh
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -PRODUCT_NAME=$(pkg-config --variable=product_name lib3270) | |
| 3 | +. ./dbus.conf | |
| 4 | 4 | |
| 5 | 5 | gdbus \ |
| 6 | 6 | introspect \ |
| 7 | 7 | --session \ |
| 8 | - --dest=br.com.bb.${PRODUCT_NAME}.a \ | |
| 9 | - --object-path=/br/com/bb/${PRODUCT_NAME}/a | |
| 8 | + --dest=${DBUS_DEST} \ | |
| 9 | + --object-path="${DBUS_PATH}" | |
| 10 | 10 | ... | ... |
| ... | ... | @@ -0,0 +1,138 @@ |
| 1 | +# | |
| 2 | +# "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | +# (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | +# aplicativos mainframe. Registro no INPI sob o nome G3270. | |
| 5 | +# | |
| 6 | +# Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 7 | +# | |
| 8 | +# Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 9 | +# os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 10 | +# Free Software Foundation. | |
| 11 | +# | |
| 12 | +# Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 13 | +# GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 14 | +# A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 15 | +# obter mais detalhes. | |
| 16 | +# | |
| 17 | +# Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 18 | +# programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | |
| 19 | +# Place, Suite 330, Boston, MA, 02111-1307, USA | |
| 20 | +# | |
| 21 | +# Contatos: | |
| 22 | +# | |
| 23 | +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 24 | +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
| 25 | +# | |
| 26 | + | |
| 27 | +!include "$(PW3270_SDK_PATH)\lib3270.mak" | |
| 28 | + | |
| 29 | +OBJ_FILES= \ | |
| 30 | + client\src\core\abstract.obj \ | |
| 31 | + client\src\core\actions.obj \ | |
| 32 | + client\src\core\attribute.obj \ | |
| 33 | + client\src\core\constants.obj \ | |
| 34 | + client\src\core\events.obj \ | |
| 35 | + client\src\core\session.obj \ | |
| 36 | + client\src\core\windows\attribute.obj \ | |
| 37 | + client\src\core\windows\pop.obj \ | |
| 38 | + client\src\core\windows\push.obj \ | |
| 39 | + client\src\core\windows\request.obj \ | |
| 40 | + client\src\core\windows\tools.obj \ | |
| 41 | + client\src\host\actions.obj \ | |
| 42 | + client\src\host\init.obj \ | |
| 43 | + client\src\host\pop.obj \ | |
| 44 | + client\src\host\properties.obj \ | |
| 45 | + client\src\host\push.obj \ | |
| 46 | + client\src\host\states.obj \ | |
| 47 | + client\src\host\stream.obj \ | |
| 48 | + client\src\host\string.obj \ | |
| 49 | + client\src\session\action.obj \ | |
| 50 | + client\src\session\get.obj \ | |
| 51 | + client\src\session\set.obj \ | |
| 52 | + client\src\session\tools.obj \ | |
| 53 | + client\src\session\local\actions.obj \ | |
| 54 | + client\src\session\local\attribute.obj \ | |
| 55 | + client\src\session\local\events.obj \ | |
| 56 | + client\src\session\local\get.obj \ | |
| 57 | + client\src\session\local\init.obj \ | |
| 58 | + client\src\session\local\set.obj \ | |
| 59 | + client\src\session\local\wait.obj \ | |
| 60 | + client\src\session\remote\actions.obj \ | |
| 61 | + client\src\session\remote\attribute.obj \ | |
| 62 | + client\src\session\remote\get.obj \ | |
| 63 | + client\src\session\remote\properties.obj \ | |
| 64 | + client\src\session\remote\set.obj \ | |
| 65 | + client\src\session\remote\tools.obj \ | |
| 66 | + client\src\session\remote\wait.obj \ | |
| 67 | + client\src\session\remote\windows\request.obj \ | |
| 68 | + client\src\session\remote\windows\session.obj | |
| 69 | + | |
| 70 | +.cc.obj: | |
| 71 | + @echo Compiling... | |
| 72 | + @$(CPP) \ | |
| 73 | + /c \ | |
| 74 | + /DPACKAGE_NAME=\"ipc3270\" \ | |
| 75 | + /DPRODUCT_NAME=$(PRODUCT_NAME) \ | |
| 76 | + /DLIB3270_NAME=$(LIB3270_NAME) \ | |
| 77 | + /DDEBUG=1 \ | |
| 78 | + /I".\client\src\include" \ | |
| 79 | + /I"$(PW3270_SDK_PATH)\include" \ | |
| 80 | + /EHsc \ | |
| 81 | + /Fo"$@" \ | |
| 82 | + $< | |
| 83 | + | |
| 84 | +testprogram.exe: \ | |
| 85 | + client\src\testprogram\testprogram.obj \ | |
| 86 | + ipc3270.dll | |
| 87 | + | |
| 88 | + @echo Build exe file.... | |
| 89 | + @link \ | |
| 90 | + /nologo \ | |
| 91 | + /OUT:"$@" \ | |
| 92 | + client\src\testprogram\testprogram.obj | |
| 93 | + | |
| 94 | +install: \ | |
| 95 | + $(OBJ_FILES) \ | |
| 96 | + ipc3270.dll | |
| 97 | + @echo Building library... | |
| 98 | + @-mkdir "$(PW3270_SDK_PATH)\lib" | |
| 99 | + @lib \ | |
| 100 | + /NOLOGO \ | |
| 101 | + /OUT:"$(PW3270_SDK_PATH)\lib\ipc3270.lib" \ | |
| 102 | + $(OBJ_FILES) | |
| 103 | + | |
| 104 | + @copy "ipc3270.dll" "$(PW3270_SDK_PATH)\..\ipc3270.dll" | |
| 105 | + @copy "ipc3270.dll.lib" "$(PW3270_SDK_PATH)\lib\ipc3270.dll.lib" | |
| 106 | + | |
| 107 | + @-mkdir "$(PW3270_SDK_PATH)\include\lib3270\ipc" | |
| 108 | + @copy "client\src\include\lib3270\ipc\*.h" "$(PW3270_SDK_PATH)\include\lib3270\ipc" | |
| 109 | + @copy "client\src\include\lib3270\*.h" "$(PW3270_SDK_PATH)\include\lib3270" | |
| 110 | + | |
| 111 | +ipc3270.dll: \ | |
| 112 | + $(OBJ_FILES) \ | |
| 113 | + client\src\core\windows\dynamic\init.obj \ | |
| 114 | + $(LIB3270_NAME).lib | |
| 115 | + @echo Build dll file.... | |
| 116 | + link \ | |
| 117 | + /NOLOGO \ | |
| 118 | + /DLL \ | |
| 119 | + /OUT:"$@" \ | |
| 120 | + /IMPLIB:ipc3270.dll.lib \ | |
| 121 | + $(OBJ_FILES) \ | |
| 122 | + client\src\core\windows\dynamic\init.obj \ | |
| 123 | + /DELAYLOAD:$(LIB3270_NAME).dll | |
| 124 | + | |
| 125 | +$(LIB3270_NAME).lib: | |
| 126 | + lib \ | |
| 127 | + /def:"$(PW3270_SDK_PATH)\def\$(LIB3270_NAME).def" \ | |
| 128 | + /out:$(LIB3270_NAME).lib | |
| 129 | + | |
| 130 | +clean: | |
| 131 | + del \ | |
| 132 | + $(LIB3270_NAME).lib \ | |
| 133 | + $(LIB3270_NAME).dll \ | |
| 134 | + *.lib \ | |
| 135 | + *.dll \ | |
| 136 | + $(OBJ_FILES) \ | |
| 137 | + client\src\core\windows\dynamic\init.obj \ | |
| 138 | + testprogram.* | ... | ... |
win/Makefile.msc
| ... | ... | @@ -84,6 +84,7 @@ OBJ_FILES= \ |
| 84 | 84 | testprogram.exe: \ |
| 85 | 85 | client\src\testprogram\testprogram.obj \ |
| 86 | 86 | ipc3270.dll |
| 87 | + | |
| 87 | 88 | @echo Build exe file.... |
| 88 | 89 | @link \ |
| 89 | 90 | /nologo \ |
| ... | ... | @@ -91,45 +92,50 @@ testprogram.exe: \ |
| 91 | 92 | client\src\testprogram\testprogram.obj |
| 92 | 93 | |
| 93 | 94 | install: \ |
| 94 | - $(OBJ_FILES) \ | |
| 95 | + ipc3270.dll \ | |
| 96 | + ipc3270.lib \ | |
| 95 | 97 | $(LIB3270_NAME).lib |
| 96 | 98 | @echo Building library... |
| 97 | 99 | @-mkdir "$(PW3270_SDK_PATH)\lib" |
| 100 | + copy "$(LIB3270_NAME).lib" "$(PW3270_SDK_PATH)\lib\$(LIB3270_NAME).lib" | |
| 101 | + copy "ipc3270.lib" "$(PW3270_SDK_PATH)\lib\ipc3270.lib" | |
| 102 | + copy "ipc3270.dll" "$(PW3270_SDK_PATH)\..\ipc3270.dll" | |
| 103 | + copy "ipc3270.dll.lib" "$(PW3270_SDK_PATH)\lib\ipc3270.dll.lib" | |
| 104 | + @-mkdir "$(PW3270_SDK_PATH)\include\lib3270\ipc" | |
| 105 | + copy "client\src\include\lib3270\ipc\*.h" "$(PW3270_SDK_PATH)\include\lib3270\ipc" | |
| 106 | + copy "client\src\include\lib3270\*.h" "$(PW3270_SDK_PATH)\include\lib3270" | |
| 107 | + | |
| 108 | +ipc3270.lib: \ | |
| 109 | + $(OBJ_FILES) | |
| 110 | + @echo Build dll file.... | |
| 98 | 111 | @lib \ |
| 99 | 112 | /NOLOGO \ |
| 100 | - /OUT:"$(PW3270_SDK_PATH)\lib\ipc3270.lib" \ | |
| 113 | + /OUT:"ipc3270.lib" \ | |
| 101 | 114 | $(OBJ_FILES) |
| 102 | 115 | |
| 103 | - | |
| 104 | - @copy "$(LIB3270_NAME).lib" "$(PW3270_SDK_PATH)\lib\$(LIB3270_NAME).lib" | |
| 105 | - @-mkdir "$(PW3270_SDK_PATH)\include\lib3270\ipc" | |
| 106 | - @copy "client\src\include\lib3270\ipc\*.h" "$(PW3270_SDK_PATH)\include\lib3270\ipc" | |
| 107 | - @copy "client\src\include\lib3270\*.h" "$(PW3270_SDK_PATH)\include\lib3270" | |
| 108 | - | |
| 109 | 116 | ipc3270.dll: \ |
| 110 | 117 | $(OBJ_FILES) \ |
| 111 | 118 | client\src\core\windows\dynamic\init.obj \ |
| 112 | 119 | $(LIB3270_NAME).lib |
| 113 | 120 | @echo Build dll file.... |
| 114 | - link \ | |
| 121 | + @link \ | |
| 115 | 122 | /NOLOGO \ |
| 116 | 123 | /DLL \ |
| 117 | 124 | /OUT:"$@" \ |
| 125 | + /IMPLIB:ipc3270.dll.lib \ | |
| 118 | 126 | $(OBJ_FILES) \ |
| 119 | 127 | client\src\core\windows\dynamic\init.obj \ |
| 120 | 128 | /DELAYLOAD:$(LIB3270_NAME).dll |
| 121 | 129 | |
| 122 | 130 | $(LIB3270_NAME).lib: |
| 123 | - lib \ | |
| 131 | + @lib \ | |
| 124 | 132 | /def:"$(PW3270_SDK_PATH)\def\$(LIB3270_NAME).def" \ |
| 125 | 133 | /out:$(LIB3270_NAME).lib |
| 126 | 134 | |
| 127 | 135 | clean: |
| 128 | 136 | del \ |
| 129 | - $(LIB3270_NAME).lib \ | |
| 130 | - $(LIB3270_NAME).dll \ | |
| 131 | - ipc3270.lib \ | |
| 132 | - ipc3270.dll \ | |
| 137 | + *.lib \ | |
| 138 | + *.dll \ | |
| 133 | 139 | $(OBJ_FILES) \ |
| 134 | 140 | client\src\core\windows\dynamic\init.obj \ |
| 135 | 141 | testprogram.* | ... | ... |