Beispiel #1
0
void MapMgr::_UnloadOldTiles(void)
{
    for(int32 gy=0; gy<64; gy++)
    {
        for(int32 gx=0; gx<64; gx++)
        {
            if( (int32(_gridx) < gx-1 || int32(_gridx) > gx+1) && (int32(_gridy) < gy-1 || int32(_gridy) > gy+1) )
            {
                if(_tiles->GetTile(gx,gy))
                {
                    logdebug("MAPMGR: Unloading old MapTile (%u, %u) map %u",gx,gy,_mapid);
                    _tiles->UnloadMapTile(gx,gy);
                }
            }
        }
    }
}
Beispiel #2
0
static int
kbd_probe_lmu(void)
{
  int fd;
  int ret;
  char buffer[4];

  ret = kbd_get_lmuaddr();
  if (ret < 0)
    return -1;

  ret = kbd_get_i2cdev();
  if (ret < 0)
    return -1;

  fd = open(lmu_info.i2cdev, O_RDWR);
  if (fd < 0)
    {
      logmsg(LOG_WARNING, "Could not open device %s: %s", lmu_info.i2cdev, strerror(errno));

      return -1;
    }

  ret = ioctl(fd, I2C_SLAVE, lmu_info.lmuaddr);
  if (ret < 0)
    {
      logmsg(LOG_ERR, "ioctl failed on %s: %s", lmu_info.i2cdev, strerror(errno));

      close(fd);
      return -1;
    }

  ret = read(fd, buffer, 4);
  if (ret != 4)
    {
      logmsg(LOG_WARNING, "Probing failed on %s: %s", lmu_info.i2cdev, strerror(errno));

      close(fd);
      return -1;
    }
  close(fd);

  logdebug("Probing successful on %s\n", lmu_info.i2cdev);

  return 0;
}
Beispiel #3
0
int unix_socket (char* path)
{
#if !defined( HAVE_SYS_UN_H )
    UNREFERENCED(path);
    WRMSG (HHC01032, "E");
    return -1;
#else // defined( HAVE_SYS_UN_H )

    struct sockaddr_un addr;
    int sd;

    logdebug ("unix_socket(%s)\n", path);

    if (strlen (path) > sizeof(addr.sun_path) - 1)
    {
        WRMSG (HHC01033, "E", path, (int) sizeof(addr.sun_path) - 1);
        return -1;
    }

    addr.sun_family = AF_UNIX;
    strlcpy( addr.sun_path, path,sizeof(addr.sun_path) ); /* guaranteed room by above check */
    sd = socket (PF_UNIX, SOCK_STREAM, 0);

    if (sd == -1)
    {
        WRMSG (HHC01034, "E", "socket()", strerror(HSO_errno));
        return -1;
    }

    unlink (path);
    fchmod (sd, 0700);

    if (0
            || bind (sd, (struct sockaddr*) &addr, sizeof(addr)) == -1
            || listen (sd, 0) == -1
       )
    {
        WRMSG (HHC01034, "E", "bind()", strerror(HSO_errno));
        return -1;
    }

    return sd;

#endif // !defined( HAVE_SYS_UN_H )
}
/* fork and exec a child process with netexec. Close the given file descriptor
   in the parent process. Return the child's PID or -1 on error. */
int netrun(struct fdinfo *info, char *cmdexec)
{
    int pid;

    errno = 0;
    pid = fork();
    if (pid == 0) {
        /* In the child process. */
        netexec(info, cmdexec);
    }

    Close(info->fd);

    if (pid == -1 && o.verbose)
        logdebug("Error in fork: %s\n", strerror(errno));

    return pid;
}
Beispiel #5
0
/** Destroy the Buffer chain of a BufferedWriter
 *
 * \param self pointer to the BufferedWriter
 * \return 0 on success, or a negative number otherwise
 */
int
destroyBufferChain(BufferedWriter* self) {
  BufferChain *chain, *start;

  if (!self)
    return -1;

  /* BufferChain is a circular buffer */
  start = self->firstChain;
  while( (chain = self->firstChain) && chain!=start) {
    logdebug("Destroying BufferChain at %p\n", chain);
    self->firstChain = chain->next;
    mbuf_destroy(chain->mbuf);
    xfree(chain);
  }

  return 0;
}
Beispiel #6
0
/** Called to close the socket
 * \see oml_outs_close_f
 */
