Пример #1
0
VOID KeyboardEvent(BOOL bPress, UINT out, UINT in)
{
	if (nState != SM_RUN)					// not in running state
		return;								// ignore key
	if (in == 0x8000)						// ON key ?
	{
		Chipset.IR15X = bPress?0x8000:0x0000; // refresh special ON key flag
	}
	else
	{
		// "out" is outside Keyboard_Row 
		if (out >= ARRAYSIZEOF(Chipset.Keyboard_Row)) return;

		// in &= 0x1FF;						// only IR[0:8] are wired on Clarke/Yorke chip

		_ASSERT(out < ARRAYSIZEOF(Chipset.Keyboard_Row));
		if (bPress)							// key pressed
			Chipset.Keyboard_Row[out] |= in; // set key marker in keyboard row
		else
			Chipset.Keyboard_Row[out] &= (~in); // clear key marker in keyboard row
	}
	AdjKeySpeed();							// adjust key repeat speed
	ScanKeyboard(FALSE,FALSE);				// update Chipset.in register by 1ms keyboard poll
	Sleep(50);								// hold key state for a definite time
	return;
}
    int32_t get_char_number_from_name(const char* name)
    {
      int32_t ret = 0;
      int32_t low = 0;
      int32_t high = ARRAYSIZEOF(charset) - 1;
      int cret = 0;
      while (low <= high)
      {
        ret = low + (high - low)/2;
        cret = strcasecmp(charset[ret].name_, name);
        if (0 == cret)
        {
          break;
        }
        else if (0 < cret)
        {
          high = ret - 1;
        }
        else
        {
          low = ret + 1;
        }
      }

      if (low > high)
      {
        ret = -1;
      }
      else
      {
        ret = charset[ret].number_;
      }
      return ret;
    }
    const char* get_char_name_from_number(int32_t number)
    {
      const char *name = "gbk";
      int32_t ret = 0;
      int32_t low = 0;
      int32_t high = ARRAYSIZEOF(charsetR) - 1;
      while (low <= high)
      {
        ret = low + (high - low)/2;
        if (charsetR[ret].number_ == number)
        {
          break;
        }
        else if (charsetR[ret].number_ > number)
        {
          high = ret - 1;
        }
        else
        {
          low = ret + 1;
        }
      }

      if (low > high)
      {
        ret = -1;
      }
      else
      {
        name = charsetR[ret].name_;
      }
      return name;
    }
Пример #4
0
int
ps2pad_stat_conv(int stat)
{
	if (stat < 0 || ARRAYSIZEOF(stat_conv_table) <= stat) {
		return PS2PAD_STAT_ERROR;
	} else {
		return stat_conv_table[stat];
	}
}
 int TSIStackAllocator::clear(const bool slow)
 {
   int err = OB_SUCCESS;
   for(int64_t i = 0; OB_SUCCESS == err && i < (int64_t)ARRAYSIZEOF(allocator_array_); i++)
   {
     err = allocator_array_[i].clear(slow);
   }
   return err;
 }
