Format source code
This commit is contained in:
parent
b6df536fe9
commit
d0be6165c0
165 changed files with 30306 additions and 33687 deletions
73
main.c
73
main.c
|
|
@ -46,76 +46,66 @@
|
|||
#include "const.h"
|
||||
#include "server.h"
|
||||
|
||||
extern int fork_flag;
|
||||
extern char *lock_file;
|
||||
extern int fork_flag;
|
||||
extern char* lock_file;
|
||||
|
||||
char *version_number = "2.08C";
|
||||
char *time_stamp = "Mon Mar 23 16:42:59 JST 1998";
|
||||
char* version_number = "2.08C";
|
||||
char* time_stamp = "Mon Mar 23 16:42:59 JST 1998";
|
||||
|
||||
static void
|
||||
opening(void)
|
||||
{
|
||||
opening(void) {
|
||||
printf("Kana-Kanji Conversion Server Version %s\r\n", version_number);
|
||||
printf("Copyright (c) 1990-1995 Sony Corporation\r\n");
|
||||
printf("Created at %s\r\n", time_stamp);
|
||||
}
|
||||
|
||||
#ifdef LOCK_FILE
|
||||
#ifdef LOCK_FILE
|
||||
|
||||
int
|
||||
make_lockfile(void)
|
||||
{
|
||||
int fd;
|
||||
int make_lockfile(void) {
|
||||
int fd;
|
||||
|
||||
fd = open(lock_file, O_CREAT | O_EXCL, 0600);
|
||||
if (fd < 0)
|
||||
if(fd < 0)
|
||||
return ERROR;
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
erase_lockfile(void)
|
||||
{
|
||||
int erase_lockfile(void) {
|
||||
return unlink(lock_file);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
signal_handler(int sig)
|
||||
{
|
||||
signal_handler(int sig) {
|
||||
warning_out("signal %d catched.", sig);
|
||||
}
|
||||
|
||||
static int
|
||||
terminate_handler(int sig)
|
||||
{
|
||||
terminate_handler(int sig) {
|
||||
close_socket();
|
||||
sj_closeall();
|
||||
#ifdef LOCK_FILE
|
||||
#ifdef LOCK_FILE
|
||||
erase_lockfile();
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
server_terminate(void)
|
||||
{
|
||||
void server_terminate(void) {
|
||||
close_socket();
|
||||
sj_closeall();
|
||||
#ifdef LOCK_FILE
|
||||
#ifdef LOCK_FILE
|
||||
erase_lockfile();
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
exec_fork(void)
|
||||
{
|
||||
int tmp;
|
||||
exec_fork(void) {
|
||||
int tmp;
|
||||
|
||||
if (fork_flag && (tmp = fork())) {
|
||||
if (tmp < 0) {
|
||||
if(fork_flag && (tmp = fork())) {
|
||||
if(tmp < 0) {
|
||||
fprintf(stderr, "Can't fork child process\r\n");
|
||||
fflush(stderr);
|
||||
} else {
|
||||
|
|
@ -135,14 +125,13 @@ exec_fork(void)
|
|||
signal(SIGINT, (void (*)())terminate_handler);
|
||||
signal(SIGQUIT, (void (*)())signal_handler);
|
||||
signal(SIGTERM, (void (*)())terminate_handler);
|
||||
if (fork_flag)
|
||||
if(fork_flag)
|
||||
signal(SIGTSTP, SIG_IGN);
|
||||
}
|
||||
|
||||
static void
|
||||
leave_tty(void)
|
||||
{
|
||||
int tmp;
|
||||
leave_tty(void) {
|
||||
int tmp;
|
||||
|
||||
tmp = open_error();
|
||||
tmp |= open_log();
|
||||
|
|
@ -150,23 +139,21 @@ leave_tty(void)
|
|||
kill(getppid(), SIGTERM);
|
||||
fclose(stdin);
|
||||
fclose(stdout);
|
||||
if (!tmp)
|
||||
if(!tmp)
|
||||
fclose(stderr);
|
||||
|
||||
if (fork_flag) {
|
||||
if ((tmp = open("/dev/tty", O_RDWR)) >= 0) {
|
||||
if(fork_flag) {
|
||||
if((tmp = open("/dev/tty", O_RDWR)) >= 0) {
|
||||
ioctl(tmp, TIOCNOTTY, 0);
|
||||
close(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char** argv) {
|
||||
opening();
|
||||
#ifndef __NetBSD__
|
||||
if (setuid(geteuid())) {
|
||||
if(setuid(geteuid())) {
|
||||
fprintf(stderr, "error at setuid.\r\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -176,8 +163,8 @@ main(int argc, char **argv)
|
|||
read_runcmd();
|
||||
set_default();
|
||||
|
||||
#ifdef LOCK_FILE
|
||||
if (make_lockfile() == ERROR) {
|
||||
#ifdef LOCK_FILE
|
||||
if(make_lockfile() == ERROR) {
|
||||
fprintf(stderr, "Already running...\r\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -196,7 +183,7 @@ main(int argc, char **argv)
|
|||
|
||||
close_socket();
|
||||
sj_closeall();
|
||||
#ifdef LOCK_FILE
|
||||
#ifdef LOCK_FILE
|
||||
erase_lockfile();
|
||||
#endif
|
||||
exit(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue