📄 queryismg.cpp
字号:
/* -------------------------------------------------------------------------- Name: QueryISMG.cpp Title: CMPP API of ISMG for CMPP 1.1 Package: Send query request to ISMG sample code for Asiainfo CMPP 1.1 API Written: 2000/12/20 Asiainfo Revised: Synopsis: Editor: TAB=4 -----------------------------------------------------------------------------*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include "CMPPAPI.hpp"void Usage(char *sProgram);int main(int argc, char ** argv){ int nOutput = 1; char sResultFile[100] = "", sServiceID[10+1] = "", sDate[20] = ""; FILE *pFile; int nType = 0, n; QueryResp theQueryResp; // get argument for(n=1; n<argc; ++n) { if(strcmp(argv[n], "-n") == 0) { nOutput = 0; } else if(strcmp(argv[n], "-d") == 0) { n++; strcpy(sDate, argv[n]); } else if(strcmp(argv[n], "-t") == 0) { n++; nType = atoi(argv[n]); } else if(strcmp(argv[n], "-s") == 0) { n++; strcpy(sServiceID, argv[n]); } else if(strcmp(argv[n], "-f") == 0) { n++; strcpy(sResultFile, argv[n]); } else { if(nOutput == 1) { Usage(argv[0]); } exit(1); } } if(strlen(sResultFile) == 0) { if(nOutput == 1) { printf("No result file!\n"); } exit(1); } if(strlen(sDate) == 0) { if(nOutput == 1) { printf("No query date!\n"); } exit(1); } if(nType == 1 && strlen(sServiceID) == 0) { if(nOutput == 1) { printf("No serviceid!\n"); } exit(1); } // initiate API if(InitCMPPAPI() != 0) { if(nOutput == 1) { printf("Fail to call InitCMPPAPI!\n"); } exit(1); } if(CMPPQuery(sDate, nType, sServiceID, &theQueryResp) != 0) { if(nOutput == 1) { printf("Fail to call CMPPQuery!\n"); } exit(1); } // write query result into file pFile = fopen(sResultFile, "w"); if(pFile == NULL) { if(nOutput == 1) { printf("Fail to open file %s!\n", sResultFile); } exit(1); } fprintf(pFile, "%d\n", theQueryResp.nMT_TLMsg); fprintf(pFile, "%d\n", theQueryResp.nMT_TLusr); fprintf(pFile, "%d\n", theQueryResp.nMT_Scs); fprintf(pFile, "%d\n", theQueryResp.nMT_WT); fprintf(pFile, "%d\n", theQueryResp.nMT_FL); fprintf(pFile, "%d\n", theQueryResp.nMO_Scs); fprintf(pFile, "%d\n", theQueryResp.nMO_WT); fprintf(pFile, "%d\n", theQueryResp.nMO_FL); fclose(pFile); exit(0); return(0);}void Usage(char *sProgram){ printf("Usage: %s [-n] <-d date> <-t type> <-s serviceid> <-f result_file>\n", sProgram); printf(" -n: no message output\n"); printf(" -d: qeury date, format=yyyymmdd.\n"); printf(" -t: qeury type, 0=total, 1=serviceid.\n"); printf(" -s: serviceid.\n"); printf(" -f: result file name.\n"); printf("e.g.: %s -d 20001220 -t 1 -s 00001 -f query.txt\n", sProgram);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -