Beispiel #1
0
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
                              GP_Pixel bmask, GP_Pixel amask,
			      uint8_t bits_per_pixel)
{
	unsigned int i;

	GP_DEBUG(1, "Matching Pixel R %08x G %08x B %08x A %08x size %u",
	            rmask, gmask, bmask, amask, bits_per_pixel);

	for (i = 0; i < GP_PIXEL_MAX; i++) {
		int res;
		const GP_PixelTypeChannel *r, *g, *b, *a;

		if (!GP_PixelHasFlags(i, GP_PIXEL_IS_RGB))
			continue;

		if (GP_PixelTypes[i].size != bits_per_pixel)
			continue;

		r = get_channel(&GP_PixelTypes[i], "R");
		g = get_channel(&GP_PixelTypes[i], "G");
		b = get_channel(&GP_PixelTypes[i], "B");
		a = get_channel(&GP_PixelTypes[i], "A");

		GP_DEBUG(2, "Trying Pixel %s %u",
		         GP_PixelTypes[i].name, bits_per_pixel);

		if (r)
			GP_DEBUG(3, "Matching R %i %i", r->size, r->offset);

		if (g)
			GP_DEBUG(3, "Matching G %i %i", g->size, g->offset);

		if (b)
			GP_DEBUG(3, "Matching B %i %i", b->size, b->offset);

		if (a)
			GP_DEBUG(3, "Matching A %i %i", a->size, a->offset);

		res = match(r, rmask) && match(g, gmask) &&
		      match(b, bmask) && match(a, amask);

		if (res) {
			GP_DEBUG(1, "Pixel found type id %u name '%s'",
			         GP_PixelTypes[i].type, GP_PixelTypes[i].name);
			return GP_PixelTypes[i].type;
		}
	}

	return GP_PIXEL_UNKNOWN;
}
Beispiel #2
0
void send_time(bool is_use_ssl,char *data)
{
	time_t t;
	char *ti;
	char *res;
	char *nick;
	char *channel;

	nick=get_nick(data);
	channel=get_channel(data);
	t=time(NULL);
	ti=ctime(&t);
	if(channel == NULL)
		res=string_add("PRIVMSG %s :%s",nick,ti);
	else
		res=string_add("PRIVMSG %s :%s: %s",channel,nick,ti);
	free(nick);
	null_no_free(channel);

	if(is_use_ssl)
		SSL_write(ssl,res,strlen(res));
	else
		send(sockfd,res,strlen(res),0);

	free(res);
}
Beispiel #3
0
static int8_t par_sensor_control(func_cb_ptr cb, sensor_driver_command_t command, 
			sos_pid_t app_id, sensor_id_t sensor, sample_context_t *param, void *context) {
	par_sensor_state_t *s = (par_sensor_state_t *)sys_get_state();

	// Return if driver is in error state.
	if (s->state == DRIVER_ERROR) return -EINVAL;

	// Get sensor <-> channel mapping for requested sensor
	uint16_t channel = get_channel(sensor, s->map, NUM_SENSORS); 

	// Return if requested sensor is not supported by this driver.
	if (channel == 0) return -EINVAL;

	switch(command) {
		case SENSOR_REGISTER_REQUEST_COMMAND: {
			if (param == NULL) return -EINVAL;
			return sys_adc_get_data(ADC_REGISTER_REQUEST, app_id, channel, param, context); 
		}
		case SENSOR_GET_DATA_COMMAND: {
			if (param == NULL) return -EINVAL;
			return sys_adc_get_data(ADC_GET_DATA, app_id, channel, param, context); 
		}
		case SENSOR_STOP_DATA_COMMAND: {
			return sys_adc_stop_data(app_id, channel);
		}
		default: return -EINVAL;
	}

	return SOS_OK;
}
Beispiel #4
0
int rmd_devmgr_lookup_channel(int driver_type, int device_id, int channel_id,
		driver_t **driver, device_t **device, channel_t **channel)
{
	*driver = rmd_devmgr_get_driver(driver_type);
	if (*driver == NULL)
	{
		syslog(LOG_DEBUG, "driver not found");
		return -1;
	}

	*device = get_device(*driver, device_id);
	if (*device == NULL)
	{
		syslog(LOG_DEBUG, "device:%d not found", device_id);
		return -1;
	}

	*channel = get_channel(*driver, *device, channel_id);
	if (*channel == NULL)
	{
		syslog(LOG_DEBUG, "channel:%d not found", channel_id);
		return -1;
	}
	return 0;
}
Beispiel #5
0
static void	_send_to_channel(t_server *server, int fd,
				 char *chan, char *msg)
{
  t_channel	*tmp;
  int		i;
  t_list	*lst;

  if (!(tmp = get_channel(server->channels, chan)))
    send_code_msg(server, fd, ERR_NOSUCHNICK,
		  create_error_msg(chan, " :No such nick/channel"));
  else if (get_list(tmp->clients, server->client[fd].nick) == tmp->clients)
    send_code_msg(server, fd, ERR_CANNOTSENDTOCHAN,
		  create_error_msg(chan, " :Cannot send to channel"));
  else
    {
      lst = tmp->clients->next;
      while (lst != tmp->clients)
	{
	  i = -1;
	  while (++i < MAX_FD)
	    if (server->type_fd[i] == FD_CLIENT &&
		strcmp(server->client[i].nick, lst->data) == 0)
	      break;
	  if (i != fd)
	    send_info_msg(server, i, server->client[fd].nick, msg);
	  lst = lst->next;
	}
    }
}
Beispiel #6
0
GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
                               uint32_t gsize, uint32_t goff,
			       uint32_t bsize, uint32_t boff,
			       uint32_t asize, uint32_t aoff,
			       uint8_t bits_per_pixel)
{
	unsigned int i;

	GP_DEBUG(1, "Looking up Pixel R %08x %08x G %08x %08x B %08x %08x "
	            "size %u", rsize, roff, gsize, goff, bsize, boff,
	             bits_per_pixel);

	for (i = 0; i < GP_PIXEL_MAX; i++) {
		const GP_PixelTypeChannel *r, *g, *b, *a;

		if (!GP_PixelHasFlags(i, GP_PIXEL_IS_RGB))
			continue;

		if (GP_PixelTypes[i].size != bits_per_pixel)
			continue;

		GP_DEBUG(2, "Trying Pixel %s %u",
		         GP_PixelTypes[i].name, bits_per_pixel);

		r = get_channel(&GP_PixelTypes[i], "R");
		g = get_channel(&GP_PixelTypes[i], "G");
		b = get_channel(&GP_PixelTypes[i], "B");
		a = get_channel(&GP_PixelTypes[i], "A");

		if (a == NULL && asize != 0)
			continue;

		if (a != NULL && (a->offset != aoff || a->size != asize))
			continue;

		if (r->offset == roff && r->size == rsize &&
		    g->offset == goff && g->size == gsize &&
		    b->offset == boff && b->size == bsize) {
			GP_DEBUG(1, "Pixel found type id %u name '%s'",
			         GP_PixelTypes[i].type, GP_PixelTypes[i].name);

			return GP_PixelTypes[i].type;
		 }
	}

	return GP_PIXEL_UNKNOWN;
}
Beispiel #7
0
/*---------------------------------------------------------------------------*/
static radio_result_t
get_value(radio_param_t param, radio_value_t *value)
{
  if(!value) {
    return RADIO_RESULT_INVALID_VALUE;
  }
  switch(param) {
  case RADIO_PARAM_POWER_MODE:
    *value = listen_on || tx_in_progress ? RADIO_POWER_MODE_ON : RADIO_POWER_MODE_OFF;
    return RADIO_RESULT_OK;
  case RADIO_PARAM_CHANNEL:
    *value = get_channel();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_RX_MODE:
    *value = 0;
    if(frame_filtering) {
      *value |= RADIO_RX_MODE_ADDRESS_FILTER;
    }
    if(autoack_enabled) {
      *value |= RADIO_RX_MODE_AUTOACK;
    }
    if(poll_mode) {
      *value |= RADIO_RX_MODE_POLL_MODE;
    }
    return RADIO_RESULT_OK;
  case RADIO_PARAM_TX_MODE:
    *value = 0;
    if(send_on_cca) {
      *value |= RADIO_TX_MODE_SEND_ON_CCA;
    }
    return RADIO_RESULT_OK;
  case RADIO_PARAM_TXPOWER:
    *value = get_txpower();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_RSSI:
    *value = get_rssi();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_LAST_RSSI:
    *value = radio_last_rssi;
    return RADIO_RESULT_OK;
  case RADIO_PARAM_CCA_THRESHOLD:
    *value = cca_thershold;
    return RADIO_RESULT_OK;
  case RADIO_CONST_CHANNEL_MIN:
    *value = 11;
    return RADIO_RESULT_OK;
  case RADIO_CONST_CHANNEL_MAX:
    *value = 26;
    return RADIO_RESULT_OK;
  case RADIO_CONST_TXPOWER_MIN:
    *value = OUTPUT_POWER_MIN;
    return RADIO_RESULT_OK;
  case RADIO_CONST_TXPOWER_MAX:
    *value = OUTPUT_POWER_MAX;
    return RADIO_RESULT_OK;
  default:
    return RADIO_RESULT_NOT_SUPPORTED;
  }
}
Beispiel #8
0
static void start_ppm_frame(void) {
    current_channel = 0;
    frame_time_remaining = FRAME_US;
    for (uint8_t i=0; i<channel_count; i++) {
        frame_times[i] = (1000+get_channel(i));
        frame_time_remaining -= frame_times[i];
    }
}
void
editable_event::analyze ()
{
    midibyte status = get_status();
    if (status >= EVENT_NOTE_OFF && status <= EVENT_PITCH_WHEEL)
    {
        char tmp[32];
        midibyte channel = get_channel();
        midibyte d0, d1;
        get_data(d0, d1);
        category(category_channel_message);
        status = get_status() & EVENT_CLEAR_CHAN_MASK;

        /*
         * Get channel message name (e.g. "Program change");
         */

        m_name_status = value_to_name(status, category_channel_message);
        snprintf(tmp, sizeof tmp, "Chan %d", int(channel));
        m_name_channel = std::string(tmp);
        if (is_one_byte_msg(status))
            snprintf(tmp, sizeof tmp, "Data %d", int(d0));
        else
        {
            if (is_note_msg(status))
            {
                snprintf(tmp, sizeof tmp, "Key %d Vel %d", int(d0), int(d1));
            }
            else
            {
                snprintf
                (
                    tmp, sizeof tmp, "Data %d, %d", int(d0), int(d1)
                );
            }
        }
        m_name_data = std::string(tmp);
    }
    else if (status >= EVENT_MIDI_SYSEX)    //  && status <= EVENT_MIDI_RESET
    {
        category(category_system_message);

        /*
         * Get system message name (e.g. "SysEx start");
         */

        m_name_status = value_to_name(status, category_system_message);
        m_name_channel.clear();
        m_name_data.clear();
    }
    else
    {
        // Would try to detect SysEx versus Meta message versus SeqSpec here.
        // Then set either m_name_meta and/or m_name_seqspec.
    }

}
Beispiel #10
0
double
stp_channel_get_density_adjustment(stp_vars_t *v, int color, int subchannel)
{
  stpi_subchannel_t *sch = get_channel(v, color, subchannel);
  if (sch)
    return sch->s_density / 65535.0;
  else
    return -1;
}
Beispiel #11
0
double
stp_channel_get_cutoff_adjustment(stp_vars_t *v, int color, int subchannel)
{
  stpi_subchannel_t *sch = get_channel(v, color, subchannel);
  if (sch)
    return sch->cutoff;
  else
    return -1.0;
}
Beispiel #12
0
double
stp_channel_get_value(stp_vars_t *v, unsigned color, unsigned subchannel)
{
  stpi_subchannel_t *sch = get_channel(v, color, subchannel);
  if (sch)
    return sch->value;
  else
    return -1;
}
Beispiel #13
0
/*---------------------------------------------------------------------------*/
static radio_result_t
get_value(radio_param_t param, radio_value_t *value)
{
  if(!value) {
    return RADIO_RESULT_INVALID_VALUE;
  }

  switch(param) {
  case RADIO_PARAM_POWER_MODE:
    *value = (REG(RFCORE_XREG_RXENABLE) && RFCORE_XREG_RXENABLE_RXENMASK) == 0
      ? RADIO_POWER_MODE_OFF : RADIO_POWER_MODE_ON;
    return RADIO_RESULT_OK;
  case RADIO_PARAM_CHANNEL:
    *value = (radio_value_t)get_channel();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_PAN_ID:
    *value = get_pan_id();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_16BIT_ADDR:
    *value = get_short_addr();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_RX_MODE:
    *value = 0;
    if(REG(RFCORE_XREG_FRMFILT0) & RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN) {
      *value |= RADIO_RX_MODE_ADDRESS_FILTER;
    }
    if(REG(RFCORE_XREG_FRMCTRL0) & RFCORE_XREG_FRMCTRL0_AUTOACK) {
      *value |= RADIO_RX_MODE_AUTOACK;
    }
    return RADIO_RESULT_OK;
  case RADIO_PARAM_TXPOWER:
    *value = get_tx_power();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_CCA_THRESHOLD:
    *value = get_cca_threshold();
    return RADIO_RESULT_OK;
  case RADIO_PARAM_RSSI:
    *value = get_rssi();
    return RADIO_RESULT_OK;
  case RADIO_CONST_CHANNEL_MIN:
    *value = CC2538_RF_CHANNEL_MIN;
    return RADIO_RESULT_OK;
  case RADIO_CONST_CHANNEL_MAX:
    *value = CC2538_RF_CHANNEL_MAX;
    return RADIO_RESULT_OK;
  case RADIO_CONST_TXPOWER_MIN:
    *value = OUTPUT_POWER_MIN;
    return RADIO_RESULT_OK;
  case RADIO_CONST_TXPOWER_MAX:
    *value = OUTPUT_POWER_MAX;
    return RADIO_RESULT_OK;
  default:
    return RADIO_RESULT_NOT_SUPPORTED;
  }
}
Beispiel #14
0
/* poll_listen:
 *  Here we check for an incoming connection, and if there is one we
 *  fill in `newconn' with our data pointer for it and the addresses,
 *  and return nonzero.  Otherwise return 0.
 */
