Exemple #1
0
/*
** physical_read: attempt to read 'num' physical blocks starting at physical
** block 'start' into st->buf. Fails if st->buf is not large enough, 
** suceeds otherwise (for now!) 
*/
PUBLIC bool_t physical_read(ext2fs_st *st, 
			    block_t    start, 
			    uint32_t   num,
			    char      *buf, 
			    uint32_t   buf_size)
{
    USD_Extent   extent;
    USDCtl_Error rc;
    uint32_t     readlen;
    
    readlen = num * st->disk.phys_block_size;

    /* Check we're initialised, and have enough space for the read */
    if(!st->disk.usdctl || (readlen > buf_size)) 
	return False;

    extent.base = start;
    extent.len  = num;
    TRC(printf("EXT2: %d,%d -> %p\n", start, num, buf));

    TRC(printf("[%d]\n", block));
    rc = USDCtl$Request(st->disk.usdctl, &extent, FileIO_Op_Read, buf);
    if (rc != USDCtl_Error_None) return False;

    return True;
}
void CUpdateDlg::DoUpdates()
{
	::ShowWindow(GetDlgItem(IDOK), SW_HIDE);
	::ShowWindow(GetDlgItem(IDC_UPDATEINFO), SW_HIDE);
	m_listView.DeleteAllItems();

	for (size_t i = 0; i < m_UpdateManager.m_updateList.size(); i++)
	{
		m_listView.AddItem(i, 0, m_UpdateManager.m_updateList[i].displayName());
		m_listView.AddItem(i, 1, TR("В очереди"));
	}
	m_listView.ShowWindow(SW_SHOW);
	m_UpdateManager.DoUpdates();

	if (m_UpdateManager.successPackageUpdatesCount())
	{
		::ShowWindow(GetDlgItem(IDCANCEL), SW_HIDE);
		::ShowWindow(GetDlgItem(IDOK), SW_SHOW);
		TRC(IDOK, "Завершить");
		m_bUpdateFinished = true;
	}
	else
	{
		::ShowWindow(GetDlgItem(IDCANCEL), SW_SHOW);
		::ShowWindow(GetDlgItem(IDOK), SW_HIDE);
		TRC(IDCANCEL, "Закрыть");
		m_bUpdateFinished = false;
	}
	m_Checked = false;
}
Exemple #3
0
/*
** At startup we create a physical heap; while this is fine, the idea
** of protection is closely tied to that of stretches. Hence this function
** maps a stretch over the existing heap.
** This allows us to map it read/write for us, and read-only to everyone else.
*/
void MapInitialHeap(HeapMod_clp hmod, Heap_clp heap, 
		    word_t heap_size, ProtectionDomain_ID pdom)
{
    Stretch_clp str;
    Heap_clp realheap; 
    addr_t a = (addr_t)((size_t)heap & ~(PAGE_SIZE-1));

    TRC(eprintf(" + Mapping stretch over heap: 0x%x bytes at %p\n", 
	    heap_size, a));
    str = StretchAllocatorF$NewOver((StretchAllocatorF_cl *)Pvs(salloc), 
				    heap_size, AXS_R, a, 0, 
				    PAGE_WIDTH, NULL);
    ASSERT_ADDRESS(str, a);
    TRC(eprintf(" + Done!\n"));

    realheap = HeapMod$Realize(hmod, heap, str);

    if(realheap != heap) 
	eprintf("WARNING: HeapMod$Realize(%p) => %p\n", 
		heap, realheap);


    /* Map our heap as local read/write */
    STR_SETPROT(str, pdom, (SET_ELEM(Stretch_Right_Read)|
			    SET_ELEM(Stretch_Right_Write)));
}
LRESULT CNewFolderDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	TRC(IDC_FOLDERNAMELABEL, "Название папки/альбома:");
	TRC(IDC_FOLDERDESCRLABEL, "Описание:");
	TRC(IDC_ACCESSTYPELABEL, "Доступ:");
	TRC(IDCANCEL, "Отмена");
	TRC(IDOK, "OK");
	
	
	DlgResize_Init();
	CenterWindow(GetParent());
	if(m_bCreateNewFolder)
		SetWindowText(TR("Новая папка (альбом)"));
	else
		SetWindowText(TR("Редактирование папки"));
	SetDlgItemText(IDC_FOLDERTITLEEDIT, Utf8ToWCstring(m_folder.title));
	CString text = Utf8ToWCstring(m_folder.summary);
	text.Replace(_T("\r"), _T(""));
	text.Replace(_T("\n"), _T("\r\n"));
	SetDlgItemText(IDC_FOLDERDESCREDIT, text);
	for(size_t i=0; i< m_accessTypeList.size(); i++)
	{
		SendDlgItemMessage(IDC_ACCESSTYPECOMBO, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)Utf8ToWCstring(m_accessTypeList[i].c_str()));
	}
	SendDlgItemMessage(IDC_ACCESSTYPECOMBO, CB_SETCURSEL, m_folder.accessType);
	
	::SetFocus(GetDlgItem(IDC_FOLDERTITLEEDIT));
	return 0;  // Let the system set the focus
}
Exemple #5
0
static bool_t Login_Validate_m (
    Login_cl        *self,
    string_t        certificate,
    Domain_ID       domain )
{
    Login_st      *st = self->st;
    UnixLoginMod_st   *lst = st->lst;

    Certificate *c;

    MU_LOCK(&lst->mu);

    /* Find the certificate */
    if (!StringTbl$Get(lst->certificate_tbl, certificate, (void *)&c)) {
	MU_RELEASE(&lst->mu);
	TRC(printf("Login_Validate: unknown certificate %s\n",certificate));
	return False; /* Not a valid certificate */
    }

    /* Check the certificate */
    if (!Security$CheckTag(lst->sec, c->tag, domain)) {
	MU_RELEASE(&lst->mu);
	TRC(printf("Login_Validate: certificate %s (%s) may not be used by"
		   "domain %qx\n",certificate, c->u->username, domain));
	return False; /* Domain does not own certificate */
    }

    MU_RELEASE(&lst->mu);

    return True; /* Certificate is valid for domain to use */
}
Exemple #6
0
static void ModData_Register_m (
        ModData_cl      *self,
        string_t        name    /* IN */,
        word_t  offset  /* IN */ )
{
    mod_data_rec *m;
    mod_data_entry *e;

    TRC(fprintf(stderr, "ModData: Adding module %s, address %p\n", name, 
		offset));
    
    if (!INFO_PAGE.mod_data) {
	eprintf("ModData: no module data rec\n");
	return;
    }

    m = INFO_PAGE.mod_data;

    if (m->max_entries == m->num_entries) {

	TRC(fprintf(stderr, "ModData: Expanding data area\n"));

	m->max_entries += 10;
	
	m->entries = Heap$Realloc(Pvs(heap), 
				  m->entries, 
				  m->max_entries * sizeof(*m->entries));

    }
    
    e = &m->entries[m->num_entries++];

    e->name = strdup(name);
    e->offset = offset;
}
Exemple #7
0
	void Start() override {
		if (!RpcUrl.get_Port())
			RpcUrl = Uri("http://127.0.0.1:" + Convert::ToString(GetFreePort()));
		else {
			try {
				DBG_LOCAL_IGNORE_CONDITION(errc::connection_refused);

				Call("getinfo");			

				if (!PathDaemon.empty()) {
					try {
						vector<Process> ps = Process::GetProcessesByName(PathDaemon.stem().c_str());	//!!! incorrect process can be selected and then terminated
						if (!ps.empty())
							m_process = ps.back();
					} catch (RCExc) {
					}
				}
				return;
			} catch (system_error& DBG_PARAM(ex)) {
				TRC(1, ex.code() << " " << ex.what());
			}
		}

		if (PathDaemon.empty()) {
			LOG("Currency daemon for " << Name << " is unavailable");
			return;
		}
		if (m_process) {
			if (!m_process.HasExited)
				return;
			TRC(2, "Process " << m_process.get_ID() << " exited with code " << m_process.get_ExitCode());
		}
		
		String exeFilePath = System.get_ExeFilePath();
		ostringstream os;
		create_directories(DataDir);
		Listen ? (os << " -port=" << GetFreePort()) : (os << " -listen=0");
		os << " -rpcport=" << RpcUrl.get_Port()
			<< " -rpcallowip=127.0.0.1"
			<< " -rpcuser="******" -rpcpassword="******" -daemon"
			<< " -server"
			<< (IsTestNet ? " -testnet" : "")
			<< " -datadir=\"" << DataDir << "\"";
		if (EnableNotifications) {
			os << " -blocknotify=\"" << exeFilePath << " " << EpApi << " blocknotify " << Name << " %s\""
			<< " -alertnotify=\"" << exeFilePath << " " << EpApi << " alertnotify " << Name << " %s\"";		
			if (WalletNotifications)
				os << " -walletnotify=\"" << exeFilePath << " " << EpApi <<  " walletnotify " << Name << " %s\"";
		}
		if (!Args.empty())
			os << " " << Args;
		ProcessStartInfo psi;
		psi.Arguments = os.str();
		psi.FileName = PathDaemon;
		psi.EnvironmentVariables["ComSpec"] = exeFilePath;										// to avoid console window
		m_process = Process::Start(psi);
	}
Exemple #8
0
static void IDCCallback_Closed_m (
	IDCCallback_cl	       *self,
	IDCOffer_clp	        offer	/* IN */,
	IDCServerBinding_clp	binding /* IN */,
	const Type_Any	       *server  /* IN */ )
{
    ext2fs_st *st=self->st; 
    Client_st *c=NULL, *head;
    int i;


    /* A client has gone away. We have to close all of their files,
       remove their stream from the USD, and delete all of the state
       associated with them. */

    /* set head to the start of the client list */
    head= (&st->client.clients)->next;

    /* search through the list to find the current client */
    for (c=head; c!=(&st->client.clients); c=c->next)
	{
	    if (c->binding==binding)
		{	
		    TRC(printf("ext2fs: disconnecting client %p\n", c));

		    TRC(printf("ext2fs: closing client's files\n"));

		    /* attempt to close the client's files (Ext2$Free
                       checks whether a handle is valid or not) */
		    for (i=0; i<MAX_CLIENT_HANDLES; i++)
			{
			    Ext2$Free(&(c->cl), (Ext2_Handle)i, True);
			}
		    
		    /* destroy client's stream to the USD */
		    TRC(printf("ext2fs: deleting client's stream from USD\n"));
		    if ( USDCtl$DestroyStream(st->disk.usdctl, c->usd_stream) != USDCtl_Error_None)
			printf("ext2fs: error deleting stream from USD\n");

		    /* remove client from client list */
		    LINK_REMOVE(c);
		    /* free client's state */
		    FREE(c);
		    
			   
		    TRC(printf("ext2fs: finished deleting stream\n"));
		    
		    return;	
		}
	    
		   
		
	}
    
	
    printf("ext2fs: a client has disconnected. Couldn't find it's binding though. Oh dear.\n");
    
    printf("ext2fs: a client has disconnected. Oh dear.\n");
}
Exemple #9
0
static bool_t Login_Login_m (
    Login_cl        *self,
    Security_Tag   tag    /* IN */,
    string_t        username        /* IN */,
    string_t        password        /* IN */
    /* RETURNS */,
    string_t        *certificate )
{
    Login_st      *st = self->st;
    UnixLoginMod_st   *lst = st->lst;

    User *u;
    Certificate *c;

    /* Check that caller owns the tag */
    if (!Security$CheckTag(lst->sec, tag, st->id)) {
	TRC(printf("Login: domain %qx doesn't have tag %qx\n",st->id,tag));
	*certificate=strduph("invalid", lst->heap);
	return False; /* Bad tag */
    }

    /* Lookup username */
    if (!StringTbl$Get(lst->users, username, (void *)&u)) {
	*certificate=strduph("invalid", lst->heap);
	TRC(printf("Login: domain %qx tried to login with unknown "
		   "username %s\n",st->id,username));
	return False; /* Bad username */
    }

    /* XXX Check password; skip for now */

    /* Proceed: generate a new certificate */
    c=Heap$Malloc(lst->heap, sizeof(*c));
    if (!c) {
	TRC(printf("Login: out of memory\n"));
	return False; /* Out of memory */
    }

    MU_LOCK(&lst->mu);
    c->tag=tag;
    c->u=u;
    c->cert=Heap$Malloc(lst->heap, 18+strlen(username));
    sprintf(c->cert, "%s:%x", username, lst->certificate_id++);

    LINK_ADD_TO_HEAD(&lst->certificate_list, c);
    StringTbl$Put(lst->certificate_tbl, c->cert, c);

    MU_RELEASE(&lst->mu);

    *certificate=strduph(c->cert, lst->heap);

    TRC(printf("Login: user %s logged in; issued certificate %s\n"
	       "       bound to tag %qx\n",c->u->username,c->cert,tag));

    return True; /* User logged on */
}
Exemple #10
0
/*
 * Returns 1, 0 or -1
 * In nonblocking mode, you must call again with same buffer while
 * return value is 1.
 */