Пример #6
0
int ps2mcfs_init_dirent(void)
{
	int i;

	INIT_LIST_HEAD(&free_dirents);
	for (i = 0; i < ARRAYSIZEOF(active_dirents); i++)
		INIT_LIST_HEAD(&active_dirents[i]);

	return (0);
}
Пример #7
0
static void
ps2pad_read_stat(struct ps2pad_stat *stat)
{
	int i, res;
	u_char data[PS2PAD_DATASIZE];

	for (i = 0; i < ps2pad_npads; i++) {
		/* port and slot */
		stat[i].portslot = ((ps2pad_pads[i].port << 4) |
				    ps2pad_pads[i].slot);

		/* request status */
		res = ps2padlib_GetReqState(ps2pad_pads[i].port,
					ps2pad_pads[i].slot);
		if (res < 0 || ARRAYSIZEOF(rstat_conv_table) <= res) {
			stat[i].rstat = PS2PAD_RSTAT_FAILED;
		} else {
			stat[i].rstat = rstat_conv_table[res];
		}

		/* connection status */
		res = ps2padlib_GetState(ps2pad_pads[i].port, ps2pad_pads[i].slot);
		stat[i].type = 0;
		if (res < 0 || ARRAYSIZEOF(stat_conv_table) <= res) {
			stat[i].stat = PS2PAD_STAT_ERROR;
		} else {
			stat[i].stat = stat_conv_table[res];
			if (stat[i].stat == PS2PAD_STAT_READY) {
				res = ps2padlib_Read(ps2pad_pads[i].port,
						 ps2pad_pads[i].slot,
						 data);
				if (res != 0 && data[0] == 0) {
					/* pad data is valid */
					stat[i].type = data[1];
				} else {
					stat[i].stat = PS2PAD_STAT_ERROR;
				}
			}
		}
	}
}
Пример #8
0
char*
ps2cdvd_getstatestr(int no)
{
	static char buf[32];
	if (0 <= no && no < ARRAYSIZEOF(ps2cdvd_states) &&
	    ps2cdvd_states[no]) {
		return ps2cdvd_states[no];
	} else {
		sprintf(buf, "unknown state(0x%02x)", no);
		return buf;
	}
}
Пример #9
0
// InitListViewColumns - adds columns to a list-view control. 
// Returns TRUE if successful, or FALSE otherwise. 
// hWndListView - handle to the list-view control. 
static
BOOL InitListViewColumns(HWND hWndListView) 
{ 
    TCHAR szText[256];     // temporary buffer 
    LVCOLUMN lvc;
    RECT rect;
    int iCol;
	int Labels[PC_NUM_COLUMNS] = {IDS_FRIENDLY_NAME, IDS_ISSUER};

 #if 0
	HBITMAP hBmp;
	HICON hIcon;
	HIMAGELIST hImg;
	// create image list
    //hImg = ImageList_Create(GetSystemMetrics(SM_CXSMICON), 
    //    GetSystemMetrics(SM_CYSMICON), 0, 1, 1);
	 hImg = ImageList_Create(16, 16, 0, 1, 1);


	hBmp = LoadBitmap(v_hInst, MAKEINTRESOURCE(IDB_PKEY));
	hIcon = LoadIcon(v_hInst, MAKEINTRESOURCE(IDI_ICON1));

	ImageList_AddIcon(hImg, hIcon);
	// Assign the image lists to the list-view control. 
    ListView_SetImageList(hWndListView, hImg, LVSIL_SMALL); 
	// DeleteObject(hBmp);
#endif

    // Initialize the LVCOLUMN structure.
    // The mask specifies that the format, width, text, and subitem
    // members of the structure are valid. 
    lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
    GetClientRect(hWndListView, &rect);
    
    // Add the columns. 
    for (iCol = 0; iCol < PC_NUM_COLUMNS; iCol++) 
	{ 
        lvc.iSubItem = iCol;
        lvc.cx = (rect.right - rect.left)/PC_NUM_COLUMNS;           // width of column in pixels
        lvc.fmt = LVCFMT_LEFT;  // left-aligned column
		lvc.pszText = szText;
		LoadString(v_hInst, Labels[iCol], 
                szText, ARRAYSIZEOF(szText));
        if (ListView_InsertColumn(hWndListView, iCol, &lvc) == -1) 
            return FALSE; 
    } 
    return TRUE; 
} 
Пример #10
0
 const char* get_clog_src_name(const int64_t role)
 {
   const char* str = NULL;
   const char* names[] = {"self", "master_master", "master_master", "slave_master",
                          "self", "master_master", "lsync", "slave_master"};
   if (role >= 0 && role < (int64_t)ARRAYSIZEOF(names))
   {
     str = names[role];
   }
   else
   {
     str = "unknown";
     TBSYS_LOG(WARN, "unknown role[%ld]", role);
   }
   return str;
 }
