コード例 #1
0
ファイル: IdMapper.cpp プロジェクト: AmirAbrams/haiku
int
main(int argc, char** argv)
{
	gRequestPort = find_port(kRequestPortName);
	if (gRequestPort < B_OK) {
		fprintf(stderr, "%s\n", strerror(gRequestPort));
		return gRequestPort;
	}

	gReplyPort = find_port(kReplyPortName);
	if (gReplyPort < B_OK) {
		fprintf(stderr, "%s\n", strerror(gReplyPort));
		return gReplyPort;
	}

	ReadSettings();

	struct passwd* userInfo = getpwnam(kNobodyName);
	if (userInfo != NULL)
		gNobodyId = userInfo->pw_uid;
	else
		gNobodyId = 0;

	struct group* groupInfo = getgrnam(kNogroupName);
	if (groupInfo != NULL)
		gNogroupId = groupInfo->gr_gid;
	else
		gNogroupId = 0;

	return MainLoop();
}
コード例 #2
0
ファイル: port.c プロジェクト: aunali1/exopc
unsigned int read_port_w(unsigned short port)
{
    unsigned int r;
    int i = find_port(port, IO_READ);
    int j = find_port(port + 1, IO_READ);

#ifdef GUSPNP
    if (port == 0x324)
	i = j = 0;
#endif

    /* FIXME:  shoudl already be checked.  ASSERT if i, j == -1 */
    if (i == -1) {
	i_printf("can't read low-byte of 16 bit port 0x%04x:trying to read high\n",
		 port);
	return ((read_port(port + 1) << 8) | 0xff);
    }
    if (j == -1) {
	i_printf("can't read hi-byte of 16 bit port 0x%04x:trying to read low\n",
		 port);
	return (read_port(port) | 0xff00);
    }
    if (!video_port_io)
	enter_priv_on();
    if (port <= 0x3fe) {
	set_ioperm(port, 2, 1);
    } else
	priv_iopl(3);
    if (!video_port_io)
	leave_priv_setting();

    r = port_in_w(port);
    if (!video_port_io)
	enter_priv_on();
    if (port <= 0x3fe)
	set_ioperm(port, 2, 0);
    else
	priv_iopl(0);
    if (!video_port_io)
	leave_priv_setting();

    if (
#ifdef GUSPNP
	   i && j &&
#endif
	   !video_port_io) {
	r &= (ports[i].andmask | 0xff00);
	r &= ((ports[j].andmask << 8) | 0xff);
	r |= (ports[i].ormask & 0xff);
	r |= ((ports[j].ormask << 8) & 0xff00);
    } else
	video_port_io = 0;

    LOG_IO(port, r, '}', 0xffff);

    i_printf("read 16 bit port 0x%x gave %04x at %04x:%04x\n",
	     port, r, LWORD(cs), LWORD(eip));
    return (r);
}
コード例 #3
0
ファイル: tree.c プロジェクト: jhallen/joes-sandbox
struct expr *find_port(struct expr *e,char *name)
  {
  struct expr *r;
  if(e)
    if(e->t==',')
      if(r=find_port(e->l,name)) return r;
      else return find_port(e->r,name);
    else if(e->t=='.' && e->l && e->l->t=='NAME' && !strcmp(e->l->str,name))
      return e;
  return 0;
  }
