?? sendmsg.c
字號:
/********************************************************************
ModuleName: SMGW Client API Example Program
FileName: Sendmsg.c
DESCRIPTION: Send Single Message Example Program
History:
Date Version Modifier Activies
2002/03/19 1.0 Zhang Jiebin Create
********************************************************************/
/********************************************************************
Include Files
********************************************************************/
#include <stdio.h>
#include "sendmsg.h"
/********************************************************************
Macro Definition
********************************************************************/
#define MSG_DEFAULT_INT 0
#define MSG_DEFAULT_STRING "default"
/********************************************************************
Global Var Definition
********************************************************************/
/* SMGPSendSingle Param */
static SMGP_Submit g_SMGP_Submit;
/* Semd Msg Msg Id */
static char g_sMsgID[10];
/* Send Msg Error Num */
static int g_nErrorCode = 0xff;
/* Send Msg Config File Dir */
static char g_cConfigFileDir[200];
/********************************************************************
Local Function Definition
********************************************************************/
static int ReadSmFile(const char *pSmConfigFile);
/********************************************************************
FunctionName: main
DESCRIPTION: Main Function
Input: None
Output: None
Return: None
********************************************************************/
void main(void)
{
/* Local Vars */
int nRetCode;
/* Call API InitSMGPAPI*/
/* If Your Config File Not In Current Dir Or Config Dir Please */
/* All Dir And File Name */
nRetCode = InitSMGPAPI(NULL);
if(nRetCode)
{
printf("InitSMGPAPI Return Error\n");
}
/* Read Send Msg Param From Config File */
/* Just A Example You Can Get These Params From Other Method */
nRetCode = ReadSmFile((char *)SEMD_MSG_CONFIG_FILE);
if(nRetCode)
{
printf("ReadSmFile Return Error\n");
}
/* Call API Function SMGPSendSingle To Send Msg */
nRetCode = SMGPSendSingle( g_SMGP_Submit.nNeedReport,
g_SMGP_Submit.nPriority,
g_SMGP_Submit.sServerId,
g_SMGP_Submit.nMsgFormat,
g_SMGP_Submit.sFeeType,
g_SMGP_Submit.sFeeCode,
g_SMGP_Submit.sValidTime,
g_SMGP_Submit.sAtTime,
g_SMGP_Submit.sChargeTermId,
g_SMGP_Submit.sDestTermId,
g_SMGP_Submit.sReplyPath,
g_SMGP_Submit.nMsgLength,
g_SMGP_Submit.sMsgContent,
g_sMsgID,
&g_nErrorCode
);
/* If Return Error */
if(nRetCode)
{
printf("SMGPSendSingle Return Error\n");
printf("The Error Code Is %d",&g_nErrorCode);
}
/* Else Return Success */
else
{
printf("SMGPSendSingle Return Success\n");
printf("You have sent a short message to SMGW\n");
}
return;
}
/********************************************************************
FunctionName: ReadSmFile
DESCRIPTION: Read Send Msg Param From Config File
Input: pSmConfigFile, Send Msg Param Config File
Output: None
Return: 0:Sucess;1:Error
********************************************************************/
static int ReadSmFile(const char *pSmConfigFile)
{
/* Get Current Dir */
GetCurrentDirectory(200,g_cConfigFileDir);
#ifdef _WIN32
strcat(g_cConfigFileDir,"\\");
#else
strcat(g_cConfigFileDir,"/");
#endif
strcat(g_cConfigFileDir,pSmConfigFile);
/* Get Params*/
g_SMGP_Submit.nNeedReport = GetPrivateProfileInt
("SendSingle",
"nNeedReply",
MSG_DEFAULT_INT,
g_cConfigFileDir
);
g_SMGP_Submit.nPriority = GetPrivateProfileInt
("SendSingle",
"nMsgLevel",
MSG_DEFAULT_INT,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sServiceID",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sServerId,
10,
g_cConfigFileDir
);
g_SMGP_Submit.nMsgFormat = GetPrivateProfileInt
("SendSingle",
"nMsgFormat",
MSG_DEFAULT_INT,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sFeeType",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sFeeType,
2,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sFeeCode",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sFeeCode,
6,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sValidTime",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sValidTime,
17,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sAtTime",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sAtTime,
17,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sChargeTermID",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sChargeTermId,
21,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sDestTermID",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sDestTermId,
21,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sReplyPath",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sReplyPath,
21,
g_cConfigFileDir
);
g_SMGP_Submit.nMsgLength = GetPrivateProfileInt
("SendSingle",
"nMsgLen",
MSG_DEFAULT_INT,
g_cConfigFileDir
);
GetPrivateProfileString ("SendSingle",
"sMsgContent",
MSG_DEFAULT_STRING,
g_SMGP_Submit.sMsgContent,
252,
g_cConfigFileDir
);
return 0;
}
/********************************************************************
End Of File
********************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -