HP OpenVMS Systems Documentation |
| 前へ | 次へ | 目次 | 索引 |
次の例は XTPU$EDIT を呼び出して,INFILE.DAT 中のテキストを編集し,その結果を OUTFILE.DAT に書き込みます。XTPU$EDIT に渡すパラメータはディスクリプタ渡しでなければなりません。
/* Sample C program that calls DEC XTPU. This program uses XTPU$EDIT to provide the names of the input and output files */ #include descrip int return_status; static $DESCRIPTOR (input_file, "infile.dat"); static $DESCRIPTOR (output_file, "outfile.dat"); main (argc, argv) int argc; char *argv[]; { /* Call DEC XTPU to edit text in "infile.dat" and write the result to "outfile.dat". Return the condition code from DEC XTPU as the status of this program. */ return_status = XTPU$EDIT (&input_file, &output_file); exit (return_status); }
以下の例は,上の例と同じ動作をします。ここではエントリ・ポイントとして XTPU$XTPUを使います。XTPU$XTPU は引数として "XTPU" で始まるコマンド文字列を受け取ります。コマンド文字列には "EDIT/XTPU" コマンドに使用できるすべての修飾子を使用できます。
/* Sample C program that calls DEC XTPU. This program uses XTPU$XTPU and specifies a command string */ #include descrip int return_status; static $DESCRIPTOR (command_prefix, "XTPU/NOJOURNAL/NOCOMMAND/OUTPUT="); static $DESCRIPTOR (input_file, "infile.dat"); static $DESCRIPTOR (output_file, "outfile.dat"); static $DESCRIPTOR (space_desc, " "); char command_line [100]; static $DESCRIPTOR (command_desc, command_line); main (argc, argv) int argc; char *argv[]; { /* Build the command line for DEC XTPU. Note that the command verb is "XTPU". The string we construct in the buffer command_line will be "XTPU/NOJOURNAL/NOCOMMAND/OUTPUT=outfile.dat infile.dat" */ return_status = STR$CONCAT (&command_desc, &command_prefix, &output_file, &space_desc, &input_file); if (! return_status) exit (return_status); /* Now call DEC XTPU to edit the file */ return_status = XTPU$XTPU (&command_desc); exit (return_status); }
次節では,完全な呼び出し可能インタフェースによって呼び出されるルーチンについて詳しく説明します。単純な呼び出し可能インタフェースを使用した場合には,これらのルーチンがインタフェースによって呼び出されます。完全な呼び出し可能インタフェースを使用する場合には,ユーザ・プログラムが直接これらのルーチンを呼び出します。
6.3 完全な呼び出し可能インタフェース
DEC XTPU の完全な呼び出し可能インタフェースは,以下の作業を実行するために使用できる複数のルーチンから構成されています。
単純な呼び出し可能インタフェースを使用する場合には,上記の操作は自動的に実行されます。これらの機能を実行する各 DEC XTPU ルーチンはユーザ作成プログラムから呼び出すことができ,DEC XTPU の完全な呼び出し可能インタフェースと呼ばれます。このインタフェースには2種類のルーチンが含まれています。すなわち DEC XTPU の呼び出し可能なメイン・ルーチンと DEC XTPU ユーティリティ・ルーチンです。これらの DEC XTPU ルーチンと,DEC XTPU ルーチンにパラメータを渡すユーザ・ルーチンを使用することにより,アプリケーション・プログラムが DEC XTPU を制御します。
以降の節では,呼び出し可能なメイン・ルーチン,これらのルーチンに対するパラメータの受渡し方法,DEC XTPU ユーティリティ・ルーチン,およびユーザ作成ルーチンの必要条件について説明します。
6.3.1 主な呼び出し可能なDEC XTPU ユーティリティ・ルーチン
この節では,以下の呼び出し可能なDEC XTPU ルーチンについて説明します。
これらのルーチンを呼び出す前に,条件ハンドラとして XTPU$HANDLER かまたはユーザ独自のルーチンを設定しておかなければなりません。条件ハンドラの設定については,この章の XTPU$HANDLER ルーチンの説明および『OpenVMS Calling Standard』を参照してください。 |
完全な呼び出し可能インタフェースにはユーティリティ・ルーチンがいくつか含まれており,それらに対してはパラメータを渡すことができます。アプリケーションによっては,ユーザ独自のルーチンの代わりにこれらのルーチンが利用できる場合があります。ユーティリティ・ルーチンには以下のものがあります。
| XTPU$CLIPARSE | コマンド・ラインを解析し,XTPU$INITIALIZE 用のアイテム・リストを作成する |
| XTPU$PARSEINFO | コマンドを解析し,XTPU$INITIALIZE 用のアイテム・リストを作成する |
| XTPU$FILEIO | 省略時のファイル入出力ルーチン |
| XTPU$MESSAGE | MESSAGE 組込みプロシージャを使ってエラー・メッセージや文字列を出力する |
| XTPU$HANDLER | 省略時の条件ハンドラ |
| XTPU$CLOSE_TERMINAL | CALL_USER ルーチンの実行中,DEC XTPU のターミナルへのチャネルをクローズする |
| XTPU$SPECIFY_ASYNC_ACTION | XTPU$CONTROL ルーチンを中断するための非同期イベントを指定する |
| XTPU$TRIGGER_ASYNC_ACTION | 指定の非同期イベントで XTPU$CONTROL ルーチンを中断する |
XTPU$CLIPARSE および XTPU$PARSEINFO は,コマンド解析のために CLI$ ルーチンによって保持されているデータを破壊することに注意してください。
6.3.3 ユーザ作成ルーチン
この節では,ユーザ作成ルーチンの必要条件を定義します。これらのルーチンを DEC XTPU に渡す場合には,バウンド・プロシージャ値として渡さなければなりません (バウンド・プロシージャ値については 第 6.1.3 項 を参照してください)。アプリケーションに応じて,以下に示すルーチンのうち,1つまたはすべてを作成しなければなりません。
例 6-1 , 例 6-2 ,および 例 6-3 は,呼び出し可能な DECXTPU を使用したものです。これらの例は解説を目的としたものであり,DEC はこれらの信頼性について,その責任を負いません。
| 例 6-1 DEC FORTRAN における通常のDEC XTPU セットアップ |
|---|
C A sample FORTRAN program that calls DEC XTPU to act
C normally, using the programmable interface.
C
C IMPLICIT NONE
INTEGER*4 CLEAN_OPT !options for clean up routine
INTEGER*4 STATUS !return status from DEC XTPU routines
INTEGER*4 BPV_PARSE(2) !set up a Bound Procedure Value
INTEGER*4 LOC_PARSE !a local function call
C declare the DEC XTPU functions
INTEGER*4 XTPU$CONTROL
INTEGER*4 XTPU$CLEANUP
INTEGER*4 XTPU$EXECUTE_INIFILE
INTEGER*4 XTPU$INITIALIZE
INTEGER*4 XTPU$CLIPARSE
C declare a local copy to hold the values of DEC XTPU cleanup variables
INTEGER*4 RESET_TERMINAL
INTEGER*4 DELETE_JOURNAL
INTEGER*4 DELETE_BUFFERS,DELETE_WINDOWS
INTEGER*4 DELETE_EXITH,EXECUTE_PROC
INTEGER*4 PRUNE_CACHE,KILL_PROCESSES
INTEGER*4 CLOSE_SECTION
INTEGER*4 CLOSE_KANJI_DIC
C declare the DEC XTPU functions used as external
EXTERNA XTPU$HANDLER
EXTERNAL XTPU$CLIPARSE
EXTERNAL XTPU$_SUCCESS !external error message
EXTERNAL LOC_PARSE !user supplied routine to
C call TPUCLIPARSE and setup
C declare the DEC XTPU cleanup variables as external these are the
C external literals that hold the value of the options
EXTERNAL XTPU$M_RESET_TERMINAL
EXTERNAL XTPU$M_DELETE_JOURNAL
EXTERNAL XTPU$M_DELETE_BUFFERS,XTPU$M_DELETE_WINDOWS
EXTERNAL XTPU$M_DELETE_EXITH,XTPU$M_EXECUTE_PROC
EXTERNAL XTPU$M_PRUNE_CACHE,XTPU$M_KILL_PROCESSES
EXTERNAL XTPU$M_CLOSE_KANJI_DIC
100 CALL LIB$ESTABLISH ( XTPU$HANDLER ) !establish the condition handler
C set up the Bound Procedure Value for the call to XTPU$INITIALIZE
BPV_PARSE( 1 ) = %LOC( LOC_PARSE )
BPV_PARSE( 2 ) = 0
C call the DEC XTPU initialization routine to do some set up work
STATUS = XTPU$INITIALIZE ( BPV_PARSE )
C Check the status if it is not a success then signal the error
IF ( STATUS .NE. %LOC ( XTPU$_SUCCESS ) ) THEN
CALL LIB$SIGNAL( %VAL( STATUS ) )
GOTO 9999
ENDIF
C execute the XTPU$_ init files and also a command file if it
C was specified in the command line call to DEC XTPU
STATUS = XTPU$EXECUTE_INIFILE ( )
IF ( STATUS .NE. %LOC ( XTPU$_SUCCESS ) ) THEN
CALL LIB$SIGNAL( %VAL( STATUS ) )
GOTO 9999
ENDIF
C invoke the editor as it normally would appear
STATUS = XTPU$CONTROL ( ) !call the DEC XTPU editor
IF ( STATUS .NE. %LOC ( XTPU$_SUCCESS ) ) THEN
CALL LIB$SIGNAL( %VAL( STATUS ) )
C GOTO 9999
ENDIF
C Get the value of the option from the external literals. In FORTRAN you
C cannot use external literals directly so you must first get the value
C of the literal from its external location. Here we are getting the
C values of the options that we want to use in the call to XTPU$CLEANUP.
DELETE_JOURNAL = %LOC ( XTPU$M_DELETE_JOURNAL )
DELETE_EXITH = %LOC ( XTPU$M_DELETE_EXITH )
DELETE_BUFFERS = %LOC ( XTPU$M_DELETE_BUFFERS )
DELETE_WINDOWS = %LOC ( XTPU$M_DELETE_WINDOWS )
EXECUTE_PROC = %LOC ( XTPU$M_EXECUTE_PROC )
RESET_TERMINAL = %LOC ( XTPU$M_RESET_TERMINAL )
KILL_PROCESSES = %LOC ( XTPU$M_KILL_PROCESSES )
CLOSE_SECTION = %LOC ( XTPU$M_CLOSE_SECTION )
CLOSE_KANJI_DIC = %LOC ( XTPU$M_CLOSE_KANJI_DIC )
C Now that we have the local copies of the variables we can do the
C logical OR to set the multiple options that we need.
CLEAN_OPT = DELETE_JOURNAL .OR. DELETE_EXITH .OR.
1 DELETE_BUFFERS .OR. DELETE_WINDOWS .OR. EXECUTE_PROC
1 .OR. RESET_TERMINAL .OR. KILL_PROCESSES .OR. CLOSE_SECTION
1 .OR. CLOSE_KANJI_DIC
C do the necessary clean up
C XTPU$CLEANUP wants the address of the flags as the parameter so
C pass the %LOC of CLEAN_OPT which is the address of the variable
STATUS = XTPU$CLEANUP ( %LOC ( CLEAN_OPT ) )
IF ( STATUS .NE. %LOC (XTPU$_SUCCESS) ) THEN
CALL LIB$SIGNAL( %VAL(STATUS) )
ENDIF
9999 CALL LIB$REVERT !go back to normal processing -- handlers
STOP
END
C
C
INTEGER*4 FUNCTION LOC_PARSE
INTEGER*4 BPV(2) !A local Bound Procedure Value
CHARACTER*13 EDIT_COMM !A command line to send to XTPU$CLIPARSE
C Declare the DEC XTPU functions used
INTEGER*4 XTPU$FILEIO
INTEGER*4 XTPU$CLIPARSE
C Declare this routine as external because it is never called directly and
C we need to tell FORTRAN that it is a function and not a variable
EXTERNAL XTPU$FILEIO
BPV(1) = %LOC(XTPU$FILEIO) !set up the BOUND PROCEDURE VALUE
BPV(2) = 0
EDIT_COMM(1:18) = 'EDIT/XTPU TEST.TXT'
C parse the command line and build the item list for XTPU$INITIALIZE
9999 LOC_PARSE = XTPU$CLIPARSE (EDIT_COMM, BPV , 0)
RETURN
END
|
| 例 6-2 DEC FORTRAN でのコール・バック項目リストの作成 |
|---|
PROGRAM TEST_TPU
C
IMPLICIT NONE
C
C Define the expected DEC XTPU return statuses
C
EXTERNAL XTPU$_SUCCESS
EXTERNAL XTPU$_QUITTING
C
C Declare the DEC XTPU routines and symbols used
C
EXTERNAL XTPU$M_DELETE_CONTEXT
EXTERNAL XTPU$HANDLER
INTEGER*4 XTPU$M_DELETE_CONTEXT
INTEGER*4 XTPU$INITIALIZE
INTEGER*4 XTPU$EXECUTE_INIFILE
INTEGER*4 XTPU$CONTROL
INTEGER*4 XTPU$CLEANUP
C
C Declare the external callback routine
C
EXTERNAL TPU_STARTUP ! the DEC XTPU set-up function
INTEGER*4 TPU_STARTUP
INTEGER*4 BPV(2) ! Set up a bound procedure value
C
C Declare the functions used for working with the condition handler
C
INTEGER*4 LIB$ESTABLISH
INTEGER*4 LIB$REVERT
C
C Local Flags and Indices
C
INTEGER*4 CLEANUP_FLAG ! flag(s) for DEC XTPU cleanup
INTEGER*4 RET_STATUS
C
C Initializations
C
RET_STATUS = 0
CLEANUP_FLAG = %LOC(XTPU$M_DELETE_CONTEXT)
C
C Establish the default DEC XTPU condition handler
C
CALL LIB$ESTABLISH(%REF(XTPU$HANDLER))
C
C Set up the bound procedure value for the initialization callback
C
BPV(1) = %LOC (TPU_STARTUP)
BPV(2) = 0
C
C Call the DEC XTPU procedure for initialization
C
RET_STATUS = XTPU$INITIALIZE(BPV)
IF (RET_STATUS .NE. %LOC(XTPU$_SUCCESS)) THEN
CALL LIB$SIGNAL (%VAL(RET_STATUS))
ENDIF
C
C Execute the DEC XTPU initialization file
C
RET_STATUS = XTPU$EXECUTE_INIFILE()
IF (RET_STATUS .NE. %LOC(XTPU$_SUCCESS)) THEN
CALL LIB$SIGNAL (%VAL(RET_STATUS))
ENDIF
C
C Pass control to DEC XTPU
C
RET_STATUS = XTPU$CONTROL()
IF (RET_STATUS .NE. %LOC(XTPU$_QUITTING)
1 .OR. %LOC(XTPU$_QUITTING)) THEN
CALL LIB$SIGNAL (%VAL(RET_STATUS))
ENDIF
C
C Clean up after processing
C
RET_STATUS = XTPU$CLEANUP(%REF(CLEANUP_FLAG))
IF (RET_STATUS .NE. %LOC(XTPU$_SUCCESS)) THEN
CALL LIB$SIGNAL (%VAL(RET_STATUS))
ENDIF
C
C Set the condition handler back to the default
C
RET_STATUS = LIB$REVERT()
END
INTEGER*4 FUNCTION TPU_STARTUP
IMPLICIT NONE
INTEGER*4 OPTION_MASK ! temporary variable for DEC XTPU
CHARACTER*44 SECTION_NAME ! temporary variable for DEC XTPU
C
C External DEC XTPU routines and symbols
C
EXTERNAL XTPU$K_OPTIONS
EXTERNAL XTPU$M_READ
EXTERNAL XTPU$M_SECTION
EXTERNAL XTPU$M_DISPLAY
EXTERNAL XTPU$K_SECTIONFILE
EXTERNAL XTPU$K_FILEIO
EXTERNAL XTPU$FILEIO
INTEGER*4 XTPU$FILEIO
C
C The bound procedure value used for setting up the file I/O routine
C
INTEGER*4 BPV(2)
C
C Define the structure of the item list defined for the callback
C
STRUCTURE /CALLBACK/
INTEGER*2 BUFFER_LENGTH
INTEGER*2 ITEM_CODE
INTEGER*4 BUFFER_ADDRESS
INTEGER*4 RETURN_ADDRESS
END STRUCTURE
C
C There are a total of four items in the item list
C
RECORD /CALLBACK/ CALLBACK (4)
C
C Make sure it is not optimized!
C
VOLATILE /CALLBACK/
C
C Define the options we want to use in the DEC XTPU session
C
OPTION_MASK = %LOC(XTPU$M_SECTION) .OR. %LOC(XTPU$M_READ)
1 .OR. %LOC(XTPU$M_DISPLAY)
C
C Define the name of the initialization section file
C
SECTION_NAME = 'SYS$SHARE:JEVE$SECTION_V3.XTPU$SECTION'
C
C Set up the required I/O routine. Use the DEC XTPU default.
C
BPV(1) = %LOC(XTPU$FILEIO)
BPV(2) = 0
C
C Build the callback item list
C
C Set up the edit session options
C
CALLBACK(1).ITEM_CODE = %LOC(XTPU$K_OPTIONS)
CALLBACK(1).BUFFER_ADDRESS = %LOC(OPTION_MASK)
CALLBACK(1).BUFFER_LENGTH = 4
CALLBACK(1).RETURN_ADDRESS = 0
C
C Identify the section file to be used
C
CALLBACK(2).ITEM_CODE = %LOC(XTPU$K_SECTIONFILE)
CALLBACK(2).BUFFER_ADDRESS = %LOC(SECTION_NAME)
CALLBACK(2).BUFFER_LENGTH = LEN(SECTION_NAME)
CALLBACK(2).RETURN_ADDRESS = 0
C
C Set up the I/O handler
C
CALLBACK(3).ITEM_CODE = %LOC(XTPU$K_FILEIO)
CALLBACK(3).BUFFER_ADDRESS = %LOC(BPV)
CALLBACK(3).BUFFER_LENGTH = 4
CALLBACK(3).RETURN_ADDRESS = 0
C
C End the item list with zeros to indicate we are finished
C
CALLBACK(4).ITEM_CODE = 0
CALLBACK(4).BUFFER_ADDRESS = 0
CALLBACK(4).BUFFER_LENGTH = 0
CALLBACK(4).RETURN_ADDRESS = 0
C
C Return the address of the item list
C
TPU_STARTUP = %LOC(CALLBACK)
RETURN
END
|
| 例 6-3 DEC C でのユーザ作成ファイルの入出力ルーチンの指定 |
|---|
/*
Simple example of a C program to invoke DEC XTPU. This program provides its
own FILEIO routine instead of using the one provided by DEC XTPU.
*/
#include descrip
#include stdio
/* data structures needed */
struct bpv_arg /* bound procedure value */
{
int *routine_add ; /* pointer to routine */
int env ; /* environment pointer */
} ;
struct item_list_entry /* item list data structure */
{
short int buffer_length; /* buffer length */
short int item_code; /* item code */
int *buffer_add; /* buffer address */
int *return_len_add; /* return address */
} ;
struct stream_type
{
int ident; /* stream id */
short int alloc; /* file size */
short int flags; /* file record attributes/format */
short int length; /* resultant file name length */
short int stuff; /* file name descriptor class & type */
int nam_add; /* file name descriptor text pointer */
} ;
globalvalue xtpu$_success; /* DEC XTPU Success code */
globalvalue xtpu$_quitting; /* Exit code defined by DEC XTPU */
globalvalue /* Cleanup codes defined by DEC XTPU */
xtpu$m_delete_journal, xtpu$m_delete_exith,
xtpu$m_delete_buffers, xtpu$m_delete_windows, xtpu$m_delete_cache,
xtpu$m_prune_cache, xtpu$m_execute_file, xtpu$m_execute_proc,
xtpu$m_delete_context, xtpu$m_reset_terminal, xtpu$m_kill_processes,
xtpu$m_close_section, xtpu$m_delete_others, xtpu$m_last_time;
globalvalue /* Item codes for item list entries */
xtpu$_fileio, xtpu$_options, xtpu$_sectionfile,
xtpu$_commandfile ;
globalvalue /* Option codes for option item */
xtpu$m_display, xtpu$m_section, xtpu$m_command, xtpu$m_create ;
globalvalue /* Possible item codes in item list */
xtpu$k_access, xtpu$k_filename, xtpu$k_defaultfile,
xtpu$k_relatedfile, xtpu$k_record_attr, xtpu$k_maximize_ver,
xtpu$k_flush, xtpu$k_filesize;
globalvalue /* Possible access types for xtpu$k_access */
xtpu$k_io, xtpu$k_input, xtpu$k_output;
globalvalue /* RMS File Not Found message code */
rms$_fnf;
globalvalue /* FILEIO routine functions */
xtpu$k_open, xtpu$k_close, xtpu$k_close_delete,
xtpu$k_get, xtpu$k_put;
int lib$establish (); /* RTL routine to establish an event handler */
int xtpu$cleanup (); /* XTPU routine to free resources used */
int xtpu$control (); /* XTPU routine to invoke the editor */
int xtpu$execute_inifile (); /* XTPU routine to execute initialization code */
int xtpu$handler (); /* XTPU signal handling routine */
int xtpu$initialize (); /* XTPU routine to initialize the editor */
/*
This function opens a file for either read or write access, based upon
the itemlist passed as the data parameter. Note that a full implementation
of the file open routine would have to handle the default file, related
file, record attribute, maximize version, flush and file size item code
properly.
*/
open_file (data, stream)
int *data;
struct stream_type *stream;
{
struct item_list_entry *item;
char *access; /* File access type */
char filename[256]; /* Max file specification size */
/* Process the item list */
item = data;
while (item->item_code != 0 && item->buffer_length != 0)
{
if (item->item_code == xtpu$k_access)
{
if (item->buffer_add == xtpu$k_io) access = "r+";
else if (item->buffer_add == xtpu$k_input) access = "r";
else if (item->buffer_add == xtpu$k_output) access = "w";
}
else if (item->item_code == xtpu$k_filename)
{
strncpy (filename, item->buffer_add, item->buffer_length);
filename [item->buffer_length] = 0;
lib$scopy_r_dx (&item->buffer_length, item->buffer_add,
&stream->length);
}
else if (item->item_code == xtpu$k_defaultfile)
{ /* Add code to handle default file */
} /* spec here */
else if (item->item_code == xtpu$k_relatedfile)
{ /* Add code to handle related */
} /* file spec here */
else if (item->item_code == xtpu$k_record_attr)
{ /* Add code to handle record */
} /* attributes for creating files */
else if (item->item_code == xtpu$k_maximize_ver)
{ /* Add code to maximize version */
} /* number with existing file here */
else if (item->item_code == xtpu$k_flush)
{ /* Add code to cause each record */
} /* to be flushed to disk as written */
else if (item->item_code == xtpu$k_filesize)
{ /* Add code to handle specification */
} /* of initial file allocation here */
++item; /* get next item */
}
stream->ident = fopen(filename,access);
if (stream->ident != 0)
return xtpu$_success;
else
return rms$_fnf;
}
/*
This procedure closes a file
*/
close_file (data,stream)
struct stream_type *stream;
{
close(stream->ident);
return xtpu$_success;
}
/*
This procedure reads a line from a file
*/
read_line(data,stream)
struct dsc$descriptor *data;
struct stream_type *stream;
{
char textline[984]; /* max line size for XTPU records */
int len;
globalvalue rms$_eof; /* RMS End-Of-File code */
if (fgets(textline,984,stream->ident) == NULL)
return rms$_eof;
else
{
len = strlen(textline);
if (len > 0)
len = len - 1;
return lib$scopy_r_dx (&len, textline, data);
}
}
/*
This procedure writes a line to a file
*/
write_line(data,stream)
struct dsc$descriptor *data;
struct stream_type *stream;
{
char textline[984]; /* max line size for XTPU records */
strncpy (textline, data->dsc$a_pointer, data->dsc$w_length);
textline [data->dsc$w_length] = 0;
fputs(textline,stream->ident);
fputs("\n",stream->ident);
return xtpu$_success;
}
/*
This procedure will handle I/O for XTPU
*/
fileio(code,stream,data)
int *code;
int *stream;
int *data;
{
int status;
/* Dispatch based on code type. Note that a full implementation of the */
/* file I/O routines would have to handle the close and delete code properly */
/* instead of simply closing the file */
if (*code == xtpu$k_open) /* Initial access to file */
status = open_file (data,stream);
else if (*code == xtpu$k_close) /* End access to file */
status = close_file (data,stream);
else if (*code == xtpu$k_close_delete) /* Treat same as close */
status = close_file (data,stream);
else if (*code == xtpu$k_get) /* Read a record from a file */
status = read_line (data,stream);
else if (*code == xtpu$k_put) /* Write a record to a file */
status = write_line (data,stream);
else
{ /* Who knows what we got? */
status = xtpu$_success;
printf ("Bad FILEIO I/O function requested");
}
return status;
}
/*
This procedure formats the initialization item list and returns it as
is return value.
*/
callrout()
{
static struct bpv_arg add_block =
{ fileio, 0 } ; /* BPV for fileio routine */
int options ;
char *section_name = "XTPU$SECTION";
static struct item_list_entry arg[4];
/* Setup file I/O routine item entry */
arg[0].item_code = (unsigned short int) xtpu$_fileio;
arg[0].buffer_length = 4;
arg[0].buffer_add = &add_block;
arg[0].return_len_add = 0;
/* Setup options item entry. Leave journaling off. */
options = xtpu$m_display | xtpu$m_section;
arg[1].item_code = (unsigned short int) xtpu$_options;
arg[1].buffer_length = 4;
arg[1].buffer_add = &options;
arg[1].return_len_add = 0;
/* Setup section file name */
arg[2].item_code = (unsigned short int) xtpu$_sectionfile;
arg[2].buffer_length = strlen(section_name);
arg[2].buffer_add = section_name;
arg[2].return_len_add = 0;
arg[3].item_code = 0;
arg[3].buffer_length = 0;
arg[3].buffer_add = 0;
arg[3].return_len_add = 0;
return arg;
}
/*
Main program. Initializes XTPU, then passes control to it.
*/
main()
{
int return_status ;
int cleanup_options;
struct bpv_arg add_block;
/* Establish as condition handler the normal DEC XTPU handler */
lib$establish(xtpu$handler);
/* Setup a BPV to point to the callback routine */
add_block.routine_add = callrout ;
add_block.env = 0;
/* Do the initialize of XTPU */
return_status = xtpu$initialize(&add_block);
if (!return_status)
exit(return_status);
/* Have XTPU execute the procedure XTPU$INIT_PROCEDURE from the section file */
/* and then compile and execute the code from the command file */
return_status = xtpu$execute_inifile();
if (!return_status)
exit (return_status);
/* Turn control over to XTPU */
return_status = xtpu$control ();
if (!return_status)
exit(return_status);
/* Now clean up. */
cleanup_options = xtpu$m_last_time | xtpu$m_delete_context;
return_status = xtpu$cleanup (&cleanup_options);
exit (return_status);
printf("Experiment complete");
}
|
| 前へ | 次へ | 目次 | 索引 |