コード例 #4
0
void ensure_connected(jack_client_t *client, const char **ports, desired_connection *connection) {
  const char *from_port_name = find_port(client, ports, connection->from_port);
  const char *to_port_name = find_port(client, ports, connection->to_port);

  // make sure both ports exist
  if (from_port_name == NULL) {
    printf("X from port (%s:%s) cannot be found\n", connection->from_port->desired,
	   mtype_strings[connection->from_port->which]);
    return;
  }
  if (to_port_name == NULL) {
    printf("X to port (%s:%s) cannot be found\n", connection->to_port->desired,
	   mtype_strings[connection->to_port->which]);
    return;
  }

  jack_port_t *from_port, *to_port;
  from_port = jack_port_by_name(client, from_port_name);
  to_port = jack_port_by_name(client, to_port_name);

  // this should never prematurely return, in theory
  if (from_port == NULL || to_port == NULL) {
    return;
  }
  
  const char **connections, **orig_connections;
  orig_connections = connections = jack_port_get_all_connections(client, from_port);
  
  printf("! connections for %s\n", from_port_name);
  if (connections == NULL) {
    printf("X  --None\n");
  }
  int connected = 0;
  while (connections && *connections) {
    if (port_matcher(client, *connections, connection->to_port)) {
      printf("! -->%s\n", *connections);
      connected = 1;
      break;
    }
    printf("  >%s\n", *connections);
    *connections++;
  }
  if (connections != NULL) {
    jack_free(orig_connections);
  }

  if (!connected) {
    int rc;
    printf("! Connecting %s to %s\n", from_port_name, to_port_name);
    rc = jack_connect(client, from_port_name, to_port_name);
    printf("%s rc is %d\n", rc == 0 ? "!" : "X", rc);
  }
}
コード例 #5
0
ファイル: port.c プロジェクト: aunali1/exopc
int write_port_w(unsigned int value, unsigned short port)
{
    int i = find_port(port, IO_WRITE);
    int j = find_port(port + 1, IO_WRITE);

#ifdef GUSPNP
    if (port == 0x324)
	i = j = 0;
#endif
    if ((i == -1) || (j == -1)) {
	i_printf("can't write to 16 bit port 0x%04x\n", port);
	return 0;
    }
    if (
#ifdef GUSPNP
	   i && j &&
#endif
	   !video_port_io) {
	value &= (ports[i].andmask | 0xff00);
	value &= ((ports[j].andmask << 8) | 0xff);
	value |= (ports[i].ormask & 0xff);
	value |= ((ports[j].ormask << 8) & 0xff00);
    }
    i_printf("write 16 bit port 0x%x value %04x at %04x:%04x\n",
	     port, (value & 0xffff), LWORD(cs), LWORD(eip));

    LOG_IO(port, value, '{', 0xffff);

    if (!video_port_io)
	enter_priv_on();
    if (port <= 0x3fe)
	set_ioperm(port, 2, 1);
    else
	priv_iopl(3);
    if (!video_port_io)
	leave_priv_setting();

    port_out_w(value, port);

    if (!video_port_io)
	enter_priv_on();
    if (port <= 0x3fe)
	set_ioperm(port, 2, 0);
    else
	priv_iopl(0);
    if (!video_port_io)
	leave_priv_setting();
    video_port_io = 0;

    return (1);
}
コード例 #6
0
ファイル: kutils.c プロジェクト: wh33t01/noncereboot1131UI
uint64_t task_self_addr() {
    if (cached_task_self_addr == 0) {
        cached_task_self_addr = find_port(mach_task_self());
        printf("task self: 0x%llx\n", cached_task_self_addr);
    }
    return cached_task_self_addr;
}
コード例 #7
0
ファイル: queue_out.c プロジェクト: akshayknarayan/bess
static struct snobj *queue_out_init(struct module *m, struct snobj *arg)
{
    struct queue_out_priv *priv = get_priv(m);

    struct snobj *t;

    const char *port_name;

    int ret;

    if (!arg || snobj_type(arg) != TYPE_MAP)
        return snobj_err(EINVAL, "Argument must be a map");

    t = snobj_eval(arg, "port");
    if (!t || !(port_name = snobj_str_get(t)))
        return snobj_err(EINVAL, "Field 'port' must be specified");

    t = snobj_eval(arg, "qid");
    if (!t || snobj_type(t) != TYPE_INT)
        return snobj_err(EINVAL, "Field 'qid' must be specified");
    priv->qid = snobj_uint_get(t);

    priv->port = find_port(port_name);
    if (!priv->port)
        return snobj_err(ENODEV, "Port %s not found", port_name);

    ret = acquire_queues(priv->port, m, PACKET_DIR_OUT, &priv->qid, 1);
    if (ret < 0)
        return snobj_errno(-ret);

    priv->send_pkts = priv->port->driver->send_pkts;

    return NULL;
}
コード例 #8
0
ファイル: InputFilter.cpp プロジェクト: HaikuArchives/ClipUp
filter_result InputFilter::Filter(BMessage *message, BList *outList) {
	
	const int32	kControlKeys = B_COMMAND_KEY | B_SHIFT_KEY;
	
	if (message->what == B_KEY_DOWN ) {

		int32 raw;
		int32 mods;
		
		if ((message->FindInt32("raw_char", 0, (int32 *)&raw) == B_OK)
			&& (message->FindInt32("modifiers", (int32 *)&mods) == B_OK)
			&& (raw==118) // v
			&& ((mods & kControlKeys) == kControlKeys) ) {
			
			port_id port = find_port("ClipUp input port");

			if (port!=B_NAME_NOT_FOUND) {
				write_port( port, 'CtSV', NULL, 0 );
				return B_SKIP_MESSAGE;
			}
		}
	}
	
	return B_DISPATCH_MESSAGE;
}
コード例 #9
0
//////////// == 
// Function to find a remote BLooper 
BMessenger *SLooper::FindOtherEnd(char *unique_name) { 
        BMessenger *rc = new BMessenger(); 
        int32 ignored; 

        FORMULATE_UNIQUE(unique_name);
        
        // find port by name 
        port_id port = find_port(unique); 
        if (port < 0) { 
                return NULL; 
        } 

        // create a port for the reply
        
        port_id myPort = create_port(1, "temporary port for answer"); 
       
        // send the request to the other end with the port of our end 
        write_port(port, 0xdeadbeef, &myPort, sizeof(myPort)); 
        
        // wait for an answer 
        ssize_t messageSize = port_buffer_size(myPort); 
        char *message = new char[messageSize]; 
        read_port(myPort, &ignored, message, messageSize); 

        // get the BMessenger out of it 
        BMessage msg; 
        msg.Unflatten(message); 
        msg.FindMessenger("messageTarget", rc); 
        
        return rc; 
}
コード例 #10
0
ファイル: port.c プロジェクト: Mcjesus15/Zio_Other
static DBusMessage *port_disconnect(DBusConnection *conn,
					DBusMessage *msg, void *user_data)
{
	struct serial_device *device = user_data;
	struct serial_port *port;
	const char *dev, *owner, *caller;

	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &dev,
						DBUS_TYPE_INVALID) == FALSE)
		return NULL;

	port = find_port(device->ports, dev);
	if (!port)
		return does_not_exist(msg, "Port does not exist");

	if (!port->listener_id)
		return failed(msg, "Not connected");

	owner = dbus_message_get_sender(port->msg);
	caller = dbus_message_get_sender(msg);
	if (!g_str_equal(owner, caller))
		return failed(msg, "Operation not permited");

	port_release(port);

	g_dbus_remove_watch(conn, port->listener_id);
	port->listener_id = 0;

	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
