Linkexpress 利用者プログラム開発ガイド
目次 索引 前ページ次ページ

付録A サンプル> A.1 転送APIのサンプル

A.1.2 起動側連続ファイル送信(完了復帰型)の例

このサンプルプログラムは、以下のファイルに格納されています。

PCサーバ : インストールディレクトリ\sample\api\sndfile2.c

UNIXサーバ : インストールディレクトリ/SAMPLE/api/sndfile2.c

機能

このサンプルプログラムは、完了復帰型のSNDFILEを使用してファイル転送を連続して行うものです。プログラムの説明を以下に示します。

Linkexpressに対してSNDFILEの要求を連続して行います。完了復帰型で要求しているため、続けてSNDFILEを要求しています。

SNDFILEで完了通知を受け取るため、GETINFで完了通知を受け取る必要はありません。

ソースコード

sndfile2.cの内容を以下に示します。

/*
 *
 * All Rights Reserved Copyright (c) FUJITSU LIMITED 1997-2005
 *
 */

/*
 *      API sample program  (init No.2) 
 */

/*
 *      include file
 */
#include        <sys/types.h>
#include        <string.h>
#include        <stdio.h>
#include        <lxapi.h>

int
main()
{
dts_sndfile_dcb_t        input_dcb;
dts_inf_transfer_comp_t  output_dcb;
password_t  password;
int         ret = 0;


        /*
         *    clear parameters
         */
        memset( &input_dcb, 0, sizeof(dts_sndfile_dcb_t) );
        memset( &output_dcb, 0, sizeof(dts_inf_transfer_comp_t) );
        memset( &password, 0, sizeof(password_t) );

        /*
         *    set parameters
         */
        input_dcb.req_ident = 0;
        input_dcb.req_type = DTS_API_COMP;
        input_dcb.appl_name = "@_USRAPL";
        input_dcb.system_name = "dest_system";
        input_dcb.assoc_cont = DTS_API_CONT;
        input_dcb.local_filename = "C:\\test\\api\\a";
        input_dcb.local_user = 0;
        input_dcb.remote_filename = "C:\\test\\api\\b";
        input_dcb.storage_form = DTS_API_REP;
        input_dcb.access_password = 0;
        input_dcb.data_type = DTS_API_BINARY;
        input_dcb.file_attr = 0;
        input_dcb.speed = 0;
        input_dcb.ret_tid = 0;
        input_dcb.protocol_option = 0;
        input_dcb.user_id = "linkexp";
        input_dcb.password = &password;
        password.password_len = 7;
        strcpy( password.password, "linkexp" );
        input_dcb.group = 0;

        /*
         *    sndfile
         */
        ret = sndfile( &input_dcb, &output_dcb );
        printf("ret =%d, diag %d,%d,%d\n", ret, 
                output_dcb.diagnostic.category_code, 
                output_dcb.diagnostic.error_code, 
                output_dcb.diagnostic.detail_code );
        printf("req_ident =%d\n", output_dcb.req_ident );
        printf("system_name =%s\n", output_dcb.system_name );
        printf("flow_kind =%d\n", output_dcb.flow_kind );
        printf("start_time =%s", ctime( (time_t *)&output_dcb.start_time ) );
        printf("comp_time =%s", ctime( (time_t *)&output_dcb.comp_time ) );
        printf("trn_comptype =%d\n", output_dcb.trn_comptype );
        printf("data_size =%d\n", output_dcb.data_size );


        /*
         *    set parameters
         */
        input_dcb.req_ident = 0;
        input_dcb.req_type = DTS_API_COMP;
        input_dcb.appl_name = "@_USRAPL";
        input_dcb.system_name = "dest_system";
        input_dcb.assoc_cont = DTS_API_CUT;
        input_dcb.local_filename = "C:\\test\\api\\a";
        input_dcb.local_user = 0;
        input_dcb.remote_filename = "C:\\test\\api\\b";
        input_dcb.storage_form = DTS_API_REP;
        input_dcb.access_password = 0;
        input_dcb.data_type = DTS_API_BINARY;
        input_dcb.file_attr = 0;
        input_dcb.speed = 0;
        input_dcb.ret_tid = 0;
        input_dcb.protocol_option = 0;
        input_dcb.user_id = "linkexp";
        input_dcb.password = &password;
        password.password_len = 7;
        strcpy( password.password, "linkexp" );
        input_dcb.group = 0;

        /*
         *    sndfile
         */
        ret = sndfile( &input_dcb, &output_dcb );
        printf("ret =%d, diag %d,%d,%d\n", ret, 
                output_dcb.diagnostic.category_code, 
                output_dcb.diagnostic.error_code, 
                output_dcb.diagnostic.detail_code );
        printf("req_ident =%d\n", output_dcb.req_ident );
        printf("system_name =%s\n", output_dcb.system_name );
        printf("flow_kind =%d\n", output_dcb.flow_kind );
        printf("start_time =%s", ctime( (time_t *)&output_dcb.start_time ) );
        printf("comp_time =%s", ctime( (time_t *)&output_dcb.comp_time ) );
        printf("trn_comptype =%d\n", output_dcb.trn_comptype );
        printf("data_size =%d\n", output_dcb.data_size );

        return( 0 );

}

参照

lxapi.h

用語解説

DTS_API_COMP
完了復帰型で要求するため、DTS_API_COMP(完了復帰型)を指定します。
DTS_API_CONT
コネクションを継続するため、DTS_API_CONT(継続)を指定します。
DTS_API_CUT
コネクションを切断するため、DTS_API_CUT(切断)を指定します。
DTS_API_REP
仮想ファイルの先頭から格納するため、DTS_API_REP(ファイル置換え)を指定します。
DTS_API_BINARY
バイナリデータを転送するため、DTS_API_BINARY(バイナリ)を指定します。

 


目次 索引 前ページ次ページ

All Rights Reserved, Copyright(C) 富士通株式会社 1997-2007