Exemple #1
0
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;
}
Exemple #2
0
/*>GetScreenSizes(int *ScrHeight, int *ScrWidth)
   ---------------------------------------------
   This routine gets the screen sizes from the WorkBench and returns
   interlaced value if the WB was not interlaced.
   01.07.92 Original based on code from MoG.
*/
GetScreenSizes(int *ScrHeight,
               int *ScrWidth)
{
   struct Screen ScreenBuffer;
   
   GetScreenData(&ScreenBuffer,sizeof(struct Screen), WBENCHSCREEN, NULL);

   /* Get the height of the WB screen */
   *ScrHeight     = ScreenBuffer.Height;

   /* If it wasn't interlace, make it so */
   if(*ScrHeight < 300) (*ScrHeight) *= 2;
   
   /* Now get the width; V1.3 returns this as 0 */
   *ScrWidth = ScreenBuffer.Width;
   if(*ScrWidth == 0)   (*ScrWidth)   = 640;
   
   return(0);
}
Exemple #3
0
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;
}
Exemple #4
0
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);
}