예제 #1
0
파일: pf_o.c 프로젝트: gbourgeo/42projects
void		pf_o(t_dt *data)
{
	t_av	av;
	int		len;

	av.ui = get_modifier(data);
	av.s = ft_itoa_base(av.ui, 8);
	av.len = ft_strlen(av.s) + data->flag.hash;
	len = (data->flag.precision > av.len) ? data->flag.precision : av.len;
	print_zero_space(data, &av);
	if (*data->tail == 'o')
	{
		if (data->flag.hash || !data->flag.point || av.ui)
			write_str(data, av.s, av.len - data->flag.hash);
	}
	else if (!data->flag.point || *(data->flag.point + 1) != '0')
		write_str(data, av.s, av.len - data->flag.hash);
	if (data->flag.minus)
	{
		while (data->flag.min_width > len && data->flag.min_width--)
			write_char(data, ' ');
	}
	if (av.s)
		free(av.s);
}
예제 #2
0
파일: shou.c 프로젝트: 18959263172/hardware
uchar nRF24L01_RxPacket(uchar *rx_buf)
{	 
    uchar revale=0;
	SPI_Write_Buf(WRITE_REG + RX_ADDR_P0,RX_ADDRESS, RX_ADR_WIDTH);
	CE=0;
	SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f);   		// IRQ收发完成中断响应,16位CRC	,主接收
	CE = 1; 
	inerDelay_us(130);
	sta=SPI_Read(STATUS);     // 读取状态寄存其来判断数据接收状况
	if(RX_DR)				// 判断是否接收到数据
	{
	    CE = 0; 			//SPI使能
		SPI_Read_Buf(RD_RX_PLOAD,rx_buf,RX_PLOAD_WIDTH);// read receive payload from RX_FIFO buffer
		revale =1;			//读取数据完成标志
						write_com(0x80);
						write_str("   Hum");
						write_data(':');
						write_data(rx_buf[1]/10%10+48);
						write_data(rx_buf[1]%10+48);
						
						write_data('%');
						write_com(0x80+0x40);
						write_str("   Tem");
						write_data(':');
						write_data(rx_buf[2]/10%10+48);
						write_data(rx_buf[2]%10+48);
                        write_data(0xdf);
						write_data('c');
				
	}
	SPI_RW_Reg(WRITE_REG+STATUS,sta);   //接收到数据后RX_DR,TX_DS,MAX_PT都置高为1,通过写1来清楚中断标志
	return revale;
}
예제 #3
0
void pars_beep(void) {
    switch (pars_number()) {
        case MSG_BEEPBEEP:
            if (strncmp(config->nick, packet, NICK_MAXLEN)) break;
            strncpy(status->nick, pars_word(), NICK_MAXLEN);
            if (user_ignore()) break;
            snprintf(message, MSG_SIZE, PARS_BEEP, time_get(), status->nick);
            if (config->verbose) {
                write_log(config->log_main);
                write_str(status->room->name, COL_MESG);
            }
            if ((config->mode == MOD_NORMAL) || (config->mode == MOD_DND) ||
                    ((config->mode == MOD_AWAY) && user_favorite())) {
                make_beepack();
                beep_beep();
            }
            break;
        case MSG_BEEPACK:
            if (strncmp(config->nick, packet, NICK_MAXLEN)) break;
            if (!config->packet_qchat) {
                strncpy(status->nick, pars_word(), NICK_MAXLEN); 
                status->gender = pars_number();
            }
            snprintf(message, MSG_SIZE, PARS_BEEPACK, time_get(), status->nick);
            write_log(config->log_main);
            write_str(status->room->name, COL_MESG);
            break;
        default:
#ifdef  DEBUG
            fprintf(debug_file, "error: Unknown beep type.\n");
            fflush(debug_file);
#endif  /* DEBUG */
            break;
    }
}
예제 #4
0
/* Write system errnos to stdout.  The function is allowed to
   modify LINE.  Trailing white space is already removed.  Passing
   NULL resets the internal state.  */
static void
write_errnos_in (char *line)
{
  static int state;
  char *p1, *p2;

  if (!line)
    {
      state = 0;
      return;
    }

  if (!*line)
    return;

  if (!state && strchr ("0123456789", *line))
    state = 1;
  else if (state == 1 && !strchr ("0123456789", *line))
    state = 2;

  if (state != 1)
    return;

  p1 = strtok (line, " \t");
  p2 = p1? strtok (NULL, " \t") : NULL;

  if (p1 && p2 && strchr ("0123456789", *p1) && *p2)
    {
      write_str ("    GPG_ERR_");
      write_str (p2);
      write_str (" = GPG_ERR_SYSTEM_ERROR | ");
      write_str (p1);
      write_str (",\n");
    }
}
예제 #5
0
/* Write SOURCE or CODES line to stdout.  The function is allowed to
   modify LINE.  Trailing white space is already removed.  Passing
   NULL resets the internal state.  */
static void
write_sources_or_codes (char *line)
{
  static int in_intro;
  char *p1, *p2;

  if (!line)
    {
      in_intro = 1;
      return;
    }

  if (!*line)
    return;

  if (in_intro)
    {
      if (!strchr ("0123456789", *line))
        return;
      in_intro = 0;
    }

  p1 = strtok (line, " \t");
  p2 = p1? strtok (NULL, " \t") : NULL;

  if (p1 && p2 && strchr ("0123456789", *p1) && *p2)
    {
      write_str ("    ");
      write_str (p2);
      write_str (" = ");
      write_str (p1);
      write_str (",\n");
    }
}
예제 #6
0
/**
 * 主函数,显示一些东西
 * @return
 */
int main(void)
{
    uint8_t ch;
    //0. 初始化LCD
    init_lcd();
    //1. 最简单的字符输出测试 (写数据)
    set_pos(0x00);
    write_str("hello world");
    _delay_ms(100);
    //2. 读取数据测试 (读数据)
    _delay_ms(100);
    set_pos(0x06);     //设置读取的位置,第1行6列,'w'的位置
    _delay_ms(1000);
    ch = get_data();
    set_pos(0x0D);     //设置光标位置
    set_data(ch);
    _delay_ms(1000);
    //3. 自定义字符测试 (写内存+读内存)
    init_chardb();     //初始化自定义的字符集
    set_pos(0x40);     //设置在第2行还是显示
    int i;
    for ( i =0; i<0b111+1; i++) {
        set_data(i);
        //_delay_ms(50);
    }
    //4. 读取光标位置 (读地址/位置) I处即光标所在地址
    _delay_ms(1000);
    char str[5];
    set_pos(0x4a);
    ch=get_pos();
    sprintf(str,"I=%02XH",ch);
    write_str(str);
    return 0;
}
예제 #7
0
void pars_chat(void) {
    strncpy(status->channel, packet, CHANNEL_MAXLEN);
    strncpy(status->nick, pars_word(), NICK_MAXLEN);
    if (user_ignore()) return;
    if (strncmp(status->chnl[0].name, status->channel, CHANNEL_MAXLEN) &&
        !chnl_getnum()) return;
    snprintf(message, MSG_SIZE, "[%s] <%s> %s\n", time_get(), status->nick, pars_word());
#ifdef  TCP
    write_tcp(status->channel);
#endif  /* TCP */
    write_log(config->log_main);

/* SERGEJ */
if(g_show_channel)
{
    if (!strncmp(config->nick, status->nick, NICK_MAXLEN))
        write_str(status->channel, COL_MY);
    else
        write_str(status->channel, COL_CHAT);
}
/* SERGEJ */

    if ((!config->my_only || !strncmp(status->room->name, status->channel, CHANNEL_MAXLEN)) &&
        (config->mode == MOD_NORMAL)) beep_chat();
}
void ST7920_Lite_Status_Screen::draw_status_message() {
  const char *str = ui.status_message;

  set_ddram_address(DDRAM_LINE_4);
  begin_data();
  #if ENABLED(STATUS_MESSAGE_SCROLLING)

    uint8_t slen = utf8_strlen(str);

    if (slen <= LCD_WIDTH) {
      // String fits the LCD, so just print it
      write_str(str);
      for (; slen < LCD_WIDTH; ++slen) write_byte(' ');
    }
    else {
      // String is larger than the available space in screen.

      // Get a pointer to the next valid UTF8 character
      const char *stat = str + ui.status_scroll_offset;

      // Get the string remaining length
      const uint8_t rlen = utf8_strlen(stat);

      // If we have enough characters to display
      if (rlen >= LCD_WIDTH) {
        // The remaining string fills the screen - Print it
        write_str(stat, LCD_WIDTH);
      }
      else {
        // The remaining string does not completely fill the screen
        write_str(stat);                        // The string leaves space
        uint8_t chars = LCD_WIDTH - rlen;         // Amount of space left in characters

        write_byte('.');                        // Always at 1+ spaces left, draw a dot
        if (--chars) {                          // Draw a second dot if there's space
          write_byte('.');
          if (--chars)
            write_str(str, chars);              // Print a second copy of the message
        }
      }

      // Adjust by complete UTF8 characters
      if (ui.status_scroll_offset < slen) {
        ui.status_scroll_offset++;
        while (!START_OF_UTF8_CHAR(str[ui.status_scroll_offset]))
          ui.status_scroll_offset++;
      }
      else
        ui.status_scroll_offset = 0;
    }

  #else

    uint8_t slen = utf8_strlen(str);
    write_str(str, LCD_WIDTH);
    for (; slen < LCD_WIDTH; ++slen) write_byte(' ');

  #endif
}
예제 #9
0
파일: launch.c 프로젝트: Sorikairo/42sh
int	launch_not_found(t_cmd *cmd)
{
  write_str(g_fstdout, "Error: command ");
  write_str(g_fstdout, cmd->cmd);
  write_str(g_fstdout, " not found.\n");
  flush_file(g_fstdout);
  return (SIGRTN_NOTFND);
}
예제 #10
0
/*
 * Add the arcitecture suffix to the program name if needed,
 * except on Windows, where we insert it just before ".DLL".
 */
