Dear All,
I am trying to integrate CitiBank payment gateway in my application developed in php. The steps CitiBank told us to follow are these.
copy checksum.so.1 in /usr/lib folder
check the bit of the server using 'uname -1' and it should be i386
then type 'ldconfig -n /usr/lib' or add the line "/usr/lib" in /etc/ld.so.conf then run ldconfig.
then create a C language program to call the checksum file, sample c file is attached
compile the C program using 'gcc -rdynamic -o prog3 prog3.c -ldl' where prog3.c is the c program name
this will create a executable name prog3
test run the executable using './prog3 test 1234567890abcdef'
finally create a php file and call the c executable, sample php program is attached
#########################################
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<dlfcn.h>
int main(int argc, char *argv[] )
{
void *handle;
char *str;
int len1, len2;
char *param1 , *param2;
len1=strlen(argv[1]);
param1=(char*)malloc(sizeof(char*)*(len1 +1));
strcpy(param1,argv[1]);
//printf("Argument1 - %s\n",param1);
len2=strlen(argv[2]);
param2=(char*)malloc(sizeof(char*)*(len2 +1));
strcpy(param2,argv[2]);
//printf("Argument2 - %s\n",param2);
/*
char temp1[strlen(argv[1]+1)];
char temp2[strlen(argv[2]+1)];
strncpy(temp1,argv[1],strlen(argv[1]));
temp1[strlen(argv[1])+1] = '\0';
strncpy(temp2,argv[2],strlen(argv[2]));
temp2[strlen(argv[2])+1] = '\0';
*/
char* (*func)(char*,char*);
handle=dlopen("/usr/lib/checksum.so.1",RTLD_LAZY);
func=(char* (*)(char*,char*))dlsym(handle,"Transpo");
str=(char*)malloc(sizeof(char) * 20);
str=(char *)((*func)(param1,param2));
//str=(char *)((*func)(temp1,temp2));
/*
printf("\n");
printf("%d",argc);
printf("\n");
printf("%s",argv[1]);
printf("\n");
printf("%s",argv[2]);
printf("\n");
*/
printf("STR = %s \n", str);
//return str;
//return 0;
}
---------------
###########################
PHP program
-----------
<?php
$output = shell_exec('./prog3 test 1234567890abcdef');
echo "$output";
?>
We followed all the above steps. But when we run the executable c program we get SEGMENTATION FAULT error.
Can anybody help us how to do it?
Thanks.
Nasir Perwaiz