static int
net_stream_close(OmlOutStream* stream)
{
    OmlNetOutStream* self = (OmlNetOutStream*)stream;

    logdebug("%s: Destroying OmlNetOutStream at %p\n", self->dest, self);

    if (self->socket != 0) {
        socket_close(self->socket);
        self->socket = NULL;
    }
    oml_free(self->dest);
    oml_free(self->host);
    oml_free(self->protocol);
    oml_free(self->service);
    oml_free(self);
    return 0;
}
Beispiel #7
0
ilb_status_t
i_ilbd_save_rule(ilbd_rule_t *irl, ilbd_scf_cmd_t scf_cmd)
{
	boolean_t enable = irl->irl_flags & ILB_FLAGS_RULE_ENABLED;

	switch (scf_cmd) {
	case ILBD_SCF_CREATE:
		return (ilbd_create_pg(ILBD_SCF_RULE, (void *)irl));
	case ILBD_SCF_DESTROY:
		return (ilbd_destroy_pg(ILBD_SCF_RULE, irl->irl_name));
	case ILBD_SCF_ENABLE_DISABLE:
		return (ilbd_change_prop(ILBD_SCF_RULE, irl->irl_name,
		    "status", &enable));
	default:
		logdebug("i_ilbd_save_rule: invalid scf cmd %d", scf_cmd);
		return (ILB_STATUS_INVAL_CMD);
	}
}
Beispiel #8
0
static void __customErrorFunc(void *userdata, virErrorPtr err)
{
    if (err->code == VIR_ERR_NO_DOMAIN) {
        logdebug(_("domain not found\n"));
        return;
    }

    logprintf("Failure of libvirt library call:\n");
    logsimple("  Code: %d\n", err->code);
    logsimple("  Domain: %d\n", err->domain);
    logsimple("  Message: %s\n", err->message);
    logsimple("  Level: %d\n", err->level);
    logsimple("  str1: %s\n", err->str1);
    logsimple("  str2: %s\n", err->str2);
    logsimple("  str3: %s\n", err->str3);
    logsimple("  int1: %d\n", err->int1);
    logsimple("  int2: %d\n", err->int2);
}
Beispiel #9
0
static ilb_status_t
ilbd_destroy_one_rule(ilbd_rule_t *irl)
{
	ilb_status_t	rc;
	ilb_name_cmd_t	kcmd;

	/*
	 * as far as talking to the kernel is concerned, "all rules"
	 * is handled in one go somewhere else, so we only
	 * tell the kernel about single rules here.
	 */
	if ((irl->irl_flags & ILB_FLAGS_RULE_ALLRULES) == 0) {
		kcmd.cmd = ILB_DESTROY_RULE;
		(void) strlcpy(kcmd.name, irl->irl_name, sizeof (kcmd.name));
		kcmd.flags = 0;

		rc = do_ioctl(&kcmd, 0);
		if (rc != ILB_STATUS_OK)
			return (rc);

	}
	list_remove(&irl->irl_sg->isg_rulelist, irl);
	list_remove(&ilbd_rule_hlist, irl);

	/*
	 * When dissociating a rule, only two errors can happen.  The hc
	 * name is incorrect or the rule is not associated with the hc
	 * object.  Both should not happen....  The check is for debugging
	 * purpose.
	 */
	if (RULE_HAS_HC(irl) && (rc = ilbd_hc_dissociate_rule(irl)) !=
	    ILB_STATUS_OK) {
		logerr("ilbd_destroy_one_rule: cannot "
		    "dissociate %s from hc object %s: %d",
		    irl->irl_name, irl->irl_hcname, rc);
	}

	rc = i_ilbd_save_rule(irl, ILBD_SCF_DESTROY);
	if (rc != ILB_STATUS_OK)
		logdebug("ilbd_destroy_rule: save rule failed");

	free(irl);
	return (rc);
}
Beispiel #10
0
/* node register and authtication */
static int __node_register_auth(NodeInfo * nf, int ent_id)
{
    if (nf->host_tag <= 0) {
        logerror(_("error in %s(%d)\n"), __func__, __LINE__);
        return -1;
    }

    int ret = -1;
    DBNodeRegInfo db_nf;
    bzero(&db_nf, sizeof(DBNodeRegInfo));

    int found = db_node_find(DB_NODE_FIND_BY_ID, &nf->host_tag, &db_nf);
    if (found == 1) {
        logdebug(_("tagged node found in db(%d %s %d %d)\n"),
                    db_nf.id, db_nf.ip, db_nf.status, db_nf.enabled);
        if (!ly_entity_is_authenticated(ent_id)) {
            logwarn(_("authentication is required for node(%d, %s)\n"),
                      nf->host_tag, nf->host_ip);
            goto out;
        }
        if (strcmp(nf->host_ip, db_nf.ip) != 0)
            logwarn(_("tagged node ip changed from %s to %s\n"),
                       db_nf.ip, nf->host_ip);

        nf->cpu_vlimit = db_nf.cpu_vlimit;
        nf->mem_vlimit = db_nf.mem_vlimit;
        ly_entity_enable(ent_id, db_nf.id, db_nf.enabled);
        ret = LY_S_REGISTERING_DONE_SUCCESS;
    }
    else if (found == 0) {
        logwarn(_("invalid tag for node(%d, %s), re-registration needed\n"),
                  nf->host_tag, nf->host_ip);
        ret = LY_S_REGISTERING_REINIT;
        goto out;
    }
    else {
        logerror(_("error in %s(%d)\n"), __func__, __LINE__);
        goto out;
    }

out:
    db_node_reginfo_free(&db_nf);
    return ret;
}
Beispiel #11
0
/* process xml packet from node */
int eh_process_node_xml(char * xml, int ent_id)
{
    logdebug(_("%s called\n"), __func__);
    /* logdebug("%s\n", xml); */

    int ret = 0;
    xmlDoc *doc = xml_doc_from_str(xml);
    if (doc == NULL) {
        /* error: could not parse xml string */
        logerror(_("unrecognized node packet data\n%s\n"), xml);
        return -1;
    }
    xmlNode * node = xmlDocGetRootElement(doc);
    if (node == NULL || strcmp((char *)node->name, LYXML_ROOT) != 0) {
        /* error: xml string not for "LYXML_ROOT" */
        logerror(_("unrecognized node packet data\n%s\n"), xml);
        return -1;
    }

    node = node->children;

    for (; node; node = node->next) {
        if (node->type == XML_ELEMENT_NODE) {
            if (strcmp((char *)node->name, "response") == 0 ) {
                ret = __process_node_xml_response(doc, node, ent_id);
                if (ret  < 0)
                    break;
            }
            else if (strcmp((char *)node->name, "request") == 0 ) {
                ret = __process_node_xml_request(doc, node, ent_id);
                if (ret  < 0)
                    break;
            }
            else if (strcmp((char *)node->name, "report") == 0 ) {
                ret = __process_node_xml_report(doc, node, ent_id);
                if (ret  < 0)
                    break;
            }
            /* other nodes ignored */
        }
    }
    xmlFreeDoc(doc);
    return ret;
}
Beispiel #12
0
/** Setup the PostgreSQL backend.
 *
 * \return 0 on success, -1 otherwise
 */
