Commit e1d7adf3580ad4297d1d30f220b6ccde84f3a64b

Authored by perry.werneck@gmail.com
1 parent 00e98f6e

Como o antigo plugin remotectl foi totalmente remodelado para suportar hllapi na…

…da mais lógico que mudar o nome para hllapi
Makefile.in
... ... @@ -326,7 +326,7 @@ clean:
326 326 @make -C src/lib3270 clean
327 327 @make -C src/pw3270 clean
328 328 @make -C src/tools clean
329   - @make -C src/plugins/remotectl clean
  329 + @make -C src/plugins/hllapi clean
330 330 @make -C src/plugins/rx3270 clean
331 331 @make -C src/plugins/dbus3270 clean
332 332 @make -C src/oxt clean
... ... @@ -356,10 +356,10 @@ distclean: clean
356 356  
357 357 #---[ Plugins ]----------------------------------------------------------------
358 358  
359   -$(BINDIR)/Debug/plugins/remotectl@DLLEXT@: src/plugins/remotectl/* $(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT)
  359 +$(BINDIR)/Debug/plugins/hllapi@DLLEXT@: src/plugins/hllapi/* $(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT)
360 360 @make $(PLUGIN_DEBUG_ARGS) -C $(dir $<) Debug
361 361  
362   -$(BINDIR)/Release/plugins/remotectl@DLLEXT@: src/plugins/remotectl/* $(BINDIR)/Release/$(PACKAGE_TARNAME)$(EXEEXT)
  362 +$(BINDIR)/Release/plugins/hllapi@DLLEXT@: src/plugins/hllapi/* $(BINDIR)/Release/$(PACKAGE_TARNAME)$(EXEEXT)
363 363 @make $(PLUGIN_RELEASE_ARGS) -C $(dir $<) Release
364 364  
365 365 $(BINDIR)/Debug/plugins/rx3270@DLLEXT@: src/plugins/rx3270/* $(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT)
... ...
configure.ac
... ... @@ -128,7 +128,7 @@ case &quot;$host&quot; in
128 128 DLLDIR=""
129 129 DBGCMDPREFIX=""
130 130 LDARCH=""
131   - PLUGINS="remotectl"
  131 + PLUGINS="hllapi"
132 132 APP_GUI_SRC="resources.rc"
133 133 ;;
134 134  
... ... @@ -433,7 +433,7 @@ AC_CONFIG_FILES([
433 433 src/oxt/Makefile
434 434 src/pw3270/uiparser/Makefile
435 435 src/tools/Makefile
436   - src/plugins/remotectl/Makefile
  436 + src/plugins/hllapi/Makefile
437 437 src/plugins/rx3270/Makefile
438 438 src/plugins/dbus3270/Makefile
439 439 man/Makefile
... ...
po/pt_BR.po
... ... @@ -5,7 +5,7 @@ msgid &quot;&quot;
5 5 msgstr ""
6 6 "Project-Id-Version: pw3270 5.0\n"
7 7 "Report-Msgid-Bugs-To: \n"
8   -"POT-Creation-Date: 2013-03-04 18:26-0300\n"
  8 +"POT-Creation-Date: 2013-03-06 09:33-0300\n"
9 9 "PO-Revision-Date: 2013-02-25 14:46-0300\n"
10 10 "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n"
11 11 "Language-Team: Português <>\n"
... ... @@ -91,11 +91,11 @@ msgstr &quot;- Emulador 3270 para GTK&quot;
91 91 msgid "16 colors"
92 92 msgstr "16 cores"
93 93  
94   -#: screen.c:653 screen.c:683 screen.c:697 screen.c:816
  94 +#: screen.c:655 screen.c:685 screen.c:699 screen.c:818
95 95 msgid "3270 Error"
96 96 msgstr "Erro 3270"
97 97  
98   -#: screen.c:668
  98 +#: screen.c:670
99 99 msgid "3270 Warning"
100 100 msgstr "Alerta 3270"
101 101  
... ... @@ -200,7 +200,7 @@ msgstr &quot;Sobre a segurança&quot;
200 200 msgid "Action failed"
201 201 msgstr "Ação falhou"
202 202  
203   -#: ui/00default.xml:64
  203 +#: ui/00default.xml:286
204 204 msgid "Add to copy"
205 205 msgstr "Adicionar à cópia"
206 206  
... ... @@ -208,7 +208,7 @@ msgstr &quot;Adicionar à cópia&quot;
208 208 msgid "Add/Remove _CR at end of line"
209 209 msgstr "Adicionar/Remover _CR no final da linha"
210 210  
211   -#: ui/00default.xml:132
  211 +#: ui/00default.xml:354
212 212 msgid "Alert sound"
213 213 msgstr "Aviso sonoro"
214 214  
... ... @@ -221,7 +221,7 @@ msgstr &quot;&quot;
221 221 msgid "Application name"
222 222 msgstr "Nome da aplicação"
223 223  
224   -#: ui/10keypad.xml:467
  224 +#: ui/10keypad.xml:155
225 225 msgid "Attn"
226 226 msgstr "Attn"
227 227  
... ... @@ -238,7 +238,7 @@ msgstr &quot;Authority and issuer serial number mismatch&quot;
238 238 msgid "Authority and subject key identifier mismatch"
239 239 msgstr "Authority and subject key identifier mismatch"
240 240  
241   -#: ui/00default.xml:127
  241 +#: ui/00default.xml:349
242 242 msgid "Auto-Reconnect"
243 243 msgstr "Reconectar automaticamente"
244 244  
... ... @@ -262,11 +262,11 @@ msgstr &quot;Versão winsock inválida&quot;
262 262 msgid "Black"
263 263 msgstr "Preto"
264 264  
265   -#: ui/00default.xml:125
  265 +#: ui/00default.xml:347
266 266 msgid "Blank Fill"
267 267 msgstr "Completar com espaços"
268 268  
269   -#: ui/00default.xml:118
  269 +#: ui/00default.xml:340
270 270 msgid "Blinking Cursor"
271 271 msgstr "Cursor piscante"
272 272  
... ... @@ -274,7 +274,7 @@ msgstr &quot;Cursor piscante&quot;
274 274 msgid "Blue"
275 275 msgstr "Azul"
276 276  
277   -#: ui/00default.xml:128
  277 +#: ui/00default.xml:350
278 278 msgid "Bold"
279 279 msgstr "Negrito"
280 280  
... ... @@ -282,7 +282,7 @@ msgstr &quot;Negrito&quot;
282 282 msgid "Brazilian Public Software Portal"
283 283 msgstr "Portal do Software Público Brasileiro"
284 284  
285   -#: ui/10keypad.xml:468
  285 +#: ui/10keypad.xml:156
286 286 msgid "Break"
287 287 msgstr "Break"
288 288  
... ... @@ -474,7 +474,7 @@ msgstr &quot;Tabela de tradução tem %d entradas, precisa de 256&quot;
474 474 msgid "Charset has more than 256 entries"
475 475 msgstr "Tabela de tradução tem mais de 256 caracteres"
476 476  
477   -#: ui/00default.xml:79
  477 +#: ui/10keypad.xml:147
478 478 msgid "Clear"
479 479 msgstr "Limpar"
480 480  
... ... @@ -486,7 +486,7 @@ msgstr &quot;Tema de cores:&quot;
486 486 msgid "Color setup"
487 487 msgstr "Configuração de cores"
488 488  
489   -#: ui/00default.xml:107
  489 +#: ui/00default.xml:329
490 490 msgid "Colors"
491 491 msgstr "Cores"
492 492  
... ... @@ -494,7 +494,7 @@ msgstr &quot;Cores&quot;
494 494 msgid "Complete"
495 495 msgstr "Completo"
496 496  
497   -#: ui/00default.xml:117
  497 +#: ui/00default.xml:339
498 498 msgid "Connect on startup"
499 499 msgstr "Conectar ao iniciar"
500 500  
... ... @@ -502,19 +502,19 @@ msgstr &quot;Conectar ao iniciar&quot;
502 502 msgid "Connection reset by peer"
503 503 msgstr "Conexão foi cancelada pelo servidor"
504 504  
505   -#: ui/00default.xml:61
  505 +#: ui/00default.xml:283
506 506 msgid "Copy"
507 507 msgstr "Copiar"
508 508  
509   -#: ui/99debug.xml:566
  509 +#: ui/99debug.xml:200
510 510 msgid "Copy as HTML"
511 511 msgstr "Copiar como HTML"
512 512  
513   -#: ui/00default.xml:62
  513 +#: ui/00default.xml:284
514 514 msgid "Copy as table"
515 515 msgstr "Copiar como tabela"
516 516  
517   -#: colors.c:418 ui/00default.xml:124
  517 +#: colors.c:418 ui/00default.xml:346
518 518 msgid "Cross hair cursor"
519 519 msgstr "Cursor mira"
520 520  
... ... @@ -527,7 +527,7 @@ msgstr &quot;Atual (%s)&quot;
527 527 msgid "Custom colors"
528 528 msgstr "Cores personalizadas"
529 529  
530   -#: ui/00default.xml:65
  530 +#: ui/00default.xml:287
531 531 msgid "Cut"
532 532 msgstr "Recortar"
533 533  
... ... @@ -539,7 +539,7 @@ msgstr &quot;Cilindros&quot;
539 539 msgid "DFT B_uffer size:"
540 540 msgstr "Tamanho do b_uffer DFT:"
541 541  
542   -#: ui/99debug.xml:571
  542 +#: ui/99debug.xml:205
543 543 msgid "DS Trace"
544 544 msgstr "DS Trace"
545 545  
... ... @@ -555,11 +555,11 @@ msgstr &quot;Verde Escuro&quot;
555 555 msgid "Data conversion error"
556 556 msgstr "Erro na conversão de dados"
557 557  
558   -#: ui/99debug.xml:579
  558 +#: ui/99debug.xml:213
559 559 msgid "Debug"
560 560 msgstr "Depuração"
561 561  
562   -#: ui/99debug.xml:581
  562 +#: ui/99debug.xml:215
563 563 msgid "Debug window updates"
564 564 msgstr "Mostrar atualizações de janela"
565 565  
... ... @@ -567,7 +567,7 @@ msgstr &quot;Mostrar atualizações de janela&quot;
567 567 msgid "Default"
568 568 msgstr "Padrão"
569 569  
570   -#: ui/00default.xml:81
  570 +#: ui/00default.xml:303
571 571 msgid "Delete field"
572 572 msgstr "Apagar campo"
573 573  
... ... @@ -599,7 +599,7 @@ msgstr &quot;Nome do servidor em branco&quot;
599 599 msgid "Empty port name"
600 600 msgstr "Porta em branco"
601 601  
602   -#: ui/10keypad.xml:463
  602 +#: ui/10keypad.xml:151
603 603 msgid ""
604 604 "Erase\n"
605 605 "EOF"
... ... @@ -607,7 +607,7 @@ msgstr &quot;&quot;
607 607 "Apagar\n"
608 608 "Campo"
609 609  
610   -#: ui/10keypad.xml:464
  610 +#: ui/10keypad.xml:152
611 611 msgid ""
612 612 "Erase\n"
613 613 "Input"
... ... @@ -615,15 +615,15 @@ msgstr &quot;&quot;
615 615 "Apagar\n"
616 616 "Campos"
617 617  
618   -#: ui/00default.xml:80
  618 +#: ui/00default.xml:302
619 619 msgid "Erase input"
620 620 msgstr "Apagar campos"
621 621  
622   -#: ui/00default.xml:82
  622 +#: ui/00default.xml:304
623 623 msgid "Erase to end of field"
624 624 msgstr "Apagar até o final do campo"
625 625  
626   -#: ui/00default.xml:83
  626 +#: ui/00default.xml:305
627 627 msgid "Erase to end of line"
628 628 msgstr "Apagar até o final da linha"
629 629  
... ... @@ -666,7 +666,7 @@ msgstr &quot;Erro lendo %s&quot;
666 666 msgid "Error resolving %s: %s"
667 667 msgstr "Erro ao resolver %s: %s"
668 668  
669   -#: ui/99debug.xml:573
  669 +#: ui/99debug.xml:207
670 670 msgid "Event Trace"
671 671 msgstr "Trace de eventos"
672 672  
... ... @@ -714,11 +714,11 @@ msgstr &quot;Format error in certificate&#39;s notAfter field&quot;
714 714 msgid "Format error in certificate's notBefore field"
715 715 msgstr "Format error in certificate's notBefore field"
716 716  
717   -#: ui/00default.xml:121
  717 +#: ui/00default.xml:343
718 718 msgid "Full Screen"
719 719 msgstr "Tela cheia"
720 720  
721   -#: ui/10functions.xml:347
  721 +#: ui/10functions.xml:35
722 722 msgid "Function bar"
723 723 msgstr "Barra de funções"
724 724  
... ... @@ -763,7 +763,7 @@ msgstr &quot;HTTP Proxy: EOF inesperado&quot;
763 763 msgid "HTTP Proxy: unrecognized reply"
764 764 msgstr "HTTP Proxy: Resposta desconhecida"
765 765  
766   -#: ui/00default.xml:142
  766 +#: ui/00default.xml:364
767 767 msgid "Help"
768 768 msgstr "Ajuda"
769 769  
... ... @@ -824,7 +824,7 @@ msgstr &quot;Comprimento de frame inválido&quot;
824 824 msgid "Informations"
825 825 msgstr "Informações"
826 826  
827   -#: ui/00default.xml:137
  827 +#: ui/00default.xml:359
828 828 msgid "Input method"
829 829 msgstr "Método de entrada"
830 830  
... ... @@ -871,7 +871,7 @@ msgstr &quot;Sintaxe de proxy inválida&quot;
871 871 msgid "Invalid proxy type '%.*s'"
872 872 msgstr "Tipo de proxy invalido '%.*s'"
873 873  
874   -#: ui/00default.xml:130
  874 +#: ui/00default.xml:352
875 875 msgid "Keep selected"
876 876 msgstr "Manter selecionado"
877 877  
... ... @@ -887,7 +887,7 @@ msgstr &quot;Teclado está bloqueado&quot;
887 887 msgid "LRECL:"
888 888 msgstr "LRECL:"
889 889  
890   -#: ui/10keypad.xml:413
  890 +#: ui/10keypad.xml:101
891 891 msgid "Lateral keypad"
892 892 msgstr "Barra lateral"
893 893  
... ... @@ -904,7 +904,7 @@ msgstr &quot;Faltando &#39;]&#39;&quot;
904 904 msgid "Model %d (%s)"
905 905 msgstr "Modelo %d (%s)"
906 906  
907   -#: ui/00default.xml:119
  907 +#: ui/00default.xml:341
908 908 msgid "Monocase"
909 909 msgstr "Só Maiúsculas"
910 910  
... ... @@ -940,7 +940,7 @@ msgstr &quot;Erro de rede&quot;
940 940 msgid "Network startup error"
941 941 msgstr "Erro ao iniciar a rede"
942 942  
943   -#: ui/00default.xml:189
  943 +#: ui/00default.xml:411
944 944 msgid "Next field"
945 945 msgstr "Próximo campo"
946 946  
... ... @@ -1017,111 +1017,111 @@ msgstr &quot;Other (VM/CMS)&quot;
1017 1017 msgid "Out of memory"
1018 1018 msgstr "Out of memory"
1019 1019  
1020   -#: ui/10keypad.xml:450
  1020 +#: ui/10keypad.xml:138
1021 1021 msgid "PA1"
1022 1022 msgstr "PA1"
1023 1023  
1024   -#: ui/10keypad.xml:451
  1024 +#: ui/10keypad.xml:139
1025 1025 msgid "PA2"
1026 1026 msgstr "PA2"
1027 1027  
1028   -#: ui/10keypad.xml:452
  1028 +#: ui/10keypad.xml:140
1029 1029 msgid "PA3"
1030 1030 msgstr "PA3"
1031 1031  
1032   -#: ui/10functions.xml:348
  1032 +#: ui/10functions.xml:36
1033 1033 msgid "PF1"
1034 1034 msgstr "PF1"
1035 1035  
1036   -#: ui/10functions.xml:357
  1036 +#: ui/10functions.xml:45
1037 1037 msgid "PF10"
1038 1038 msgstr "PF10"
1039 1039  
1040   -#: ui/10functions.xml:358
  1040 +#: ui/10functions.xml:46
1041 1041 msgid "PF11"
1042 1042 msgstr "PF11"
1043 1043  
1044   -#: ui/10functions.xml:359
  1044 +#: ui/10functions.xml:47
1045 1045 msgid "PF12"
1046 1046 msgstr "PF12"
1047 1047  
1048   -#: ui/10functions.xml:362
  1048 +#: ui/10functions.xml:50
1049 1049 msgid "PF13"
1050 1050 msgstr "PF13"
1051 1051  
1052   -#: ui/10functions.xml:363
  1052 +#: ui/10functions.xml:51
1053 1053 msgid "PF14"
1054 1054 msgstr "PF14"
1055 1055  
1056   -#: ui/10functions.xml:364
  1056 +#: ui/10functions.xml:52
1057 1057 msgid "PF15"
1058 1058 msgstr "PF15"
1059 1059  
1060   -#: ui/10functions.xml:365
  1060 +#: ui/10functions.xml:53
1061 1061 msgid "PF16"
1062 1062 msgstr "PF16"
1063 1063  
1064   -#: ui/10functions.xml:366
  1064 +#: ui/10functions.xml:54
1065 1065 msgid "PF17"
1066 1066 msgstr "PF17"
1067 1067  
1068   -#: ui/10functions.xml:367
  1068 +#: ui/10functions.xml:55
1069 1069 msgid "PF18"
1070 1070 msgstr "PF18"
1071 1071  
1072   -#: ui/10functions.xml:368
  1072 +#: ui/10functions.xml:56
1073 1073 msgid "PF19"
1074 1074 msgstr "PF19"
1075 1075  
1076   -#: ui/10functions.xml:349
  1076 +#: ui/10functions.xml:37
1077 1077 msgid "PF2"
1078 1078 msgstr "PF2"
1079 1079  
1080   -#: ui/10functions.xml:369
  1080 +#: ui/10functions.xml:57
1081 1081 msgid "PF20"
1082 1082 msgstr "PF20"
1083 1083  
1084   -#: ui/10functions.xml:370
  1084 +#: ui/10functions.xml:58
1085 1085 msgid "PF21"
1086 1086 msgstr "PF21"
1087 1087  
1088   -#: ui/10functions.xml:371
  1088 +#: ui/10functions.xml:59
1089 1089 msgid "PF22"
1090 1090 msgstr "PF22"
1091 1091  
1092   -#: ui/10functions.xml:372
  1092 +#: ui/10functions.xml:60
1093 1093 msgid "PF23"
1094 1094 msgstr "PF23"
1095 1095  
1096   -#: ui/10functions.xml:373
  1096 +#: ui/10functions.xml:61
1097 1097 msgid "PF24"
1098 1098 msgstr "PF24"
1099 1099  
1100   -#: ui/10functions.xml:350
  1100 +#: ui/10functions.xml:38
1101 1101 msgid "PF3"
1102 1102 msgstr "PF3"
1103 1103  
1104   -#: ui/10functions.xml:351
  1104 +#: ui/10functions.xml:39
1105 1105 msgid "PF4"
1106 1106 msgstr "PF4"
1107 1107  
1108   -#: ui/10functions.xml:352
  1108 +#: ui/10functions.xml:40
1109 1109 msgid "PF5"
1110 1110 msgstr "PF5"
1111 1111  
1112   -#: ui/10functions.xml:353
  1112 +#: ui/10functions.xml:41
1113 1113 msgid "PF6"
1114 1114 msgstr "PF6"
1115 1115  
1116   -#: ui/10functions.xml:354
  1116 +#: ui/10functions.xml:42
1117 1117 msgid "PF7"
1118 1118 msgstr "PF7"
1119 1119  
1120   -#: ui/10functions.xml:355
  1120 +#: ui/10functions.xml:43
1121 1121 msgid "PF8"
1122 1122 msgstr "PF8"
1123 1123  
1124   -#: ui/10functions.xml:356
  1124 +#: ui/10functions.xml:44
1125 1125 msgid "PF9"
1126 1126 msgstr "PF9"
1127 1127  
... ... @@ -1138,15 +1138,15 @@ msgstr &quot;Erro de interpretação em %s&quot;
1138 1138 msgid "Passthru Proxy: send error"
1139 1139 msgstr "Passthru Proxy: Erro ao enviar"
1140 1140  
1141   -#: ui/00default.xml:66
  1141 +#: ui/00default.xml:288
1142 1142 msgid "Paste"
1143 1143 msgstr "Colar"
1144 1144  
1145   -#: ui/00default.xml:67
  1145 +#: ui/00default.xml:289
1146 1146 msgid "Paste next"
1147 1147 msgstr "Colar próximo"
1148 1148  
1149   -#: ui/00default.xml:70
  1149 +#: ui/00default.xml:292
1150 1150 msgid "Paste text file"
1151 1151 msgstr "Colar arquivo texto"
1152 1152  
... ... @@ -1154,7 +1154,7 @@ msgstr &quot;Colar arquivo texto&quot;
1154 1154 msgid "Paste text file contents"
1155 1155 msgstr "Colar conteúdo de arquivo texto"
1156 1156  
1157   -#: ui/00default.xml:123
  1157 +#: ui/00default.xml:345
1158 1158 msgid "Paste with left margin"
1159 1159 msgstr "Colar com margem esquerda"
1160 1160  
... ... @@ -1170,7 +1170,7 @@ msgstr &quot;Path to application data files&quot;
1170 1170 msgid "Pink"
1171 1171 msgstr "Rosa"
1172 1172  
1173   -#: ui/00default.xml:188
  1173 +#: ui/00default.xml:410
1174 1174 msgid "Previous field"
1175 1175 msgstr "Campo anterior"
1176 1176  
... ... @@ -1178,11 +1178,11 @@ msgstr &quot;Campo anterior&quot;
1178 1178 msgid "Primary space:"
1179 1179 msgstr "Primary space:"
1180 1180  
1181   -#: ui/00default.xml:49
  1181 +#: ui/00default.xml:271
1182 1182 msgid "Print"
1183 1183 msgstr "Imprimir"
1184 1184  
1185   -#: ui/00default.xml:51
  1185 +#: ui/00default.xml:273
1186 1186 msgid "Print copy"
1187 1187 msgstr "Imprimir cópia"
1188 1188  
... ... @@ -1190,7 +1190,7 @@ msgstr &quot;Imprimir cópia&quot;
1190 1190 msgid "Print operation failed"
1191 1191 msgstr "Operação de impressão falhou"
1192 1192  
1193   -#: ui/00default.xml:50
  1193 +#: ui/00default.xml:272
1194 1194 msgid "Print selected"
1195 1195 msgstr "Imprimir seleção"
1196 1196  
... ... @@ -1198,7 +1198,7 @@ msgstr &quot;Imprimir seleção&quot;
1198 1198 msgid "Print selection box"
1199 1199 msgstr "Imprimir marca de seleção"
1200 1200  
1201   -#: print.c:743 ui/00default.xml:108
  1201 +#: print.c:743 ui/00default.xml:330
1202 1202 msgid "Print settings"
1203 1203 msgstr "Configurações de impressão"
1204 1204  
... ... @@ -1286,7 +1286,7 @@ msgstr &quot;RPQ: can&#39;t resolve &#39;%s&#39;: %s&quot;
1286 1286 msgid "RPQ: gethostbyname error"
1287 1287 msgstr "RPQ: Erro em gethostbyname"
1288 1288  
1289   -#: ui/00default.xml:54
  1289 +#: ui/00default.xml:276
1290 1290 msgid "Receive file"
1291 1291 msgstr "Receber arquivo"
1292 1292  
... ... @@ -1302,27 +1302,27 @@ msgstr &quot;Formato de registro&quot;
1302 1302 msgid "Red"
1303 1303 msgstr "Vermelho"
1304 1304  
1305   -#: ui/99debug.xml:580
  1305 +#: ui/99debug.xml:214
1306 1306 msgid "Reload buffer contents"
1307 1307 msgstr "Recarregar conteúdo do buffer"
1308 1308  
1309   -#: ui/00default.xml:75
  1309 +#: ui/00default.xml:297
1310 1310 msgid "Remove selection"
1311 1311 msgstr "Remover seleção"
1312 1312  
1313   -#: ui/00default.xml:76
  1313 +#: ui/00default.xml:298
1314 1314 msgid "Reselect"
1315 1315 msgstr "Reselecionar"
1316 1316  
1317   -#: ui/10keypad.xml:460
  1317 +#: ui/10keypad.xml:148
1318 1318 msgid "Reset"
1319 1319 msgstr "Reset"
1320 1320  
1321   -#: ui/00default.xml:122
  1321 +#: ui/00default.xml:344
1322 1322 msgid "Resize on alternate screen"
1323 1323 msgstr "Mudar tamanho do terminal em tela alternativa"
1324 1324  
1325   -#: ui/00default.xml:190
  1325 +#: ui/00default.xml:412
1326 1326 msgid "Return"
1327 1327 msgstr "Return"
1328 1328  
... ... @@ -1483,7 +1483,7 @@ msgstr &quot;&quot;
1483 1483 "SSL_write:\n"
1484 1484 "%s"
1485 1485  
1486   -#: ui/00default.xml:46
  1486 +#: ui/00default.xml:268
1487 1487 msgid "Save copy"
1488 1488 msgstr "Salvar cópia"
1489 1489  
... ... @@ -1491,7 +1491,7 @@ msgstr &quot;Salvar cópia&quot;
1491 1491 msgid "Save copy to file"
1492 1492 msgstr "Salvar cópia para arquivo"
1493 1493  
1494   -#: ui/00default.xml:44
  1494 +#: ui/00default.xml:266
1495 1495 msgid "Save screen"
1496 1496 msgstr "Salvar tela"
1497 1497  
... ... @@ -1499,7 +1499,7 @@ msgstr &quot;Salvar tela&quot;
1499 1499 msgid "Save screen to file"
1500 1500 msgstr "Salvar tela para arquivo"
1501 1501  
1502   -#: ui/00default.xml:45
  1502 +#: ui/00default.xml:267
1503 1503 msgid "Save selected"
1504 1504 msgstr "Salvar seleção"
1505 1505  
... ... @@ -1507,20 +1507,15 @@ msgstr &quot;Salvar seleção&quot;
1507 1507 msgid "Save selection to file"
1508 1508 msgstr "Salvar seleção para arquivo"
1509 1509  
1510   -#: ui/99debug.xml:572
  1510 +#: ui/99debug.xml:206
1511 1511 msgid "Screen Trace"
1512 1512 msgstr "Trace de tela"
1513 1513  
1514   -#: ui/00default.xml:114
  1514 +#: ui/00default.xml:336
1515 1515 msgid "Screen size"
1516 1516 msgstr "Tamanho da tela"
1517 1517  
1518   -#: ui/09scripts.xml:297
1519   -#, fuzzy
1520   -msgid "Script"
1521   -msgstr "Scripts"
1522   -
1523   -#: ui/00default.xml:89
  1518 +#: ui/00default.xml:311
1524 1519 msgid "Scripts"
1525 1520 msgstr "Scripts"
1526 1521  
... ... @@ -1532,15 +1527,15 @@ msgstr &quot;Secondary space:&quot;
1532 1527 msgid "Secure connection was successful."
1533 1528 msgstr "Conexão segura efetuada com sucesso."
1534 1529  
1535   -#: ui/00default.xml:74
  1530 +#: ui/00default.xml:296
1536 1531 msgid "Select Field"
1537 1532 msgstr "Selecionar campo"
1538 1533  
1539   -#: ui/00default.xml:73
  1534 +#: ui/00default.xml:295
1540 1535 msgid "Select all"
1541 1536 msgstr "Selecionar tudo"
1542 1537  
1543   -#: ui/00default.xml:126
  1538 +#: ui/00default.xml:348
1544 1539 msgid "Select by rectangles"
1545 1540 msgstr "Seleção retangular"
1546 1541  
... ... @@ -1552,7 +1547,7 @@ msgstr &quot;Selecione arquivo a receber&quot;
1552 1547 msgid "Select file to send"
1553 1548 msgstr "Selecione arquivo a enviar"
1554 1549  
1555   -#: ui/00default.xml:111
  1550 +#: ui/00default.xml:333
1556 1551 msgid "Select font"
1557 1552 msgstr "Selecione fonte"
1558 1553  
... ... @@ -1576,7 +1571,7 @@ msgstr &quot;Self signed certificate&quot;
1576 1571 msgid "Self signed certificate in certificate chain"
1577 1572 msgstr "Self signed certificate in certificate chain"
1578 1573  
1579   -#: ui/00default.xml:55
  1574 +#: ui/00default.xml:277
1580 1575 msgid "Send file"
1581 1576 msgstr "Enviar arquivo"
1582 1577  
... ... @@ -1588,7 +1583,7 @@ msgstr &quot;Enviar arquivo para o servidor&quot;
1588 1583 msgid "Send messages to syslog"
1589 1584 msgstr "Send messages to syslog"
1590 1585  
1591   -#: ui/00default.xml:54
  1586 +#: ui/00default.xml:276
1592 1587 msgid "Send/Receive"
1593 1588 msgstr "Enviar/Receber"
1594 1589  
... ... @@ -1596,7 +1591,7 @@ msgstr &quot;Enviar/Receber&quot;
1596 1591 msgid "Session name"
1597 1592 msgstr "Nome da sessão"
1598 1593  
1599   -#: ui/00default.xml:92
  1594 +#: ui/00default.xml:314
1600 1595 msgid "Set hostname"
1601 1596 msgstr "Selecione servidor"
1602 1597  
... ... @@ -1604,19 +1599,19 @@ msgstr &quot;Selecione servidor&quot;
1604 1599 msgid "Set reported colors (8/16)"
1605 1600 msgstr "Define número de cores informadas (8/16)"
1606 1601  
1607   -#: ui/00default.xml:107
  1602 +#: ui/00default.xml:329
1608 1603 msgid "Settings"
1609 1604 msgstr "Configurações"
1610 1605  
1611   -#: ui/00default.xml:129
  1606 +#: ui/00default.xml:351
1612 1607 msgid "Show Underline"
1613 1608 msgstr "Mostrar sublinhado"
1614 1609  
1615   -#: ui/99debug.xml:579
  1610 +#: ui/99debug.xml:213
1616 1611 msgid "Show test pattern"
1617 1612 msgstr "Mostrar padrão de teste"
1618 1613  
1619   -#: ui/00default.xml:131
  1614 +#: ui/00default.xml:353
1620 1615 msgid "Smart paste"
1621 1616 msgstr "Colar inteligente"
1622 1617  
... ... @@ -1664,18 +1659,6 @@ msgstr &quot;T_otal&quot;
1664 1659 msgid "Terminal colors"
1665 1660 msgstr "Cores do terminal"
1666 1661  
1667   -#: ui/09scripts.xml:298
1668   -msgid "Teste01"
1669   -msgstr "Teste01"
1670   -
1671   -#: ui/09scripts.xml:302
1672   -msgid "Teste02"
1673   -msgstr "Teste02"
1674   -
1675   -#: ui/09scripts.xml:306
1676   -msgid "Teste03"
1677   -msgstr "Teste03"
1678   -
1679 1662 #: host.c:216
1680 1663 msgid "Text before '['"
1681 1664 msgstr "Texto antes de '['"
... ... @@ -1902,15 +1885,15 @@ msgid &quot;&quot;
1902 1885 "This version of %s was built without support for secure sockets layer (SSL)."
1903 1886 msgstr "Esta versão do %s foi gerada sem suporte para conexões seguras (SSL)."
1904 1887  
1905   -#: ui/00default.xml:148
  1888 +#: ui/00default.xml:370
1906 1889 msgid "Toolbar"
1907 1890 msgstr "Barra de ferramentas"
1908 1891  
1909   -#: ui/99debug.xml:571
  1892 +#: ui/99debug.xml:205
1910 1893 msgid "Trace"
1911 1894 msgstr "Trace"
1912 1895  
1913   -#: ui/00default.xml:120
  1896 +#: ui/00default.xml:342
1914 1897 msgid "Track Cursor"
1915 1898 msgstr "Mostrar posição do cursor"
1916 1899  
... ... @@ -2117,7 +2100,7 @@ msgstr &quot;Unsupported passthru host session&quot;
2117 2100 msgid "Unsupported socks 4 proxy"
2118 2101 msgstr "Unsupported socks 4 proxy"
2119 2102  
2120   -#: ui/00default.xml:133
  2103 +#: ui/00default.xml:355
2121 2104 msgid "Use +/- for field navigation"
2122 2105 msgstr "Usar teclas +/- para navegar por campos"
2123 2106  
... ... @@ -2130,7 +2113,7 @@ msgstr &quot;Variável&quot;
2130 2113 msgid "Version %s - Revision %s"
2131 2114 msgstr "Versão %s - Revisão %s"
2132 2115  
2133   -#: ui/99debug.xml:574
  2116 +#: ui/99debug.xml:208
2134 2117 msgid "View Field Delimiters"
2135 2118 msgstr "Mostrar delimitadores de campo"
2136 2119  
... ... @@ -2158,7 +2141,7 @@ msgstr &quot;Europa ocidental (ISO 8859-1)&quot;
2158 2141 msgid "White"
2159 2142 msgstr "Branco"
2160 2143  
2161   -#: ui/00default.xml:159
  2144 +#: ui/00default.xml:381
2162 2145 msgid "Window"
2163 2146 msgstr "Janela"
2164 2147  
... ... @@ -2226,19 +2209,19 @@ msgstr &quot;_Procurar&quot;
2226 2209 msgid "_Color table:"
2227 2210 msgstr "Tabela de cores:"
2228 2211  
2229   -#: ui/00default.xml:102
  2212 +#: ui/00default.xml:324
2230 2213 msgid "_Connect"
2231 2214 msgstr "_Conectar"
2232 2215  
2233   -#: ui/00default.xml:103
  2216 +#: ui/00default.xml:325
2234 2217 msgid "_Disconnect"
2235 2218 msgstr "_Desconectar"
2236 2219  
2237   -#: ui/00default.xml:61
  2220 +#: ui/99debug.xml:200
2238 2221 msgid "_Edit"
2239 2222 msgstr "_Editar"
2240 2223  
2241   -#: ui/00default.xml:36
  2224 +#: ui/00default.xml:258
2242 2225 msgid "_File"
2243 2226 msgstr "_Arquivo"
2244 2227  
... ... @@ -2266,11 +2249,11 @@ msgstr &quot;Nome do _Host:&quot;
2266 2249 msgid "_Local file name:"
2267 2250 msgstr "Arquivo _local:"
2268 2251  
2269   -#: ui/00default.xml:92
  2252 +#: ui/00default.xml:314
2270 2253 msgid "_Network"
2271 2254 msgstr "_Rede"
2272 2255  
2273   -#: ui/00default.xml:117
  2256 +#: ui/00default.xml:339
2274 2257 msgid "_Options"
2275 2258 msgstr "_Opções"
2276 2259  
... ... @@ -2298,7 +2281,7 @@ msgstr &quot;Arquivo _texto&quot;
2298 2281 msgid "_To"
2299 2282 msgstr "_Para"
2300 2283  
2301   -#: ui/00default.xml:87
  2284 +#: ui/00default.xml:309
2302 2285 msgid "_View"
2303 2286 msgstr "_Exibir"
2304 2287  
... ... @@ -2345,6 +2328,19 @@ msgid &quot;unknown error&quot;
2345 2328 msgstr "Erro desconhecido"
2346 2329  
2347 2330 #, fuzzy
  2331 +#~ msgid "Script"
  2332 +#~ msgstr "Scripts"
  2333 +
  2334 +#~ msgid "Teste01"
  2335 +#~ msgstr "Teste01"
  2336 +
  2337 +#~ msgid "Teste02"
  2338 +#~ msgstr "Teste02"
  2339 +
  2340 +#~ msgid "Teste03"
  2341 +#~ msgstr "Teste03"
  2342 +
  2343 +#, fuzzy
2348 2344 #~ msgid "Cross hair Cursor"
2349 2345 #~ msgstr "Cursor mira"
2350 2346  
... ...
pw3270.cbp
... ... @@ -243,29 +243,34 @@
243 243 <Unit filename="src/plugins/dbus3270/pw3270dbus.xml" />
244 244 <Unit filename="src/plugins/dbus3270/service.h" />
245 245 <Unit filename="src/plugins/dbus3270/test.sh" />
246   - <Unit filename="src/plugins/remotectl/Makefile.in" />
247   - <Unit filename="src/plugins/remotectl/calls.c">
  246 + <Unit filename="src/plugins/hllapi/Makefile.in" />
  247 + <Unit filename="src/plugins/hllapi/calls.c">
248 248 <Option compilerVar="CC" />
249 249 </Unit>
250   - <Unit filename="src/plugins/remotectl/client.h" />
251   - <Unit filename="src/plugins/remotectl/hllapi.c">
  250 + <Unit filename="src/plugins/hllapi/client.h" />
  251 + <Unit filename="src/plugins/hllapi/hllapi.c">
252 252 <Option compilerVar="CC" />
253 253 </Unit>
254   - <Unit filename="src/plugins/remotectl/packets.h" />
255   - <Unit filename="src/plugins/remotectl/pipesource.c">
  254 + <Unit filename="src/plugins/hllapi/packets.h" />
  255 + <Unit filename="src/plugins/hllapi/pipesource.c">
256 256 <Option compilerVar="CC" />
257 257 </Unit>
258   - <Unit filename="src/plugins/remotectl/pluginmain.c">
  258 + <Unit filename="src/plugins/hllapi/pluginmain.c">
259 259 <Option compilerVar="CC" />
260 260 </Unit>
261   - <Unit filename="src/plugins/remotectl/remote.c">
  261 + <Unit filename="src/plugins/hllapi/remote.c">
262 262 <Option compilerVar="CC" />
263 263 </Unit>
264   - <Unit filename="src/plugins/remotectl/remotectl.h" />
265   - <Unit filename="src/plugins/remotectl/server.h" />
266   - <Unit filename="src/plugins/remotectl/testprogram.c">
  264 + <Unit filename="src/plugins/hllapi/remotectl.h" />
  265 + <Unit filename="src/plugins/hllapi/server.h" />
  266 + <Unit filename="src/plugins/hllapi/testprogram.c">
267 267 <Option compilerVar="CC" />
268 268 </Unit>
  269 + <Unit filename="src/plugins/remotectl/Makefile.in" />
  270 + <Unit filename="src/plugins/remotectl/client.h" />
  271 + <Unit filename="src/plugins/remotectl/packets.h" />
  272 + <Unit filename="src/plugins/remotectl/remotectl.h" />
  273 + <Unit filename="src/plugins/remotectl/server.h" />
269 274 <Unit filename="src/plugins/rx3270/Makefile.in" />
270 275 <Unit filename="src/plugins/rx3270/pluginmain.cc" />
271 276 <Unit filename="src/plugins/rx3270/rx3270.h" />
... ...
pw3270.nsi.in
... ... @@ -117,7 +117,7 @@ SubSection &quot;@PACKAGE@&quot; SecMain
117 117 setOutPath $INSTDIR
118 118  
119 119 CreateDirectory "$INSTDIR\plugins"
120   - file "/oname=$INSTDIR\plugins\remotectl.dll" ".bin\Release\plugins\remotectl.dll"
  120 + file "/oname=$INSTDIR\plugins\hllapi.dll" ".bin\Release\plugins\hllapi.dll"
121 121 file "/oname=$SYSDIR\libhllapi.dll" ".bin\Release\libhllapi.dll"
122 122  
123 123 sectionEnd
... ...
src/include/pw3270/hllapi.h
... ... @@ -81,13 +81,16 @@ extern &quot;C&quot; {
81 81 __declspec (dllexport) DWORD __stdcall hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
82 82 __declspec (dllexport) DWORD __stdcall hllapi_enter(void);
83 83 __declspec (dllexport) DWORD __stdcall hllapi_set_text_at(WORD row, WORD col, LPSTR text);
84   - __declspec (dllexport) DWORD __stdcall hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
  84 + __declspec (dllexport) DWORD __stdcall hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
  85 + __declspec (dllexport) DWORD __stdcall hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting);
85 86 __declspec (dllexport) DWORD __stdcall hllapi_wait_for_ready(WORD seconds);
86 87 __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds);
87 88 __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key);
88 89 __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key);
89 90 __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD key);
90 91 __declspec (dllexport) DWORD __stdcall hllapi_getcursor();
  92 + __declspec (dllexport) DWORD __stdcall hllapi_erase_eof(void);
  93 + __declspec (dllexport) DWORD __stdcall hllapi_print(void);
91 94  
92 95 #else
93 96  
... ...
src/plugins/hllapi/Makefile.in 0 → 100644
... ... @@ -0,0 +1,152 @@
  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 +# licinio@bb.com.br (Licínio Luis Branco)
  26 +# kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  27 +#
  28 +
  29 +#---[ Sources ]----------------------------------------------------------------
  30 +
  31 +MODULE_NAME=hllapi
  32 +DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile
  33 +PLUGIN_SRC=pluginmain.c
  34 +HLLAPI_SRC=hllapi.c calls.c remote.c
  35 +
  36 +#---[ Paths ]------------------------------------------------------------------
  37 +
  38 +ROOTDIR ?= .
  39 +OBJDIR ?= $(ROOTDIR)/.obj
  40 +BINDIR ?= $(ROOTDIR)/.bin
  41 +BINDBG ?= $(BINDIR)/Debug
  42 +BINRLS ?= $(BINDIR)/Release
  43 +
  44 +OBJDBG = $(OBJDIR)/Debug
  45 +OBJRLS = $(OBJDIR)/Release
  46 +OBJEXT = o
  47 +
  48 +#---[ Tools ]------------------------------------------------------------------
  49 +
  50 +MKDIR=@MKDIR_P@
  51 +CC=@CC@
  52 +LD=@CC@
  53 +MSGCAT=@MSGCAT@
  54 +XGETTEXT=@XGETTEXT@
  55 +
  56 +#---[ Rules ]------------------------------------------------------------------
  57 +
  58 +DLL_FLAGS=@DLL_FLAGS@
  59 +DEBUG_CFLAGS=-DDEBUG=1 -g -Wall
  60 +
  61 +LIB3270_MODE ?= Default
  62 +
  63 +ifeq ($(LIB3270_MODE),Debug)
  64 + PW3270_LIBS=-L../../../.bin/Debug@DLLDIR@ -lpw3270 -l3270
  65 + PW3270_CFLAGS=-I../../../src/include
  66 + LIB3270_LIBS=-L../../../.bin/Debug@DLLDIR@ -l3270
  67 + LIB3270_CFLAGS=-I../../../src/include
  68 +endif
  69 +
  70 +ifeq ($(LIB3270_MODE),Release)
  71 + PW3270_LIBS=-L../../../.bin/Release@DLLDIR@ -lpw3270 -l3270
  72 + PW3270_CFLAGS=-I../../../src/include
  73 + LIB3270_LIBS=-L../../../.bin/Release@DLLDIR@ -l3270
  74 + LIB3270_CFLAGS=-I../../../src/include
  75 +endif
  76 +
  77 +ifeq ($(LIB3270_MODE),Default)
  78 + LIB3270_LIBS ?= `pkg-config --libs lib3270`
  79 + LIB3270_CFLAGS ?= `pkg-config --cflags lib3270`
  80 + PW3270_LIBS ?= `pkg-config --libs pw3270 lib3270`
  81 + PW3270_CFLAGS ?= `pkg-config --cflags pw3270 lib3270`
  82 +endif
  83 +
  84 +
  85 +GTK_CFLAGS ?= @GTK_CFLAGS@ @GTKMAC_CFLAGS@
  86 +GTK_LIBS ?= @GTK_LIBS@ @GTKMAC_LIBS@
  87 +
  88 +$(OBJDBG)/%.o: %.c $(DEPENDS)
  89 + @echo " CC `basename $@`"
  90 + @$(MKDIR) `dirname $@`
  91 + @$(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
  92 +
  93 +$(OBJRLS)/%.o: %.c $(DEPENDS)
  94 + @echo " CC `basename $@`"
  95 + @$(MKDIR) `dirname $@`
  96 + @$(CC) $(CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
  97 +
  98 +
  99 +#---[ Release targets ]--------------------------------------------------------
  100 +
  101 +Release: $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINRLS)/libhllapi@DLLEXT@
  102 +
  103 +$(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o)
  104 + @echo " CCLD `basename $@`"
  105 + @$(MKDIR) `dirname $@`
  106 + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS)
  107 +
  108 +$(BINRLS)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJRLS)/$(SRC).o)
  109 + @echo " CCLD `basename $@`"
  110 + @$(MKDIR) `dirname $@`
  111 + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @LDLIBFLAGS@ -o $@ $^ $(LIBS)
  112 +
  113 +#---[ Debug targets ]----------------------------------------------------------
  114 +
  115 +Debug: $(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINDBG)/libhllapi@DLLEXT@
  116 +
  117 +$(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o)
  118 + @echo " CCLD `basename $@`"
  119 + @$(MKDIR) `dirname $@`
  120 + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS)
  121 +
  122 +$(BINDBG)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJDBG)/$(SRC).o)
  123 + @echo " CCLD `basename $@`"
  124 + @$(MKDIR) `dirname $@`
  125 + @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @LDLIBFLAGS@ -o $@ $^ $(LIBS)
  126 +
  127 +#---[ Misc targets ]-----------------------------------------------------------
  128 +
  129 +$(BINDBG)/testprogram@EXEEXT@: testprogram.c $(BINDBG)/libhllapi@DLLEXT@
  130 + @echo " CCLD `basename $@`"
  131 + @$(MKDIR) `dirname $@`
  132 + @$(CC) $(CFLAGS) $(PW3270_CFLAGS) -L$(BINDBG) $(DEBUG_CFLAGS) -lhllapi -o $@ testprogram.c
  133 +
  134 +test: $(BINDBG)/testprogram@EXEEXT@
  135 +
  136 +run: $(BINDBG)/testprogram@EXEEXT@
  137 + @cd $(BINDBG) ; ./testprogram@EXEEXT@
  138 +
  139 +install: $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@
  140 + @$(MKDIR) $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugins
  141 + @$(INSTALL_PROGRAM) $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugins
  142 +
  143 +$(DEBDIR)/$(MODULE_NAME).install: Makefile
  144 + @$(MKDIR) `dirname $@`
  145 + @rm -f $@
  146 + @echo $(libdir)/$(PACKAGE_NAME)-plugins/$(MODULE_NAME)@DLLEXT@ > $@
  147 +
  148 +clean:
  149 + @rm -fr $(OBJDIR)
  150 + @rm -fr $(BINDIR)
  151 + @rm -f testprogram@EXEEXT@
  152 + @find . -name "*~" -exec rm -f {} \;
... ...
src/plugins/hllapi/calls.c 0 → 100644
... ... @@ -0,0 +1,463 @@
  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 + * Este programa está nomeado como calls.c 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 + #include <windows.h>
  31 + #include <lib3270.h>
  32 + #include <malloc.h>
  33 + #include <string.h>
  34 + #include <errno.h>
  35 + #include <pw3270/hllapi.h>
  36 + #include <stdio.h>
  37 + #include <lib3270/log.h>
  38 + #include "client.h"
  39 +
  40 + #undef trace
  41 + #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } }
  42 +
  43 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  44 +
  45 + HMODULE hModule = NULL;
  46 + void * hSession = NULL;
  47 +
  48 + static void * (*session_new)(const char *model) = NULL;
  49 + static void (*session_free)(void *h) = NULL;
  50 + static const char * (*get_revision)(void) = NULL;
  51 + static int (*host_connect)(void *h,const char *n, int wait) = NULL;
  52 + static int (*host_is_connected)(void *h) = NULL;
  53 + static int (*wait_for_ready)(void *h, int seconds) = NULL;
  54 + static void (*host_disconnect)(void *h) = NULL;
  55 + static int (*script_sleep)(void *h, int seconds) = NULL;
  56 + static LIB3270_MESSAGE (*get_message)(void *h) = NULL;
  57 + static char * (*get_text)(void *h, int row, int col, int len) = NULL;
  58 + static char * (*get_text_at_offset)(void *h, int offset, int len) = NULL;
  59 +
  60 + static void * (*release_memory)(void *p) = NULL;
  61 + static int (*action_enter)(void *h) = NULL;
  62 + static int (*set_text_at)(void *h, int row, int col, const unsigned char *str) = NULL;
  63 + static int (*cmp_text_at)(void *h, int row, int col, const char *text) = NULL;
  64 + static int (*pfkey)(void *hSession, int key) = NULL;
  65 + static int (*pakey)(void *hSession, int key) = NULL;
  66 + static int (*getcursor)(void *hSession) = NULL;
  67 + static int (*setcursor)(void *hSession, int baddr) = NULL;
  68 + static int (*emulate_input)(void *hSession, const char *s, int len, int pasting) = NULL;
  69 + static int (*erase_eof)(void *hSession) = NULL;
  70 +
  71 + static const struct _entry_point
  72 + {
  73 + void **call;
  74 + void * pipe;
  75 + const char * name;
  76 + } entry_point[] =
  77 + {
  78 + { (void **) &session_new, (void *) hllapi_pipe_init, "lib3270_session_new" },
  79 + { (void **) &session_free, (void *) hllapi_pipe_deinit, "lib3270_session_free" },
  80 + { (void **) &get_revision, (void *) hllapi_pipe_get_revision, "lib3270_get_revision" },
  81 + { (void **) &host_connect, (void *) hllapi_pipe_connect, "lib3270_connect" },
  82 + { (void **) &host_disconnect, (void *) hllapi_pipe_disconnect, "lib3270_disconnect" },
  83 + { (void **) &host_is_connected, (void *) hllapi_pipe_is_connected, "lib3270_in_tn3270e" },
  84 + { (void **) &wait_for_ready, (void *) hllapi_pipe_wait_for_ready, "lib3270_wait_for_ready" },
  85 + { (void **) &script_sleep, (void *) hllapi_pipe_sleep, "lib3270_wait" },
  86 + { (void **) &get_message, (void *) hllapi_pipe_get_message, "lib3270_get_program_message" },
  87 + { (void **) &get_text, (void *) hllapi_pipe_get_text_at, "lib3270_get_text_at" },
  88 + { (void **) &release_memory, (void *) hllapi_pipe_release_memory, "lib3270_free" },
  89 + { (void **) &action_enter, (void *) hllapi_pipe_enter, "lib3270_enter" },
  90 + { (void **) &set_text_at, (void *) hllapi_pipe_set_text_at, "lib3270_set_string_at" },
  91 + { (void **) &cmp_text_at, (void *) hllapi_pipe_cmp_text_at, "lib3270_cmp_text_at" },
  92 + { (void **) &pfkey, (void *) hllapi_pipe_pfkey, "lib3270_pfkey" },
  93 + { (void **) &pakey, (void *) hllapi_pipe_pakey, "lib3270_pakey" },
  94 + { (void **) &setcursor, (void *) hllapi_pipe_setcursor, "lib3270_set_cursor_address" },
  95 + { (void **) &getcursor, (void *) hllapi_pipe_getcursor, "lib3270_get_cursor_address" },
  96 + { (void **) &get_text_at_offset, (void *) hllapi_pipe_get_text, "lib3270_get_text" },
  97 + { (void **) &emulate_input, (void *) hllapi_pipe_emulate_input, "lib3270_emulate_input" },
  98 + { (void **) &erase_eof, (void *) hllapi_pipe_erase_eof, "lib3270_eraseeof" },
  99 + { NULL, NULL, NULL }
  100 + };
  101 +
  102 +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx
  103 +#ifndef LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
  104 + #define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000
  105 +#endif // LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
  106 +
  107 +#ifndef LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
  108 + #define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100
  109 +#endif // LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
  110 +
  111 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  112 +
  113 + __declspec (dllexport) DWORD __stdcall hllapi_init(LPSTR mode)
  114 + {
  115 + if(!mode)
  116 + return EINVAL;
  117 +
  118 + trace("%s(%s)",__FUNCTION__,(char *) mode);
  119 +
  120 + if(mode && *mode)
  121 + {
  122 + // Get pointers to the pipe based calls
  123 + int f;
  124 +
  125 + trace("%s: Loading pipe based calls",__FUNCTION__);
  126 + for(f=0;entry_point[f].name;f++)
  127 + *entry_point[f].call = entry_point[f].pipe;
  128 +
  129 + }
  130 + else
  131 + {
  132 + // Direct mode, load lib3270.dll, get pointers to the calls
  133 + static const char *dllname = "lib3270.dll." PACKAGE_VERSION;
  134 +
  135 + int f;
  136 + HMODULE kernel;
  137 + HANDLE cookie = NULL;
  138 + DWORD rc;
  139 + HANDLE (*AddDllDirectory)(PCWSTR NewDirectory);
  140 + BOOL (*RemoveDllDirectory)(HANDLE Cookie);
  141 + UINT errorMode;
  142 + char datadir[4096];
  143 +
  144 + trace("hModule=%p",hModule);
  145 + if(hModule)
  146 + return EBUSY;
  147 +
  148 + kernel = LoadLibrary("kernel32.dll");
  149 + AddDllDirectory = (HANDLE (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory");
  150 + RemoveDllDirectory = (BOOL (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory");
  151 +
  152 + // Notify user in case of error loading protocol DLL
  153 + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx
  154 + errorMode = SetErrorMode(1);
  155 +
  156 + memset(datadir,' ',4095);
  157 + datadir[4095] = 0;
  158 +
  159 + if(hllapi_get_datadir(datadir))
  160 + {
  161 + char buffer[4096];
  162 + wchar_t path[4096];
  163 +
  164 + mbstowcs(path, datadir, 4095);
  165 + trace("Datadir=[%s] AddDllDirectory=%p RemoveDllDirectory=%p\n",datadir,AddDllDirectory,RemoveDllDirectory);
  166 + if(AddDllDirectory)
  167 + cookie = AddDllDirectory(path);
  168 +
  169 +#ifdef DEBUG
  170 + snprintf(buffer,4096,"%s\\.bin\\Debug\\%s",datadir,dllname);
  171 +#else
  172 + snprintf(buffer,4096,"%s\\%s",datadir,dllname);
  173 +#endif // DEBUG
  174 +
  175 + hModule = LoadLibrary(buffer);
  176 +
  177 + trace("%s hModule=%p rc=%d",buffer,hModule,(int) GetLastError());
  178 +
  179 + if(hModule == NULL)
  180 + {
  181 + // Enable DLL error popup and try again with full path
  182 + SetErrorMode(0);
  183 + hModule = LoadLibraryEx(buffer,NULL,LOAD_LIBRARY_SEARCH_DEFAULT_DIRS|LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
  184 + }
  185 +
  186 + rc = GetLastError();
  187 +
  188 + trace("%s hModule=%p rc=%d",buffer,hModule,(int) rc);
  189 + }
  190 + else
  191 + {
  192 + hModule = LoadLibrary(dllname);
  193 + rc = GetLastError();
  194 + }
  195 +
  196 + SetErrorMode(errorMode);
  197 +
  198 + trace("%s hModule=%p rc=%d",dllname,hModule,(int) rc);
  199 +
  200 + if(cookie && RemoveDllDirectory)
  201 + RemoveDllDirectory(cookie);
  202 +
  203 + if(kernel)
  204 + FreeLibrary(kernel);
  205 +
  206 + if(!hModule)
  207 + return rc;
  208 +
  209 + // Get library entry pointers
  210 + for(f=0;entry_point[f].name;f++)
  211 + {
  212 + void *ptr = (void *) GetProcAddress(hModule,entry_point[f].name);
  213 +
  214 + trace("%d %s=%p\n",f,entry_point[f].name,ptr);
  215 +
  216 + if(!ptr)
  217 + {
  218 + fprintf(stderr,"Can´t load \"%s\"\n",entry_point[f].name);
  219 + hllapi_deinit();
  220 + return ENOENT;
  221 + }
  222 + *entry_point[f].call = ptr;
  223 + }
  224 +
  225 + }
  226 + // Get session handle
  227 + hSession = session_new((const char *) mode);
  228 + trace("%s ok hSession=%p\n",__FUNCTION__,hSession);
  229 +
  230 + return hSession ? 0 : -1;
  231 + }
  232 +
  233 + __declspec (dllexport) DWORD __stdcall hllapi_deinit(void)
  234 + {
  235 + int f;
  236 +
  237 + // Release session
  238 + if(hSession && session_free)
  239 + session_free(hSession);
  240 +
  241 + for(f=0;entry_point[f].name;f++)
  242 + *entry_point[f].call = NULL;
  243 +
  244 + if(hModule != NULL)
  245 + {
  246 + FreeLibrary(hModule);
  247 + hModule = NULL;
  248 + }
  249 +
  250 + return 0;
  251 + }
  252 +
  253 + __declspec (dllexport) DWORD __stdcall hllapi_get_revision(void)
  254 + {
  255 + if(!get_revision)
  256 + return 0;
  257 + return (DWORD) atoi(get_revision());
  258 + }
  259 +
  260 + __declspec (dllexport) DWORD __stdcall hllapi_connect(LPSTR uri, WORD wait)
  261 + {
  262 + if(!(host_connect && hSession && uri))
  263 + return EINVAL;
  264 +
  265 + return host_connect(hSession,uri,wait);
  266 + }
  267 +
  268 + __declspec (dllexport) DWORD __stdcall hllapi_is_connected(void)
  269 + {
  270 + if(!(host_is_connected && hSession))
  271 + return EINVAL;
  272 +
  273 + return host_is_connected(hSession);
  274 + }
  275 +
  276 + __declspec (dllexport) DWORD __stdcall hllapi_disconnect(void)
  277 + {
  278 + if(!(host_disconnect && hSession))
  279 + return EINVAL;
  280 +
  281 + host_disconnect(hSession);
  282 +
  283 + return 0;
  284 + }
  285 +
  286 + __declspec (dllexport) DWORD __stdcall hllapi_wait_for_ready(WORD seconds)
  287 + {
  288 + if(!(wait_for_ready && hSession))
  289 + return EINVAL;
  290 +
  291 + trace("%s seconds=%d\n", __FUNCTION__, (int) seconds);
  292 +
  293 + return (DWORD) wait_for_ready(hSession,(int) seconds);
  294 + }
  295 +
  296 + __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds)
  297 + {
  298 + if(!(script_sleep && hSession))
  299 + return EINVAL;
  300 +
  301 + return (DWORD) script_sleep(hSession,(int) seconds);
  302 + }
  303 +
  304 + __declspec (dllexport) DWORD __stdcall hllapi_get_message_id(void)
  305 + {
  306 + if(!(get_message && hSession))
  307 + return EINVAL;
  308 + return (DWORD) get_message(hSession);
  309 + }
  310 +
  311 + __declspec (dllexport) DWORD __stdcall hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)
  312 + {
  313 + char * text;
  314 + int len;
  315 +
  316 + if(!(get_text && release_memory && hSession))
  317 + return EINVAL;
  318 +
  319 + trace("%s row=%d col=%d buffer=%p",__FUNCTION__,row,col,buffer);
  320 + len = strlen(buffer);
  321 +
  322 + trace(" len=%d",len);
  323 +
  324 + text = get_text(hSession,row,col,len);
  325 +
  326 + trace(" text=%p errno=%d %s\n",text,errno,strerror(errno));
  327 +
  328 + if(!text)
  329 + return EINVAL;
  330 +
  331 + strncpy(buffer,text,len);
  332 + release_memory(text);
  333 +
  334 + trace("text:\n%s\n",buffer);
  335 +
  336 + return 0;
  337 + }
  338 +
  339 + __declspec (dllexport) DWORD __stdcall hllapi_enter(void)
  340 + {
  341 + if(!(action_enter && hSession))
  342 + return EINVAL;
  343 +
  344 + return (DWORD) action_enter(hSession);
  345 + }
  346 +
  347 + __declspec (dllexport) DWORD __stdcall hllapi_set_text_at(WORD row, WORD col, LPSTR text)
  348 + {
  349 + if(!(set_text_at && hSession))
  350 + return EINVAL;
  351 +
  352 + return (DWORD) set_text_at(hSession,row,col,(const unsigned char *) text);
  353 + }
  354 +
  355 + __declspec (dllexport) DWORD __stdcall hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)
  356 + {
  357 + if(!(cmp_text_at && hSession))
  358 + return EINVAL;
  359 +
  360 + return (DWORD) cmp_text_at(hSession,row,col,(const char *) text);
  361 + }
  362 +
  363 + __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key)
  364 + {
  365 + if(!(pfkey && hSession))
  366 + return EINVAL;
  367 +
  368 + return (DWORD) pfkey(hSession,key);
  369 + }
  370 +
  371 + __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key)
  372 + {
  373 + if(!(pfkey && hSession))
  374 + return EINVAL;
  375 +
  376 + return (DWORD) pakey(hSession,key);
  377 + }
  378 +
  379 + __declspec (dllexport) DWORD __stdcall hllapi_get_datadir(LPSTR datadir)
  380 + {
  381 + HKEY hKey = 0;
  382 + unsigned long datalen = strlen(datadir);
  383 +
  384 + *datadir = 0;
  385 +
  386 + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)
  387 + {
  388 + unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
  389 + if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)
  390 + *datadir = 0;
  391 + RegCloseKey(hKey);
  392 + }
  393 +
  394 + return *datadir;
  395 + }
  396 +
  397 + __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD pos)
  398 + {
  399 + if(!(setcursor && hSession))
  400 + return EINVAL;
  401 + trace("%s(%d)",__FUNCTION__,pos);
  402 + return setcursor(hSession,pos-1);
  403 + }
  404 +
  405 + __declspec (dllexport) DWORD __stdcall hllapi_getcursor()
  406 + {
  407 + if(!(getcursor && hSession))
  408 + return -EINVAL;
  409 + return getcursor(hSession)+1;
  410 + }
  411 +
  412 + __declspec (dllexport) DWORD __stdcall hllapi_get_screen(WORD pos, LPSTR buffer, WORD len)
  413 + {
  414 + char *text;
  415 +
  416 + trace("%s(%d,%d)",__FUNCTION__,pos,len);
  417 +
  418 + if(len < 0)
  419 + len = strlen(buffer);
  420 +
  421 + if(!(get_text_at_offset && hSession))
  422 + return EINVAL;
  423 +
  424 + if(len > strlen(buffer))
  425 + len = strlen(buffer);
  426 +
  427 + trace("len=%d",len);
  428 + text = get_text_at_offset(hSession,pos-1,len);
  429 +
  430 + trace("text=\n%s\n",text);
  431 +
  432 + if(!text)
  433 + return -1;
  434 +
  435 + memcpy(buffer,text,len);
  436 +
  437 + release_memory(text);
  438 +
  439 + return 0;
  440 + }
  441 +
  442 + __declspec (dllexport) DWORD __stdcall hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting)
  443 + {
  444 +
  445 + if(!(emulate_input && hSession))
  446 + return EINVAL;
  447 + trace("%s",__FUNCTION__);
  448 + return emulate_input(hSession, buffer, len, pasting);
  449 + }
  450 +
  451 + __declspec (dllexport) DWORD __stdcall hllapi_erase_eof(void)
  452 + {
  453 + if(!erase_eof && hSession)
  454 + return EINVAL;
  455 + trace("%s",__FUNCTION__);
  456 + return erase_eof(hSession);
  457 + }
  458 +
  459 + __declspec (dllexport) DWORD __stdcall hllapi_print(void)
  460 + {
  461 + #warning Implementar
  462 + return -1;
  463 + }
... ...
src/plugins/hllapi/client.h 0 → 100644
... ... @@ -0,0 +1,63 @@
  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 + * Este programa está nomeado como private.h 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 + #include <windows.h>
  31 + #include <pw3270/hllapi.h>
  32 +
  33 + #ifndef ETIMEDOUT
  34 + #define ETIMEDOUT 1238
  35 + #endif // ETIMEDOUT
  36 +
  37 + #define PIPE_BUFFER_LENGTH 8192
  38 +
  39 + #define set_active(x) /* x */
  40 +
  41 + void * hllapi_pipe_init(const char *id);
  42 + void hllapi_pipe_deinit(void *h);
  43 + const char * hllapi_pipe_get_revision(void);
  44 + void hllapi_pipe_release_memory(void *p);
  45 + int hllapi_pipe_connect(void *h, const char *n, int wait);
  46 + void hllapi_pipe_disconnect(void *h);
  47 + LIB3270_MESSAGE hllapi_pipe_get_message(void *h);
  48 + char * hllapi_pipe_get_text_at(void *h, int row, int col, int len);
  49 + char * hllapi_pipe_get_text(void *h, int offset, int len);
  50 + int hllapi_pipe_enter(void *h);
  51 + int hllapi_pipe_erase_eof(void *h);
  52 + int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str);
  53 + int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text);
  54 + int hllapi_pipe_pfkey(void *h, int key);
  55 + int hllapi_pipe_pakey(void *h, int key);
  56 + int hllapi_pipe_wait_for_ready(void *h, int seconds);
  57 + int hllapi_pipe_sleep(void *h, int seconds);
  58 + int hllapi_pipe_is_connected(void *h);
  59 + int hllapi_pipe_getcursor(void *h);
  60 + int hllapi_pipe_setcursor(void *h, int baddr);
  61 + int hllapi_pipe_emulate_input(void *hSession, const char *s, int len, int pasting);
  62 +
  63 +
... ...
src/plugins/hllapi/hllapi.c 0 → 100644
... ... @@ -0,0 +1,291 @@
  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 + * Este programa está nomeado como hllapi.c 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 + #include <lib3270.h>
  31 + #include <malloc.h>
  32 + #include <string.h>
  33 + #include <errno.h>
  34 + #include <pw3270/hllapi.h>
  35 + #include <stdio.h>
  36 + #include <lib3270/log.h>
  37 +
  38 + #undef trace
  39 + #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } }
  40 +
  41 +/*--[ Prototipes ]-----------------------------------------------------------------------------------*/
  42 +
  43 + static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc);
  44 + static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc);
  45 + static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc);
  46 + static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc);
  47 +
  48 + static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
  49 + static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
  50 + static int input_string(char *buffer, unsigned short *length, unsigned short *rc);
  51 +
  52 + static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc);
  53 +
  54 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  55 +
  56 + static const struct _hllapi_call
  57 + {
  58 + unsigned long func;
  59 + int (*exec)(char *buffer, unsigned short *length, unsigned short *rc);
  60 + } hllapi_call[] =
  61 + {
  62 + { HLLAPI_CMD_CONNECTPS, connect_ps },
  63 + { HLLAPI_CMD_DISCONNECTPS, disconnect_ps },
  64 + { HLLAPI_CMD_GETREVISION, get_library_revision },
  65 + { HLLAPI_CMD_QUERYCURSOR, get_cursor_position },
  66 + { HLLAPI_CMD_SETCURSOR, set_cursor_position },
  67 + { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str },
  68 + { HLLAPI_CMD_INPUTSTRING, input_string },
  69 + { HLLAPI_CMD_WAIT, invalid_request },
  70 + { HLLAPI_CMD_COPYPS, invalid_request },
  71 + { HLLAPI_CMD_SEARCHPS, invalid_request },
  72 + { HLLAPI_CMD_COPYSTRTOPS, invalid_request },
  73 + { HLLAPI_CMD_SENDFILE, invalid_request },
  74 + { HLLAPI_CMD_RECEIVEFILE, invalid_request },
  75 +
  76 + };
  77 +
  78 + static const char control_char = '@';
  79 +
  80 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  81 +
  82 +#ifdef _WIN32
  83 + __declspec (dllexport) int __stdcall hllapi(LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)
  84 +#else
  85 + LIB3270_EXPORT int hllapi(const unsigned long *func, char *buffer, unsigned short *length, unsigned short *rc)
  86 +#endif // _WIN32
  87 +{
  88 + int f;
  89 +
  90 + trace("%s(%d)",__FUNCTION__,*func);
  91 +
  92 + for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++)
  93 + {
  94 + if(hllapi_call[f].func == *func)
  95 + return hllapi_call[f].exec(buffer,length,rc);
  96 + }
  97 +
  98 + return invalid_request(buffer, length, rc);
  99 +}
  100 +
  101 +static int invalid_request(char *buffer, unsigned short *length, unsigned short *rc)
  102 +{
  103 + *rc = HLLAPI_STATUS_BAD_PARAMETER;
  104 + return *rc;
  105 +}
  106 +
  107 +static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc)
  108 +{
  109 + char *tempbuffer = NULL;
  110 +
  111 + trace("%s: len=%d buflen=%d",__FUNCTION__,*length,strlen(buffer));
  112 +
  113 + if(strlen(buffer) > *length)
  114 + buffer[*length] = 0;
  115 +
  116 + if(!strrchr(buffer,':'))
  117 + {
  118 + int sz = strlen(buffer);
  119 +
  120 + tempbuffer = malloc(sz+2);
  121 + strcpy(tempbuffer,buffer);
  122 + tempbuffer[sz-1] = ':';
  123 + tempbuffer[sz] = buffer[sz-1];
  124 + tempbuffer[sz+1] = 0;
  125 + buffer = tempbuffer;
  126 + }
  127 +
  128 + if(hllapi_init(buffer) == 0)
  129 + *rc = HLLAPI_STATUS_SUCESS;
  130 + else
  131 + *rc = HLLAPI_STATUS_UNAVAILABLE;
  132 +
  133 + if(tempbuffer)
  134 + free(tempbuffer);
  135 +
  136 + return 0;
  137 +}
  138 +
  139 +static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc)
  140 +{
  141 + *rc = hllapi_deinit();
  142 + return 0;
  143 +}
  144 +
  145 +static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc)
  146 +{
  147 + *rc = hllapi_get_revision();
  148 + return 0;
  149 +}
  150 +
  151 +static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)
  152 +{
  153 + int pos = hllapi_getcursor();
  154 +
  155 + trace("%s(%d)",__FUNCTION__,pos);
  156 +
  157 + if(pos < 0)
  158 + return -1;
  159 +
  160 + *rc = pos;
  161 + return 0;
  162 +}
  163 +
  164 +static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)
  165 +{
  166 + trace("%s(%d)",__FUNCTION__,*rc);
  167 + *rc = hllapi_setcursor(*rc);
  168 + return 0;
  169 +}
  170 +
  171 +static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc)
  172 +{
  173 + // Length Length of the target data string.
  174 + // PS Position Position within the host presentation space of the first byte in your target data string.
  175 + return hllapi_get_screen(*rc,buffer,*length);
  176 +}
  177 +
  178 +static int input_string(char *input, unsigned short *length, unsigned short *rc)
  179 +{
  180 + size_t szText;
  181 + char * text;
  182 +
  183 + if(!input)
  184 + {
  185 + *rc = HLLAPI_STATUS_BAD_PARAMETER;
  186 + return HLLAPI_STATUS_BAD_PARAMETER;
  187 + }
  188 +
  189 + szText = strlen(input);
  190 +
  191 + if(*length > 0 && *length < szText)
  192 + szText = *length;
  193 +
  194 + text = malloc(szText+2);
  195 + memcpy(text,input,szText);
  196 + text[szText] = 0;
  197 +
  198 + *rc = 0;
  199 +
  200 + if(strchr(text,control_char))
  201 + {
  202 + // Convert control char
  203 + char * buffer = text;
  204 + char * ptr;
  205 +
  206 + for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char))
  207 + {
  208 + *(ptr++) = 0;
  209 +
  210 + hllapi_emulate_input(buffer,-1,0);
  211 +
  212 + switch(*(ptr++))
  213 + {
  214 + case 'P': // Print
  215 + *rc = hllapi_print();
  216 + break;
  217 +
  218 + case 'E': // Enter
  219 + hllapi_enter();
  220 + break;
  221 +
  222 + case 'F': // Erase EOF
  223 + hllapi_erase_eof();
  224 + break;
  225 +
  226 + case '1': // PF1
  227 + hllapi_pfkey(1);
  228 + break;
  229 +
  230 + case '2': // PF2
  231 + hllapi_pfkey(2);
  232 + break;
  233 +
  234 + case '3': // PF3
  235 + hllapi_pfkey(3);
  236 + break;
  237 +
  238 + case '4': // PF4
  239 + hllapi_pfkey(4);
  240 + break;
  241 +
  242 + case '5': // PF5
  243 + hllapi_pfkey(5);
  244 + break;
  245 +
  246 + case '6': // PF6
  247 + hllapi_pfkey(6);
  248 + break;
  249 +
  250 + case '7': // PF7
  251 + hllapi_pfkey(7);
  252 + break;
  253 +
  254 + case '8': // PF8
  255 + hllapi_pfkey(8);
  256 + break;
  257 +
  258 + case '9': // PF9
  259 + hllapi_pfkey(9);
  260 + break;
  261 +
  262 + case 'a': // PF10
  263 + hllapi_pfkey(10);
  264 + break;
  265 +
  266 + case 'b': // PF11
  267 + hllapi_pfkey(11);
  268 + break;
  269 +
  270 + case 'c': // PF12
  271 + hllapi_pfkey(12);
  272 + break;
  273 + }
  274 +
  275 + buffer = ptr;
  276 +
  277 + }
  278 +
  279 + hllapi_emulate_input(buffer,-1,0);
  280 +
  281 + }
  282 + else
  283 + {
  284 + hllapi_emulate_input(text,szText,0);
  285 + }
  286 +
  287 + free(text);
  288 +
  289 + return 0;
  290 +}
  291 +
... ...
src/plugins/hllapi/hllapi.cbp 0 → 100644
... ... @@ -0,0 +1,84 @@
  1 +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
  2 +<CodeBlocks_project_file>
  3 + <FileVersion major="1" minor="6" />
  4 + <Project>
  5 + <Option title="pw3270 HLLAPI" />
  6 + <Option makefile_is_custom="1" />
  7 + <Option pch_mode="2" />
  8 + <Option compiler="gcc" />
  9 + <Build>
  10 + <Target title="Debug">
  11 + <Option output=".bin/Debug/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />
  12 + <Option object_output=".obj/Debug/" />
  13 + <Option type="1" />
  14 + <Option compiler="gcc" />
  15 + <Compiler>
  16 + <Add option="-g" />
  17 + </Compiler>
  18 + </Target>
  19 + <Target title="Release">
  20 + <Option output=".bin/Release/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />
  21 + <Option object_output=".obj/Release/" />
  22 + <Option type="1" />
  23 + <Option compiler="gcc" />
  24 + <Compiler>
  25 + <Add option="-O2" />
  26 + </Compiler>
  27 + <Linker>
  28 + <Add option="-s" />
  29 + </Linker>
  30 + </Target>
  31 + <Target title="test">
  32 + <Option output=".bin/Debug/testprogram" prefix_auto="1" extension_auto="1" />
  33 + <Option object_output=".obj/Debug/" />
  34 + <Option type="1" />
  35 + <Option compiler="gcc" />
  36 + <Compiler>
  37 + <Add option="-g" />
  38 + </Compiler>
  39 + <Environment>
  40 + <Variable name="LIB3270_CFLAGS" value='&quot;-I../../../src/include&quot;' />
  41 + <Variable name="LIB3270_LIBS" value='&quot;-L../../../.bin/Debug -l3270&quot;' />
  42 + <Variable name="PW3270_LIBS" value='&quot;-L../../../.bin/Debug -lpw3270 -l3270&quot;' />
  43 + </Environment>
  44 + <MakeCommands>
  45 + <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />
  46 + <CompileFile command="$make -f $makefile $file" />
  47 + <Clean command="$make -f $makefile clean$target" />
  48 + <DistClean command="$make -f $makefile distclean$target" />
  49 + <AskRebuildNeeded command="$make -q -f $makefile $target" />
  50 + <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />
  51 + </MakeCommands>
  52 + </Target>
  53 + </Build>
  54 + <Compiler>
  55 + <Add option="-Wall" />
  56 + </Compiler>
  57 + <Unit filename="Makefile.in" />
  58 + <Unit filename="calls.c">
  59 + <Option compilerVar="CC" />
  60 + </Unit>
  61 + <Unit filename="client.h" />
  62 + <Unit filename="hllapi.c">
  63 + <Option compilerVar="CC" />
  64 + </Unit>
  65 + <Unit filename="packets.h" />
  66 + <Unit filename="pluginmain.c">
  67 + <Option compilerVar="CC" />
  68 + </Unit>
  69 + <Unit filename="remote.c">
  70 + <Option compilerVar="CC" />
  71 + </Unit>
  72 + <Unit filename="remotectl.h" />
  73 + <Unit filename="server.h" />
  74 + <Unit filename="testprogram.c">
  75 + <Option compilerVar="CC" />
  76 + </Unit>
  77 + <Extensions>
  78 + <code_completion />
  79 + <envvars />
  80 + <debugger />
  81 + <lib_finder disable_auto="1" />
  82 + </Extensions>
  83 + </Project>
  84 +</CodeBlocks_project_file>
... ...
src/plugins/hllapi/packets.h 0 → 100644
... ... @@ -0,0 +1,152 @@
  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 + * Este programa está nomeado como packets.h 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 + typedef enum _hllapi_packet
  31 + {
  32 + HLLAPI_PACKET_CONNECT,
  33 + HLLAPI_PACKET_DISCONNECT,
  34 + HLLAPI_PACKET_GET_PROGRAM_MESSAGE,
  35 + HLLAPI_PACKET_GET_TEXT_AT_OFFSET,
  36 + HLLAPI_PACKET_GET_TEXT_AT,
  37 + HLLAPI_PACKET_SET_TEXT_AT,
  38 + HLLAPI_PACKET_CMP_TEXT_AT,
  39 + HLLAPI_PACKET_ENTER,
  40 + HLLAPI_PACKET_PFKEY,
  41 + HLLAPI_PACKET_PAKEY,
  42 + HLLAPI_PACKET_SET_CURSOR_POSITION,
  43 + HLLAPI_PACKET_GET_CURSOR_POSITION,
  44 + HLLAPI_PACKET_INPUT_STRING,
  45 + HLLAPI_PACKET_IS_CONNECTED,
  46 + HLLAPI_PACKET_SET_CURSOR,
  47 + HLLAPI_PACKET_GET_CURSOR,
  48 + HLLAPI_PACKET_EMULATE_INPUT,
  49 + HLLAPI_PACKET_ERASE_EOF,
  50 +
  51 + HLLAPI_PACKET_INVALID
  52 +
  53 + } HLLAPI_PACKET;
  54 +
  55 +#pragma pack(1)
  56 +
  57 +struct hllapi_packet_result
  58 +{
  59 + int rc;
  60 +};
  61 +
  62 +struct hllapi_packet_text_result
  63 +{
  64 + int rc;
  65 + char text[1];
  66 +};
  67 +
  68 +struct hllapi_packet_query
  69 +{
  70 + unsigned char packet_id;
  71 +};
  72 +
  73 +struct hllapi_packet_connect
  74 +{
  75 + unsigned char packet_id;
  76 + unsigned char wait;
  77 + char hostname[1];
  78 +};
  79 +
  80 +struct hllapi_packet_keycode
  81 +{
  82 + unsigned char packet_id;
  83 + unsigned short keycode;
  84 +};
  85 +
  86 +struct hllapi_packet_cursor
  87 +{
  88 + unsigned char packet_id;
  89 + unsigned short row;
  90 + unsigned short col;
  91 +};
  92 +
  93 +struct hllapi_packet_text
  94 +{
  95 + unsigned char packet_id;
  96 + char text[1];
  97 +};
  98 +
  99 +struct hllapi_packet_at
  100 +{
  101 + unsigned char packet_id;
  102 + unsigned short row;
  103 + unsigned short col;
  104 + unsigned short len;
  105 +};
  106 +
  107 +struct hllapi_packet_text_at
  108 +{
  109 + unsigned char packet_id;
  110 + unsigned short row;
  111 + unsigned short col;
  112 + char text[1];
  113 +};
  114 +
  115 +struct hllapi_packet_query_at
  116 +{
  117 + unsigned char packet_id;
  118 + unsigned short row;
  119 + unsigned short col;
  120 + unsigned short len;
  121 +};
  122 +
  123 +struct hllapi_packet_wait
  124 +{
  125 + unsigned char packet_id;
  126 + int timeout;
  127 +};
  128 +
  129 +struct hllapi_packet_addr
  130 +{
  131 + unsigned char packet_id;
  132 + unsigned short addr;
  133 +};
  134 +
  135 +struct hllapi_packet_query_offset
  136 +{
  137 + unsigned char packet_id;
  138 + unsigned short addr;
  139 + unsigned short len;
  140 +};
  141 +
  142 +struct hllapi_packet_emulate_input
  143 +{
  144 + unsigned char packet_id;
  145 + unsigned short len;
  146 + unsigned char pasting;
  147 + char text[1];
  148 +};
  149 +
  150 +
  151 +#pragma pack()
  152 +
... ...
src/plugins/hllapi/pipesource.c 0 → 100644
... ... @@ -0,0 +1,385 @@
  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 + * Este programa está nomeado como pipesource.c 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 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 + #include <pw3270.h>
  33 + #include <pw3270/v3270.h>
  34 +
  35 + #include <windows.h>
  36 + #include <stdarg.h>
  37 + #include "remotectl.h"
  38 +
  39 +/*---[ Defines ]----------------------------------------------------------------------------*/
  40 +
  41 + #pragma pack(1)
  42 +
  43 + typedef struct _pipe_source
  44 + {
  45 + GSource gsrc;
  46 + HANDLE hPipe;
  47 +
  48 + enum _PIPE_STATE
  49 + {
  50 + PIPE_STATE_WAITING,
  51 + PIPE_STATE_READ,
  52 + PIPE_STATE_PENDING_READ,
  53 +
  54 + PIPE_STATE_UNDEFINED,
  55 + } state;
  56 +
  57 + OVERLAPPED overlap;
  58 + unsigned char buffer[PIPE_BUFFER_LENGTH+1];
  59 + } pipe_source;
  60 +
  61 + #pragma pack()
  62 +
  63 +/*---[ GSource ]----------------------------------------------------------------------------*/
  64 +
  65 +static void wait_for_client(pipe_source *source)
  66 +{
  67 + set_active(FALSE);
  68 + if(ConnectNamedPipe(source->hPipe,&source->overlap))
  69 + {
  70 + popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));
  71 + return;
  72 + }
  73 +
  74 + switch(GetLastError())
  75 + {
  76 + // The overlapped connection in progress.
  77 + case ERROR_IO_PENDING:
  78 + // trace("%s: ERROR_IO_PENDING",__FUNCTION__);
  79 + source->state = PIPE_STATE_WAITING;
  80 + break;
  81 +
  82 + // Client is already connected, so signal an event.
  83 + case ERROR_PIPE_CONNECTED:
  84 + trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);
  85 + set_active(TRUE);
  86 + if(SetEvent(source->overlap.hEvent))
  87 + break;
  88 +
  89 + // If an error occurs during the connect operation...
  90 + default:
  91 + popup_lasterror("%s", _( "ConnectNamedPipe failed" ));
  92 + }
  93 +
  94 + }
  95 +
  96 + static gboolean IO_prepare(GSource *source, gint *timeout)
  97 + {
  98 + /*
  99 + * Called before all the file descriptors are polled.
  100 + * If the source can determine that it is ready here
  101 + * (without waiting for the results of the poll() call)
  102 + * it should return TRUE.
  103 + *
  104 + * It can also return a timeout_ value which should be the maximum
  105 + * timeout (in milliseconds) which should be passed to the poll() call.
  106 + * The actual timeout used will be -1 if all sources returned -1,
  107 + * or it will be the minimum of all the timeout_ values
  108 + * returned which were >= 0.
  109 + *
  110 + */
  111 + if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  112 + {
  113 + // trace("%s: source=%p",__FUNCTION__,source);
  114 + return TRUE;
  115 + }
  116 +
  117 + *timeout = 10;
  118 + return FALSE;
  119 + }
  120 +
  121 + static gboolean IO_check(GSource *source)
  122 + {
  123 + /*
  124 + * Called after all the file descriptors are polled.
  125 + * The source should return TRUE if it is ready to be dispatched.
  126 + * Note that some time may have passed since the previous prepare
  127 + * function was called, so the source should be checked again here.
  128 + *
  129 + */
  130 + if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  131 + return TRUE;
  132 +
  133 + return FALSE;
  134 + }
  135 +
  136 + static void process_input(pipe_source *source, DWORD cbRead)
  137 + {
  138 + HLLAPI_DATA * data = (HLLAPI_DATA *) source->buffer;
  139 + QUERY * qry = g_malloc0(sizeof(QUERY)+cbRead+1);
  140 +
  141 + qry->hPipe = source->hPipe;
  142 + qry->text = (const gchar *) (qry+1);
  143 +
  144 + if(data->id == HLLAPI_REQUEST_QUERY)
  145 + {
  146 + // HLLAPI query
  147 + qry->cmd = (int) data->func;
  148 + qry->pos = (int) data->rc;
  149 + qry->length = data->value;
  150 + memcpy((gchar *)(qry->text),data->string,qry->length);
  151 + }
  152 + else
  153 + {
  154 + qry->cmd = -1;
  155 + }
  156 +
  157 + enqueue_request(qry);
  158 + }
  159 +
  160 + void request_complete(QUERY *qry, int rc, const gchar *text)
  161 + {
  162 + request_buffer(qry,rc,strlen(text),(const gpointer) text);
  163 + }
  164 +
  165 + void request_status(QUERY *qry, int rc)
  166 + {
  167 + if(rc)
  168 + {
  169 + const gchar *msg = strerror(rc);
  170 + request_buffer(qry, rc, strlen(msg), (const gpointer) msg);
  171 + }
  172 + else
  173 + {
  174 + request_buffer(qry, rc, 0, NULL);
  175 + }
  176 + }
  177 +
  178 + void request_value(QUERY *qry, int rc, unsigned int value)
  179 + {
  180 + HLLAPI_DATA data;
  181 +
  182 + memset(&data,0,sizeof(data));
  183 + data.id = HLLAPI_RESPONSE_VALUE;
  184 + data.func = qry->cmd;
  185 + data.rc = rc;
  186 + data.value = value;
  187 +
  188 +#ifdef WIN32
  189 + {
  190 + DWORD wrote = sizeof(data);
  191 + WriteFile(qry->hPipe,&data,wrote,&wrote,NULL);
  192 + trace("Wrote=%d len=%d",(int) wrote, sizeof(data));
  193 + }
  194 +#endif // WIN32
  195 +
  196 + g_free(qry);
  197 +
  198 +
  199 + }
  200 +
  201 + void request_buffer(QUERY *qry, int rc, size_t szBuffer, const gpointer buffer)
  202 + {
  203 + size_t sz;
  204 + HLLAPI_DATA *data;
  205 +
  206 + if(buffer)
  207 + {
  208 + sz = sizeof(HLLAPI_DATA)+szBuffer;
  209 + data = g_malloc0(sz);
  210 + data->id = HLLAPI_RESPONSE_TEXT;
  211 + memcpy(data->string,buffer,szBuffer);
  212 + }
  213 + else
  214 + {
  215 + sz = sizeof(HLLAPI_DATA);
  216 + data = g_malloc0(sz);
  217 + data->id = HLLAPI_RESPONSE_VALUE;
  218 + }
  219 +
  220 + data->func = qry->cmd;
  221 + data->rc = rc;
  222 + data->value = szBuffer;
  223 +
  224 + trace("rc=%d data->len=%d",rc,(int) szBuffer);
  225 +
  226 +#ifdef WIN32
  227 + {
  228 + DWORD wrote = sz;
  229 + WriteFile(qry->hPipe,data,wrote,&wrote,NULL);
  230 + trace("Wrote=%d len=%d",(int) wrote, (int) sz);
  231 + }
  232 +#endif // WIN32
  233 +
  234 + g_free(data);
  235 + g_free(qry);
  236 +
  237 + }
  238 +
  239 + static void read_input_pipe(pipe_source *source)
  240 + {
  241 + DWORD cbRead = 0;
  242 +
  243 + if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)
  244 + process_input(source,cbRead);
  245 +
  246 + // The read operation is still pending.
  247 + switch(GetLastError())
  248 + {
  249 + case 0:
  250 + break;
  251 +
  252 + case ERROR_IO_PENDING:
  253 + // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);
  254 + source->state = PIPE_STATE_PENDING_READ;
  255 + break;
  256 +
  257 + case ERROR_PIPE_LISTENING:
  258 + // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);
  259 + source->state = PIPE_STATE_READ;
  260 + break;
  261 +
  262 + case ERROR_BROKEN_PIPE:
  263 + trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);
  264 +
  265 + if(!DisconnectNamedPipe(source->hPipe))
  266 + {
  267 + set_active(FALSE);
  268 + popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));
  269 + }
  270 + else
  271 + {
  272 + wait_for_client(source);
  273 + }
  274 + break;
  275 +
  276 + case ERROR_PIPE_NOT_CONNECTED:
  277 + trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);
  278 + set_active(FALSE);
  279 + break;
  280 +
  281 + default:
  282 + if(source->hPipe != INVALID_HANDLE_VALUE)
  283 + popup_lasterror("%s",_( "Error receiving message from pipe" ) );
  284 + }
  285 +
  286 + }
  287 +
  288 + static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer data)
  289 + {
  290 + /*
  291 + * Called to dispatch the event source,
  292 + * after it has returned TRUE in either its prepare or its check function.
  293 + * The dispatch function is passed in a callback function and data.
  294 + * The callback function may be NULL if the source was never connected
  295 + * to a callback using g_source_set_callback(). The dispatch function
  296 + * should call the callback function with user_data and whatever additional
  297 + * parameters are needed for this type of event source.
  298 + */
  299 + BOOL fSuccess;
  300 + DWORD cbRead = 0;
  301 +// DWORD dwErr = 0;
  302 +
  303 + fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );
  304 +
  305 + // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);
  306 +
  307 + switch(((pipe_source *) source)->state)
  308 + {
  309 + case PIPE_STATE_WAITING:
  310 + if(fSuccess)
  311 + {
  312 + trace("Pipe connected (cbRet=%d)",(int) cbRead);
  313 + set_active(TRUE);
  314 + ((pipe_source *) source)->state = PIPE_STATE_READ;
  315 + }
  316 + else
  317 + {
  318 + popup_lasterror("%s", _( "Pipe connection failed" ));
  319 + }
  320 + break;
  321 +
  322 + case PIPE_STATE_READ:
  323 + // trace("Reading pipe (cbRead=%d)",(int) cbRead);
  324 + read_input_pipe( (pipe_source *) source);
  325 + break;
  326 +
  327 + case PIPE_STATE_PENDING_READ:
  328 + if(fSuccess && cbRead > 0)
  329 + process_input((pipe_source *) source,cbRead);
  330 + ((pipe_source *) source)->state = PIPE_STATE_READ;
  331 + break;
  332 +
  333 +//#ifdef DEBUG
  334 +// default:
  335 +// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);
  336 +//#endif
  337 + }
  338 +
  339 + return TRUE;
  340 + }
  341 +
  342 + static void IO_finalize(GSource *source)
  343 + {
  344 +// trace("%s: source=%p",__FUNCTION__,source);
  345 +
  346 + if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)
  347 + {
  348 + CloseHandle(((pipe_source *) source)->hPipe);
  349 + ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;
  350 + }
  351 +
  352 + }
  353 +
  354 + static gboolean IO_closure(gpointer data)
  355 + {
  356 +// trace("%s: data=%p",__FUNCTION__,data);
  357 + return 0;
  358 + }
  359 +
  360 +
  361 + void init_source_pipe(HANDLE hPipe)
  362 + {
  363 + static GSourceFuncs pipe_source_funcs =
  364 + {
  365 + IO_prepare,
  366 + IO_check,
  367 + IO_dispatch,
  368 + IO_finalize,
  369 + IO_closure,
  370 + NULL
  371 + };
  372 +
  373 + pipe_source *source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));
  374 +
  375 + source->hPipe = hPipe;
  376 + source->state = PIPE_STATE_WAITING;
  377 + source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);
  378 +
  379 + g_source_attach((GSource *) source,NULL);
  380 +
  381 + wait_for_client(source);
  382 +
  383 + return;
  384 + }
  385 +
