日本-日本語
日本HPホーム 製品 & サービス OpenVMS製品情報
≫  お問い合わせ


OpenVMS マニュアル


 

OpenVMS ドキュメント
ライブラリ

タイトルページ
目次
まえがき
第 1 章:DEC XTPU の概要
第 2 章:DEC XTPU のデータ・タイプ
第 3 章:DEC XTPU 言語のレキシカル要素
第 4 章:DEC XTPU 組込みプロシージャ
第 5 章:DEC XTPU の起動
第 6 章:呼び出し可能なDEC XTPU
付録 A :DEC XTPUにおける端末装置のサポートと制限事項
付録 B :DEC XTPU メッセージ
索引
PDF
OpenVMS ホーム
日本語 HP OpenVMS

日本語 HP OpenVMS
DEC XTPU リファレンス・マニュアル


目次 索引

例 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"); 
} 
 



6.5 DEC XTPU ルーチン

この節では,個々の DEC XTPU ルーチンについて,ルーチン・プレート形式で説明します。




ユーザ作成ルーチン FILEIO は,DEC XTPU のファイル操作を処理するのに使用されます。このルーチンの名前は,ユーザ独自のファイル入出力ルーチンのものであるか,または DEC XTPU のファイル入出力ルーチンの名前 (XTPU$FILEIO) のいずれかです。

形式

FILEIO code, stream, data


戻り値



OpenVMS 用法 条件値
データ型 符号なしロングワード
アクセス 書き込みのみ
受け渡し方 参照による


ロングワードの条件値です。ユーティリティ・ルーチンはほとんど,条件値を R0 に戻します。このルーチンから戻される可能性のある条件値は,"戻される条件値"にまとめられています。


引数



code

OpenVMS 用法 符号なしロングワード
データ型 符号なしロングワード
アクセス 読み取りのみ
受け渡し方 ディスクリプタによる


実行する機能を指定するDEC XTPU からのアイテム・コードです。code 引数は実行する機能を指定するDEC XTPU からのアイテム・コードを含むロングワードのアドレスです。

stream

OpenVMS 用法 未指定
データ型 符号なしロングワード
アクセス 変更
受け渡し方 参照による


ファイル記述です。stream 引数は,4つのロングワードを含むデータ構造のアドレスです。このデータ構造は,操作するファイルを記述するために使用されます。

data

OpenVMS 用法 アイテム・リスト3
データ型 符号なしロングワード
アクセス 変更
受け渡し方 参照による


ストリーム・データです。data 引数はアイテム・リストのアドレス,またはディスクリプタのアドレスです。

このパラメータの値は,どのアイテム・コードを指定したかによって異なります。


説明

このルーチンのバウンド・プロシージャ値は,コールバック・ルーチンによって作成されたアイテム・リストの中に指定されているものです。このルーチンは,ファイル操作を実行するために呼び出されます。ユーザが作成した独自のファイル入出力ルーチンを使用する代わりに,処理させるファイル操作をパラメータとして XTPU$FILEIO を呼び出すことができます。ただし,XTPU$FILEIO は,それがオープンしたファイルについてはすべての入出力要求を処理しなければならず,また,オープンしていないファイルに対しては何らの入出力要求も処理できないことに注意してください。言い換えれば,ファイル操作に関し,ユーザ独自のファイル入出力ルーチンとDEC XTPU の用意しているルーチンとを組み合わせることはできません。

説明

戻される条件値はユーザによって決められ,操作の正常終了あるいは失敗を指示します。



ユーザ作成ルーチン HANDLER は,条件処理を実行します。

形式

HANDLER signal_vector, mechanism_vector


戻り値



OpenVMS 用法 条件値
データ型 符号なしロングワード
アクセス 書き込みのみ
受け渡し方 値による


ロングワードの条件値です。


引数



signal_vector

OpenVMS 用法 引数リスト
データ型 符号なしロングワード
アクセス 変更
受け渡し方 参照による


シグナル・ベクタです。条件ハンドラに渡されるシグナル・ベクタについての説明は,『OpenVMS System Services Reference Manual』を参照してください。

mechanism_vector

OpenVMS 用法 引数リスト
データ型 符号なしロングワード
アクセス 読み取りのみ
受け渡し方 参照による


メカニズム・ベクタです。条件ハンドラに渡されるメカニズム・ベクタについての説明は,『OpenVMS System Services Reference Manual』を参照してください。


説明

条件ハンドラの作成方法と,OpenVMS 条件処理標準についての詳しい説明が必要な場合には,『OpenVMS Programming Interfaces: Calling a System Routine』または『OpenVMS Calling Standard』を参照してください。

ユーザが独自に条件ハンドラを作成する代わりに,省略時の条件ハンドラである XTPU$HANDLER を利用することができます。条件ハンドラを独自に作成する場合には,DEC XTPU の内部シグナルを操作するため,そのルーチンは受け取ったのと同じパラメータで XTPU$HANDLER を呼び出さなければなりません。




初期化コールバック・ルーチン INITIALIZE は,XTPU$INITIALIZE にバウンド・プロシージャ値として渡され,DEC XTPU の初期化に必要な情報を得るために呼び出されるユーザ作成ルーチンです。

形式

INITIALIZE [user_arg]


戻り値



OpenVMS 用法 アイテム・リスト
データ型 符号なしロングワード
アクセス 書き込みのみ
受け渡し方 参照による


このルーチンは,アイテム・リストのアドレスを返します。


引数



user_arg

OpenVMS 用法 ユーザ引数
データ型 符号なしロングワード
アクセス 読み取りのみ
受け渡し方 値による



説明

初期化コールバック・ルーチン INITIALIZE は,XTPU$INITIALIZE にバウンド・プロシージャ値として渡され,DEC XTPU の初期化に必要な情報を得るために呼び出されるユーザ作成ルーチンです。

XTPU$INITIALIZE で user_arg パラメータが指定された時には,初期化コールバック・ルーチンは,そのパラメータだけを使って呼ばれます。 XTPU$INITIALIZE で user_arg パラメータが指定されなかった時には,初期化コールバック・ルーチンはパラメータなしで呼ばれます。

パラメータ user_arg によって,アプリケーションは XTPU$INITIALIZE を通してユーザによって書かれた初期化ルーチンに情報を渡すことができます。 DEC XTPU はこのデータを解釈しません。

この初期化コールバック・ルーチンは,初期化パラメータのアイテム・リストのアドレスを返すものと期待されています。そのアイテム・リストはこの初期化コールバック・ルーチンのスコープの外で用いられるため,静的メモリ内に割り当てられる必要があります。

このアイテム・リスト・エントリは XTPU$INITIALIZE のセクションに記述されています。ほとんどの初期化パラメータには省略値があります。省略時の文字列はヌル文字列です。省略時のフラグは FALSE です。唯一必要な初期化パラメータはファイル入出力のためのルーチンのアドレスです。ファイル入出力ルーチンのアドレスがアイテム・リストにないと,XTPU$INITIALIZE はエラー・ステータスを返します。


目次 索引

© 2012 Hewlett-Packard Development Company, L.P.