int
psql_backend_setup ()
{
  MString *str, *conninfo;

  loginfo ("psql: Sending experiment data to PostgreSQL server %s:%s as user '%s'\n",
           pg_host, pg_port, pg_user);

  conninfo = psql_prepare_conninfo("postgres", pg_host, pg_port, pg_user, pg_pass, pg_conninfo);
  PGconn *conn = PQconnectdb (mstring_buf (conninfo));

  if (PQstatus (conn) != CONNECTION_OK) {
    logerror ("psql: Could not connect to PostgreSQL database (conninfo \"%s\"): %s\n",
         mstring_buf(conninfo), PQerrorMessage (conn));
    mstring_delete(conninfo);
    return -1;
  }

  /* oml2-server must be able to create new databases, so check that
     our user has the required role attributes */
  str = mstring_create();
  mstring_sprintf (str, "SELECT rolcreatedb FROM pg_roles WHERE rolname='%s'", pg_user);
  PGresult *res = PQexec (conn, mstring_buf (str));
  mstring_delete(str);
  if (PQresultStatus (res) != PGRES_TUPLES_OK) {
    logerror ("psql: Failed to determine role privileges for role '%s': %s\n",
         pg_user, PQerrorMessage (conn));
    return -1;
  }
  char *has_create = PQgetvalue (res, 0, 0);
  if (strcmp (has_create, "t") == 0)
    logdebug ("psql: User '%s' has CREATE DATABASE privileges\n", pg_user);
  else {
    logerror ("psql: User '%s' does not have required role CREATE DATABASE\n", pg_user);
    return -1;
  }

  mstring_delete(conninfo);
  PQclear (res);
  PQfinish (conn);

  return 0;
}
Beispiel #13
0
/* Read from a client socket and write to stdout. Return the number of bytes
   read from the socket, or -1 on error. */