static int poll_listen (NET_CONN *conn, NET_CONN *newconn)
{
	struct conn_data_t *data;
	char buffer[12], buffer2[8+NET_MAX_ADDRESS_LENGTH] = { 0, 0, 0, 0, 0, 0, 0, 0 };
	char addr[NET_MAX_ADDRESS_LENGTH];
	int x;

	int count = 32; /* maximum number of packets to process */
	while (net_query (((struct conn_data_t *)conn->data)->chan) && count-- > 0) {
		if ((net_receive (((struct conn_data_t *)conn->data)->chan, buffer, 12, addr) == 12) && !memcmp (buffer, "connect", 8)) {
			newconn->data = data = malloc (sizeof *data);
			if (!data) continue;

			if (create_queues (newconn)) {
				free (data);
				continue;
			}

			data->conns = NULL;
			
			x = get_channel (
				((struct conn_data_t *)conn->data)->conns, addr,
				(buffer[8] << 24) + (buffer[9] << 16) +
				(buffer[10] << 8) + buffer[11],
				conn->type, NULL, &data->chan, data
			);
			
			if (x) {
				data->referer = conn->data;

				/* tell new channel where to send in future */
				net_assigntarget (data->chan, addr);

				/* send reply now with address of new channel, through
				 * listening conn so it can get through NATs */
				net_assigntarget (((struct conn_data_t *)conn->data)->chan, addr);
				strcpy (buffer2+8, net_getlocaladdress (data->chan));
				net_send (((struct conn_data_t *)conn->data)->chan, buffer2, 8+NET_MAX_ADDRESS_LENGTH);
			}
			
			if (x >= 0) {
				destroy_queues (newconn);
				free (data);
				continue;
			}

			strcpy (newconn->peer_addr, addr);

			return 1;
		}
	}

	return 0;
}
Beispiel #15
0
void
stp_channel_set_cutoff_adjustment(stp_vars_t *v, int color, int subchannel,
				  double adjustment)
{
  stpi_subchannel_t *sch = get_channel(v, color, subchannel);
  stp_dprintf(STP_DBG_INK, v,
	      "channel_cutoff channel %d subchannel %d adjustment %f\n",
	      color, subchannel, adjustment);
  if (sch && adjustment >= 0)
    sch->cutoff = adjustment;
}
Beispiel #16
0
/*
 * m_part - generic message handler
 *
 * parv[0] = sender prefix
 * parv[1] = channel
 * parv[parc - 1] = comment
 */
int m_part(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  struct Channel *chptr;
  struct Membership *member;
  struct JoinBuf parts;
  unsigned int flags = 0;
  char *p = 0;
  char *name;

  ClrFlag(sptr, FLAG_TS8);

  /* check number of arguments */
  if (parc < 2 || parv[1][0] == '\0')
    return need_more_params(sptr, "PART");

  /* init join/part buffer */
  joinbuf_init(&parts, sptr, cptr, JOINBUF_TYPE_PART,
	       (parc > 2 && !EmptyString(parv[parc - 1])) ? parv[parc - 1] : 0,
	       0);

  /* scan through channel list */
  for (name = ircd_strtok(&p, parv[1], ","); name;
       name = ircd_strtok(&p, 0, ",")) {

    chptr = get_channel(sptr, name, CGT_NO_CREATE); /* look up channel */

    if (!chptr) { /* complain if there isn't such a channel */
      send_reply(sptr, ERR_NOSUCHCHANNEL, name);
      continue;
    }

    if (!(member = find_member_link(chptr, sptr))) { /* complain if not on */
      send_reply(sptr, ERR_NOTONCHANNEL, chptr->chname);
      continue;
    }

    assert(!IsZombie(member)); /* Local users should never zombie */

    if (!member_can_send_to_channel(member, 0))
    {
      flags |= CHFL_BANNED;
      /* Remote clients don't want to see a comment either. */
      parts.jb_comment = 0;
    }

    if (IsDelayedJoin(member))
      flags |= CHFL_DELAYED;

    joinbuf_join(&parts, chptr, flags); /* part client from channel */
  }

  return joinbuf_flush(&parts); /* flush channel parts */
}
void PPMReceiver::execute(void){
	uint8_t i;
	uint16_t channel_val;

	for(i=0; i<6; i++){
		channel_val = channel_table[i]->get_pulse_lenght();

		if(channel_val < PLM_RECEIVER_MAX_PULSE &&
		   channel_val > PLM_RECEIVER_MIN_PULSE ){
			//Update channel:
			channel_values[i] = channel_val;
			last_update_timestamp[i] = Time.get_timestamp();
		}
	}

	sorted_channel_values.throttle = get_channel(CHANNEL_THROTTLE);
	sorted_channel_values.pitch    = get_channel(CHANNEL_PITCH);
	sorted_channel_values.roll     = get_channel(CHANNEL_ROLL);
	sorted_channel_values.yaw 	   = get_channel(CHANNEL_YAW);
	sorted_channel_values.aux1 	   = get_channel(CHANNEL_AUX1);
	sorted_channel_values.aux2     = get_channel(CHANNEL_AUX2);

	update_status();
	if(calibrating) calibrate();
}
Beispiel #18
0
void set_anonops (char *f) {

	if (edit_channel==1) {

		get_channel(get_bot(thebots,1), 1)->anonops = 1 ;

	} else {

		printf("Error parsing configuration file (line %d) - Can't define AnonOps ouuside a NewChannel/EndChannel definition.\n", line)

	}

}
/**
 * Get the message queue (#GNUNET_MQ_Handle) of a specific peer.
 *
 * If we already have a message queue open to this client,
 * simply return it, otherways create one.
 *
 * @param peer the peer to get the mq to
 * @return the #GNUNET_MQ_Handle
 */
