Beispiel #1
0
int
fd_readline (int fdi, int fdo, char *b, int bsz)
{
    int r;
    unsigned char c;
    unsigned char *bp, *bpe;
    
    bp = (unsigned char *)b;
    bpe = (unsigned char *)b + bsz - 1;

    while (1) {
        r = read(fdi, &c, 1);
        if ( r <= 0 ) { r = -1; goto out; }

        switch (c) {
        case '\b':
        case '\x7f':
            if ( bp > (unsigned char *)b ) { 
                bp--;
                if ( isprint(*bp) ) 
                    cdel(fdo);
                else 
                    xdel(fdo);
            } else {
                cput(fdo, '\x07');
            }
            break;
        case '\x03': /* CTRL-c */
            r = -1;
            errno = EINTR;
            goto out;
        case '\r':
            *bp = '\0';
            r = bp - (unsigned char *)b; 
            goto out;
        default:
            if ( bp < bpe ) { 
                *bp++ = c;
                if ( isprint(c) ) 
                    cput(fdo, c); 
                else 
                    xput(fdo, c);
            } else { 
                cput(fdo, '\x07'); 
            }
            break;
        }
    }

out:
    return r;
}
Beispiel #2
0
/* -------------------------------------------------------------------------------------
// sdyALShutdown
//------------------------------------------------------------------------------------- */
void SDYAPI sdyALShutdown(void)
{
	SDY_SOUND* pSound;
	CONT_ITEM* i;
	
	assert(g_cAudLines);
	
	if(g_cAudLines)
	{
		i = cfirst(g_cAudLines);
		while(i)
		{
			pSound = (SDY_SOUND*)cidata(i);
			i = cinext(i);
			_sdyALPop(pSound);
		}
		cdel(g_cAudLines);
		g_cAudLines = 0;
	}
	
	sdyManShutdown();
}