int read_socket(int recv_fd)
{
    char buf[DEFAULT_TCP_BUF_LEN];
    struct fdinfo *fdn;
    int nbytes, pending;

    fdn = get_fdinfo(&client_fdlist, recv_fd);
    ncat_assert(fdn != NULL);

    nbytes = 0;
    do {
        int n;

        n = ncat_recv(fdn, buf, sizeof(buf), &pending);
        if (n <= 0) {
            if (o.debug)
                logdebug("Closing connection.\n");
#ifdef HAVE_OPENSSL
            if (o.ssl && fdn->ssl) {
                if (nbytes == 0)
                    SSL_shutdown(fdn->ssl);
                SSL_free(fdn->ssl);
            }
#endif
            close(recv_fd);
            FD_CLR(recv_fd, &master_readfds);
            rm_fd(&client_fdlist, recv_fd);
            FD_CLR(recv_fd, &master_broadcastfds);
            rm_fd(&broadcast_fdlist, recv_fd);

            conn_inc--;
            if (get_conn_count() == 0)
                FD_CLR(STDIN_FILENO, &master_readfds);

            return n;
        }

        Write(STDOUT_FILENO, buf, n);
        nbytes += n;
    } while (pending);

    return nbytes;
}
Beispiel #14
0
/** Destroy a filter and free its memory.
 *
 * This function is designed so it can be used in a while loop to clean up the
 * entire linked list:
 *
 *   while( (f=destroy_ms(f)) );
 *
 * \param f pointer to the filter to destroy
 * \returns f->next (can be NULL)
 */
