Ejemplo n.º 1
0
static int do_set_param(Request *req)
{
	u8 *name = g_buffer;
	char *content = (char *)g_buffer;
	int retv = 0;
	Section * section;
	Ack ack;

	retv = receive_text(name, req->dataSize);
	name[req->dataSize] = 0;
	APP_INFO("Section Name is : %s\n", (char *)name);
	section = find_section((char *)name);
	ack.info = ack.result = (NULL == section) ? -1 : 0;
	retv = send_text((u8 *)&ack, sizeof(ack));
	if (ack.result == -1) {
		APP_INFO("Section [%s] is not found!\n", (char *)name);
		return -1;
	}

	// Receive parameter settings
	retv = receive_text((u8 *)content, req->info);
	content[req->info] = 0;
	if (0) {
		APP_INFO("===== Parameter Setting is : \n%s", content);
	} else {
		APP_INFO("===== Parameter Setting is : \n%s", content);
		retv = mw_config_params(section->map, content);
		retv = (*section->set)(section->name);
		ack.result = ack.info = retv;
	}
	retv = send_text((u8 *)&ack, sizeof(ack));
	return retv;
}
Ejemplo n.º 2
0
static int do_get_param(Request *req)
{
	u8 *name = g_buffer;
	char *content = (char *)g_buffer;
	int retv = 0;
	Section * section;
	Ack ack;

	// Get section name
	retv = receive_text(name, req->dataSize);
	name[req->dataSize] = 0;
	APP_INFO("Section Name is : %s\n", (char *)name);

	section = find_section((char *)name);
	if (NULL == section) {
		ack.result = -1;
		ack.info = -1;
		APP_INFO("Section [%s] is not found!\n", (char *)name);
		return send_text((u8 *)&ack, sizeof(ack));
	} else {
		retv = (*section->get)(section->name, req->info);
		retv = mw_output_params(section->map, &content);
		APP_INFO("\n%s\n", content);
		ack.result = retv;
		ack.info = strlen(content);
		send_text((u8 *)&ack, sizeof(ack));
		return send_text((u8 *)content, ack.info);
	}
}
Ejemplo n.º 3
0
int hash_map(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    char map_name[80]="";
    int map_id;

    if(sscanf(text, "%*s *s")==-1){

        //if no tail specified in command, default to current map
        map_id=clients.client[actor_node].map_id;
    }
    else if(sscanf(text, "%*s %[^\n]", map_name)==1){

        map_id=get_map_id(map_name);

        if(map_id==-1){

            send_text(socket, CHAT_SERVER, "%cMap does not exist", c_red3+127);
            return 0;
        }
    }
    else {

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #MAP [map_name] or #MAP", c_red3+127);
        return 0;
    }

    get_map_details(actor_node, map_id);
    get_map_developer_details(actor_node, map_id);

    return 0;
}
Ejemplo n.º 4
0
int hash_set_map_development_status(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    int development_status=0;
    int map_id;

    //extract data from text string
    if(sscanf(text, "%*s %i %i", &map_id, &development_status)!=2){

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #SET_MAP_DEVELOPMENT_STATUS [map id] [map development status 0-2]", c_red3+127);
        return 0;
    }

    //check map exists
    if(strlen(maps.map[map_id].elm_filename)==0){

        send_text(socket, CHAT_SERVER, "%cthat map id does not exist", c_red3+127);
        return 0;
    }

    //update map array
    maps.map[map_id].development_status=development_status;

    //update database
    push_sql_command("UPDATE MAP_TABLE SET STATUS=%i WHERE MAP_ID=%i", maps.map[map_id].development_status, map_id);

    send_text(socket, CHAT_SERVER, "%cyou changed the development status of map %i to %i", c_green3+127, map_id, maps.map[map_id].development_status);

    return 0;
}
Ejemplo n.º 5
0
void main ()
{
	get_text();

	send_text(1,line1);
	send_text(2,line2);
}
Ejemplo n.º 6
0
int hash_set_map_name(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    char map_name[80]="";
    int map_id;

    if(sscanf(text, "%*s %i %[^\n]", &map_id, map_name)!=2){

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #SET_MAP_NAME [map id] [map name]", c_red3+127);
        return 0;
    }

    //check map exists
    if(strlen(maps.map[map_id].elm_filename)==0){

        send_text(socket, CHAT_SERVER, "%cthat map id does not exist", c_red3+127);
        return 0;
    }

    //update map array
    strcpy(maps.map[map_id].map_name, map_name);

    //update database
    push_sql_command("UPDATE MAP_TABLE SET MAP_NAME='%s' WHERE MAP_ID=%i", maps.map[map_id].map_name, map_id);

    send_text(socket, CHAT_SERVER, "%cyou changed the name of map %i to %s", c_green3+127, map_id, maps.map[map_id].map_name);

    return 0;
}
Ejemplo n.º 7
0
__interrupt void interr_P1(void){
    
    P1OUT ^= 0x01;              // Sinalizar interrupção
  
    flag_pisca ^= 1;		// Inverte flag_pisca
    if (flag_pisca == 1){
        // Enviar msg pela serial
        send_text("Botton ON\n");
    }		
    else{
        // Enviar msg pela serial
        send_text("Botton OFF\n");
        
        itoa(int_buffer_ADC10, char_buffer_ADC10, 10);          // int to char base 10
        send_text(char_buffer_ADC10);
        send_byte('\n');
    }
    
    P1IFG = 0x00;		// Zera a flag de interrupção da porta 1
    
    // DEBAUNCING
    __delay_cycles(8000);	// delay de 1ms
    x = 1;			// garante que irá entrar no while
    
    while(x == 1)
    if((P1IN & 0x08) == 0){     // testa se o botão p1.3 está pressionado
        x = 0;		        // muda estatus de x para sair do while
    }
    else{			// se não estiver pressionado volta a conferir
        x = 1;
    }
    __delay_cycles(8000);	// delay de 1ms
    
}
Ejemplo n.º 8
0
gboolean full_char_proc(KeySym keysym)
{
  char *s = half_char_to_full_char(keysym);

  if (!s)
    return 0;

  char tt[CH_SZ+1];

  utf8cpy(tt, s);

  if (current_CS->im_state  == HIME_STATE_ENG_FULL) {
    send_text(tt);
    return 1;
  }

  if (current_method_type() == 6 && current_CS->im_state == HIME_STATE_CHINESE)
    add_to_tsin_buf_str(tt);
  else
  if (gtab_phrase_on() && ggg.gbufN)
    insert_gbuf_nokey(tt);
  else
    send_text(tt);

  return 1;
}
Ejemplo n.º 9
0
int hash_cp(int actor_node, char *text) {

    /** public function - see header */

    (void)(text);

    int socket=clients.client[actor_node].socket;

    int active_chan_slot=clients.client[actor_node].active_chan;

    if(active_chan_slot==0){

        send_text(socket, CHAT_SERVER, "%cNo active channel", c_red3+127);
        return 0;
    }

    int chan_id=clients.client[socket].chan[active_chan_slot-31];

    send_text(socket, CHAT_SERVER, "%cListing for channel [%i]: %s", c_blue1+127, chan_id, channels.channel[chan_id].channel_name);
    send_text(socket, CHAT_SERVER, "%cDescription: %s", c_blue1+127, channels.channel[chan_id].description);
    send_text(socket, CHAT_SERVER, "%cCharacters in channel...", c_blue1+127);

    for(int i=0; i<MAX_ACTORS; i++){

        if(clients.client[i].client_node_status==CLIENT_NODE_USED && clients.client[i].player_type==PLAYER){

            if(player_in_chan(i, chan_id)!=-1){

                send_text(socket, CHAT_SERVER, "%c%s ", c_blue1+127, clients.client[i].char_name);
            }
        }
    }

    return 0;
}
Ejemplo n.º 10
0
int hash_track(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    char on_off[4]="";

    if(sscanf(text, "%*s %s", on_off)!=1){

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #TRACK [ON / OFF]", c_red3+127);
        return 0;
    }

    str_conv_upper(on_off);

    if(strcmp(on_off, "ON")==0) {

        send_text(socket, CHAT_SERVER, "%cposition tracking 'on'", c_green3+127);
        clients.client[actor_node].debug_status=DEBUG_TRACK;
    }

    else if(strcmp(on_off, "OFF")==0) {

        send_text(socket, CHAT_SERVER, "%cposition tracking 'off'", c_green3+127);
        clients.client[actor_node].debug_status=DEBUG_OFF;
    }

    else {

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #TRACK [ON / OFF]", c_red3+127);
        return 0;
    }

    return 0;
}
Ejemplo n.º 11
0
int hash_set_map_author_email(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    char map_author_email[80]="";
    int map_id;

    //extract data from text string
    if(sscanf(text, "%*s %i %s", &map_id, map_author_email)!=2){

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #SET_MAP_AUTHOR_EMAIL [map id] [map author email address]", c_red3+127);
        return 0;
    }

    //check map exists
    if(strlen(maps.map[map_id].elm_filename)==0){

        send_text(socket, CHAT_SERVER, "%cthat map id does not exist", c_red3+127);
        return 0;
    }

    //update map array
    strcpy(maps.map[map_id].author_email, map_author_email);

    //update database
    push_sql_command("UPDATE MAP_TABLE SET AUTHOR_EMAIL='%s' WHERE MAP_ID=%i", maps.map[map_id].author_email, map_id);

    send_text(socket, CHAT_SERVER, "%cyou changed the author email of map %i to %s", c_green3+127, map_id, maps.map[map_id].author_email);

    return 0;
}
Ejemplo n.º 12
0
int hash_trace(int actor_node, char *text) {

    /** public function - see header */

    (void)(text);

    int socket=clients.client[actor_node].socket;
    int map_id=clients.client[actor_node].map_id;
    int map_axis=maps.map[map_id].map_axis;

    int pos_x=clients.client[actor_node].map_tile % map_axis;
    int pos_y=clients.client[actor_node].map_tile / map_axis;

    send_text(socket, CHAT_SERVER, "%cwalkable tile trace (@=%i/%i)", c_green3+127, pos_x, pos_y);

    for(int x=pos_x-20; x<pos_x+20; x++){

        char str[81]="";

        for(int y=pos_y-40; y<pos_y+40; y++){

            int z=(y * map_axis) + x;

            if(z==clients.client[actor_node].map_tile){

                fprintf(stderr, "@");
                strcat(str, "@");
            }
            else {

                if(y>=0 && y<map_axis && x>=0 && x<map_axis){

                    if(maps.map[map_id].height_map[z]==NON_TRAVERSABLE_TILE){

                        fprintf(stderr, "#");
                        strcat(str, "#");
                    }
                    else{

                        fprintf(stderr, ".");
                        strcat(str, ".");
                    }
                }
                else{
                    fprintf(stderr, ":");
                    strcat(str, ":");
                }
            }
        }

        send_text(socket, CHAT_SERVER, "%c%s", c_grey1+127, str);
        fprintf(stderr, "\n");
    }

    return 0;
}
Ejemplo n.º 13
0
void static emit()
{
  send_text("Received:");
  char  text[2+1];
  text[2] = '\0';
  while ( received_data_is_waiting() )
  {
    send_text(" 0x");
    u8_to_hex( next_received_char(), text);
    send_text( text);
  }
  send_text("\r\n");
}
Ejemplo n.º 14
0
MAV_RESULT GCS_MAVLINK_Tracker::handle_command_long_packet(const mavlink_command_long_t &packet)
{
    // do command
    send_text(MAV_SEVERITY_INFO,"Command received: ");

    switch(packet.command) {

    case MAV_CMD_COMPONENT_ARM_DISARM:
        if (is_equal(packet.param1,1.0f)) {
            tracker.arm_servos();
            return MAV_RESULT_ACCEPTED;
        }
        if (is_zero(packet.param1))  {
            tracker.disarm_servos();
            return MAV_RESULT_ACCEPTED;
        }
        return MAV_RESULT_UNSUPPORTED;

    case MAV_CMD_DO_SET_SERVO:
        if (!tracker.servo_test_set_servo(packet.param1, packet.param2)) {
            return MAV_RESULT_FAILED;
        }
        return MAV_RESULT_ACCEPTED;

        // mavproxy/mavutil sends this when auto command is entered 
    case MAV_CMD_MISSION_START:
        tracker.set_mode(AUTO, MODE_REASON_GCS_COMMAND);
        return MAV_RESULT_ACCEPTED;

    default:
        return GCS_MAVLINK::handle_command_long_packet(packet);
    }
}
Ejemplo n.º 15
0
static int do_aaa_control(Request *req)
{
	int retv = 0;
	Ack ack;

	APP_INFO("Process AAA control id [%d].\n", (int)req->info);
	switch (req->info) {
	case AAA_START:
		retv = mw_start_aaa(fd_iav);
		if (retv < 0) {
			APP_ERROR("mw_start_aaa failed!\n");
		}
		APP_INFO("AAA control : Start AAA done !\n");
		break;
	case AAA_STOP:
		retv = mw_stop_aaa();
		APP_INFO("AAA control : Stop AAA done !\n");
		break;
	default:
		APP_PRINTF("Unknown AAA control id [%d]\n", (int)req->info);
		break;
	}
	ack.result = ack.info = retv;
	retv = send_text((u8 *)&ack, sizeof(ack));

	return retv;
}
Ejemplo n.º 16
0
/**
  * @brief  This function handles Hard Fault exception.
  * @param  None
  * @retval None
  */