static struct GNUNET_MQ_Handle *
get_mq (const struct GNUNET_PeerIdentity *peer)
{
  struct PeerContext *peer_ctx;

  peer_ctx = get_peer_ctx (peer);

  if (NULL == peer_ctx->mq)
  {
    (void) get_channel (peer);
    peer_ctx->mq = GNUNET_CADET_mq_create (peer_ctx->send_channel);
  }
  return peer_ctx->mq;
}
Beispiel #20
0
void set_chanlog (char *f) {

	if (edit_channel==1) {

		sscanf (f, "%s ", temp_line);
		strcpy ( get_channel(get_bot (thebots,1), 1)->logfile, temp_line);

	} else {

		printf("Error parsing configuration file (line %d) - Can't define Channel_Log ouuside a NewChannel/EndChannel definition.\n", line);

	}

}
Beispiel #21
0
int
Mavlink::configure_stream(const char *stream_name, const float rate)
{
	/* calculate interval in us, 0 means disabled stream */
	unsigned int interval = (rate > 0.0f) ? (1000000.0f / rate) : 0;

	/* search if stream exists */
	MavlinkStream *stream;
	LL_FOREACH(_streams, stream) {
		if (strcmp(stream_name, stream->get_name()) == 0) {
			if (interval > 0) {
				/* set new interval */
				stream->set_interval(interval);

			} else {
				/* delete stream */
				LL_DELETE(_streams, stream);
				delete stream;
				warnx("deleted stream %s", stream->get_name());
			}

			return OK;
		}
	}

	if (interval == 0) {
		/* stream was not active and is requested to be disabled, do nothing */
		return OK;
	}

	/* search for stream with specified name in supported streams list */
	for (unsigned int i = 0; streams_list[i] != nullptr; i++) {

		if (strcmp(stream_name, streams_list[i]->get_name()) == 0) {
			/* create new instance */
			stream = streams_list[i]->new_instance();
			stream->set_channel(get_channel());
			stream->set_interval(interval);
			stream->subscribe(this);
			LL_APPEND(_streams, stream);

			return OK;
		}
	}

	/* if we reach here, the stream list does not contain the stream */
	warnx("stream %s not found", stream_name);

	return ERROR;
}
Beispiel #22
0
/*
 * get_proto
 *
 * returns -1 if error
 */