OmlFilter *destroy_filter(OmlFilter* f) {
  OmlFilter *next;
  if (!f)
    return NULL;

  logdebug("Destroying filter %s at %p\n", f->name, f);

  next = f->next;

  if(f->result) {
    oml_value_array_reset(f->result, f->output_count);
    oml_free(f->result);
  }
  if(f->instance_data)
    oml_free(f->instance_data);
  oml_free(f);

  return next;
}
Beispiel #15
0
/* process xml report */
static int __process_node_xml_report(xmlDoc * doc, xmlNode * node, int ent_id)
{
    loginfo(_("node report for entity %d\n"), ent_id);

    int node_id = ly_entity_db_id(ent_id);
    int status = -1;
    node = node->children;
    for (; node; node = node->next) {
        if (node->type == XML_ELEMENT_NODE) {
            if (strcmp((char *)node->name, "status") == 0) {
                if (node->children != NULL &&
                    node->children->type == XML_TEXT_NODE) {
                    status = atoi((char *)node->children->content);
                    logwarn(_("node %d report status %d\n"),
                               node_id, status);
                }
                else {
                    logerror(_("error in %s(%d)\n"), __func__, __LINE__);
                    return -1;
                }
            }
            else if (strcmp((char *)node->name, "message") == 0) {
                if (node->children != NULL && 
                    node->children->type == XML_TEXT_NODE) {
                    logwarn(_("node %d report message %s\n"),
                               node_id, node->children->content);
                }
            }
            else if (strcmp((char *)node->name, "resource") == 0) {
                 logdebug(_("node %d report resource\n"), node_id);
                 __node_resource_update(doc, node, ent_id);
            }
        }
    }

    NodeInfo *nf = ly_entity_data(ent_id);
    if (nf != NULL && status != -1) {
        nf->status = status;
        loginfo(_("update node status to %d from report\n"), status);
    }

    return 0;
}
Beispiel #16
0
static int __print_config(NodeConfig *c)
{
    logdebug("NodeControl :\n"
             "  clc_ip = %s\n" "  clc_port = %d\n"
             "  clc_mcast_ip = %s\n" "  clc_mcast_port = %d\n"
             "  auto_connect = %d\n"
             "  node_data_dir = %s\n"
             "  conf_path = %s\n"
             "  sysconf_path = %s\n"
             "  log_path = %s\n"
             "  verbose = %d\n" "  debug = %d\n" "  daemon = %d\n",
             c->clc_ip, c->clc_port,
             c->clc_mcast_ip, c->clc_mcast_port,
             c->auto_connect,
             c->node_data_dir, c->conf_path, c->sysconf_path, c->log_path,
             c->verbose, c->debug, c->daemon);

    return 0;
}
Beispiel #17
0
void
stdin_handler(SockEvtSource* source, void* handle, void* buf, int buf_size)
{
  Session *proxy = (Session*)handle;
  char command[80];
  (void)source;
  strncpy (command, buf, 80);

  if (buf_size < 80 && command[buf_size-1] == '\n')
    command[buf_size-1] = '\0';

  printf ("Received command: %s\n", command);
  logdebug ("Received command: %s\n", command);

  if ((strcmp (command, "OMLPROXY-RESUME") == 0) ||
      (strcmp (command, "RESUME") == 0)) {
    proxy->state = ProxyState_SENDING;
  } else if (strcmp (command, "OMLPROXY-STOP") == 0 ||
             strcmp (command, "STOP") == 0) {
    proxy->state = ProxyState_STOPPED;
  } else if (strcmp (command, "OMLPROXY-PAUSE") == 0 ||
             strcmp (command, "PAUSE") == 0) {
    proxy->state = ProxyState_PAUSED;
  }

  /*
   * If we're in sending state, wake up the client sender threads
   * so that they will start sending to the downstream server.  We do
   * this even if the state was already ProxyState_SENDING because
   * some of the clients might have dropped back to idle due to
   * disconnection from the upstream server.
   */
  if (session->state == ProxyState_SENDING) {
    Client *current = session->clients;
    while (current) {
      pthread_mutex_lock (&current->mutex);
      pthread_cond_signal (&current->condvar);
      pthread_mutex_unlock (&current->mutex);
      current = current->next;
    }
  }
}
Beispiel #18
0
/**
 * @brief Execute an SQL statement (using PQexec()).
 *
 * This function executes a statement with the assumption that the
 * result can be ignored; that is, it's not useful for SELECT
 * statements.
 *
 * @param self the database handle.
 * @param stmt the SQL statement to execute.
 * @return 0 if successful, -1 if the database reports an error.
 */
