Witam wszystkich.
Znalazlem pewien kod w necie, jest dosc stary (napisany chyba w 94 r) i podczas kompilacji pokazuja mi sie kilka ostrzezen. Czesc nich sie juz pozbylem ale zostalo mi pare i nie wiem jak mam je usunac gdyz nie pisze w C tylko w Javie.
test.c: In function 'parse':
test.c warning: assignment makes integer from pointer without a cast
test.c warning: passing argument 2 of 'strcmp' makes pointer from intege r without a cast
test.c: In function 'Java_login_exit':
test.c warning: initialization makes integer from pointer without a cast
test.c warning: passing argument 2 of 'strcat' makes pointer from intege
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include "login.h"
int getChars() {
struct termios oldt, newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}
void parse(char *buf,char **args)
{
while (strcmp(buf,NULL) == 0) {
while ((*buf == ' ') || (*buf == '\t'))
*buf++ = NULL;
*args++ = buf;
while ((strcmp(buf,NULL) == 0) && (strcmp(buf,"") == 0) && (strcmp(buf,'\t') == 0))
buf++;
}
*args = NULL;
}
void execute(char **args)
{
int pid, status;
if ((pid = fork()) < 0) {
perror("fork");
exit(1);
}
if (pid == 0) {
execvp(*args, args);
perror(*args);
exit(1);
}
while (wait(&status) != pid)
;
}
JNIEXPORT void JNICALL
Java_login_exit(JNIEnv *env, jobject obj,jstring login)
{
char log = (*env)->GetStringUTFChars(env, login, 0);
char buf[1024] = "ls";
strcat(buf,log);
char *args[64];
parse(buf, args);
execute(args);
}
JNIEXPORT int JNICALL
Java_login_getch(JNIEnv *env, jobject obj)
{
return getChars();
}