コード例 #11
0
static int
config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
	image_width = width;
	image_height = height;
	image_depth = 32;
	image_size = (image_width * image_height * image_depth + 7) / 8;
	
	aspect_save_orig(width,height);
    aspect_save_prescale(d_width,d_height);

	//printf("WinID=%d\n",WinID);
	port=find_port("WID:12345");	
	
	if(port==B_NAME_NOT_FOUND || port==B_BAD_VALUE)	{
		haiku_wnd = new MWindow(image_width,image_height, title);
		image_data=(unsigned char *)haiku_wnd->fb->GetBuffer();
		haiku_wnd->Show();
		if(flags&VOFLAG_FULLSCREEN) {    
			vo_fs=1;
	        if(haiku_wnd)
	        	haiku_wnd->SetFullscreen(vo_fs);
		}		
	} else {
		image_data=(unsigned char *)malloc(image_size);
	}
					
	return 0;
}
コード例 #12
0
ファイル: Common.cpp プロジェクト: BackupTheBerlios/textbank
//------------------------------------------------------------------------------
bool	is_asst_running()
{
	bool	aRunning = true;
	BEntry	aEntry;

	try {
		if ( find_port(PORT_NAME_ASST_SPY) < 0 )
			throw B_ERROR;
		if ( find_port(PORT_NAME_ASST_PASTE_SENDER) < 0 )
			throw B_ERROR;
	} catch (...) {
		aRunning = false;
	}
//	DBEXP("is_asst_running",aRunning);
	return aRunning;	
}
コード例 #13
0
ファイル: local.c プロジェクト: haision/GitHub_C
/* send:
 *  Send the given data block down the channel.  `size' is in bytes.
 *  Return zero if successful, otherwise return non-zero.  Don't bother
 *  checking that the packet arrived at the destination though.
 */
static int local_send(NET_CHANNEL *chan, const void *buf, int size)
{
    channel_data_t *data;
    port_t *target;
    packet_t *packet;
    
    if (size > MAX_PACKET_SIZE)
	return -1;
    
    /* Strictly, we should be locking the port's queue, but this will do. */
    MUTEX_LOCK(port_list);

    data = chan->data;
    target = find_port(data->target);
    
    if (target && (next_packet(target->head) != target->tail)) {
	target->head = next_packet(target->head);
    
	packet = &target->packets[target->head];
	packet->from = data->port->num;
	packet->size = size;
	memcpy(packet->data, buf, size);
    }

    /* Errors and successes all end up here, because no delivery
     * checking occurs on channels. */

    MUTEX_UNLOCK(port_list);
    
    return 0;
}
コード例 #14
0
ファイル: CommonTestApp.cpp プロジェクト: mariuz/haiku
// init_connection
status_t
init_connection()
{
	status_t error = B_OK;
	// create a port
	outputPort = create_port(10, "common test app port");
	if (outputPort < 0)
		error = outputPort;
	// find the remote port
	port_id port = -1;
	if (error == B_OK) {
		port = find_port(kAppRunnerTeamPort);
		if (port < 0)
			error = port;
	}
	// send the port ID
	if (error == B_OK) {
		ssize_t written = write_port(port, outputPort, &be_app_messenger,
									 sizeof(BMessenger));
		if (written < 0)
			error = written;
	}
	connectionEstablished = (error == B_OK);
	return error;
}
コード例 #15
0
ファイル: msgport.c プロジェクト: rickcaudill/Pyro
/*****************************************************************************
 * NAME:
 * DESC:
 * NOTE:
 * SEE ALSO:
 ****************************************************************************/
