Commit 8053c4050dbdf1a0c30b13e95c2956ae6262a3a2
1 parent
c1abe605
Exists in
master
and in
1 other branch
Improving hllapi test module.
Showing
2 changed files
with
51 additions
and
48 deletions
Show diff stats
src/testprograms/hllapi.c
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | #include <stdio.h> |
31 | 31 | #include <string.h> |
32 | 32 | #include <time.h> |
33 | + #include <getopt.h> | |
33 | 34 | #include <pw3270/hllapi.h> |
34 | 35 | |
35 | 36 | #if defined(DEBUG) && defined(_WIN32) |
... | ... | @@ -39,10 +40,11 @@ |
39 | 40 | |
40 | 41 | #define MAX_DATA_SIZE 8000 //< Maximum data size for this application. |
41 | 42 | |
42 | - static CHAR hllapi_data[MAX_DATA_SIZE]; | |
43 | +// static CHAR hllapi_data[MAX_DATA_SIZE]; | |
43 | 44 | |
44 | 45 | /*---[ Implement ]--------------------------------------------------------------------------------*/ |
45 | 46 | |
47 | + /* | |
46 | 48 | static void connect_ps(const char *session) |
47 | 49 | { |
48 | 50 | WORD len; |
... | ... | @@ -54,51 +56,65 @@ |
54 | 56 | len = strlen(session); |
55 | 57 | hllapi(&fn,hllapi_data,&len,&rc); |
56 | 58 | |
57 | - /* | |
58 | - if(rc) | |
59 | - { | |
60 | - trace("HLLAPI_CMD_CONNECTPS(%s) exits with rc=%d", session, (int) rc); | |
61 | - } | |
62 | - */ | |
63 | - | |
64 | 59 | } |
60 | + */ | |
65 | 61 | |
66 | - int main(int numpar, char *param[]) | |
62 | + int main(int argc, char **argv) | |
67 | 63 | { |
64 | + const char *host = NULL; | |
68 | 65 | const char *session = "pw3270:A"; |
69 | 66 | |
70 | - connect_ps(session); | |
71 | - | |
72 | - /* | |
67 | + #pragma GCC diagnostic push | |
68 | + static struct option options[] = | |
69 | + { | |
70 | + { "host", required_argument, 0, 'h' }, | |
71 | + { "session-name", required_argument, 0, 'S' }, | |
72 | + { 0, 0, 0, 0} | |
73 | + }; | |
74 | + #pragma GCC diagnostic pop | |
73 | 75 | |
74 | - printf("init(%s)=%d\n",session,(int) hllapi_init((LPSTR) session)); | |
75 | - printf("revision=%d\n",(int) hllapi_get_revision()); | |
76 | - printf("connect=%d\n",(int) hllapi_connect((char *) "fandezhi.efglobe.com:23",1)); | |
77 | - printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10)); | |
78 | - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No"); | |
76 | + int long_index =0; | |
77 | + int opt; | |
78 | + while((opt = getopt_long(argc, argv, "h:S:", options, &long_index )) != -1) | |
79 | + { | |
79 | 80 | |
80 | -// printf("disconnect=%d\n",(int) hllapi_disconnect()); | |
81 | + switch(opt) | |
82 | + { | |
83 | + case 'h': | |
84 | + host = optarg; | |
85 | + break; | |
81 | 86 | |
87 | + case 'S': | |
88 | + session = optarg; | |
89 | + break; | |
82 | 90 | |
83 | - printf("deinit=%d\n",(int) hllapi_deinit()); | |
91 | + } | |
84 | 92 | |
85 | - DWORD revision; | |
86 | - int rc; | |
93 | + } | |
87 | 94 | |
88 | - rc = hllapi_init(""); | |
95 | + int rc = hllapi_init((char *) session); | |
89 | 96 | if(rc) |
90 | 97 | { |
91 | - printf("Init exits with rc=%d\n",rc); | |
98 | + printf("hllapi_init returns with rc=%d\n",rc); | |
92 | 99 | return rc; |
93 | 100 | } |
94 | 101 | |
95 | - if(!hllapi_get_revision(&revision)) | |
96 | - printf("Library revision is %d\n",(int) revision); | |
102 | + printf("Library revision is %d\n",(int) hllapi_get_revision()); | |
103 | + | |
104 | + if(host) { | |
97 | 105 | |
106 | + printf("connect=%d\n",(int) hllapi_connect((char *) host,1)); | |
107 | + printf("wait_for_ready=%d\n",(int) hllapi_wait_for_ready(10)); | |
108 | + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No"); | |
109 | + | |
110 | + printf("disconnect=%d\n",(int) hllapi_disconnect()); | |
111 | + } | |
112 | + | |
113 | + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No"); | |
98 | 114 | |
99 | - printf("Deinit exits with rc=%d\n",rc); | |
100 | 115 | rc = hllapi_deinit(); |
101 | -*/ | |
116 | + printf("hllapi_deinit exits with rc=%d\n",rc); | |
117 | + | |
102 | 118 | return 0; |
103 | 119 | } |
104 | 120 | ... | ... |
src/testprograms/ipc3270c.c
... | ... | @@ -209,33 +209,20 @@ |
209 | 209 | |
210 | 210 | int main (int argc, char **argv) { |
211 | 211 | |
212 | - /* | |
213 | - GVariantBuilder builder; | |
212 | + static const GOptionEntry app_options[] = { | |
213 | + { "plugin-path", 'P', 0, G_OPTION_ARG_STRING, &plugin_path, "Path for plugin search", NULL }, | |
214 | + { "install", 'S', 0, G_OPTION_ARG_STRING, &session_name, "Session name", "pw3270" }, | |
215 | + { "module", 'm', 0, G_OPTION_ARG_STRING, &plugin_name, "Module name", "ipc3270c." G_MODULE_SUFFIX }, | |
214 | 216 | |
215 | - g_variant_builder_init(&builder,G_VARIANT_TYPE("(isi)")); | |
216 | - | |
217 | - g_variant_builder_add(&builder, "i", 10); | |
218 | - g_variant_builder_add(&builder, "s", "teste"); | |
219 | - g_variant_builder_add(&builder, "i", 20); | |
220 | - | |
221 | - GVariant *value = g_variant_builder_end(&builder); | |
222 | - | |
223 | - size_t szPacket = 0; | |
224 | - g_autofree unsigned char * buffer = ipc3270_pack("teste", value, &szPacket); | |
225 | - g_variant_unref(value); | |
226 | - | |
227 | - debug("Package \"%s\" was created with %u bytes", buffer, (unsigned int) szPacket); | |
228 | - | |
229 | - value = ipc3270_unpack(buffer); | |
230 | - | |
231 | - g_variant_unref(value); | |
232 | - */ | |
217 | + { NULL } | |
218 | + }; | |
233 | 219 | |
234 | 220 | GtkApplication *app; |
235 | 221 | int status; |
236 | 222 | |
237 | - app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
223 | + app = gtk_application_new("br.com.bb.ipc3270c",G_APPLICATION_FLAGS_NONE); | |
238 | 224 | |
225 | + g_application_add_main_option_entries(G_APPLICATION(app),app_options); | |
239 | 226 | g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); |
240 | 227 | |
241 | 228 | status = g_application_run (G_APPLICATION (app), argc, argv); | ... | ... |