コード例 #1
0
ファイル: chat.c プロジェクト: AoLaD/rtems
static int put_string (
  char *s)
{
	char *out,*free_ptr=0;
	
    quiet = 0;
    out = free_ptr = clean(s, 1);
    while (*out) {
		register char c = *out++;

		if (c != '\\') {
	    	if (!write_char (c)){
	    		free(free_ptr);
				return 0;
			}
	    	continue;
		}

		c = *out++;

		switch (c) {
			case 'd':
	    		sleep(1);
		    break;

			case 'K':
	    		break_sequence();
	    	break;

			case 'p':
#if 0 /* FIXME!!! */
	    		usleep(10000); 	/* 1/100th of a second (arg is microseconds) */
#else
	    		sleep(1);
#endif
	    	break;

			default:
	    		if (!write_char (c)){
	    			free(free_ptr);
					return 0;
				}
	    	break;
		}
    }
    free(free_ptr);

    return (1);
}
コード例 #2
0
ファイル: chat.c プロジェクト: 2asoft/freebsd
int
put_string(char *s)
{
    quiet = 0;
    s = clean(s, 1);

    if (verbose)
        chat_logf("send (%v)", quiet ? "??????" : s);

    alarm(timeout); alarmed = 0;

    while (*s) {
	char c = *s++;

	if (c != '\\') {
	    if (!write_char (c))
		return 0;
	    continue;
	}

	c = *s++;
	switch (c) {
	case 'd':
	    sleep(1);
	    break;

	case 'K':
	    break_sequence();
	    break;

	case 'p':
	    usleep(10000); 	/* 1/100th of a second (arg is microseconds) */
	    break;

	default:
	    if (!write_char (c))
		return 0;
	    break;
	}
    }

    alarm(0);
    alarmed = 0;
    return (1);
}