Пример #11
0
 const char* get_role_as_str(const int64_t role)
 {
   const char* str = NULL;
   const char* names[] = {"master_master", "master_slave", "slave_master", "slave_slave",
                          "master_master", "master_slave", "slave_master", "slave_slave"};
   if (role >= 0 && role < (int64_t)ARRAYSIZEOF(names))
   {
     str = names[role];
   }
   else
   {
     str = "unknown";
     TBSYS_LOG(WARN, "unknown role[%ld]", role);
   }
   return str;
 }
Пример #12
0
 int ObUpsCLogStatus::to_str(char* buf, const int64_t len, const bool detail /*=true*/) const
 {
   int err = OB_SUCCESS;
   int64_t count = 0;
   int64_t count2 = 0;
   char rs_addr[OB_MAX_SERVER_ADDR_SIZE];
   char self_addr[OB_MAX_SERVER_ADDR_SIZE];
   char ups_master_addr[OB_MAX_SERVER_ADDR_SIZE];
   char inst_ups_master_addr[OB_MAX_SERVER_ADDR_SIZE];
   char lsync_addr[OB_MAX_SERVER_ADDR_SIZE];
   char* clog_src_addr_array[] = {self_addr, ups_master_addr, inst_ups_master_addr, ups_master_addr,
                                  self_addr, ups_master_addr, lsync_addr, ups_master_addr};
   int64_t role = get_role_as_int(obi_role_.get_role(), role_mgr_.get_role(), obi_slave_stat_);
   const char* clog_src_addr = (role >= 0 && role < (int)ARRAYSIZEOF(clog_src_addr_array)) ? clog_src_addr_array[role]: "unknown";
   if (!rs_.to_string(rs_addr, sizeof(rs_addr)) || !self_.to_string(self_addr, sizeof(self_addr))
       || !ups_master_.to_string(ups_master_addr, sizeof(ups_master_addr)) || !inst_ups_master_.to_string(inst_ups_master_addr, sizeof(inst_ups_master_addr))
       || !lsync_.to_string(lsync_addr, sizeof(lsync_addr)))
   {
     err = OB_ERR_UNEXPECTED;
   }
   else if (0 >= (count = snprintf(buf, len,
                                   "role=%s_%s:%s[%s], replay_switch=%ld\n"
                                   "frozen_version=%ld, cursor=%ld[%ld+%ld]->%ld<-%ld[%s:%s]\n"
                                   ,
                                   obi_role_.get_role_str(), role_mgr_.get_role_str(), role_mgr_.get_state_str(),
                                   slave_sync_type_.get_type_str(),
                                   replay_switch_.get_seq(),
                                   last_frozen_version_, 
                                   replayed_cursor_.log_id_, replayed_cursor_.file_id_, replayed_cursor_.offset_,
                                   max_log_id_replayable_, master_log_id_,
                                   get_clog_src_name(role), clog_src_addr))
                  || count > len)
   {
     err = OB_BUF_NOT_ENOUGH;
     TBSYS_LOG(WARN, "snprintf(buf=%p[%ld]): count=%ld", buf, len, count);
   }
   else if (detail && 0 >= (count2 = snprintf(buf + count, len - count,
                                              "rs=%s, self=%s, ups_master=%s, inst_ups_master=%s, lsync=%s\n",
                                              rs_addr, self_addr, ups_master_addr, inst_ups_master_addr,
                                              lsync_addr))
                            && count2 > len - count)
   {
     err = OB_BUF_NOT_ENOUGH;
     TBSYS_LOG(WARN, "snprintf(buf=%p[%ld]): count=%ld", buf + count, len - count, count2);
   }
   return err;
 }
