Commit b0197eced2223614d5f463692c21e4476ba48022
1 parent
ab92de78
Exists in
master
Melhorando aplicativo de teste da biblioteca
Showing
4 changed files
with
82 additions
and
29 deletions
Show diff stats
src/lib/globals.h
@@ -349,5 +349,6 @@ enum state_change | @@ -349,5 +349,6 @@ enum state_change | ||
349 | 349 | ||
350 | /* Library internal calls */ | 350 | /* Library internal calls */ |
351 | void key_ACharacter(unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); | 351 | void key_ACharacter(unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); |
352 | +void lib3270_initialize(void); | ||
352 | 353 | ||
353 | 354 |
src/lib/lib3270.cbp
@@ -7,8 +7,8 @@ | @@ -7,8 +7,8 @@ | ||
7 | <Option compiler="gcc" /> | 7 | <Option compiler="gcc" /> |
8 | <Build> | 8 | <Build> |
9 | <Target title="Debug"> | 9 | <Target title="Debug"> |
10 | - <Option output=".bin\Debug\lib3270" prefix_auto="1" extension_auto="1" /> | ||
11 | - <Option object_output=".obj\Debug\" /> | 10 | + <Option output=".bin/Debug/lib3270" prefix_auto="1" extension_auto="1" /> |
11 | + <Option object_output=".obj/Debug/" /> | ||
12 | <Option type="1" /> | 12 | <Option type="1" /> |
13 | <Option compiler="gcc" /> | 13 | <Option compiler="gcc" /> |
14 | <Compiler> | 14 | <Compiler> |
@@ -17,8 +17,8 @@ | @@ -17,8 +17,8 @@ | ||
17 | </Compiler> | 17 | </Compiler> |
18 | </Target> | 18 | </Target> |
19 | <Target title="Release"> | 19 | <Target title="Release"> |
20 | - <Option output=".bin\Release\lib3270" prefix_auto="1" extension_auto="1" /> | ||
21 | - <Option object_output=".obj\Release\" /> | 20 | + <Option output=".bin/Release/lib3270" prefix_auto="1" extension_auto="1" /> |
21 | + <Option object_output=".obj/Release/" /> | ||
22 | <Option type="3" /> | 22 | <Option type="3" /> |
23 | <Option compiler="gcc" /> | 23 | <Option compiler="gcc" /> |
24 | <Option createDefFile="1" /> | 24 | <Option createDefFile="1" /> |
@@ -33,8 +33,9 @@ | @@ -33,8 +33,9 @@ | ||
33 | </Build> | 33 | </Build> |
34 | <Compiler> | 34 | <Compiler> |
35 | <Add option="-Wall" /> | 35 | <Add option="-Wall" /> |
36 | - <Add directory="..\include" /> | ||
37 | - <Add directory="..\include\lib3270" /> | 36 | + <Add option="-DLIB3270=1" /> |
37 | + <Add directory="../include" /> | ||
38 | + <Add directory="../include/lib3270" /> | ||
38 | </Compiler> | 39 | </Compiler> |
39 | <Unit filename="Makefile.in" /> | 40 | <Unit filename="Makefile.in" /> |
40 | <Unit filename="XtGlue.c"> | 41 | <Unit filename="XtGlue.c"> |
@@ -163,9 +164,8 @@ | @@ -163,9 +164,8 @@ | ||
163 | <Option compilerVar="CC" /> | 164 | <Option compilerVar="CC" /> |
164 | </Unit> | 165 | </Unit> |
165 | <Unit filename="telnetc.h" /> | 166 | <Unit filename="telnetc.h" /> |
166 | - <Unit filename="tesprogram.c"> | 167 | + <Unit filename="testprogram.c"> |
167 | <Option compilerVar="CC" /> | 168 | <Option compilerVar="CC" /> |
168 | - <Option target="Debug" /> | ||
169 | </Unit> | 169 | </Unit> |
170 | <Unit filename="tn3270e.h" /> | 170 | <Unit filename="tn3270e.h" /> |
171 | <Unit filename="toggles.c"> | 171 | <Unit filename="toggles.c"> |
src/lib/tesprogram.c
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | - | ||
2 | -#include <stdio.h> | ||
3 | -#include <lib3270.h> | ||
4 | - | ||
5 | -int main(int numpar, char *param[]) | ||
6 | -{ | ||
7 | - H3270 *h; | ||
8 | - | ||
9 | - lib3270_initialize(); | ||
10 | - | ||
11 | - h = lib3270_session_new(""); | ||
12 | - printf("3270 session %p created\n",h); | ||
13 | - | ||
14 | - | ||
15 | - | ||
16 | - | ||
17 | - printf("Ending 3270 session %p\n",h); | ||
18 | - lib3270_session_free(h); | ||
19 | - | ||
20 | - return 0; | ||
21 | -} |
@@ -0,0 +1,73 @@ | @@ -0,0 +1,73 @@ | ||
1 | + | ||
2 | +#include <stdio.h> | ||
3 | +#include <string.h> | ||
4 | +#include "globals.h" | ||
5 | +#include <lib3270/macros.h> | ||
6 | + | ||
7 | +#define MAX_ARGS 10 | ||
8 | + | ||
9 | +int main(int numpar, char *param[]) | ||
10 | +{ | ||
11 | + H3270 * h; | ||
12 | + char line[4096]; | ||
13 | + | ||
14 | + lib3270_initialize(); | ||
15 | + | ||
16 | + h = lib3270_session_new(""); | ||
17 | + printf("3270 session %p created\n]",h); | ||
18 | + | ||
19 | + while(fgets(line,4095,stdin)) | ||
20 | + { | ||
21 | + const LIB3270_MACRO_LIST *cmd = get_3270_calls(); | ||
22 | + | ||
23 | + int f; | ||
24 | + int argc = 0; | ||
25 | + const char * argv[MAX_ARGS]; | ||
26 | + char * ptr; | ||
27 | + | ||
28 | + line[4095] = 0; // Just in case. | ||
29 | + | ||
30 | + for(ptr = line;ptr && *ptr != '\n';ptr++); | ||
31 | + *ptr = 0; | ||
32 | + | ||
33 | + if(!*line) | ||
34 | + break; | ||
35 | + | ||
36 | + argv[argc++] = strtok(line," "); | ||
37 | + for(f=1;f<MAX_ARGS;f++) | ||
38 | + { | ||
39 | + if( (argv[argc++] = strtok(NULL," ")) == NULL) | ||
40 | + break; | ||
41 | + } | ||
42 | + argc--; | ||
43 | + | ||
44 | + if(!strcmp(argv[0],"quit")) | ||
45 | + break; | ||
46 | + | ||
47 | + for(f=0;cmd[f].name;f++) | ||
48 | + { | ||
49 | + if(!strcmp(cmd[f].name,argv[0])) | ||
50 | + { | ||
51 | + char *str = cmd[f].exec(h,argc,argv); | ||
52 | + if(str) | ||
53 | + { | ||
54 | + printf("\n%s\n",str); | ||
55 | + free(str); | ||
56 | + } | ||
57 | + else | ||
58 | + { | ||
59 | + printf("\nNo response\n"); | ||
60 | + } | ||
61 | + break; | ||
62 | + } | ||
63 | + } | ||
64 | + | ||
65 | + printf("\n]"); | ||
66 | + | ||
67 | + } | ||
68 | + | ||
69 | + printf("Ending 3270 session %p\n",h); | ||
70 | + lib3270_session_free(h); | ||
71 | + | ||
72 | + return 0; | ||
73 | +} |