extern size_t RequestReadBLOB( NETFILE *fp, MonObjectType obj, unsigned char **ret, size_t *size) { unsigned char *buff; size_t red; ENTER_FUNC; red = 0; *ret = NULL; RequestBLOB(fp,BLOB_READ); ON_IO_ERROR(fp,badio); SendObject(fp,obj); ON_IO_ERROR(fp,badio); if ( RecvPacketClass(fp) == BLOB_OK ) { *size = RecvLength(fp); ON_IO_ERROR(fp,badio); if ( *size > 0 ) { buff = xmalloc(*size); red = Recv(fp,buff,*size); *ret = buff; } } badio: LEAVE_FUNC; return (red); }
static SessionData * CheckSession( NETFILE *fp, char *term) { SessionData *data; ENTER_FUNC; if ((data = LookupSession(term)) != NULL) { if (!data->fInProcess) { SendPacketClass(fp,WFC_TRUE); ON_IO_ERROR(fp,badio); data->hdr->command = APL_COMMAND_GET; gettimeofday(&data->access_time,NULL); } else { Warning("Error: Other threads are processing it."); SendPacketClass(fp,WFC_FALSE); ON_IO_ERROR(fp,badio); data = NULL; } } else { Warning("session [%s] does not found",term); } LEAVE_FUNC; return data; badio: LEAVE_FUNC; Warning("CheckSession failure: io error"); return NULL; }
extern void PutDB_AuditLog( DBG_Struct *dbg, LargeByteString *lbs) { ENTER_FUNC; if ( dbg->fpLog != NULL ) { SendPacketClass(dbg->fpLog,RED_AUDIT); ON_IO_ERROR(dbg->fpLog,badio); SendLBS(dbg->fpLog,lbs); ON_IO_ERROR(dbg->fpLog,badio); } badio: LEAVE_FUNC; }
static Bool RecvSTATUS_Redirect( DBG_Struct *dbg) { int dbstatus; Bool rc = FALSE; if ( dbg->fpLog != NULL ) { SendPacketClass(dbg->fpLog, RED_STATUS); ON_IO_ERROR(dbg->fpLog,badio); dbstatus = RecvChar(dbg->fpLog); ON_IO_ERROR(dbg->fpLog,badio); ChangeDBStatus_Redirect(dbg, dbstatus); } rc = TRUE; badio: return rc; }
extern void BeginDB_Redirect( DBG_Struct *dbg) { ENTER_FUNC; if ( dbg->redirect == NULL ) return; if ( dbg->fpLog != NULL ) { SendPacketClass(dbg->fpLog,RED_BEGIN); ON_IO_ERROR(dbg->fpLog,badio); dbg->ticket_id = RecvInt(dbg->fpLog); if (dbg->ticket_id == 0 ) { Warning("Illegal ticket_id."); } } else { dbg->ticket_id = 0; } if ( dbg->redirectData != NULL ) { LBS_EmitStart(dbg->redirectData); LBS_EmitStart(dbg->checkData); } LEAVE_FUNC; return; badio: Warning("dbredirector connection is lost."); return; }
static Bool RequestBLOB( NETFILE *fp, PacketClass op) { Bool rc; ENTER_FUNC; rc = FALSE; SendPacketClass(fp,SYSDATA_BLOB); ON_IO_ERROR(fp,badio); SendPacketClass(fp,op); ON_IO_ERROR(fp,badio); rc = TRUE; badio: LEAVE_FUNC; return (rc); }
static void GetApplication(MessageHandler *handler, NETFILE *fp, ProcessNode *node) { int i; ConvFuncs *conv; conv = handler->serialize; LBS_EmitStart(iobuff); RecvLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); ConvSetRecName(handler->conv, node->mcprec->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->mcprec->value); if (node->linkrec != NULL) { ConvSetRecName(handler->conv, node->linkrec->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->linkrec->value); } if (node->sparec != NULL) { ConvSetRecName(handler->conv, node->sparec->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->sparec->value); } for (i = 0; i < node->cWindow; i++) { if (node->scrrec[i] != NULL) { ConvSetRecName(handler->conv, node->scrrec[i]->name); conv->UnPackValue(handler->conv, LBS_Body(iobuff), node->scrrec[i]->value); } } DumpNode(node); badio: return; }
PacketClass SYSDB_GetDataAll(NETFILE *fp, int *size, ValueStruct *vals) { PacketClass rc; LargeByteString *buf; rc = SESSION_CONTROL_NG; buf = NewLBS(); SendPacketClass(fp, SYSDATA_SYSDB); ON_IO_ERROR(fp, badio); SendPacketClass(fp, SYSDB_GET_DATA_ALL); ON_IO_ERROR(fp, badio); rc = RecvPacketClass(fp); *size = RecvInt(fp); RecvLBS(fp, buf); NativeUnPackValue(NULL, LBS_Body(buf), vals); badio: FreeLBS(buf); return rc; }
extern MonObjectType RequestNewBLOB( NETFILE *fp, int mode) { MonObjectType obj; ENTER_FUNC; obj = GL_OBJ_NULL; RequestBLOB(fp,BLOB_CREATE); ON_IO_ERROR(fp,badio); SendInt(fp,mode); ON_IO_ERROR(fp,badio); if ( RecvPacketClass(fp) == BLOB_OK ) { obj = RecvObject(fp); ON_IO_ERROR(fp,badio); } badio: LEAVE_FUNC; return (obj); }
extern Bool RequestDestroyBLOB( NETFILE *fp, MonObjectType obj) { Bool rc; ENTER_FUNC; rc = FALSE; RequestBLOB(fp,BLOB_DESTROY); ON_IO_ERROR(fp,badio); SendObject(fp,obj); ON_IO_ERROR(fp,badio); if ( RecvPacketClass(fp) == BLOB_OK ) { rc = TRUE; } badio: LEAVE_FUNC; return (rc); }
static Bool SendCommit_Redirect( DBG_Struct *dbg) { Bool rc = TRUE; if ( dbg->fpLog == NULL ) { return rc; } SendPacketClass(dbg->fpLog,RED_COMMIT); ON_IO_ERROR(dbg->fpLog,badio); SendInt(dbg->fpLog, dbg->ticket_id); ON_IO_ERROR(dbg->fpLog,badio); if ( RecvPacketClass(dbg->fpLog) != RED_OK ) { badio: rc = FALSE; Warning("Redirect Commit error (%d)", dbg->ticket_id); } return rc; }
extern void AbortDB_Redirect( DBG_Struct *dbg) { ENTER_FUNC; if ( dbg->redirect == NULL ) return; if ( dbg->fpLog != NULL ) { SendPacketClass(dbg->fpLog,RED_ABORT); ON_IO_ERROR(dbg->fpLog,badio); SendInt(dbg->fpLog, dbg->ticket_id); ON_IO_ERROR(dbg->fpLog,badio); } if ( dbg->redirectData != NULL ) { LBS_EmitStart(dbg->redirectData); LBS_EmitStart(dbg->checkData); } badio: LEAVE_FUNC; }
static Bool SendVeryfyData_Redirect( DBG_Struct *dbg) { Bool rc = FALSE; if ( (dbg->fpLog != NULL) && ( dbg->redirectData != NULL) && ( LBS_Size(dbg->redirectData) > 0 ) ) { LBS_EmitEnd(dbg->checkData); LBS_EmitEnd(dbg->redirectData); SendPacketClass(dbg->fpLog,RED_DATA); ON_IO_ERROR(dbg->fpLog,badio); SendInt(dbg->fpLog, dbg->ticket_id); ON_IO_ERROR(dbg->fpLog,badio); SendLBS(dbg->fpLog,dbg->checkData); ON_IO_ERROR(dbg->fpLog,badio); SendLBS(dbg->fpLog,dbg->redirectData); ON_IO_ERROR(dbg->fpLog,badio); } rc = SendCommit_Redirect(dbg); badio: return rc; }
static void RecvPanda( ScreenData *scr, NETFILE *fp) { char old_window[SIZE_NAME+1]; int i; ENTER_FUNC; strncpy(old_window,scr->window,SIZE_NAME); old_window[SIZE_NAME] = 0; if (RecvTermServerHeader(fp,scr)) { ON_IO_ERROR(fp,badio); if (scr->Windows != NULL) { g_hash_table_foreach(scr->Windows,(GHFunc)ClearPutType,NULL); } dbgprintf("type = [%d]",type); dbgprintf("ThisWindow [%s]",old_window); dbgprintf("window [%s]",scr->window); dbgprintf("user = [%s]",scr->user); for (i=0;i<scr->w.sp;i++) { if (scr->w.s[i].puttype == SCREEN_CLOSE_WINDOW) { RegisterWindow(scr,scr->w.s[i].window); PutWindow(scr,scr->w.s[i].window,SCREEN_CLOSE_WINDOW); scr->w.s[i].puttype = SCREEN_NULL; } } if (RegisterWindow(scr,scr->window) != NULL) { PutWindow(scr,scr->window,scr->puttype); RecvTermServerData(fp,scr); ON_IO_ERROR(fp,badio); } else { scr->status = SCREEN_DATA_NULL; /*glserver exit*/ } } else { Error("invalid LD; window = [%s]",scr->window); } LEAVE_FUNC; return; badio: Warning("badio"); exit(1); }
static PacketClass SYSDB_RequestCommon(NETFILE *fp, PacketClass pc, ValueStruct *val) { PacketClass rc; LargeByteString *buf; rc = SESSION_CONTROL_NG; buf = NewLBS(); LBS_ReserveSize(buf, NativeSizeValue(NULL, val), FALSE); NativePackValue(NULL, LBS_Body(buf), val); SendPacketClass(fp, SYSDATA_SYSDB); ON_IO_ERROR(fp, badio); SendPacketClass(fp, pc); ON_IO_ERROR(fp, badio); SendLBS(fp, buf); ON_IO_ERROR(fp, badio); rc = RecvPacketClass(fp); RecvLBS(fp, buf); NativeUnPackValue(NULL, LBS_Body(buf), val); badio: FreeLBS(buf); return rc; }
extern MonObjectType RequestImportBLOB( NETFILE *fp, char *fname) { MonObjectType obj; char buff[SIZE_BUFF]; FILE *fpf; struct stat sb; size_t size , left; ENTER_FUNC; obj = GL_OBJ_NULL; RequestBLOB(fp,BLOB_IMPORT); ON_IO_ERROR(fp,badio); if ( RecvPacketClass(fp) == BLOB_OK ) { obj = RecvObject(fp); ON_IO_ERROR(fp,badio); if ( ( fpf = fopen(fname,"r") ) != NULL ) { fstat(fileno(fpf),&sb); left = sb.st_size; SendLength(fp,left); Flush(fp); while ( left > 0 ) { size = ( left > SIZE_BUFF ) ? SIZE_BUFF : left; fread(buff,size,1,fpf); Send(fp,buff,size); ON_IO_ERROR(fp,badio); Flush(fp); left -= size; } fclose(fpf); } else { dbgprintf("could not open for read: %s", fname); SendLength(fp,0); Flush(fp); } } badio: LEAVE_FUNC; return (obj); }
extern Bool RequestExportBLOB( NETFILE *fp, MonObjectType obj, char *fname) { Bool rc; char buff[SIZE_BUFF]; FILE *fpf; size_t size , left; ENTER_FUNC; rc = FALSE; RequestBLOB(fp,BLOB_EXPORT); ON_IO_ERROR(fp,badio); SendObject(fp,obj); ON_IO_ERROR(fp,badio); if ( RecvPacketClass(fp) == BLOB_OK ) { if ( ( fpf = Fopen(fname,"w") ) != NULL ) { fchmod(fileno(fpf),0600); left = RecvLength(fp); while ( left > 0 ) { size = ( left > SIZE_BUFF ) ? SIZE_BUFF : left; Recv(fp,buff,size); ON_IO_ERROR(fp,badio); fwrite(buff,size,1,fpf); left -= size; } fclose(fpf); rc = TRUE; } else { Warning("could not open for write: %s", fname); } } badio: LEAVE_FUNC; return (rc); }
extern size_t RequestWriteBLOB( NETFILE *fp, MonObjectType obj, unsigned char *buff, size_t size) { size_t wrote; ENTER_FUNC; wrote = 0; RequestBLOB(fp,BLOB_WRITE); ON_IO_ERROR(fp,badio); SendObject(fp,obj); ON_IO_ERROR(fp,badio); if ( RecvPacketClass(fp) == BLOB_OK ) { SendLength(fp,size); ON_IO_ERROR(fp,badio); if ( size > 0 ) { Send(fp,buff,size); ON_IO_ERROR(fp,badio); wrote = RecvLength(fp); ON_IO_ERROR(fp,badio); } } badio: LEAVE_FUNC; return (wrote); }
extern Bool RequestAbortBLOB( NETFILE *fp) { Bool rc; ENTER_FUNC; rc = FALSE; RequestBLOB(fp,BLOB_ABORT); ON_IO_ERROR(fp,badio); if ( RecvPacketClass(fp) == BLOB_OK ) { rc = TRUE; } badio: LEAVE_FUNC; return (rc); }
static void APISession( TermNode *term) { SessionData *data; APIData *api; char ld[SIZE_NAME+1]; char window[SIZE_NAME+1]; char user[SIZE_USER+1]; char host[SIZE_HOST+1]; data = NULL; RecvnString(term->fp, sizeof(ld), ld); ON_IO_ERROR(term->fp,badio); RecvnString(term->fp, sizeof(window), window); ON_IO_ERROR(term->fp,badio); RecvnString(term->fp, sizeof(user), user); ON_IO_ERROR(term->fp,badio); RecvnString(term->fp, sizeof(host), host); ON_IO_ERROR(term->fp,badio); data = InitAPISession(user,ld,window,host); if (data != NULL) { data->term = term; data->retry = 0; api = data->apidata; RecvLBS(term->fp, api->rec); data = Process(data); api = data->apidata; SendPacketClass(term->fp, api->status); ON_IO_ERROR(term->fp,badio2); if (api->status == WFC_API_OK) { SendLBS(term->fp, api->rec); ON_IO_ERROR(term->fp,badio2); } CloseNet(term->fp); badio2: FreeSessionData(data); } else { SendPacketClass(term->fp,WFC_API_NOT_FOUND); ON_IO_ERROR(term->fp,badio2); CloseNet(term->fp); } badio: ; }
extern Bool CheckDB_Redirect( DBG_Struct *dbg) { Bool rc = TRUE; ENTER_FUNC; if ( dbg->redirect == NULL ) return rc; if ( dbg->redirectData != NULL ) { if ( dbg->fpLog != NULL ) { SendPacketClass(dbg->fpLog,RED_PING); ON_IO_ERROR(dbg->fpLog,badio); if ( RecvPacketClass(dbg->fpLog) != RED_PONG ) { badio: Warning("dbredirect server down?"); ChangeDBStatus_Redirect(dbg, DB_STATUS_REDFAILURE); CloseDB_RedirectPort(dbg); rc = FALSE; } } } LEAVE_FUNC; return (rc); }
static SessionData * ReadTerminal( NETFILE *fp, SessionData *data) { LD_Node *ld; Bool fExit; int c; LargeByteString *scrdata; int i; ENTER_FUNC; fExit = FALSE; while (!fExit) { switch (c = RecvPacketClass(fp)) { case WFC_DATA: dbgmsg("recv DATA"); if (data != NULL) { RecvnString(fp,SIZE_NAME,data->hdr->window); ON_IO_ERROR(fp,badio); RecvnString(fp,SIZE_NAME,data->hdr->widget); ON_IO_ERROR(fp,badio); RecvnString(fp,SIZE_NAME,data->hdr->event); ON_IO_ERROR(fp,badio); data->w.sp = RecvInt(fp); ON_IO_ERROR(fp,badio); for (i=0;i<data->w.sp ;i++) { data->w.s[i].puttype = RecvChar(fp); ON_IO_ERROR(fp,badio); RecvnString(fp,SIZE_NAME,data->w.s[i].window); ON_IO_ERROR(fp,badio); } dbgprintf("window = [%s]",data->hdr->window); dbgprintf("widget = [%s]",data->hdr->widget); dbgprintf("event = [%s]",data->hdr->event); ld = g_hash_table_lookup(ComponentHash,data->hdr->window); if (ld != NULL) { dbgprintf("ld = [%s]",ld->info->name); dbgprintf("window = [%s]",data->hdr->window); scrdata = GetScreenData(data,data->hdr->window); if (scrdata != NULL) { SendPacketClass(fp,WFC_OK); ON_IO_ERROR(fp,badio); dbgmsg("send OK"); if (RecvPacketClass(fp) == WFC_DATA) { RecvLBS(fp,scrdata);ON_IO_ERROR(fp,badio); } data->hdr->puttype = SCREEN_NULL; } else { Error("invalid window [%s]",data->hdr->window); } if (data->ld != ld) { ChangeLD(data,ld); } } else { Error("component [%s] not found.",data->hdr->window); fExit = TRUE; } } else { fExit = TRUE; } break; case WFC_OK: dbgmsg("OK"); fExit = TRUE; break; case WFC_END: dbgmsg("END"); if ((ld = g_hash_table_lookup(APS_Hash, "session")) != NULL) { strncpy(data->hdr->window,"session_end", sizeof(data->hdr->window)); data->hdr->widget[0] = 0; sprintf(data->hdr->event,"SESSIONEND"); data->hdr->puttype = SCREEN_NULL; ChangeLD(data,ld); data->status = SESSION_STATUS_END; } else { data->status = SESSION_STATUS_ABORT; } fExit = TRUE; break; default: Warning("Invalid PacketClass in ReadTerminal [%X]", c); SendPacketClass(fp,WFC_NOT);ON_IO_ERROR(fp,badio); fExit = TRUE; data->status = SESSION_STATUS_ABORT; break; } } badio: LEAVE_FUNC; return(data); }
static void PutApplication(MessageHandler *handler, NETFILE *fp, ProcessNode *node) { int i; size_t size; ConvFuncs *conv; DumpNode(node); conv = handler->serialize; ConvSetRecName(handler->conv, node->mcprec->name); size = conv->SizeValue(handler->conv, node->mcprec->value); LBS_EmitStart(iobuff); LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->mcprec->value); LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); Send(fp, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fp, badio); if (node->linkrec != NULL) { ConvSetRecName(handler->conv, node->linkrec->name); size = conv->SizeValue(handler->conv, node->linkrec->value); LBS_EmitStart(iobuff); LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->linkrec->value); LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); Send(fp, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fp, badio); } if (node->sparec != NULL) { ConvSetRecName(handler->conv, node->sparec->name); size = conv->SizeValue(handler->conv, node->sparec->value); LBS_EmitStart(iobuff); LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->sparec->value); LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); } for (i = 0; i < node->cWindow; i++) { LBS_EmitStart(iobuff); if (node->scrrec[i] != NULL) { ConvSetRecName(handler->conv, node->scrrec[i]->name); size = conv->SizeValue(handler->conv, node->scrrec[i]->value); if (size > 0) { Send(fp, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fp, badio); } LBS_ReserveSize(iobuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(iobuff), node->scrrec[i]->value); } LBS_EmitEnd(iobuff); SendLargeString(fp, iobuff); ON_IO_ERROR(fp, badio); } Send(fp, conv->bsep, strlen(conv->bsep)); ON_IO_ERROR(fp, badio); badio: return; }
static void ExecuteDB_Server(MessageHandler *handler) { RecordStruct *rec; ValueStruct *value, *ret; PathStruct *path; DB_Operation *op; size_t size; int rno, pno, ono; DBCOMM_CTRL ctrl; char *rname, *pname, *func; ConvFuncs *conv; InitializeCTRL(&ctrl); conv = handler->serialize; while (TRUE) { dbgmsg("read"); LBS_EmitStart(dbbuff); RecvLargeString(fpDBR, dbbuff); ON_IO_ERROR(fpDBR, badio); ConvSetRecName(handler->conv, recDBCTRL->name); InitializeValue(recDBCTRL->value); conv->UnPackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value); rname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "rname")); strncpy(ctrl.rname, rname, SIZE_NAME); value = NULL; ret = NULL; if ((rname != NULL) && ((rno = (int)(long)g_hash_table_lookup(DB_Table, rname)) != 0)) { ctrl.rno = rno - 1; rec = ThisDB[ctrl.rno]; value = rec->value; pname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "pname")); strncpy(ctrl.pname, pname, SIZE_NAME); if ((pno = (int)(long)g_hash_table_lookup(rec->opt.db->paths, pname)) != 0) { ctrl.pno = pno - 1; path = rec->opt.db->path[pno - 1]; value = (path->args != NULL) ? path->args : value; } else { ctrl.pno = 0; path = NULL; } } else { rec = NULL; path = NULL; } func = ValueStringPointer(GetItemLongName(recDBCTRL->value, "func")); if (*func != 0) { if (path == NULL) { Error("path is NULL"); } else if ((ono = (int)(long)g_hash_table_lookup(path->opHash, func)) != 0) { op = path->ops[ono - 1]; value = (op->args != NULL) ? op->args : value; } if (rec != NULL) { ConvSetRecName(handler->conv, rec->name); } else { Error("rec is NULL"); } InitializeValue(value); conv->UnPackValue(handler->conv, LBS_Body(dbbuff), value); strncpy(ctrl.func, func, SIZE_FUNC); ret = ExecDB_Process(&ctrl, rec, value); } else { ctrl.rc = 0; } dbgmsg("write"); SetValueInteger(GetItemLongName(recDBCTRL->value, "rc"), ctrl.rc); ConvSetRecName(handler->conv, recDBCTRL->name); LBS_EmitStart(dbbuff); size = conv->SizeValue(handler->conv, recDBCTRL->value); LBS_ReserveSize(dbbuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value); LBS_EmitEnd(dbbuff); SendLargeString(fpDBW, dbbuff); ON_IO_ERROR(fpDBW, badio); if (ret != NULL) { Send(fpDBW, conv->fsep, strlen(conv->fsep)); ON_IO_ERROR(fpDBW, badio); LBS_EmitStart(dbbuff); if (rec != NULL) { ConvSetRecName(handler->conv, rec->name); } size = conv->SizeValue(handler->conv, ret); LBS_ReserveSize(dbbuff, size, FALSE); conv->PackValue(handler->conv, LBS_Body(dbbuff), ret); LBS_EmitEnd(dbbuff); SendLargeString(fpDBW, dbbuff); ON_IO_ERROR(fpDBW, badio); FreeValueStruct(ret); } Send(fpDBW, conv->bsep, strlen(conv->bsep)); ON_IO_ERROR(fpDBW, badio); } badio: return; }
static gint PingTimerFunc(gpointer data) { NETFILE *fp = (NETFILE *)data; PacketClass c; char buff[CLIENT_SIZE_BUFF]; if (ISRECV(Session)) { return 1; } ISRECV(Session) = TRUE; fp = (NETFILE *)data; if (fV47) { GL_SendPacketClass(fp,GL_Ping);ON_IO_ERROR(fp,badio); c = GL_RecvPacketClass(fp);ON_IO_ERROR(fp,badio); switch (c) { case GL_Pong_Dialog: GL_RecvString(fp, sizeof(buff), buff);ON_IO_ERROR(fp,badio); ISRECV(Session) = FALSE; ShowInfoDialog(buff); break; case GL_Pong_Popup: GL_RecvString(fp, sizeof(buff), buff);ON_IO_ERROR(fp,badio); ISRECV(Session) = FALSE; Notify(_("glclient message notify"),buff,"gtk-dialog-info",0); break; case GL_Pong_Abort: GL_RecvString(fp, sizeof(buff), buff);ON_IO_ERROR(fp,badio); ShowInfoDialog(buff); exit(1); break; case GL_Pong: ISRECV(Session) = FALSE; break; default: ShowErrorDialog(_("connection error(invalid pong packet)")); break; } } else { GL_SendPacketClass(fp,GL_Ping);ON_IO_ERROR(fp,badio); c = GL_RecvPacketClass(fp);ON_IO_ERROR(fp,badio); if (c != GL_Pong) { ShowErrorDialog(_("connection error(server doesn't reply ping)")); return 1; } c = GL_RecvPacketClass(fp);ON_IO_ERROR(fp,badio); switch (c) { case GL_STOP: GL_RecvString(fp, sizeof(buff), buff);ON_IO_ERROR(fp,badio); ShowInfoDialog(buff); exit(1); break; case GL_CONTINUE: GL_RecvString(fp, sizeof(buff), buff);ON_IO_ERROR(fp,badio); ISRECV(Session) = FALSE; ShowInfoDialog(buff); break; case GL_END: default: ISRECV(Session) = FALSE; break; }; } ISRECV(Session) = FALSE; CheckPrintList(); CheckDLList(); return 1; badio: ShowErrorDialog(_("connection error(server doesn't reply ping)")); return 1; }
static void TermInit( TermNode *term) { SessionData *data; LD_Node *ld; int i; uuid_t u; ENTER_FUNC; data = NewSessionData(); data->term = term; data->fInProcess = TRUE; uuid_generate(u); uuid_unparse(u,data->hdr->uuid); if ((ld = g_hash_table_lookup(APS_Hash,ThisEnv->InitialLD)) == NULL) { Error("cannot find initial ld:%s.check directory",ThisEnv->InitialLD); } RecvnString(term->fp,SIZE_NAME,data->hdr->user);ON_IO_ERROR(term->fp,badio); RecvnString(term->fp,SIZE_HOST,data->host); ON_IO_ERROR(term->fp,badio); RecvnString(term->fp,SIZE_NAME,data->agent);ON_IO_ERROR(term->fp,badio); MessageLogPrintf("[%s:%s] session start",data->hdr->user,data->hdr->uuid); dbgprintf("uuid = [%s]",data->hdr->uuid); dbgprintf("user = [%s]",data->hdr->user); dbgprintf("host = [%s]",data->host); dbgprintf("agent = [%s]",data->agent); if (SesNum != 0 && GetSessionNum() >= SesNum) { Warning("Discard new session(%s);max session number(%d)",term,SesNum); SendPacketClass(term->fp,WFC_NOT); CloseNet(term->fp); return; } SendPacketClass(term->fp,WFC_OK); ON_IO_ERROR(term->fp,badio); SendString(term->fp,data->hdr->uuid); ON_IO_ERROR(term->fp,badio); data->ld = ld; data->linkdata = NewLinkData(); data->cWindow = ld->info->cWindow; data->scrdata = (LargeByteString **)xmalloc(sizeof(void*)*data->cWindow); for (i = 0 ; i < data->cWindow ; i ++) { if (data->ld->info->windows[i] != NULL) { dbgprintf("[%s]",data->ld->info->windows[i]->name); data->scrdata[i] = GetScreenData(data,data->ld->info->windows[i]->name); } else { data->scrdata[i] = NULL; } } data->hdr->puttype = SCREEN_NULL; RegisterSession(data); TermMain(term,data); CloseNet(term->fp); badio: LEAVE_FUNC; return; }
static Bool SendTerminal( NETFILE *fp, SessionData *data) { unsigned char c; char wname[SIZE_LONGNAME+1]; LargeByteString *scrdata; int i; ENTER_FUNC; SendPacketClass(fp,WFC_HEADER); ON_IO_ERROR(fp,badio); dbgmsg("send DATA"); SendString(fp,data->hdr->user); ON_IO_ERROR(fp,badio); SendString(fp,data->hdr->window); ON_IO_ERROR(fp,badio); SendString(fp,data->hdr->widget); ON_IO_ERROR(fp,badio); SendChar (fp,data->hdr->puttype); ON_IO_ERROR(fp,badio); dbgprintf("window = [%s]",data->hdr->window); SendInt(fp,data->w.sp); ON_IO_ERROR(fp,badio); for (i=0;i<data->w.sp;i++) { SendChar(fp,data->w.s[i].puttype);ON_IO_ERROR(fp,badio); SendString(fp,data->w.s[i].window);ON_IO_ERROR(fp,badio); } while (1) { c = RecvPacketClass(fp); ON_IO_ERROR(fp,badio); switch (c) { case WFC_DATA: dbgmsg(">DATA"); RecvnString(fp,SIZE_LONGNAME,wname);ON_IO_ERROR(fp,badio); if ((scrdata = GetScreenData(data,wname)) != NULL) { dbgmsg("send OK"); SendPacketClass(fp,WFC_OK); ON_IO_ERROR(fp,badio); SendLBS(fp,scrdata); ON_IO_ERROR(fp,badio); } else { dbgmsg("send NODATA"); SendPacketClass(fp,WFC_NODATA); ON_IO_ERROR(fp,badio); } dbgmsg("<DATA"); break; case WFC_DONE: dbgmsg("DONE"); return TRUE; case WFC_END: dbgmsg("END"); return FALSE; default: Warning("[%s] session failure packet [%X]",data->hdr->uuid,c); dbgprintf("c = [%X]\n",c); return FALSE; } } Warning("does not reach"); LEAVE_FUNC; return FALSE; badio: Warning("[%s] session recv failure",data->hdr->uuid); LEAVE_FUNC; return FALSE; }