static char*
add_extra_suffixes(char *prog, int type)
{
   char *res;
   char *p;
   int len;
#ifdef __WIN32__
   char *dll_p;
   int dll = 0;
#endif

   if (!type) {
       return prog;
   }

   len = strlen(prog);

   /* Worst-case allocation */
   p = emalloc(len +
	       EMU_TYPE_SUFFIX_LENGTH +
	       + 1);
   res = p;
   p = write_str(p, prog);

#ifdef __WIN32__
   dll_p = res + len - 4;
   if (dll_p >= res) {
      if (dll_p[0] == '.' &&
	  (dll_p[1] == 'd' || dll_p[1] == 'D') &&
	  (dll_p[2] == 'l' || dll_p[2] == 'L') &&
	  (dll_p[3] == 'l' || dll_p[3] == 'L')) {
	  p = dll_p;
	  dll = 1;
      }
   }
#endif

#ifdef __WIN32__
   if (type & EMU_TYPE_DEBUG) {
       p = write_str(p, DEBUG_SUFFIX);
       type &= ~(EMU_TYPE_DEBUG);
   }
#endif
   if (type == EMU_TYPE_SMP) {
       p = write_str(p, SMP_SUFFIX);
   }
   else if (type == EMU_TYPE_HYBRID) {
       p = write_str(p, HYBRID_SUFFIX);
   }
#ifdef __WIN32__
   if (dll) {
       p = write_str(p, DLL_EXT);
   }
#endif

   return res;
}
예제 #11
0
void pars_execack(void) {
    if (strncmp(config->nick, packet, NICK_MAXLEN)) return;
    strncpy(status->nick, pars_word(), NICK_MAXLEN);
    snprintf(message, MSG_SIZE, PARS_EXECACK, time_get(), status->nick);
    write_log(config->log_main);
    write_str(status->chnl[0].name, COL_SYSTEM);
    snprintf(message, MSG_SIZE, "%s\n", pars_word());
    write_log(config->log_main);
    write_str(status->chnl[0].name, COL_SYSTEM);
}
예제 #12
0
void save_font_list(void)
{
	char *file_name = obs_module_config_path("font_data.bin");
	uint32_t font_checksum = get_font_checksum();
	int font_count = (int)font_list.num;
	struct serializer s;
	bool success = false;

	if (font_checksum)
		success = file_output_serializer_init_safe(&s, file_name,
				"tmp");
	bfree(file_name);

	if (!success)
		return;

	success = write_var(&s, font_cache_ver);
	if (!success) return;
	success = write_var(&s, font_checksum);
	if (!success) return;
	success = write_var(&s, font_count);
	if (!success) return;

#define do_write(var) \
	success = write_var(&s, var); \
	if (!success) break

	for (size_t i = 0; i < font_list.num; i++) {
		struct font_path_info *info = &font_list.array[i];

		success = write_str(&s, info->face_and_style);
		if (!success) break;

		do_write(info->full_len);
		do_write(info->face_len);
		do_write(info->is_bitmap);
		do_write(info->num_sizes);

		success = write_data(&s, info->sizes,
				sizeof(int) * info->num_sizes);
		if (!success) break;

		do_write(info->bold);

		success = write_str(&s, info->path);
		if (!success) break;

		do_write(info->italic);
		do_write(info->index);
	}

#undef do_write

	file_output_serializer_free(&s);
}
예제 #13
0
static ssize_t core_info_read(struct file *file, char __user *buf,
		size_t count, loff_t *ppos)
{
	struct msm_vidc_core *core = file->private_data;
	int i = 0;
	if (!core) {
		dprintk(VIDC_ERR, "Invalid params, core: %p\n", core);
		return 0;
	}
	INIT_DBG_BUF(dbg_buf);
	write_str(&dbg_buf, "===============================\n");
	write_str(&dbg_buf, "CORE %d: 0x%p\n", core->id, core);
	write_str(&dbg_buf, "===============================\n");
	write_str(&dbg_buf, "state: %d\n", core->state);
	write_str(&dbg_buf, "base addr: 0x%x\n", core->base_addr);
	write_str(&dbg_buf, "register_base: 0x%x\n", core->register_base);
	write_str(&dbg_buf, "register_size: %u\n", core->register_size);
	write_str(&dbg_buf, "irq: %u\n", core->irq);
	for (i = SYS_MSG_START; i < SYS_MSG_END; i++) {
		write_str(&dbg_buf, "completions[%d]: %s\n", i,
			completion_done(&core->completions[SYS_MSG_INDEX(i)]) ?
			"pending" : "done");
	}
	return simple_read_from_buffer(buf, count, ppos,
			dbg_buf.ptr, dbg_buf.filled_size);
}
예제 #14
0
void pars_exec(void) {
    strncpy(status->nick, packet, NICK_MAXLEN);
    if (user_ignore()) return;
    if (strncmp(config->nick, pars_word(), NICK_MAXLEN)) return;
    snprintf(message, MSG_SIZE, PARS_EXEC, time_get(), status->nick);
    write_log(config->log_main);
    write_str(status->room->name, COL_ERROR);
    snprintf(message, MSG_SIZE, "%s\n", pars_word());
    write_log(config->log_main);
    write_str(status->room->name, COL_ERROR);
    if (config->mode != MOD_OFF) make_execack();
}
예제 #15
0
void pars_newtopic(void) {
    if (config->packet_qchat) {
        strncpy(status->chnl[0].topic, packet, STR_SIZE);
        snprintf(message, MSG_SIZE, PARS_QTOPIC, time_get());
#ifdef  TCP
        write_tcp(status->room->name);
#endif  /* TCP */
        if (config->verbose) {
            write_log(config->log_main);
            write_str(status->room->name, COL_SYSTEM);
        }
/* SERGEJ */        validate_string(status->chnl[0].topic);
        snprintf(message, MSG_SIZE, "%s\n", status->chnl[0].topic);
#ifdef  TCP
        write_tcp(status->room->name);
#endif  /* TCP */
        if (config->verbose) {
            write_log(config->log_main);
            write_str(status->room->name, COL_SYSTEM);
        }
    } else {
        strncpy(status->channel, packet, CHANNEL_MAXLEN);
        if (strncmp(status->chnl[0].name, status->channel, CHANNEL_MAXLEN) &&
            !chnl_getnum()) return;
        strncpy(status->chnl[chnl_getnum()].topic, pars_word(), STR_SIZE);
        snprintf(message, MSG_SIZE, PARS_TOPIC, time_get(), status->channel);
#ifdef  TCP
        write_tcp(status->channel);
#endif  /* TCP */
        if (config->verbose) {
            write_log(config->log_main);
            write_str(status->channel, COL_SYSTEM);
        }
/* SERGEJ */        validate_string(status->chnl[chnl_getnum()].topic);
        snprintf(message, MSG_SIZE, "%s\n", status->chnl[chnl_getnum()].topic);
#ifdef  TCP
        write_tcp(status->channel);
#endif  /* TCP */
        if (config->verbose) {
            write_log(config->log_main);
            write_str(status->channel, COL_SYSTEM);
        }
    }
    refresh_room();
    screen_show();
    refresh_input();
    string_show();
    if ((!config->my_only || !strncmp(status->room->name, status->channel, CHANNEL_MAXLEN)) &&
        (config->mode == MOD_NORMAL)) beep_system();
}
예제 #16
0
void StarDictClient::request_command()
{
    reading_type_ = READ_LINE;
    if (cmdlist.empty()) {
        cmdlist.push_back(new STARDICT::Cmd(STARDICT::CMD_QUIT));
    }
    STARDICT::Cmd *c = cmdlist.front();
	switch (c->command) {
        case STARDICT::CMD_AUTH:
		{
			struct MD5Context ctx;
			unsigned char digest[16];
			char hex[33];
			int i;
			MD5Init(&ctx);
			MD5Update(&ctx, (const unsigned char*)cmd_reply.daemonStamp.c_str(), cmd_reply.daemonStamp.length());
			MD5Update(&ctx, (const unsigned char*)(c->auth->md5saltpasswd.c_str()), c->auth->md5saltpasswd.length());
			MD5Final(digest, &ctx );
			for (i = 0; i < 16; i++)
				sprintf( hex+2*i, "%02x", digest[i] );
			hex[32] = '\0';
			std::string earg1, earg2;
			arg_escape(earg1, c->auth->user.c_str());
			arg_escape(earg2, hex);
			char *data = g_strdup_printf("auth %s %s\n", earg1.c_str(), earg2.c_str());
            GError *err = NULL;
            write_str(data, &err);
			g_free(data);
			if (err) {
                on_error_.emit(err->message);
                g_error_free(err);
				return;
			}
			break;
		}
		default:
        {
            GError *err = NULL;
            write_str(c->data, &err);
			if (err) {
                on_error_.emit(err->message);
                g_error_free(err);
				return;
            }
			break;
        }
	}
	return;
}
void write(adt_type& tok_str, token tok) {
	if (tok.kind == tk_err) {
		write_str(tok_str, "<error token>");
	} else if (tok.kind == tk_eof) {
		write_str(tok_str, "<end of file>");
	} else if (tok.kind == tk_special) {
		write(tok_str, tok.special_id);
	} else if (tok.kind == tk_uint) {
		write_char(tok_str, '#');
		write_uint(tok_str, tok.uint_val);
	} else {
		fox_assert(tok.kind == tk_name && "invalid token kind");
		write_str(tok_str, tok.str_val);
	}
}
예제 #18
0
void		param_error(int err_id, int line)
{
  char		*line_str;
  int		size;

  size = get_param_error_size();
  if (err_id < 0 || err_id >= size)
    err_id = 0;
  write_str(g_fstdout, "Error line ");
  line_str = utl_itoa(line);
  write_str(g_fstdout, line_str);
  free(line_str);
  write_str(g_fstdout, ": ");
  write_str(g_fstdout, g_param_error[err_id]);
  flush_file(g_fstdout);
}
예제 #19
0
/*
 * Multiple CP commands can be specified via "vmcmd XY1 vmcmd XY2 ..."
 */
static void vmcmd_set(struct shutdown_trigger *st, int argc, char *argv[])
{
	char vmcmd[1024], path[PATH_MAX];
	int first = 1, i;
	int vmcmd_length = 0;

	if (is_lpar())
		ERR_EXIT("vmcmd works only under z/VM");
	memset(vmcmd, 0, sizeof(vmcmd));
	for (i = 2; i < argc; i++) {
		if (strcmp(argv[i], "vmcmd") != 0)
			ERR_EXIT("Invalid vmcmd command specification");
		if (i == argc - 1)
			ERR_EXIT("vmcmd needs an additional argument");
		if (!first) {
			strcat(vmcmd, "\n");
			vmcmd_length++;
		} else {
			first = 0;
		}
		vmcmd_length += strlen(argv[i + 1]);
		if (vmcmd_length >= 127)
			ERR_EXIT("The vmcmd command must not exceed 127 "
				 "characters");

		strcat(vmcmd, argv[i + 1]);
		i++;
	}

	sprintf(path, "vmcmd/%s", st->name_sysfs);
	write_str(vmcmd, path);
}
예제 #20
0
static void to_echo(void)
{
	/* if server requests ECHO, don't agree */
	if (G.telwish == DO) {
		putiac2(WONT, TELOPT_ECHO);
		return;
	}
	if (G.telwish == DONT)
		return;

	if (G.telflags & UF_ECHO) {
		if (G.telwish == WILL)
			return;
	} else if (G.telwish == WONT)
		return;

	if (G.charmode != CHM_OFF)
		G.telflags ^= UF_ECHO;

	if (G.telflags & UF_ECHO)
		putiac2(DO, TELOPT_ECHO);
	else
		putiac2(DONT, TELOPT_ECHO);

	setConMode();
	write_str(1, "\r\n");  /* sudden modec */
}
예제 #21
0
bool HttpClient::SendGetRequest()
{
	std::string request;

	request += "GET HTTP://";
	request += host_;
	request += file_;
	request += " HTTP/1.1\r\n";

	request += "User-Agent: Mozilla/4.0(compatible;MSIE 5.00;Windows 98)\r\n";
	request += "Accept: */*\r\n";

	request += "Host: ";
	request += host_;
	request += "\r\n";

	request += "Connection: close\r\n\r\n";
	
	GError *err = NULL;
	write_str(request.c_str(), &err);
	if (err) {
		on_error_.emit(this, err->message);
		g_error_free(err);
		return true;
	}
	return false;
}
예제 #22
0
파일: netpbm.hpp 프로젝트: hcab14/HFMonitor
 void update_height() {
   if (not need_height_update_) return;
   os_.seekp(height_pos_, std::ios::beg);
   write_str(str(boost::format(" %9d\n")  % height_));
   os_.seekp(0, std::ios::end);
   need_height_update_= false;
 }
예제 #23
0
void pars_privat(void) {
    int privat;

    privat = pars_number();
    strncpy(status->nick, packet, NICK_MAXLEN);
    if (user_ignore()) return;
    strncpy(status->channel, packet, NICK_MAXLEN);
    if (!strncmp(config->nick, status->nick, NICK_MAXLEN))
        strncpy(status->channel, pars_word(), NICK_MAXLEN);
    else if (strncmp(config->nick, pars_word(), NICK_MAXLEN)) return;
    switch (privat) {
        case MSG_PRIVATJOIN:
            if (!config->packet_qchat) {
                pars_word(); status->gender = pars_number();
            }
            chat_join();
            break;
        case MSG_PRIVATLEAVE:
            if (!config->packet_qchat) {
                pars_word(); status->gender = pars_number();
            }
            chat_leave();
            break;
        case MSG_PRIVATCHAT:
            chat_rejoin();
            snprintf(message, MSG_SIZE, "<%s> %s\n", status->nick, pars_word());
            write_log(config->log_priv);
            write_str(status->channel, COL_CHAT);
            if ((!config->my_only || !strncmp(status->room->name, status->channel, CHANNEL_MAXLEN)) &&
                (config->mode == MOD_NORMAL)) beep_chat();
            break;
        case MSG_PRIVATME:
            chat_rejoin();
            snprintf(message, MSG_SIZE, " * %s %s\n", status->nick, pars_word());
            write_log(config->log_priv);
            write_str(status->channel, COL_CHAT);
            if ((!config->my_only || !strncmp(status->room->name, status->channel, CHANNEL_MAXLEN)) &&
                (config->mode == MOD_NORMAL)) beep_chat();
            break;
        default:
#ifdef  DEBUG
            fprintf(debug_file, "error: Unknown private type.\n");
            fflush(debug_file);
#endif  /* DEBUG */
            break;
    }
}
예제 #24
0
static void conescape(void)
{
	char b;

	if (G.gotsig)	/* came from line  mode... go raw */
		rawmode();

	write_str(1, "\r\nConsole escape. Commands are:\r\n\n"
			" l	go to line mode\r\n"
			" c	go to character mode\r\n"
			" z	suspend telnet\r\n"
			" e	exit telnet\r\n");

	if (read(STDIN_FILENO, &b, 1) <= 0)
		doexit(EXIT_FAILURE);

	switch (b) {
	case 'l':
		if (!G.gotsig) {
			do_linemode();
			goto rrturn;
		}
		break;
	case 'c':
		if (G.gotsig) {
			will_charmode();
			goto rrturn;
		}
		break;
	case 'z':
		cookmode();
		kill(0, SIGTSTP);
		rawmode();
		break;
	case 'e':
		doexit(EXIT_SUCCESS);
	}

	write_str(1, "continuing...\r\n");

	if (G.gotsig)
		cookmode();

 rrturn:
	G.gotsig = 0;

}
예제 #25
0
void send_billinginfo_request(void)
{
    unsigned char packetbuff[4096], *p;
    p = packetbuff;
    *p++ = 0x4c;
    *p++ = 0x01;
    *p++ = 0x02;
    write_str(&p, "Account closed.");
    *p++ = 0x01;
    *p++ = 0xff;
    *p++ = 0x55;
    write_str(&p, "0.0.0.0");
    *p++ = 0x00;
    *p++ = 0x00;
    send_daoc_packet(0x00c8, packetbuff, p - packetbuff);
    printf("Requesting user enter their billing info...\n");
}
예제 #26
0
static void clear_line(void)
{
	if (global_profile->batch_mode) return;
	if (!(write_char('\r'))) goto done;
	if (!(write_str("\033[K"))) goto done;
 done:
	return;
}
예제 #27
0
void
diff_write_commit(const char* zone, uint32_t old_serial,
	uint32_t new_serial, uint16_t id, uint32_t num_parts,
	uint8_t commit, const char* log_str, nsd_options_t* opt)
{
	const char* filename = opt->difffile;
	struct timeval tv;
	FILE *df;
	uint32_t len;

	if (gettimeofday(&tv, NULL) != 0) {
		log_msg(LOG_ERR, "could not set timestamp for %s: %s",
			filename, strerror(errno));
		return;
	}

	df = fopen(filename, "a");
	if(!df) {
		log_msg(LOG_ERR, "could not open file %s for append: %s",
			filename, strerror(errno));
		return;
	}

	len = strlen(zone) + sizeof(len) + sizeof(old_serial) +
		sizeof(new_serial) + sizeof(id) + sizeof(num_parts) +
		sizeof(commit) + strlen(log_str) + sizeof(len);

	if(!write_32(df, DIFF_PART_SURE) ||
		!write_32(df, (uint32_t) tv.tv_sec) ||
		!write_32(df, (uint32_t) tv.tv_usec) ||
		!write_32(df, len) ||
		!write_str(df, zone) ||
		!write_32(df, old_serial) ||
		!write_32(df, new_serial) ||
		!write_16(df, id) ||
		!write_32(df, num_parts) ||
		!write_8(df, commit) ||
		!write_str(df, log_str) ||
		!write_32(df, len))
	{
		log_msg(LOG_ERR, "could not write to file %s: %s",
			filename, strerror(errno));
	}
	fflush(df);
	fclose(df);
}
예제 #28
0
파일: io.c 프로젝트: Henningstone/libsrsirc
/* Documented in io.h */
bool
lsi_io_write(sckhld sh, const char *line)
{
	size_t len = strlen(line);
	int needbr = len < 2 || line[len-2] != '\r' || line[len-1] != '\n';

	V("Wanna write: '%s%s'", line, needbr ? "\r\n" : "");

	bool suc = write_str(sh, line) && (!needbr || write_str(sh, "\r\n"));

	if (suc)
		I("Wrote: '%s%s'", line, needbr ? "\r\n" : "");
	else
		W("Failed to write '%s%s'", line, needbr ? "\r\n" : "");

	return suc;
}
예제 #29
0
파일: wait_proc.c 프로젝트: Sorikairo/42sh
static void	print_sigmsg(int signal, int coredump)
{
  int		it;

  it = 0;
  while (g_sigmsg[it].sig)
    {
      if (g_sigmsg[it].sig == signal)
	{
	  write_str(g_fstdout, g_sigmsg[it].msg);
	  if (coredump)
	    write_str(g_fstdout, " (core dumped)");
	  write_char(g_fstdout, '\n');
	  flush_file(g_fstdout);
	}
      it++;
    }
}
예제 #30
0
파일: pf_p.c 프로젝트: gbourgeo/42projects
static void	print_ox(t_dt *data, t_av *av)
{
	size_t	len;

	len = (data->flag.precision > av->len) ? data->flag.precision : av->len;
	if (!data->flag.minus)
	{
		if (data->flag.min_width <= len + 2 || data->flag.zero)
			write_str(data, "0x", 2);
		while (data->flag.min_width > len + 2 && len++)
			write_char(data, (data->flag.zero) ? '0' : ' ');
		len = (data->flag.precision > av->len) ? data->flag.precision : av->len;
		if (data->flag.min_width > len + 2 && !data->flag.zero)
			write_str(data, "0x", 2);
	}
	else
		write_str(data, "0x", 2);
}