void HardFault_Handler(void)
{
	send_text( "Hard Fault.\n" );
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)
  {
  }
}
Ejemplo n.º 17
0
/**
  * @brief  This function handles Memory Manage exception.
  * @param  None
  * @retval None
  */
void MemManage_Handler(void)
{
	send_text( "MemRange Fault.\n" );

  /* Go to infinite loop when Memory Manage exception occurs */
  while (1)
  {
  }
}
Ejemplo n.º 18
0
void *text_reader_thread(void *args)
{
    char line[200];
    while(true) {
    	scanf("%s", line);
    	if (text_reader_active)
    		send_text(line);
    }
    return NULL;
}
Ejemplo n.º 19
0
void send_utf8_ch(char *bchar)
{
  char tt[CH_SZ+1];
  int len = utf8_sz(bchar);

  memcpy(tt, bchar, len);
  tt[len]=0;

  send_text(tt);
}
Ejemplo n.º 20
0
int hash_cl(int actor_node, char *text) {

    /** public function - see header */

    (void)(text);

    int socket=clients.client[actor_node].socket;

    send_text(socket, CHAT_SERVER, "\n%cNo   Channel    Description", c_blue1+127);

    for(int i=0; i<MAX_CHANNELS; i++){

        if(channels.channel[i].chan_type!=CHAN_VACANT) {

            send_text(socket, CHAT_SERVER, "%c%i %s %-10s %-30s", c_blue1+127, i, "  ", channels.channel[i].channel_name, channels.channel[i].description);
        }
    }

    return 0;
}
Ejemplo n.º 21
0
void packet_scan(uint8_t *data, uint8_t length)
{
	if (length > 0)
	{
		switch (data[0])
		{
			case 0:
				send_text("%d", adc_z_new);
				break;
		}
	}
}
Ejemplo n.º 22
0
Archivo: ctcp.c Proyecto: srfrog/epic5
/*
 * This is no longer directly sends information to its target.
 * As part of a larger attempt to consolidate all data transmission
 * into send_text, this function was modified so as to use send_text().
 * This function can send both direct CTCP requests, as well as the
 * appropriate CTCP replies.  By its use of send_text(), it can send
 * CTCPs to DCC CHAT and irc nickname peers, and handles encryption
 * transparantly.  This greatly reduces the logic, complexity, and
 * possibility for error in this function.
 */