... ...
src/plugins/hllapi/pluginmain.c 0 → 100644
... ... @@ -0,0 +1,818 @@
  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. 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 pluginmain.c 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 + * Agradecimento:
  29 + *
  30 + * Hélio Passos
  31 + *
  32 + */
  33 +
  34 + #include "server.h"
  35 + #include "packets.h"
  36 + #include <lib3270/actions.h>
  37 +
  38 +/*--[ Defines ]--------------------------------------------------------------------------------------*/
  39 +
  40 + #pragma pack(1)
  41 +
  42 + typedef struct _pipe_source
  43 + {
  44 + GSource gsrc;
  45 + HANDLE hPipe;
  46 +
  47 + enum _PIPE_STATE
  48 + {
  49 + PIPE_STATE_WAITING,
  50 + PIPE_STATE_READ,
  51 + PIPE_STATE_PENDING_READ,
  52 + PIPE_STATE_UNDEFINED,
  53 + } state;
  54 +
  55 + OVERLAPPED overlap;
  56 + unsigned char buffer[PIPE_BUFFER_LENGTH+1];
  57 + } pipe_source;
  58 +
  59 + #pragma pack()
  60 +
  61 +
  62 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  63 +
  64 + static const gchar control_char = '@';
  65 +
  66 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  67 +
  68 + static void IO_accept(pipe_source *source)
  69 + {
  70 + set_active(FALSE);
  71 +
  72 + if(ConnectNamedPipe(source->hPipe,&source->overlap))
  73 + {
  74 + popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));
  75 + return;
  76 + }
  77 +
  78 + switch(GetLastError())
  79 + {
  80 + // The overlapped connection in progress.
  81 + case ERROR_IO_PENDING:
  82 + // trace("%s: ERROR_IO_PENDING",__FUNCTION__);
  83 + source->state = PIPE_STATE_WAITING;
  84 + break;
  85 +
  86 + // Client is already connected, so signal an event.
  87 + case ERROR_PIPE_CONNECTED:
  88 + trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);
  89 + set_active(TRUE);
  90 + if(SetEvent(source->overlap.hEvent))
  91 + break;
  92 +
  93 + // If an error occurs during the connect operation...
  94 + default:
  95 + popup_lasterror("%s", _( "ConnectNamedPipe failed" ));
  96 + }
  97 +
  98 + }
  99 +
  100 + static gboolean IO_prepare(GSource *source, gint *timeout)
  101 + {
  102 + /*
  103 + * Called before all the file descriptors are polled.
  104 + * If the source can determine that it is ready here
  105 + * (without waiting for the results of the poll() call)
  106 + * it should return TRUE.
  107 + *
  108 + * It can also return a timeout_ value which should be the maximum
  109 + * timeout (in milliseconds) which should be passed to the poll() call.
  110 + * The actual timeout used will be -1 if all sources returned -1,
  111 + * or it will be the minimum of all the timeout_ values
  112 + * returned which were >= 0.
  113 + *
  114 + */
  115 + if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  116 + return TRUE;
  117 +
  118 + *timeout = 10;
  119 + return FALSE;
  120 + }
  121 +
  122 + static gboolean IO_check(GSource *source)
  123 + {
  124 + /*
  125 + * Called after all the file descriptors are polled.
  126 + * The source should return TRUE if it is ready to be dispatched.
  127 + * Note that some time may have passed since the previous prepare
  128 + * function was called, so the source should be checked again here.
  129 + *
  130 + */
  131 + if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
  132 + return TRUE;
  133 +
  134 + return FALSE;
  135 + }
  136 +
  137 + static void send_text(pipe_source *source, char *text)
  138 + {
  139 + struct hllapi_packet_text *pkt;
  140 + DWORD szBlock;
  141 +
  142 + if(text)
  143 + {
  144 + szBlock = sizeof(struct hllapi_packet_text)+strlen(text);
  145 + pkt = g_malloc0(szBlock);
  146 + pkt->packet_id = 0;
  147 + strcpy(pkt->text,text);
  148 + lib3270_free(text);
  149 + }
  150 + else
  151 + {
  152 + szBlock = sizeof(struct hllapi_packet_text);
  153 + pkt = g_malloc0(szBlock);
  154 + pkt->packet_id = errno ? errno : -1;
  155 + }
  156 +
  157 + WriteFile(source->hPipe,pkt,szBlock,&szBlock,NULL);
  158 +
  159 + g_free(pkt);
  160 + }
  161 +
  162 + static void send_result(pipe_source *source, int rc)
  163 + {
  164 + struct hllapi_packet_result pkt = { rc };
  165 + DWORD wrote = sizeof(pkt);
  166 + WriteFile(source->hPipe,&pkt,wrote,&wrote,NULL);
  167 + }
  168 +
  169 + static void process_input(pipe_source *source, DWORD cbRead)
  170 + {
  171 +
  172 + trace("%s id=%d",__FUNCTION__,((struct hllapi_packet_query *) source->buffer)->packet_id);
  173 +
  174 + switch(((struct hllapi_packet_query *) source->buffer)->packet_id)
  175 + {
  176 + case HLLAPI_PACKET_CONNECT:
  177 + send_result(source,lib3270_connect( lib3270_get_default_session_handle(),
  178 + ((struct hllapi_packet_connect *) source->buffer)->hostname,
  179 + ((struct hllapi_packet_connect *) source->buffer)->wait));
  180 + break;
  181 +
  182 + case HLLAPI_PACKET_DISCONNECT:
  183 + send_result(source,lib3270_disconnect(lib3270_get_default_session_handle()));
  184 + break;
  185 +
  186 + case HLLAPI_PACKET_GET_PROGRAM_MESSAGE:
  187 + send_result(source,lib3270_get_program_message(lib3270_get_default_session_handle()));
  188 + break;
  189 +
  190 + case HLLAPI_PACKET_IS_CONNECTED:
  191 + send_result(source,lib3270_in_tn3270e(lib3270_get_default_session_handle()));
  192 + break;
  193 +
  194 + case HLLAPI_PACKET_ENTER:
  195 + send_result(source,lib3270_enter(lib3270_get_default_session_handle()));
  196 + break;
  197 +
  198 + case HLLAPI_PACKET_ERASE_EOF:
  199 + send_result(source,lib3270_eraseeof(lib3270_get_default_session_handle()));
  200 + break;
  201 +
  202 + case HLLAPI_PACKET_PFKEY:
  203 + send_result(source,lib3270_pfkey( lib3270_get_default_session_handle(),
  204 + ((struct hllapi_packet_keycode *) source->buffer)->keycode));
  205 + break;
  206 +
  207 + case HLLAPI_PACKET_PAKEY:
  208 + send_result(source,lib3270_pakey( lib3270_get_default_session_handle(),
  209 + ((struct hllapi_packet_keycode *) source->buffer)->keycode));
  210 + break;
  211 +
  212 + case HLLAPI_PACKET_SET_CURSOR_POSITION:
  213 + send_result(source,lib3270_set_cursor_position( lib3270_get_default_session_handle(),
  214 + ((struct hllapi_packet_cursor *) source->buffer)->row,
  215 + ((struct hllapi_packet_cursor *) source->buffer)->col));
  216 + break;
  217 +
  218 + case HLLAPI_PACKET_SET_TEXT_AT:
  219 + send_result(source,lib3270_set_text_at( lib3270_get_default_session_handle(),
  220 + ((struct hllapi_packet_text_at *) source->buffer)->row,
  221 + ((struct hllapi_packet_text_at *) source->buffer)->col,
  222 + (unsigned char *) ((struct hllapi_packet_text_at *) source->buffer)->text));
  223 + break;
  224 +
  225 + case HLLAPI_PACKET_GET_TEXT_AT:
  226 + send_text(source,lib3270_get_text_at( lib3270_get_default_session_handle(),
  227 + ((struct hllapi_packet_at *) source->buffer)->row,
  228 + ((struct hllapi_packet_at *) source->buffer)->col,
  229 + ((struct hllapi_packet_at *) source->buffer)->len));
  230 + break;
  231 +
  232 + case HLLAPI_PACKET_GET_TEXT_AT_OFFSET:
  233 + send_text(source,lib3270_get_text( lib3270_get_default_session_handle(),
  234 + ((struct hllapi_packet_query_offset *) source->buffer)->addr,
  235 + ((struct hllapi_packet_query_offset *) source->buffer)->len));
  236 + break;
  237 +
  238 + case HLLAPI_PACKET_CMP_TEXT_AT:
  239 + send_result(source,lib3270_cmp_text_at( lib3270_get_default_session_handle(),
  240 + ((struct hllapi_packet_text_at *) source->buffer)->row,
  241 + ((struct hllapi_packet_text_at *) source->buffer)->col,
  242 + ((struct hllapi_packet_text_at *) source->buffer)->text));
  243 + break;
  244 +
  245 + case HLLAPI_PACKET_INPUT_STRING:
  246 + send_result(source,lib3270_input_string(lib3270_get_default_session_handle(),
  247 + (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text));
  248 + break;
  249 +
  250 + case HLLAPI_PACKET_EMULATE_INPUT:
  251 + send_result(source,lib3270_emulate_input(lib3270_get_default_session_handle(),
  252 + (const char *) ((struct hllapi_packet_emulate_input *) source->buffer)->text,
  253 + (int) ((struct hllapi_packet_emulate_input *) source->buffer)->len,
  254 + (int) ((struct hllapi_packet_emulate_input *) source->buffer)->pasting));
  255 + break;
  256 +
  257 + case HLLAPI_PACKET_SET_CURSOR:
  258 + send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(),
  259 + ((struct hllapi_packet_addr *) source->buffer)->addr));
  260 + break;
  261 +
  262 + case HLLAPI_PACKET_GET_CURSOR:
  263 + send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle()));
  264 + break;
  265 +
  266 +
  267 + default:
  268 + send_result(source, EINVAL);
  269 + g_message("Invalid remote request (id=%d)",source->buffer[0]);
  270 + }
  271 +
  272 + }
  273 +
  274 + static void read_input_pipe(pipe_source *source)
  275 + {
  276 + DWORD cbRead = 0;
  277 +
  278 + if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)
  279 + process_input(source,cbRead);
  280 +
  281 + // The read operation is still pending.
  282 + switch(GetLastError())
  283 + {
  284 + case 0:
  285 + break;
  286 +
  287 + case ERROR_IO_PENDING:
  288 + // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);
  289 + source->state = PIPE_STATE_PENDING_READ;
  290 + break;
  291 +
  292 + case ERROR_PIPE_LISTENING:
  293 + // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);
  294 + source->state = PIPE_STATE_READ;
  295 + break;
  296 +
  297 + case ERROR_BROKEN_PIPE:
  298 + trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);
  299 +
  300 + if(!DisconnectNamedPipe(source->hPipe))
  301 + {
  302 + set_active(FALSE);
  303 + popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));
  304 + }
  305 + else
  306 + {
  307 + IO_accept(source);
  308 + }
  309 + break;
  310 +
  311 + case ERROR_PIPE_NOT_CONNECTED:
  312 + trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);
  313 + set_active(FALSE);
  314 + break;
  315 +
  316 + default:
  317 + if(source->hPipe != INVALID_HANDLE_VALUE)
  318 + popup_lasterror("%s",_( "Error receiving message from pipe" ) );
  319 + }
  320 +
  321 + }
  322 +
  323 + static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer data)
  324 + {
  325 + /*
  326 + * Called to dispatch the event source,
  327 + * after it has returned TRUE in either its prepare or its check function.
  328 + * The dispatch function is passed in a callback function and data.
  329 + * The callback function may be NULL if the source was never connected
  330 + * to a callback using g_source_set_callback(). The dispatch function
  331 + * should call the callback function with user_data and whatever additional
  332 + * parameters are needed for this type of event source.
  333 + */
  334 + BOOL fSuccess;
  335 + DWORD cbRead = 0;
  336 +// DWORD dwErr = 0;
  337 +
  338 + fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );
  339 +
  340 + // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);
  341 +
  342 + switch(((pipe_source *) source)->state)
  343 + {
  344 + case PIPE_STATE_WAITING:
  345 + if(fSuccess)
  346 + {
  347 + trace("Pipe connected (cbRet=%d)",(int) cbRead);
  348 + set_active(TRUE);
  349 + ((pipe_source *) source)->state = PIPE_STATE_READ;
  350 + }
  351 + else
  352 + {
  353 + popup_lasterror("%s", _( "Pipe connection failed" ));
  354 + }
  355 + break;
  356 +
  357 + case PIPE_STATE_READ:
  358 + // trace("Reading pipe (cbRead=%d)",(int) cbRead);
  359 + read_input_pipe( (pipe_source *) source);
  360 + break;
  361 +
  362 + case PIPE_STATE_PENDING_READ:
  363 + if(fSuccess && cbRead > 0)
  364 + process_input((pipe_source *) source,cbRead);
  365 + ((pipe_source *) source)->state = PIPE_STATE_READ;
  366 + break;
  367 +
  368 + case PIPE_STATE_UNDEFINED:
  369 + break;
  370 +
  371 +//#ifdef DEBUG
  372 +// default:
  373 +// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);
  374 +//#endif
  375 + }
  376 +
  377 + return TRUE;
  378 + }
  379 +
  380 + static void IO_finalize(GSource *source)
  381 + {
  382 +// trace("%s: source=%p",__FUNCTION__,source);
  383 +
  384 + if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)
  385 + {
  386 + CloseHandle(((pipe_source *) source)->hPipe);
  387 + ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;
  388 + }
  389 +
  390 + }
  391 +
  392 + static gboolean IO_closure(gpointer data)
  393 + {
  394 +// trace("%s: data=%p",__FUNCTION__,data);
  395 + return 0;
  396 + }
  397 +
  398 + void popup_lasterror(const gchar *fmt, ...)
  399 + {
  400 + char buffer[4096];
  401 + va_list arg_ptr;
  402 + int sz;
  403 + DWORD errcode = GetLastError();
  404 + char *ptr;
  405 + LPVOID lpMsgBuf = 0;
  406 +
  407 + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
  408 +
  409 + for(ptr=lpMsgBuf;*ptr && *ptr != '\n';ptr++);
  410 + *ptr = 0;
  411 +
  412 + va_start(arg_ptr, fmt);
  413 + vsnprintf(buffer,4095,fmt,arg_ptr);
  414 + va_end(arg_ptr);
  415 +
  416 + sz = strlen(buffer);
  417 + snprintf(buffer+sz,4096-sz,": %s\n(rc=%d)",lpMsgBuf,(int) errcode);
  418 +
  419 + printf("%s\n",buffer);
  420 +
  421 +#ifdef DEBUG
  422 + fprintf(stderr,"%s\n",buffer);
  423 + fflush(stderr);
  424 +#endif
  425 +
  426 + LocalFree(lpMsgBuf);
  427 + }
  428 +
  429 + LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window)
  430 + {
  431 + char id;
  432 +
  433 + for(id='A';id < 'Z';id++)
  434 + {
  435 + gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s_%c",pw3270_get_session_name(window),id);
  436 + gchar * ptr;
  437 + HANDLE hPipe;
  438 +
  439 + for(ptr=pipename;*ptr;ptr++)
  440 + *ptr = g_ascii_tolower(*ptr);
  441 +
  442 + hPipe = CreateNamedPipe( TEXT(pipename), // pipe name
  443 + PIPE_ACCESS_DUPLEX | // read/write access
  444 + FILE_FLAG_OVERLAPPED, // overlapped mode
  445 + PIPE_TYPE_MESSAGE | // pipe type
  446 + PIPE_READMODE_MESSAGE | // pipe mode
  447 + PIPE_WAIT, // blocking mode
  448 + 1, // number of instances
  449 + PIPE_BUFFER_LENGTH, // output buffer size
  450 + PIPE_BUFFER_LENGTH, // input buffer size
  451 + NMPWAIT_USE_DEFAULT_WAIT, // client time-out
  452 + NULL); // default security attributes
  453 +
  454 + trace("%s = %p",pipename,hPipe);
  455 + g_free(pipename);
  456 +
  457 + if(hPipe != INVALID_HANDLE_VALUE)
  458 + {
  459 + static GSourceFuncs pipe_source_funcs =
  460 + {
  461 + IO_prepare,
  462 + IO_check,
  463 + IO_dispatch,
  464 + IO_finalize,
  465 + IO_closure,
  466 + NULL
  467 + };
  468 + pipe_source * source;
  469 + gchar * session = g_strdup_printf("%s:%c",pw3270_get_session_name(window),id);
  470 +
  471 + pw3270_set_session_name(window,session);
  472 + g_free(session);
  473 +
  474 + source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));
  475 +
  476 + source->hPipe = hPipe;
  477 + source->state = PIPE_STATE_WAITING;
  478 + source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);
  479 +
  480 + g_source_attach((GSource *) source,NULL);
  481 + IO_accept(source);
  482 +
  483 + return 0;
  484 + }
  485 +
  486 + }
  487 +
  488 + popup_lasterror( "%s", _( "Can´t create remote control pipe" ));
  489 +
  490 + return -1;
  491 + }
  492 +
  493 + LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window)
  494 + {
  495 +
  496 + return 0;
  497 + }
  498 +
  499 +/*
  500 + static void cmd_connectps(QUERY *qry)
  501 + {
  502 + g_message("%s","HLLAPI ConnectPS request received");
  503 + request_status(qry,v3270_set_script(pw3270_get_terminal_widget(NULL),'H',TRUE));
  504 + }
  505 +
  506 + static void cmd_disconnectps(QUERY *qry)
  507 + {
  508 + g_message("%s","HLLAPI DisconnectPS request received");
  509 + request_status(qry,0);
  510 + }
  511 +
  512 + static void cmd_getrevision(QUERY *qry)
  513 + {
  514 + request_complete(qry,0,lib3270_get_revision());
  515 + }
  516 +
  517 + static void cmd_setcursor(QUERY *qry)
  518 + {
  519 + int rc = ENOTCONN;
  520 +
  521 + if(lib3270_connected(qry->hSession))
  522 + {
  523 + trace("%s: pos=%d row=%d col=%d",__FUNCTION__,rc,rc/80,rc%80);
  524 + lib3270_set_cursor_address(qry->hSession,qry->pos -1);
  525 + rc = 0;
  526 + }
  527 +
  528 + request_status(qry,rc);
  529 + }
  530 +
  531 + static void cmd_sendstring(QUERY *qry)
  532 + {
  533 + gchar * text;
  534 + GError * error = NULL;
  535 + gsize bytes_read;
  536 + gsize bytes_written;
  537 + const gchar * charset;
  538 +
  539 + if(!lib3270_connected(qry->hSession))
  540 + {
  541 + request_status(qry,ENOTCONN);
  542 + return;
  543 + }
  544 +
  545 + g_get_charset(&charset);
  546 +
  547 + text = g_convert(qry->text,qry->length,lib3270_get_charset(qry->hSession),charset,&bytes_read,&bytes_written,&error);
  548 + if(text)
  549 + {
  550 + int rc = 0;
  551 +
  552 + if(strchr(text,control_char))
  553 + {
  554 + // Convert control char
  555 + gchar * buffer = text;
  556 + char * ptr;
  557 +
  558 + for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char))
  559 + {
  560 + *(ptr++) = 0;
  561 +
  562 + lib3270_emulate_input(qry->hSession,buffer,-1,0);
  563 +
  564 + switch(*(ptr++))
  565 + {
  566 + case 'P': // Print
  567 + rc = pw3270_print(pw3270_get_terminal_widget(NULL), NULL, GTK_PRINT_OPERATION_ACTION_PRINT, PW3270_SRC_ALL);
  568 + break;
  569 +
  570 + case 'E': // Enter
  571 + lib3270_enter(qry->hSession);
  572 + break;
  573 +
  574 + case 'F': // Erase EOF
  575 + lib3270_eraseeof(qry->hSession);
  576 + break;
  577 +
  578 + case '1': // PF1
  579 + lib3270_pfkey(qry->hSession,1);
  580 + break;
  581 +
  582 + case '2': // PF2
  583 + lib3270_pfkey(qry->hSession,2);
  584 + break;
  585 +
  586 + case '3': // PF3
  587 + lib3270_pfkey(qry->hSession,3);
  588 + break;
  589 +
  590 + case '4': // PF4
  591 + lib3270_pfkey(qry->hSession,4);
  592 + break;
  593 +
  594 + case '5': // PF5
  595 + lib3270_pfkey(qry->hSession,5);
  596 + break;
  597 +
  598 + case '6': // PF6
  599 + lib3270_pfkey(qry->hSession,6);
  600 + break;
  601 +
  602 + case '7': // PF7
  603 + lib3270_pfkey(qry->hSession,7);
  604 + break;
  605 +
  606 + case '8': // PF8
  607 + lib3270_pfkey(qry->hSession,8);
  608 + break;
  609 +
  610 + case '9': // PF9
  611 + lib3270_pfkey(qry->hSession,9);
  612 + break;
  613 +
  614 + case 'a': // PF10
  615 + lib3270_pfkey(qry->hSession,10);
  616 + break;
  617 +
  618 + case 'b': // PF11
  619 + lib3270_pfkey(qry->hSession,11);
  620 + break;
  621 +
  622 + case 'c': // PF12
  623 + lib3270_pfkey(qry->hSession,12);
  624 + break;
  625 + }
  626 +
  627 + }
  628 +
  629 + lib3270_emulate_input(qry->hSession,buffer,-1,0);
  630 +
  631 + }
  632 + else
  633 + {
  634 + lib3270_emulate_input(qry->hSession,text,strlen(text),0);
  635 + }
  636 + g_free(text);
  637 +
  638 + request_status(qry,rc);
  639 +
  640 + return;
  641 + }
  642 +
  643 + request_complete(qry, error->code, error->message);
  644 + g_error_free(error);
  645 +
  646 + }
  647 +
  648 + struct wait
  649 + {
  650 + QUERY * qry;
  651 + time_t end;
  652 + };
  653 +
  654 + static gboolean do_wait(struct wait *w)
  655 + {
  656 + if(lib3270_get_program_message(w->qry->hSession) == LIB3270_MESSAGE_NONE)
  657 + {
  658 + request_status(w->qry,0);
  659 + return FALSE;
  660 + }
  661 +
  662 + if(time(0) > w->end)
  663 + {
  664 + trace("%s: TIMEOUT",__FUNCTION__);
  665 + request_status(w->qry,ETIMEDOUT);
  666 + return FALSE;
  667 + }
  668 +
  669 + return TRUE;
  670 + }
  671 +
  672 + static void cmd_wait(QUERY *qry)
  673 + {
  674 + struct wait *w;
  675 +
  676 + if(lib3270_get_program_message(qry->hSession) == LIB3270_MESSAGE_NONE)
  677 + {
  678 + request_status(qry,0);
  679 + return;
  680 + }
  681 +
  682 + w = g_malloc0(sizeof(struct wait));
  683 + w->qry = qry;
  684 + w->end = time(0)+pw3270_get_integer(pw3270_get_toplevel(),"hllapi","wait",2);
  685 +
  686 + g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) 300, (GSourceFunc) do_wait, w, g_free);
  687 + }
  688 +
  689 + static void cmd_copypstostr(QUERY *qry)
  690 + {
  691 + int rows;
  692 + int cols;
  693 + unsigned short * attr;
  694 + unsigned char * text;
  695 + int rc;
  696 + unsigned char * buffer;
  697 + size_t length;
  698 +
  699 + if(!lib3270_connected(qry->hSession))
  700 + {
  701 + request_status(qry,ENOTCONN);
  702 + return;
  703 + }
  704 +
  705 + lib3270_get_screen_size(qry->hSession,&rows,&cols);
  706 +
  707 + if(qry->pos < 1 || (qry->pos+qry->length) >= (rows*cols))
  708 + {
  709 + request_status(qry,EINVAL);
  710 + return;
  711 + }
  712 +
  713 + qry->pos--;
  714 +
  715 + length = (qry->length * sizeof(unsigned short)) + qry->length + 2;
  716 + text = buffer = g_malloc0(length+1);
  717 + attr = (unsigned short *) (text+qry->length+1);
  718 +
  719 + trace("%s: pos=%d length=%d",__FUNCTION__,qry->pos,qry->length);
  720 + rc = lib3270_get_contents(qry->hSession,qry->pos,qry->pos+(qry->length-1),text,attr);
  721 +
  722 + if(rc)
  723 + {
  724 + request_status(qry,rc);
  725 + }
  726 + else
  727 + {
  728 + const gchar * charset;
  729 + gchar * local;
  730 + gsize bytes_read;
  731 + gsize bytes_written;
  732 + GError * error = NULL;
  733 +
  734 + trace("Text: [%s]",text);
  735 +
  736 + g_get_charset(&charset);
  737 +
  738 + local = g_convert((const gchar *) text,-1,charset,lib3270_get_charset(qry->hSession),&bytes_read,&bytes_written,&error);
  739 +
  740 + if(!local)
  741 + {
  742 + request_complete(qry,error->code,error->message);
  743 + g_error_free(error);
  744 + }
  745 + else
  746 + {
  747 + strncpy((char *) text,(const char *) local,qry->length);
  748 +
  749 + trace("response: [%s] len=%d",buffer,length);
  750 + request_buffer(qry,0,length,buffer);
  751 + g_free(local);
  752 + }
  753 + }
  754 +
  755 + g_free(buffer);
  756 + }
  757 +
  758 + static void cmd_querycursor(QUERY *qry)
  759 + {
  760 + request_value(qry,0,lib3270_get_cursor_address(qry->hSession));
  761 + }
  762 +
  763 + void enqueue_request(QUERY *qry)
  764 + {
  765 + static const struct _cmd
  766 + {
  767 + int cmd;
  768 + void (*exec)(QUERY *qry);
  769 + } cmd[] =
  770 + {
  771 + { HLLAPI_CMD_CONNECTPS, cmd_connectps }, // 1
  772 + { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, // 2
  773 + { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, // 3
  774 + { HLLAPI_CMD_WAIT, cmd_wait }, // 4
  775 +// { HLLAPI_CMD_COPYPS, }, // 5
  776 +// { HLLAPI_CMD_SEARCHPS, }, // 6
  777 + { HLLAPI_CMD_QUERYCURSOR, cmd_querycursor }, // 7
  778 +
  779 + { HLLAPI_CMD_COPYPSTOSTR, cmd_copypstostr }, // 8
  780 +
  781 +// { HLLAPI_CMD_COPYSTRTOPS }, // 15
  782 +
  783 + { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, // 40
  784 +
  785 +// { HLLAPI_CMD_SENDFILE }, // 90
  786 +// { HLLAPI_CMD_RECEIVEFILE },
  787 +
  788 +
  789 + { HLLAPI_CMD_GETREVISION, cmd_getrevision },
  790 + };
  791 +
  792 +
  793 +
  794 + int f;
  795 +
  796 + trace("HLLAPI function %d",(int) qry->cmd);
  797 +
  798 + qry->hSession = lib3270_get_default_session_handle();
  799 +
  800 + for(f=0;f<G_N_ELEMENTS(cmd);f++)
  801 + {
  802 + if(cmd[f].cmd == qry->cmd)
  803 + {
  804 + cmd[f].exec(qry);
  805 + return;
  806 + }
  807 + }
  808 +
  809 + g_warning("Unexpected HLLAPI function %d",(int) qry->cmd);
  810 + request_status(qry,EINVAL);
  811 + }
  812 +
  813 + G_GNUC_INTERNAL void set_active(gboolean on)
  814 + {
  815 + v3270_set_script(pw3270_get_terminal_widget(NULL),'H',on);
  816 + }
  817 +
  818 +*/
... ...
src/plugins/hllapi/remote.c 0 → 100644
... ... @@ -0,0 +1,363 @@
  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 + * Este programa está nomeado como calls.c 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 + #include <lib3270.h>
  31 + #include <malloc.h>
  32 + #include <string.h>
  33 + #include <errno.h>
  34 + #include <stdio.h>
  35 + #include <time.h>
  36 + #include <lib3270/log.h>
  37 +
  38 + #include "client.h"
  39 + #include "packets.h"
  40 +
  41 +/*--[ Globals ]--------------------------------------------------------------------------------------*/
  42 +
  43 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  44 +
  45 + void * hllapi_pipe_init(const char *id)
  46 + {
  47 + HANDLE hPipe = INVALID_HANDLE_VALUE;
  48 + static DWORD dwMode = PIPE_READMODE_MESSAGE;
  49 + char buffer[4096];
  50 + char * name = strdup(id);
  51 + char * ptr;
  52 +
  53 + trace("%s(%s)",__FUNCTION__,id);
  54 +
  55 + for(ptr=name;*ptr;ptr++)
  56 + {
  57 + if(*ptr == ':')
  58 + *ptr = '_';
  59 + }
  60 +
  61 + snprintf(buffer,4095,"\\\\.\\pipe\\%s",name);
  62 +
  63 + free(name);
  64 +
  65 + trace("Opening \"%s\"",buffer);
  66 +
  67 + if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT))
  68 + {
  69 + trace("%s: Pipe not found",__FUNCTION__);
  70 + errno = ENOENT;
  71 + return NULL;
  72 + }
  73 +
  74 + hPipe = CreateFile(buffer,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
  75 +
  76 + if(hPipe == INVALID_HANDLE_VALUE)
  77 + {
  78 + errno = GetLastError();
  79 + return NULL;
  80 + }
  81 +
  82 + if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL))
  83 + {
  84 + errno = GetLastError();
  85 + return NULL;
  86 + }
  87 +
  88 + trace("hPipe=%p",(void *) hPipe);
  89 + return hPipe;
  90 + }
  91 +
  92 + void hllapi_pipe_deinit(void *h)
  93 + {
  94 + trace("%s(%p)",__FUNCTION__,h);
  95 +
  96 + if(!h)
  97 + return;
  98 +
  99 + CloseHandle((HANDLE) h);
  100 + }
  101 +
  102 + const char * hllapi_pipe_get_revision(void)
  103 + {
  104 + return PACKAGE_REVISION;
  105 + }
  106 +
  107 + int hllapi_pipe_connect(void *h, const char *n, int wait)
  108 + {
  109 + struct hllapi_packet_connect * pkt;
  110 + struct hllapi_packet_result response;
  111 + DWORD cbSize;
  112 +
  113 + if(!n)
  114 + n = "";
  115 +
  116 + cbSize = sizeof(struct hllapi_packet_connect)+strlen(n);
  117 + pkt = malloc(cbSize);
  118 +
  119 + pkt->packet_id = HLLAPI_PACKET_CONNECT;
  120 + pkt->wait = (unsigned char) wait;
  121 + strcpy(pkt->hostname,n);
  122 +
  123 + trace("Sending %s",pkt->hostname);
  124 +
  125 + if(!TransactNamedPipe((HANDLE) h,(LPVOID) pkt, cbSize, &response, sizeof(response), &cbSize,NULL))
  126 + {
  127 + errno = GetLastError();
  128 + response.rc = -1;
  129 + }
  130 +
  131 + free(pkt);
  132 +
  133 + return response.rc;
  134 + }
  135 +
  136 + void hllapi_pipe_disconnect(void *h)
  137 + {
  138 + static const struct hllapi_packet_query query = { HLLAPI_PACKET_DISCONNECT };
  139 + struct hllapi_packet_result response;
  140 + DWORD cbSize = sizeof(query);
  141 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  142 + }
  143 +
  144 + LIB3270_MESSAGE hllapi_pipe_get_message(void *h)
  145 + {
  146 + static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_PROGRAM_MESSAGE };
  147 + struct hllapi_packet_result response;
  148 + DWORD cbSize = sizeof(query);
  149 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  150 + return (LIB3270_MESSAGE) response.rc;
  151 + }
  152 +
  153 + char * hllapi_pipe_get_text_at(void *h, int row, int col, int len)
  154 + {
  155 + struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, };
  156 + struct hllapi_packet_text * response;
  157 + DWORD cbSize = sizeof(struct hllapi_packet_text)+len;
  158 + char * text = NULL;
  159 +
  160 + response = malloc(cbSize+2);
  161 + memset(response,0,cbSize+2);
  162 +
  163 + if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(struct hllapi_packet_query_at), &response, cbSize, &cbSize,NULL))
  164 + return NULL;
  165 +
  166 + if(response->packet_id)
  167 + errno = response->packet_id;
  168 + else
  169 + text = strdup(response->text);
  170 +
  171 + free(response);
  172 + return text;
  173 + }
  174 +
  175 + int hllapi_pipe_enter(void *h)
  176 + {
  177 + static const struct hllapi_packet_query query = { HLLAPI_PACKET_ENTER };
  178 + struct hllapi_packet_result response;
  179 + DWORD cbSize = sizeof(query);
  180 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  181 + return response.rc;
  182 + }
  183 +
  184 + int hllapi_pipe_erase_eof(void *h)
  185 + {
  186 + static const struct hllapi_packet_query query = { HLLAPI_PACKET_ERASE_EOF };
  187 + struct hllapi_packet_result response;
  188 + DWORD cbSize = sizeof(query);
  189 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  190 + return response.rc;
  191 + }
  192 +
  193 +
  194 + int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str)
  195 + {
  196 + struct hllapi_packet_text_at * query;
  197 + struct hllapi_packet_result response;
  198 + DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen((const char *) str);
  199 +
  200 + query = malloc(cbSize);
  201 + query->packet_id = HLLAPI_PACKET_SET_TEXT_AT;
  202 + query->row = row;
  203 + query->col = col;
  204 + strcpy(query->text,(const char *) str);
  205 +
  206 + TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
  207 +
  208 + free(query);
  209 +
  210 + return response.rc;
  211 + }
  212 +
  213 + int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text)
  214 + {
  215 + struct hllapi_packet_text_at * query;
  216 + struct hllapi_packet_result response;
  217 + DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen(text);
  218 +
  219 + query = malloc(cbSize);
  220 + query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT;
  221 + query->row = row;
  222 + query->col = col;
  223 + strcpy(query->text,text);
  224 +
  225 + TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
  226 +
  227 + free(query);
  228 +
  229 + return response.rc;
  230 + }
  231 +
  232 + int hllapi_pipe_pfkey(void *h, int key)
  233 + {
  234 + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, key };
  235 + struct hllapi_packet_result response;
  236 + DWORD cbSize = sizeof(query);
  237 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  238 + return response.rc;
  239 + }
  240 +
  241 + int hllapi_pipe_pakey(void *h, int key)
  242 + {
  243 + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, key };
  244 + struct hllapi_packet_result response;
  245 + DWORD cbSize = sizeof(query);
  246 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  247 + return response.rc;
  248 + }
  249 +
  250 + void hllapi_pipe_release_memory(void *p)
  251 + {
  252 + free(p);
  253 + }
  254 +
  255 + int hllapi_pipe_wait_for_ready(void *h, int seconds)
  256 + {
  257 + time_t end = time(0)+seconds;
  258 +
  259 + while(time(0) < end)
  260 + {
  261 + if(!hllapi_pipe_is_connected(h))
  262 + return ENOTCONN;
  263 +
  264 + if(hllapi_pipe_get_message(h) == 0)
  265 + return 0;
  266 + Sleep(250);
  267 + }
  268 +
  269 + return ETIMEDOUT;
  270 + }
  271 +
  272 + int hllapi_pipe_is_connected(void *h)
  273 + {
  274 + static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_CONNECTED };
  275 + struct hllapi_packet_result response;
  276 + DWORD cbSize = sizeof(query);
  277 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  278 + return (LIB3270_MESSAGE) response.rc;
  279 + }
  280 +
  281 + int hllapi_pipe_sleep(void *h, int seconds)
  282 + {
  283 + time_t end = time(0)+seconds;
  284 +
  285 + while(time(0) < end)
  286 + {
  287 + if(!hllapi_pipe_is_connected(h))
  288 + return ENOTCONN;
  289 + Sleep(500);
  290 + }
  291 +
  292 + return 0;
  293 + }
  294 +
  295 + int hllapi_pipe_getcursor(void *h)
  296 + {
  297 + static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR };
  298 + struct hllapi_packet_result response;
  299 + DWORD cbSize = sizeof(query);
  300 +
  301 + trace("%s",__FUNCTION__);
  302 +
  303 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  304 + return (LIB3270_MESSAGE) response.rc;
  305 +
  306 + }
  307 +
  308 + int hllapi_pipe_setcursor(void *h, int baddr)
  309 + {
  310 + struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr };
  311 + struct hllapi_packet_result response;
  312 + DWORD cbSize = sizeof(query);
  313 +
  314 + trace("%s(%d)",__FUNCTION__,query.addr);
  315 +
  316 + TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
  317 + return response.rc;
  318 + }
  319 +
  320 + char * hllapi_pipe_get_text(void *h, int offset, int len)
  321 + {
  322 + struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, offset, len };
  323 + struct hllapi_packet_text * response;
  324 + DWORD cbSize = sizeof(struct hllapi_packet_text)+len;
  325 + char * text = NULL;
  326 +
  327 + trace("cbSize=%d",(int) cbSize);
  328 +
  329 + response = malloc(cbSize+2);
  330 + memset(response,0,cbSize+2);
  331 +
  332 + if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(query), response, cbSize, &cbSize,NULL))
  333 + return NULL;
  334 +
  335 + trace("rc=%d",response->packet_id);
  336 +
  337 + if(response->packet_id)
  338 + errno = response->packet_id;
  339 + else
  340 + text = strdup(response->text);
  341 +
  342 + free(response);
  343 + return text;
  344 + }
  345 +
  346 + int hllapi_pipe_emulate_input(void *h, const char *text, int len, int pasting)
  347 + {
  348 + struct hllapi_packet_emulate_input * query;
  349 + struct hllapi_packet_result response;
  350 + DWORD cbSize = sizeof(struct hllapi_packet_emulate_input)+strlen(text);
  351 +
  352 + query = malloc(cbSize);
  353 + query->packet_id = HLLAPI_PACKET_EMULATE_INPUT;
  354 + query->len = len;
  355 + query->pasting = pasting;
  356 + strcpy(query->text,text);
  357 +
  358 + TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
  359 +
  360 + free(query);
  361 +
  362 + return response.rc;
  363 + }
... ...
src/plugins/hllapi/remotectl.h 0 → 100644
... ... @@ -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. 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 remotectl.h 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 + * Agradecimento:
  29 + *
  30 + * Hélio Passos
  31 + *
  32 + */
  33 +
  34 + #define ENABLE_NLS
  35 + #define GETTEXT_PACKAGE PACKAGE_NAME
  36 +
  37 + #include <libintl.h>
  38 + #include <glib/gi18n.h>
  39 + #include <gtk/gtk.h>
  40 +
  41 + #include <lib3270.h>
  42 + #include <lib3270/log.h>
  43 + #include <pw3270/hllapi.h>
  44 +
  45 + typedef struct _remotequery
  46 + {
  47 +#ifdef WIN32
  48 + HANDLE hPipe; /**< Pipe handle (for response) */
  49 +#endif // WIN32
  50 +
  51 + H3270 * hSession; /**< 3270 Session */
  52 + int cmd; /**< Command */
  53 + int rc; /**< Response status */
  54 +
  55 + int pos;
  56 + unsigned short length; /**< Query string length */
  57 + const gchar * text; /**< Query string */
  58 +
  59 + } QUERY;
  60 +
  61 + G_GNUC_INTERNAL void set_active(gboolean on);
  62 + G_GNUC_INTERNAL void enqueue_request(QUERY *qry);
  63 + G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text);
  64 +
  65 + G_GNUC_INTERNAL void request_status(QUERY *qry, int rc);
  66 + G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value);
  67 + G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer);
  68 +
  69 +// int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc);
  70 +
  71 +
  72 +#ifdef WIN32
  73 +
  74 + #define PIPE_BUFFER_LENGTH 8192
  75 +
  76 + void init_source_pipe(HANDLE hPipe);
  77 + void popup_lasterror(const gchar *fmt, ...);
  78 +
  79 +#endif // WIN32
  80 +
  81 +
  82 +
  83 +
  84 +
  85 +
... ...
src/plugins/hllapi/server.h 0 → 100644
... ... @@ -0,0 +1,51 @@
  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 + * Este programa está nomeado como server.h 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 + #include <lib3270/config.h>
  31 + #define ENABLE_NLS
  32 + #define GETTEXT_PACKAGE PACKAGE_NAME
  33 +
  34 + #include <libintl.h>
  35 + #include <glib/gi18n.h>
  36 + #include <gtk/gtk.h>
  37 +
  38 + #include <lib3270.h>
  39 + #include <lib3270/log.h>
  40 + #include <pw3270.h>
  41 + #include <pw3270/hllapi.h>
  42 +
  43 + #include <windows.h>
  44 +
  45 + #define PIPE_BUFFER_LENGTH HLLAPI_MAXLENGTH+30
  46 +
  47 + #define set_active(x) /* x */
  48 +
  49 +
  50 + G_GNUC_INTERNAL void popup_lasterror(const gchar *fmt, ...);
  51 +
... ...
src/plugins/hllapi/testprogram.c 0 → 100644
... ... @@ -0,0 +1,139 @@
  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 + * Este programa está nomeado como testprogram.c 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 + #include <windows.h>
  31 + #include <stdio.h>
  32 + #include <time.h>
  33 + #include <pw3270/hllapi.h>
  34 +
  35 + #define BUFFER_LENGTH 8000
  36 +
  37 +/*---[ Implement ]--------------------------------------------------------------------------------*/
  38 +
  39 + int main(int numpar, char *param[])
  40 + {
  41 + const char *session = "pw3270:a";
  42 +
  43 + printf("init(%s)=%d\n",session,(int) hllapi_init((LPSTR) session));
  44 + printf("revision=%d\n",(int) hllapi_get_revision());
  45 + printf("connect=%d\n",(int) hllapi_connect("fandezhi.efglobe.com:23",0));
  46 + printf("wait=%d\n",(int) hllapi_wait(3));
  47 + printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");
  48 +
  49 +// printf("disconnect=%d\n",(int) hllapi_disconnect("fandezhi.efglobe.com:23",1));
  50 +
  51 +
  52 + printf("deinit=%d\n",(int) hllapi_deinit());
  53 +
  54 +/*
  55 + DWORD revision;
  56 + int rc;
  57 +
  58 + rc = hllapi_init("");
  59 + if(rc)
  60 + {
  61 + printf("Init exits with rc=%d\n",rc);
  62 + return rc;
  63 + }
  64 +
  65 + if(!hllapi_get_revision(&revision))
  66 + printf("Library revision is %d\n",(int) revision);
  67 +
  68 +
  69 + printf("Deinit exits with rc=%d\n",rc);
  70 + rc = hllapi_deinit();
  71 +*/
  72 + return 0;
  73 + }
  74 +
  75 +/*
  76 + int main(int numpar, char *param[])
  77 + {
  78 + char buffer[BUFFER_LENGTH];
  79 + unsigned short rc;
  80 + unsigned short len;
  81 + unsigned long fn;
  82 +
  83 + static const struct _cmd
  84 + {
  85 + const char * name;
  86 + unsigned short fn;
  87 + const char * arg;
  88 + } cmd[] =
  89 + {
  90 + { "GetRevision", HLLAPI_CMD_GETREVISION, " " },
  91 + { "ConnectPS", HLLAPI_CMD_CONNECTPS, "pw3270A" },
  92 + { "InputString", HLLAPI_CMD_INPUTSTRING, "test" },
  93 +
  94 + };
  95 +
  96 + int f;
  97 +
  98 +
  99 + for(f=0;f< (sizeof(cmd)/sizeof(struct _cmd)); f++)
  100 + {
  101 + len = strlen(cmd[f].arg);
  102 + memcpy(buffer,cmd[f].arg,len);
  103 + hllapi((LPWORD) &cmd[f].fn,buffer,&len,&rc);
  104 + printf("%s exits with rc=%d\n[%s]\n",cmd[f].name,rc,buffer);
  105 + }
  106 +
  107 + len = 80;
  108 + rc = 1040;
  109 + fn = HLLAPI_CMD_COPYPSTOSTR;
  110 + hllapi((LPWORD) &fn,buffer,&len,&rc);
  111 + printf("%s exits with rc=%d\n%s\n","HLLAPI_CMD_COPYPSTOSTR",rc,buffer);
  112 +
  113 + // Performance
  114 + len = strlen(cmd[0].arg);
  115 + memcpy(buffer,cmd[0].arg,len);
  116 + if(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0)
  117 + {
  118 + time_t end = time(0) + 5;
  119 + int qtd = 0;
  120 + do
  121 + {
  122 + qtd++;
  123 + } while(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0 && time(0)<end);
  124 + printf("%d interacoes em 5 segundos (rc=%d)\n",qtd,rc);
  125 +
  126 + }
  127 +
  128 + // Disconnect
  129 + len = 10;
  130 + rc = 1;
  131 + fn = HLLAPI_CMD_DISCONNECTPS;
  132 + *buffer = 0;
  133 + hllapi((LPWORD) &fn,buffer,&len,&rc);
  134 + printf("%s exits with rc=%d\n[%s]\n","HLLAPI_CMD_DISCONNECTPS",rc,buffer);
  135 +
  136 +
  137 + return 0;
  138 + }
  139 +*/
