version 1.18, 2004/09/17 07:27:28 |
version 1.21, 2005/02/28 12:53:44 |
|
|
/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.17 2004/03/03 02:31:50 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.20 2004/09/17 12:32:11 takayama Exp $ */ |
/* nullserver01 */ |
/* nullserver01 */ |
#include <stdio.h> |
#include <stdio.h> |
#include <fcntl.h> |
#include <fcntl.h> |
Line 37 static void errorToStartEngine(void); |
|
Line 37 static void errorToStartEngine(void); |
|
static int findOxServer(char *server); |
static int findOxServer(char *server); |
static void couldNotFind(char *s); |
static void couldNotFind(char *s); |
/* gcc -v -c hoge.c */ |
/* gcc -v -c hoge.c */ |
|
static void mywait(); |
|
|
void *sGC_malloc(int n) { |
void *sGC_malloc(int n) { |
return (void *)malloc(n); |
return (void *)malloc(n); |
Line 146 main(int argc, char *argv[]) { |
|
Line 147 main(int argc, char *argv[]) { |
|
passControl = pass; |
passControl = pass; |
} |
} |
|
|
|
/* Decrypt passControl and passData, here. Lookup cryptmethod. */ |
|
|
if (reverse) { |
if (reverse) { |
/* The order is very important. */ |
/* The order is very important. */ |
fdControl = socketConnectWithPass(sname,portControl,passControl); |
fdControl = socketConnectWithPass(sname,portControl,passControl); |
Line 155 main(int argc, char *argv[]) { |
|
Line 158 main(int argc, char *argv[]) { |
|
result = 0; |
result = 0; |
|
|
|
|
|
if ((fdControl < 0) || (fdStream < 0)) { |
|
fprintf(stderr,"Waiting for 10 seconds to show an error.\n"); |
|
sleep(10); |
|
} |
|
|
if (portControl != -1) { |
if (portControl != -1) { |
MyServerPid = fork(); |
MyServerPid = fork(); |
if (MyServerPid > 0 ) parentServerMain(fdControl,fdStream); |
if (MyServerPid > 0 ) parentServerMain(fdControl,fdStream); |
Line 215 main(int argc, char *argv[]) { |
|
Line 223 main(int argc, char *argv[]) { |
|
} |
} |
} |
} |
|
|
|
if (passControl != NULL) { |
|
char *s; int mm; |
|
fprintf(stderr,"passControl\n"); |
|
mm = strlen(passControl); |
|
s = (char *) malloc(mm+1); |
|
if (s == NULL) {fprintf(stderr,"No more memory.\n"); exit(1); } |
|
if (read(fdControl,s,mm+1) < 0) { |
|
fprintf(stderr,"Read error to read passControl\n"); sleep(5); exit(1); |
|
} |
|
s[mm] = 0; |
|
if (strcmp(s,passControl) != 0) { |
|
fprintf(stderr,"s=%s and passControl=%s do not match.\n",s,passControl); sleep(5); exit(1); |
|
} |
|
free(s); |
|
} |
|
if (passData != NULL) { |
|
char *s; int mm; |
|
mm = strlen(passData); |
|
fprintf(stderr,"passData\n"); |
|
s = (char *) malloc(mm+1); |
|
if (s == NULL) {fprintf(stderr,"No more memory.\n"); exit(1); } |
|
if (read(fdStream,s,mm+1) < 0) { |
|
fprintf(stderr,"Read error to read passData\n"); |
|
errorToStartEngine(); |
|
} |
|
if (strcmp(s,passData) != 0) { |
|
fprintf(stderr,"s=%s and passData=%s do not match.\n",s,passData); |
|
errorToStartEngine(); |
|
} |
|
free(s); |
|
} |
|
|
|
if ((fdControl < 0) || (fdStream < 0)) { |
|
fprintf(stderr,"Waiting for 10 seconds to show an error.\n"); |
|
sleep(10); |
|
} |
|
|
|
|
result = 0; |
result = 0; |
if (portControl != -1) { |
if (portControl != -1) { |
MyServerPid = fork(); |
MyServerPid = fork(); |
Line 236 static void errorToStartEngine(void) { |
|
Line 281 static void errorToStartEngine(void) { |
|
If you implement this, set Do_not_use_control_stream_to_tell_no_server to |
If you implement this, set Do_not_use_control_stream_to_tell_no_server to |
zero. |
zero. |
*/ |
*/ |
sleep(2); |
sleep(10); |
exit(-1); |
exit(-1); |
} |
} |
|
|
Line 282 parentServerMain(int fdControl, int fdStream) { |
|
Line 327 parentServerMain(int fdControl, int fdStream) { |
|
extern OxTerminateMode; |
extern OxTerminateMode; |
extern void myServerExit(); |
extern void myServerExit(); |
|
|
|
signal(SIGCHLD,mywait); |
if (OxTerminateMode) { |
if (OxTerminateMode) { |
/* |
/* |
OxTerminateMode cannot be used if you run ox by xterm -exec ox ... |
OxTerminateMode cannot be used if you run ox by xterm -exec ox ... |
Line 438 static void couldNotFind(char *s) { |
|
Line 484 static void couldNotFind(char *s) { |
|
} |
} |
|
|
|
|
|
static void mywait() { |
|
int status; |
|
int pid; |
|
int i,j; |
|
/* signal(SIGCHLD,SIG_IGN); */ |
|
pid = wait(&status); |
|
fprintf(stderr,"Control: child process %d is exiting.\n",pid); |
|
fprintf(stderr,"Control: Shutting down the control server.\n"); |
|
sleep(2); |
|
exit(0); |
|
} |
|
|
|
|