示例#1
0
URL url_buff_open(URL url, int autoclose)
{
    URL_buff *urlp;

    if((urlp = (URL_buff *)alloc_url(sizeof(URL_buff))) == NULL)
    {
	if(autoclose)
	    url_close(url);
	return NULL;
    }

    /* common members */
    URLm(urlp, type)	  = URL_buff_t;
    URLm(urlp, url_read)  = url_buff_read;
    URLm(urlp, url_gets)  = url_buff_gets;
    URLm(urlp, url_fgetc) = url_buff_fgetc;
    URLm(urlp, url_seek)  = url_buff_seek;
    URLm(urlp, url_tell)  = url_buff_tell;
    URLm(urlp, url_close) = url_buff_close;

    /* private members */
    urlp->reader = url;
    memset(urlp->buffer, 0, sizeof(urlp->buffer));
    urlp->wp = 0;
    urlp->rp = 0;
    if((urlp->posofs = url_tell(url)) == -1)
	urlp->posofs = 0;
    urlp->pos = 0;
    urlp->eof = 0;
    urlp->autoclose = autoclose;

    return (URL)urlp;
}
示例#2
0
long tf_tell(struct timidity_file *tf)
{
    long pos;

    pos = url_tell(tf->url);
    if(pos == -1)
    {
	ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
		  "Warning: Can't get current file position");
	return (long)tf->url->nread;
    }

    return pos;
}