Hello ,
I used to program in c++ several years before and totally out of touch now. I was trying to compile a small program. Please let me know whether it is meaningful.
This doesn't have a main. So, doesn't compile. If I include a dummy main(){;}, What would happen? Should I call the method void MQENTRY MQMDH001() inside the main? Will it work? Please suggest.
Thanks
I used to program in c++ several years before and totally out of touch now. I was trying to compile a small program. Please let me know whether it is meaningful.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef AIX
#include <langinfo.h>
#endif
#include <sys/types.h>
#include <sys/timeb.h>
#include <time.h>
/* MQSeries headers */
#include <cmqc.h>
#include <cmqxc.h>
/* testing headers */
#include <time.h>
/* dummy function used as entry point to exit, only needed AIX boxes */
void MQStart() {;} /* dummy entry point */
void MQENTRY MQMDH001( PMQCXP pChannelExitParams,
PMQCD pChannelDefinition,
PMQLONG pDataLength,
PMQLONG pAgentBufferLength,
PMQBYTE AgentBuffer,
PMQLONG pExitBufferLength,
PMQPTR pExitBufferAddr)
{
char Channel_Logfile[] = "c:\\temp\\scylog.log";
FILE * fp;
/* for test purposes */
char TimeBuffer[100];
struct tm *pNow=NULL;
time_t MyTime;
/* open the log file */
fp = fopen(Channel_Logfile,"a+");
pChannelExitParams->ExitResponse = MQXCC_OK;
pChannelExitParams->Feedback = 0;
switch( pChannelExitParams-> ExitReason )
{
case MQXR_INIT:
MyTime=time(NULL);
pNow=localtime(&MyTime);
strftime(TimeBuffer, sizeof(TimeBuffer),
"\nScy exit called for INIT at %A %B %d, %Y at %I:%M %p\n", pNow);
fprintf(fp, "%s", TimeBuffer);
break;
case MQXR_INIT_SEC:
*pDataLength = 9;
pChannelExitParams->ExitResponse = MQXCC_SEND_SEC_MSG;
strncpy((char *)AgentBuffer, "WHOAREYOU\0", 10);
fprintf(fp,"Scy exit called for INIT_SEC, resp=%d, buff=%s\n", pChannelExitParams->ExitResponse, (char *)AgentBuffer);
break;
case MQXR_SEC_MSG:
fprintf(fp,"Scy exit called for SEC_MSG, resp=%d, buff=%.10s\n", pChannelExitParams->ExitResponse, (char *)AgentBuffer);
*pDataLength = 20;
pChannelExitParams->ExitResponse = MQXCC_SEND_SEC_MSG;
/******CHANGE userid/password in the following line:********/
strncpy((char *)AgentBuffer, "A000Userid Password\0", 21);
/******END OF CHANGE userid/password: **********************/
fprintf(fp,"Scy exit called for SEC_MSG, resp=%d, buff=%.10s\n", pChannelExitParams->ExitResponse, (char *)AgentBuffer);
break;
case MQXR_TERM:
fprintf(fp,"Scy exit called for TERM\n");
break;
default:
fprintf(fp,"Scy exit called with invalid reason code: %d\n", pChannelExitParams-> ExitReason);
break;
} /* switch */
fclose(fp);
return;
} /* END OF void MQENTRY MQMDH001( */
This doesn't have a main. So, doesn't compile. If I include a dummy main(){;}, What would happen? Should I call the method void MQENTRY MQMDH001() inside the main? Will it work? Please suggest.
Thanks