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

📄 empp.h

📁 [解决方法] 对上述程序改动如下: 发送端: MMM SendBag ZeroMemory(&SendBag,sizeof(SendBag)) .............
💻 H
字号:
#ifndef EMPP_INCLUDED
#define EMPP_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#ifndef TRUE
  #define TRUE 1
#endif
#ifndef FALSE
  #define FALSE 0
#endif

#ifdef WIN32
  #ifndef _WINDOWS_
  typedef int                  BOOL;
  #endif
#endif

#ifdef OS2DEF_INCLUDED
  #define BYTE_DECLARED
#endif

#ifdef _WINDEF_
  #define  WORD_DECLARED
  #define DWORD_DECLARED
  #define  BYTE_DECLARED
#endif

/* --------------- OS/2 IBM 32-bit COMPILERS ---------------------------- */

#if (defined (__IBMC__) || defined (__IBMCPP__)) && defined(__32BIT__)
                                               /* IBM C/C++ 32-bits */

  #define    IBMC                    1
  #define    OS2                     1
  #define    EMPPAPI            _System
  #define    EMPPSTDCALL        _System
  #define    EMPPSTDCALLPTR   * _System

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

/*-------------- BORLAND C/C++ OS/2 32-bit COMPILER ----------------------- */

#elif defined (__BORLANDC__)  && !defined(__WIN32__)

  #define    OS2                     1
  #define    EMPPAPI           _syscall
  #define    EMPPSTDCALL       _syscall
  #define    EMPPSTDCALLPTR    _syscall *

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

/* --------------- MICROSOFT COMPILERS ----------------------------------- */

#elif defined (_MSC_VER)

  #if (_MSC_VER == 600)

/* --------------- Microsoft C 6.0A for OS/2, 16-bits -------------------- */
  #define    MSC6   1

  #define    OS2                     1
  #define    EMPPAPI                     /*xx- _pascal-xx*/
  #define    EMPPSTDCALL     far _cdecl
  #define    EMPPSTDCALLPTR  far _cdecl *

  #ifndef     INT16_DECLARED
    typedef  int                 INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  long                INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

  #elif (_MSC_VER >= 900)

/* ---------------  Microsoft VISUAL C++ ---------------------------------- */
  #define    MSVCPP2                  1

  #ifndef    WIN32
    #define  WIN32
  #endif

  #define    EMPPAPI          __stdcall
  #define    EMPPSTDCALL      __stdcall
  #define    EMPPSTDCALLPTR   __stdcall *

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

  #else
    #error Unknown Microsoft compiler type
  #endif

/* --------------- SCO 32-bit UNIX COMPILERS ----------------------------- */

#elif defined (SCO)                  /* Might need to add compiler version */

  #ifndef UNIX
     #define    UNIX                    1
  #endif
  #define    EMPPAPI
  #define    EMPPSTDCALL
  #define    EMPPSTDCALLPTR            *

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

/* --------------- UNIXWARE UNIX COMPILERS ------------------------------- */

#elif defined (UNIX_SVR4) || defined (UNIXWARE) || defined (SOLARIS)
                                                  /* UNIX_SVR4 preferred */

  #define    UNIX_SVR4               1            /* if UNIXWARE def'd   */
  #ifndef UNIX
     #define    UNIX                    1
  #endif
  /* #define    UNIX                    1*/
  #define    EMPPAPI
  #define    EMPPSTDCALL
  #define    EMPPSTDCALLPTR             *

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

  /* 020199 BC Added support for BOOL */
  #ifndef BOOL_DECLARED
    typedef int                  BOOL;
    #define BOOL_DECLARED
  #endif

/* --------------- HIGH C COMPILERS ------------------------------- */

#elif defined (__HIGHC__)

  #define    EMPPAPI
  #define    EMPPSTDCALL
  #define    EMPPSTDCALLPTR             *

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

/* --------------- NETWARE           ------------------------------- */

#elif defined (__NETWARE_386__)

  #define    EMPPAPI
  #define    EMPPSTDCALL
  #define    EMPPSTDCALLPTR             *

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

/*-------------- Borland C++ 32 bit compiler for Windows ------------------ */

/* __BORLANDC__ and __WIN32__ are produced by compiler */

#elif defined (__BORLANDC__) && defined (__WIN32__)

  #define    EMPPAPI         PASCAL _export
  #define    EMPPSTDCALL     PASCAL _export
  #define    EMPPSTDCALLPTR   PASCAL _export*

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif

  #include <windows.h>

/* --------------- QNX ----------------------------------------------------- */
#elif defined (__QNX__)

  #define    EMPPAPI
  /*
  ** This is normally defined in /usr/include/sys/types.h
  ** however QNX does not do it. therefore define it here.
  */

  typedef    unsigned short     ushort;
  typedef    unsigned char      unchar;
  typedef    unsigned long      ulong;

  #define    EMPPSTDCALL
  #define    EMPPSTDCALLPTR             *

  #ifndef     INT16_DECLARED
    typedef  short int           INT16;
  #endif
  #ifndef     INT32_DECLARED
    typedef  int                 INT32;
  #endif
  #ifndef     WORD_DECLARED
    typedef  unsigned short       WORD;
  #endif
  #ifndef     DWORD_DECLARED
    typedef  unsigned long       DWORD;
  #endif
  #ifndef     BYTE_DECLARED
    typedef  unsigned char        BYTE;
  #endif
  #ifndef BOOL_DECLARED
    typedef unsigned short  BOOL ;
    #define BOOL_DECLARED
  #endif

#else
  #error Unknown Compiler Type
#endif

/* !多线程程序注意!
此api只保证在主线程里调用才是安全的,其他线程不要直接调用!如果需要调用请先交给主线程
,由主程序提交消息.
api提交接收消息速度很快,不必担心性能问题.
*/

typedef void (EMPPSTDCALLPTR TRACE_PROC)  /* 跟踪回调涵数,用于api输出信息,此涵数线程是主线程 */
    (
    char           *msg      /* 需要跟踪的消息内容           */
    );

/*当api接收到一条短信(以下简称mo)时的回调涵数,此涵数执行时将阻塞api的消息处理,
   因此需要保证此涵数尽快完成操作,否则影响api的收发流程.此涵数线程是主线程
*/
typedef void (EMPPSTDCALLPTR MO_PROC) 
    (
    char           *srcAddr,      /*源手机号码           */
    char           *msg           /*消息内容             */
    );

/* 初试化api,传入短信服务器的ip,port,用户名,密码,持久性海量存储使用的队列文件名,
队列最大容量,api跟踪回调涵数,mo回调涵数
api提供由文件实现的海量队列,队列大小由调用者配置,如果程序退出时还有短信未发送完毕,
则下次启动时将继续自动提交;如果队列大小跟上次设置的不同,队列将被清空,未发送短信将丢失,
队列大小与发送效率几乎无关,只是占用硬盘空间,因此可以将队列设置为可能提交的最大值,
如50000.队列文件如果不存在会自动生成,如果存在则重细腻打开.

此涵数在进程生命期只需要调用一次.
返回:0成功,其他失败.
*/

INT32 EMPPAPI init(
    char     *ip,        /* 服务器ip地址, */
	WORD     port,       /* 服务器端口    */
	char     *user,      /* 登陆用户名    */
	char     *pswd,      /* 密码         */
	char     *queue,     /* 队列文件名,api用于缓存,可以带全路径 */
	INT32    queueSize,  /* 队列大小,可以尽量设置大点,大于最大一次发送量,如5万,10万都可以 */
	TRACE_PROC  trace,   /* api显示输出  */
	MO_PROC  mo);        /* api收到短信时的回调涵数 */

/*提交短信到api对列,api将自动后台处理.
输入:
DestAddr:目的号码,手机不加0,如13812345678,小灵通或固话加区号,如07178765432
Msg:短信内容,不超过70字符,数字字母汉字都算一个.如果超长调用者需要分割后再发送.api不分割.
返回:
0:成功提交.
其他:失败.
*/
INT32 EMPPAPI sendSMS(
	char     *destAddr,
    char     *msg);

/*
查询余额
返回:
如果未登录状态,返回0
*/
INT32 EMPPAPI getBalance();

/*
设置api是否调试状态,调试状态下输出更多协议信息
输入:
0:不调试.
其他:调试状态
*/
void EMPPAPI setDebug(INT32 value);

/*
查询api队列待发短信数量
*/
DWORD EMPPAPI getUnSend();

/*
查询api状态
返回:
0:未正确初试化.
1:'连接断开'
2:'连接已建立'
3:'正在登录'
4:'已登录'
5:'已退出登录'
*/
INT32 EMPPAPI getState();

/*
释放api资源.
*/
void EMPPAPI uninit();


#ifdef __cplusplus
}
#endif

#endif          /* EMPPTYPES_INCLUDED */

⌨️ 快捷键说明

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