int get_proto(struct MPIR_COMMUNICATOR *comm, int src_lrank)
{
    int rc;

    if (src_lrank == MPI_ANY_SOURCE)
	rc = (comm->vmpi_only ? mpi : unknown);
    else
    {
	if (src_lrank >= 0 && src_lrank < comm->np)
	{
	    int src_grank = comm->lrank_to_grank[src_lrank];
	    struct channel_t *cp;

	    if (!(cp = get_channel(src_grank)))
	    {
		rc = -1;
		globus_libc_fprintf(stderr, 
		    "ERROR: get_proto: proc %d failed get_channel "
		    "for src_grank %d\n",
		    MPID_MyWorldRank, src_grank);
		print_channels();
	    }
	    else if (!(cp->selected_proto))
	    {
		rc = -1;
		globus_libc_fprintf(stderr, 
		    "ERROR: get_proto: proc %d has NULL selected protocol "
		    "for src_grank %d\n",
		    MPID_MyWorldRank, src_grank);
		print_channels();
	    } 
	    else
		rc = (cp->selected_proto)->type;
	}
	else
	{
	    rc = -1;
	    globus_libc_fprintf(stderr,
		"ERROR: get_proto: src_lrank %d out of bounds for communicator "
		"with %d procs\n",
		src_lrank, 
		comm->np);
	} /* endif */
    } /* endif */

    return rc;

} /* end get_proto() */
Beispiel #23
0
char MySniff::cfg_chann(char *channels)
{
	int tmp;
	uint8_t default_channels[]=
	{
		1, 7, 13, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12, 0
		//1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0
	};
	
	if (is_offline() != 0){
		xlog_err(LEVEL1,parent,"Alert","Can't set channels in offline mode");
		return -1;
	}
	
	if ((settings & XSNIFF_SETTING_IS_SET_INTERFACE) == 0){
		xlog_err(LEVEL2,parent,"Alert","First you must configure interface!");
		return -1;
	}
	
	if (channels==NULL){
		if (init_default_channels(default_channels) < 0){
			xlog_err(LEVEL2,parent,"Alert","Can't init default channels");
			return -1;
		}
		
	}else{
		if (parse_own_channels(channels)<0){
			xlog_err(LEVEL2,parent,"Alert","Can't parse channels. You must enter just positive numbers (lower than 255) and comas Eg: 1,2,3,4,5");
			return -1;
		}
	}
	
	tmp=verify_freq();
	if (tmp!=0){
		if (tmp>0){
			xlog_err(LEVEL2,parent,"Alert","Unsuported channel %d (%d MHz)",get_channel(tmp-1),get_freq(tmp-1));
			return -1;
		}else{
			xlog_err(LEVEL2,parent,"Alert","Can't set channels");
			return -1;
		}
	}
		
	settings = settings | XSNIFF_SETTING_IS_SET_FREQ; 
	
	return 0;
	
}
Beispiel #24
0
void set_endchannel (char *f)
{

    struct Channel *mychan;

    if (edit_channel==1)
    {

        mychan= get_channel ( get_bot(thebots,1), 1);

        if ( mychan->channel[0]=='\0')
        {

            printf("Error parsing configuration file (line %d) - Channel name not defined!\n", line);
            cfg_error=1;

        }

        if ( mychan->userfile[0]=='\0')
        {

            printf("Error parsing configuration file (line %d) - Userfile not defined!\n", line);
            cfg_error=1;

        }

        if ( mychan->logfile[0]=='\0')
        {

            printf("Error parsing configuration file (line %d) - Channel_Log not defined!\n", line);
            cfg_error=1;

        }

        edit_channel=0;

    }
    else
    {

        printf("Error parsing configuration file (line %d) - Found EndChannel before NewChannel.\n", line);
        cfg_error=1;

    }

}
Beispiel #25
0
/**
 * Add channel into channel proxy list
 */
static guint64 add_channel(const char *path, const char *device, int fd,
						gboolean initiated_by_us)
{
	DBusGProxy *proxy;
	GIOChannel *gio;

	gio = g_io_channel_unix_new(fd);
	g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
		       data_received, NULL);

	channel_object *c = get_channel(path);
	if (c) {
		c->fd = fd;
		return 0;
	}

	proxy = dbus_g_proxy_new_for_name(conn, "org.bluez", path,
					  "org.bluez.HealthChannel");

	c = (channel_object *) g_new(channel_object, 1);
	c->path = g_strdup(path);
	c->device = g_strdup(device);
	c->proxy = proxy;
	c->fd = fd;
	c->initiated_by_us = initiated_by_us;

	llist_add(channels(), c);

	device_object *dev = get_device_object(device);
	if (dev) {
		c->first = (++dev->channels == 1);
		if (c->first) {
			c->handle = ++last_handle;
			dev->first_handle = c->handle;
			return c->handle;
		} else {
			c->handle = dev->first_handle;
			return 0;
		}
	} else {
		ERROR("unknown dev %s", device);
	}

	return 0;
}
Beispiel #26
0
/*
 * ms_part - server message handler
 *
 * parv[0] = sender prefix
 * parv[1] = channel
 * parv[parc - 1] = comment
 */
int ms_part(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  struct Channel *chptr;
  struct Membership *member;
  struct JoinBuf parts;
  unsigned int flags;
  char *p = 0;
  char *name;

  ClrFlag(sptr, FLAG_TS8);

  /* check number of arguments */
  if (parc < 2 || parv[1][0] == '\0')
    return need_more_params(sptr, "PART");

  /* init join/part buffer */
  joinbuf_init(&parts, sptr, cptr, JOINBUF_TYPE_PART,
	       (parc > 2 && !EmptyString(parv[parc - 1])) ? parv[parc - 1] : 0,
	       0);

  /* scan through channel list */
  for (name = ircd_strtok(&p, parv[1], ","); name;
       name = ircd_strtok(&p, 0, ",")) {

    flags = 0;

    chptr = get_channel(sptr, name, CGT_NO_CREATE); /* look up channel */

    if (!chptr || IsLocalChannel(name) ||
	!(member = find_member_link(chptr, sptr)))
      continue; /* ignore from remote clients */

    if (IsZombie(member)) /* figure out special flags... */
      flags |= CHFL_ZOMBIE;

    if (IsDelayedJoin(member))
      flags |= CHFL_DELAYED;

    /* part user from channel */
    joinbuf_join(&parts, chptr, flags);
  }

  return joinbuf_flush(&parts); /* flush channel parts */
}
Beispiel #27
0
static void
event_part(irc_session_t *session, const char *event, const char *nick,
		const char **params, unsigned int count) {
	const char *channel_name = params[0];
	if (count < 1) return;
	irc_t *irc = get_module(session);
	if (irc->current_nick && !strcmp(irc->current_nick, nick)) {
		// we left
	} else {
		// someone else left
		if (debug) {
			printf("Parted (%s): %s\n", channel_name, nick);
		}

		// Update our internal list of members of the channel
		channel_t *channel = get_channel(irc, channel_name);
		channel_remove_nick(channel, nick);
	}
}
Beispiel #28
0
int  irc_server_cmd_part(t_srv *s, t_usr* u, char** cmd)
{
  t_chn *channel;
  int r;

  if (!cmd[1])
    return (server_send(u->s, ERR_NEEDMOREPARAMS));
  if (u->n == NULL)
    return (server_send(u->s, ERR_NOLOGIN));
  if (((channel = get_channel(s->c, cmd[1])) == NULL))
    return (server_send(u->s, ERR_NOSUCHCHANNEL));
  else if (is_in_chan(channel, u))
  {
    if (!(r = remove_user_from_chan(s->c, u, (cmd[2] ? cmd[2] : P_MSG))))
      remove_chan(s, channel);
    u->c = NULL;
    return (EXIT_SUCCESS);
  }
  return (server_send(u->s, ERR_NOTONCHANNEL));
}
Beispiel #29
0
static void
event_join(irc_session_t *session, const char *event, const char *nick,
		const char **params, unsigned int count) {
	const char *channel_name = params[0];
	if (count < 1) return;
	irc_t *irc = get_module(session);
	if (irc->current_nick && !strcasecmp(irc->current_nick, nick)) {
		// so we joined
		// good for us
	} else {
		// someone else joined
		if (debug) {
			printf("Joined (%s): %s\n", channel_name, nick);
		}

		// Update our internal list of members of the channel
		channel_t *channel = get_channel(irc, channel_name);
		channel_add_nick(channel, nick);
	}
}
Beispiel #30
0
/**
 * Takes care of channel closure, when initiative is remote
 */
static void channel_closed(const char *path)
{
	channel_object *c = get_channel(path);
	device_object *d;

	if (!c)
		return;

	d = get_device_object(c->device);

	if (c->first) {
		// notifies higher layers
		if (d) {
			device_disconnected(c->handle, d->addr);
		} else {
			ERROR("Unknown device: %s", c->device);
			device_disconnected(c->handle, c->device);
		}
	}

	disconnect_channel(c->handle, 1);
}