Пример #13
0
void
ps2mcfs_invalidate_dirents(struct ps2mcfs_root *root)
{
	int i;
	struct list_head *p;
	struct ps2mcfs_dirent *de;
	struct inode *inode;
	const char *path;

	TRACE("ps2mcfs_invalidate_dirents(card%02x)\n", root->portslot);

	for (i = 0; i < ARRAYSIZEOF(active_dirents); i++) {
		for (p = active_dirents[i].next;
		     p != &active_dirents[i]; p = p->next) {

			de = list_entry(p, struct ps2mcfs_dirent, hashlink);
			if (de->root != root)
				continue;

			path = ps2mcfs_get_path(de);
			DPRINT(DBG_INFO, "  invalidate: %s\n", path);
			ps2mcfs_put_path(de, path);

			de->flags |= PS2MCFS_DIRENT_INVALID;
			if (de->flags & PS2MCFS_DIRENT_BMAPPED) {
				de->flags &= ~PS2MCFS_DIRENT_BMAPPED;

				/*
				 * XXX,
				 * You can't call ps2mcfs_unref_dirent(de)
				 * because it possibly free the node.
				 * But I think it might not happen...
				 */
				de->refcount--;
				if (de->refcount == 0)
					printk("ps2mcfs: dirent refcount=0\n");
			}

			if ((inode = de->inode) != NULL) {
				/*inode->i_op = &ps2mcfs_null_inode_operations;
				 */
				inode->i_nlink = 0;
			}
		}
	}
}
Пример #14
0
// write to buffer initial command
static VOID WrStateE8(DWORD d)
{
	// @todo add 2nd write buffer implementation
	// @todo add program timing implementation

	WSMset.byExStatusReg = 0;				// no write buffer
	if (WSMset.byWrite1No == 0)				// buffer1 available
	{
		WSMset.byWrite1No = 1;				// buffer1 in use
		WSMset.dwWrite1Addr = d;			// byte block address of buffer1
		WSMset.byExStatusReg = WBS;			// write buffer available
		// fill write buffer
		FillMemory(WSMset.pbyWrite1,ARRAYSIZEOF(WSMset.pbyWrite1),0xFF);
		WSMset.uWrState = WRS_WR_BUFFER_N;	// set state machine
		WSMset.uRdState = RDS_XSR;
	}
	return;
}
 int TSIStackAllocator::init(ObIAllocator* block_allocator, int64_t block_size)
 {
   int err = OB_SUCCESS;
   if (NULL == block_allocator || 0 >= block_size)
   {
     err = OB_INVALID_ARGUMENT;
   }
   else if (NULL != block_allocator_)
   {
     err = OB_INIT_TWICE;
   }
   for(int64_t i = 0; OB_SUCCESS == err && i < (int64_t)ARRAYSIZEOF(allocator_array_); i++)
   {
     err = allocator_array_[i].init(block_allocator, block_size);
   }
   if (OB_SUCCESS == err)
   {
     block_allocator_ = block_allocator;
     block_size_ = block_size;
   }
   return err;
 }
Пример #16
0
/* DlgProcRemoveConnect
 *
 *  Dialog box procedure for WNetDisconnectDialog() function. Construct a
 *  list of all connected and remembered resources, and allow the user to
 *  select one to attempt to delete.
 */