static int
sql_stmt(PsqlDB* self, const char* stmt)
{
  PGresult   *res;
  logdebug("psql: Will execute '%s'\n", stmt);
  res = PQexec(self->conn, stmt);

  if (PQresultStatus(res) != PGRES_COMMAND_OK) {
    logerror("psql: Error executing '%s': %s\n", stmt, PQerrorMessage(self->conn));
    PQclear(res);
    return -1;
  }
  /*
   * Should PQclear PGresult whenever it is no longer needed to avoid memory
   * leaks
   */
  PQclear(res);

  return 0;
}
Beispiel #19
0
/* ACPI Lid switch */
static int
evdev_is_lidswitch(unsigned short *id)
{
  unsigned short product = id[ID_PRODUCT];

  if (id[ID_BUS] != BUS_HOST)
    return 0;

  if (id[ID_VENDOR] != 0)
    return 0;

  if (product == 0x0005)
    {
      logdebug(" -> ACPI LID switch\n");

      return 1;
    }

  return 0;
}
Beispiel #20
0
/* Mouseemu virtual keyboard */
static int
evdev_is_mouseemu(unsigned short *id)
{
  unsigned short product = id[ID_PRODUCT];

  if (id[ID_BUS] != BUS_VIRTUAL)
    return 0;

  if (id[ID_VENDOR] != 0x001f)
    return 0;

  if (product == 0x001f)
    {
      logdebug(" -> Mouseemu virtual keyboard\n");

      return 1;
    }

  return 0;
}
Beispiel #21
0
int
evdev_init(void)
{
  int ret;
  int i;

  char evdev[32];

  int ndevs;
  int fd;

  internal_kbd_fd = -1;

  ndevs = 0;
  for (i = 0; i < EVDEV_MAX; i++)
    {
      ret = snprintf(evdev, 32, "%s%d", EVDEV_BASE, i);

      if ((ret <= 0) || (ret > 31))
	return -1;

      fd = open(evdev, O_RDWR);
      if (fd < 0)
	{
	  if (errno != ENOENT)
	    logmsg(LOG_WARNING, "Could not open %s: %s", evdev, strerror(errno));

	  continue;
	}

      if (evdev_try_add(fd) == 0)
	ndevs++;
    }

  logdebug("\nFound %d devices\n", ndevs);

  /* Initialize inotify */
  evdev_inotify_init();

  return ndevs;
}
Beispiel #22
0
static void
sysfs_backlight_set(int value)
{
  FILE *fp;

  if (bck_driver == SYSFS_DRIVER_NONE)
    return;

  fp = fopen(brightness[bck_driver], "a");
  if (fp == NULL)
    {
      logmsg(LOG_WARNING, "Could not open sysfs brightness node: %s", strerror(errno));

      return;
    }

  fprintf(fp, "%d", value);

  fclose(fp);
logdebug("sole opened file = %s, wrote %d\n", brightness[bck_driver], value);
}
Beispiel #23
0
/* Apple Remote IR Receiver */
static int
evdev_is_appleir(unsigned short *id)
{
  unsigned short product = id[ID_PRODUCT];

  if (id[ID_BUS] != BUS_USB)
    return 0;

  if (id[ID_VENDOR] != USB_VENDOR_ID_APPLE)
    return 0;

  if ((product == USB_PRODUCT_ID_APPLEIR)
      || (product == USB_PRODUCT_ID_APPLEIR_2))
    {
      logdebug(" -> Apple IR receiver\n");

      return 1;
    }

  return 0;
}
Beispiel #24
0
static int __print_config(CLCConfig * c)
{
    logdebug("CLCConfig :\n"
             "  clc_ip = %s\n" "  clc_port = %d\n"
             "  clc_mcast_ip = %s\n" "  clc_mcast_port = %d\n"
             "  conf_path = %s\n"
             "  log_path = %s\n"
             "  DB info = %s,%s,%s\n"
             "  factor = %d,%d\n"
             "  vm_name_prefix = %s\n"
             "  verbose = %d\n" "  debug = %d\n" "  daemon = %d\n",
             c->clc_ip, c->clc_port,
             c->clc_mcast_ip, c->clc_mcast_port,
             c->conf_path, c->log_path,
             c->db_name, c->db_user, c->db_pass,
             c->node_cpu_factor, c->node_mem_factor,
             c->vm_name_prefix,
             c->verbose, c->debug, c->daemon);

    return 0;
}
Beispiel #25
0
void
kbd_set_fnmode(void)
{
  char *fnmode_node[] =
    {
      "/sys/module/hid_apple/parameters/fnmode", /* 2.6.28 & up */
      "/sys/module/hid/parameters/pb_fnmode",    /* 2.6.20 & up */
      "/sys/module/usbhid/parameters/pb_fnmode"
    };
  FILE *fp;
  int i;

  if ((general_cfg.fnmode < 1) || (general_cfg.fnmode > 2))
    general_cfg.fnmode = 1;

  for (i = 0; i < sizeof(fnmode_node) / sizeof(*fnmode_node); i++)
    {
      logdebug("Trying %s\n", fnmode_node[i]);

      fp = fopen(fnmode_node[i], "a");
      if (fp != NULL)
	break;

      if (errno == ENOENT)
	continue;

      logmsg(LOG_INFO, "Could not open %s: %s", fnmode_node[i], strerror(errno));
      return;
    }

  if (!fp)
    {
      logmsg(LOG_INFO, "Could not set fnmode: no sysfs node found!");
      return;
    }

  fprintf(fp, "%d", general_cfg.fnmode);

  fclose(fp);
}
Beispiel #26
0
/* MacBookPro10,1 (15" 2012)
 */
