testprogram.c
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <stdio.h>
#include <string.h>
// #include <pthread.h>
#include "globals.h"
#include <lib3270/macros.h>
#define MAX_ARGS 10
static H3270 *session = NULL;
static void * mainloop(void *dunno)
{
while(session)
{
lib3270_main_iterate(session,1);
}
return NULL;
}
int main(int numpar, char *param[])
{
H3270 * h;
int rc = 0;
// char line[4096];
// pthread_t thread;
lib3270_initialize();
session = h = lib3270_session_new("");
printf("3270 session %p created\n]",h);
// lib3270_set_toggle(session,LIB3270_TOGGLE_DS_TRACE,1);
// pthread_create(&thread, NULL, mainloop, NULL);
// pthread_detach(thread);
// rc = lib3270_connect_host(h, "fandezhi.efglobe.com", "telnet", LIB3270_CONNECT_OPTION_WAIT);
// rc = lib3270_connect_host(h, "127.0.0.1", "9090", LIB3270_CONNECT_OPTION_WAIT);
// lib3270_set_host_url(h,"tn3270://fandezhi.efglobe.com:9090?lu=default");
lib3270_set_host(h,"tn3270://fandezhi.efglobe.com");
printf("\nConnect exits with rc=%d\n",rc);
mainloop(0);
/*
while(fgets(line,4095,stdin))
{
// const LIB3270_MACRO_LIST *cmd = get_3270_calls();
int f;
int argc = 0;
const char * argv[MAX_ARGS+1];
char * ptr;
line[4095] = 0; // Just in case.
for(ptr = line;ptr && *ptr != '\n';ptr++);
*ptr = 0;
if(!*line)
break;
argv[argc++] = strtok(line," ");
for(f=1;f<MAX_ARGS;f++)
{
if( (argv[argc++] = strtok(NULL," ")) == NULL)
break;
}
argv[argc] = NULL;
if(!strcmp(argv[0],"quit"))
break;
ptr = lib3270_run_macro(h,argv);
if(ptr)
{
printf("\n%s\n",ptr);
lib3270_free(ptr);
}
else
{
printf("\nNo response\n");
}
printf("\n]");
}
session = 0;
pthread_cancel(thread);
printf("Ending 3270 session %p\n",h);
lib3270_session_free(h);
*/
return 0;
}