static BOOL CALLBACK
DlgProcRemoveConnect(
    HWND hDlg,
    UINT message,
    WPARAM wParam,
    LPARAM lParam )
{

    HWND hListBoxWnd = GetDlgItem(hDlg,IDC_NETUI_DISCONLIST);

    // FONT HANDLING STUFF
    // set font size, weight, and color per the table gs_rgTextDescRemoveConn
    static  void*   s_pvFontManager;
    ULONG ulFontMgrRetVal;

    if (SHRunFontManager(gs_rgTextDescRemoveConn,
                         ARRAYSIZEOF(gs_rgTextDescRemoveConn),
                         &s_pvFontManager,
                         message,
                         hDlg,
                         wParam,
                         lParam,
                         &ulFontMgrRetVal) == CTLTEXT_EXIT )
    {
        return (BOOL)ulFontMgrRetVal;
    }

    switch( message ) {

        case WM_INITDIALOG:
        {
            DWORD Status, BufSize, NumElements;
            NETRESOURCE *pNetRes;
            HANDLE hEnum;
            DWORD dwScope = RESOURCE_CONNECTED;

    StartEnum:
            // Populate listbox with list of resources.  Since we don't automatically
            // try to connect our remebered resources, we have to enumerate connected
            // and remembered resources separately.
            if ((Status = pfnWNetOpenEnum(dwScope,RESOURCETYPE_ANY,
                                          0, // Doesn't matter
                                          NULL,&hEnum)) != ERROR_SUCCESS) {
                DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: Error %u in WNetOpenEnum(%d)"),
                                     GetLastError(),dwScope));
                return FALSE;
            }
            while (Status == ERROR_SUCCESS) {
                DWORD iRet;
                WCHAR StrBuf[100];

                // First, call with 0 buffer to determine needed size (this is not very efficient,
                // but we want a separate buffer for each NETRESOURCE struct).
                BufSize = 0;
                pNetRes = NULL;
                NumElements = 1;
                Status = pfnWNetEnumResource(hEnum,&NumElements,pNetRes,&BufSize);
                if (Status == ERROR_NO_MORE_ITEMS)
                    break;
                else if (Status != ERROR_MORE_DATA) {
                    DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: WNetEnumResource(0) returned %u\r\n"),Status));
                }
                else
                    DEBUGMSG(ZONE_DISCONN,(DBGTEXT("DlgProcRemoveConnect: Using buffer size %u"),BufSize));

                if ((pNetRes = LocalAlloc(0,BufSize)) == NULL) {
                    DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: LocalAlloc(%d) failed"),BufSize));
                    Status = ERROR_NOT_ENOUGH_MEMORY;
                    break;
                }
                NumElements = 1;
                Status = pfnWNetEnumResource(hEnum,&NumElements,pNetRes,&BufSize);
                if (Status != ERROR_SUCCESS) {
                    DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: Error %u in WNetEnumResource()"),
                                         GetLastError()));
                    break;
                }

                // Use TAB to separate local, remote names
                wsprintf(StrBuf,L"%s\t%s",pNetRes->lpLocalName? pNetRes->lpLocalName : L"(none)",pNetRes->lpRemoteName);
                // If remembered resource is also connected, we'll get duplicated entries
                if (ListBox_FindString(hListBoxWnd,0,StrBuf) != LB_ERR) {
                    DEBUGMSG(ZONE_DISCONN,(DBGTEXT("Entry %s already added to listbox"),StrBuf));
                    LocalFree(pNetRes);
                    continue;
                }
                DEBUGMSG(ZONE_DISCONN,(DBGTEXT("Adding entry %s to listbox"),StrBuf));
                iRet = ListBox_AddString(hListBoxWnd,StrBuf);
                if ((iRet == LB_ERR) || (iRet == LB_ERRSPACE)) {
                    DEBUGMSG(ZONE_ERROR,(DBGTEXT("DlgProcRemoveConnect: Error adding string to listbox: %d"),iRet));
                    LocalFree(pNetRes);
                    continue;
                }
                ListBox_SetItemData(hListBoxWnd,iRet,pNetRes);
            }
            pfnWNetCloseEnum(hEnum);
            if (Status != ERROR_NO_MORE_ITEMS) {
                // Some error occurred, clean up
                DisconnectDialogDone(hDlg,FALSE);
                return FALSE;
            }
            // List both connected and remembered resources
            if (dwScope == RESOURCE_CONNECTED) {
                dwScope = RESOURCE_REMEMBERED;
                goto StartEnum;
            }

            ListBox_SetCurSel(hListBoxWnd,0);

            return FALSE;
        }
        case WM_COMMAND:
            switch( LOWORD( wParam ) ) {
                case IDCANCEL:
                    // Clean up
                    DisconnectDialogDone(hDlg, FALSE);
                    break;

                case IDOK:
                {
                    BOOL bRet = TRUE;
                    NETRESOURCE *pNetRes;
                    int Index;
                    Index = ListBox_GetCurSel(hListBoxWnd);
                    pNetRes = (NETRESOURCE *)ListBox_GetItemData(hListBoxWnd,Index);
                    if (((LRESULT)pNetRes == LB_ERR) || (pNetRes == NULL)) {
                        DEBUGMSG(ZONE_ERROR,(DBGTEXT("!DisconnectDlgDone: LB_GETITEMDATA returned err or NULL: %d"),
                                             GetLastError()));
                    }
                    else {
                        // Disconnect selected resource
                        DISCDLGSTRUCT DlgStruct;
                        DlgStruct.cbStructure = sizeof(DlgStruct);
                        DlgStruct.hwndOwner   = hDlg;
                        DlgStruct.lpLocalName = pNetRes->lpLocalName;
                        DlgStruct.lpRemoteName= pNetRes->lpRemoteName;
                        DlgStruct.dwFlags     = DISC_UPDATE_PROFILE;

                        DEBUGMSG(ZONE_DISCONN,(DBGTEXT("Got Selection %s -> %s"),
                                           pNetRes->lpLocalName,pNetRes->lpRemoteName));
                        if (pfnWNetDisconnectDialog1(&DlgStruct) != ERROR_SUCCESS)
                            bRet = FALSE;
                    }

                    // Clean up
                    DisconnectDialogDone(hDlg, bRet);
                    break;
                }
            }

        case WM_DESTROY:
            return( FALSE );

        default:
            return( FALSE );
    }
}
Пример #17
0
static int
ps2pad_ioctl(struct inode *inode, struct file *filp, u_int cmd, u_long arg)
{
	int i, res;
	struct ps2pad_dev *dev = filp->private_data;
	int port = dev->pad->port;
	int slot = dev->pad->slot;

	switch (cmd) {
	case PS2PAD_IOCPRESSMODEINFO:
		if (lock() < 0) return -ERESTARTSYS;
		*(int*)(arg) = ps2padlib_InfoPressMode(port, slot);
		unlock();
		break;
	case PS2PAD_IOCENTERPRESSMODE:
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_EnterPressMode(port, slot);
		unlock();
		ps2pad_update_status();
		if (res != 1)
			return -EIO;
		return (filp->f_flags & O_NONBLOCK) ? 0 : ps2pad_check_req_stat(dev);
		break;
	case PS2PAD_IOCEXITPRESSMODE:
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_ExitPressMode(port, slot);
		unlock();
		ps2pad_update_status();
		if (res != 1)
			return -EIO;
		return (filp->f_flags & O_NONBLOCK) ? 0 : ps2pad_check_req_stat(dev);
		break;
	case PS2PAD_IOCGETREQSTAT:
		if (filp->f_flags & O_NONBLOCK) {
			res = ps2padlib_GetReqState(port, slot);
		} else {
			if ((res = ps2pad_wait_req_stat(dev)) < 0)
				return res;
		}
		if (res < 0 || ARRAYSIZEOF(rstat_conv_table) <= res) {
			return -EIO;
		} else {
			*(int*)(arg) = rstat_conv_table[res];
		}
		break;
	case PS2PAD_IOCGETSTAT:
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_GetState(port, slot);
		unlock();
		if (res < 0 || ARRAYSIZEOF(stat_conv_table) <= res) {
			return -EIO;
		} else {
			*(int*)(arg) = stat_conv_table[res];
		}
		break;
	case PS2PAD_IOCACTINFO: {
		struct ps2pad_actinfo *info = (struct ps2pad_actinfo *)arg;
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_InfoAct(port, slot, info->actno, info->term);
		unlock();
		if (res < 0) return -EIO;
		info->result = res;
		return 0;
		}
		break;
	case PS2PAD_IOCCOMBINFO: {
		struct ps2pad_combinfo *info = (struct ps2pad_combinfo *)arg;
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_InfoComb(port, slot, info->listno, info->offs);
		unlock();
		if (res < 0) return -EIO;
		info->result = res;
		return 0;
		}
		break;
	case PS2PAD_IOCMODEINFO: {
		struct ps2pad_modeinfo *info = (struct ps2pad_modeinfo *)arg;
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_InfoMode(port, slot, info->term, info->offs);
		unlock();
		if (res < 0) return -EIO;
		info->result = res;
		return 0;
		}
		break;
	case PS2PAD_IOCSETMODE: {
		struct ps2pad_mode *mode = (struct ps2pad_mode *)arg;
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_SetMainMode(port, slot, mode->offs, mode->lock);
		unlock();
		ps2pad_update_status();
		if (res != 1) {
			DPRINT("%d %d: ps2padlib_SetMainMode() failed\n",
			       dev->pad->port, dev->pad->slot);
			return -EIO;
		}
		if (filp->f_flags & O_NONBLOCK) {
			DPRINT("port%d slot%d: PS2PAD_IOCSETMODE: non-block\n",
			       dev->pad->port, dev->pad->slot);
			return 0;
		} else {
			return ps2pad_check_req_stat(dev);
		}
		}
		break;
	case PS2PAD_IOCSETACTALIGN: {
		struct ps2pad_act *act = (struct ps2pad_act *)arg;
		if (6 < act->len) {
			return EINVAL;
		}
		for (i = act->len; i < 6; i++) {
			act->data[i] = 0xff;
		}
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_SetActAlign(port, slot, act->data);
		unlock();
		ps2pad_update_status();
		if (res != 1) return -EIO;
		return (filp->f_flags & O_NONBLOCK) ? 0 : ps2pad_check_req_stat(dev);
		}
		break;
	case PS2PAD_IOCSETACT: {
		struct ps2pad_act *act = (struct ps2pad_act *)arg;
		if (6 < act->len) {
			return EINVAL;
		}
		if (lock() < 0) return -ERESTARTSYS;
		res = ps2padlib_SetActDirect(port, slot, act->data);
		unlock();
		if (res != 1) return -EIO;
		return 0;
		}
		break;
	default:
		return -EINVAL;
	}

	return 0;
}
Пример #18
0
static
BOOL PopulateListView(HWND hCtl, PNETUI_PICKCERT pPickCert)
{
	PCCERT_CONTEXT pCert = NULL;
	LVITEM lvI;
	int index = 0;
	TCHAR rgch[CRYPTUI_MAX_STRING_SIZE];

	// Initialize LVITEM members that are common to all items. 
	lvI.state = 0; 
	lvI.stateMask = 0; 

	for (index = 0; index < (int) pPickCert->nCerts; index++)
	{
	
        pCert = pPickCert->ppCerts[index];
	// Initialize LVITEM members that are different for each item. 
   		lvI.iItem = index;
		lvI.mask = LVIF_PARAM | LVIF_STATE ; //LVIF_IMAGE 
		lvI.iImage = 0;
		lvI.iSubItem = 0;
		lvI.lParam = index;
		//lvI.pszText = LPSTR_TEXTCALLBACK; // sends an LVN_GETDISPINFO
											   // message.									  
		
		if(ListView_InsertItem(hCtl, &lvI) == -1)
			break;

		lvI.mask = LVIF_TEXT;

		pCertGetNameStringW(
				pCert,
                CERT_NAME_FRIENDLY_DISPLAY_TYPE,
                0,//CERT_NAME_ISSUER_FLAG,
                NULL,
                rgch,
                ARRAYSIZEOF(rgch));

		lvI.iSubItem = 0;	// subject name
		lvI.pszText = rgch;

		ListView_SetItemText(hCtl, index, 0, rgch);
		
		pCertGetNameStringW(
				pCert,
                CERT_NAME_SIMPLE_DISPLAY_TYPE,
                CERT_NAME_ISSUER_FLAG,
                NULL,
                rgch,
                ARRAYSIZEOF(rgch));

		lvI.iSubItem = 1;   // issuer name
		
		ListView_SetItemText(hCtl, index, 1, rgch);

	}
	if (pPickCert->iSelected >= 0 && pPickCert->iSelected < pPickCert->nCerts)
	{
	    // mark one element as selected
	    ListView_SetItemState(hCtl, pPickCert->iSelected, LVIS_SELECTED, LVIS_SELECTED);
	}
	return TRUE;
}
Пример #19
0
/* DlgProcAddConnect
 *
 *    Dialog box procedure for WnetAddConnect. Very simple now, later
 *    integrate with browser.
 *
 * Return Value:
 *    Return TRUE if successful, FALSE if error or cancel.
 */
