-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathherclin.c
111 lines (91 loc) · 3.47 KB
/
herclin.c
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
102
103
104
105
106
107
108
109
110
111
/* HERCLIN.C (c) Copyright Roger Bowler, 2005-2012 */
/* Hercules Interface Control Program */
/* */
/* Released under "The Q Public License Version 1" */
/* (http://www.hercules-390.org/herclic.html) as modifications to */
/* Hercules. */
/************************************************/
/* (C) Copyright 2005-2009 Roger Bowler & Others*/
/* Initial author : Ivan Warren */
/* */
/* HERCLIN.C */
/* */
/* THIS IS SAMPLE CODE DEMONSTRATING */
/* THE USE OF THE INITIAL HARDWARE PANEL */
/* INTERFACE FEATURE. */
/************************************************/
#include "hstdinc.h"
#include "hercules.h"
#include "hextapi.h"
/**********************************************/
/* The following function is the LOG callback */
/* function. It gets called by the engine */
/* whenever a log message needs to be */
/* displayed. This function therefore */
/* might be invoked from a separate thread */
/**********************************************/
int hercules_has_exited = 0;
void log_callback( const char* msg, size_t msglen )
{
UNREFERENCED( msg );
if (!msglen)
{
hercules_has_exited = 1;
return;
}
fflush( stdout );
fwrite( msg, 1, msglen, stdout );
fflush( stdout );
fflush( stderr );
}
int main( int argc, char* argv[] )
{
int rc;
/*****************************************/
/* COMMANDHANDLER is the function type */
/* of the engine's panel command handler */
/* this MUST be resolved at run time */
/* since some HDL module might have */
/* redirected the initial engine function*/
/*****************************************/
COMMANDHANDLER process_command;
char *cmdbuf, *cmd;
#if defined( OPTION_DYNAMIC_LOAD ) && defined( HDL_USE_LIBTOOL )
/* LTDL Preloaded symbols for HDL using libtool */
LTDL_SET_PRELOADED_SYMBOLS();
#endif
/******************************************/
/* Register the 'log_callback' function */
/* as the log message callback routine */
/******************************************/
registerLogCallback( log_callback );
/******************************************/
/* Initialize the HERCULE Engine */
/******************************************/
if ((rc = impl( argc, argv )) == 0)
{
sysblk.panel_init = 1;
/******************************************/
/* Get the command handler function */
/* This MUST be done after IML */
/******************************************/
process_command = getCommandHandler();
/******************************************/
/* Read STDIN and pass to Command Handler */
/******************************************/
#define CMDBUFSIZ 1024
cmdbuf = (char*) malloc( CMDBUFSIZ );
do
{
if ((cmd = fgets( cmdbuf, CMDBUFSIZ, stdin )))
{
/* (remove newline) */
cmd[ strlen( cmd ) - 1 ] = 0;
process_command( cmd );
}
}
while (!hercules_has_exited);
sysblk.panel_init = 0;
}
return rc;
}