port_id sys_find_port( const char *pzPortname )
{
	port_id hPort;

	hPort = find_port( pzPortname );
	return ( hPort );
}
コード例 #16
0
void
dns_portlist_remove(dns_portlist_t *portlist, int af, in_port_t port) {
	dns_element_t *el;

	REQUIRE(DNS_VALID_PORTLIST(portlist));
	REQUIRE(af == AF_INET || af == AF_INET6);

	LOCK(&portlist->lock);
	if (portlist->active != 0) {
		el = find_port(portlist->list, portlist->active, port);
		if (el != NULL) {
			if (af == AF_INET)
				el->flags &= ~DNS_PL_INET;
			else
				el->flags &= ~DNS_PL_INET6;
			if (el->flags == 0) {
				*el = portlist->list[portlist->active];
				portlist->active--;
				qsort(portlist->list, portlist->active,
				      sizeof(*el), compare);
			}
		}
	}
	UNLOCK(&portlist->lock);
}
コード例 #17
0
ファイル: port.c プロジェクト: Mcjesus15/Zio_Other
int port_register(DBusConnection *conn, const char *path, bdaddr_t *src,
			bdaddr_t *dst, const char *uuid, uint8_t channel)
{
	struct serial_device *device;
	struct serial_port *port;

	device = find_device(devices, path);
	if (!device) {
		device = create_serial_device(conn, path, src, dst);
		if (!device)
			return -1;
		devices = g_slist_append(devices, device);
	}

	if (find_port(device->ports, uuid))
		return 0;

	port = g_new0(struct serial_port, 1);
	port->uuid = g_strdup(uuid);
	port->channel = channel;
	port->device = device;
	port->id = -1;
	port->fd = -1;

	device->ports = g_slist_append(device->ports, port);

	return 0;
}
コード例 #18
0
ファイル: main.cpp プロジェクト: AmirAbrams/haiku
int
main(int argc, char** argv)
{
	gRequestPort = find_port(kPortNameReq);
	if (gRequestPort < B_OK) {
		fprintf(stderr, "%s\n", strerror(gRequestPort));
		return gRequestPort;
	}

	gReplyPort = find_port(kPortNameRpl);
	if (gReplyPort < B_OK) {
		fprintf(stderr, "%s\n", strerror(gReplyPort));
		return gReplyPort;
	}

	return MainLoop();
}
コード例 #19
0
ファイル: BTCoreData.cpp プロジェクト: kallisti5/haiku
status_t
PostEvent(bluetooth_device* ndev, void* event, size_t size)
{
    struct hci_event_header* outgoingEvent = (struct hci_event_header*) event;
    status_t err;

    // Take actions on certain type of events.
    switch (outgoingEvent->ecode) {
    case HCI_EVENT_CONN_COMPLETE:
    {
        struct hci_ev_conn_complete* data
            = (struct hci_ev_conn_complete*)(outgoingEvent + 1);

        // TODO: XXX parse handle field
        HciConnection* conn = AddConnection(data->handle, BT_ACL,
                                            data->bdaddr, ndev->index);

        if (conn == NULL)
            panic("no mem for conn desc");
        conn->ndevice = ndev;
        TRACE("%s: Registered connection handle=%#x\n", __func__,
              data->handle);
        break;
    }

    case HCI_EVENT_DISCONNECTION_COMPLETE:
    {
        struct hci_ev_disconnection_complete_reply* data;

        data = (struct hci_ev_disconnection_complete_reply*)
               (outgoingEvent + 1);

        RemoveConnection(data->handle, ndev->index);
        TRACE("%s: unRegistered connection handle=%#x\n", __func__,
              data->handle);
        break;
    }

    }

    // forward to bluetooth server
    port_id port = find_port(BT_USERLAND_PORT_NAME);
    if (port != B_NAME_NOT_FOUND) {

        err = write_port_etc(port, PACK_PORTCODE(BT_EVENT, ndev->index, -1),
                             event, size, B_TIMEOUT, 1 * 1000 * 1000);

        if (err != B_OK)
            ERROR("%s: Error posting userland %s\n", __func__, strerror(err));

    } else {
        ERROR("%s: bluetooth_server not found for posting!\n", __func__);
        err = B_NAME_NOT_FOUND;
    }

    return err;
}
コード例 #20
0
ファイル: DataExchange.cpp プロジェクト: mariuz/haiku
static void
find_media_addon_server_port()
{
	sMediaAddonServerPort = find_port(MEDIA_ADDON_SERVER_PORT_NAME);
	if (sMediaAddonServerPort < 0) {
		ERROR("couldn't find sMediaAddonServerPort\n");
		sMediaAddonServerPort = BAD_MEDIA_ADDON_SERVER_PORT; // make this a unique number
	}
}
コード例 #21
0
ファイル: uhd_dpdk.c プロジェクト: dkozel/uhd
int uhd_dpdk_set_ipv4_addr(unsigned int portid, uint32_t ipv4_addr, uint32_t netmask)
{
    struct uhd_dpdk_port *p = find_port(portid);
    if (p) {
        p->ipv4_addr = ipv4_addr;
        p->netmask = netmask;
        return 0;
    }
    return -ENODEV;
}
コード例 #22
0
//----------------------------------------------------------------------
static bool out_port_address(ea_t addr)
{
  const char *name = find_port(addr);
  if ( name != NULL )
  {
    out_line(name, COLOR_IMPNAME);
    return true;
  }
  return false;
}
コード例 #23
0
ファイル: lac.c プロジェクト: sevennothing/lros
/*---------------------------------------------------------------------------*/
extern void lac_init_port(Lac_system *system, Port_no port_no,
                          Boolean lacp_enabled)
{
    Lac_port *p;
    if (find_port(system, port_no, &p))
    {
        init_port(p, lacp_enabled);
        enable_port(p);
    }
}
コード例 #24
0
ファイル: uhd_dpdk.c プロジェクト: dkozel/uhd
struct eth_addr uhd_dpdk_get_eth_addr(unsigned int portid)
{
    struct eth_addr retval;
    memset(retval.addr, 0xff, ETHER_ADDR_LEN);

