code has been taken frm linux platform and try to compile it on windows using vc++2008
errors are as following-
licensejni.c(11 7)warning :c4047:"=":'int ' difers the level of indirection from 'char*'
licensejni.c(15 0):error c2143:syntax error:missing'; 'before'type'
licensejni.c(15 4):error c2065:'comm':un declared identifier
licensejni.c(15 5):error c2065:'comm':un declared identifier
licensejni.c(15 9):error c2065:'comm':un declared identifier
licensejni.c(17 7):error c2143:syntax error:missing'; 'before'type'
licensejni.c(18 4):error c2065:'licenseu pdateresult':un declered identifier
Code:
#include <stdio.h> #include <sys/types.h> //#include <sys/socket.h> #include <winsock.h> #include<stdlib.h> #include<string.h> /*#include<cstring.h>*/ #include "FunctionMapping.h" #include "getInventory.h" //#include "source.h" //#include <netinet/in.h> void error(char *msg) { perror(msg); exit(1); } struct licensedetails { char lic_num[16]; long int max_cc_calls; long int max_subs_limit; char expiry_date[10]; char authorised_mac_addr[32]; }; int dummylicensedecrypter(char* encryptedtext) { int decryptionresult=0; char badcharacter='*'; if(strchr(encryptedtext,badcharacter)) { decryptionresult=0; printf ("\nFound badcharacter%c at %d\n",badcharacter,strchr(encryptedtext,badcharacter)); } else decryptionresult=1; printf("\nDecryptionResult: %d\n",decryptionresult); return decryptionresult; } // using jni /*JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2(JNIEnv *env, jobject obj,jstring s1 ) { char tosend[200]; const jbyte *str; int presult; str = (*env)->GetStringUTFChars(env, s1, NULL); if (str == NULL) { return NULL; /* OutOfMemoryError already thrown } char strng[20] ="updatelicense"; presult=(char *)invokelicenseupdate(strng,str); printf(" processreply %s\n",tosend); if(presult==1)strcpy(tosend,"SUCCESS"); else strcpy(tosend,"FAILURE"); printf("processreply .. %s",tosend); (*env)->ReleaseStringUTFChars(env, s1, str); return (*env)->NewStringUTF(env, tosend); }*/ JNIEXPORT jstring JNICALL Java_FunctionMapping_interchange (JNIEnv *env, jobject obj, jstring s, jstring s2) { char reply[200]; const jbyte *str; int rno; str = (*env)->GetStringUTFChars(env, s, NULL); if (str == NULL) { return NULL; /* OutOfMemoryError already thrown */ } (*env)->ReleaseStringUTFChars(env, s, str); rno = rand()%(10); if (rno <7) {strcpy(reply,"SUCCESS");} else {strcpy(reply,"FAILURE");} return (*env)->NewStringUTF(env, reply); } // ist function JNIEXPORT jstring JNICALL Java_FunctionMapping_updatelicense__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring s1, jstring s2) { char tosend[200]; const jbyte *str, *str2; int presult; str = (*env)->GetStringUTFChars(env, s1, NULL); str2 = (*env)->GetStringUTFChars(env, s2, NULL); if (str == NULL) { return NULL; /* OutOfMemoryError already thrown */ } if (str2 == NULL) { return NULL; /* OutOfMemoryError already thrown */ } if(strcmp(str,"UPDATE_LICENSE")==0) { printf("Invoking commands for execution of .... %s\n with process parameters using jni %s\n",str,str2); presult=(char *)invokelicenseupdate(str,str2); printf(" processreply %s\n",tosend); } else { printf("Unrecognized process %s\n",str); } if(presult==1)strcpy(tosend,"SUCCESS"); else strcpy(tosend,"FAILURE"); printf("processreply .. %s",tosend); (*env)->ReleaseStringUTFChars(env, s1, str); (*env)->ReleaseStringUTFChars(env, s2, str2); return (*env)->NewStringUTF(env, tosend); } int reloadngcpe(char processparameter[]) { int licenseupdateresult=0; printf("\nreloading ngcpe...."); printf("\ndecrypting license file...."); //dummy decryption logic licenseupdateresult=dummylicensedecrypter(processparameter); if(licenseupdateresult==1) { //updating database printf("\nwriting to database"); char comm[500]; while(1) { printf("\n myPrompt>>>"); gets(comm); if(!strcmp(comm,"exit")) { break; } system(comm); } } return licenseupdateresult; } int invokelicenseupdate(char process[],char processparameter[]) { printf("\nTaking backup of current license file in cdot_license.bk . . ."); printf("\nPlacing new license file cdot_license.dat"); int licenseupdateresult=reloadngcpe(processparameter); printf("\nlicense update information logged in pdtrc.log file"); return licenseupdateresult; } int main(int argc, char *argv[]) { int sockfd, newsockfd, portno, clilen; char buffer[1000]; struct sockaddr_in serv_addr, cli_addr; int n; char process[50]; int i,j=0; char processparameter[100]; char processreply[100]; int processresult; if (argc < 2) { fprintf(stderr,"ERROR, no port provided\n"); exit(1); } sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) error("ERROR opening socket"); bzero((char *) &serv_addr, sizeof(serv_addr)); portno = atoi(argv[1]); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno); if (bind(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) error("ERROR on binding"); listen(sockfd,5); printf("\nSS simulator ready...listening on port : %d",portno); clilen = sizeof(cli_addr); newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd < 0) error("ERROR on accept"); bzero(buffer,1000); n = read(newsockfd,buffer,1000); if (n < 0) error("ERROR reading from socket"); printf("Here is the message: %s\n",buffer); for(i=0;i<strlen(buffer);i++) { if(buffer[i]!=';') process[i]=buffer[i]; else break; } i++;//for omitting delimiter printf("i %d\n",i); for(i,j;i<strlen(buffer);i++,j++) { processparameter[j]=buffer[i]; } printf("Here is the process invoked: (%s)\n",process); printf("Here is the process parameter: %s\n",processparameter); if(strcmp(process,"UPDATE_LICENSE")==0) { printf("Invoking commands for execution of .... %s\n with process parameters %s\n",process,processparameter); processresult=(char *)invokelicenseupdate(process,processparameter); printf(" processreply %s\n",processreply); } else { printf("Unrecognized process %s\n",process); } if(processresult==1)strcpy(processreply,"SUCCESS"); else strcpy(processreply,"FAILURE"); printf("processreply .. %s",processreply); n = write(newsockfd,processreply,sizeof(processreply)); if (n < 0) error("\nERROR writing to socket"); return 0; } //mysql -ungcpe -pngcpe agent; // update sip_license set lic_num='0001'; //quit //exit
licensejni.c(11 7)warning :c4047:"=":'int ' difers the level of indirection from 'char*'
licensejni.c(15 0):error c2143:syntax error:missing'; 'before'type'
licensejni.c(15 4):error c2065:'comm':un declared identifier
licensejni.c(15 5):error c2065:'comm':un declared identifier
licensejni.c(15 9):error c2065:'comm':un declared identifier
licensejni.c(17 7):error c2143:syntax error:missing'; 'before'type'
licensejni.c(18 4):error c2065:'licenseu pdateresult':un declered identifier
Comment