Function argument assignment between types "unsigned int*" and "unsigned long*"

This is a discussion on Function argument assignment between types "unsigned int*" and "unsigned long*" within the C Programming forums, part of the General Programming Boards category; Dear All , I am getting the below error while compiling the below source code in 64 bit mode , ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    8

    Exclamation 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

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The line numbers in your error messages and the code don't appear to line up, but one thing I can see is that you use:
    Code:
    unsigned loing nsize = sizeof(SOCKADDR); 
    ...
    getpeername(..., &nsize);
    You should really use:
    Code:
    socklen_t nsize = sizeof(SOCKADDR); 
    ...
    As it happens, there are exactly three calls to getpeername() in your code, and the lines indicated in the warning messages are near these calls.

    Note that a long will change from 32 to 64 bit whilst an int is 32 bits in both cases.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    8

    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

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You don't have a prototype for the function:
    Code:
    long
    performCISTransaction(
    	struct cc_inquire_in		*cc_inquire_inv,
    	struct cc_inquire_out	*cc_inquire_outv
    	)
    Likewise for performCAMTransacation.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    8

    Thanks a lot ..

    Just one doubt , this code was compiling and running successfully in 32 bit mode ... will the 64 bit compilation make a difference ?
    Thanks once again
    Nadeer.

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,263
    Quote Originally Posted by nadeer78 View Post
    Just one doubt , this code was compiling and running successfully in 32 bit mode ... will the 64 bit compilation make a difference ?
    Thanks once again
    Nadeer.
    Yes, it definitely will make a difference. On a 32-bit platform, an "int" and a "long" are often the same size. That will definitely not be true on 64-bit. Which explains your entire problem, actually.

    I am guilty myself of treating "int" and "long" as if they were the same type. It will bite you.

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    8

    Thumbs up Thanks A trillion...

    Thanks a lot ... for your help...
    Nadeer.

  8. #8
    Registered User
    Join Date
    Mar 2008
    Posts
    8

    After Prototyping

    Could you please help me in this ..

    as mentioned earlier I prototyped the function and compiled , got the beloww erro

    "armtrx.c", line 258.40: 1506-280 (W) Function argument assignment between types "struct fts_request_in*" and "struct fts_request_out*" is not allowed.
    "armtrx.c", line 293.46: 1506-280 (W) Function argument assignment between types "struct fts_request_in*" and "struct fts_request_out*" is not allowed.
    "armtrx.c", line 302.51: 1506-280 (W) Function argument assignment between types "struct fts_request_in*" and "struct fts_request_out*" is not allowed.

    here is the code

    Code:
    #include <stdio.h>
    #include <ctype.h>
    #include <atmi.h>	/* TUXEDO Header File */
    #include <userlog.h>	/* TUXEDO Header File */
    
    #ifdef WIN32
    #include <sys/stat.h>
    #else
    #include <unistd.h>
    #endif
    #include "mt.c"
    #include "tuxerrs.h"
    #include "utils.h"
    #include "fts_request.h" /* view definition for main transaction */
    
    /* These can be varied from the command line parameters */
    int debugOn	= 0;
    static unsigned long updateTimeout = 80;
    
    /* 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.
    */
    
    #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;
    
    	/* Some compilers warn if argc and argv aren't used. */
    	argc = argc;
    	argv = argv;
    
    	/* userlog writes to the central TUXEDO message log */
    	userlog("Welcome to the ARMTRX server v1.0.0");
    
    	while ((c = getopt(argc, argv, "d:t:")) != -1)
    	{
    		switch(c)
    		{
    		case 'd':
    			temp = (unsigned long) atol(optarg);
    			if (temp == 0)
    				debugOn = 0;
    			else
    				debugOn = 1;
    			break;
    		case 't':
    			temp = (unsigned long) atol(optarg);
    			if (temp > 0)
    				updateTimeout = temp;
    			else
    				userlog("TUXWARN: Invalid value for '-t' on command line");
    			break;
    		default:
    			userlog("TUXERR: Invalid command line option, '%c'", c);
    			return -1;
    		}
    	}
    	return(0);
    }
    
    /* This TUX service acts as a service dispatcher and invokes the actual
       service required to handle the client's transaction.
       Its argument is a structure containing among other things a pointer
       to the data buffer, and the length of the data buffer. The data contains
       a transaction code which allows us to identify which service should be
       invoked.
    */
    
    #ifdef __cplusplus
    extern "C"
    #endif
    void
    #if defined(__STDC__) || defined(__cplusplus)
    ARMTRX(TPSVCINFO *rqst)
    #else
    ARMTRX(rqst)
    TPSVCINFO *rqst;
    #endif
    {
    	struct fts_request_in	*pstrARM_in	 = NULL;  /* ARM Input */
    	struct fts_request_out  *pstrARM_out = NULL;  /* ARM Final Output */
    	struct fts_request_out  *pstrARM_tmp = NULL;  /* ARM Temp  Output */
    
    	char		*serviceName	= rqst->name;
    	long		rcode				= 0;
    	long		answer_len		= 0;
    	int      xdone          = 0;
    	long		acall				= 0;   /* jb01 return code for tpacall */
    
    	char		TranCode[9];
    	char		TempBuff[9];
    	char		service_name[16];
      
    /* Nad1-->> */ 
        long   mtrcode =0;
        char *StpData =NULL;
    /* Nad1 <<--*/
    long
    performTPCALL(
       char* service_call,
            struct fts_request_in   *input_buffer,
            struct fts_request_out  **output_buffer
            );
    	/* Retrieve the input data */
    	pstrARM_in = (struct fts_request_in *) rqst->data;
    
    
    	if (pstrARM_in == NULL)
    	{
    		userlog("TUXERR: Unable to read input buffer [Key = %.35s]", pstrARM_in);
    		tpreturn(TPFAIL, -1, NULL, 0L, 0L);
    	}
    
    	if ((pstrARM_out = (struct fts_request_out *)tpalloc("VIEW32",
    		"fts_request_out", sizeof(struct fts_request_out) + 8))
    			== (struct fts_request_out *)NULL)
    	{
    		userlog("TUXERR: tpalloc(\"fts_request_out\") failed, %s\n [Key = %.35s]",
    			tpstrerror(tperrno), pstrARM_in);
    
    		tpreturn(TPFAIL, -1, NULL, 0L, 0L);
    	}
    	memset(pstrARM_out, '\0', sizeof(struct fts_request_out));
    	
    
    
    	/*
    	 * Check Transaction Type and process accordingly.
    	 */
       memcpy(pstrARM_in->fts_tranref, "RETARMCO", 8); /* Prep Input */
    	memset(TempBuff, 0, sizeof(TempBuff));
    	memset(TranCode, 0, sizeof(TranCode));
    	memcpy(TempBuff, ((struct fts_request_in*)pstrARM_in)->fts_request_fn+4,4);
    	sscanf(TempBuff, "%s", TranCode);
    
    	memset(service_name, 0, sizeof(service_name));
       if (strncmp(TranCode, "NQ11", 4) == 0)  
       {
    	  memcpy(pstrARM_out, pstrARM_in, 160);
         memcpy(pstrARM_out->fts_camm_action_code, "0000", 4); /* Initialize */
    
          rcode = tpbegin(updateTimeout, 0);
          if (rcode == -1)
          {
             userlog("TUXERR: tpbegin() failed, %s [Key = %.35s]", tpstrerror(tperrno), pstrARM_in);
    
             /* Return original message to caller with new action code. */
             memcpy(pstrARM_out, pstrARM_in, sizeof(struct fts_request_out));
             memcpy(pstrARM_out->fts_camm_action_code, TUXCODE_GENERALFAIL, 4);
    
             answer_len = strlen((char*)pstrARM_out);
             tpreturn(TPSUCCESS, -1, (char *)pstrARM_out, answer_len, 0L);
          }    
    
           memcpy(service_name, "FTSREQ_RETARMCO", 16);  /* Access to FTS */
           rcode = performTPCALL(service_name, pstrARM_in, &pstrARM_out);
    	    answer_len = strlen((char *) pstrARM_out);
           if (rcode != 0)
           {
             rcode = tpabort(0);
             if (rcode == -1)
             {
                userlog("TUXERR: tpabort() failed, %s [Key = %.35s]", tpstrerror(tperrno), pstrARM_in);
    
             }
    
             tpreturn(TPSUCCESS, rcode, (char *)pstrARM_out, answer_len, 0L);
           }
    
          /*
           * Beyond this point, reply is successful.
           * Commit the transaction.
           */
    
    
          rcode = tpcommit(0);
          if (rcode == -1)
          {
             /* Commit failure, attempt to tpabort(). */
            userlog("TUXERR: tpcommit() failed, %s [Key = %.35s]", tpstrerror(tperrno), pstrARM_in);
              rcode = tpabort(0);
             if (rcode == -1)
             {
                userlog("TUXERR: tpabort() failed, %s [Key = %.35s]", tpstrerror(tperrno), pstrARM_in);
             }
    
             /* Return original message to caller with new action code. */
             memcpy(pstrARM_out, pstrARM_in, sizeof(struct fts_request_out));
             memcpy(pstrARM_out->fts_camm_action_code, TUXCODE_COMMITFAIL, 4);
    
             answer_len = strlen((char*)pstrARM_out);
             tpreturn(TPSUCCESS, -1, (char *)pstrARM_out, answer_len, 0L);
         }
    	
       }
    
       else if (strncmp(TranCode, "PD03", 4) == 0  ||
                strncmp(TranCode, "PD06", 4) == 0  ||
                strncmp(TranCode, "PD10", 4) == 0)
       {
           memcpy(service_name, "FTSREQ_RETARMCO", 16);  /* Access to FTS */
           rcode = performTPCALL(service_name, pstrARM_in, &pstrARM_out);
    	    answer_len = strlen((char *) pstrARM_out);
    	  	 if (strncmp(pstrARM_out->fts_result_code,"0000", 4) != 0 ||
               rcode != 0)
           {
    		   tpreturn(TPSUCCESS, -1, (char *)pstrARM_out, answer_len, 0L);
           }
    	      if ((pstrARM_tmp = (struct fts_request_out *)tpalloc("VIEW32",
    		       "fts_request_out", sizeof(struct fts_request_out) + 8))
    			     == (struct fts_request_out *)NULL)
    	      {
    		       userlog("TUXERR: tpalloc(\"fts_request_out\") failed, %s [Key = %.35s]",
    		     	 tpstrerror(tperrno), pstrARM_in);
    		       tpreturn(TPFAIL, -1, NULL, 0L, 0L);
    	      }
    	    memset(pstrARM_tmp, '\0', sizeof(struct fts_request_out));
    
           rcode = performTPCALL("GFCUPD", pstrARM_out, &pstrARM_tmp);
    	      memcpy(pstrARM_out, '\0', 161);
    	      memcpy(pstrARM_out, pstrARM_in, 160);
    	  	   memcpy(pstrARM_out->fts_camm_action_code, 
                    pstrARM_tmp->fts_camm_action_code, 4);
    	  	   memcpy(pstrARM_out->fts_result_code, 
                    pstrARM_tmp->fts_result_code, 4);
             tpfree((char *)pstrARM_tmp);       
    		   tpreturn(TPSUCCESS, rcode, (char *)pstrARM_out, answer_len, 0L);
       }
       else if (strncmp(TranCode, "NQ99", 4) == 0)  
       {
    	      if ((pstrARM_tmp = (struct fts_request_out *)tpalloc("VIEW32",
    		       "fts_request_out", sizeof(struct fts_request_out) + 8))
    			     == (struct fts_request_out *)NULL)
    	      {
    		       userlog("TUXERR: tpalloc(\"fts_request_out\") failed, %s [Key = %.35s]",
    		     	 tpstrerror(tperrno), pstrARM_in);
    		       tpreturn(TPFAIL, -1, NULL, 0L, 0L);
    	      }
    	    memset(pstrARM_tmp, '\0', sizeof(struct fts_request_out));
    
           memcpy(service_name, "FTSREQ_RETARMCO", 16);  /* Access to FTS */
           xdone = 0;
           while (!xdone)
           {
              rcode = performTPCALL(service_name, pstrARM_in, &pstrARM_out);
    	       answer_len = strlen((char *) pstrARM_out);
    	  	    if (strncmp(pstrARM_out->fts_output1,"NIL", 3) == 0 ||
    	  	        strncmp(pstrARM_out->fts_output1,"ERR", 3) == 0   )
              {
                 xdone = 1;
              }
              else
              {
                 rcode = performTPCALL("GFCUPD", pstrARM_out, &pstrARM_tmp);
    
    /*Nad1 */      StpData=pstrARM_out->fts_output1;         
    
                 if (strncmp(pstrARM_tmp->fts_camm_action_code, "0000", 4) != 0)
                 {
                  memcpy(pstrARM_tmp->fts_output1,"REV",3);
                  memcpy(pstrARM_tmp->fts_output4,pstrARM_out->fts_output1+239,10); /*jb02*/
    	   userlog("REVERT: [%s]", pstrARM_tmp);
                  rcode = performTPCALL(service_name, pstrARM_tmp, &pstrARM_out);
                  xdone = 1;
                 }
    /* jb01 begin */
                 if (strncmp(pstrARM_in->fts_input+125, "CCSWP", 5) == 0)
                 {
                    memcpy(pstrARM_in->fts_input+125,"CCVRF",5);
                    acall = tpacall(service_name, (char*)pstrARM_in, 0L,
                            TPNOTRAN|TPNOREPLY);
       /* Nad1 -->>*/
                     if (strncmp(pstrARM_tmp->fts_camm_action_code, "0000", 4) == 0)
                      { 
                         userlog("The Input To Stp is [%s]",StpData);
                         mtrcode= mt( StpData,"/tuxhome/tuxadmin/src/armreq/"  );
                      } 
    
       /*Nad End <<--- */
                    xdone = 1;
                 }
    /* jb01 end */
              }
           }
       }
       else /* Transaction Code is Invalid */
       {
    	   memcpy(pstrARM_out, pstrARM_in, 160);
    	  	memcpy(pstrARM_out->fts_camm_action_code, TUXCODE_BADTXN, 4);
    	   userlog("Invalid Transaction Code %s [Key = %.35s]", TranCode, pstrARM_in);
    		answer_len = strlen((char*)pstrARM_out);
    		tpreturn(TPSUCCESS, -1, (char *)pstrARM_out, answer_len, 0L);
       }
    
    	answer_len = strlen((char *) pstrARM_out);
    	tpreturn(TPSUCCESS, 0, (char *)pstrARM_out, answer_len, 0L);
    }
    
    
    /*
     * Function to perform tpcall to Services.
     *		- checks return code in message
     *
     * Returns:
     *		 0 : success, reply placed in output_buffer
     *		 1 : failure, error reply placed in output_buffer
     */
    long
    performTPCALL(
       char* service_call,
    	struct fts_request_in	*input_buffer,
    	struct fts_request_out  **output_buffer
    	)
    {
    	struct fts_request_out	*output_buffer_ptr = *output_buffer;
    	long		view_len			= 0;
    	long		rcode				= 0;
    
    	if (debugOn)
    	{
    		userlog("DEBUG: About to call service '%s' [Key = %.35s]", service_call, input_buffer->fts_source_id);
    	}
    
    	view_len = sizeof(struct fts_request_out);
    	rcode = tpcall(service_call, (char *)input_buffer, 0,
    						(char **)&output_buffer_ptr, &view_len, 0);
    	*output_buffer = output_buffer_ptr;
    
    	  if (rcode == -1)
    	  {
    		userlog("TUXERR: tpcall(\"%s\") failed, %s [Key = %.35s]",
    			service_call, tpstrerror(tperrno), input_buffer);
    
    		/* Return original message to caller with new action code. */
    		memcpy(output_buffer_ptr, input_buffer, sizeof(struct fts_request_out));
    		memcpy(output_buffer_ptr->fts_camm_action_code, TUXCODE_SVCFAIL, 4);
    
    		return -1;
    	  }
    
    	  /* inspect action code in message */
      if (strncmp(output_buffer_ptr->fts_camm_action_code, "0000", 4) != 0 &&
          strncmp(output_buffer_ptr->fts_camm_action_code, "5555", 4) != 0 )
    	  {
          userlog("ERROR: Request to %s failed: [%.4s] [Key = %.35s]", 
             service_call, output_buffer_ptr->fts_camm_action_code, input_buffer);
    		return 1;
    
    	  }
    	/* NB: reply is already in output_buffer for caller */
    
    	return 0;
    } /* performTPCALL() */

  9. #9
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    Location
    Pacem
    Posts
    355
    Getting in the habit of using the <stdint.h> which provides guaranteed minimum width types, is perhaps the best way to avoid 32 vs 64 bit compilation problems or ambiguities. It's just 4 more keystrokes for int (int32_t), but all the unsigned declarations are much shorter and in fact one saves keyboard time when using <stdint.h>. Also i believe it enhances reliability of you on your variables, as you stop thinking precision issues.
    Code:
    ...
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of ...cheap programming practices.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21