static int unix_put(COMSTACK h, char *buf, int size)
{
    int res;
    struct unix_state *state = (struct unix_state *)h->cprivate;

    TRC(fprintf(stderr, "unix_put: size=%d\n", size));
    h->io_pending = 0;
    h->event = CS_DATA;
    if (state->towrite < 0)
    {
        state->towrite = size;
        state->written = 0;
    }
    else if (state->towrite != size)
    {
        h->cerrno = CSWRONGBUF;
        return -1;
    }
    while (state->towrite > state->written)
    {
        if ((res =
             send(h->iofile, buf + state->written, size -
                  state->written,
#ifdef MSG_NOSIGNAL
                  MSG_NOSIGNAL
#else
                  0
#endif
                 )) < 0)
        {
            if (
                yaz_errno() == EWOULDBLOCK
#ifdef EAGAIN
#if EAGAIN != EWOULDBLOCK
                || yaz_errno() == EAGAIN
#endif
#endif
                )
            {
                TRC(fprintf(stderr, "  Flow control stop\n"));
                h->io_pending = CS_WANT_WRITE;
                return 1;
            }
            h->cerrno = CSYSERR;
            return -1;
        }
        state->written += res;
        TRC(fprintf(stderr, "  Wrote %d, written=%d, nbytes=%d\n",
                    res, state->written, size));
    }
    state->towrite = state->written = -1;
    TRC(fprintf(stderr, "  Ok\n"));
    return 0;
}
Exemple #11
0
static void MuxDispatch_m(IDCServerStubs_clp self)
{
    MuxServer_t          *st     = self->st;
    ShmConnection_t      *conn   = st->conn;
    word_t               *id;

   /* If it's been smoked, then let dispatch return happily */
    if(DCB_EPRW(RO(Pvs(vp)), conn->eps.tx)->state == Channel_State_Dead)
	return;

    while(conn->call < VP$Poll (Pvs(vp), conn->eps.rx)) {

	/* Unmarshall the binding id (first in the buf)  */
	id = conn->rxbuf.base;    

	/* Frob the rxbuf so that the servers underneath us are happy. 
	   We will frob them back when we leave. */
	conn->rxbuf.base += sizeof(*id);  
	conn->rxsize     -= sizeof(*id);  
	conn->rxbuf.space = conn->rxsize; 
	
	/* We hijack the rx event count as marker so that the 
	   ServerBinding knows it is being called from the 
	   muxed dispatcher (rather than via the while {..} 
	   in the Dispatch method of the stubs. */
	conn->evs.rx      = NULL_EVENT;

	TRC(eprintf("call=%x, rx ep is %x (current val is %x).\n", 
		     conn->call, conn->eps.rx, 
		     VP$Poll(Pvs(vp), conn->eps.rx)));

	if(*id >= st->nstubs) {
	    eprintf("Critical Error: got binding_id as %d (nstubs is %d)!\n", 
		    *id, st->nstubs);
	    ntsc_dbgstop();
	}
	
	TRC(eprintf("=> server stubs are at %p\n", st->stubs[binding_id]));
	TRC(eprintf("=> op = %p, st = %p, op->Dispatch = %p\n", 
		     st->stubs[*id]->op, 
		     st->stubs[*id]->st, 
		     st->stubs[*id]->op->Dispatch));
	IDCServerStubs$Dispatch(st->stubs[*id]);
	TRC(eprintf("done dispatch!\n"));

	/* Now we frob the rxbuf back again */
	conn->rxbuf.base  -= sizeof(*id);  
	conn->rxsize      += sizeof(*id);  
	conn->rxbuf.space = conn->rxsize; 
    } 

    return;
}
void CUpdateDlg::CheckUpdates()
{
	m_listView.ShowWindow(SW_HIDE);
	::ShowWindow(GetDlgItem(IDC_UPDATEINFO), SW_SHOW);
	m_Checked = true;

	SetDlgItemText(IDC_UPDATEINFO, TR("Проверка обновлений..."));
	if (!m_UpdateManager.CheckUpdates())
	{
		TRC(IDCANCEL, "Закрыть");
		m_Checked = false;
		CString errorStr = TR("Ошибка при получении данных об обновлениях.");
		errorStr += "\r\n";
		errorStr += m_UpdateManager.ErrorString();
		SetDlgItemText(IDC_UPDATEINFO, errorStr);
		return;
	}

	Settings.LastUpdateTime = static_cast<int>(time(0));
	if (m_UpdateManager.AreUpdatesAvailable())
	{
		if ( !m_UpdateManager.AreCoreUpdates() ) {
			DoUpdates();
			return;
		}
		if (CmdLine.IsOption(_T("update")))
		{
			DoUpdates();
			return;
		}

		::ShowWindow(GetDlgItem(IDOK), SW_SHOW);
		TRC(IDOK, "Обновить");
		if (m_UpdateCallback)
			m_UpdateCallback->UpdateAvailabilityChanged(true);

		if (ShouldStop())
			return;

		if (!IsWindowVisible())
			SetTimer(2, 2000, 0);

		CString text = m_UpdateManager.generateReport();
		SetDlgItemText(IDC_UPDATEINFO, text);
		return;
	}
	else
	{
		TRC(IDCANCEL, "Закрыть");
		SetDlgItemText(IDC_UPDATEINFO, TR("Обновление не требуется."));
	}
}
LRESULT CTraySettingsPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	TRC(IDC_SHOWTRAYICON,"Показывать значок в трее");
	TRC(IDC_MOUSEREACTIONGROUP,"Реакция на действия мыши");
	TRC(IDC_LEFTBUTTONDOUBLECLICKLABEL,"Двойной клик левой кнопкой");
	TRC(IDC_LEFTBUTTONCLICKLABEL,"Одиночный клик левой кнопкой");
	TRC(IDC_MIDDLEBUTTONCLICKLABEL,"Клик средней кнопкой");
	TRC(IDC_RIGHTBUTTONCLICKLABEL,"Клик правой кнопкой");
	TRC(IDC_ONEINSTANCE,"Не запускать новые копии программы из трея");
	TRC(IDC_AUTOSTARTUP, "Запуск программы при старте Windows");
	//CTrayActions trayActions;
	for(size_t i=0; i< Settings.Hotkeys/*trayActions*/.size(); i++)
	{
		SendDlgItemMessage(IDC_LEFTBUTTONDOUBLECLICKCOMBO, CB_ADDSTRING,0, (LPARAM)(LPCTSTR)Settings.Hotkeys[i].GetDisplayName());
		SendDlgItemMessage(IDC_LEFTBUTTONCLICKCOMBO, CB_ADDSTRING,0, (LPARAM)(LPCTSTR)Settings.Hotkeys[i].GetDisplayName());
		SendDlgItemMessage(IDC_MIDDLEBUTTONCLICKCOMBO, CB_ADDSTRING,0, (LPARAM)(LPCTSTR)Settings.Hotkeys[i].GetDisplayName());
	
		SendDlgItemMessage(IDC_RIGHTBUTTONCLICKCOMBO, CB_ADDSTRING,0, (LPARAM)(LPCTSTR)Settings.Hotkeys[i].GetDisplayName());
	
	}

	SendDlgItemMessage(IDC_SHOWTRAYICON, BM_SETCHECK,Settings.ShowTrayIcon);
	SendDlgItemMessage(IDC_AUTOSTARTUP, BM_SETCHECK,Settings.AutoStartup);

	SendDlgItemMessage(IDC_ONEINSTANCE, BM_SETCHECK,Settings.TrayIconSettings.DontLaunchCopy);
	OnShowTrayIconBnClicked(BN_CLICKED, IDC_SHOWTRAYICON, 0);

	SendDlgItemMessage(IDC_LEFTBUTTONDOUBLECLICKCOMBO, CB_SETCURSEL,Settings.TrayIconSettings.LeftDoubleClickCommand);
	SendDlgItemMessage(IDC_LEFTBUTTONCLICKCOMBO, CB_SETCURSEL,Settings.TrayIconSettings.LeftClickCommand);
	SendDlgItemMessage(IDC_MIDDLEBUTTONCLICKCOMBO, CB_SETCURSEL,Settings.TrayIconSettings.MiddleClickCommand);
	SendDlgItemMessage(IDC_RIGHTBUTTONCLICKCOMBO, CB_SETCURSEL,Settings.TrayIconSettings.RightClickCommand);
	
	return 1;  // Let the system set the focus
}
Exemple #14
0
bool ServiceBase::OnCommand(DWORD dwControl, DWORD dwEventType, void *lpEventData) {
	TRC(2, ServiceName << ": " << ServiceControlToString(dwControl));

	switch (dwControl) {
	case SERVICE_CONTROL_STOP:
		Stop();
		break;
	case SERVICE_CONTROL_SHUTDOWN:
		Status = SERVICE_STOP_PENDING;
		OnShutdown();
		break;
	case SERVICE_CONTROL_PAUSE:
		Status = SERVICE_PAUSE_PENDING;
		OnPause();
		break;
	case SERVICE_CONTROL_CONTINUE:
		Status = SERVICE_CONTINUE_PENDING;
		OnContinue();
		break;
	case SERVICE_CONTROL_INTERROGATE:
		Status = m_status;
		break;
	case SERVICE_CONTROL_POWEREVENT:
		OnPowerEvent((PowerBroadcastStatus)dwEventType);
		break;
	case SERVICE_CONTROL_SESSIONCHANGE:
		{
			SessionChangeDescription scd = { (SessionChangeReason)dwEventType, (int)((WTSSESSION_NOTIFICATION*)lpEventData)->dwSessionId };
			TRC(2, ReasonToString(scd.Reason));
			OnSessionChange(scd);
		}
		break;
	case SERVICE_CONTROL_PARAMCHANGE:
		OnParamChange();
		break;
	case SERVICE_CONTROL_TIMECHANGE:
		OnTimeChange();
		break;
	case SERVICE_CONTROL_HARDWAREPROFILECHANGE:
		OnHardwareProfileChange();
		break;
	default:
		if (dwControl >= 128 && dwControl <= 255)
			OnCustomCommand(dwControl);
		else
			return false;
	}
	return true;
}
Exemple #15
0
/*
 * This routine is called by the domain manager to complete initialisation
 * of the first domain.
 */