... ...
src/plugins/remotectl/Makefile.in
... ... @@ -1,152 +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., 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   -# licinio@bb.com.br (Licínio Luis Branco)
26   -# kraucer@bb.com.br (Kraucer Fernandes Mazuco)
27   -#
28   -
29   -#---[ Sources ]----------------------------------------------------------------
30   -
31   -MODULE_NAME=remotectl
32   -DEPENDS=*.h ../../include/*.h ../../include/lib3270/*.h Makefile
33   -PLUGIN_SRC=pluginmain.c
34   -HLLAPI_SRC=hllapi.c calls.c remote.c
35   -
36   -#---[ Paths ]------------------------------------------------------------------
37   -
38   -ROOTDIR ?= .
39   -OBJDIR ?= $(ROOTDIR)/.obj
40   -BINDIR ?= $(ROOTDIR)/.bin
41   -BINDBG ?= $(BINDIR)/Debug
42   -BINRLS ?= $(BINDIR)/Release
43   -
44   -OBJDBG = $(OBJDIR)/Debug
45   -OBJRLS = $(OBJDIR)/Release
46   -OBJEXT = o
47   -
48   -#---[ Tools ]------------------------------------------------------------------
49   -
50   -MKDIR=@MKDIR_P@
51   -CC=@CC@
52   -LD=@CC@
53   -MSGCAT=@MSGCAT@
54   -XGETTEXT=@XGETTEXT@
55   -
56   -#---[ Rules ]------------------------------------------------------------------
57   -
58   -DLL_FLAGS=@DLL_FLAGS@
59   -DEBUG_CFLAGS=-DDEBUG=1 -g -Wall
60   -
61   -LIB3270_MODE ?= Default
62   -
63   -ifeq ($(LIB3270_MODE),Debug)
64   - PW3270_LIBS=-L../../../.bin/Debug@DLLDIR@ -lpw3270 -l3270
65   - PW3270_CFLAGS=-I../../../src/include
66   - LIB3270_LIBS=-L../../../.bin/Debug@DLLDIR@ -l3270
67   - LIB3270_CFLAGS=-I../../../src/include
68   -endif
69   -
70   -ifeq ($(LIB3270_MODE),Release)
71   - PW3270_LIBS=-L../../../.bin/Release@DLLDIR@ -lpw3270 -l3270
72   - PW3270_CFLAGS=-I../../../src/include
73   - LIB3270_LIBS=-L../../../.bin/Release@DLLDIR@ -l3270
74   - LIB3270_CFLAGS=-I../../../src/include
75   -endif
76   -
77   -ifeq ($(LIB3270_MODE),Default)
78   - LIB3270_LIBS ?= `pkg-config --libs lib3270`
79   - LIB3270_CFLAGS ?= `pkg-config --cflags lib3270`
80   - PW3270_LIBS ?= `pkg-config --libs pw3270 lib3270`
81   - PW3270_CFLAGS ?= `pkg-config --cflags pw3270 lib3270`
82   -endif
83   -
84   -
85   -GTK_CFLAGS ?= @GTK_CFLAGS@ @GTKMAC_CFLAGS@
86   -GTK_LIBS ?= @GTK_LIBS@ @GTKMAC_LIBS@
87   -
88   -$(OBJDBG)/%.o: %.c $(DEPENDS)
89   - @echo " CC `basename $@`"
90   - @$(MKDIR) `dirname $@`
91   - @$(CC) $(CFLAGS) $(DEBUG_CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
92   -
93   -$(OBJRLS)/%.o: %.c $(DEPENDS)
94   - @echo " CC `basename $@`"
95   - @$(MKDIR) `dirname $@`
96   - @$(CC) $(CFLAGS) $(LIB3270_CFLAGS) $(GTK_CFLAGS) -o $@ -c $<
97   -
98   -
99   -#---[ Release targets ]--------------------------------------------------------
100   -
101   -Release: $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINRLS)/libhllapi@DLLEXT@
102   -
103   -$(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o)
104   - @echo " CCLD `basename $@`"
105   - @$(MKDIR) `dirname $@`
106   - @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS)
107   -
108   -$(BINRLS)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJRLS)/$(SRC).o)
109   - @echo " CCLD `basename $@`"
110   - @$(MKDIR) `dirname $@`
111   - @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @LDLIBFLAGS@ -o $@ $^ $(LIBS)
112   -
113   -#---[ Debug targets ]----------------------------------------------------------
114   -
115   -Debug: $(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@ $(BINDBG)/libhllapi@DLLEXT@
116   -
117   -$(BINDBG)/plugins/$(MODULE_NAME)@DLLEXT@: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o)
118   - @echo " CCLD `basename $@`"
119   - @$(MKDIR) `dirname $@`
120   - @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) -o $@ $^ $(LIBS) $(PW3270_LIBS) $(GTK_LIBS)
121   -
122   -$(BINDBG)/libhllapi@DLLEXT@: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJDBG)/$(SRC).o)
123   - @echo " CCLD `basename $@`"
124   - @$(MKDIR) `dirname $@`
125   - @$(LD) $(DLL_FLAGS) @LDSOFLAGS@ $(LDFLAGS) @LDLIBFLAGS@ -o $@ $^ $(LIBS)
126   -
127   -#---[ Misc targets ]-----------------------------------------------------------
128   -
129   -$(BINDBG)/testprogram@EXEEXT@: testprogram.c $(BINDBG)/libhllapi@DLLEXT@
130   - @echo " CCLD `basename $@`"
131   - @$(MKDIR) `dirname $@`
132   - @$(CC) $(CFLAGS) $(PW3270_CFLAGS) -L$(BINDBG) $(DEBUG_CFLAGS) -lhllapi -o $@ testprogram.c
133   -
134   -test: $(BINDBG)/testprogram@EXEEXT@
135   -
136   -run: $(BINDBG)/testprogram@EXEEXT@
137   - @cd $(BINDBG) ; ./testprogram@EXEEXT@
138   -
139   -install: $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@
140   - @$(MKDIR) $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugins
141   - @$(INSTALL_PROGRAM) $(BINRLS)/plugins/$(MODULE_NAME)@DLLEXT@ $(DESTDIR)$(libdir)/$(PACKAGE_NAME)-plugins
142   -
143   -$(DEBDIR)/$(MODULE_NAME).install: Makefile
144   - @$(MKDIR) `dirname $@`
145   - @rm -f $@
146   - @echo $(libdir)/$(PACKAGE_NAME)-plugins/$(MODULE_NAME)@DLLEXT@ > $@
147   -
148   -clean:
149   - @rm -fr $(OBJDIR)
150   - @rm -fr $(BINDIR)
151   - @rm -f testprogram@EXEEXT@
152   - @find . -name "*~" -exec rm -f {} \;
src/plugins/remotectl/calls.c
... ... @@ -1,436 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como calls.c 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   - #include <windows.h>
31   - #include <lib3270.h>
32   - #include <malloc.h>
33   - #include <string.h>
34   - #include <errno.h>
35   - #include <pw3270/hllapi.h>
36   - #include <stdio.h>
37   - #include <lib3270/log.h>
38   - #include "client.h"
39   -
40   - #undef trace
41   - #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } }
42   -
43   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
44   -
45   - HMODULE hModule = NULL;
46   - void * hSession = NULL;
47   -
48   - static void * (*session_new)(const char *model) = NULL;
49   - static void (*session_free)(void *h) = NULL;
50   - static const char * (*get_revision)(void) = NULL;
51   - static int (*host_connect)(void *h,const char *n, int wait) = NULL;
52   - static int (*host_is_connected)(void *h) = NULL;
53   - static int (*wait_for_ready)(void *h, int seconds) = NULL;
54   - static void (*host_disconnect)(void *h) = NULL;
55   - static int (*script_sleep)(void *h, int seconds) = NULL;
56   - static LIB3270_MESSAGE (*get_message)(void *h) = NULL;
57   - static char * (*get_text)(void *h, int row, int col, int len) = NULL;
58   - static char * (*get_text_at_offset)(void *h, int offset, int len) = NULL;
59   -
60   - static void * (*release_memory)(void *p) = NULL;
61   - static int (*action_enter)(void *h) = NULL;
62   - static int (*set_text_at)(void *h, int row, int col, const unsigned char *str) = NULL;
63   - static int (*cmp_text_at)(void *h, int row, int col, const char *text) = NULL;
64   - static int (*pfkey)(void *hSession, int key) = NULL;
65   - static int (*pakey)(void *hSession, int key) = NULL;
66   - static int (*getcursor)(void *hSession) = NULL;
67   - static int (*setcursor)(void *hSession, int baddr) = NULL;
68   -
69   - static const struct _entry_point
70   - {
71   - void **call;
72   - void * pipe;
73   - const char * name;
74   - } entry_point[] =
75   - {
76   - { (void **) &session_new, (void *) hllapi_pipe_init, "lib3270_session_new" },
77   - { (void **) &session_free, (void *) hllapi_pipe_deinit, "lib3270_session_free" },
78   - { (void **) &get_revision, (void *) hllapi_pipe_get_revision, "lib3270_get_revision" },
79   - { (void **) &host_connect, (void *) hllapi_pipe_connect, "lib3270_connect" },
80   - { (void **) &host_disconnect, (void *) hllapi_pipe_disconnect, "lib3270_disconnect" },
81   - { (void **) &host_is_connected, (void *) hllapi_pipe_is_connected, "lib3270_in_tn3270e" },
82   - { (void **) &wait_for_ready, (void *) hllapi_pipe_wait_for_ready, "lib3270_wait_for_ready" },
83   - { (void **) &script_sleep, (void *) hllapi_pipe_sleep, "lib3270_wait" },
84   - { (void **) &get_message, (void *) hllapi_pipe_get_message, "lib3270_get_program_message" },
85   - { (void **) &get_text, (void *) hllapi_pipe_get_text_at, "lib3270_get_text_at" },
86   - { (void **) &release_memory, (void *) hllapi_pipe_release_memory, "lib3270_free" },
87   - { (void **) &action_enter, (void *) hllapi_pipe_enter, "lib3270_enter" },
88   - { (void **) &set_text_at, (void *) hllapi_pipe_set_text_at, "lib3270_set_string_at" },
89   - { (void **) &cmp_text_at, (void *) hllapi_pipe_cmp_text_at, "lib3270_cmp_text_at" },
90   - { (void **) &pfkey, (void *) hllapi_pipe_pfkey, "lib3270_pfkey" },
91   - { (void **) &pakey, (void *) hllapi_pipe_pakey, "lib3270_pakey" },
92   - { (void **) &setcursor, (void *) hllapi_pipe_setcursor, "lib3270_set_cursor_address" },
93   - { (void **) &getcursor, (void *) hllapi_pipe_getcursor, "lib3270_get_cursor_address" },
94   - { (void **) &get_text_at_offset, (void *) hllapi_pipe_get_text, "lib3270_get_text" },
95   - { NULL, NULL }
96   - };
97   -
98   -// http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx
99   -#ifndef LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
100   - #define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000
101   -#endif // LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
102   -
103   -#ifndef LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
104   - #define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100
105   -#endif // LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
106   -
107   -/*--[ Implement ]------------------------------------------------------------------------------------*/
108   -
109   - __declspec (dllexport) DWORD __stdcall hllapi_init(LPSTR mode)
110   - {
111   - if(!mode)
112   - return EINVAL;
113   -
114   - trace("%s(%s)",__FUNCTION__,(char *) mode);
115   -
116   - if(mode && *mode)
117   - {
118   - // Get pointers to the pipe based calls
119   - int f;
120   -
121   - trace("%s: Loading pipe based calls",__FUNCTION__);
122   - for(f=0;entry_point[f].name;f++)
123   - *entry_point[f].call = entry_point[f].pipe;
124   -
125   - }
126   - else
127   - {
128   - // Direct mode, load lib3270.dll, get pointers to the calls
129   - static const char *dllname = "lib3270.dll." PACKAGE_VERSION;
130   -
131   - int f;
132   - HMODULE kernel;
133   - HANDLE cookie = NULL;
134   - DWORD rc;
135   - HANDLE (*AddDllDirectory)(PCWSTR NewDirectory);
136   - BOOL (*RemoveDllDirectory)(HANDLE Cookie);
137   - UINT errorMode;
138   - char datadir[4096];
139   -
140   - trace("hModule=%p",hModule);
141   - if(hModule)
142   - return EBUSY;
143   -
144   - kernel = LoadLibrary("kernel32.dll");
145   - AddDllDirectory = (HANDLE (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory");
146   - RemoveDllDirectory = (BOOL (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory");
147   -
148   - // Notify user in case of error loading protocol DLL
149   - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx
150   - errorMode = SetErrorMode(1);
151   -
152   - memset(datadir,' ',4095);
153   - datadir[4095] = 0;
154   -
155   - if(hllapi_get_datadir(datadir))
156   - {
157   - char buffer[4096];
158   - wchar_t path[4096];
159   -
160   - mbstowcs(path, datadir, 4095);
161   - trace("Datadir=[%s] AddDllDirectory=%p RemoveDllDirectory=%p\n",datadir,AddDllDirectory,RemoveDllDirectory);
162   - if(AddDllDirectory)
163   - cookie = AddDllDirectory(path);
164   -
165   -#ifdef DEBUG
166   - snprintf(buffer,4096,"%s\\.bin\\Debug\\%s",datadir,dllname);
167   -#else
168   - snprintf(buffer,4096,"%s\\%s",datadir,dllname);
169   -#endif // DEBUG
170   -
171   - hModule = LoadLibrary(buffer);
172   -
173   - trace("%s hModule=%p rc=%d",buffer,hModule,(int) GetLastError());
174   -
175   - if(hModule == NULL)
176   - {
177   - // Enable DLL error popup and try again with full path
178   - SetErrorMode(0);
179   - hModule = LoadLibraryEx(buffer,NULL,LOAD_LIBRARY_SEARCH_DEFAULT_DIRS|LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
180   - }
181   -
182   - rc = GetLastError();
183   -
184   - trace("%s hModule=%p rc=%d",buffer,hModule,(int) rc);
185   - }
186   - else
187   - {
188   - hModule = LoadLibrary(dllname);
189   - rc = GetLastError();
190   - }
191   -
192   - SetErrorMode(errorMode);
193   -
194   - trace("%s hModule=%p rc=%d",dllname,hModule,(int) rc);
195   -
196   - if(cookie && RemoveDllDirectory)
197   - RemoveDllDirectory(cookie);
198   -
199   - if(kernel)
200   - FreeLibrary(kernel);
201   -
202   - if(!hModule)
203   - return rc;
204   -
205   - // Get library entry pointers
206   - for(f=0;entry_point[f].name;f++)
207   - {
208   - void *ptr = (void *) GetProcAddress(hModule,entry_point[f].name);
209   -
210   - trace("%d %s=%p\n",f,entry_point[f].name,ptr);
211   -
212   - if(!ptr)
213   - {
214   - fprintf(stderr,"Can´t load \"%s\"\n",entry_point[f].name);
215   - hllapi_deinit();
216   - return ENOENT;
217   - }
218   - *entry_point[f].call = ptr;
219   - }
220   -
221   - }
222   - // Get session handle
223   - hSession = session_new((const char *) mode);
224   - trace("%s ok hSession=%p\n",__FUNCTION__,hSession);
225   -
226   - return hSession ? 0 : -1;
227   - }
228   -
229   - __declspec (dllexport) DWORD __stdcall hllapi_deinit(void)
230   - {
231   - int f;
232   -
233   - // Release session
234   - if(hSession && session_free)
235   - session_free(hSession);
236   -
237   - for(f=0;entry_point[f].name;f++)
238   - *entry_point[f].call = NULL;
239   -
240   - if(hModule != NULL)
241   - {
242   - FreeLibrary(hModule);
243   - hModule = NULL;
244   - }
245   -
246   - return 0;
247   - }
248   -
249   - __declspec (dllexport) DWORD __stdcall hllapi_get_revision(void)
250   - {
251   - if(!get_revision)
252   - return 0;
253   - return (DWORD) atoi(get_revision());
254   - }
255   -
256   - __declspec (dllexport) DWORD __stdcall hllapi_connect(LPSTR uri, WORD wait)
257   - {
258   - if(!(host_connect && hSession && uri))
259   - return EINVAL;
260   -
261   - return host_connect(hSession,uri,wait);
262   - }
263   -
264   - __declspec (dllexport) DWORD __stdcall hllapi_is_connected(void)
265   - {
266   - if(!(host_is_connected && hSession))
267   - return EINVAL;
268   -
269   - return host_is_connected(hSession);
270   - }
271   -
272   - __declspec (dllexport) DWORD __stdcall hllapi_disconnect(void)
273   - {
274   - if(!(host_disconnect && hSession))
275   - return EINVAL;
276   -
277   - host_disconnect(hSession);
278   -
279   - return 0;
280   - }
281   -
282   - __declspec (dllexport) DWORD __stdcall hllapi_wait_for_ready(WORD seconds)
283   - {
284   - if(!(wait_for_ready && hSession))
285   - return EINVAL;
286   -
287   - trace("%s seconds=%d\n", __FUNCTION__, (int) seconds);
288   -
289   - return (DWORD) wait_for_ready(hSession,(int) seconds);
290   - }
291   -
292   - __declspec (dllexport) DWORD __stdcall hllapi_wait(WORD seconds)
293   - {
294   - if(!(script_sleep && hSession))
295   - return EINVAL;
296   -
297   - return (DWORD) script_sleep(hSession,(int) seconds);
298   - }
299   -
300   - __declspec (dllexport) DWORD __stdcall hllapi_get_message_id(void)
301   - {
302   - if(!(get_message && hSession))
303   - return EINVAL;
304   - return (DWORD) get_message(hSession);
305   - }
306   -
307   - __declspec (dllexport) DWORD __stdcall hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)
308   - {
309   - char * text;
310   - int len;
311   -
312   - if(!(get_text && release_memory && hSession))
313   - return EINVAL;
314   -
315   - trace("%s row=%d col=%d buffer=%p",__FUNCTION__,row,col,buffer);
316   - len = strlen(buffer);
317   -
318   - trace(" len=%d",len);
319   -
320   - text = get_text(hSession,row,col,len);
321   -
322   - trace(" text=%p errno=%d %s\n",text,errno,strerror(errno));
323   -
324   - if(!text)
325   - return EINVAL;
326   -
327   - strncpy(buffer,text,len);
328   - release_memory(text);
329   -
330   - trace("text:\n%s\n",buffer);
331   -
332   - return 0;
333   - }
334   -
335   - __declspec (dllexport) DWORD __stdcall hllapi_enter(void)
336   - {
337   - if(!(action_enter && hSession))
338   - return EINVAL;
339   -
340   - return (DWORD) action_enter(hSession);
341   - }
342   -
343   - __declspec (dllexport) DWORD __stdcall hllapi_set_text_at(WORD row, WORD col, LPSTR text)
344   - {
345   - if(!(set_text_at && hSession))
346   - return EINVAL;
347   -
348   - return (DWORD) set_text_at(hSession,row,col,(const unsigned char *) text);
349   - }
350   -
351   - __declspec (dllexport) DWORD __stdcall hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)
352   - {
353   - if(!(cmp_text_at && hSession))
354   - return EINVAL;
355   -
356   - return (DWORD) cmp_text_at(hSession,row,col,(const char *) text);
357   - }
358   -
359   - __declspec (dllexport) DWORD __stdcall hllapi_pfkey(WORD key)
360   - {
361   - if(!(pfkey && hSession))
362   - return EINVAL;
363   -
364   - return (DWORD) pfkey(hSession,key);
365   - }
366   -
367   - __declspec (dllexport) DWORD __stdcall hllapi_pakey(WORD key)
368   - {
369   - if(!(pfkey && hSession))
370   - return EINVAL;
371   -
372   - return (DWORD) pakey(hSession,key);
373   - }
374   -
375   - __declspec (dllexport) DWORD __stdcall hllapi_get_datadir(LPSTR datadir)
376   - {
377   - HKEY hKey = 0;
378   - unsigned long datalen = strlen(datadir);
379   -
380   - *datadir = 0;
381   -
382   - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\pw3270",0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS)
383   - {
384   - unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
385   - if(RegQueryValueExA(hKey,"datadir",NULL,&datatype,(LPBYTE) datadir,&datalen) != ERROR_SUCCESS)
386   - *datadir = 0;
387   - RegCloseKey(hKey);
388   - }
389   -
390   - return *datadir;
391   - }
392   -
393   - __declspec (dllexport) DWORD __stdcall hllapi_setcursor(WORD pos)
394   - {
395   - if(!(setcursor && hSession))
396   - return EINVAL;
397   - trace("%s(%d)",__FUNCTION__,pos);
398   - return setcursor(hSession,pos-1);
399   - }
400   -
401   - __declspec (dllexport) DWORD __stdcall hllapi_getcursor()
402   - {
403   - if(!(getcursor && hSession))
404   - return -EINVAL;
405   - return getcursor(hSession)+1;
406   - }
407   -
408   - __declspec (dllexport) DWORD __stdcall hllapi_get_screen(WORD pos, LPSTR buffer, WORD len)
409   - {
410   - char *text;
411   -
412   - trace("%s(%d,%d)",__FUNCTION__,pos,len);
413   -
414   - if(len < 0)
415   - len = strlen(buffer);
416   -
417   - if(!(get_text_at_offset && hSession))
418   - return EINVAL;
419   -
420   - if(len > strlen(buffer))
421   - len = strlen(buffer);
422   -
423   - trace("len=%d",len);
424   - text = get_text_at_offset(hSession,pos-1,len);
425   -
426   - trace("text=\n%s\n",text);
427   -
428   - if(!text)
429   - return -1;
430   -
431   - memcpy(buffer,text,len);
432   -
433   - release_memory(text);
434   -
435   - return 0;
436   - }
src/plugins/remotectl/client.h
... ... @@ -1,61 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como private.h 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   - #include <windows.h>
31   - #include <pw3270/hllapi.h>
32   -
33   - #ifndef ETIMEDOUT
34   - #define ETIMEDOUT 1238
35   - #endif // ETIMEDOUT
36   -
37   - #define PIPE_BUFFER_LENGTH 8192
38   -
39   - #define set_active(x) /* x */
40   -
41   - void * hllapi_pipe_init(const char *id);
42   - void hllapi_pipe_deinit(void *h);
43   - const char * hllapi_pipe_get_revision(void);
44   - void hllapi_pipe_release_memory(void *p);
45   - int hllapi_pipe_connect(void *h, const char *n, int wait);
46   - void hllapi_pipe_disconnect(void *h);
47   - LIB3270_MESSAGE hllapi_pipe_get_message(void *h);
48   - char * hllapi_pipe_get_text_at(void *h, int row, int col, int len);
49   - char * hllapi_pipe_get_text(void *h, int offset, int len);
50   - int hllapi_pipe_enter(void *h);
51   - int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str);
52   - int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text);
53   - int hllapi_pipe_pfkey(void *h, int key);
54   - int hllapi_pipe_pakey(void *h, int key);
55   - int hllapi_pipe_wait_for_ready(void *h, int seconds);
56   - int hllapi_pipe_sleep(void *h, int seconds);
57   - int hllapi_pipe_is_connected(void *h);
58   - int hllapi_pipe_getcursor(void *h);
59   - int hllapi_pipe_setcursor(void *h, int baddr);
60   -
61   -
src/plugins/remotectl/hllapi.c
... ... @@ -1,354 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como hllapi.c 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   - #include <lib3270.h>
31   - #include <malloc.h>
32   - #include <string.h>
33   - #include <errno.h>
34   - #include <pw3270/hllapi.h>
35   - #include <stdio.h>
36   - #include <lib3270/log.h>
37   -
38   - #undef trace
39   - #define trace( fmt, ... ) { FILE *out = fopen("c:\\Users\\Perry\\hllapi.log","a"); if(out) { fprintf(out, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fclose(out); } }
40   -
41   -/*--[ Prototipes ]-----------------------------------------------------------------------------------*/
42   -
43   - static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc);
44   - static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc);
45   - static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc);
46   - static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc);
47   -
48   - static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
49   - static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc);
50   -
51   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
52   -
53   - static const struct _hllapi_call
54   - {
55   - unsigned long func;
56   - int (*exec)(char *buffer, unsigned short *length, unsigned short *rc);
57   - } hllapi_call[] =
58   - {
59   - { HLLAPI_CMD_CONNECTPS, connect_ps },
60   - { HLLAPI_CMD_DISCONNECTPS, disconnect_ps },
61   - { HLLAPI_CMD_GETREVISION, get_library_revision },
62   - { HLLAPI_CMD_QUERYCURSOR, get_cursor_position },
63   - { HLLAPI_CMD_SETCURSOR, set_cursor_position },
64   - { HLLAPI_CMD_COPYPSTOSTR, copy_ps_to_str },
65   - };
66   -
67   -/*--[ Implement ]------------------------------------------------------------------------------------*/
68   -
69   -#ifdef _WIN32
70   - __declspec (dllexport) int __stdcall hllapi(LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)
71   -#else
72   - LIB3270_EXPORT int hllapi(const unsigned long *func, char *buffer, unsigned short *length, unsigned short *rc)
73   -#endif // _WIN32
74   -{
75   - int f;
76   -
77   - trace("%s(%d)",__FUNCTION__,*func);
78   -
79   - for(f=0;f< (sizeof (hllapi_call) / sizeof ((hllapi_call)[0]));f++)
80   - {
81   - if(hllapi_call[f].func == *func)
82   - return hllapi_call[f].exec(buffer,length,rc);
83   - }
84   -
85   - *rc = HLLAPI_STATUS_BAD_PARAMETER;
86   -
87   - return *rc;
88   -}
89   -
90   -static int connect_ps(char *buffer, unsigned short *length, unsigned short *rc)
91   -{
92   - char *tempbuffer = NULL;
93   -
94   - trace("%s: len=%d buflen=%d",__FUNCTION__,*length,strlen(buffer));
95   -
96   - if(strlen(buffer) > *length)
97   - buffer[*length] = 0;
98   -
99   - if(!strrchr(buffer,':'))
100   - {
101   - int sz = strlen(buffer);
102   -
103   - tempbuffer = malloc(sz+2);
104   - strcpy(tempbuffer,buffer);
105   - tempbuffer[sz-1] = ':';
106   - tempbuffer[sz] = buffer[sz-1];
107   - tempbuffer[sz+1] = 0;
108   - buffer = tempbuffer;
109   - }
110   -
111   - if(hllapi_init(buffer) == 0)
112   - *rc = HLLAPI_STATUS_SUCESS;
113   - else
114   - *rc = HLLAPI_STATUS_UNAVAILABLE;
115   -
116   - if(tempbuffer)
117   - free(tempbuffer);
118   -
119   - return 0;
120   -}
121   -
122   -static int disconnect_ps(char *buffer, unsigned short *length, unsigned short *rc)
123   -{
124   - *rc = hllapi_deinit();
125   - return 0;
126   -}
127   -
128   -static int get_library_revision(char *buffer, unsigned short *length, unsigned short *rc)
129   -{
130   - *rc = hllapi_get_revision();
131   - return 0;
132   -}
133   -
134   -static int get_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)
135   -{
136   - int pos = hllapi_getcursor();
137   -
138   - trace("%s(%d)",__FUNCTION__,pos);
139   -
140   - if(pos < 0)
141   - return -1;
142   -
143   - *rc = pos;
144   - return 0;
145   -}
146   -
147   -static int set_cursor_position(char *buffer, unsigned short *length, unsigned short *rc)
148   -{
149   - trace("%s(%d)",__FUNCTION__,*rc);
150   - *rc = hllapi_setcursor(*rc);
151   - return 0;
152   -}
153   -
154   -static int copy_ps_to_str(char *buffer, unsigned short *length, unsigned short *rc)
155   -{
156   - // Length Length of the target data string.
157   - // PS Position Position within the host presentation space of the first byte in your target data string.
158   - return hllapi_get_screen(*rc,buffer,*length);
159   -}
160   -
161   -/*
162   - static int cmd_connect_ps(const char *name)
163   - {
164   -#ifdef WIN32
165   -
166   - static DWORD dwMode = PIPE_READMODE_MESSAGE;
167   - char PipeName[4096];
168   -
169   - if(hPipe != INVALID_HANDLE_VALUE)
170   - return 0;
171   -
172   - snprintf(PipeName,4095,"\\\\.\\pipe\\%s",name);
173   -
174   - if(!WaitNamedPipe(PipeName,NMPWAIT_USE_DEFAULT_WAIT))
175   - return ENOENT;
176   -
177   - hPipe = CreateFile(PipeName,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
178   -
179   - if(hPipe == INVALID_HANDLE_VALUE)
180   - return GetLastError();
181   -
182   - if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL))
183   - return GetLastError();
184   -
185   - trace("Pipe %ld open",(unsigned long) hPipe);
186   -#else
187   -
188   - #error Not implemented
189   -
190   -#endif // WIN32
191   -
192   - return 0;
193   - }
194   -
195   -
196   - static char * run_query(unsigned long func, const char *arg, size_t *length, unsigned short *rc)
197   - {
198   - char *outBuffer = NULL;
199   -
200   -#ifdef WIN32
201   -
202   - if(hPipe == INVALID_HANDLE_VALUE)
203   - {
204   - trace("%s: Invalid pipe handle",__FUNCTION__);
205   - *rc = EPERM;
206   - }
207   - else
208   - {
209   - HLLAPI_DATA *buffer = malloc(HLLAPI_MAXLENGTH+1);
210   - DWORD cbSize = sizeof(HLLAPI_DATA) + *length;
211   - HLLAPI_DATA *data = malloc(cbSize+1);
212   -
213   - memset(buffer,0,HLLAPI_MAXLENGTH);
214   -
215   - data->id = HLLAPI_REQUEST_QUERY;
216   - data->func = func;
217   - data->rc = *rc;
218   - data->value = *length;
219   -
220   - if(arg && *length > 0)
221   - memcpy(data->string,arg,*length);
222   -
223   - memset(buffer,0,HLLAPI_MAXLENGTH);
224   -
225   - if(!TransactNamedPipe(hPipe,(LPVOID) data,cbSize,buffer,HLLAPI_MAXLENGTH,&cbSize,NULL))
226   - {
227   - trace("Error %d in TransactNamedPipe",(int) GetLastError());
228   - *rc = GetLastError();
229   - }
230   - else
231   - {
232   - *rc = buffer->rc;
233   - *length = buffer->value;
234   -
235   - trace("buffer->id=%d buffer->value=%d rc=%d",buffer->id,buffer->value,buffer->rc);
236   -
237   - if(buffer->value > 0 && buffer->id == HLLAPI_RESPONSE_TEXT)
238   - {
239   - outBuffer = malloc(buffer->value+1);
240   - memcpy(outBuffer,buffer->string,buffer->value);
241   - outBuffer[buffer->value] = 0;
242   -
243   - trace("outBuffer=[%s]",outBuffer);
244   - }
245   - }
246   -
247   - free(data);
248   - free(buffer);
249   - }
250   -
251   -#else
252   -
253   - #error NOT IMPLEMENTED
254   -
255   -#endif // WIN32
256   -
257   - return outBuffer;
258   - }
259   -
260   - static void copyString(char *str, unsigned short *length, const char *msg)
261   - {
262   - size_t len = strlen(msg);
263   -
264   - if(len > *length)
265   - len = *length;
266   - else
267   - *length = len;
268   -
269   - memcpy(str,msg,*length);
270   - }
271   -
272   -#ifdef _WIN32
273   - __declspec (dllexport) int __stdcall hllapi(LPWORD func, LPSTR buffer, LPWORD length, LPWORD rc)
274   -#else
275   - LIB3270_EXPORT int hllapi(const unsigned long *func, char *buffer, unsigned short *length, unsigned short *rc)
276   -#endif // _WIN32
277   - {
278   - char * inBuffer = NULL;
279   - char * outBuffer = NULL;
280   - size_t szOutBuffer;
281   -
282   - if(*length < 0 || *length > HLLAPI_MAXLENGTH)
283   - {
284   - *rc = EINVAL;
285   - return 0;
286   - }
287   -
288   - szOutBuffer = (size_t) *length;
289   -
290   - // Copy input argument
291   - if(*length)
292   - {
293   - inBuffer = malloc(*length+1);
294   - memcpy(inBuffer,buffer,*length);
295   - inBuffer[*length] = 0;
296   - }
297   -
298   - // Clear output buffer
299   - memset(buffer,' ',*length);
300   - buffer[*length] = 0;
301   -
302   - switch(*func)
303   - {
304   - case HLLAPI_CMD_CONNECTPS:
305   - *rc = cmd_connect_ps(inBuffer);
306   - if(!*rc)
307   - {
308   - outBuffer = run_query(*func, inBuffer, &szOutBuffer, rc);
309   - if(*rc)
310   - {
311   - trace("Closing pipe rc=%d",*rc);
312   - CloseHandle(hPipe);
313   - hPipe = INVALID_HANDLE_VALUE;
314   - }
315   - }
316   - break;
317   -
318   - case HLLAPI_CMD_DISCONNECTPS:
319   -#ifdef WIN32
320   - if(hPipe == INVALID_HANDLE_VALUE)
321   - {
322   - *rc = EINVAL;
323   - }
324   - else
325   - {
326   - outBuffer = run_query(*func, inBuffer, &szOutBuffer, rc);
327   - CloseHandle(hPipe);
328   - hPipe = INVALID_HANDLE_VALUE;
329   - }
330   -#endif // WIN32
331   - break;
332   -
333   - default:
334   - trace("Calling function %d",(int) *func);
335   - outBuffer = run_query(*func, inBuffer, &szOutBuffer, rc);
336   - }
337   -
338   - if(*rc)
339   - copyString(buffer,length,strerror(*rc));
340   - else if(outBuffer)
341   - {
342   - if(szOutBuffer < *length)
343   - *length = szOutBuffer;
344   -
345   - copyString(buffer,length,outBuffer);
346   - }
347   - if(outBuffer)
348   - free(outBuffer);
349   -
350   - free(inBuffer);
351   - return 0;
352   - }
353   -
354   -*/
src/plugins/remotectl/hllapi.cbp
... ... @@ -1,84 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2   -<CodeBlocks_project_file>
3   - <FileVersion major="1" minor="6" />
4   - <Project>
5   - <Option title="pw3270 HLLAPI" />
6   - <Option makefile_is_custom="1" />
7   - <Option pch_mode="2" />
8   - <Option compiler="gcc" />
9   - <Build>
10   - <Target title="Debug">
11   - <Option output=".bin/Debug/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />
12   - <Option object_output=".obj/Debug/" />
13   - <Option type="1" />
14   - <Option compiler="gcc" />
15   - <Compiler>
16   - <Add option="-g" />
17   - </Compiler>
18   - </Target>
19   - <Target title="Release">
20   - <Option output=".bin/Release/pw3270 HLLAPI" prefix_auto="1" extension_auto="1" />
21   - <Option object_output=".obj/Release/" />
22   - <Option type="1" />
23   - <Option compiler="gcc" />
24   - <Compiler>
25   - <Add option="-O2" />
26   - </Compiler>
27   - <Linker>
28   - <Add option="-s" />
29   - </Linker>
30   - </Target>
31   - <Target title="test">
32   - <Option output=".bin/Debug/testprogram" prefix_auto="1" extension_auto="1" />
33   - <Option object_output=".obj/Debug/" />
34   - <Option type="1" />
35   - <Option compiler="gcc" />
36   - <Compiler>
37   - <Add option="-g" />
38   - </Compiler>
39   - <Environment>
40   - <Variable name="LIB3270_CFLAGS" value='&quot;-I../../../src/include&quot;' />
41   - <Variable name="LIB3270_LIBS" value='&quot;-L../../../.bin/Debug -l3270&quot;' />
42   - <Variable name="PW3270_LIBS" value='&quot;-L../../../.bin/Debug -lpw3270 -l3270&quot;' />
43   - </Environment>
44   - <MakeCommands>
45   - <Build command="$make LIB3270_MODE=Debug -f $makefile $target" />
46   - <CompileFile command="$make -f $makefile $file" />
47   - <Clean command="$make -f $makefile clean$target" />
48   - <DistClean command="$make -f $makefile distclean$target" />
49   - <AskRebuildNeeded command="$make -q -f $makefile $target" />
50   - <SilentBuild command="$make LIB3270_MODE=Debug -f $makefile $target &gt; $(CMD_NULL)" />
51   - </MakeCommands>
52   - </Target>
53   - </Build>
54   - <Compiler>
55   - <Add option="-Wall" />
56   - </Compiler>
57   - <Unit filename="Makefile.in" />
58   - <Unit filename="calls.c">
59   - <Option compilerVar="CC" />
60   - </Unit>
61   - <Unit filename="client.h" />
62   - <Unit filename="hllapi.c">
63   - <Option compilerVar="CC" />
64   - </Unit>
65   - <Unit filename="packets.h" />
66   - <Unit filename="pluginmain.c">
67   - <Option compilerVar="CC" />
68   - </Unit>
69   - <Unit filename="remote.c">
70   - <Option compilerVar="CC" />
71   - </Unit>
72   - <Unit filename="remotectl.h" />
73   - <Unit filename="server.h" />
74   - <Unit filename="testprogram.c">
75   - <Option compilerVar="CC" />
76   - </Unit>
77   - <Extensions>
78   - <code_completion />
79   - <envvars />
80   - <debugger />
81   - <lib_finder disable_auto="1" />
82   - </Extensions>
83   - </Project>
84   -</CodeBlocks_project_file>
src/plugins/remotectl/packets.h
... ... @@ -1,143 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como packets.h 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   - typedef enum _hllapi_packet
31   - {
32   - HLLAPI_PACKET_CONNECT,
33   - HLLAPI_PACKET_DISCONNECT,
34   - HLLAPI_PACKET_GET_PROGRAM_MESSAGE,
35   - HLLAPI_PACKET_GET_TEXT_AT_OFFSET,
36   - HLLAPI_PACKET_GET_TEXT_AT,
37   - HLLAPI_PACKET_SET_TEXT_AT,
38   - HLLAPI_PACKET_CMP_TEXT_AT,
39   - HLLAPI_PACKET_ENTER,
40   - HLLAPI_PACKET_PFKEY,
41   - HLLAPI_PACKET_PAKEY,
42   - HLLAPI_PACKET_SET_CURSOR_POSITION,
43   - HLLAPI_PACKET_GET_CURSOR_POSITION,
44   - HLLAPI_PACKET_INPUT_STRING,
45   - HLLAPI_PACKET_IS_CONNECTED,
46   - HLLAPI_PACKET_SET_CURSOR,
47   - HLLAPI_PACKET_GET_CURSOR,
48   -
49   - HLLAPI_PACKET_INVALID
50   -
51   - } HLLAPI_PACKET;
52   -
53   -#pragma pack(1)
54   -
55   -struct hllapi_packet_result
56   -{
57   - int rc;
58   -};
59   -
60   -struct hllapi_packet_text_result
61   -{
62   - int rc;
63   - char text[1];
64   -};
65   -
66   -struct hllapi_packet_query
67   -{
68   - unsigned char packet_id;
69   -};
70   -
71   -struct hllapi_packet_connect
72   -{
73   - unsigned char packet_id;
74   - unsigned char wait;
75   - char hostname[1];
76   -};
77   -
78   -struct hllapi_packet_keycode
79   -{
80   - unsigned char packet_id;
81   - unsigned short keycode;
82   -};
83   -
84   -struct hllapi_packet_cursor
85   -{
86   - unsigned char packet_id;
87   - unsigned short row;
88   - unsigned short col;
89   -};
90   -
91   -struct hllapi_packet_text
92   -{
93   - unsigned char packet_id;
94   - char text[1];
95   -};
96   -
97   -struct hllapi_packet_at
98   -{
99   - unsigned char packet_id;
100   - unsigned short row;
101   - unsigned short col;
102   - unsigned short len;
103   -};
104   -
105   -struct hllapi_packet_text_at
106   -{
107   - unsigned char packet_id;
108   - unsigned short row;
109   - unsigned short col;
110   - char text[1];
111   -};
112   -
113   -struct hllapi_packet_query_at
114   -{
115   - unsigned char packet_id;
116   - unsigned short row;
117   - unsigned short col;
118   - unsigned short len;
119   -};
120   -
121   -struct hllapi_packet_wait
122   -{
123   - unsigned char packet_id;
124   - int timeout;
125   -};
126   -
127   -struct hllapi_packet_addr
128   -{
129   - unsigned char packet_id;
130   - unsigned short addr;
131   -};
132   -
133   -struct hllapi_packet_query_offset
134   -{
135   - unsigned char packet_id;
136   - unsigned short addr;
137   - unsigned short len;
138   -};
139   -
140   -
141   -
142   -#pragma pack()
143   -
src/plugins/remotectl/pipesource.c
... ... @@ -1,385 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como pipesource.c 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   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   - #include <pw3270.h>
33   - #include <pw3270/v3270.h>
34   -
35   - #include <windows.h>
36   - #include <stdarg.h>
37   - #include "remotectl.h"
38   -
39   -/*---[ Defines ]----------------------------------------------------------------------------*/
40   -
41   - #pragma pack(1)
42   -
43   - typedef struct _pipe_source
44   - {
45   - GSource gsrc;
46   - HANDLE hPipe;
47   -
48   - enum _PIPE_STATE
49   - {
50   - PIPE_STATE_WAITING,
51   - PIPE_STATE_READ,
52   - PIPE_STATE_PENDING_READ,
53   -
54   - PIPE_STATE_UNDEFINED,
55   - } state;
56   -
57   - OVERLAPPED overlap;
58   - unsigned char buffer[PIPE_BUFFER_LENGTH+1];
59   - } pipe_source;
60   -
61   - #pragma pack()
62   -
63   -/*---[ GSource ]----------------------------------------------------------------------------*/
64   -
65   -static void wait_for_client(pipe_source *source)
66   -{
67   - set_active(FALSE);
68   - if(ConnectNamedPipe(source->hPipe,&source->overlap))
69   - {
70   - popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));
71   - return;
72   - }
73   -
74   - switch(GetLastError())
75   - {
76   - // The overlapped connection in progress.
77   - case ERROR_IO_PENDING:
78   - // trace("%s: ERROR_IO_PENDING",__FUNCTION__);
79   - source->state = PIPE_STATE_WAITING;
80   - break;
81   -
82   - // Client is already connected, so signal an event.
83   - case ERROR_PIPE_CONNECTED:
84   - trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);
85   - set_active(TRUE);
86   - if(SetEvent(source->overlap.hEvent))
87   - break;
88   -
89   - // If an error occurs during the connect operation...
90   - default:
91   - popup_lasterror("%s", _( "ConnectNamedPipe failed" ));
92   - }
93   -
94   - }
95   -
96   - static gboolean IO_prepare(GSource *source, gint *timeout)
97   - {
98   - /*
99   - * Called before all the file descriptors are polled.
100   - * If the source can determine that it is ready here
101   - * (without waiting for the results of the poll() call)
102   - * it should return TRUE.
103   - *
104   - * It can also return a timeout_ value which should be the maximum
105   - * timeout (in milliseconds) which should be passed to the poll() call.
106   - * The actual timeout used will be -1 if all sources returned -1,
107   - * or it will be the minimum of all the timeout_ values
108   - * returned which were >= 0.
109   - *
110   - */
111   - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
112   - {
113   - // trace("%s: source=%p",__FUNCTION__,source);
114   - return TRUE;
115   - }
116   -
117   - *timeout = 10;
118   - return FALSE;
119   - }
120   -
121   - static gboolean IO_check(GSource *source)
122   - {
123   - /*
124   - * Called after all the file descriptors are polled.
125   - * The source should return TRUE if it is ready to be dispatched.
126   - * Note that some time may have passed since the previous prepare
127   - * function was called, so the source should be checked again here.
128   - *
129   - */
130   - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
131   - return TRUE;
132   -
133   - return FALSE;
134   - }
135   -
136   - static void process_input(pipe_source *source, DWORD cbRead)
137   - {
138   - HLLAPI_DATA * data = (HLLAPI_DATA *) source->buffer;
139   - QUERY * qry = g_malloc0(sizeof(QUERY)+cbRead+1);
140   -
141   - qry->hPipe = source->hPipe;
142   - qry->text = (const gchar *) (qry+1);
143   -
144   - if(data->id == HLLAPI_REQUEST_QUERY)
145   - {
146   - // HLLAPI query
147   - qry->cmd = (int) data->func;
148   - qry->pos = (int) data->rc;
149   - qry->length = data->value;
150   - memcpy((gchar *)(qry->text),data->string,qry->length);
151   - }
152   - else
153   - {
154   - qry->cmd = -1;
155   - }
156   -
157   - enqueue_request(qry);
158   - }
159   -
160   - void request_complete(QUERY *qry, int rc, const gchar *text)
161   - {
162   - request_buffer(qry,rc,strlen(text),(const gpointer) text);
163   - }
164   -
165   - void request_status(QUERY *qry, int rc)
166   - {
167   - if(rc)
168   - {
169   - const gchar *msg = strerror(rc);
170   - request_buffer(qry, rc, strlen(msg), (const gpointer) msg);
171   - }
172   - else
173   - {
174   - request_buffer(qry, rc, 0, NULL);
175   - }
176   - }
177   -
178   - void request_value(QUERY *qry, int rc, unsigned int value)
179   - {
180   - HLLAPI_DATA data;
181   -
182   - memset(&data,0,sizeof(data));
183   - data.id = HLLAPI_RESPONSE_VALUE;
184   - data.func = qry->cmd;
185   - data.rc = rc;
186   - data.value = value;
187   -
188   -#ifdef WIN32
189   - {
190   - DWORD wrote = sizeof(data);
191   - WriteFile(qry->hPipe,&data,wrote,&wrote,NULL);
192   - trace("Wrote=%d len=%d",(int) wrote, sizeof(data));
193   - }
194   -#endif // WIN32
195   -
196   - g_free(qry);
197   -
198   -
199   - }
200   -
201   - void request_buffer(QUERY *qry, int rc, size_t szBuffer, const gpointer buffer)
202   - {
203   - size_t sz;
204   - HLLAPI_DATA *data;
205   -
206   - if(buffer)
207   - {
208   - sz = sizeof(HLLAPI_DATA)+szBuffer;
209   - data = g_malloc0(sz);
210   - data->id = HLLAPI_RESPONSE_TEXT;
211   - memcpy(data->string,buffer,szBuffer);
212   - }
213   - else
214   - {
215   - sz = sizeof(HLLAPI_DATA);
216   - data = g_malloc0(sz);
217   - data->id = HLLAPI_RESPONSE_VALUE;
218   - }
219   -
220   - data->func = qry->cmd;
221   - data->rc = rc;
222   - data->value = szBuffer;
223   -
224   - trace("rc=%d data->len=%d",rc,(int) szBuffer);
225   -
226   -#ifdef WIN32
227   - {
228   - DWORD wrote = sz;
229   - WriteFile(qry->hPipe,data,wrote,&wrote,NULL);
230   - trace("Wrote=%d len=%d",(int) wrote, (int) sz);
231   - }
232   -#endif // WIN32
233   -
234   - g_free(data);
235   - g_free(qry);
236   -
237   - }
238   -
239   - static void read_input_pipe(pipe_source *source)
240   - {
241   - DWORD cbRead = 0;
242   -
243   - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)
244   - process_input(source,cbRead);
245   -
246   - // The read operation is still pending.
247   - switch(GetLastError())
248   - {
249   - case 0:
250   - break;
251   -
252   - case ERROR_IO_PENDING:
253   - // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);
254   - source->state = PIPE_STATE_PENDING_READ;
255   - break;
256   -
257   - case ERROR_PIPE_LISTENING:
258   - // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);
259   - source->state = PIPE_STATE_READ;
260   - break;
261   -
262   - case ERROR_BROKEN_PIPE:
263   - trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);
264   -
265   - if(!DisconnectNamedPipe(source->hPipe))
266   - {
267   - set_active(FALSE);
268   - popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));
269   - }
270   - else
271   - {
272   - wait_for_client(source);
273   - }
274   - break;
275   -
276   - case ERROR_PIPE_NOT_CONNECTED:
277   - trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);
278   - set_active(FALSE);
279   - break;
280   -
281   - default:
282   - if(source->hPipe != INVALID_HANDLE_VALUE)
283   - popup_lasterror("%s",_( "Error receiving message from pipe" ) );
284   - }
285   -
286   - }
287   -
288   - static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer data)
289   - {
290   - /*
291   - * Called to dispatch the event source,
292   - * after it has returned TRUE in either its prepare or its check function.
293   - * The dispatch function is passed in a callback function and data.
294   - * The callback function may be NULL if the source was never connected
295   - * to a callback using g_source_set_callback(). The dispatch function
296   - * should call the callback function with user_data and whatever additional
297   - * parameters are needed for this type of event source.
298   - */
299   - BOOL fSuccess;
300   - DWORD cbRead = 0;
301   -// DWORD dwErr = 0;
302   -
303   - fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );
304   -
305   - // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);
306   -
307   - switch(((pipe_source *) source)->state)
308   - {
309   - case PIPE_STATE_WAITING:
310   - if(fSuccess)
311   - {
312   - trace("Pipe connected (cbRet=%d)",(int) cbRead);
313   - set_active(TRUE);
314   - ((pipe_source *) source)->state = PIPE_STATE_READ;
315   - }
316   - else
317   - {
318   - popup_lasterror("%s", _( "Pipe connection failed" ));
319   - }
320   - break;
321   -
322   - case PIPE_STATE_READ:
323   - // trace("Reading pipe (cbRead=%d)",(int) cbRead);
324   - read_input_pipe( (pipe_source *) source);
325   - break;
326   -
327   - case PIPE_STATE_PENDING_READ:
328   - if(fSuccess && cbRead > 0)
329   - process_input((pipe_source *) source,cbRead);
330   - ((pipe_source *) source)->state = PIPE_STATE_READ;
331   - break;
332   -
333   -//#ifdef DEBUG
334   -// default:
335   -// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);
336   -//#endif
337   - }
338   -
339   - return TRUE;
340   - }
341   -
342   - static void IO_finalize(GSource *source)
343   - {
344   -// trace("%s: source=%p",__FUNCTION__,source);
345   -
346   - if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)
347   - {
348   - CloseHandle(((pipe_source *) source)->hPipe);
349   - ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;
350   - }
351   -
352   - }
353   -
354   - static gboolean IO_closure(gpointer data)
355   - {
356   -// trace("%s: data=%p",__FUNCTION__,data);
357   - return 0;
358   - }
359   -
360   -
361   - void init_source_pipe(HANDLE hPipe)
362   - {
363   - static GSourceFuncs pipe_source_funcs =
364   - {
365   - IO_prepare,
366   - IO_check,
367   - IO_dispatch,
368   - IO_finalize,
369   - IO_closure,
370   - NULL
371   - };
372   -
373   - pipe_source *source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));
374   -
375   - source->hPipe = hPipe;
376   - source->state = PIPE_STATE_WAITING;
377   - source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);
378   -
379   - g_source_attach((GSource *) source,NULL);
380   -
381   - wait_for_client(source);
382   -
383   - return;
384   - }
385   -
src/plugins/remotectl/pluginmain.c
... ... @@ -1,807 +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. 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 pluginmain.c 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   - * Agradecimento:
29   - *
30   - * Hélio Passos
31   - *
32   - */
33   -
34   - #include "server.h"
35   - #include "packets.h"
36   - #include <lib3270/actions.h>
37   -
38   -/*--[ Defines ]--------------------------------------------------------------------------------------*/
39   -
40   - #pragma pack(1)
41   -
42   - typedef struct _pipe_source
43   - {
44   - GSource gsrc;
45   - HANDLE hPipe;
46   -
47   - enum _PIPE_STATE
48   - {
49   - PIPE_STATE_WAITING,
50   - PIPE_STATE_READ,
51   - PIPE_STATE_PENDING_READ,
52   - PIPE_STATE_UNDEFINED,
53   - } state;
54   -
55   - OVERLAPPED overlap;
56   - unsigned char buffer[PIPE_BUFFER_LENGTH+1];
57   - } pipe_source;
58   -
59   - #pragma pack()
60   -
61   -
62   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
63   -
64   - static const gchar control_char = '@';
65   -
66   -/*--[ Implement ]------------------------------------------------------------------------------------*/
67   -
68   - static void IO_accept(pipe_source *source)
69   - {
70   - set_active(FALSE);
71   -
72   - if(ConnectNamedPipe(source->hPipe,&source->overlap))
73   - {
74   - popup_lasterror("%s",_( "Error in ConnectNamedPipe" ));
75   - return;
76   - }
77   -
78   - switch(GetLastError())
79   - {
80   - // The overlapped connection in progress.
81   - case ERROR_IO_PENDING:
82   - // trace("%s: ERROR_IO_PENDING",__FUNCTION__);
83   - source->state = PIPE_STATE_WAITING;
84   - break;
85   -
86   - // Client is already connected, so signal an event.
87   - case ERROR_PIPE_CONNECTED:
88   - trace("%s: ERROR_PIPE_CONNECTED",__FUNCTION__);
89   - set_active(TRUE);
90   - if(SetEvent(source->overlap.hEvent))
91   - break;
92   -
93   - // If an error occurs during the connect operation...
94   - default:
95   - popup_lasterror("%s", _( "ConnectNamedPipe failed" ));
96   - }
97   -
98   - }
99   -
100   - static gboolean IO_prepare(GSource *source, gint *timeout)
101   - {
102   - /*
103   - * Called before all the file descriptors are polled.
104   - * If the source can determine that it is ready here
105   - * (without waiting for the results of the poll() call)
106   - * it should return TRUE.
107   - *
108   - * It can also return a timeout_ value which should be the maximum
109   - * timeout (in milliseconds) which should be passed to the poll() call.
110   - * The actual timeout used will be -1 if all sources returned -1,
111   - * or it will be the minimum of all the timeout_ values
112   - * returned which were >= 0.
113   - *
114   - */
115   - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
116   - return TRUE;
117   -
118   - *timeout = 10;
119   - return FALSE;
120   - }
121   -
122   - static gboolean IO_check(GSource *source)
123   - {
124   - /*
125   - * Called after all the file descriptors are polled.
126   - * The source should return TRUE if it is ready to be dispatched.
127   - * Note that some time may have passed since the previous prepare
128   - * function was called, so the source should be checked again here.
129   - *
130   - */
131   - if(WaitForSingleObject(((pipe_source *) source)->overlap.hEvent,0) == WAIT_OBJECT_0)
132   - return TRUE;
133   -
134   - return FALSE;
135   - }
136   -
137   - static void send_text(pipe_source *source, char *text)
138   - {
139   - struct hllapi_packet_text *pkt;
140   - DWORD szBlock;
141   -
142   - if(text)
143   - {
144   - szBlock = sizeof(struct hllapi_packet_text)+strlen(text);
145   - pkt = g_malloc0(szBlock);
146   - pkt->packet_id = 0;
147   - strcpy(pkt->text,text);
148   - lib3270_free(text);
149   - }
150   - else
151   - {
152   - szBlock = sizeof(struct hllapi_packet_text);
153   - pkt = g_malloc0(szBlock);
154   - pkt->packet_id = errno ? errno : -1;
155   - }
156   -
157   - WriteFile(source->hPipe,pkt,szBlock,&szBlock,NULL);
158   -
159   - g_free(pkt);
160   - }
161   -
162   - static void send_result(pipe_source *source, int rc)
163   - {
164   - struct hllapi_packet_result pkt = { rc };
165   - DWORD wrote = sizeof(pkt);
166   - WriteFile(source->hPipe,&pkt,wrote,&wrote,NULL);
167   - }
168   -
169   - static void process_input(pipe_source *source, DWORD cbRead)
170   - {
171   -
172   - trace("%s id=%d",__FUNCTION__,((struct hllapi_packet_query *) source->buffer)->packet_id);
173   -
174   - switch(((struct hllapi_packet_query *) source->buffer)->packet_id)
175   - {
176   - case HLLAPI_PACKET_CONNECT:
177   - send_result(source,lib3270_connect( lib3270_get_default_session_handle(),
178   - ((struct hllapi_packet_connect *) source->buffer)->hostname,
179   - ((struct hllapi_packet_connect *) source->buffer)->wait));
180   - break;
181   -
182   - case HLLAPI_PACKET_DISCONNECT:
183   - send_result(source,lib3270_disconnect(lib3270_get_default_session_handle()));
184   - break;
185   -
186   - case HLLAPI_PACKET_GET_PROGRAM_MESSAGE:
187   - send_result(source,lib3270_get_program_message(lib3270_get_default_session_handle()));
188   - break;
189   -
190   - case HLLAPI_PACKET_IS_CONNECTED:
191   - send_result(source,lib3270_in_tn3270e(lib3270_get_default_session_handle()));
192   - break;
193   -
194   - case HLLAPI_PACKET_ENTER:
195   - send_result(source,lib3270_enter(lib3270_get_default_session_handle()));
196   - break;
197   -
198   - case HLLAPI_PACKET_PFKEY:
199   - send_result(source,lib3270_pfkey( lib3270_get_default_session_handle(),
200   - ((struct hllapi_packet_keycode *) source->buffer)->keycode));
201   - break;
202   -
203   - case HLLAPI_PACKET_PAKEY:
204   - send_result(source,lib3270_pakey( lib3270_get_default_session_handle(),
205   - ((struct hllapi_packet_keycode *) source->buffer)->keycode));
206   - break;
207   -
208   - case HLLAPI_PACKET_SET_CURSOR_POSITION:
209   - send_result(source,lib3270_set_cursor_position( lib3270_get_default_session_handle(),
210   - ((struct hllapi_packet_cursor *) source->buffer)->row,
211   - ((struct hllapi_packet_cursor *) source->buffer)->col));
212   - break;
213   -
214   - case HLLAPI_PACKET_SET_TEXT_AT:
215   - send_result(source,lib3270_set_text_at( lib3270_get_default_session_handle(),
216   - ((struct hllapi_packet_text_at *) source->buffer)->row,
217   - ((struct hllapi_packet_text_at *) source->buffer)->col,
218   - (unsigned char *) ((struct hllapi_packet_text_at *) source->buffer)->text));
219   - break;
220   -
221   - case HLLAPI_PACKET_GET_TEXT_AT:
222   - send_text(source,lib3270_get_text_at( lib3270_get_default_session_handle(),
223   - ((struct hllapi_packet_at *) source->buffer)->row,
224   - ((struct hllapi_packet_at *) source->buffer)->col,
225   - ((struct hllapi_packet_at *) source->buffer)->len));
226   - break;
227   -
228   - case HLLAPI_PACKET_GET_TEXT_AT_OFFSET:
229   - send_text(source,lib3270_get_text( lib3270_get_default_session_handle(),
230   - ((struct hllapi_packet_query_offset *) source->buffer)->addr,
231   - ((struct hllapi_packet_query_offset *) source->buffer)->len));
232   - break;
233   -
234   - case HLLAPI_PACKET_CMP_TEXT_AT:
235   - send_result(source,lib3270_cmp_text_at( lib3270_get_default_session_handle(),
236   - ((struct hllapi_packet_text_at *) source->buffer)->row,
237   - ((struct hllapi_packet_text_at *) source->buffer)->col,
238   - ((struct hllapi_packet_text_at *) source->buffer)->text));
239   - break;
240   -
241   - case HLLAPI_PACKET_INPUT_STRING:
242   - send_result(source,lib3270_input_string(lib3270_get_default_session_handle(),
243   - (unsigned char *) ((struct hllapi_packet_text *) source->buffer)->text));
244   - break;
245   -
246   - case HLLAPI_PACKET_SET_CURSOR:
247   - send_result(source,lib3270_set_cursor_address(lib3270_get_default_session_handle(),
248   - ((struct hllapi_packet_addr *) source->buffer)->addr));
249   - break;
250   -
251   - case HLLAPI_PACKET_GET_CURSOR:
252   - send_result(source,lib3270_get_cursor_address(lib3270_get_default_session_handle()));
253   - break;
254   -
255   -
256   - default:
257   - send_result(source, EINVAL);
258   - g_message("Invalid remote request (id=%d)",source->buffer[0]);
259   - }
260   -
261   - }
262   -
263   - static void read_input_pipe(pipe_source *source)
264   - {
265   - DWORD cbRead = 0;
266   -
267   - if(ReadFile(source->hPipe,source->buffer,PIPE_BUFFER_LENGTH,&cbRead,&source->overlap) && cbRead > 0)
268   - process_input(source,cbRead);
269   -
270   - // The read operation is still pending.
271   - switch(GetLastError())
272   - {
273   - case 0:
274   - break;
275   -
276   - case ERROR_IO_PENDING:
277   - // trace("%s: PIPE_STATE_PENDING_READ",__FUNCTION__);
278   - source->state = PIPE_STATE_PENDING_READ;
279   - break;
280   -
281   - case ERROR_PIPE_LISTENING:
282   - // trace("%s: ERROR_PIPE_LISTENING",__FUNCTION__);
283   - source->state = PIPE_STATE_READ;
284   - break;
285   -
286   - case ERROR_BROKEN_PIPE:
287   - trace("%s: ERROR_BROKEN_PIPE",__FUNCTION__);
288   -
289   - if(!DisconnectNamedPipe(source->hPipe))
290   - {
291   - set_active(FALSE);
292   - popup_lasterror("%s",_( "Error in DisconnectNamedPipe" ));
293   - }
294   - else
295   - {
296   - IO_accept(source);
297   - }
298   - break;
299   -
300   - case ERROR_PIPE_NOT_CONNECTED:
301   - trace("%s: ERROR_PIPE_NOT_CONNECTED",__FUNCTION__);
302   - set_active(FALSE);
303   - break;
304   -
305   - default:
306   - if(source->hPipe != INVALID_HANDLE_VALUE)
307   - popup_lasterror("%s",_( "Error receiving message from pipe" ) );
308   - }
309   -
310   - }
311   -
312   - static gboolean IO_dispatch(GSource *source, GSourceFunc callback, gpointer data)
313   - {
314   - /*
315   - * Called to dispatch the event source,
316   - * after it has returned TRUE in either its prepare or its check function.
317   - * The dispatch function is passed in a callback function and data.
318   - * The callback function may be NULL if the source was never connected
319   - * to a callback using g_source_set_callback(). The dispatch function
320   - * should call the callback function with user_data and whatever additional
321   - * parameters are needed for this type of event source.
322   - */
323   - BOOL fSuccess;
324   - DWORD cbRead = 0;
325   -// DWORD dwErr = 0;
326   -
327   - fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );
328   -
329   - // trace("%s: source=%p data=%p Result=%s cbRead=%d",__FUNCTION__,source,data,fSuccess ? "Success" : "Unsuccess",(int) cbRead);
330   -
331   - switch(((pipe_source *) source)->state)
332   - {
333   - case PIPE_STATE_WAITING:
334   - if(fSuccess)
335   - {
336   - trace("Pipe connected (cbRet=%d)",(int) cbRead);
337   - set_active(TRUE);
338   - ((pipe_source *) source)->state = PIPE_STATE_READ;
339   - }
340   - else
341   - {
342   - popup_lasterror("%s", _( "Pipe connection failed" ));
343   - }
344   - break;
345   -
346   - case PIPE_STATE_READ:
347   - // trace("Reading pipe (cbRead=%d)",(int) cbRead);
348   - read_input_pipe( (pipe_source *) source);
349   - break;
350   -
351   - case PIPE_STATE_PENDING_READ:
352   - if(fSuccess && cbRead > 0)
353   - process_input((pipe_source *) source,cbRead);
354   - ((pipe_source *) source)->state = PIPE_STATE_READ;
355   - break;
356   -
357   - case PIPE_STATE_UNDEFINED:
358   - break;
359   -
360   -//#ifdef DEBUG
361   -// default:
362   -// trace("%s: source=%p data=%p Unexpected mode %d",__FUNCTION__,source,data,((pipe_source *) source)->state);
363   -//#endif
364   - }
365   -
366   - return TRUE;
367   - }
368   -
369   - static void IO_finalize(GSource *source)
370   - {
371   -// trace("%s: source=%p",__FUNCTION__,source);
372   -
373   - if( ((pipe_source *) source)->hPipe != INVALID_HANDLE_VALUE)
374   - {
375   - CloseHandle(((pipe_source *) source)->hPipe);
376   - ((pipe_source *) source)->hPipe = INVALID_HANDLE_VALUE;
377   - }
378   -
379   - }
380   -
381   - static gboolean IO_closure(gpointer data)
382   - {
383   -// trace("%s: data=%p",__FUNCTION__,data);
384   - return 0;
385   - }
386   -
387   - void popup_lasterror(const gchar *fmt, ...)
388   - {
389   - char buffer[4096];
390   - va_list arg_ptr;
391   - int sz;
392   - DWORD errcode = GetLastError();
393   - char *ptr;
394   - LPVOID lpMsgBuf = 0;
395   -
396   - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
397   -
398   - for(ptr=lpMsgBuf;*ptr && *ptr != '\n';ptr++);
399   - *ptr = 0;
400   -
401   - va_start(arg_ptr, fmt);
402   - vsnprintf(buffer,4095,fmt,arg_ptr);
403   - va_end(arg_ptr);
404   -
405   - sz = strlen(buffer);
406   - snprintf(buffer+sz,4096-sz,": %s\n(rc=%d)",lpMsgBuf,(int) errcode);
407   -
408   - printf("%s\n",buffer);
409   -
410   -#ifdef DEBUG
411   - fprintf(stderr,"%s\n",buffer);
412   - fflush(stderr);
413   -#endif
414   -
415   - LocalFree(lpMsgBuf);
416   - }
417   -
418   - LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window)
419   - {
420   - char id;
421   -
422   - for(id='A';id < 'Z';id++)
423   - {
424   - gchar * pipename = g_strdup_printf("\\\\.\\pipe\\%s_%c",pw3270_get_session_name(window),id);
425   - gchar * ptr;
426   - HANDLE hPipe;
427   -
428   - for(ptr=pipename;*ptr;ptr++)
429   - *ptr = g_ascii_tolower(*ptr);
430   -
431   - hPipe = CreateNamedPipe( TEXT(pipename), // pipe name
432   - PIPE_ACCESS_DUPLEX | // read/write access
433   - FILE_FLAG_OVERLAPPED, // overlapped mode
434   - PIPE_TYPE_MESSAGE | // pipe type
435   - PIPE_READMODE_MESSAGE | // pipe mode
436   - PIPE_WAIT, // blocking mode
437   - 1, // number of instances
438   - PIPE_BUFFER_LENGTH, // output buffer size
439   - PIPE_BUFFER_LENGTH, // input buffer size
440   - NMPWAIT_USE_DEFAULT_WAIT, // client time-out
441   - NULL); // default security attributes
442   -
443   - trace("%s = %p",pipename,hPipe);
444   - g_free(pipename);
445   -
446   - if(hPipe != INVALID_HANDLE_VALUE)
447   - {
448   - static GSourceFuncs pipe_source_funcs =
449   - {
450   - IO_prepare,
451   - IO_check,
452   - IO_dispatch,
453   - IO_finalize,
454   - IO_closure,
455   - NULL
456   - };
457   - pipe_source * source;
458   - gchar * session = g_strdup_printf("%s:%c",pw3270_get_session_name(window),id);
459   -
460   - pw3270_set_session_name(window,session);
461   - g_free(session);
462   -
463   - source = (pipe_source *) g_source_new(&pipe_source_funcs,sizeof(pipe_source));
464   -
465   - source->hPipe = hPipe;
466   - source->state = PIPE_STATE_WAITING;
467   - source->overlap.hEvent = CreateEvent( NULL,TRUE,TRUE,NULL);
468   -
469   - g_source_attach((GSource *) source,NULL);
470   - IO_accept(source);
471   -
472   - return 0;
473   - }
474   -
475   - }
476   -
477   - popup_lasterror( "%s", _( "Can´t create remote control pipe" ));
478   -
479   - return -1;
480   - }
481   -
482   - LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window)
483   - {
484   -
485   - return 0;
486   - }
487   -
488   -/*
489   - static void cmd_connectps(QUERY *qry)
490   - {
491   - g_message("%s","HLLAPI ConnectPS request received");
492   - request_status(qry,v3270_set_script(pw3270_get_terminal_widget(NULL),'H',TRUE));
493   - }
494   -
495   - static void cmd_disconnectps(QUERY *qry)
496   - {
497   - g_message("%s","HLLAPI DisconnectPS request received");
498   - request_status(qry,0);
499   - }
500   -
501   - static void cmd_getrevision(QUERY *qry)
502   - {
503   - request_complete(qry,0,lib3270_get_revision());
504   - }
505   -
506   - static void cmd_setcursor(QUERY *qry)
507   - {
508   - int rc = ENOTCONN;
509   -
510   - if(lib3270_connected(qry->hSession))
511   - {
512   - trace("%s: pos=%d row=%d col=%d",__FUNCTION__,rc,rc/80,rc%80);
513   - lib3270_set_cursor_address(qry->hSession,qry->pos -1);
514   - rc = 0;
515   - }
516   -
517   - request_status(qry,rc);
518   - }
519   -
520   - static void cmd_sendstring(QUERY *qry)
521   - {
522   - gchar * text;
523   - GError * error = NULL;
524   - gsize bytes_read;
525   - gsize bytes_written;
526   - const gchar * charset;
527   -
528   - if(!lib3270_connected(qry->hSession))
529   - {
530   - request_status(qry,ENOTCONN);
531   - return;
532   - }
533   -
534   - g_get_charset(&charset);
535   -
536   - text = g_convert(qry->text,qry->length,lib3270_get_charset(qry->hSession),charset,&bytes_read,&bytes_written,&error);
537   - if(text)
538   - {
539   - int rc = 0;
540   -
541   - if(strchr(text,control_char))
542   - {
543   - // Convert control char
544   - gchar * buffer = text;
545   - char * ptr;
546   -
547   - for(ptr = strchr(text,control_char);ptr;ptr = strchr(buffer,control_char))
548   - {
549   - *(ptr++) = 0;
550   -
551   - lib3270_emulate_input(qry->hSession,buffer,-1,0);
552   -
553   - switch(*(ptr++))
554   - {
555   - case 'P': // Print
556   - rc = pw3270_print(pw3270_get_terminal_widget(NULL), NULL, GTK_PRINT_OPERATION_ACTION_PRINT, PW3270_SRC_ALL);
557   - break;
558   -
559   - case 'E': // Enter
560   - lib3270_enter(qry->hSession);
561   - break;
562   -
563   - case 'F': // Erase EOF
564   - lib3270_eraseeof(qry->hSession);
565   - break;
566   -
567   - case '1': // PF1
568   - lib3270_pfkey(qry->hSession,1);
569   - break;
570   -
571   - case '2': // PF2
572   - lib3270_pfkey(qry->hSession,2);
573   - break;
574   -
575   - case '3': // PF3
576   - lib3270_pfkey(qry->hSession,3);
577   - break;
578   -
579   - case '4': // PF4
580   - lib3270_pfkey(qry->hSession,4);
581   - break;
582   -
583   - case '5': // PF5
584   - lib3270_pfkey(qry->hSession,5);
585   - break;
586   -
587   - case '6': // PF6
588   - lib3270_pfkey(qry->hSession,6);
589   - break;
590   -
591   - case '7': // PF7
592   - lib3270_pfkey(qry->hSession,7);
593   - break;
594   -
595   - case '8': // PF8
596   - lib3270_pfkey(qry->hSession,8);
597   - break;
598   -
599   - case '9': // PF9
600   - lib3270_pfkey(qry->hSession,9);
601   - break;
602   -
603   - case 'a': // PF10
604   - lib3270_pfkey(qry->hSession,10);
605   - break;
606   -
607   - case 'b': // PF11
608   - lib3270_pfkey(qry->hSession,11);
609   - break;
610   -
611   - case 'c': // PF12
612   - lib3270_pfkey(qry->hSession,12);
613   - break;
614   - }
615   -
616   - }
617   -
618   - lib3270_emulate_input(qry->hSession,buffer,-1,0);
619   -
620   - }
621   - else
622   - {
623   - lib3270_emulate_input(qry->hSession,text,strlen(text),0);
624   - }
625   - g_free(text);
626   -
627   - request_status(qry,rc);
628   -
629   - return;
630   - }
631   -
632   - request_complete(qry, error->code, error->message);
633   - g_error_free(error);
634   -
635   - }
636   -
637   - struct wait
638   - {
639   - QUERY * qry;
640   - time_t end;
641   - };
642   -
643   - static gboolean do_wait(struct wait *w)
644   - {
645   - if(lib3270_get_program_message(w->qry->hSession) == LIB3270_MESSAGE_NONE)
646   - {
647   - request_status(w->qry,0);
648   - return FALSE;
649   - }
650   -
651   - if(time(0) > w->end)
652   - {
653   - trace("%s: TIMEOUT",__FUNCTION__);
654   - request_status(w->qry,ETIMEDOUT);
655   - return FALSE;
656   - }
657   -
658   - return TRUE;
659   - }
660   -
661   - static void cmd_wait(QUERY *qry)
662   - {
663   - struct wait *w;
664   -
665   - if(lib3270_get_program_message(qry->hSession) == LIB3270_MESSAGE_NONE)
666   - {
667   - request_status(qry,0);
668   - return;
669   - }
670   -
671   - w = g_malloc0(sizeof(struct wait));
672   - w->qry = qry;
673   - w->end = time(0)+pw3270_get_integer(pw3270_get_toplevel(),"hllapi","wait",2);
674   -
675   - g_timeout_add_full(G_PRIORITY_DEFAULT, (guint) 300, (GSourceFunc) do_wait, w, g_free);
676   - }
677   -
678   - static void cmd_copypstostr(QUERY *qry)
679   - {
680   - int rows;
681   - int cols;
682   - unsigned short * attr;
683   - unsigned char * text;
684   - int rc;
685   - unsigned char * buffer;
686   - size_t length;
687   -
688   - if(!lib3270_connected(qry->hSession))
689   - {
690   - request_status(qry,ENOTCONN);
691   - return;
692   - }
693   -
694   - lib3270_get_screen_size(qry->hSession,&rows,&cols);
695   -
696   - if(qry->pos < 1 || (qry->pos+qry->length) >= (rows*cols))
697   - {
698   - request_status(qry,EINVAL);
699   - return;
700   - }
701   -
702   - qry->pos--;
703   -
704   - length = (qry->length * sizeof(unsigned short)) + qry->length + 2;
705   - text = buffer = g_malloc0(length+1);
706   - attr = (unsigned short *) (text+qry->length+1);
707   -
708   - trace("%s: pos=%d length=%d",__FUNCTION__,qry->pos,qry->length);
709   - rc = lib3270_get_contents(qry->hSession,qry->pos,qry->pos+(qry->length-1),text,attr);
710   -
711   - if(rc)
712   - {
713   - request_status(qry,rc);
714   - }
715   - else
716   - {
717   - const gchar * charset;
718   - gchar * local;
719   - gsize bytes_read;
720   - gsize bytes_written;
721   - GError * error = NULL;
722   -
723   - trace("Text: [%s]",text);
724   -
725   - g_get_charset(&charset);
726   -
727   - local = g_convert((const gchar *) text,-1,charset,lib3270_get_charset(qry->hSession),&bytes_read,&bytes_written,&error);
728   -
729   - if(!local)
730   - {
731   - request_complete(qry,error->code,error->message);
732   - g_error_free(error);
733   - }
734   - else
735   - {
736   - strncpy((char *) text,(const char *) local,qry->length);
737   -
738   - trace("response: [%s] len=%d",buffer,length);
739   - request_buffer(qry,0,length,buffer);
740   - g_free(local);
741   - }
742   - }
743   -
744   - g_free(buffer);
745   - }
746   -
747   - static void cmd_querycursor(QUERY *qry)
748   - {
749   - request_value(qry,0,lib3270_get_cursor_address(qry->hSession));
750   - }
751   -
752   - void enqueue_request(QUERY *qry)
753   - {
754   - static const struct _cmd
755   - {
756   - int cmd;
757   - void (*exec)(QUERY *qry);
758   - } cmd[] =
759   - {
760   - { HLLAPI_CMD_CONNECTPS, cmd_connectps }, // 1
761   - { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, // 2
762   - { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, // 3
763   - { HLLAPI_CMD_WAIT, cmd_wait }, // 4
764   -// { HLLAPI_CMD_COPYPS, }, // 5
765   -// { HLLAPI_CMD_SEARCHPS, }, // 6
766   - { HLLAPI_CMD_QUERYCURSOR, cmd_querycursor }, // 7
767   -
768   - { HLLAPI_CMD_COPYPSTOSTR, cmd_copypstostr }, // 8
769   -
770   -// { HLLAPI_CMD_COPYSTRTOPS }, // 15
771   -
772   - { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, // 40
773   -
774   -// { HLLAPI_CMD_SENDFILE }, // 90
775   -// { HLLAPI_CMD_RECEIVEFILE },
776   -
777   -
778   - { HLLAPI_CMD_GETREVISION, cmd_getrevision },
779   - };
780   -
781   -
782   -
783   - int f;
784   -
785   - trace("HLLAPI function %d",(int) qry->cmd);
786   -
787   - qry->hSession = lib3270_get_default_session_handle();
788   -
789   - for(f=0;f<G_N_ELEMENTS(cmd);f++)
790   - {
791   - if(cmd[f].cmd == qry->cmd)
792   - {
793   - cmd[f].exec(qry);
794   - return;
795   - }
796   - }
797   -
798   - g_warning("Unexpected HLLAPI function %d",(int) qry->cmd);
799   - request_status(qry,EINVAL);
800   - }
801   -
802   - G_GNUC_INTERNAL void set_active(gboolean on)
803   - {
804   - v3270_set_script(pw3270_get_terminal_widget(NULL),'H',on);
805   - }
806   -
807   -*/
src/plugins/remotectl/remote.c
... ... @@ -1,334 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como calls.c 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   - #include <lib3270.h>
31   - #include <malloc.h>
32   - #include <string.h>
33   - #include <errno.h>
34   - #include <stdio.h>
35   - #include <time.h>
36   - #include <lib3270/log.h>
37   -
38   - #include "client.h"
39   - #include "packets.h"
40   -
41   -/*--[ Globals ]--------------------------------------------------------------------------------------*/
42   -
43   -/*--[ Implement ]------------------------------------------------------------------------------------*/
44   -
45   - void * hllapi_pipe_init(const char *id)
46   - {
47   - HANDLE hPipe = INVALID_HANDLE_VALUE;
48   - static DWORD dwMode = PIPE_READMODE_MESSAGE;
49   - char buffer[4096];
50   - char * name = strdup(id);
51   - char * ptr;
52   -
53   - trace("%s(%s)",__FUNCTION__,id);
54   -
55   - for(ptr=name;*ptr;ptr++)
56   - {
57   - if(*ptr == ':')
58   - *ptr = '_';
59   - }
60   -
61   - snprintf(buffer,4095,"\\\\.\\pipe\\%s",name);
62   -
63   - free(name);
64   -
65   - trace("Opening \"%s\"",buffer);
66   -
67   - if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT))
68   - {
69   - trace("%s: Pipe not found",__FUNCTION__);
70   - errno = ENOENT;
71   - return NULL;
72   - }
73   -
74   - hPipe = CreateFile(buffer,GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
75   -
76   - if(hPipe == INVALID_HANDLE_VALUE)
77   - {
78   - errno = GetLastError();
79   - return NULL;
80   - }
81   -
82   - if(!SetNamedPipeHandleState(hPipe,&dwMode,NULL,NULL))
83   - {
84   - errno = GetLastError();
85   - return NULL;
86   - }
87   -
88   - trace("hPipe=%p",(void *) hPipe);
89   - return hPipe;
90   - }
91   -
92   - void hllapi_pipe_deinit(void *h)
93   - {
94   - trace("%s(%p)",__FUNCTION__,h);
95   -
96   - if(!h)
97   - return;
98   -
99   - CloseHandle((HANDLE) h);
100   - }
101   -
102   - const char * hllapi_pipe_get_revision(void)
103   - {
104   - return PACKAGE_REVISION;
105   - }
106   -
107   - int hllapi_pipe_connect(void *h, const char *n, int wait)
108   - {
109   - struct hllapi_packet_connect * pkt;
110   - struct hllapi_packet_result response;
111   - DWORD cbSize;
112   -
113   - if(!n)
114   - n = "";
115   -
116   - cbSize = sizeof(struct hllapi_packet_connect)+strlen(n);
117   - pkt = malloc(cbSize);
118   -
119   - pkt->packet_id = HLLAPI_PACKET_CONNECT;
120   - pkt->wait = (unsigned char) wait;
121   - strcpy(pkt->hostname,n);
122   -
123   - trace("Sending %s",pkt->hostname);
124   -
125   - if(!TransactNamedPipe((HANDLE) h,(LPVOID) pkt, cbSize, &response, sizeof(response), &cbSize,NULL))
126   - {
127   - errno = GetLastError();
128   - response.rc = -1;
129   - }
130   -
131   - free(pkt);
132   -
133   - return response.rc;
134   - }
135   -
136   - void hllapi_pipe_disconnect(void *h)
137   - {
138   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_DISCONNECT };
139   - struct hllapi_packet_result response;
140   - DWORD cbSize = sizeof(query);
141   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
142   - }
143   -
144   - LIB3270_MESSAGE hllapi_pipe_get_message(void *h)
145   - {
146   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_PROGRAM_MESSAGE };
147   - struct hllapi_packet_result response;
148   - DWORD cbSize = sizeof(query);
149   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
150   - return (LIB3270_MESSAGE) response.rc;
151   - }
152   -
153   - char * hllapi_pipe_get_text_at(void *h, int row, int col, int len)
154   - {
155   - struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, };
156   - struct hllapi_packet_text * response;
157   - DWORD cbSize = sizeof(struct hllapi_packet_text)+len;
158   - char * text = NULL;
159   -
160   - response = malloc(cbSize+2);
161   - memset(response,0,cbSize+2);
162   -
163   - if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(struct hllapi_packet_query_at), &response, cbSize, &cbSize,NULL))
164   - return NULL;
165   -
166   - if(response->packet_id)
167   - errno = response->packet_id;
168   - else
169   - text = strdup(response->text);
170   -
171   - free(response);
172   - return text;
173   - }
174   -
175   - int hllapi_pipe_enter(void *h)
176   - {
177   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_ENTER };
178   - struct hllapi_packet_result response;
179   - DWORD cbSize = sizeof(query);
180   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
181   - return response.rc;
182   - }
183   -
184   - int hllapi_pipe_set_text_at(void *h, int row, int col, const unsigned char *str)
185   - {
186   - struct hllapi_packet_text_at * query;
187   - struct hllapi_packet_result response;
188   - DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen((const char *) str);
189   -
190   - query = malloc(cbSize);
191   - query->packet_id = HLLAPI_PACKET_SET_TEXT_AT;
192   - query->row = row;
193   - query->col = col;
194   - strcpy(query->text,(const char *) str);
195   -
196   - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
197   -
198   - free(query);
199   -
200   - return response.rc;
201   - }
202   -
203   - int hllapi_pipe_cmp_text_at(void *h, int row, int col, const char *text)
204   - {
205   - struct hllapi_packet_text_at * query;
206   - struct hllapi_packet_result response;
207   - DWORD cbSize = sizeof(struct hllapi_packet_text_at)+strlen(text);
208   -
209   - query = malloc(cbSize);
210   - query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT;
211   - query->row = row;
212   - query->col = col;
213   - strcpy(query->text,text);
214   -
215   - TransactNamedPipe((HANDLE) h,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL);
216   -
217   - free(query);
218   -
219   - return response.rc;
220   - }
221   -
222   - int hllapi_pipe_pfkey(void *h, int key)
223   - {
224   - struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, key };
225   - struct hllapi_packet_result response;
226   - DWORD cbSize = sizeof(query);
227   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
228   - return response.rc;
229   - }
230   -
231   - int hllapi_pipe_pakey(void *h, int key)
232   - {
233   - struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, key };
234   - struct hllapi_packet_result response;
235   - DWORD cbSize = sizeof(query);
236   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
237   - return response.rc;
238   - }
239   -
240   - void hllapi_pipe_release_memory(void *p)
241   - {
242   - free(p);
243   - }
244   -
245   - int hllapi_pipe_wait_for_ready(void *h, int seconds)
246   - {
247   - time_t end = time(0)+seconds;
248   -
249   - while(time(0) < end)
250   - {
251   - if(!hllapi_pipe_is_connected(h))
252   - return ENOTCONN;
253   -
254   - if(hllapi_pipe_get_message(h) == 0)
255   - return 0;
256   - Sleep(250);
257   - }
258   -
259   - return ETIMEDOUT;
260   - }
261   -
262   - int hllapi_pipe_is_connected(void *h)
263   - {
264   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_IS_CONNECTED };
265   - struct hllapi_packet_result response;
266   - DWORD cbSize = sizeof(query);
267   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
268   - return (LIB3270_MESSAGE) response.rc;
269   - }
270   -
271   - int hllapi_pipe_sleep(void *h, int seconds)
272   - {
273   - time_t end = time(0)+seconds;
274   -
275   - while(time(0) < end)
276   - {
277   - if(!hllapi_pipe_is_connected(h))
278   - return ENOTCONN;
279   - Sleep(500);
280   - }
281   -
282   - return 0;
283   - }
284   -
285   - int hllapi_pipe_getcursor(void *h)
286   - {
287   - static const struct hllapi_packet_query query = { HLLAPI_PACKET_GET_CURSOR };
288   - struct hllapi_packet_result response;
289   - DWORD cbSize = sizeof(query);
290   -
291   - trace("%s",__FUNCTION__);
292   -
293   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
294   - return (LIB3270_MESSAGE) response.rc;
295   -
296   - }
297   -
298   - int hllapi_pipe_setcursor(void *h, int baddr)
299   - {
300   - struct hllapi_packet_addr query = { HLLAPI_PACKET_SET_CURSOR, baddr };
301   - struct hllapi_packet_result response;
302   - DWORD cbSize = sizeof(query);
303   -
304   - trace("%s(%d)",__FUNCTION__,query.addr);
305   -
306   - TransactNamedPipe((HANDLE) h,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL);
307   - return response.rc;
308   - }
309   -
310   - char * hllapi_pipe_get_text(void *h, int offset, int len)
311   - {
312   - struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, offset, len };
313   - struct hllapi_packet_text * response;
314   - DWORD cbSize = sizeof(struct hllapi_packet_text)+len;
315   - char * text = NULL;
316   -
317   - trace("cbSize=%d",(int) cbSize);
318   -
319   - response = malloc(cbSize+2);
320   - memset(response,0,cbSize+2);
321   -
322   - if(!TransactNamedPipe((HANDLE) h,(LPVOID) &query, sizeof(query), response, cbSize, &cbSize,NULL))
323   - return NULL;
324   -
325   - trace("rc=%d",response->packet_id);
326   -
327   - if(response->packet_id)
328   - errno = response->packet_id;
329   - else
330   - text = strdup(response->text);
331   -
332   - free(response);
333   - return text;
334   - }
src/plugins/remotectl/remotectl.h
... ... @@ -1,85 +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. 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 remotectl.h 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   - * Agradecimento:
29   - *
30   - * Hélio Passos
31   - *
32   - */
33   -
34   - #define ENABLE_NLS
35   - #define GETTEXT_PACKAGE PACKAGE_NAME
36   -
37   - #include <libintl.h>
38   - #include <glib/gi18n.h>
39   - #include <gtk/gtk.h>
40   -
41   - #include <lib3270.h>
42   - #include <lib3270/log.h>
43   - #include <pw3270/hllapi.h>
44   -
45   - typedef struct _remotequery
46   - {
47   -#ifdef WIN32
48   - HANDLE hPipe; /**< Pipe handle (for response) */
49   -#endif // WIN32
50   -
51   - H3270 * hSession; /**< 3270 Session */
52   - int cmd; /**< Command */
53   - int rc; /**< Response status */
54   -
55   - int pos;
56   - unsigned short length; /**< Query string length */
57   - const gchar * text; /**< Query string */
58   -
59   - } QUERY;
60   -
61   - G_GNUC_INTERNAL void set_active(gboolean on);
62   - G_GNUC_INTERNAL void enqueue_request(QUERY *qry);
63   - G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text);
64   -
65   - G_GNUC_INTERNAL void request_status(QUERY *qry, int rc);
66   - G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value);
67   - G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer);
68   -
69   -// int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc);
70   -
71   -
72   -#ifdef WIN32
73   -
74   - #define PIPE_BUFFER_LENGTH 8192
75   -
76   - void init_source_pipe(HANDLE hPipe);
77   - void popup_lasterror(const gchar *fmt, ...);
78   -
79   -#endif // WIN32
80   -
81   -
82   -
83   -
84   -
85   -
src/plugins/remotectl/server.h
... ... @@ -1,51 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como server.h 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   - #include <lib3270/config.h>
31   - #define ENABLE_NLS
32   - #define GETTEXT_PACKAGE PACKAGE_NAME
33   -
34   - #include <libintl.h>
35   - #include <glib/gi18n.h>
36   - #include <gtk/gtk.h>
37   -
38   - #include <lib3270.h>
39   - #include <lib3270/log.h>
40   - #include <pw3270.h>
41   - #include <pw3270/hllapi.h>
42   -
43   - #include <windows.h>
44   -
45   - #define PIPE_BUFFER_LENGTH HLLAPI_MAXLENGTH+30
46   -
47   - #define set_active(x) /* x */
48   -
49   -
50   - G_GNUC_INTERNAL void popup_lasterror(const gchar *fmt, ...);
51   -
src/plugins/remotectl/testprogram.c
... ... @@ -1,139 +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., 59 Temple
19   - * Place, Suite 330, Boston, MA, 02111-1307, USA
20   - *
21   - * Este programa está nomeado como testprogram.c 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   - #include <windows.h>
31   - #include <stdio.h>
32   - #include <time.h>
33   - #include <pw3270/hllapi.h>
34   -
35   - #define BUFFER_LENGTH 8000
36   -
37   -/*---[ Implement ]--------------------------------------------------------------------------------*/
38   -
39   - int main(int numpar, char *param[])
40   - {
41   - const char *session = "pw3270:a";
42   -
43   - printf("init(%s)=%d\n",session,(int) hllapi_init((LPSTR) session));
44   - printf("revision=%d\n",(int) hllapi_get_revision());
45   - printf("connect=%d\n",(int) hllapi_connect("fandezhi.efglobe.com:23",0));
46   - printf("wait=%d\n",(int) hllapi_wait(3));
47   - printf("connected=%s\n",(int) hllapi_is_connected() ? "Yes" : "No");
48   -
49   -// printf("disconnect=%d\n",(int) hllapi_disconnect("fandezhi.efglobe.com:23",1));
50   -
51   -
52   - printf("deinit=%d\n",(int) hllapi_deinit());
53   -
54   -/*
55   - DWORD revision;
56   - int rc;
57   -
58   - rc = hllapi_init("");
59   - if(rc)
60   - {
61   - printf("Init exits with rc=%d\n",rc);
62   - return rc;
63   - }
64   -
65   - if(!hllapi_get_revision(&revision))
66   - printf("Library revision is %d\n",(int) revision);
67   -
68   -
69   - printf("Deinit exits with rc=%d\n",rc);
70   - rc = hllapi_deinit();
71   -*/
72   - return 0;
73   - }
74   -
75   -/*
76   - int main(int numpar, char *param[])
77   - {
78   - char buffer[BUFFER_LENGTH];
79   - unsigned short rc;
80   - unsigned short len;
81   - unsigned long fn;
82   -
83   - static const struct _cmd
84   - {
85   - const char * name;
86   - unsigned short fn;
87   - const char * arg;
88   - } cmd[] =
89   - {
90   - { "GetRevision", HLLAPI_CMD_GETREVISION, " " },
91   - { "ConnectPS", HLLAPI_CMD_CONNECTPS, "pw3270A" },
92   - { "InputString", HLLAPI_CMD_INPUTSTRING, "test" },
93   -
94   - };
95   -
96   - int f;
97   -
98   -
99   - for(f=0;f< (sizeof(cmd)/sizeof(struct _cmd)); f++)
100   - {
101   - len = strlen(cmd[f].arg);
102   - memcpy(buffer,cmd[f].arg,len);
103   - hllapi((LPWORD) &cmd[f].fn,buffer,&len,&rc);
104   - printf("%s exits with rc=%d\n[%s]\n",cmd[f].name,rc,buffer);
105   - }
106   -
107   - len = 80;
108   - rc = 1040;
109   - fn = HLLAPI_CMD_COPYPSTOSTR;
110   - hllapi((LPWORD) &fn,buffer,&len,&rc);
111   - printf("%s exits with rc=%d\n%s\n","HLLAPI_CMD_COPYPSTOSTR",rc,buffer);
112   -
113   - // Performance
114   - len = strlen(cmd[0].arg);
115   - memcpy(buffer,cmd[0].arg,len);
116   - if(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0)
117   - {
118   - time_t end = time(0) + 5;
119   - int qtd = 0;
120   - do
121   - {
122   - qtd++;
123   - } while(hllapi((LPWORD) &cmd[0].fn,buffer,&len,&rc) == 0 && rc == 0 && time(0)<end);
124   - printf("%d interacoes em 5 segundos (rc=%d)\n",qtd,rc);
125   -
126   - }
127   -
128   - // Disconnect
129   - len = 10;
130   - rc = 1;
131   - fn = HLLAPI_CMD_DISCONNECTPS;
132   - *buffer = 0;
133   - hllapi((LPWORD) &fn,buffer,&len,&rc);
134   - printf("%s exits with rc=%d\n[%s]\n","HLLAPI_CMD_DISCONNECTPS",rc,buffer);
135   -
136   -
137   - return 0;
138   - }
139   -*/