예제 #1
0
void WINAPI QERApp_GetPoints(int nMax, _QERPointData *pData, LPCSTR pMsg)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  ShowInfoDialog(pMsg);
  g_bPlugWait = true;
  g_bPlugOK = false;
  g_nPlugCount = 0;
//  g_nPlugCount=nMax-1;
  AcquirePath(nMax, &_PlugDone);
  while (g_bPlugWait)
  {
    MSG msg;
    if (::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) 
    { 
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
  }
  HideInfoDialog();
  
  pData->m_nCount = 0;
  pData->m_pVectors = NULL;

  if (g_bPlugOK && g_nPlugCount > 0)
  {
    pData->m_nCount = g_nPlugCount;
    pData->m_pVectors = reinterpret_cast<vec3_t*>(qmalloc(g_nPlugCount * sizeof(vec3_t)));
    vec3_t *pOut = pData->m_pVectors;
    for (int i = 0; i < g_nPlugCount; i++)
    {
	memcpy(pOut, &g_PathPoints[i],sizeof(vec3_t));
	pOut++;
    }
  }
}
예제 #2
0
void ShowDeadl(XButtonEvent *ie)
{
    struct p_i_l_type *from;
    struct p_i_object *pip;
    int             first = TRUE;
    char            string[LINEMAX];
	
    if (figure_modified)
		ClearDeadl();
    if (p_invars == NULL)
	{
		ShowInfoDialog("Sorry, no up-to-date Deadlocks available",mainwin);
		return;
    }
    DehighlightDeadl();
    fix_x = event_x(ie) / zoom_level;
    fix_y = event_y(ie) / zoom_level;
    if ((cur_place = near_place_obj(fix_x, fix_y)) == NULL) 
	{
		StatusPrintf("");
		ShowShowDialog("");
		return;
    }
    for (from = p_invars = p_invars->next; first || (p_invars != from);
	 first = FALSE, p_invars = p_invars->next) {
		for (pip = p_invars->i_l; pip != NULL; pip = pip->next)
			if (pip->p_p == cur_place)
				goto found;
    }
    sprintf(string,"place %s is not contained in any minimal deadlock",cur_place->tag);
	StatusPrintf(string);
	ShowShowDialog(string);
    return;
	found:
		DisplayDeadl();
}
예제 #3
0
static LONG_PTR WINAPI InfoMenuProc(HANDLE hDlg,int Msg,int Param1,LONG_PTR Param2)
{
  InfoMenuData *DlgParams=(InfoMenuData *)Info.SendDlgMessage(hDlg,DM_GETDLGDATA,0,0);
  switch(Msg)
  {
    case DN_DRAGGED:
      return FALSE;
    case DN_CTLCOLORDIALOG:
      return Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_MENUTEXT);
    case DN_CTLCOLORDLGLIST:
      if(Param1==0)
      {
        FarListColors *Colors=(FarListColors *)Param2;
        int ColorIndex[]={COL_MENUTEXT,COL_MENUTEXT,COL_MENUTITLE,COL_MENUTEXT,COL_MENUHIGHLIGHT,COL_MENUTEXT,COL_MENUSELECTEDTEXT,COL_MENUSELECTEDHIGHLIGHT,COL_MENUSCROLLBAR,COL_MENUDISABLEDTEXT};
        int Count=sizeofa(ColorIndex);
        if(Count>Colors->ColorCount) Count=Colors->ColorCount;
        for(int i=0;i<Count;i++)
          Colors->Colors[i]=(BYTE)Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)(INT_PTR)(ColorIndex[i]));
        return TRUE;
      }
      break;
    case DN_INITDIALOG:
      {
        FarListTitles titles;
        titles.Title=(TCHAR *)GetMsg(mName);
        titles.TitleLen=(int)_tcslen(titles.Title);
        titles.Bottom=(TCHAR *)GetMsg(mInfoBottom);
        titles.BottomLen=(int)_tcslen(titles.Bottom);
        Info.SendDlgMessage(hDlg,DM_LISTSETTITLES,0,(LONG_PTR)&titles);
      }
      break;
    case DN_DRAWDIALOG:
      if(DlgParams->firsttime)
      {
        Info.SendDlgMessage(hDlg,DN_TIMER,0,0);
        Info.SendDlgMessage(hDlg,DN_TIMER,0,0);
      }
      break;
    case DN_TIMER:
      {
        HANDLE console=CreateFileW(L"CONOUT$",GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
        if(console!=INVALID_HANDLE_VALUE)
        {
          DWORD size,height=0,width=0,path_width,length; SmallInfoRec *receive;
          if(GetJobList(&size,&receive)||DlgParams->firsttime)
          {
            bool refresh=true;
            if(!DlgParams->forcerefresh)
            {
              if(DlgParams->count==size)
              {
                refresh=false;
                for(DWORD i=0;i<size;i++)
                  if(DlgParams->id[i].ThreadId!=receive[i].ThreadId)
                  {
                    refresh=true;
                    break;
                  }
              }
            }
            if(refresh)
            {
              DWORD old_pos=0; bool restore_pos=false;
              if(DlgParams->count)
              {
                DWORD pos=(DWORD)Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,0,(LONG_PTR)NULL);
                if(pos<DlgParams->count)
                {
                  old_pos=DlgParams->id[pos].ThreadId;
                  restore_pos=true;
                }
              }
              free(DlgParams->id);
              DlgParams->id=receive;
              DlgParams->count=size;
              Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
              for(DWORD i=0;i<size;i++)
              {
                length=(DWORD)wcslen(receive[i].Src);
                if(length>width) width=length;
              }
              width+=(DWORD)_tcslen(GetMsg(mInfoCopy));
              width+=(DWORD)(2*_tcslen(GetMsg(mInfoSep)))-1+4; // -1 for headers, 4 for percents
              length=(DWORD)_tcslen(GetMsg(mName));
              if(length>width) width=length;
              length=(DWORD)_tcslen(GetMsg(mInfoBottom));
              if(length>width) width=length;
              width+=12;
              height=size+4;
              { //normalize according console size
                COORD console_size={80,25};
#ifdef UNICODE
                SMALL_RECT console_rect;
                if(Info.AdvControl(Info.ModuleNumber,ACTL_GETFARRECT,(void*)&console_rect))
                {
                  console_size.X=console_rect.Right-console_rect.Left+1;
                  console_size.Y=console_rect.Bottom-console_rect.Top+1;
                }
#else
                CONSOLE_SCREEN_BUFFER_INFO console_info;
                if(GetConsoleScreenBufferInfo(console,&console_info))
                {
                  console_size=console_info.dwSize;
                }
#endif
                if(width>(DWORD)(console_size.X-4))
                  width=console_size.X-4;
                if(height>(DWORD)(console_size.Y-2))
                  height=console_size.Y-2;
              }
              //calculate path width
              path_width=WidthToPathWidth(width);
              { //minimize listbox
                SMALL_RECT listbox_size={3,1,4,2};
                Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,(LONG_PTR)&listbox_size);
              }
              { //resize and move dialog
                COORD dialog_size={(SHORT)width,(SHORT)height};
                Info.SendDlgMessage(hDlg,DM_RESIZEDIALOG,0,(LONG_PTR)&dialog_size);
                COORD position={-1,-1};
                Info.SendDlgMessage(hDlg,DM_MOVEDIALOG,TRUE,(LONG_PTR)&position);
              }
              { //resize listbox
                SMALL_RECT listbox_size={3,1,(SHORT)(width-4),(SHORT)(height-2)};
                Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,(LONG_PTR)&listbox_size);
              }
              { //refresh listbox
                FarListPos new_pos={0,-1};
                FarListDelete clear={0,0};
                FarListItem *list_items=(FarListItem *)malloc(sizeof(FarListItem)*size);
                FarList list={(int)size,list_items};
                if(list_items)
                {
                  Info.SendDlgMessage(hDlg,DM_LISTDELETE,0,(LONG_PTR)&clear);
                  for(DWORD i=0;i<size;i++)
                  {
                    UpdateItem(list_items+i,receive+i,path_width);
                    if(restore_pos&&receive[i].ThreadId==old_pos) new_pos.SelectPos=i;
                  }
                  Info.SendDlgMessage(hDlg,DM_LISTADD,0,(LONG_PTR)&list);
                  FreeItems(list_items,size);
                  free(list_items);
                  if(restore_pos) Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,0,(LONG_PTR)&new_pos);
                }
              }
              Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
              if(DlgParams->firsttime)
              {
                DlgParams->firsttime=false;
                if((PlgOpt.InfoMenu&INFO_MENU_ALT_1)&&(DlgParams->count==1))
                  Info.SendDlgMessage(hDlg,DM_CLOSE,-1,0);
              }
              else
              {
                DlgParams->forcerefresh=false;
                if((DlgParams->count==0)&&(!(PlgOpt.InfoMenu&INFO_MENU_ALT_0)))
                  Info.SendDlgMessage(hDlg,DM_CLOSE,-1,0);
              }
            }
            else
            {
              SMALL_RECT in;
              Info.SendDlgMessage(hDlg,DM_GETDLGRECT,0,(LONG_PTR)&in);
              path_width=WidthToPathWidth(in.Right-in.Left+1);
              for(DWORD i=0;i<size;i++)
              {
                if(receive[i].pause!=DlgParams->id[i].pause||receive[i].Ask!=DlgParams->id[i].Ask||receive[i].percent!=DlgParams->id[i].percent)
                {
                  FarListGetItem item;
                  item.ItemIndex=i;
                  Info.SendDlgMessage(hDlg,DM_LISTGETITEM,0,(LONG_PTR)&item);
                  UpdateItem(&(item.Item),receive+i,path_width);
                  Info.SendDlgMessage(hDlg,DM_LISTUPDATE,0,(LONG_PTR)&item);
                  FreeItems(&(item.Item),1);
                }
              }
              free(DlgParams->id);
              DlgParams->id=receive;
            }
          }
          CloseHandle(console);
        }
      }
      break;
    case DN_RESIZECONSOLE:
      DlgParams->forcerefresh=true;
      Info.SendDlgMessage(hDlg,DN_TIMER,0,0);
      break;
    case DN_CLOSE:
      {
        DWORD pos=(DWORD)Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,0,0);
        if((Param1==0)&&(DlgParams->id)&&(pos<DlgParams->count))
        {
          Info.SendDlgMessage(hDlg,DM_SHOWDIALOG,FALSE,0);
          SuspendThread(DlgParams->CommonData.Thread);
          ShowInfoDialog(DlgParams->id+pos);
          ResumeThread(DlgParams->CommonData.Thread);
          Info.SendDlgMessage(hDlg,DM_SHOWDIALOG,TRUE,0);
          Info.SendDlgMessage(hDlg,DN_ENTERIDLE,0,0);
          return FALSE;
        }
        else
          Redraw_Close(DlgParams->CommonData.Thread);
      }
      break;
  }
  return FastRedrawDefDlgProc(hDlg,Msg,Param1,Param2);
}
예제 #4
0
void WINAPI QERApp_InfoMsg(LPCSTR pMsg)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
  ShowInfoDialog(pMsg);
}
예제 #5
0
void CollectDeadl(int complain)
{
    FILE           *p_f;
    char            buf[LINEMAX], buf2[LINEMAX];
    struct p_i_object *pip;
    struct p_i_l_type *pil=NULL;
    int             i, j, np;
    struct place_object *plp;
	char string[300];
	
	strcpy(buf,GetCurrentFilename());
	strcpy(buf2,GetCurrentFilename());
	strcat(buf,".mdead");
	strcat(buf2,".net");
    {
		struct stat     stb, stb2;
		
		if ((stat(buf, &stb) < 0) || (stat(buf2, &stb2) < 0)
			|| (stb2.st_mtime > stb.st_mtime)) 
		{
			if (complain)
			{
				sprintf(string,"No up-to-date Deadlocks for net %s", GetCurrentFilename());
				ShowInfoDialog(string,frame_w);
			}
			return;
		}
    }
    if ((p_f = fopen(buf, "r")) == NULL) 
	{
		if (complain)
		{
			sprintf(string,"Can't open file %s for read", buf);
			ShowErrorDialog(string,frame_w);
		}
		return;
    }
    ClearDeadl();
    fscanf(p_f, "%d\n", &num_pinv);
    p_invars = NULL;
    if (num_pinv <= 0)
		return;
    for (i = num_pinv; i-- > 0;) 
	{
		if (p_invars == NULL)
			p_invars = pil = (struct p_i_l_type *) emalloc(sizeof(struct p_i_l_type));
		else {
			pil->next = (struct p_i_l_type *) emalloc(sizeof(struct p_i_l_type));
			pil = pil->next;
		}
		fscanf(p_f, "%d", &j);
		pil->i_l = pip = NULL;
		for (; j-- > 0;)
		{
			if (pip == NULL)
				pil->i_l = pip = (struct p_i_object *) emalloc(sizeof(struct p_i_object));
			else 
			{
				pip->next = (struct p_i_object *) emalloc(sizeof(struct p_i_object));
				pip = pip->next;
			}
			fscanf(p_f, "%d", &np);
			for (plp = netobj->places; --np > 0; plp = plp->next);
			pip->p_p = plp;
		}
		pip->next = NULL;
    }
    pil->next = p_invars;
    (void) fclose(p_f);
}
예제 #6
0
파일: protocol.c 프로젝트: authorNari/panda
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;
}