void	send_ctcp (int type, const char *to, int datatag, const char *format, ...)
{
	char 	putbuf [BIG_BUFFER_SIZE + 1],
		*putbuf2;
	int	len;
	int	l;
	const char *pb;
	char	*extra = NULL;

	/* Make sure that the final \001 doesnt get truncated */
	if ((len = IRCD_BUFFER_SIZE - (12 + strlen(to))) <= 0)
		return;				/* Whatever. */
	putbuf2 = alloca(len);

	l = message_from(to, LEVEL_CTCP);
	if (format)
	{
		va_list args;
		va_start(args, format);
		vsnprintf(putbuf, BIG_BUFFER_SIZE, format, args);
		va_end(args);

		pb = outbound_recode(to, from_server, putbuf, &extra);

		do_hook(SEND_CTCP_LIST, "%s %s %s %s", 
				ctcp_type[type], to, 
				ctcp_cmd[datatag].name, pb);
		snprintf(putbuf2, len, "%c%s %s%c", 
				CTCP_DELIM_CHAR, 
				ctcp_cmd[datatag].name, pb, 
				CTCP_DELIM_CHAR);

		new_free(&extra);
	}
	else
	{
		do_hook(SEND_CTCP_LIST, "%s %s %s", 
				ctcp_type[type], to, 
				ctcp_cmd[datatag].name);
		snprintf(putbuf2, len, "%c%s%c", 
				CTCP_DELIM_CHAR, 
				ctcp_cmd[datatag].name, 
				CTCP_DELIM_CHAR);
	}

	/* XXX - Ugh.  What a hack. */
	putbuf2[len - 2] = CTCP_DELIM_CHAR;
	putbuf2[len - 1] = 0;

	send_text(from_server, to, putbuf2, ctcp_type[type], 0, 1);
	pop_message_from(l);
}
Ejemplo n.º 23
0
void send_verbose_date(int socket, int game_days){

    /** public function - see header */

    int game_year=game_data.game_days / 360;
    int year_days=game_data.game_days % 360;

    char season_name[80]="";
    char season_description[160]="";
    get_game_season(year_days, season_name, season_description);

    send_text(socket, CHAT_SERVER, "%cThe day is %02i in the season of %s, year %i", 127+c_purple1, game_days, season_name, game_year);
}
Ejemplo n.º 24
0
void
GCS_MAVLINK::send_text_P(gcs_severity severity, const prog_char_t *str)
{
    mavlink_statustext_t m;
    uint8_t i;
    for (i=0; i<sizeof(m.text); i++) {
        m.text[i] = pgm_read_byte((const prog_char *)(str++));
        if (m.text[i] == '\0') {
            break;
        }
    }
    if (i < sizeof(m.text)) m.text[i] = 0;
    send_text(severity, (const char *)m.text);
}
Ejemplo n.º 25
0
static void putstr_inp(char *p)
{
  clear_page_label();

//  dbg("gtab_hide_row2 %d\n", gtab_hide_row2);
  hide_row2_if_necessary();

  char_play(p);

  int to_tsin = (cur_inmd->flag & FLAG_GTAB_SYM_KBM) && inmd[default_input_method].method_type==method_type_TSIN && tss.c_len;

  if (utf8_str_N(p) > 1  || !(p[0]&128)) {
    if ((gtab_disp_key_codes && !gtab_hide_row2) || ggg.wild_mode)
      lookup_gtabn(p, NULL);
    if (to_tsin) {
      add_to_tsin_buf_str(p);
    }
    else
      send_text(p);
  }
  else {
    if (poo.same_pho_query_state == SAME_PHO_QUERY_gtab_input) {
      poo.same_pho_query_state = SAME_PHO_QUERY_pho_select;
      start_gtab_pho_query(p);

      ClrIn();
      ClrSelArea();
      return;
    }

    if ((gtab_disp_key_codes && !gtab_hide_row2) || ggg.wild_mode)
      lookup_gtab(p);

    if (to_tsin)
      add_to_tsin_buf_str(p);
    else
      send_utf8_ch(p);
  }

  clear_after_put();

  if ((cur_inmd->flag & FLAG_GTAB_SYM_KBM)) {
    extern int win_kbm_inited, b_show_win_kbm;
    init_in_method(default_input_method);
    if (win_kbm_inited && !b_show_win_kbm)
      hide_win_kbm();
  }
}
Ejemplo n.º 26
0
int hash_lc(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    int chan_id=0;

    if(sscanf(text, "%*s %i", &chan_id)!=1){

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #LC [channel number]", c_red3+127);
        return 0;
    }

    leave_channel(actor_node, chan_id);
    return 0;
}
Ejemplo n.º 27
0
void keyPress(unsigned char key, int mousex, int mousey) 
{
	switch (key) {
	case 13: 
		messages.push_back("You: "+msg);
		send_text(msg);
		msg = "";
		break;
	case 8:
		if (msg.size() > 0) { msg.pop_back(); }
		break;
	default:
		msg += key;
	}
	glutPostRedisplay();
}
Ejemplo n.º 28
0
void GCS_MAVLINK::handle_param_request_list(mavlink_message_t *msg)
{
    mavlink_param_request_list_t packet;
    mavlink_msg_param_request_list_decode(msg, &packet);

    // send system ID if we can
    char sysid[40];
    if (hal.util->get_system_id(sysid)) {
        send_text(MAV_SEVERITY_WARNING, sysid);
    }

    // Start sending parameters - next call to ::update will kick the first one out
    _queued_parameter = AP_Param::first(&_queued_parameter_token, &_queued_parameter_type);
    _queued_parameter_index = 0;
    _queued_parameter_count = AP_Param::count_parameters();
}
Ejemplo n.º 29
0
int hash_pm(int actor_node, char *text) {

    /** public function - see header */

    int socket=clients.client[actor_node].socket;
    char char_name[MAX_CHAR_NAME_LEN]="";
    char message[1024]="";

    if(sscanf(text, "%*s %s %[^\n]", char_name, message)!=2){

        send_text(socket, CHAT_SERVER, "%cyou need to use the format #PM [character name][message]", c_red3+127);
        return 0;
    }

    send_pm(actor_node, char_name, message);
    return 0;
}
Ejemplo n.º 30
0
/***************************************************************************
 * Function: void flush_output()
 *
 * Description:
 *   Use select() to determine which connections that have output pending
 * are capable of accepting output at the moment, and send as much data to
 * those connections as they will accept.
 **************************************************************************/
void flush_output() {
  conn_data *conn;
  fd_set fd_outset;
  struct timeval sel_timeout;
  iterator *conn_iter = create_iter(conn_list);;

/*
 * Clear out the fd_set and add to it the fds of all connections with
 * output pending.
 */
  FD_ZERO(&fd_outset);
  for (init_iter(conn_iter); (conn = peek_iter(conn_iter));
       iterate_iter(conn_iter)) {
    if (length_list(conn->output) != 0) FD_SET(conn->fd, &fd_outset);
  }

/*
 * Use select to determine which fds actually belong in the set.
 * (NOFILE is the maximum number of open files per process, as described
 * previously)
 */
  bzero(&sel_timeout, sizeof(struct timeval));
  if (select(NOFILE, NULL, &fd_outset, NULL, &sel_timeout) <0 ) {
    fprintf(stderr, "Error: Selection of ready file descriptors failed.\n");
    perror("  flush_output(select)");
    exit(ERROR);
  }

/*
 * Process connections with pending output.  Note that it is necessary to
 * iterate the iterator _before_ executing the loop in case the connection
 * we're currently working on gets disconnected.
 */
  for (init_iter(conn_iter); (conn = peek_iter(conn_iter)); ) {
    iterate_iter(conn_iter);

    if (FD_ISSET(conn->fd, &fd_outset)) {
      if (send_text(conn) <= 0) {
        disconnect(conn);
        continue;
      }
    }
  }

  destroy_iter(conn_iter);
}