void Binder_Done(DomainMgr_st *dm_st)
{
    PerDomain_st *bst = ROP_TO_PDS(dm_st->dm_dom);
    Closure_clp cl;

    bst->callback = dm_st->bcb;
    TRC(eprintf ("Binder_Done: bst=%x callback=%x.\n", bst, bst->callback));
    cl = Entry$Closure (Pvs(entry));
    Threads$Fork (Pvs(thds), cl->op->Apply, cl, 0);
    Threads$Fork (Pvs(thds), cl->op->Apply, cl, 0);
#if 0
    Threads$Fork (Pvs(thds), cl->op->Apply, cl, 0);
#endif /* 0 */
    TRC(eprintf ("Binder_Done: forked server thread\n"));
}
Exemple #16
0
int sub_image (imageptr iptr, regionptr rptr, imageptr *optr)
{
  int nx,ny,nz, nx1,ny1,nz1, ix,iy,iz, ix0,iy0,iz0;
  size_t np, np1;

  nx  = Nx(iptr);
  ny  = Ny(iptr);
  nz  = Nz(iptr);
  np = nx*ny*nz;
  /* grab the bounding box */
  ix0 = BLC(rptr)[0];
  iy0 = BLC(rptr)[1];
  iz0 = BLC(rptr)[2];
  nx1 = TRC(rptr)[0] - ix0;
  ny1 = TRC(rptr)[1] - iy0;
  nz1 = TRC(rptr)[2] - iz0;
  np1 = nx1*ny1*nz1;

  *optr = (imageptr ) allocate(sizeof(image));
  dprintf (DLEV,"copy_image:Allocated image @ %d size=%d * %d * %d",*optr,nx1,ny1,nz1);
    	
  Frame(*optr) = (real *) allocate(np1*sizeof(real));	
  dprintf (DLEV,"Frame allocated @ %d ",Frame(*optr));
  Nx(*optr) = nx1;
  Ny(*optr) = ny1;
  Nz(*optr) = nz1;
  Xmin(*optr) = Xmin(iptr) + ix0*Dx(iptr);
  Ymin(*optr) = Ymin(iptr) + iy0*Dy(iptr);
  Zmin(*optr) = Zmin(iptr) + iz0*Dz(iptr);
  Dx(*optr) = Dx(iptr);
  Dy(*optr) = Dy(iptr);
  Dz(*optr) = Dz(iptr);
  Namex(*optr) = mystrcpy(Namex(iptr));
  Namey(*optr) = mystrcpy(Namey(iptr));
  Namez(*optr) = mystrcpy(Namez(iptr));
  Xref(*optr) = Xref(iptr) + ix0;
  Yref(*optr) = Yref(iptr) + iy0;
  Zref(*optr) = Zref(iptr) + iz0;
  for (iz=0; iz<nz1; iz++)
    for (iy=0; iy<ny1; iy++)
      for (ix=0; ix<nx1; ix++)
	CubeValue(*optr,ix,iy,iz) = CubeValue(iptr,ix-ix0,iy-iy0,iz-iy0);
  Storage(*optr) = matdef[idef];
  Axis(*optr) = Axis(iptr);
  set_iarray(*optr);
  
  return 1;		/* succes return code  */
}
Exemple #17
0
LIBUDEV_EXPORT void
udev_unref(struct udev *udev)
{

	TRC("(%p) refcount=%d", udev, udev->refcount);
	_udev_unref(udev);
}
Exemple #18
0
void
video_play(mvp_widget_t *widget)
{
	demux_attr_t *attr;
	video_info_t *vi;
	TRC("%s\n", __FUNCTION__);
	mvpw_set_idle(NULL);

	if (demux_spu_get_id(handle) < 0)
		mvpw_set_timer(root, video_subtitle_check, 1000);
	else
		mvpw_set_timer(root, video_subtitle_display, 250);

	video_set_root();

	av_set_tv_aspect(config->av_tv_aspect);
	attr = demux_get_attr(handle);
	vi = &attr->video.stats.info.video;
	video_change_aspect(vi->aspect,vi->afd);
	/*Force video demux code to detect and trigger an aspect event for any
	 *new AFD or aspect ratio: */
	vi->aspect = -1;
	vi->afd = -1;
	paused = 0;
	video_reopen = 1;
	video_playing = 1;
	pthread_cond_broadcast(&video_cond);
}
Exemple #19
0
static bool_t IDCCallback_Bound_m (
	IDCCallback_cl	       *self,
	IDCOffer_clp	        offer	/* IN */,
	IDCServerBinding_clp	binding /* IN */,
	Domain_ID	        dom	/* IN */,
	ProtectionDomain_ID	pdid	/* IN */,
	const Binder_Cookies   *clt_cks	/* IN */,
	Type_Any	       *server  /* INOUT */ )
{
    ext2fs_st *st = self->st;
    Client_st *c;

    /* A client has finished binding. We need to invent a server. */
    TRC(printf("ext2fs: accepted connection from dom %qx\n",dom));

    c=Heap$Malloc(st->heap, sizeof(*c));
    if (!c) {
	printf("ext2fs: out of memory while accepting connection from %qx\n",
	       dom);
	return False;
    }

    if (!create_client(st,c,binding)) {
	printf("ext2fs: aargh, client create failed. Rejecting connection.\n");
	FREE(c);
	return False;
    }

    /* XXX: concurrency? */
    LINK_ADD_TO_HEAD(&st->client.clients, c);

    ANY_INIT(server, Ext2_clp, &c->cl);

    return True;
}
Exemple #20
0
static void L2_Dispose_m (USDCallback_cl  *self)
{
    TRC(L2_st *st = self->st);
    FTRC("entered: self=%p, st=%p.\n", self, st);

    FTRC("leaving, succeded.\n");
}
Exemple #21
0
void
video_clear(void)
{
	int cnt;
	TRC("%s\n", __FUNCTION__);
	if (fd >= 0)
		close(fd);
	fd = -1;
	video_playing = 0;
	audio_type = 0;
        if (video_write_thread) {
            pthread_kill(video_write_thread, SIGURG);
        }
        if (audio_write_thread) {
            pthread_kill(audio_write_thread, SIGURG);
        }

	sem_getvalue(&write_threads_idle_sem, &cnt);
	while ( cnt != 2 ) {
		sleep(0);
		sem_getvalue(&write_threads_idle_sem, &cnt);
		pthread_cond_broadcast(&video_cond);
	}
	av_stop();
	av_video_blank();
	av_reset();
	av_reset_stc();
	pthread_cond_broadcast(&video_cond);

	mvpw_set_bg(root, MVPW_BLACK);
	av_wss_update_aspect(WSS_ASPECT_FULL_4x3);
}
Exemple #22
0
/* Scan the cache in reverse order starting from the least recently
   used.  If we find a suitable victim, return that. */
struct buffer_head *balloc(ext2fs_st *st)
{
    struct buffer_head *b;

    TRC(printf("balloc -> "));
    b = st->cache.bufs.prev;
    while (b->prev != st->cache.bufs.prev) {
	if (b->state <= buf_unlocked) {
	    TRC(printf("%p\n", b));
	    return b;
	}
	b = b->prev;
    }
    TRC(printf("NULL\n"));
    return NULL;
}
Exemple #23
0
static int bt_init_rfkill(void) 
{
    char path[128];
    char buf[32];
    int fd, id;
    ssize_t sz;
    
    TRC();
    
    for (id = 0; id < 10 ; id++) {
        snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id);
        fd = open(path, O_RDONLY);
        if (fd < 0) {
            ERR("Open %s fails: %s(%d)\n", path, strerror(errno), errno);
            return -1;
        }
        sz = read(fd, &buf, sizeof(buf));
        close(fd);
        if (sz >= (ssize_t)strlen(BT_DRV_MOD_NAME) && 
            memcmp(buf, BT_DRV_MOD_NAME, strlen(BT_DRV_MOD_NAME)) == 0) {
            bt_rfkill_id = id;
            break;
        }
    }

    if (id == 10)
        return -1;

    asprintf(&bt_rfkill_state_path, "/sys/class/rfkill/rfkill%d/state", 
        bt_rfkill_id);
    
    return 0;
}
Exemple #24
0
void EM_BT_deinit(void)
{
    TRC();
    
    if (!glib_handle){
        ERR("mtk bt library is unloaded!\n");
    }
    else{
        if (bt_fd < 0){
            ERR("bt driver fd is invalid!\n");
        }
        else{
            bt_restore(bt_fd);
            bt_fd = -1;
        }
        dlclose(glib_handle);
        glib_handle = NULL;
    }

#ifndef MTK_COMBO_SUPPORT
    bt_set_power(0); /* shutdown BT */
#endif

    return;
}
Exemple #25
0
static void
scan_out(int scfd, char *scsp, int dlm)
{
	char *strp;
	int nchrs, j;
	char outbuf[LINELEN+1], *sp, c, cc;
	int d, scnhgt;

	for (scnhgt = 0; scnhgt++ < HEIGHT+DROP; ) {
		strp = &outbuf[0];
		sp = scsp;
		for (nchrs = 0; *sp != dlm && *sp != '\0'; ) {
			cc = *sp++;
			if ((unsigned char)cc < ' ' ||
			    (unsigned char)cc > 0x7f)
				cc = INVALID;

			c = TRC(cc);
			d = dropit(c);
			if ((!d && scnhgt > HEIGHT) || (scnhgt <= DROP && d))
				for (j = WIDTH; --j;)
					*strp++ = BACKGND;
			else
				strp = scnline(scnkey[(int)c][scnhgt-1-d], strp, cc);
			if (nchrs++ >= PW/(WIDTH+1)-1)
				break;
			*strp++ = BACKGND;
		}
		while (*--strp == BACKGND && strp >= outbuf)
			;
		strp++;
		*strp++ = '\n';
		write(scfd, outbuf, strp-outbuf);
	}
}
Exemple #26
0
static BOOL BT_DisableSleepMode(void)
{
    UCHAR   HCI_VS_SLEEP[] = 
                {0x01, 0x7A, 0xFC, 0x07, 0x00, 0x40, 0x1F, 0x00, 0x00, 0x00, 0x04};
    UCHAR   pAckEvent[7];
    UCHAR   ucEvent[] = {0x04, 0x0E, 0x04, 0x01, 0x7A, 0xFC, 0x00};
    
    TRC();
    
    if (!glib_handle){
        ERR("mtk bt library is unloaded!\n");
        return FALSE;
    }
    if (bt_fd < 0){
        ERR("bt driver fd is invalid!\n");
        return FALSE;
    }
    
    if(bt_send_data(bt_fd, HCI_VS_SLEEP, sizeof(HCI_VS_SLEEP)) < 0){
        ERR("Send disable sleep mode command fails errno %d\n", errno);
        return FALSE;
    }
    
    if(bt_receive_data(bt_fd, pAckEvent, sizeof(pAckEvent)) < 0){
        ERR("Receive event fails errno %d\n", errno);
        return FALSE;
    }
    
    if(memcmp(pAckEvent, ucEvent, sizeof(ucEvent))){
        ERR("Receive unexpected event\n");
        return FALSE;
    }
    
    return TRUE;
}
BOOL RELAYER_start(int serial_port, int serial_speed)
{
    TRC();
    
    if (EM_BT_init()){
        DBG("BT device power on success\n");
    }
    else{
        ERR("BT device power on failed\n");
        return FALSE;
    }
    
    serial_fd = init_serial(serial_port, serial_speed);
    if (serial_fd < 0){
        ERR("Initialize serial port to PC failed\n");
        EM_BT_deinit();
        return FALSE;
    }
    
    signal(SIGRTMIN, thread_exit);
    /* Create Tx monitor thread */
    pthread_create(&txThread, NULL, bt_tx_monitor, (void*)NULL);
    /* Create RX monitor thread */
    pthread_create(&rxThread, NULL, bt_rx_monitor, (void*)NULL);
    
    DBG("BT Relayer mode start\n");
    
    return TRUE;
}
Exemple #28
0
	void InsertTx(const Tx& tx, const TxHashesOutNums& hashesOutNums, const HashValue& txHash, int height, const ConstBuf& txIns, const ConstBuf& spend, const ConstBuf& data) override {
		CoinEng& eng = Eng();

		m_cmdInsertTx
			.Bind(1, ReducedHashValue(txHash))
			.Bind(2, (Int64)height)
			.Bind(3, txIns)
			.Bind(4, spend);

		m_cmdInsertTx.Bind(5, data);
		try {
			DBG_LOCAL_IGNORE_NAME(MAKE_HRESULT(SEVERITY_ERROR, FACILITY_SQLITE, SQLITE_CONSTRAINT_PRIMARYKEY), ignSQLITE_CONSTRAINT_PRIMARYKEY);
					
			m_cmdInsertTx.ExecuteNonQuery();
		} catch (const SqliteException&) {
			TRC(1, "Duplicated Transaction: " << txHash);

			if (height >= eng.ChainParams.CheckDupTxHeight && ContainsInLinear(GetCoinsByTxHash(txHash), true))
				Throw(E_COIN_DupNonSpentTx);						

			SqliteCommand("UPDATE txes SET coins=? WHERE id=?", m_db)
				.Bind(1, spend)
				.Bind(2, ReducedHashValue(txHash))
				.ExecuteNonQuery();
		}
		if (eng.Mode == EngMode::BlockExplorer)
			InsertPubkeyToTxes(tx);
	}