static BOOL CALLBACK
DlgProcAddConnect(
    HWND hDlg,
    UINT message,
    WPARAM wParam,
    LPARAM lParam )
{
    ADDCONNECT_DLGPARAMS *pDlgParams;

    // FONT HANDLING STUFF
    // set font size, weight, and color per the table gs_rgTextDescAddConn
    static  void*   s_pvFontManager;
    ULONG ulFontMgrRetVal;

    if (SHRunFontManager(gs_rgTextDescAddConn,
                         ARRAYSIZEOF(gs_rgTextDescAddConn),
                         &s_pvFontManager,
                         message,
                         hDlg,
                         wParam,
                         lParam,
                         &ulFontMgrRetVal) == CTLTEXT_EXIT )
    {
        return (BOOL)ulFontMgrRetVal;
    }

    switch( message ) {

        case WM_INITDIALOG:
            // Param passed in lParam
            pDlgParams = (ADDCONNECT_DLGPARAMS *)lParam;

            DEBUGMSG(ZONE_ADDCONN,(DBGTEXT("+AddConnect: %s, ReadOnly: %s"),pDlgParams->RemoteName,
                                   pDlgParams->bReadOnly? TEXT("TRUE"):TEXT("FALSE")));

            SetDlgItemText( hDlg, IDC_NETUI_REMOTENAME, pDlgParams->RemoteName );
            SetDlgItemText( hDlg, IDC_NETUI_LOCALNAME,  pDlgParams->LocalName );

            if (pDlgParams->RemoteName[0]) {
                SendMessage(GetDlgItem(hDlg,IDC_NETUI_REMOTENAME),
                            EM_SETREADONLY,(WPARAM)pDlgParams->bReadOnly,0);
                SetFocus(GetDlgItem(hDlg, IDC_NETUI_LOCALNAME));
            } else {
                SetFocus(GetDlgItem(hDlg, IDC_NETUI_REMOTENAME));
            }

            // Set userdata for window so we can retrieve param later
            SetWindowLong(hDlg, GWL_USERDATA, (LONG) pDlgParams);
            return( FALSE );

        case WM_COMMAND:
            pDlgParams = (ADDCONNECT_DLGPARAMS *)GetWindowLong(hDlg,GWL_USERDATA);

            switch( LOWORD( wParam ) ) {
                case IDCANCEL: 				// Ignore values
                    DEBUGMSG(ZONE_ADDCONN,(DBGTEXT("-AddConnect: CANCELLED")));
                    EndDialog( hDlg, FALSE );
                    break;

                case IDOK: 					// Get the dialog values
                    GetDlgItemText( hDlg, IDC_NETUI_LOCALNAME,
                                    pDlgParams->LocalName,
                                    sizeof(pDlgParams->LocalName)/sizeof(pDlgParams->LocalName[0]));
                    GetDlgItemText( hDlg, IDC_NETUI_REMOTENAME,
                                    pDlgParams->RemoteName,
                                    sizeof(pDlgParams->RemoteName)/sizeof(pDlgParams->RemoteName[0]));
                    DEBUGMSG(ZONE_ADDCONN,(DBGTEXT("-AddConnect: Remote: %s, Local: %s"),
                                           pDlgParams->RemoteName, pDlgParams->LocalName));
                    EndDialog( hDlg, TRUE );
                    break;
            }

        case WM_DESTROY:
            return( FALSE );

        default:
            return( FALSE );
    }
}
 StackAllocator* TSIStackAllocator::get()
 {
   int64_t idx = itid();
   return (idx >= 0 && idx < (int64_t)ARRAYSIZEOF(allocator_array_))? allocator_array_ + idx: NULL;
 }