_Rreadindv() — 送信勧誘された装置からの読み取り

フォーマット

#include <recio.h>

_RIOFB_T *_Rreadindv(_RFILE *fp, void *buf, size_t size, int opts);

言語レベル: ILE C Extension

スレッド・セーフ: いいえ。

説明

_Rreadindv() 関数は、送信勧誘された装置からデータを読み取ります。

以下に、_Rreadindv() 関数の有効なパラメーターを示します。

buf
読み取ったデータを保管するバッファーを指定します。 位置指定モードを使用する場合、このパラメーターは NULL に設定する必要があります。
size
読み取って buf に保管するバイト数を指定します。 位置指定モードを使用する場合、このパラメーターは無視されます。
opts
ファイルの処理オプションを指定します。 指定できる値は、以下のとおりです。
__DFT
ファイルが更新用にオープンしている場合、読み取り中または位置指定中のレコードはロックされます。 そうでない場合、このオプションは無視されます。

_Rreadindv() 関数は、ディスプレイ・ファイルと ICF ファイルの場合に有効です。

戻り値

_Rreadindv() 関数は、fp に関連した _RIOFB_T 構造体を指すポインターを戻します。 _Rreadindv() 操作が正常終了した場合、num_bytes フィールドは、システム・バッファーからユーザーのバッファーに転送されたバイト数 (移動モード)、 またはファイルのレコード長 (位置指定モード) に設定されます。 sysparm および rrn (サブファイルの場合) フィールドも更新されます。 ファイルが空である場合、num_bytes フィールドは EOF に設定されます。 _Rreadindv() 関数が正常終了しなかった場合、num_bytes フィールドは size の値より小さい値に設定され、 errno が変更されます。

errno の値は、次のいずれかに設定されます。

意味
ENOTREAD
ファイルは読み取り操作用にオープンされていません。
ETRUNC
入出力操作で切り捨てが発生しました。
EIOERROR
リカバリー不能な入出力エラーが発生しました。
EIORECERR
リカバリー可能な入出力エラーが発生しました。

errno の設定については、表 12 および 表 14 を参照してください。

_Rreadindv() の使用例

#include <stdio.h>
#include <recio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
    char name[20];
    char address[25];
} format1 ;
typedef struct {
    char name[8];
    char password[10];
} format2 ;
typedef union {
    format1 fmt1;
    format2 fmt2;
} formats ;
int main(void)
{
    _RFILE   *fp;               /* File pointer                          
    */
    _RIOFB_T *rfb;        /* Pointer to the file's feedback structure    
    */
    _XXIOFB_T *iofb;          /* Pointer to the file's feedback area     
    */
    formats  buf, in_buf, out_buf          /* Buffers to hold data       
    */
 /* Open the device file.                                          */
    if (( fp = _Ropen ( "MYLIB/T1677RD2", "ar+" )) == NULL )
    {
        printf ( "Could not open file¥n" );
        exit ( 1 );
    }
   _Racquire ( fp,"DEVICE1" );    /* Acquire another device. Replace */
                                   /* with actual device name.        */
    _Rformat ( fp,"FORMAT1" );     /* Set the record format for the   */
                                   /* display file.                   */
    rfb = _Rwrite ( fp, "", 0 );   /* Set up the display.             */
    _Rpgmdev ( fp,"DEVICE2" );  /* Change the default program device. */
                                /* Replace with actual device name.   */
    _Rformat ( fp,"FORMAT2" );   /* Set the record format for the     */
                                 /* display file.                     */
    rfb = _Rwrite ( fp, "", 0 );   /* Set up the display.             */
    rfb = _Rwriterd ( fp, &buf, sizeof(buf) );
    rfb = _Rwrread ( fp, &in_buf, sizeof(in_buf), &out_buf,
                     sizeof(out_buf ));
    _Rreadindv ( fp, &buf, sizeof(buf), __DFT );
                                  /* Read from the first device that  */
                                  /* enters data - device becomes     */
                                  /* default program device.          */
 /* Determine which terminal responded first.                      */
    iofb = _Riofbk ( fp );
    if ( !strncmp ( "FORMAT1  ", iofb -> rec_format, 10 ))
    {
        _Rrelease ( fp, "DEVICE1" );
    }
    else
    {
        _Rrelease(fp, "DEVICE2" );
    }
 /* Continue processing.                                           */
    printf ( "Data displayed is %45.45s¥n", &buf);
    _Rclose ( fp );
}

関連情報



[ ページのトップ | 前ページ | 次ページ | 目次 | 索引 ]