Exemple #29
0
LIBUDEV_EXPORT struct udev *
udev_ref(struct udev *udev)
{

	TRC("(%p) refcount=%d", udev, udev->refcount);
	return (_udev_ref(udev));
}
Exemple #30
0
/* routing stuff is still missing */
void tcp_respond(struct tcpiphdr *ti, IO_Rec *recs, int nr_recs,
		 iphost_st *host_st, intf_st *ifs, tcp_seq ack,
		 tcp_seq seq, int flags)
{
    register int tlen=0;

    TRC(printf("tcp respond \n"));
#define xchg(a,b,type) { type t; t=a; a=b; b=t; }
    xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, uint32_t);
    xchg(ti->ti_dport, ti->ti_sport, uint16_t);
#undef xchg

    ti->ti_len = htons((uint16_t)(sizeof (struct tcphdr) + tlen));
    tlen += sizeof (struct tcpiphdr);
    ti->ti_next = ti->ti_prev = 0;
    ti->ti_x1 = 0;
    TRC(printf("ack before setting back %d\n", ack));
    ti->ti_seq = hton32(seq);
    ti->ti_ack = hton32(ack);
    ti->ti_x2 = 0;
    ti->ti_off = sizeof (struct tcphdr) >> 2;
    ti->ti_flags = flags;
    ti->ti_win = hton16(ti->ti_win);
    ti->ti_urp = 0;
    ti->ti_sum = 0;
    TRC(printf("calling cksum with len %d\n", tlen));

    /* checksum computes over tcp and ip (overlay) header */
    if (recs[1].len == 0) {
	ti->ti_sum = in_cksum((uint16_t *)ti, tlen);
    } else {
	printf("tcp_respond: checksum more recs, "
	       "nr recs %d rec 0 len %d rec 1 len%d\n",
	       nr_recs, recs[0].len, recs[1].len);
	ti->ti_sum = cksum_morerecs((uint16_t *)ti,
				    recs[0].len - sizeof(struct ether_header),
				    recs, nr_recs);
    }
    TRC(printf("calling cksum done\n"));

    ((struct ip *)ti)->ip_len = tlen;
    ((struct ip *)ti)->ip_ttl = MAXTTL;

    TRC(printf("tcp respond calling ip_output\n"));

    ip_output(recs, nr_recs, host_st, ifs, 0, flags);
}