static int
evdev_is_apple_internal_keyboard(unsigned short *id)
{
  unsigned short product = id[ID_PRODUCT];

  if (id[ID_BUS] != BUS_USB)
    return 0;

  if (id[ID_VENDOR] != USB_VENDOR_ID_APPLE)
    return 0;

  if ((product == USB_PRODUCT_ID_APPLE_INTERNAL_KEYBOARD_ANSI))
    {
      logdebug(" -> Apple Internal Keyboard USB assembly\n");

      kbd_set_fnmode();

      return 1;
    }

  return 0;
}
Beispiel #27
0
/* MacBookPro10,2 (13" 2012)
 */
static int
evdev_is_wellspring6(unsigned short *id)
{
  unsigned short product = id[ID_PRODUCT];

  if (id[ID_BUS] != BUS_USB)
    return 0;

  if (id[ID_VENDOR] != USB_VENDOR_ID_APPLE)
    return 0;

  if ((product == USB_PRODUCT_ID_WELLSPRING6_ANSI))
    {
      logdebug(" -> WellSpring VI USB assembly\n");

      kbd_set_fnmode();

      return 1;
    }

  return 0;
}
Beispiel #28
0
/* Apple external USB keyboard, white */
static int
evdev_is_extkbd_white(unsigned short *id)
{
  unsigned short product = id[ID_PRODUCT];

  if (id[ID_BUS] != BUS_USB)
    return 0;

  if (id[ID_VENDOR] != USB_VENDOR_ID_APPLE)
    return 0;

  if (product == USB_PRODUCT_ID_APPLE_EXTKBD_WHITE)
    {
      logdebug(" -> External Apple USB keyboard (white)\n");

      kbd_set_fnmode();

      return 1;
    }

  return 0;
}
/* Match a (user-supplied) hostname against a (certificate-supplied) name, which
   may be a wildcard pattern. A wildcard pattern may contain only one '*', it
   must be the entire leftmost component, and there must be at least two
   components following it. len is the length of pattern; pattern may contain
   null bytes so that len != strlen(pattern). */
static int wildcard_match(const char *pattern, const char *hostname, size_t len)
{
    if (pattern[0] == '*' && pattern[1] == '.') {
        /* A wildcard pattern. */
        const char *p, *h, *dot;

        /* Skip the wildcard component. */
        p = pattern + 2;

        /* Ensure there are no more wildcard characters. */
        if (memchr(p, '*', len - 2) != NULL)
            return 0;

        /* Ensure there's at least one more dot, not counting a dot at the
           end. */
        dot = strchr(p, '.');
        if (dot == NULL || *(dot + 1) == '\0') {
            if (o.debug > 1) {
                logdebug("Wildcard name \"%s\" doesn't have at least two"
                    " components after the wildcard; rejecting.\n", pattern);
            }
            return 0;
        }

        /* Skip the leftmost hostname component. */
        h = strchr(hostname, '.');
        if (h == NULL)
            return 0;
        h++;

        /* Compare what remains of the pattern and hostname. */
        return len == strlen(h) + (p - pattern) && strcmp(p, h) == 0;
    } else {
        /* Normal string comparison. Check the name length because I'm concerned
           about someone somehow embedding a '\0' in the subject and matching
           against a shorter name. */
        return len == strlen(hostname) && strcmp(pattern, hostname) == 0;
    }
}
Beispiel #30
0
void PseuGUI::Cancel(void)
{
    DEBUG(logdebug("PseuGUI::Cancel()"));

    if(_scene)
    {
        _scene->OnDelete();
        delete _scene;
        _scene = NULL;
    }
    if(_device)
    {
        _device->drop();
        _device = NULL;
    }
    if(_soundengine)
    {
        _soundengine->drop();
        _soundengine = NULL;
    }
    _mustdie = true;
}