?? test.c
字號(hào):
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "cmppif.h"
#include "kevopsall.ext"
#define INSTALL_DIR "/home/ke"
#define LOCK_FILE "./caserver.lck"
int main (int argc, char ** argv)
{
CMPPHandle hcmpp = NULL;
int i;
int ch;
int lock_fd = -1;
int runasdaemon = 0;
char * plockfile = NULL,
* pinstalldir = NULL;
initConfTable("cmpp.conf");
runasdaemon = getConfBool("CmppSystem", "RunAsDaemon");
if (runasdaemon) {
plockfile = getConfString("CmppSystem", "LockFile");
pinstalldir = getConfString("CmppSystem", "InstallDir");
if (!plockfile || strlen(plockfile) < 1)
plockfile = LOCK_FILE;
if (!pinstalldir || strlen(pinstalldir) < 1)
pinstalldir = INSTALL_DIR;
lock_fd = daemonize (plockfile, pinstalldir);
}
printf("CMPPInit begin.\n");
hcmpp = CMPPInit(getConfString("ISMG", "host"),
(unsigned int)getConfInt("ISMG", "port"),
getConfString("General", "SP_Id"),
getConfString("General", "SharedSecret"),
getConfInt("CMPP Connection", "MTConnection Num"),
getConfInt("CMPP Connection", "MOConnection Num"),
(unsigned char)getConfInt("General", "MTMajor_Version"),
(unsigned char)getConfInt("General", "MTMinor_Version"),
(unsigned char)getConfInt("General", "MOMajor_Version"),
(unsigned char)getConfInt("General", "MOMinor_Version"),
getConfInt("Flow Control", "Sliding Window"),
1
);
printf("CMPPInit end.\n");
while ((ch = getchar()) != 'q') {
if (ch == 's') {
CMPPSubmit( hcmpp,
CMPPGetSeqID(),
9,
"0000000000",
"",
"",
"01",
"000000",
0,
"",
"686802",
1,
"13601322347",
15,
70,
"你好,這是北京掌上網(wǎng)最新短信平臺(tái)測(cè)試消息!掌上網(wǎng)祝愿您周末快樂(lè)。柯恒忠",
0);
} else if (ch == 'f') {
FILE * fp = NULL;
char mpno[128], buf[1024];
fp = fopen("test.txt", "r+");
if (!fp) continue;
while(!feof(fp)) {
memset(mpno, 0, sizeof(mpno));
memset(buf, 0, sizeof(buf));
fgets(mpno, sizeof(mpno)-1, fp);
if (strlen(mpno) == 0) break;
if (!isdigit((int)mpno[0])) {
continue;
}
for(i=strlen(mpno)-1; i>=0; i--) {
if (mpno[i] == '\n' || mpno[i]==' ' || mpno[i]=='\t')
mpno[i] = '\0';
else
break;
}
fgets(buf, sizeof(buf)-1, fp);
for(i=strlen(buf)-1; i>=0; i--) {
if (buf[i] == '\n' || buf[i]==' ' || buf[i]=='\t')
buf[i] = '\0';
else
break;
}
CMPPSubmit( hcmpp,
CMPPGetSeqID(),
9,
"0000000000",
"",
"",
"01",
"000000",
0,
"",
"6868",
1,
mpno,
15,
strlen(buf),
buf,
0);
}
fclose(fp);
}
}
printf("CMPPClose begin.\n");
CMPPCleanup(hcmpp);
printf("CMPPClose end.\n");
if(lock_fd >= 0) close(lock_fd);
destructConfTable();
CMPPSysCleanup ();
return 0;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -