version 1.7, 2001/05/06 07:53:01 |
version 1.11, 2002/05/02 08:33:47 |
|
|
/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.6 2000/12/05 05:58:33 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.10 2002/05/02 03:08:28 takayama Exp $ */ |
/* nullserver01 */ |
/* nullserver01 */ |
#include <stdio.h> |
#include <stdio.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
#include <unistd.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
#include <sys/time.h> |
#include <sys/time.h> |
Line 32 int Do_not_use_control_stream_to_tell_no_server = 1; |
|
Line 33 int Do_not_use_control_stream_to_tell_no_server = 1; |
|
static void errorToStartEngine(void); |
static void errorToStartEngine(void); |
static int findOxServer(char *server); |
static int findOxServer(char *server); |
static void couldNotFind(char *s); |
static void couldNotFind(char *s); |
|
#if defined(__CYGWIN__) |
|
int errno; |
|
#endif |
|
/* gcc -v -c hoge.c */ |
|
|
|
|
main(int argc, char *argv[]) { |
main(int argc, char *argv[]) { |
int fd; |
int fd; |
int size; |
int size; |
Line 48 main(int argc, char *argv[]) { |
|
Line 52 main(int argc, char *argv[]) { |
|
char portfile[1024]; |
char portfile[1024]; |
char *pass; |
char *pass; |
int result; |
int result; |
|
int sleepingTime = 0; |
|
|
strcpy(sname,"localhost"); |
strcpy(sname,"localhost"); |
strcpy(ServerName,SERVERNAME); |
strcpy(ServerName,SERVERNAME); |
Line 88 main(int argc, char *argv[]) { |
|
Line 93 main(int argc, char *argv[]) { |
|
if (i<argc) { |
if (i<argc) { |
pass = argv[i]; |
pass = argv[i]; |
} |
} |
|
}else if (strcmp(argv[i],"-wait") == 0) { |
|
i++; |
|
if (i<argc) { |
|
sscanf(argv[i],"%d",&sleepingTime); |
|
} |
}else { |
}else { |
fprintf(stderr,"Unknown option %s.\n",argv[i]); |
fprintf(stderr,"Unknown option %s.\n",argv[i]); |
oxmainUsage(); exit(10); |
oxmainUsage(); exit(10); |
Line 103 main(int argc, char *argv[]) { |
|
Line 113 main(int argc, char *argv[]) { |
|
} |
} |
} |
} |
|
|
|
if (sleepingTime) { |
|
fprintf(stderr,"Waiting to connect for %d seconds...\n",sleepingTime); |
|
sleep(sleepingTime); |
|
fprintf(stderr,"\nTrying to connect\n"); |
|
} |
|
|
if (reverse) { |
if (reverse) { |
/* The order is very important. */ |
/* The order is very important. */ |
fdControl = socketConnectWithPass(sname,portControl,pass); |
fdControl = socketConnectWithPass(sname,portControl,pass); |
Line 318 restoreLockCtrlCForOx() { ; } |
|
Line 334 restoreLockCtrlCForOx() { ; } |
|
static int findOxServer(char *server) { |
static int findOxServer(char *server) { |
char *p; |
char *p; |
char *p2; |
char *p2; |
int fd; |
|
char *getenv(char *s); |
char *getenv(char *s); |
if (strlen(server) == 0) return(-1); |
if (strlen(server) == 0) return(-1); |
fd = open(server,O_RDONLY); |
/* fd = open(server,O_RDONLY); */ |
if (fd >= 0) { |
if (access(server,X_OK&R_OK) == 0) { |
fprintf(stderr,"Starting OX server : %s\n",server); |
fprintf(stderr,"Starting OX server : %s\n",server); |
close(fd); |
|
return(0); |
return(0); |
} |
} |
if (server[0] == '/') { |
if (server[0] == '/') { |
Line 339 static int findOxServer(char *server) { |
|
Line 353 static int findOxServer(char *server) { |
|
p2 = (char *) malloc(sizeof(char)*(strlen(p)+strlen("/bin/")+3+strlen(server))); |
p2 = (char *) malloc(sizeof(char)*(strlen(p)+strlen("/bin/")+3+strlen(server))); |
if (p2 == NULL) { fprintf(stderr,"No more memory.\n"); exit(10); } |
if (p2 == NULL) { fprintf(stderr,"No more memory.\n"); exit(10); } |
strcpy(p2,p); strcat(p2,"/bin/"); strcat(p2,server); |
strcpy(p2,p); strcat(p2,"/bin/"); strcat(p2,server); |
fd = open(p2,O_RDONLY); |
/* fd = open(p2,O_RDONLY); */ |
if (fd >= 0) { |
if (access(p2,X_OK&R_OK) == 0) { |
fprintf(stderr,"Starting OX server : %s\n",p2); |
fprintf(stderr,"Starting OX server : %s\n",p2); |
if (strlen(p2) < SERVERNAME_SIZE) strcpy(server,p2); |
if (strlen(p2) < SERVERNAME_SIZE) strcpy(server,p2); |
else { |
else { |
couldNotFind("Too long ox server name."); |
couldNotFind("Too long ox server name."); |
return(-1); |
return(-1); |
} |
} |
close(fd); |
|
return(0); |
return(0); |
} |
} |
couldNotFind(p2); |
couldNotFind(p2); |