⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmppapi.pas

📁 里面有相应的hpunix(HP-UX hpl1000 B.11.00 U 9000/800 (tb)),linux(Red Hat Linux release 9 Kernel 2.4.20-8),w
💻 PAS
字号:
unit CMPPAPI;

interface
uses
  windows,sysutils;
const

CMPPAPILIB                 = 'api.dll';
//****************************************************************
//                函数返回值定义
//****************************************************************

API_OK                      = 1;       {* 成功 *}
API_NOCELL                  = 0;       {* 没有数据包 *}

API_ERR_INVALID		    = -1;      {* 非法输入参数 *}
API_ERR_NETWORK             = -2;      {* 网络错误 *}
API_ERR_INIFILE             = -3;      {* 配置文件错误 *}
API_ERR_TIMEOUT             = -4;      {* 超时错误 *}
API_ERR_PROTOCOL            = -5;      {* 协议错误 *}
API_ERR_RESP                = -6;      {* 网关返回错误 *}
API_ERR_OTHER               = -7;      {* 其它错误 *}

// 设置时间格式定义
MacRelativeTimeFmt          = 0;
MacAbsoluteTimeFmt          = 1;

MacRegisterDelivery_No      = 0;  //(发送时)不需要状态报告
                                 //(接收时)接收包为普通Deliver
MacRegisterDelivery_Yes     = 1;  //(发送时)需要状态报告
                                 //(接收时)接收包为状态报告(Receipt)
MacFeeUserType_Dest         = 0;  //目的号码计费
MacFeeUserType_Third        = 3;  //指定号码计费(FeeTerminalId为指定号码,如不指定,默认按目的号码计费)

MacFeeType_Free             = '01'; //免费
MacFeeType_Piece            = '02';  //按次计费
MacFeeType_Month            = '03';  //包月计费
MacFeeType_Subsribe         = '08';  //订购业务
MacFeeType_Cancel           = '09'; //取消业务

MSG_FORMAT_ASCII            = 0;   {* ASCII串 *}
MSG_FORMAT_WRITE_CARD       = 3;   {* 短信写卡操作 *}
MSG_FORMAT_BINARY           = 4;   {* 二进制信息 *}
MSG_FORMAT_UCS2             = 8;   {* UCS2信息 *}
MSG_FORMAT_GB               = 15;  {* 含GB汉字 *}

MacReceiptStatus_DELIVERED  = 'DELIVRD';
MacReceiptStatus_EXPIRED    = 'EXPIRED';
MacReceiptStatus_DELETED    = 'DELETED';
MacReceiptStatus_UNDELIVERABLE = 'UNDELIV';
MacReceiptStatus_ACCEPTED      = 'ACCEPTD';
MacReceiptStatus_UNKNOWN       = 'UNKNOWN';
MacReceiptStatus_REJECTED      = 'REJECTD';

MacMsgId           = 8;
MacServiceId       = 10;
MacFeeTermId       = 21;
MacMsgSrc          = 6;
MacFeeType         = 2;
MacFeeCode         = 6;
MacValidTime       = 17;
MacAtTime          = 17;
MacSrcId           = 21;
MacUserNum         = 99;
MacDstId           = 21;
MacMsgLen          = 160;
MacReserve         = 8;

// CMPP Receipt Body definition
MacRecStat         = 7;
MacSubmitTime      = 10;
MacDoneTime        = 10;

//***************************************************************
//                    数据类型和长度定义
//***************************************************************
type
  CONNFD = integer;           {*连接句柄*}
  TMsgId = Array [1..8] of Byte;

  recSubmit = Record
    sInMsgId : Array [1..MacMsgId + 1] of Byte;
    ucPkTotal: Byte;
    ucPkNumber : Byte;
    sFeeTerminalId : Array [1..MacFeeTermId+1] of char;
    sFeeType : Array [1..MacFeeType+1] of char;
    nFeeCode : integer;
    sServiceId: Array [1..MacServiceId+1] of char;
    ucTpPid : Byte;
    ucTpUdhi : Byte;
    sSrcId: Array [1..MacSrcId+1] of char;
  end;
  PrecSubmit = ^recSubmit;

  TRecSubmit = Record
    InMsgId : TMsgId;
    PkTotal: Byte;
    PkNumber : Byte;
    FeeTerminalId : string;
    FeeType : string;
    FeeCode : integer;
    ServiceId: string;
    TpPid : Byte;
    TpUdhi : Byte;
    SrcId: string;
  end;
  PTRecSubmit = ^TRecSubmit;

// CMPP Deliver pack definition
  recCmppDeliver = record
        uchMsgId : Array [1..MacMsgId+1] of Byte;
        chDestId : Array [1..MacDstId+1] of char;
        chServiceId : Array [1..MacServiceId+1] of char;
        ucTpPid : Byte;
        ucTpUdhi : Byte;
        ucMsgFmt : Byte;
        chSrcTerminalId : Array [1..MacSrcId+1] of char;
        ucRegisterDelivery : Byte;
        ucMsgLength : Byte;
        chMsgContent : Array [1..MacMsgLen+1] of char;
        chReserve : Array [1..MacReserve+1] of char;
  end;
  PrecCmppDeliver = ^recCmppDeliver;

  TMsgContent = Array [1..MacMsgLen] of Byte;
  TReserved = Array [1..MacReserve] of Byte;
  TRecCmppDeliver = record
        MsgId : TMsgId;
        DestId : string;
        ServiceId : string;
        TpPid : Byte;
        TpUdhi : Byte;
        MsgFmt : Byte;
        SrcTerminalId : string;
        RegisterDelivery : Byte;
        MsgLength : Byte;
        MsgContent : TMsgContent;
        Reserve : TReserved;
  end;
  PTRecCmppDeliver = ^TRecCmppDeliver;

  recCmppReceiptBody = record
        uchMsgId: Array [1..MacMsgId+1] of Byte;
        chStat : Array [1..MacRecStat+1] of char;
        chSubmitTime : Array [1..MacSubmitTime+1] of char;
        chDoneTime : Array [1..MacDoneTime+1] of char;
        chDestTerminalId : Array [1..MacDstId+1] of char;
        unSmscSequence : Longword;
  end;
  PrecCmppReceiptBody = ^recCmppReceiptBody;

  TRecCmppReceiptBody = record
        MsgId: TMsgId;
        Stat : string;
        SubmitTime : string;
        DoneTime : string;
        DestTerminalId : string;
        SmscSequence : Longword;
  end;
  PTRecCmppReceiptBody = ^TRecCmppReceiptBody;

  function sGetErrorReason(nErrReturn : integer) : pchar; stdcall;
  function sGetErrorDetail : pchar; stdcall;
  function nHInitInterface(sIniFile : pchar) : integer; stdcall;
  function nHExitInterface : integer; stdcall;
  function nHSubmit(var rSubmit : recSubmit;
                    sDstTerminateId : pchar;
                    ucMsgFmt : Byte;
                    unMsgLength : Longword;
                    sMsgContent : pchar;
                    sOutMsgId : PByte;
                    var chResult : Byte;
                    sLastTerminateId : pchar
                   ) : integer; stdcall;
  function nHGetDeliver(var nReceiptOrNot : Integer;
                        var unSequenceId : Longword;
                        var rCmppDeliver : recCmppDeliver;
                        var rReceiptBody : recCmppReceiptBody;
                        nTimeOut : Integer
                   ) : Integer; stdcall;

implementation

function sGetErrorReason; external CMPPAPILIB name 'sGetErrorReason';
function sGetErrorDetail; external CMPPAPILIB name 'sGetErrorDetail';
function nHInitInterface; external CMPPAPILIB name 'nHInitInterface';
function nHExitInterface; external CMPPAPILIB name 'nHExitInterface';
function nHSubmit; external CMPPAPILIB name 'nHSubmit';
function nHGetDeliver; external CMPPAPILIB name 'nHGetDeliver';

procedure SetupWinsock;
var
     wVersionRequested : WORD;
     wsaData : TWSADATA;
begin
    wVersionRequested := $0202;
    WSAStartup( wVersionRequested, wsaData );
end;
procedure CleanWinsock;
begin
  WSACleanup;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -