Function argument assignment between types "unsigned int*" and "unsigned long*"
Dear All ,
I am getting the below error while compiling the below source code in 64 bit mode , where as it was compiling/working perfectly in the 32 bi mode
"tcputil.c", line 170.43: 1506-280 (W) Function argument assignment between types "unsigned int*" and "unsigned long*" is not allowed.
"tcputil.c", line 186.43: 1506-280 (W) Function argument assignment between types "unsigned int*" and "unsigned long*" is not allowed.
"tcputil.c", line 200.43: 1506-280 (W) Function argument assignment between types "unsigned int*" and "unsigned long*" is not allowed.
Operating System IBM AIX5.3
Compiler cc
cat tcputil.c
Code:
#include "tcputil.h"
int Connect( char* szHostName, char* szServName )
{
SOCKADDR_IN sockAddr;
LPHOSTENT sockHost;
LPSERVENT sockServ;
int nSockClient=0;
int nPortNo=0;
int nSockLen=0;
char* szAddr = NULL;
if( !szServName )
szServName = szHostName;
/* Retrieve IP address */
if( !(sockHost=gethostbyname( szHostName )) )
return -1;
/* If port name specified then convert it into a port number */
nPortNo = atoi(szServName);
if (nPortNo == 0)
{
if( !(sockServ=getservbyname(szServName, "tcp")) )
return -2;
/* Byte ordering */
nPortNo = htons( sockServ->s_port );
}
else
{
/* Byte ordering */
nPortNo = htons( nPortNo );
}
/* Convert to network address */
memset( &sockAddr, 0, sizeof(sockAddr) );
memcpy( &sockAddr.sin_addr.s_addr, sockHost->h_addr, sockHost->h_length );
szAddr = inet_ntoa( sockAddr.sin_addr );
sockAddr.sin_family = sockHost->h_addrtype;
sockAddr.sin_addr.s_addr = inet_addr( szAddr );
sockAddr.sin_port = htons(nPortNo);
/* Log the server's address */
/* SysLog( "IpAddr[%s] Port[%d]", szAddr, nPortNo);
*/
/* create a socket stream */
if( (nSockClient = socket( AF_INET, SOCK_STREAM, 0 )) < 0 )
return -3;
nSockLen = sizeof(sockAddr);
if( connect( nSockClient, (LPSOCKADDR) &sockAddr, nSockLen ) < 0 ) {
shutdown( nSockClient, 2 );
close( nSockClient );
return -4;
}
return nSockClient;
}
int CreateListener( char* szServName )
{
SOCKADDR_IN sockAddr;
SOCKADDR_IN sockClient;
LPSERVENT sockServ;
LPHOSTENT sockHost;
USHORT nPortNo = 0;
int nSockListen = 0;
int nSockLen = 0;
int nCtr = 0;
char hostName[STRLEN] = "";
/* Get the host name */
if( !szServName ) {
gethostname( hostName, sizeof(hostName) );
if( !(sockHost = gethostbyname(hostName)) )
return (-1);
szServName = hostName;
}
/* Get the port number assigned to atm_server */
if( !(sockServ = getservbyname(szServName, "tcp")) )
return (-1);
/* Create socket */
if( (nSockListen = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
return -1;
/* Convert port number to short */
nPortNo = sockServ->s_port ;
printf( "BIND on Port Number [%d]\n", nPortNo );
/* Rebind until port is available */
while( 1 ) {
bzero( (char*) &sockAddr, sizeof(sockAddr) );
sockAddr.sin_addr.s_addr = htonl( INADDR_ANY );
sockAddr.sin_family = AF_INET;
sockAddr.sin_port = nPortNo;
nSockLen = sizeof(sockAddr);
if( !bind(nSockListen, (LPSOCKADDR) &sockAddr, nSockLen ) )
break;
else {
if( nCtr > MAX_RETRY ) {
shutdown( nSockListen, 2 );
close( nSockListen );
return (-1);
}
/* Increment portno and retries */
nPortNo++;
nCtr++;
printf( "REBINDING[%d]...", nPortNo );
}
}
/* Listen for client connections */
if( listen(nSockListen, MAX_LISTEN) < 0 ) {
shutdown( nSockListen, 2 );
close( nSockListen );
return (-1);
}
return( nSockListen );
}
char* GetPeerName( int nSock )
{
SOCKADDR sockAddr;
LPSOCKADDR_IN lpSockAddr = (LPSOCKADDR_IN)&sockAddr;
LPHOSTENT lpHostEnt = NULL;
unsigned long nSize = sizeof(SOCKADDR);
/* get the peer name */
if( getpeername(nSock, &sockAddr, &nSize) < 0 )
return( NULL );
if( !(lpHostEnt=gethostbyaddr((char*)&lpSockAddr->sin_addr, 4, AF_INET)) )
return( NULL );
return( lpHostEnt->h_name );
}
char* GetPeerAddr( int nSock )
{
SOCKADDR sockAddr;
LPSOCKADDR_IN lpSockAddr = (LPSOCKADDR_IN)&sockAddr;
unsigned long nSize = sizeof(SOCKADDR);
/* get the peer name */
if( getpeername(nSock, &sockAddr, &nSize) < 0 )
return NULL;
else
return( inet_ntoa(lpSockAddr->sin_addr) );
}
int IsPeerSockValid( int nSock )
{
SOCKADDR sockAddr;
LPSOCKADDR_IN lpSockAddr = (LPSOCKADDR_IN)&sockAddr;
LPHOSTENT lpHostEnt = NULL;
unsigned long nSize = sizeof(SOCKADDR);
/* get the peer name */
if( getpeername(nSock, &sockAddr, &nSize) < 0 )
{
return( -1 );
}
if( !(lpHostEnt=gethostbyaddr((char*)&lpSockAddr->sin_addr, 4, AF_INET)) )
{
return( -1 );
}
return( 0 );
}
void SigChild( int nRC )
{
int pid, status;
#ifdef __OS_DEC_UNIX__
while((pid = wait3((union wait *)&status, WNOHANG, (struct rusage *)0))>0);
#elif defined(__OS_SEQ_UNIX__)
while((pid = wait3((int*)&status, WNOHANG, (struct rusage *)0))>0);
#endif
}
char* GetDate( char* pStr )
{
static char pszTime[STRLEN] = "";
time_t timeNow;
timeNow = time( &timeNow );
strftime( pszTime, sizeof(pszTime), "%Y%m%d%H%M%S", localtime(&timeNow) );
return pszTime;
}
int RecvExt( int nSock, char* pStr, int nLen, int nTime )
{
int nRC = 0;
memset( pStr, 0, sizeof(pStr) );
/* set an alarm of nTime secs */
alarm( nTime );
nRC = recv( nSock, pStr, nLen, 0 );
if( errno == ETIME || errno == EINTR || nRC == 0 ) {
alarm( 0 );
return( -1 );
}
/* reset all alarm(s) */
alarm( 0 );
return( nRC );
}
/*
* Function to write a message to a socket.
* The message will be formatted in the form:
* 4-char length + data
*
* Parameters:
* nSock - socket to write message to
* dataBuff - buffer containing data to send in message
* dataLen - length of data
* timeout - timeout period (secs), or 0 for no timeout
* errBuff - buffer for error message (must be > 200 chars big)
*
* Returns 0 on success, or -1 on error.
* In the event of an error an error message is also placed in errBuff.
*/
int writeMessage(
int nSock,
char* dataBuff,
int dataLen,
unsigned long timeout,
char* errBuff
)
{
char* pBuf;
long dataWritten;
/* create a buffer containing 4 char length plus data */
if ( (pBuf = (char*)malloc(dataLen+4)) == NULL )
{
sprintf(errBuff, "ERROR: malloc() failed - out of memory!" );
return -1;
}
sprintf(pBuf, "%04d", dataLen );
memcpy(pBuf+4, dataBuff, dataLen);
dataLen += 4;
if (timeout > 0)
{
alarm(timeout);
}
/* send the message */
dataWritten = writeData( nSock, pBuf, dataLen, (timeout > 0) );
if (timeout > 0)
{
alarm(0); /* MUST turn alarm off */
}
if (dataWritten != dataLen)
{
if (dataWritten == 0)
{
sprintf(errBuff, "ERROR: write() returned 0 (eof)" );
}
else if (errno == EINTR)
{
sprintf(errBuff, "ERROR: signal or timeout during write()");
}
else
{
sprintf(errBuff,
"ERROR: write() for %d chars of data returned %d, errno = %d:%s",
dataLen, dataWritten, errno, strerror(errno));
}
free(pBuf);
return -1;
}
free(pBuf);
return 0;
}
/*
* Function to read a message from a socket.
* The message is expected to be formatted in the form:
* 4-char length + data
*
* Parameters:
* nSock - socket to read message from
* dataBuff - destination buffer for data part of message
* buffLen - length of buffer
* timeout - timeout period (secs), or 0 for no timeout
* errBuff - buffer for error message (must be > 200 chars big)
*
* Returns length of data read on success, or -1 on error.
* (A length of zero can occur if a message length of zero is received.)
* In the event of an error an error message is also placed in errBuff.
*/
int readMessage(
int nSock,
char* dataBuff,
int buffLen,
unsigned long timeout,
char* errBuff
)
{
char szLength[10];
long dataRead;
long dataLen;
if (timeout > 0)
{
alarm(timeout);
}
/* read 4-char message length */
memset( szLength, 0x00, sizeof(szLength));
dataRead = readData( nSock, szLength, 4 , (timeout > 0));
if ( isdigit(szLength[0]) && isdigit(szLength[1])
&& isdigit(szLength[2]) && isdigit(szLength[3]) )
{
dataLen = atoi(szLength);
}
else
{
/* non-numeric char received in length part of message - error */
dataLen = 0;
}
if ( (dataRead != 4) || (dataLen == 0) || (dataLen >= buffLen) )
{
if (timeout > 0)
{
alarm(0); /* MUST turn alarm off */
}
if (dataRead == 0)
{
sprintf(errBuff, "ERROR: read() for length returned 0 (eof)" );
return -1;
}
else if (dataRead != 4)
{
if (errno == EINTR)
{
sprintf(errBuff,
"ERROR: signal or timeout during read() for length");
}
else
{
sprintf(errBuff,
"ERROR: read() for length returned %d [%s], errno = %d:%s",
dataRead, szLength, errno, strerror(errno) );
}
return -1;
}
else if (dataLen == 0)
{
sprintf(errBuff, "ERROR: Message length of zero received [%s]",
szLength);
return 0;
}
else if (dataLen >= buffLen)
{
sprintf(errBuff, "ERROR: Message length of %d is too big, MAXLEN = %d",
dataLen, buffLen);
return -1;
}
}
/* now read the actual message data */
memset( dataBuff, 0x00, buffLen );
dataRead = readData( nSock, dataBuff, dataLen, (timeout > 0) );
if (timeout > 0)
{
alarm(0); /* MUST turn alarm off */
}
if (dataRead != dataLen)
{
if (dataRead == 0)
{
sprintf(errBuff, "ERROR: read() for data returned 0 (eof)" );
}
else if (errno == EINTR)
{
sprintf(errBuff, "ERROR: signal or timeout during read() for data");
}
else
{
sprintf(errBuff,
"ERROR: read() for data returned %d, errno = %d:%s",
dataRead, errno, strerror(errno) );
}
return -1;
}
return dataRead;
}
/*
* Function to write data to specified file descriptor.
* Works correctly even if a signal interrupts the write() system call.
*
* Parameters:
* fd - file descriptor to write data to
* dataBuff - buffer containing data to send
* dataLen - length of data
* sigExit - if non-zero then will exit on signal, else ignores signal
*
* Returns number of bytes successfully written, or -1 on error.
* Note that if the return value is less than dataLen (but not -1) then
* it implies that the file descriptor has been closed.
*/
int writeData(
int fd,
char* dataBuff,
int dataLen,
int sigExit
)
{
long writtenLen;
char* dataPtr;
int dataSentLen;
int toSendLen;
errno = 0; /* must do this to allow caller to check for EINTR */
dataPtr = dataBuff;
dataSentLen = 0;
toSendLen = dataLen;
while (toSendLen > 0)
{
writtenLen = write( fd, dataPtr, toSendLen );
if (writtenLen == -1)
{
/* error or signal occurred */
if ((errno == EINTR) && !sigExit)
{
errno = 0;
continue; /* ignore signal */
}
return -1; /* exit on error or signal */
}
if (writtenLen == 0)
{
/* end of file occurred */
break;
}
dataSentLen += writtenLen;
toSendLen -= writtenLen;
dataPtr += writtenLen;
}
return dataSentLen;
}
/*
* Function to read data from specified file descriptor.
* Works correctly even if a signal interrupts the read() system call.
*
* Parameters:
* fd - file descriptor to read data from
* dataBuff - destination buffer for data
* dataLen - length of data to be read
* sigExit - if non-zero then will exit on signal, else ignores signal
*
* Returns number of bytes successfully read, or -1 on error.
* Note that if the return value is less than dataLen (but not -1) then
* it implies that the file descriptor has been closed.
*/
int readData(
int fd,
char* dataBuff,
int dataLen,
int sigExit
)
{
long readLen;
char* dataPtr;
int dataReadLen;
int toReadLen;
errno = 0; /* must do this to allow caller to check for EINTR */
dataPtr = dataBuff;
dataReadLen = 0;
toReadLen = dataLen;
while (toReadLen > 0)
{
readLen = read( fd, dataPtr, toReadLen );
if (readLen == -1)
{
/* error or signal occurred */
if ((errno == EINTR) && !sigExit)
{
errno = 0;
continue; /* ignore signal */
}
return -1; /* exit on error or signal */
}
if (readLen == 0)
{
/* end of file occurred */
break;
}
dataReadLen += readLen;
toReadLen -= readLen;
dataPtr += readLen;
}
return dataReadLen;
}
int GetProcInfo( char* pStr, PROCINFO* pInfo )
{
int nRC = 0;
char szCom[100] = "";
char* pszFile = NULL;
char* p = NULL;
/* get the process info */
sprintf( szCom, "ps -eaf | grep %s | grep -v grep > /tmp/procinfo", pStr );
nRC = system( szCom );
if( (pszFile = GetFileContent( "/tmp/procinfo" )) == NULL )
return( -1 );
/* get the owner */
memset( pInfo, 0, sizeof(PROCINFO) );
p = strtok( pszFile, " " );
strcpy( pInfo->szOwner, p );
/* get the PID */
p = strtok( NULL, " " );
pInfo->nPid = atol( p );
/* TODO: get additional info */
/* cleanup allocated resources */
remove( "/tmp/procinfo" );
return 0;
}
/*
** EOF
*/
cat tcputil.h
#ifndef __TCPUTIL_H__
#define __TCPUTIL_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <signal.h>
#include "errsocket.h"
#include "utils.h"
/*
** macro definition for max length, retry, etc.
*/
#define MAX_RETRY 10
#define MAX_LISTEN 5
#define MAX_CONNECTION 30
/*
** socket type definitions
*/
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr_in* LPSOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
typedef struct sockaddr* LPSOCKADDR;
typedef struct hostent HOSTENT;
typedef struct hostent* LPHOSTENT;
typedef struct servent SERVENT;
typedef struct servent* LPSERVENT;
/*
** process info
*/
typedef struct tagPROCINFO {
char szOwner[15];
int nPid;
char szTty[15];
char szIdleTm[6];
} PROCINFO;
/*
** client/server function prototypes
*/
int Connect ( char*, char* );
int CreateListener ( char* );
char* GetPeerAddr ( int );
char* GetPeerName ( int );
int IsPeerSockValid ( int );
int RecvExt ( int, char*, int, int );
int writeMessage(
int nSock,
char* dataBuff,
int dataLen,
unsigned long timeout,
char* errBuff
);
int readMessage(
int nSock,
char* dataBuff,
int buffLen,
unsigned long timeout,
char* errBuff
);
int writeData(
int fd,
char* dataBuff,
int dataLen,
int sigExit
);
int readData(
int fd,
char* dataBuff,
int dataLen,
int sigExit
);
/*
** signal function(s)
*/
void SigChild ();
int GetProcInfo ( char*, PROCINFO* );
/*
** date/time function(s)
*/
char* GetDate ( char* );
#endif /* __TCPUTIL_H__ */
Please help me resolve this issue.
Nadeer
Thanks a lot for the help..
its solved my big pain...
I am stuck with another error , ( hope you do not mind )
while compiling the below code in 64 bit mode , the below error is coming
"cc_inquire.c", line 186.1: 1506-343 (S) Redeclaration of performCISTransaction differs from previous declaration on line 135 of "cc_inquire.c".
"cc_inquire.c", line 186.1: 1506-050 (I) Return type "long" in redeclaration is not compatible with the previous return type "int".
"cc_inquire.c", line 284.1: 1506-343 (S) Redeclaration of performCAMTransaction differs from previous declaration on line 155 of "cc_inquire.c".
"cc_inquire.c", line 284.1: 1506-050 (I) Return type "long" in redeclaration is not compatible with the previous return type "int".
Code:
/* #IDENT "@(#) cc_inquire.c $Revision: 1.1 $" */
*****************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <atmi.h> /* TUXEDO Header File */
#include <userlog.h> /* TUXEDO Log File */
#include "tuxerrs.h"
#include "utils.h"
#include <inttypes.h>
#include <strings.h>
#include "cc_inquire.h"
#include "cam_inquire.h"
#include "cis_inquire.h"
static int debugOn = 1;
/* tpsvrinit is executed when a server is booted, before it begins
processing requests. It is not necessary to have this function.
Also available is tpsvrdone (not used in this example), which is
called at server shutdown time.
Command line may contain following optional params:
'-d <debug enable/disable (0 or 1)>'
*/
#if defined(__STDC__) || defined(__cplusplus)
tpsvrinit(int argc, char *argv[])
#else
tpsvrinit(argc, argv)
int argc;
char **argv;
#endif
{
int c = 0;
unsigned long temp = 0;
/* userlog writes to the central TUXEDO message log */
userlog("Welcome to the ccinq - complex server");
while ((c = getopt(argc, argv, "d:")) != -1)
{
switch(c)
{
case 'd':
temp = atol(optarg);
if (temp == 0)
debugOn = 0;
else
debugOn = 1;
break;
default:
userlog("TUXERR: Invalid command line option, '%c'", optopt);
return -1;
}
}
return 0;
}
/* This function performs the actual service requested by the client.
Its argument is a structure containing among other things a pointer
to the data buffer, and the length of the data buffer.
*/
#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) || defined(__cplusplus)
GCCINQ(TPSVCINFO *rqst)
#else
GCCINQ(rqst)
TPSVCINFO *rqst;
#endif
{
struct cc_inquire_in *cc_inquire_inv = NULL;
struct cc_inquire_out *cc_inquire_outv = NULL;
long rcode = -1;
long answer_len = 0;
char *serviceName = "CCINQ";
userlog("Entering service %s", serviceName);
/* map onto input buffer */
cc_inquire_inv = (struct cc_inquire_in *) rqst->data;
if ( cc_inquire_inv == NULL )
{
userlog("TUXERR: Unable to read input buffer");
tpreturn(TPFAIL, -1, NULL, 0L, 0L);
return;
}
/* Create CC output buffer, set data pointer and clear it */
if ((cc_inquire_outv = (struct cc_inquire_out *)tpalloc("VIEW32",
"cc_inquire_out", sizeof(struct cc_inquire_out) + 8)) ==
(struct cc_inquire_out *)NULL)
{
userlog("TUXERR: tpalloc(\"cc_inquire_out\" failed, %s",
tpstrerror(tperrno));
tpreturn(TPFAIL, -1, NULL, 0L, 0L);
return;
}
answer_len = sizeof(struct cc_inquire_out);
memset(cc_inquire_outv, '\0', answer_len);
/*
* Call CISINQ, passing in the cc_inquire_inv for the request input.
* Any reply will be returned in cc_inquire_outv.
*/
rcode = performCISTransaction(cc_inquire_inv, cc_inquire_outv);
if (rcode == -1)
{
/* error return, no error reply message for caller */
tpfree((char *)cc_inquire_outv);
tpreturn(TPFAIL, -1, NULL, 0L, 0L);
return;
}
else if (rcode == 1)
{
/* error return with error reply message for caller */
tpreturn(TPSUCCESS, -1, (char*)cc_inquire_outv, answer_len, 0L);
return;
}
/*
* Call CAMINQ, passing in the output from CIS for the request input
* (in cc_inquire_outv).
* Any reply will also be returned in cc_inquire_outv.
*/
rcode = performCAMTransaction(cc_inquire_outv);
if (rcode == -1)
{
/* error return, no error reply message for caller */
tpfree((char *)cc_inquire_outv);
tpreturn(TPFAIL, -1, NULL, 0L, 0L);
return;
}
else if (rcode == 1)
{
/* error return with error reply message for caller */
tpreturn(TPSUCCESS, -1, (char*)cc_inquire_outv, answer_len, 0L);
return;
}
userlog("Finishing service %s", serviceName);
tpreturn (TPSUCCESS, 0, (char *)cc_inquire_outv, answer_len, 0L);
}
/*
* Function to perform the CISINQ transaction.
* - passes data to CISINQ
* - checks return code in message
*
* Returns:
* 1 : failure, error reply placed in cc_inquire_outv
* 0 : success, reply placed in cc_inquire_outv
* -1 : failure, cc_inquire_outv unchanged
*/
long
performCISTransaction(
struct cc_inquire_in *cc_inquire_inv,
struct cc_inquire_out *cc_inquire_outv
)
{
struct cis_inquire_in *cis_inquire_inv = NULL;
struct cis_inquire_out *cis_inquire_outv = NULL;
long rcode = -1;
long view_len = 0;
/* Create CIS input buffer, set data pointer and copy data */
if ((cis_inquire_inv = (struct cis_inquire_in *)tpalloc("VIEW32",
"cis_inquire_in", sizeof(struct cis_inquire_in) + 8)) ==
(struct cis_inquire_in *)NULL)
{
userlog("TUXERR: tpalloc(\"cis_inquire_in\" failed, %s",
tpstrerror(tperrno));
return -1;
}
memcpy(cis_inquire_inv, cc_inquire_inv, sizeof(struct cis_inquire_in));
/* Create CIS output buffer and set data pointer */
if ((cis_inquire_outv = (struct cis_inquire_out *)tpalloc("VIEW32",
"cis_inquire_out", sizeof(struct cis_inquire_out) + 8)) ==
(struct cis_inquire_out *)NULL)
{
userlog("TUXERR: tpalloc(\"cis_inquire_out\" failed, %s",
tpstrerror(tperrno));
tpfree((char *)cis_inquire_inv);
return -1;
}
if (debugOn)
{
userlog("DEBUG: About to call CISINQ");
}
view_len = sizeof(struct cis_inquire_out);
rcode = tpcall("CISINQ", (char *)cis_inquire_inv, 0,
(char **)&cis_inquire_outv, &view_len, 0);
if (rcode == -1)
{
userlog("TUXERR: tpcall(\"CISINQ\") failed, %s ", tpstrerror(tperrno));
/* copy original message data into output buffer, with new result code */
memcpy(cc_inquire_outv, cc_inquire_inv, sizeof(struct cc_inquire_out));
strncpy(cc_inquire_outv->cc_result_code, TUXCODE_SVCFAIL, 4);
tpfree((char *)cis_inquire_inv);
tpfree((char *)cis_inquire_outv);
return 1;
}
if (debugOn)
{
userlog("DEBUG: Start of data from CIS: %.300s\n",
cis_inquire_outv->cis_output1);
userlog("DEBUG: Return code from CIS %4.4s\n",
cis_inquire_outv->cis_result_code);
}
/* inspect result code in message */
if (strncmp(cis_inquire_outv->cis_result_code, "0000", 4) != 0)
{
userlog("ERROR: Request to CISINQ failed, %.4s",
cis_inquire_outv->cis_result_code);
/* return CIS reply to caller */
memcpy(cc_inquire_outv, cis_inquire_outv, sizeof(struct cc_inquire_out));
tpfree((char *)cis_inquire_inv);
tpfree((char *)cis_inquire_outv);
return 1;
}
/* return CIS reply to caller */
memcpy(cc_inquire_outv, cis_inquire_outv, sizeof(struct cc_inquire_out));
tpfree((char *)cis_inquire_inv);
tpfree((char *)cis_inquire_outv);
return 0;
} /* performCISTransaction() */
/*
* Function to perform the CAMINQ transaction.
* - passes data to CAMINQ
* - checks return code in message
*
* Returns:
* 1 : failure, error reply placed in cc_inquire_outv
* 0 : success, reply placed in cc_inquire_outv
* -1 : failure, cc_inquire_outv unchanged
*/
long
performCAMTransaction(
struct cc_inquire_out *cc_inquire_outv
)
{
struct cam_inquire_in *cam_inquire_inv = NULL;
struct cam_inquire_out *cam_inquire_outv = NULL;
long rcode = -1;
long view_len = 0;
/* Create CAM input buffer, set data pointer and copy data */
if ((cam_inquire_inv = (struct cam_inquire_in *)tpalloc("VIEW32",
"cam_inquire_in", sizeof(struct cam_inquire_in) + 8)) ==
(struct cam_inquire_in *)NULL)
{
userlog("TUXERR: tpalloc(\"cam_inquire_in\" failed, %s",
tpstrerror(tperrno));
return -1;
}
memcpy(cam_inquire_inv, cc_inquire_outv, sizeof(struct cam_inquire_in));
/* Create CAM output buffer and set data pointer */
if ((cam_inquire_outv = (struct cam_inquire_out *)tpalloc("VIEW32",
"cam_inquire_out", sizeof(struct cam_inquire_out) + 8)) ==
(struct cam_inquire_out *)NULL)
{
userlog("TUXERR: tpalloc(\"cam_inquire_out\" failed, %s",
tpstrerror(tperrno));
tpfree((char *)cam_inquire_inv);
return -1;
}
if (debugOn)
{
userlog("DEBUG: About to call CAMINQ");
}
view_len = sizeof(struct cam_inquire_out);
rcode = tpcall("CAMINQ", (char *)cam_inquire_inv, 0,
(char **)&cam_inquire_outv, &view_len, 0);
if (rcode == -1)
{
userlog("TUXERR: tpcall(\"CAMINQ\") failed, %s ", tpstrerror(tperrno));
/* update reply with new result code */
strncpy(cc_inquire_outv->cc_result_code, TUXCODE_SVCFAIL, 4);
tpfree((char *)cam_inquire_inv);
tpfree((char *)cam_inquire_outv);
return -1;
}
if (debugOn)
{
userlog("DEBUG: Start of data from CAM: %.300s\n",
cam_inquire_outv->cam_output1);
userlog("DEBUG: Return code from CAM %4.4s\n",
cam_inquire_outv->cam_result_code);
}
/* inspect return code in message */
if (strncmp(cam_inquire_outv->cam_result_code, "0000", 4) != 0)
{
userlog("ERROR: Request to CAMINQ failed, %.4s",
cam_inquire_outv->cam_result_code);
/* update reply with CAM result code */
strncpy(cc_inquire_outv->cc_result_code,
cam_inquire_outv->cam_result_code, 4);
tpfree((char *)cam_inquire_inv);
tpfree((char *)cam_inquire_outv);
return 1;
}
/* return CAM reply to caller */
memcpy(cc_inquire_outv, cam_inquire_outv, sizeof(struct cc_inquire_out));
tpfree((char *)cam_inquire_inv);
tpfree((char *)cam_inquire_outv);
return 0;
} /* performCAMTransaction() */
Could you please help me once again
Nadeer