文字列データを使用する際、ワイド文字としてデータを扱う場合には、必ず「unsigned short*」型で宣言してください。それ以外の場合には、「char*」型で宣言してください。
■char*型
文字列データを扱う場合のサーバアプリケーションについて以下に示します。文字列データの終端には、必ずNULL文字(0x00)を設定してください。
module apfwmod { interface apfwinf { string server_apl( in string param_in, /* INパラメタ */ out string param_out, /* OUTパラメタ */ inout string param_inout /* INOUTパラメタ */ ); }; }; |
char* server_apl( char *param_in, /* INパラメタ */ char **param_out, /* OUTパラメタ */ char **param_inout, /* INOUTパラメタ */ int *rtn, /* 処理結果情報 */ apfwExcept *apfw_env ); /* 例外情報 */ |
パラメタ | アプリケーション連携実行基盤から | アプリケーション連携実行基盤へ |
---|---|---|
IN |
| - |
| ||
OUT | NULLポインタを値として持つ変数のアドレスが渡されます。 |
|
| ||
INOUT |
|
|
|
| |
復帰 | - |
|
|
#include "apfwcom.h" #include "apfw_cdr_lib.h" #include "XXXXXX.h" /* 実行基盤インタフェース生成ツールより生成されるヘッダファイル */ char* server_apl( char *param_in, /* INパラメタ */ char **param_out, /* OUTパラメタ */ char **param_inout, /* INOUTパラメタ */ int *rtn, /* 処理結果情報 */ apfwExcept *apfw_env ) /* 例外情報 */ { char *apfw_result = NULL; /* アプリケーションの復帰値 */ /* OUTパラメタ */ *param_out = apfw_c_alloc(10); if( *param_out == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset( *param_out, 0x00, 10 ); strcpy( *param_out, "PARAM OUT" ); /* INOUTパラメタ */ if( *param_inout != NULL ){ if( strlen(*param_inout)+1 <= 10 ){ apfw_c_free(*param_inout); *param_inout = apfw_c_alloc(10); } } else{ *param_inout = apfw_c_alloc(10); } if( *param_inout == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return(NULL); } memset( *param_inout, 0x00, 10 ); strcpy( *param_inout, "PARAM IO" ); /* 復帰情報 */ apfw_result = apfw_c_alloc(10); if( apfw_result == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset( apfw_result, 0x00, 10 ); strcpy( apfw_result, "PROC END" ); *rtn = APFW_RTN_COMMIT; /* 処理結果情報に正常(APFW_RTN_COMMIT)を設定 */ return( apfw_result ); } |
■unsigned short*型
ワイド文字として文字列型を扱う場合のサーバアプリケーション例を以下に示します。文字列データの終端には必ずNULL文字(0x0000)を設定してください。なお、日本語コードを設定する場合には以下の点に注意してください。
コード系がSJIS/EUCの場合、システムのエンディアンに依存せずに設定をおこなってください。
コード系がUCS2の場合、システムのエンディアンに合わせて設定を行ってください。
module apfwmod { interface apfwinf { wstring server_apl( in wstring param_in, /* INパラメタ */ out wstring param_out, /* OUTパラメタ */ inout wstring param_inout /* INOUTパラメタ */ ); }; }; |
unsigned short* server_apl( unsigned short *param_in, /* INパラメタ */ unsigned short **param_out, /* OUTパラメタ */ unsigned short **param_inout, /* INOUTパラメタ */ int *rtn, /* 処理結果情報 */ apfwExcept *apfw_env ); /* 例外情報 */ |
パラメタ | アプリケーション連携実行基盤から | アプリケーション連携実行基盤へ |
---|---|---|
IN |
| - |
| ||
OUT | NULLポインタを値として持つ変数のアドレスが渡されます。 |
|
| ||
INOUT |
|
|
|
| |
復帰 | - |
|
|
#include "apfwcom.h" #include "apfw_cdr_lib.h" #include "XXXXXX.h" /* 実行基盤インタフェース生成ツールより生成されるヘッダファイル */ unsigned short* server_apl( unsigned short *param_in, /* INパラメタ */ unsigned short **param_out, /* OUTパラメタ */ unsigned short **param_inout, /* INOUTパラメタ */ int *rtn, /* 処理結果情報 */ apfwExcept *apfw_env ) /* 例外情報 */ { unsigned short *apfw_result = NULL; /* アプリケーションの復帰値 */ /* OUTパラメタ */ /* 3文字+終端文字分領域を獲得 */ *param_out = apfw_c_alloc(sizeof(unsigned short) * 4); if( *param_out == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset( *param_out, 0x00, sizeof(unsigned short)*4 ); /* char*にキャストして日本語を設定する */ strcpy((char*)*param_out, "日本語"); /* INOUTパラメタ */ if( *param_inout != 0x0000 ){ apfw_c_free(*param_inout); } /* 3文字+終端文字分領域を獲得 */ *param_inout = apfw_c_alloc(sizeof(unsigned short) * 4 ); if( *param_inout == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset( *param_inout, 0x00, sizeof(unsigned short) * 4 ); /* char*にキャストして日本語を設定する */ strcpy((char*)*param_inout, "日本語"); /* 復帰情報 */ /* 3文字+終端文字分領域を獲得 */ apfw_result = apfw_c_alloc( sizeof(unsigned short) * 4 ); if( apfw_result == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset(apfw_result, 0x00, sizeof(unsigned short) * 4 ); /* char*にキャストして日本語を設定する */ strcpy((char*)apfw_result, "日本語"); *rtn = APFW_RTN_COMMIT; /* 処理結果情報に正常(APFW_RTN_COMMIT)を設定 */ return( apfw_result ); } |
#include "apfwcom.h" #include "apfw_cdr_lib.h" #include "XXXXXX.h" /* 実行基盤インタフェース生成ツールより生成されるヘッダファイル */ unsigned short* server_apl( unsigned short *param_in, /* INパラメタ */ unsigned short **param_out, /* OUTパラメタ */ unsigned short **param_inout, /* INOUTパラメタ */ int *rtn, /* 処理結果情報 */ apfwExcept *apfw_env ) /* 例外情報 */ { unsigned short *apfw_result = NULL; /* アプリケーションの復帰値 */ /* OUTパラメタ */ /* 3文字+終端文字分領域を獲得 */ *param_out = apfw_c_alloc(sizeof(unsigned short) * 4); if( *param_out == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset( *param_out, 0x00, sizeof(unsigned short)*4 ); /* UNICODEの値を1文字ずつ直接数値で設定します。 */ (*param_out)[0] = 0x65e5; /* "日" */ (*param_out)[1] = 0x672c; /* "本" */ (*param_out)[2] = 0x8a9e; /* "語" */ (*param_out)[3] = 0x0000; /* 終端子 */ /* INOUTパラメタ */ if( *param_inout != 0x0000 ){ apfw_c_free(*param_inout); } /* 3文字+終端文字分領域を獲得 */ *param_inout = apfw_c_alloc(sizeof(unsigned short) * 4 ); if( *param_inout == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset( *param_inout, 0x00, sizeof(unsigned short) * 4 ); /* UNICODEの値を1文字ずつ直接数値で設定します。 */ (*param_inout)[0] = 0x65e5; /* "日" */ (*param_inout)[1] = 0x672c; /* "本" */ (*param_inout)[2] = 0x8a9e; /* "語" */ (*param_inout)[3] = 0x0000; /* 終端子 */ /* 復帰情報 */ /* 3文字+終端文字分領域を獲得 */ apfw_result = apfw_c_alloc( sizeof(unsigned short) * 4 ); if( apfw_result == NULL ){ *rtn = APFW_RTN_ERROR; /* 処理結果情報に異常または例外(APFW_RTN_ERROR)を設定 */ apfw_env->errcode = -1; /* 例外情報のエラーコードに値を設定 */ return( NULL ); } memset(apfw_result, 0x00, sizeof(unsigned short) * 4 ); /* UNICODEの値を1文字ずつ直接数値で設定します。 */ apfw_result[0] = 0x65e5; /* "日" */ apfw_result[1] = 0x672c; /* "本" */ apfw_result[2] = 0x8a9e; /* "語" */ apfw_result[3] = 0x0000; /* 終端子 */ *rtn = APFW_RTN_COMMIT; /* 処理結果情報に正常(APFW_RTN_COMMIT)を設定 */ return( apfw_result ); } |