void SessionMain( ScreenData *scr) { Port *port; int fd; NETFILE *fp; ENTER_FUNC; port = ParPort(TermPort,PORT_WFC); fd = ConnectSocket(port,SOCK_STREAM); DestroyPort(port); if ( fd > 0 ){ fp = SocketToNet(fd); if (SendPanda(scr,fp)) { RecvPanda(scr,fp); CloseNet(fp); } else { scr->status = SCREEN_DATA_END; } } else { scr->status = SCREEN_DATA_END; } LEAVE_FUNC; }
extern void InitMessage(char *id, char *fn) { char *tempformat, *tempfn; #ifdef USE_MSGD int fd; Port *port; #endif #ifdef USE_SYSLOG static char buff[SIZE_LOG]; snprintf(buff, SIZE_LOG, "%s/%s", PACKAGE, id); openlog(buff, LOG_PID, syslog_facility); #endif if (fn == NULL) { tempfn = getenv("LOG_FILE_NAME"); if (tempfn != NULL) { fn = StrDup(tempfn); } } fpLog = NULL; Processid = StrDup(id); tempformat = getenv("LOG_DATA_FORMAT"); if (tempformat != NULL) { Format = StrDup(tempformat); } #ifdef USE_MSGD if (fn != NULL) { if (*fn == '@') { port = ParPort(fn + 1, PORT_MSGD); if ((fd = ConnectSocket(port, SOCK_STREAM)) >= 0) { fpLog = SocketToNet(fd); if (Format == NULL) { Format = "%F:%i:%f:%L:%B"; } } DestroyPort(port); } else { if ((fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0600)) >= 0) { fpLog = FileToNet(fd); } } } if (fpLog == NULL) { if (Format == NULL) { Format = "%Y/%M/%D/%h:%m:%s %F:%f:%L:%B"; } fpLog = FileToNet(STDOUT_FILENO); } #else if ((fn == NULL) || ((fpLog = fopen(fn, "w+")) == NULL)) { fpLog = stdout; } #endif if (Format == NULL) { Format = "%Y/%M/%D/%h:%m:%s %F:%f:%L:%B"; } MessageFunction = __Message; }
static NETFILE *ConnectBlobAPI(char *socketfile) { NETFILE *fp; Port *port; int fd; fp = NULL; port = ParPort(socketfile, NULL); fd = ConnectSocket(port, SOCK_STREAM); DestroyPort(port); if (fd > 0) { fp = SocketToNet(fd); } else { Error("cannot connect blob api"); } return fp; }
extern NETFILE * OpenPort( char *url, char *defport) { int fd; Port *port; NETFILE *fp; port = ParPort(url,defport); if ( ( fd = ConnectSocket(port,SOCK_STREAM) ) > 0 ) { fp = SocketToNet(fd); } else { fp = NULL; } DestroyPort(port); return (fp); }
void SessionExit( ScreenData *scr) { Port *port; int fd; NETFILE *fp; ENTER_FUNC; port = ParPort(TermPort,PORT_WFC); fd = ConnectSocket(port,SOCK_STREAM); DestroyPort(port); if ( fd > 0 ){ fp = SocketToNet(fd); SendTermServerEnd(fp,scr); } else { scr->status = SCREEN_DATA_NULL; } LEAVE_FUNC; }
extern void InitSystem( char *name) { struct sigaction sa; ENTER_FUNC; InitNET(); memset( &sa, 0, sizeof(struct sigaction) ); sa.sa_flags = 0; sa.sa_handler = SIG_IGN; sigemptyset (&sa.sa_mask); sigaction( SIGPIPE, &sa, NULL ); sa.sa_handler = StopSystem; sa.sa_flags |= SA_RESTART; sigemptyset (&sa.sa_mask); sigaction( SIGHUP, &sa, NULL ); InitDirectory(); SetUpDirectory(Directory, NULL, NULL, NULL, P_NONE); if ( ThisEnv == NULL ) { Error("DI file parse error."); } InitDB_Process("dbmaster"); CheckDBG(name); if ( PortNumber == NULL ) { DBMasterPort = ParPortName(PORT_MASTER); } else { DBMasterPort = ParPort(PortNumber, PORT_MASTER); } DBMasterServer = NewDBMasterThread(ThisDBG, AuthURL, DBMasterPort, Back); if (!DBMasterServer) { Error("start dbmaster thread failed"); } LEAVE_FUNC; }