    struct uhd_dpdk_port *p = find_port(portid);
    if (p) {
        memcpy(retval.addr, p->mac_addr.addr_bytes, ETHER_ADDR_LEN);
    }
    return retval;
}
コード例 #25
0
ファイル: AppMisc.cpp プロジェクト: AmirAbrams/haiku
port_id
get_app_server_port()
{
	if (sServerPort < 0) {
		// No need for synchronization - in the worst case, we'll call
		// find_port() twice.
		sServerPort = find_port(SERVER_PORT_NAME);
	}

	return sServerPort;
}
コード例 #26
0
ファイル: beos_stat_cache.c プロジェクト: GustavoMOG/edelib
// get_server_port
static
port_id
get_server_port()
{
	static port_id id = -1;
	static bool initialized = false;
	if (!initialized) {
		id = find_port(STAT_CACHE_SERVER_PORT_NAME);
		initialized = true;
	}
	return id;
}
コード例 #27
0
ファイル: uhd_dpdk.c プロジェクト: EttusResearch/uhd
int uhd_dpdk_port_link_status(unsigned int portid)
{
    if (!ctx)
        return -ENODEV;

    struct uhd_dpdk_port *p = find_port(portid);
    if (p) {
        struct rte_eth_link link;
        rte_eth_link_get_nowait(p->id, &link);
        return link.link_status;
    }
    return -ENODEV;
}
コード例 #28
0
ファイル: port.cpp プロジェクト: mariuz/haiku
port_id
_user_find_port(const char *userName)
{
	char name[B_OS_NAME_LENGTH];

	if (userName == NULL)
		return B_BAD_VALUE;
	if (!IS_USER_ADDRESS(userName)
		|| user_strlcpy(name, userName, B_OS_NAME_LENGTH) < B_OK)
		return B_BAD_ADDRESS;

	return find_port(name);
}
コード例 #29
0
ファイル: nsToolkit.cpp プロジェクト: diversys/bezilla
void nsToolkit::GetInterface()
{
  if(! cached)
  {
    char portname[64];
    PR_snprintf(portname, sizeof(portname), "event%lx", 
                (long unsigned) mGUIThreadID);

    eventport = find_port(portname);

    cached = true;
  }
}
コード例 #30
0
ファイル: l2cap_lower.cpp プロジェクト: yunxiaoxiao110/haiku
status_t
QuitConnectionPurgeThread()
{
    status_t status;

    port_id fPort = find_port(BLUETOOTH_CONNECTION_SCHED_PORT);
    if (fPort != B_NAME_NOT_FOUND)
        close_port(fPort);

    flowf("Connection port deleted\n");
    wait_for_thread(sConnectionThread, &status);
    return status;
}